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 | 3969fdf | 2017-08-29 15:50:58 -0400 | [diff] [blame] | 141 | garbageCertificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 142 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 143 | |
| 144 | var testCerts = []struct { |
| 145 | id testCert |
| 146 | certFile, keyFile string |
| 147 | cert *Certificate |
| 148 | }{ |
| 149 | { |
| 150 | id: testCertRSA, |
| 151 | certFile: rsaCertificateFile, |
| 152 | keyFile: rsaKeyFile, |
| 153 | cert: &rsaCertificate, |
| 154 | }, |
| 155 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 156 | id: testCertRSA1024, |
| 157 | certFile: rsa1024CertificateFile, |
| 158 | keyFile: rsa1024KeyFile, |
| 159 | cert: &rsa1024Certificate, |
| 160 | }, |
| 161 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 162 | id: testCertRSAChain, |
| 163 | certFile: rsaChainCertificateFile, |
| 164 | keyFile: rsaChainKeyFile, |
| 165 | cert: &rsaChainCertificate, |
| 166 | }, |
| 167 | { |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 168 | id: testCertECDSAP224, |
| 169 | certFile: ecdsaP224CertificateFile, |
| 170 | keyFile: ecdsaP224KeyFile, |
| 171 | cert: &ecdsaP224Certificate, |
| 172 | }, |
| 173 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 174 | id: testCertECDSAP256, |
| 175 | certFile: ecdsaP256CertificateFile, |
| 176 | keyFile: ecdsaP256KeyFile, |
| 177 | cert: &ecdsaP256Certificate, |
| 178 | }, |
| 179 | { |
| 180 | id: testCertECDSAP384, |
| 181 | certFile: ecdsaP384CertificateFile, |
| 182 | keyFile: ecdsaP384KeyFile, |
| 183 | cert: &ecdsaP384Certificate, |
| 184 | }, |
| 185 | { |
| 186 | id: testCertECDSAP521, |
| 187 | certFile: ecdsaP521CertificateFile, |
| 188 | keyFile: ecdsaP521KeyFile, |
| 189 | cert: &ecdsaP521Certificate, |
| 190 | }, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 191 | { |
| 192 | id: testCertEd25519, |
| 193 | certFile: ed25519CertificateFile, |
| 194 | keyFile: ed25519KeyFile, |
| 195 | cert: &ed25519Certificate, |
| 196 | }, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 197 | } |
| 198 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 199 | var channelIDKey *ecdsa.PrivateKey |
| 200 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 201 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 202 | var testOCSPResponse = []byte{1, 2, 3, 4} |
David Benjamin | 5c4271f | 2017-08-23 22:09:41 -0700 | [diff] [blame] | 203 | var testOCSPResponse2 = []byte{5, 6, 7, 8} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 204 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 5c4271f | 2017-08-23 22:09:41 -0700 | [diff] [blame] | 205 | var testSCTList2 = []byte{0, 6, 0, 4, 1, 2, 3, 4} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 206 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 207 | 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] | 208 | 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] | 209 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 210 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 211 | for i := range testCerts { |
| 212 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 213 | if err != nil { |
| 214 | panic(err) |
| 215 | } |
| 216 | cert.OCSPStaple = testOCSPResponse |
| 217 | cert.SignedCertificateTimestampList = testSCTList |
| 218 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 219 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 220 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 221 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 222 | if err != nil { |
| 223 | panic(err) |
| 224 | } |
| 225 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 226 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 227 | panic("bad key type") |
| 228 | } |
| 229 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 230 | if err != nil { |
| 231 | panic(err) |
| 232 | } |
| 233 | if channelIDKey.Curve != elliptic.P256() { |
| 234 | panic("bad curve") |
| 235 | } |
| 236 | |
| 237 | channelIDBytes = make([]byte, 64) |
| 238 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 239 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
David Benjamin | 3969fdf | 2017-08-29 15:50:58 -0400 | [diff] [blame] | 240 | |
| 241 | garbageCertificate.Certificate = [][]byte{[]byte("GARBAGE")} |
| 242 | garbageCertificate.PrivateKey = rsaCertificate.PrivateKey |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 243 | } |
| 244 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 245 | func getRunnerCertificate(t testCert) Certificate { |
| 246 | for _, cert := range testCerts { |
| 247 | if cert.id == t { |
| 248 | return *cert.cert |
| 249 | } |
| 250 | } |
| 251 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 252 | } |
| 253 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 254 | func getShimCertificate(t testCert) string { |
| 255 | for _, cert := range testCerts { |
| 256 | if cert.id == t { |
| 257 | return cert.certFile |
| 258 | } |
| 259 | } |
| 260 | panic("Unknown test certificate") |
| 261 | } |
| 262 | |
| 263 | func getShimKey(t testCert) string { |
| 264 | for _, cert := range testCerts { |
| 265 | if cert.id == t { |
| 266 | return cert.keyFile |
| 267 | } |
| 268 | } |
| 269 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 272 | // recordVersionToWire maps a record-layer protocol version to its wire |
| 273 | // representation. |
| 274 | func recordVersionToWire(vers uint16, protocol protocol) uint16 { |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 275 | if protocol == dtls { |
| 276 | switch vers { |
| 277 | case VersionTLS12: |
| 278 | return VersionDTLS12 |
| 279 | case VersionTLS10: |
| 280 | return VersionDTLS10 |
| 281 | } |
| 282 | } else { |
| 283 | switch vers { |
| 284 | case VersionSSL30, VersionTLS10, VersionTLS11, VersionTLS12: |
| 285 | return vers |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | |
| 289 | panic("unknown version") |
| 290 | } |
| 291 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 292 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 293 | func encodeDERValues(values [][]byte) string { |
| 294 | var ret string |
| 295 | for i, v := range values { |
| 296 | if i > 0 { |
| 297 | ret += "," |
| 298 | } |
| 299 | ret += hex.EncodeToString(v) |
| 300 | } |
| 301 | |
| 302 | return ret |
| 303 | } |
| 304 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 305 | type testType int |
| 306 | |
| 307 | const ( |
| 308 | clientTest testType = iota |
| 309 | serverTest |
| 310 | ) |
| 311 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 312 | type protocol int |
| 313 | |
| 314 | const ( |
| 315 | tls protocol = iota |
| 316 | dtls |
| 317 | ) |
| 318 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 319 | const ( |
| 320 | alpn = 1 |
| 321 | npn = 2 |
| 322 | ) |
| 323 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 324 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 325 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 326 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 327 | name string |
| 328 | config Config |
| 329 | shouldFail bool |
| 330 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 331 | // expectedLocalError, if not empty, contains a substring that must be |
| 332 | // found in the local error. |
| 333 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 334 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 335 | // negotiated. |
| 336 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 337 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 338 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 339 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 340 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 341 | // should be negotiated. |
| 342 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 343 | // expectChannelID controls whether the connection should have |
| 344 | // negotiated a Channel ID with channelIDKey. |
| 345 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 346 | // expectedNextProto controls whether the connection should |
| 347 | // negotiate a next protocol via NPN or ALPN. |
| 348 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 349 | // expectNoNextProto, if true, means that no next protocol should be |
| 350 | // negotiated. |
| 351 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 352 | // expectedNextProtoType, if non-zero, is the expected next |
| 353 | // protocol negotiation mechanism. |
| 354 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 355 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 356 | // should be negotiated. If zero, none should be negotiated. |
| 357 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 358 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 359 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 360 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 361 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 362 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 363 | // algorithm that the peer should have used in the handshake. |
| 364 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 365 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 366 | // have used. |
| 367 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 368 | // messageLen is the length, in bytes, of the test message that will be |
| 369 | // sent. |
| 370 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 371 | // messageCount is the number of test messages that will be sent. |
| 372 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 373 | // certFile is the path to the certificate to use for the server. |
| 374 | certFile string |
| 375 | // keyFile is the path to the private key to use for the server. |
| 376 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 377 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 378 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 379 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 380 | // resumeRenewedSession controls whether a third connection should be |
| 381 | // tested which attempts to resume the second connection's session. |
| 382 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 383 | // expectResumeRejected, if true, specifies that the attempted |
| 384 | // resumption must be rejected by the client. This is only valid for a |
| 385 | // serverTest. |
| 386 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 387 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 388 | // resumption. Unless newSessionsOnResume is set, |
| 389 | // SessionTicketKey, ServerSessionCache, and |
| 390 | // ClientSessionCache are copied from the initial connection's |
| 391 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 392 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 393 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 394 | // use a different session resumption context. |
| 395 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 396 | // noSessionCache, if true, will cause the server to run without a |
| 397 | // session cache. |
| 398 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 399 | // sendPrefix sends a prefix on the socket before actually performing a |
| 400 | // handshake. |
| 401 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 402 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 403 | // message before doing a roundtrip with the runner. |
| 404 | shimWritesFirst bool |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 405 | // readWithUnfinishedWrite behaves like shimWritesFirst, but the shim |
| 406 | // does not complete the write until responding to the first runner |
| 407 | // message. |
| 408 | readWithUnfinishedWrite bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 409 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 410 | // connection immediately after the handshake rather than echoing |
| 411 | // messages from the runner. |
| 412 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 413 | // renegotiate indicates the number of times the connection should be |
| 414 | // renegotiated during the exchange. |
| 415 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 416 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 417 | // HelloRequest when the handshake completes. |
| 418 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 419 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 420 | // switched in just before renegotiation. |
| 421 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 422 | // replayWrites, if true, configures the underlying transport |
| 423 | // to replay every write it makes in DTLS tests. |
| 424 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 425 | // damageFirstWrite, if true, configures the underlying transport to |
| 426 | // damage the final byte of the first application data write. |
| 427 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 428 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 429 | // keying material and verify they match. |
| 430 | exportKeyingMaterial int |
| 431 | exportLabel string |
| 432 | exportContext string |
| 433 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 434 | // flags, if not empty, contains a list of command-line flags that will |
| 435 | // be passed to the shim program. |
| 436 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 437 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 438 | // which will be compared against the expected value. |
| 439 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 440 | // sendEmptyRecords is the number of consecutive empty records to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 441 | // before each test message. |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 442 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 443 | // sendWarningAlerts is the number of consecutive warning alerts to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 444 | // before each test message. |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 445 | sendWarningAlerts int |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 446 | // sendBogusAlertType, if true, causes a bogus alert of invalid type to |
| 447 | // be sent before each test message. |
| 448 | sendBogusAlertType bool |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 449 | // sendKeyUpdates is the number of consecutive key updates to send |
| 450 | // before and after the test message. |
| 451 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 452 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 453 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 454 | // expectMessageDropped, if true, means the test message is expected to |
| 455 | // be dropped by the client rather than echoed back. |
| 456 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 457 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 458 | // is expected to send. |
| 459 | expectPeerCertificate *Certificate |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 460 | // shimPrefix is the prefix that the shim will send to the server. |
| 461 | shimPrefix string |
| 462 | // resumeShimPrefix is the prefix that the shim will send to the server on a |
| 463 | // resumption. |
| 464 | resumeShimPrefix string |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 465 | // tls13Variant, if non-zero, causes both runner and shim to be |
| 466 | // configured with the specified TLS 1.3 variant. This is a convenience |
| 467 | // option for configuring both concurrently. |
| 468 | tls13Variant int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 471 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 472 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 473 | func writeTranscript(test *testCase, path string, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 474 | if len(data) == 0 { |
| 475 | return |
| 476 | } |
| 477 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 478 | settings, err := ioutil.ReadFile(path) |
| 479 | if err != nil { |
| 480 | fmt.Fprintf(os.Stderr, "Error reading %s: %s.\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | return |
| 482 | } |
| 483 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 484 | settings = append(settings, data...) |
| 485 | if err := ioutil.WriteFile(path, settings, 0644); err != nil { |
| 486 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 487 | } |
| 488 | } |
| 489 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 490 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 491 | type timeoutConn struct { |
| 492 | net.Conn |
| 493 | timeout time.Duration |
| 494 | } |
| 495 | |
| 496 | func (t *timeoutConn) Read(b []byte) (int, error) { |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 497 | if !*useGDB { |
| 498 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 499 | return 0, err |
| 500 | } |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 501 | } |
| 502 | return t.Conn.Read(b) |
| 503 | } |
| 504 | |
| 505 | func (t *timeoutConn) Write(b []byte) (int, error) { |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 506 | if !*useGDB { |
| 507 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 508 | return 0, err |
| 509 | } |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 510 | } |
| 511 | return t.Conn.Write(b) |
| 512 | } |
| 513 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 514 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, transcriptPrefix string, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 515 | if !test.noSessionCache { |
| 516 | if config.ClientSessionCache == nil { |
| 517 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 518 | } |
| 519 | if config.ServerSessionCache == nil { |
| 520 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 521 | } |
| 522 | } |
| 523 | if test.testType == clientTest { |
| 524 | if len(config.Certificates) == 0 { |
| 525 | config.Certificates = []Certificate{rsaCertificate} |
| 526 | } |
| 527 | } else { |
| 528 | // Supply a ServerName to ensure a constant session cache key, |
| 529 | // rather than falling back to net.Conn.RemoteAddr. |
| 530 | if len(config.ServerName) == 0 { |
| 531 | config.ServerName = "test" |
| 532 | } |
| 533 | } |
| 534 | if *fuzzer { |
| 535 | config.Bugs.NullAllCiphers = true |
| 536 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 537 | if *deterministic { |
| 538 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 539 | } |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 540 | if test.tls13Variant != 0 { |
| 541 | config.TLS13Variant = test.tls13Variant |
| 542 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 543 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 544 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 545 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 546 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 547 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 548 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 549 | } |
| 550 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 551 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 552 | local, peer := "client", "server" |
| 553 | if test.testType == clientTest { |
| 554 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 555 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 556 | connDebug := &recordingConn{ |
| 557 | Conn: conn, |
| 558 | isDatagram: test.protocol == dtls, |
| 559 | local: local, |
| 560 | peer: peer, |
| 561 | } |
| 562 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 563 | if *flagDebug { |
| 564 | defer connDebug.WriteTo(os.Stdout) |
| 565 | } |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 566 | if len(transcriptPrefix) != 0 { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 567 | defer func() { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 568 | path := transcriptPrefix + strconv.Itoa(num) |
| 569 | writeTranscript(test, path, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 570 | }() |
| 571 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 572 | |
| 573 | if config.Bugs.PacketAdaptor != nil { |
| 574 | config.Bugs.PacketAdaptor.debug = connDebug |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | if test.replayWrites { |
| 579 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 580 | } |
| 581 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 582 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 583 | if test.damageFirstWrite { |
| 584 | connDamage = newDamageAdaptor(conn) |
| 585 | conn = connDamage |
| 586 | } |
| 587 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 588 | if test.sendPrefix != "" { |
| 589 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 590 | return err |
| 591 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 592 | } |
| 593 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 594 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 595 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 596 | if test.protocol == dtls { |
| 597 | tlsConn = DTLSServer(conn, config) |
| 598 | } else { |
| 599 | tlsConn = Server(conn, config) |
| 600 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 601 | } else { |
| 602 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 603 | if test.protocol == dtls { |
| 604 | tlsConn = DTLSClient(conn, config) |
| 605 | } else { |
| 606 | tlsConn = Client(conn, config) |
| 607 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 608 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 609 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 610 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 611 | if err := tlsConn.Handshake(); err != nil { |
| 612 | return err |
| 613 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 614 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 615 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 616 | // expectations struct that can be specified separately for the two |
| 617 | // legs. |
| 618 | expectedVersion := test.expectedVersion |
| 619 | if isResume && test.expectedResumeVersion != 0 { |
| 620 | expectedVersion = test.expectedResumeVersion |
| 621 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 622 | connState := tlsConn.ConnectionState() |
| 623 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 624 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 625 | } |
| 626 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 627 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 628 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 629 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 630 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 631 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 632 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 633 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 634 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 635 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 636 | if channelID == nil { |
| 637 | return fmt.Errorf("no channel ID negotiated") |
| 638 | } |
| 639 | if channelID.Curve != channelIDKey.Curve || |
| 640 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 641 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 642 | return fmt.Errorf("incorrect channel ID") |
| 643 | } |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 644 | } else if connState.ChannelID != nil { |
| 645 | return fmt.Errorf("channel ID unexpectedly negotiated") |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 646 | } |
| 647 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 648 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 649 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 650 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 651 | } |
| 652 | } |
| 653 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 654 | if test.expectNoNextProto { |
| 655 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 656 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 657 | } |
| 658 | } |
| 659 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 660 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 661 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 662 | return fmt.Errorf("next proto type mismatch") |
| 663 | } |
| 664 | } |
| 665 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 666 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 667 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 668 | } |
| 669 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 670 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 671 | 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] | 672 | } |
| 673 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 674 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 675 | return fmt.Errorf("SCT list mismatch") |
| 676 | } |
| 677 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 678 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 679 | 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] | 680 | } |
| 681 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 682 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 683 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 684 | } |
| 685 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 686 | if test.expectPeerCertificate != nil { |
| 687 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 688 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 689 | } |
| 690 | for i, cert := range connState.PeerCertificates { |
| 691 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 692 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 693 | } |
| 694 | } |
| 695 | } |
| 696 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 697 | if test.exportKeyingMaterial > 0 { |
| 698 | actual := make([]byte, test.exportKeyingMaterial) |
| 699 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 700 | return err |
| 701 | } |
| 702 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 703 | if err != nil { |
| 704 | return err |
| 705 | } |
| 706 | if !bytes.Equal(actual, expected) { |
| 707 | return fmt.Errorf("keying material mismatch") |
| 708 | } |
| 709 | } |
| 710 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 711 | if test.testTLSUnique { |
| 712 | var peersValue [12]byte |
| 713 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 714 | return err |
| 715 | } |
| 716 | expected := tlsConn.ConnectionState().TLSUnique |
| 717 | if !bytes.Equal(peersValue[:], expected) { |
| 718 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 719 | } |
| 720 | } |
| 721 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 722 | if test.sendHalfHelloRequest { |
| 723 | tlsConn.SendHalfHelloRequest() |
| 724 | } |
| 725 | |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 726 | shimPrefix := test.shimPrefix |
| 727 | if isResume { |
| 728 | shimPrefix = test.resumeShimPrefix |
| 729 | } |
| 730 | if test.shimWritesFirst || test.readWithUnfinishedWrite { |
| 731 | shimPrefix = "hello" |
| 732 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 733 | if test.renegotiate > 0 { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 734 | // If readWithUnfinishedWrite is set, the shim prefix will be |
| 735 | // available later. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 736 | if shimPrefix != "" && !test.readWithUnfinishedWrite { |
| 737 | var buf = make([]byte, len(shimPrefix)) |
| 738 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 739 | if err != nil { |
| 740 | return err |
| 741 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 742 | if string(buf) != shimPrefix { |
| 743 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 744 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 745 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 746 | } |
| 747 | |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 748 | if test.renegotiateCiphers != nil { |
| 749 | config.CipherSuites = test.renegotiateCiphers |
| 750 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 751 | for i := 0; i < test.renegotiate; i++ { |
| 752 | if err := tlsConn.Renegotiate(); err != nil { |
| 753 | return err |
| 754 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 755 | } |
| 756 | } else if test.renegotiateCiphers != nil { |
| 757 | panic("renegotiateCiphers without renegotiate") |
| 758 | } |
| 759 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 760 | if test.damageFirstWrite { |
| 761 | connDamage.setDamage(true) |
| 762 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 763 | connDamage.setDamage(false) |
| 764 | } |
| 765 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 766 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 767 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 768 | if test.protocol == dtls { |
| 769 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 770 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 771 | // Read until EOF. |
| 772 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 773 | return err |
| 774 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 775 | if messageLen == 0 { |
| 776 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 777 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 778 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 779 | messageCount := test.messageCount |
| 780 | if messageCount == 0 { |
| 781 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 782 | } |
| 783 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 784 | for j := 0; j < messageCount; j++ { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 785 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 786 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 787 | } |
| 788 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 789 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 790 | tlsConn.Write(nil) |
| 791 | } |
| 792 | |
| 793 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 794 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 795 | } |
| 796 | |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 797 | if test.sendBogusAlertType { |
| 798 | tlsConn.SendAlert(0x42, alertUnexpectedMessage) |
| 799 | } |
| 800 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 801 | testMessage := make([]byte, messageLen) |
| 802 | for i := range testMessage { |
| 803 | testMessage[i] = 0x42 ^ byte(j) |
| 804 | } |
| 805 | tlsConn.Write(testMessage) |
| 806 | |
| 807 | // Consume the shim prefix if needed. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 808 | if shimPrefix != "" { |
| 809 | var buf = make([]byte, len(shimPrefix)) |
| 810 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 811 | if err != nil { |
| 812 | return err |
| 813 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 814 | if string(buf) != shimPrefix { |
| 815 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 816 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 817 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 818 | } |
| 819 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 820 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 821 | // The shim will not respond. |
| 822 | continue |
| 823 | } |
| 824 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 825 | // Process the KeyUpdate ACK. However many KeyUpdates the runner |
| 826 | // sends, the shim should respond only once. |
| 827 | if test.sendKeyUpdates > 0 && test.keyUpdateRequest == keyUpdateRequested { |
| 828 | if err := tlsConn.ReadKeyUpdateACK(); err != nil { |
| 829 | return err |
| 830 | } |
| 831 | } |
| 832 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 833 | buf := make([]byte, len(testMessage)) |
| 834 | if test.protocol == dtls { |
| 835 | bufTmp := make([]byte, len(buf)+1) |
| 836 | n, err := tlsConn.Read(bufTmp) |
| 837 | if err != nil { |
| 838 | return err |
| 839 | } |
| 840 | if n != len(buf) { |
| 841 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 842 | } |
| 843 | copy(buf, bufTmp) |
| 844 | } else { |
| 845 | _, err := io.ReadFull(tlsConn, buf) |
| 846 | if err != nil { |
| 847 | return err |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | for i, v := range buf { |
| 852 | if v != testMessage[i]^0xff { |
| 853 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 854 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 855 | } |
| 856 | } |
| 857 | |
| 858 | return nil |
| 859 | } |
| 860 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 861 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 862 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 863 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 864 | 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] | 865 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 866 | valgrindArgs = append(valgrindArgs, path) |
| 867 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 868 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 869 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 870 | } |
| 871 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 872 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 873 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 874 | xtermArgs = append(xtermArgs, path) |
| 875 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 876 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 877 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 878 | } |
| 879 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 880 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 881 | xtermArgs := []string{"-e", "lldb", "--"} |
| 882 | xtermArgs = append(xtermArgs, path) |
| 883 | xtermArgs = append(xtermArgs, args...) |
| 884 | |
| 885 | return exec.Command("xterm", xtermArgs...) |
| 886 | } |
| 887 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 888 | var ( |
| 889 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 890 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 891 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 892 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 893 | // accept accepts a connection from listener, unless waitChan signals a process |
| 894 | // exit first. |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 895 | func acceptOrWait(listener *net.TCPListener, waitChan chan error) (net.Conn, error) { |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 896 | type connOrError struct { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 897 | conn net.Conn |
| 898 | err error |
| 899 | startTime, endTime time.Time |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 900 | } |
| 901 | connChan := make(chan connOrError, 1) |
| 902 | go func() { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 903 | startTime := time.Now() |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 904 | if !*useGDB { |
| 905 | listener.SetDeadline(time.Now().Add(*idleTimeout)) |
| 906 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 907 | conn, err := listener.Accept() |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 908 | endTime := time.Now() |
| 909 | connChan <- connOrError{conn, err, startTime, endTime} |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 910 | close(connChan) |
| 911 | }() |
| 912 | select { |
| 913 | case result := <-connChan: |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 914 | if result.err != nil { |
| 915 | // TODO(davidben): Remove this logging when |
| 916 | // https://crbug.com/boringssl/199 is resolved. |
| 917 | fmt.Fprintf(os.Stderr, "acceptOrWait failed, startTime=%v, endTime=%v\n", result.startTime, result.endTime) |
| 918 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 919 | return result.conn, result.err |
| 920 | case childErr := <-waitChan: |
| 921 | waitChan <- childErr |
| 922 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 923 | } |
| 924 | } |
| 925 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 926 | func translateExpectedError(errorStr string) string { |
| 927 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 928 | return translated |
| 929 | } |
| 930 | |
| 931 | if *looseErrors { |
| 932 | return "" |
| 933 | } |
| 934 | |
| 935 | return errorStr |
| 936 | } |
| 937 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 938 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 939 | // Help debugging panics on the Go side. |
| 940 | defer func() { |
| 941 | if r := recover(); r != nil { |
| 942 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 943 | panic(r) |
| 944 | } |
| 945 | }() |
| 946 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 947 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 948 | panic("Error expected without shouldFail in " + test.name) |
| 949 | } |
| 950 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 951 | if test.expectResumeRejected && !test.resumeSession { |
| 952 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 953 | } |
| 954 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 955 | for _, ver := range tlsVersions { |
| 956 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 957 | continue |
| 958 | } |
| 959 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 960 | if test.config.MaxVersion == 0 && test.config.MinVersion == 0 && test.expectedVersion == 0 { |
| 961 | panic(fmt.Sprintf("The name of test %q suggests that it's version specific, but min/max version in the Config is %x/%x. One of them should probably be %x", test.name, test.config.MinVersion, test.config.MaxVersion, ver.version)) |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 962 | } |
| 963 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 964 | if ver.tls13Variant != 0 { |
| 965 | var foundFlag bool |
| 966 | for _, flag := range test.flags { |
| 967 | if flag == "-tls13-variant" { |
| 968 | foundFlag = true |
| 969 | break |
| 970 | } |
| 971 | } |
| 972 | if !foundFlag && test.config.TLS13Variant != ver.tls13Variant && test.tls13Variant != ver.tls13Variant { |
| 973 | panic(fmt.Sprintf("The name of test %q suggests that uses an experimental TLS 1.3 variant, but neither the shim nor the runner configures it", test.name)) |
| 974 | } |
| 975 | } |
| 976 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 977 | } |
| 978 | |
Matthew Braithwaite | 2d04cf0 | 2017-05-19 18:13:25 -0700 | [diff] [blame] | 979 | listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv6loopback}) |
| 980 | if err != nil { |
| 981 | listener, err = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 982 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 983 | if err != nil { |
| 984 | panic(err) |
| 985 | } |
| 986 | defer func() { |
| 987 | if listener != nil { |
| 988 | listener.Close() |
| 989 | } |
| 990 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 991 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 992 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 993 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 994 | flags = append(flags, "-server") |
| 995 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 996 | flags = append(flags, "-key-file") |
| 997 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 998 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 999 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1000 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | flags = append(flags, "-cert-file") |
| 1004 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1005 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1006 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1007 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1008 | } |
| 1009 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1010 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 1011 | if test.protocol == dtls { |
| 1012 | flags = append(flags, "-dtls") |
| 1013 | } |
| 1014 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1015 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1016 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1017 | resumeCount++ |
| 1018 | if test.resumeRenewedSession { |
| 1019 | resumeCount++ |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | if resumeCount > 0 { |
| 1024 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1025 | } |
| 1026 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 1027 | if test.shimWritesFirst { |
| 1028 | flags = append(flags, "-shim-writes-first") |
| 1029 | } |
| 1030 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 1031 | if test.readWithUnfinishedWrite { |
| 1032 | flags = append(flags, "-read-with-unfinished-write") |
| 1033 | } |
| 1034 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1035 | if test.shimShutsDown { |
| 1036 | flags = append(flags, "-shim-shuts-down") |
| 1037 | } |
| 1038 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1039 | if test.exportKeyingMaterial > 0 { |
| 1040 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 1041 | flags = append(flags, "-export-label", test.exportLabel) |
| 1042 | flags = append(flags, "-export-context", test.exportContext) |
| 1043 | if test.useExportContext { |
| 1044 | flags = append(flags, "-use-export-context") |
| 1045 | } |
| 1046 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 1047 | if test.expectResumeRejected { |
| 1048 | flags = append(flags, "-expect-session-miss") |
| 1049 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1050 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 1051 | if test.testTLSUnique { |
| 1052 | flags = append(flags, "-tls-unique") |
| 1053 | } |
| 1054 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1055 | if test.tls13Variant != 0 { |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1056 | flags = append(flags, "-tls13-variant", strconv.Itoa(test.tls13Variant)) |
| 1057 | } |
| 1058 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1059 | var transcriptPrefix string |
| 1060 | if len(*transcriptDir) != 0 { |
| 1061 | protocol := "tls" |
| 1062 | if test.protocol == dtls { |
| 1063 | protocol = "dtls" |
| 1064 | } |
| 1065 | |
| 1066 | side := "client" |
| 1067 | if test.testType == serverTest { |
| 1068 | side = "server" |
| 1069 | } |
| 1070 | |
| 1071 | dir := filepath.Join(*transcriptDir, protocol, side) |
| 1072 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 1073 | return err |
| 1074 | } |
| 1075 | transcriptPrefix = filepath.Join(dir, test.name+"-") |
| 1076 | flags = append(flags, "-write-settings", transcriptPrefix) |
| 1077 | } |
| 1078 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1079 | flags = append(flags, test.flags...) |
| 1080 | |
| 1081 | var shim *exec.Cmd |
| 1082 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1083 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 1084 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1085 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 1086 | } else if *useLLDB { |
| 1087 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1088 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1089 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1090 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1091 | shim.Stdin = os.Stdin |
| 1092 | var stdoutBuf, stderrBuf bytes.Buffer |
| 1093 | shim.Stdout = &stdoutBuf |
| 1094 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1095 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 1096 | shim.Env = os.Environ() |
| 1097 | 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] | 1098 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 1099 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1100 | } |
| 1101 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 1102 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1103 | |
| 1104 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1105 | panic(err) |
| 1106 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1107 | waitChan := make(chan error, 1) |
| 1108 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1109 | |
| 1110 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1111 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 1112 | if *deterministic { |
| 1113 | config.Rand = &deterministicRand{} |
| 1114 | } |
| 1115 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1116 | conn, err := acceptOrWait(listener, waitChan) |
| 1117 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1118 | err = doExchange(test, &config, conn, false /* not a resumption */, transcriptPrefix, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1119 | conn.Close() |
| 1120 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 1121 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1122 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1123 | var resumeConfig Config |
| 1124 | if test.resumeConfig != nil { |
| 1125 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1126 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1127 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1128 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1129 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1130 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1131 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1132 | } else { |
| 1133 | resumeConfig = config |
| 1134 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1135 | var connResume net.Conn |
| 1136 | connResume, err = acceptOrWait(listener, waitChan) |
| 1137 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1138 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, transcriptPrefix, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1139 | connResume.Close() |
| 1140 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1141 | } |
| 1142 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1143 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1144 | // open more connections than expected. |
| 1145 | listener.Close() |
| 1146 | listener = nil |
| 1147 | |
David Benjamin | 861f28a | 2017-10-06 13:10:45 -0400 | [diff] [blame^] | 1148 | var childErr error |
| 1149 | if *useGDB { |
| 1150 | childErr = <-waitChan |
| 1151 | } else { |
| 1152 | var shimKilledLock sync.Mutex |
| 1153 | var shimKilled bool |
| 1154 | waitTimeout := time.AfterFunc(*idleTimeout, func() { |
| 1155 | shimKilledLock.Lock() |
| 1156 | shimKilled = true |
| 1157 | shimKilledLock.Unlock() |
| 1158 | shim.Process.Kill() |
| 1159 | }) |
| 1160 | childErr = <-waitChan |
| 1161 | waitTimeout.Stop() |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1162 | shimKilledLock.Lock() |
David Benjamin | 861f28a | 2017-10-06 13:10:45 -0400 | [diff] [blame^] | 1163 | if shimKilled && err == nil { |
| 1164 | err = errors.New("timeout waiting for the shim to exit.") |
| 1165 | } |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1166 | shimKilledLock.Unlock() |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1167 | } |
David Benjamin | 861f28a | 2017-10-06 13:10:45 -0400 | [diff] [blame^] | 1168 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1169 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1170 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1171 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1172 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1173 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1174 | case 89: |
| 1175 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1176 | case 99: |
| 1177 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1178 | } |
| 1179 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1180 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1181 | // Account for Windows line endings. |
| 1182 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1183 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1184 | |
| 1185 | // Separate the errors from the shim and those from tools like |
| 1186 | // AddressSanitizer. |
| 1187 | var extraStderr string |
| 1188 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1189 | stderr = stderrParts[0] |
| 1190 | extraStderr = stderrParts[1] |
| 1191 | } |
| 1192 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1193 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1194 | expectedError := translateExpectedError(test.expectedError) |
| 1195 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1196 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1197 | localError := "none" |
| 1198 | if err != nil { |
| 1199 | localError = err.Error() |
| 1200 | } |
| 1201 | if len(test.expectedLocalError) != 0 { |
| 1202 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1203 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1204 | |
| 1205 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1206 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1207 | if childErr != nil { |
| 1208 | childError = childErr.Error() |
| 1209 | } |
| 1210 | |
| 1211 | var msg string |
| 1212 | switch { |
| 1213 | case failed && !test.shouldFail: |
| 1214 | msg = "unexpected failure" |
| 1215 | case !failed && test.shouldFail: |
| 1216 | msg = "unexpected success" |
| 1217 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1218 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1219 | default: |
| 1220 | panic("internal error") |
| 1221 | } |
| 1222 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1223 | 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] | 1224 | } |
| 1225 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1226 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
Adam Langley | c88f245 | 2017-04-27 14:15:37 -0700 | [diff] [blame] | 1227 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1230 | if *useValgrind && isValgrindError { |
| 1231 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1232 | } |
| 1233 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1234 | return nil |
| 1235 | } |
| 1236 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1237 | type tlsVersion struct { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1238 | name string |
| 1239 | // version is the protocol version. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1240 | version uint16 |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1241 | // excludeFlag is the legacy shim flag to disable the version. |
| 1242 | excludeFlag string |
| 1243 | hasDTLS bool |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1244 | // versionDTLS, if non-zero, is the DTLS-specific representation of the version. |
| 1245 | versionDTLS uint16 |
| 1246 | // versionWire, if non-zero, is the wire representation of the |
| 1247 | // version. Otherwise the wire version is the protocol version or |
| 1248 | // versionDTLS. |
| 1249 | versionWire uint16 |
| 1250 | tls13Variant int |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | func (vers tlsVersion) shimFlag(protocol protocol) string { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1254 | // The shim uses the protocol version in its public API, but uses the |
| 1255 | // DTLS-specific version if it exists. |
| 1256 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1257 | return strconv.Itoa(int(vers.versionDTLS)) |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1258 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1259 | return strconv.Itoa(int(vers.version)) |
| 1260 | } |
| 1261 | |
| 1262 | func (vers tlsVersion) wire(protocol protocol) uint16 { |
| 1263 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1264 | return vers.versionDTLS |
| 1265 | } |
| 1266 | if vers.versionWire != 0 { |
| 1267 | return vers.versionWire |
| 1268 | } |
| 1269 | return vers.version |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | var tlsVersions = []tlsVersion{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1273 | { |
| 1274 | name: "SSL3", |
| 1275 | version: VersionSSL30, |
| 1276 | excludeFlag: "-no-ssl3", |
| 1277 | }, |
| 1278 | { |
| 1279 | name: "TLS1", |
| 1280 | version: VersionTLS10, |
| 1281 | excludeFlag: "-no-tls1", |
| 1282 | hasDTLS: true, |
| 1283 | versionDTLS: VersionDTLS10, |
| 1284 | }, |
| 1285 | { |
| 1286 | name: "TLS11", |
| 1287 | version: VersionTLS11, |
| 1288 | excludeFlag: "-no-tls11", |
| 1289 | }, |
| 1290 | { |
| 1291 | name: "TLS12", |
| 1292 | version: VersionTLS12, |
| 1293 | excludeFlag: "-no-tls12", |
| 1294 | hasDTLS: true, |
| 1295 | versionDTLS: VersionDTLS12, |
| 1296 | }, |
| 1297 | { |
| 1298 | name: "TLS13", |
| 1299 | version: VersionTLS13, |
| 1300 | excludeFlag: "-no-tls13", |
| 1301 | versionWire: tls13DraftVersion, |
| 1302 | tls13Variant: TLS13Default, |
| 1303 | }, |
| 1304 | { |
| 1305 | name: "TLS13Experiment", |
| 1306 | version: VersionTLS13, |
| 1307 | excludeFlag: "-no-tls13", |
| 1308 | versionWire: tls13ExperimentVersion, |
| 1309 | tls13Variant: TLS13Experiment, |
| 1310 | }, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 1311 | { |
Steven Valdez | 1682126 | 2017-09-08 17:03:42 -0400 | [diff] [blame] | 1312 | name: "TLS13Experiment2", |
| 1313 | version: VersionTLS13, |
| 1314 | excludeFlag: "-no-tls13", |
| 1315 | versionWire: tls13Experiment2Version, |
| 1316 | tls13Variant: TLS13Experiment2, |
| 1317 | }, |
| 1318 | { |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 1319 | name: "TLS13Experiment3", |
| 1320 | version: VersionTLS13, |
| 1321 | excludeFlag: "-no-tls13", |
| 1322 | versionWire: tls13Experiment3Version, |
| 1323 | tls13Variant: TLS13Experiment3, |
| 1324 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1325 | } |
| 1326 | |
| 1327 | func allVersions(protocol protocol) []tlsVersion { |
| 1328 | if protocol == tls { |
| 1329 | return tlsVersions |
| 1330 | } |
| 1331 | |
| 1332 | var ret []tlsVersion |
| 1333 | for _, vers := range tlsVersions { |
| 1334 | if vers.hasDTLS { |
| 1335 | ret = append(ret, vers) |
| 1336 | } |
| 1337 | } |
| 1338 | return ret |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1339 | } |
| 1340 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1341 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1342 | name string |
| 1343 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1347 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1348 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1349 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1350 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1351 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1352 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1353 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1354 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1355 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1356 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1357 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1358 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1359 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1360 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1361 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1362 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1363 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1364 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1365 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1366 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1367 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1368 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1369 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1370 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1371 | {"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] | 1372 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1373 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1374 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1375 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1376 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1377 | } |
| 1378 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1379 | func hasComponent(suiteName, component string) bool { |
| 1380 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1381 | } |
| 1382 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1383 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1384 | return hasComponent(suiteName, "GCM") || |
| 1385 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1386 | hasComponent(suiteName, "SHA384") || |
| 1387 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1388 | } |
| 1389 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1390 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1391 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1392 | } |
| 1393 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1394 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1395 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1396 | } |
| 1397 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1398 | func bigFromHex(hex string) *big.Int { |
| 1399 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1400 | if !ok { |
| 1401 | panic("failed to parse hex number 0x" + hex) |
| 1402 | } |
| 1403 | return ret |
| 1404 | } |
| 1405 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1406 | func addBasicTests() { |
| 1407 | basicTests := []testCase{ |
| 1408 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1409 | name: "NoFallbackSCSV", |
| 1410 | config: Config{ |
| 1411 | Bugs: ProtocolBugs{ |
| 1412 | FailIfNotFallbackSCSV: true, |
| 1413 | }, |
| 1414 | }, |
| 1415 | shouldFail: true, |
| 1416 | expectedLocalError: "no fallback SCSV found", |
| 1417 | }, |
| 1418 | { |
| 1419 | name: "SendFallbackSCSV", |
| 1420 | config: Config{ |
| 1421 | Bugs: ProtocolBugs{ |
| 1422 | FailIfNotFallbackSCSV: true, |
| 1423 | }, |
| 1424 | }, |
| 1425 | flags: []string{"-fallback-scsv"}, |
| 1426 | }, |
| 1427 | { |
| 1428 | name: "ClientCertificateTypes", |
| 1429 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1430 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1431 | ClientAuth: RequestClientCert, |
| 1432 | ClientCertificateTypes: []byte{ |
| 1433 | CertTypeDSSSign, |
| 1434 | CertTypeRSASign, |
| 1435 | CertTypeECDSASign, |
| 1436 | }, |
| 1437 | }, |
| 1438 | flags: []string{ |
| 1439 | "-expect-certificate-types", |
| 1440 | base64.StdEncoding.EncodeToString([]byte{ |
| 1441 | CertTypeDSSSign, |
| 1442 | CertTypeRSASign, |
| 1443 | CertTypeECDSASign, |
| 1444 | }), |
| 1445 | }, |
| 1446 | }, |
| 1447 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1448 | name: "UnauthenticatedECDH", |
| 1449 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1450 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1451 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1452 | Bugs: ProtocolBugs{ |
| 1453 | UnauthenticatedECDH: true, |
| 1454 | }, |
| 1455 | }, |
| 1456 | shouldFail: true, |
| 1457 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1458 | }, |
| 1459 | { |
| 1460 | name: "SkipCertificateStatus", |
| 1461 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1462 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1463 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1464 | Bugs: ProtocolBugs{ |
| 1465 | SkipCertificateStatus: true, |
| 1466 | }, |
| 1467 | }, |
| 1468 | flags: []string{ |
| 1469 | "-enable-ocsp-stapling", |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 1470 | // This test involves an optional message. Test the message callback |
| 1471 | // trace to ensure we do not miss or double-report any. |
| 1472 | "-expect-msg-callback", |
| 1473 | `write hs 1 |
| 1474 | read hs 2 |
| 1475 | read hs 11 |
| 1476 | read hs 12 |
| 1477 | read hs 14 |
| 1478 | write hs 16 |
| 1479 | write ccs |
| 1480 | write hs 20 |
| 1481 | read hs 4 |
| 1482 | read ccs |
| 1483 | read hs 20 |
| 1484 | read alert 1 0 |
| 1485 | `, |
| 1486 | }, |
| 1487 | }, |
| 1488 | { |
| 1489 | protocol: dtls, |
| 1490 | name: "SkipCertificateStatus-DTLS", |
| 1491 | config: Config{ |
| 1492 | MaxVersion: VersionTLS12, |
| 1493 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1494 | Bugs: ProtocolBugs{ |
| 1495 | SkipCertificateStatus: true, |
| 1496 | }, |
| 1497 | }, |
| 1498 | flags: []string{ |
| 1499 | "-enable-ocsp-stapling", |
| 1500 | // This test involves an optional message. Test the message callback |
| 1501 | // trace to ensure we do not miss or double-report any. |
| 1502 | "-expect-msg-callback", |
| 1503 | `write hs 1 |
| 1504 | read hs 3 |
| 1505 | write hs 1 |
| 1506 | read hs 2 |
| 1507 | read hs 11 |
| 1508 | read hs 12 |
| 1509 | read hs 14 |
| 1510 | write hs 16 |
| 1511 | write ccs |
| 1512 | write hs 20 |
| 1513 | read hs 4 |
| 1514 | read ccs |
| 1515 | read hs 20 |
| 1516 | read alert 1 0 |
| 1517 | `, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1518 | }, |
| 1519 | }, |
| 1520 | { |
| 1521 | name: "SkipServerKeyExchange", |
| 1522 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1523 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1524 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1525 | Bugs: ProtocolBugs{ |
| 1526 | SkipServerKeyExchange: true, |
| 1527 | }, |
| 1528 | }, |
| 1529 | shouldFail: true, |
| 1530 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1531 | }, |
| 1532 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1533 | testType: serverTest, |
Dimitar Vlahovski | bd70845 | 2017-08-10 18:01:06 +0200 | [diff] [blame] | 1534 | name: "ServerSkipCertificateVerify", |
| 1535 | config: Config{ |
| 1536 | MaxVersion: VersionTLS12, |
| 1537 | Certificates: []Certificate{rsaChainCertificate}, |
| 1538 | Bugs: ProtocolBugs{ |
| 1539 | SkipCertificateVerify: true, |
| 1540 | }, |
| 1541 | }, |
| 1542 | expectPeerCertificate: &rsaChainCertificate, |
| 1543 | flags: []string{ |
| 1544 | "-require-any-client-certificate", |
| 1545 | }, |
| 1546 | shouldFail: true, |
| 1547 | expectedError: ":UNEXPECTED_RECORD:", |
| 1548 | expectedLocalError: "remote error: unexpected message", |
| 1549 | }, |
| 1550 | { |
| 1551 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1552 | name: "Alert", |
| 1553 | config: Config{ |
| 1554 | Bugs: ProtocolBugs{ |
| 1555 | SendSpuriousAlert: alertRecordOverflow, |
| 1556 | }, |
| 1557 | }, |
| 1558 | shouldFail: true, |
| 1559 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1560 | }, |
| 1561 | { |
| 1562 | protocol: dtls, |
| 1563 | testType: serverTest, |
| 1564 | name: "Alert-DTLS", |
| 1565 | config: Config{ |
| 1566 | Bugs: ProtocolBugs{ |
| 1567 | SendSpuriousAlert: alertRecordOverflow, |
| 1568 | }, |
| 1569 | }, |
| 1570 | shouldFail: true, |
| 1571 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1572 | }, |
| 1573 | { |
| 1574 | testType: serverTest, |
| 1575 | name: "FragmentAlert", |
| 1576 | config: Config{ |
| 1577 | Bugs: ProtocolBugs{ |
| 1578 | FragmentAlert: true, |
| 1579 | SendSpuriousAlert: alertRecordOverflow, |
| 1580 | }, |
| 1581 | }, |
| 1582 | shouldFail: true, |
| 1583 | expectedError: ":BAD_ALERT:", |
| 1584 | }, |
| 1585 | { |
| 1586 | protocol: dtls, |
| 1587 | testType: serverTest, |
| 1588 | name: "FragmentAlert-DTLS", |
| 1589 | config: Config{ |
| 1590 | Bugs: ProtocolBugs{ |
| 1591 | FragmentAlert: true, |
| 1592 | SendSpuriousAlert: alertRecordOverflow, |
| 1593 | }, |
| 1594 | }, |
| 1595 | shouldFail: true, |
| 1596 | expectedError: ":BAD_ALERT:", |
| 1597 | }, |
| 1598 | { |
| 1599 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1600 | name: "DoubleAlert", |
| 1601 | config: Config{ |
| 1602 | Bugs: ProtocolBugs{ |
| 1603 | DoubleAlert: true, |
| 1604 | SendSpuriousAlert: alertRecordOverflow, |
| 1605 | }, |
| 1606 | }, |
| 1607 | shouldFail: true, |
| 1608 | expectedError: ":BAD_ALERT:", |
| 1609 | }, |
| 1610 | { |
| 1611 | protocol: dtls, |
| 1612 | testType: serverTest, |
| 1613 | name: "DoubleAlert-DTLS", |
| 1614 | config: Config{ |
| 1615 | Bugs: ProtocolBugs{ |
| 1616 | DoubleAlert: true, |
| 1617 | SendSpuriousAlert: alertRecordOverflow, |
| 1618 | }, |
| 1619 | }, |
| 1620 | shouldFail: true, |
| 1621 | expectedError: ":BAD_ALERT:", |
| 1622 | }, |
| 1623 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1624 | name: "SkipNewSessionTicket", |
| 1625 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1626 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1627 | Bugs: ProtocolBugs{ |
| 1628 | SkipNewSessionTicket: true, |
| 1629 | }, |
| 1630 | }, |
| 1631 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1632 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1633 | }, |
| 1634 | { |
| 1635 | testType: serverTest, |
| 1636 | name: "FallbackSCSV", |
| 1637 | config: Config{ |
| 1638 | MaxVersion: VersionTLS11, |
| 1639 | Bugs: ProtocolBugs{ |
| 1640 | SendFallbackSCSV: true, |
| 1641 | }, |
| 1642 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1643 | shouldFail: true, |
| 1644 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1645 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1646 | }, |
| 1647 | { |
| 1648 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1649 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1650 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1651 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1652 | Bugs: ProtocolBugs{ |
| 1653 | SendFallbackSCSV: true, |
| 1654 | }, |
| 1655 | }, |
| 1656 | }, |
| 1657 | { |
| 1658 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1659 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1660 | config: Config{ |
| 1661 | MaxVersion: VersionTLS12, |
| 1662 | Bugs: ProtocolBugs{ |
| 1663 | SendFallbackSCSV: true, |
| 1664 | }, |
| 1665 | }, |
| 1666 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1667 | }, |
| 1668 | { |
| 1669 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1670 | name: "FragmentedClientVersion", |
| 1671 | config: Config{ |
| 1672 | Bugs: ProtocolBugs{ |
| 1673 | MaxHandshakeRecordLength: 1, |
| 1674 | FragmentClientVersion: true, |
| 1675 | }, |
| 1676 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1677 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1678 | }, |
| 1679 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1680 | testType: serverTest, |
| 1681 | name: "HttpGET", |
| 1682 | sendPrefix: "GET / HTTP/1.0\n", |
| 1683 | shouldFail: true, |
| 1684 | expectedError: ":HTTP_REQUEST:", |
| 1685 | }, |
| 1686 | { |
| 1687 | testType: serverTest, |
| 1688 | name: "HttpPOST", |
| 1689 | sendPrefix: "POST / HTTP/1.0\n", |
| 1690 | shouldFail: true, |
| 1691 | expectedError: ":HTTP_REQUEST:", |
| 1692 | }, |
| 1693 | { |
| 1694 | testType: serverTest, |
| 1695 | name: "HttpHEAD", |
| 1696 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1697 | shouldFail: true, |
| 1698 | expectedError: ":HTTP_REQUEST:", |
| 1699 | }, |
| 1700 | { |
| 1701 | testType: serverTest, |
| 1702 | name: "HttpPUT", |
| 1703 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1704 | shouldFail: true, |
| 1705 | expectedError: ":HTTP_REQUEST:", |
| 1706 | }, |
| 1707 | { |
| 1708 | testType: serverTest, |
| 1709 | name: "HttpCONNECT", |
| 1710 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1711 | shouldFail: true, |
| 1712 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1713 | }, |
| 1714 | { |
| 1715 | testType: serverTest, |
| 1716 | name: "Garbage", |
| 1717 | sendPrefix: "blah", |
| 1718 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1719 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1720 | }, |
| 1721 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1722 | name: "RSAEphemeralKey", |
| 1723 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1724 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1725 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1726 | Bugs: ProtocolBugs{ |
| 1727 | RSAEphemeralKey: true, |
| 1728 | }, |
| 1729 | }, |
| 1730 | shouldFail: true, |
| 1731 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1732 | }, |
| 1733 | { |
| 1734 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1735 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1736 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1737 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1738 | }, |
| 1739 | { |
| 1740 | protocol: dtls, |
| 1741 | name: "DisableEverything-DTLS", |
| 1742 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1743 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1744 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1745 | }, |
| 1746 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1747 | protocol: dtls, |
| 1748 | testType: serverTest, |
| 1749 | name: "MTU", |
| 1750 | config: Config{ |
| 1751 | Bugs: ProtocolBugs{ |
| 1752 | MaxPacketLength: 256, |
| 1753 | }, |
| 1754 | }, |
| 1755 | flags: []string{"-mtu", "256"}, |
| 1756 | }, |
| 1757 | { |
| 1758 | protocol: dtls, |
| 1759 | testType: serverTest, |
| 1760 | name: "MTUExceeded", |
| 1761 | config: Config{ |
| 1762 | Bugs: ProtocolBugs{ |
| 1763 | MaxPacketLength: 255, |
| 1764 | }, |
| 1765 | }, |
| 1766 | flags: []string{"-mtu", "256"}, |
| 1767 | shouldFail: true, |
| 1768 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1769 | }, |
| 1770 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1771 | name: "EmptyCertificateList", |
| 1772 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1773 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1774 | Bugs: ProtocolBugs{ |
| 1775 | EmptyCertificateList: true, |
| 1776 | }, |
| 1777 | }, |
| 1778 | shouldFail: true, |
| 1779 | expectedError: ":DECODE_ERROR:", |
| 1780 | }, |
| 1781 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1782 | name: "EmptyCertificateList-TLS13", |
| 1783 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1784 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1785 | Bugs: ProtocolBugs{ |
| 1786 | EmptyCertificateList: true, |
| 1787 | }, |
| 1788 | }, |
| 1789 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1790 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1791 | }, |
| 1792 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1793 | name: "TLSFatalBadPackets", |
| 1794 | damageFirstWrite: true, |
| 1795 | shouldFail: true, |
| 1796 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1797 | }, |
| 1798 | { |
| 1799 | protocol: dtls, |
| 1800 | name: "DTLSIgnoreBadPackets", |
| 1801 | damageFirstWrite: true, |
| 1802 | }, |
| 1803 | { |
| 1804 | protocol: dtls, |
| 1805 | name: "DTLSIgnoreBadPackets-Async", |
| 1806 | damageFirstWrite: true, |
| 1807 | flags: []string{"-async"}, |
| 1808 | }, |
| 1809 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1810 | name: "AppDataBeforeHandshake", |
| 1811 | config: Config{ |
| 1812 | Bugs: ProtocolBugs{ |
| 1813 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1814 | }, |
| 1815 | }, |
| 1816 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1817 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1818 | }, |
| 1819 | { |
| 1820 | name: "AppDataBeforeHandshake-Empty", |
| 1821 | config: Config{ |
| 1822 | Bugs: ProtocolBugs{ |
| 1823 | AppDataBeforeHandshake: []byte{}, |
| 1824 | }, |
| 1825 | }, |
| 1826 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1827 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1828 | }, |
| 1829 | { |
| 1830 | protocol: dtls, |
| 1831 | name: "AppDataBeforeHandshake-DTLS", |
| 1832 | config: Config{ |
| 1833 | Bugs: ProtocolBugs{ |
| 1834 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1835 | }, |
| 1836 | }, |
| 1837 | shouldFail: true, |
| 1838 | expectedError: ":UNEXPECTED_RECORD:", |
| 1839 | }, |
| 1840 | { |
| 1841 | protocol: dtls, |
| 1842 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1843 | config: Config{ |
| 1844 | Bugs: ProtocolBugs{ |
| 1845 | AppDataBeforeHandshake: []byte{}, |
| 1846 | }, |
| 1847 | }, |
| 1848 | shouldFail: true, |
| 1849 | expectedError: ":UNEXPECTED_RECORD:", |
| 1850 | }, |
| 1851 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1852 | name: "AppDataAfterChangeCipherSpec", |
| 1853 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1854 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1855 | Bugs: ProtocolBugs{ |
| 1856 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1857 | }, |
| 1858 | }, |
| 1859 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1860 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1861 | }, |
| 1862 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1863 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1864 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1865 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1866 | Bugs: ProtocolBugs{ |
| 1867 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1868 | }, |
| 1869 | }, |
| 1870 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1871 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1872 | }, |
| 1873 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1874 | protocol: dtls, |
| 1875 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1876 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1877 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1878 | Bugs: ProtocolBugs{ |
| 1879 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1880 | }, |
| 1881 | }, |
| 1882 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1883 | // application data. |
| 1884 | }, |
| 1885 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1886 | protocol: dtls, |
| 1887 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1888 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1889 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1890 | Bugs: ProtocolBugs{ |
| 1891 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1892 | }, |
| 1893 | }, |
| 1894 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1895 | // application data. |
| 1896 | }, |
| 1897 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1898 | name: "AlertAfterChangeCipherSpec", |
| 1899 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1900 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1901 | Bugs: ProtocolBugs{ |
| 1902 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1903 | }, |
| 1904 | }, |
| 1905 | shouldFail: true, |
| 1906 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1907 | }, |
| 1908 | { |
| 1909 | protocol: dtls, |
| 1910 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1911 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1912 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1913 | Bugs: ProtocolBugs{ |
| 1914 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1915 | }, |
| 1916 | }, |
| 1917 | shouldFail: true, |
| 1918 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1919 | }, |
| 1920 | { |
| 1921 | protocol: dtls, |
| 1922 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1923 | config: Config{ |
| 1924 | Bugs: ProtocolBugs{ |
| 1925 | ReorderHandshakeFragments: true, |
| 1926 | // Small enough that every handshake message is |
| 1927 | // fragmented. |
| 1928 | MaxHandshakeRecordLength: 2, |
| 1929 | }, |
| 1930 | }, |
| 1931 | }, |
| 1932 | { |
| 1933 | protocol: dtls, |
| 1934 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1935 | config: Config{ |
| 1936 | Bugs: ProtocolBugs{ |
| 1937 | ReorderHandshakeFragments: true, |
| 1938 | // Large enough that no handshake message is |
| 1939 | // fragmented. |
| 1940 | MaxHandshakeRecordLength: 2048, |
| 1941 | }, |
| 1942 | }, |
| 1943 | }, |
| 1944 | { |
| 1945 | protocol: dtls, |
| 1946 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1947 | config: Config{ |
| 1948 | Bugs: ProtocolBugs{ |
| 1949 | ReorderHandshakeFragments: true, |
| 1950 | MixCompleteMessageWithFragments: true, |
| 1951 | MaxHandshakeRecordLength: 2, |
| 1952 | }, |
| 1953 | }, |
| 1954 | }, |
| 1955 | { |
| 1956 | name: "SendInvalidRecordType", |
| 1957 | config: Config{ |
| 1958 | Bugs: ProtocolBugs{ |
| 1959 | SendInvalidRecordType: true, |
| 1960 | }, |
| 1961 | }, |
| 1962 | shouldFail: true, |
| 1963 | expectedError: ":UNEXPECTED_RECORD:", |
| 1964 | }, |
| 1965 | { |
| 1966 | protocol: dtls, |
| 1967 | name: "SendInvalidRecordType-DTLS", |
| 1968 | config: Config{ |
| 1969 | Bugs: ProtocolBugs{ |
| 1970 | SendInvalidRecordType: true, |
| 1971 | }, |
| 1972 | }, |
| 1973 | shouldFail: true, |
| 1974 | expectedError: ":UNEXPECTED_RECORD:", |
| 1975 | }, |
| 1976 | { |
| 1977 | name: "FalseStart-SkipServerSecondLeg", |
| 1978 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1979 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1980 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1981 | NextProtos: []string{"foo"}, |
| 1982 | Bugs: ProtocolBugs{ |
| 1983 | SkipNewSessionTicket: true, |
| 1984 | SkipChangeCipherSpec: true, |
| 1985 | SkipFinished: true, |
| 1986 | ExpectFalseStart: true, |
| 1987 | }, |
| 1988 | }, |
| 1989 | flags: []string{ |
| 1990 | "-false-start", |
| 1991 | "-handshake-never-done", |
| 1992 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1993 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1994 | }, |
| 1995 | shimWritesFirst: true, |
| 1996 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1997 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1998 | }, |
| 1999 | { |
| 2000 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 2001 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2002 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2003 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2004 | NextProtos: []string{"foo"}, |
| 2005 | Bugs: ProtocolBugs{ |
| 2006 | SkipNewSessionTicket: true, |
| 2007 | SkipChangeCipherSpec: true, |
| 2008 | SkipFinished: true, |
| 2009 | }, |
| 2010 | }, |
| 2011 | flags: []string{ |
| 2012 | "-implicit-handshake", |
| 2013 | "-false-start", |
| 2014 | "-handshake-never-done", |
| 2015 | "-advertise-alpn", "\x03foo", |
| 2016 | }, |
| 2017 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 2018 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2019 | }, |
| 2020 | { |
| 2021 | testType: serverTest, |
| 2022 | name: "FailEarlyCallback", |
| 2023 | flags: []string{"-fail-early-callback"}, |
| 2024 | shouldFail: true, |
| 2025 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 2026 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2027 | }, |
| 2028 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 2029 | name: "FailCertCallback-Client-TLS12", |
| 2030 | config: Config{ |
| 2031 | MaxVersion: VersionTLS12, |
| 2032 | ClientAuth: RequestClientCert, |
| 2033 | }, |
| 2034 | flags: []string{"-fail-cert-callback"}, |
| 2035 | shouldFail: true, |
| 2036 | expectedError: ":CERT_CB_ERROR:", |
| 2037 | expectedLocalError: "remote error: internal error", |
| 2038 | }, |
| 2039 | { |
| 2040 | testType: serverTest, |
| 2041 | name: "FailCertCallback-Server-TLS12", |
| 2042 | config: Config{ |
| 2043 | MaxVersion: VersionTLS12, |
| 2044 | }, |
| 2045 | flags: []string{"-fail-cert-callback"}, |
| 2046 | shouldFail: true, |
| 2047 | expectedError: ":CERT_CB_ERROR:", |
| 2048 | expectedLocalError: "remote error: internal error", |
| 2049 | }, |
| 2050 | { |
| 2051 | name: "FailCertCallback-Client-TLS13", |
| 2052 | config: Config{ |
| 2053 | MaxVersion: VersionTLS13, |
| 2054 | ClientAuth: RequestClientCert, |
| 2055 | }, |
| 2056 | flags: []string{"-fail-cert-callback"}, |
| 2057 | shouldFail: true, |
| 2058 | expectedError: ":CERT_CB_ERROR:", |
| 2059 | expectedLocalError: "remote error: internal error", |
| 2060 | }, |
| 2061 | { |
| 2062 | testType: serverTest, |
| 2063 | name: "FailCertCallback-Server-TLS13", |
| 2064 | config: Config{ |
| 2065 | MaxVersion: VersionTLS13, |
| 2066 | }, |
| 2067 | flags: []string{"-fail-cert-callback"}, |
| 2068 | shouldFail: true, |
| 2069 | expectedError: ":CERT_CB_ERROR:", |
| 2070 | expectedLocalError: "remote error: internal error", |
| 2071 | }, |
| 2072 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2073 | protocol: dtls, |
| 2074 | name: "FragmentMessageTypeMismatch-DTLS", |
| 2075 | config: Config{ |
| 2076 | Bugs: ProtocolBugs{ |
| 2077 | MaxHandshakeRecordLength: 2, |
| 2078 | FragmentMessageTypeMismatch: true, |
| 2079 | }, |
| 2080 | }, |
| 2081 | shouldFail: true, |
| 2082 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2083 | }, |
| 2084 | { |
| 2085 | protocol: dtls, |
| 2086 | name: "FragmentMessageLengthMismatch-DTLS", |
| 2087 | config: Config{ |
| 2088 | Bugs: ProtocolBugs{ |
| 2089 | MaxHandshakeRecordLength: 2, |
| 2090 | FragmentMessageLengthMismatch: true, |
| 2091 | }, |
| 2092 | }, |
| 2093 | shouldFail: true, |
| 2094 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2095 | }, |
| 2096 | { |
| 2097 | protocol: dtls, |
| 2098 | name: "SplitFragments-Header-DTLS", |
| 2099 | config: Config{ |
| 2100 | Bugs: ProtocolBugs{ |
| 2101 | SplitFragments: 2, |
| 2102 | }, |
| 2103 | }, |
| 2104 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2105 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2106 | }, |
| 2107 | { |
| 2108 | protocol: dtls, |
| 2109 | name: "SplitFragments-Boundary-DTLS", |
| 2110 | config: Config{ |
| 2111 | Bugs: ProtocolBugs{ |
| 2112 | SplitFragments: dtlsRecordHeaderLen, |
| 2113 | }, |
| 2114 | }, |
| 2115 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2116 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2117 | }, |
| 2118 | { |
| 2119 | protocol: dtls, |
| 2120 | name: "SplitFragments-Body-DTLS", |
| 2121 | config: Config{ |
| 2122 | Bugs: ProtocolBugs{ |
| 2123 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 2124 | }, |
| 2125 | }, |
| 2126 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2127 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2128 | }, |
| 2129 | { |
| 2130 | protocol: dtls, |
| 2131 | name: "SendEmptyFragments-DTLS", |
| 2132 | config: Config{ |
| 2133 | Bugs: ProtocolBugs{ |
| 2134 | SendEmptyFragments: true, |
| 2135 | }, |
| 2136 | }, |
| 2137 | }, |
| 2138 | { |
David Benjamin | e51fb0f | 2017-09-07 11:51:46 -0400 | [diff] [blame] | 2139 | testType: serverTest, |
| 2140 | protocol: dtls, |
| 2141 | name: "SendEmptyFragments-Padded-DTLS", |
| 2142 | config: Config{ |
| 2143 | Bugs: ProtocolBugs{ |
| 2144 | // Test empty fragments for a message with a |
| 2145 | // nice power-of-two length. |
| 2146 | PadClientHello: 64, |
| 2147 | SendEmptyFragments: true, |
| 2148 | }, |
| 2149 | }, |
| 2150 | }, |
| 2151 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2152 | name: "BadFinished-Client", |
| 2153 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2154 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2155 | Bugs: ProtocolBugs{ |
| 2156 | BadFinished: true, |
| 2157 | }, |
| 2158 | }, |
| 2159 | shouldFail: true, |
| 2160 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2161 | }, |
| 2162 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2163 | name: "BadFinished-Client-TLS13", |
| 2164 | config: Config{ |
| 2165 | MaxVersion: VersionTLS13, |
| 2166 | Bugs: ProtocolBugs{ |
| 2167 | BadFinished: true, |
| 2168 | }, |
| 2169 | }, |
| 2170 | shouldFail: true, |
| 2171 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2172 | }, |
| 2173 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2174 | testType: serverTest, |
| 2175 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2176 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2177 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2178 | Bugs: ProtocolBugs{ |
| 2179 | BadFinished: true, |
| 2180 | }, |
| 2181 | }, |
| 2182 | shouldFail: true, |
| 2183 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2184 | }, |
| 2185 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2186 | testType: serverTest, |
| 2187 | name: "BadFinished-Server-TLS13", |
| 2188 | config: Config{ |
| 2189 | MaxVersion: VersionTLS13, |
| 2190 | Bugs: ProtocolBugs{ |
| 2191 | BadFinished: true, |
| 2192 | }, |
| 2193 | }, |
| 2194 | shouldFail: true, |
| 2195 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2196 | }, |
| 2197 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2198 | name: "FalseStart-BadFinished", |
| 2199 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2200 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2201 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2202 | NextProtos: []string{"foo"}, |
| 2203 | Bugs: ProtocolBugs{ |
| 2204 | BadFinished: true, |
| 2205 | ExpectFalseStart: true, |
| 2206 | }, |
| 2207 | }, |
| 2208 | flags: []string{ |
| 2209 | "-false-start", |
| 2210 | "-handshake-never-done", |
| 2211 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 2212 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2213 | }, |
| 2214 | shimWritesFirst: true, |
| 2215 | shouldFail: true, |
| 2216 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2217 | }, |
| 2218 | { |
| 2219 | name: "NoFalseStart-NoALPN", |
| 2220 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2221 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2222 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2223 | Bugs: ProtocolBugs{ |
| 2224 | ExpectFalseStart: true, |
| 2225 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2226 | }, |
| 2227 | }, |
| 2228 | flags: []string{ |
| 2229 | "-false-start", |
| 2230 | }, |
| 2231 | shimWritesFirst: true, |
| 2232 | shouldFail: true, |
| 2233 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2234 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2235 | }, |
| 2236 | { |
| 2237 | name: "NoFalseStart-NoAEAD", |
| 2238 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2239 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2240 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2241 | NextProtos: []string{"foo"}, |
| 2242 | Bugs: ProtocolBugs{ |
| 2243 | ExpectFalseStart: true, |
| 2244 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2245 | }, |
| 2246 | }, |
| 2247 | flags: []string{ |
| 2248 | "-false-start", |
| 2249 | "-advertise-alpn", "\x03foo", |
| 2250 | }, |
| 2251 | shimWritesFirst: true, |
| 2252 | shouldFail: true, |
| 2253 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2254 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2255 | }, |
| 2256 | { |
| 2257 | name: "NoFalseStart-RSA", |
| 2258 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2259 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2260 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 2261 | NextProtos: []string{"foo"}, |
| 2262 | Bugs: ProtocolBugs{ |
| 2263 | ExpectFalseStart: true, |
| 2264 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2265 | }, |
| 2266 | }, |
| 2267 | flags: []string{ |
| 2268 | "-false-start", |
| 2269 | "-advertise-alpn", "\x03foo", |
| 2270 | }, |
| 2271 | shimWritesFirst: true, |
| 2272 | shouldFail: true, |
| 2273 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2274 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2275 | }, |
| 2276 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2277 | protocol: dtls, |
| 2278 | name: "SendSplitAlert-Sync", |
| 2279 | config: Config{ |
| 2280 | Bugs: ProtocolBugs{ |
| 2281 | SendSplitAlert: true, |
| 2282 | }, |
| 2283 | }, |
| 2284 | }, |
| 2285 | { |
| 2286 | protocol: dtls, |
| 2287 | name: "SendSplitAlert-Async", |
| 2288 | config: Config{ |
| 2289 | Bugs: ProtocolBugs{ |
| 2290 | SendSplitAlert: true, |
| 2291 | }, |
| 2292 | }, |
| 2293 | flags: []string{"-async"}, |
| 2294 | }, |
| 2295 | { |
| 2296 | protocol: dtls, |
| 2297 | name: "PackDTLSHandshake", |
| 2298 | config: Config{ |
| 2299 | Bugs: ProtocolBugs{ |
| 2300 | MaxHandshakeRecordLength: 2, |
| 2301 | PackHandshakeFragments: 20, |
| 2302 | PackHandshakeRecords: 200, |
| 2303 | }, |
| 2304 | }, |
| 2305 | }, |
| 2306 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2307 | name: "SendEmptyRecords-Pass", |
| 2308 | sendEmptyRecords: 32, |
| 2309 | }, |
| 2310 | { |
| 2311 | name: "SendEmptyRecords", |
| 2312 | sendEmptyRecords: 33, |
| 2313 | shouldFail: true, |
| 2314 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2315 | }, |
| 2316 | { |
| 2317 | name: "SendEmptyRecords-Async", |
| 2318 | sendEmptyRecords: 33, |
| 2319 | flags: []string{"-async"}, |
| 2320 | shouldFail: true, |
| 2321 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2322 | }, |
| 2323 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2324 | name: "SendWarningAlerts-Pass", |
| 2325 | config: Config{ |
| 2326 | MaxVersion: VersionTLS12, |
| 2327 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2328 | sendWarningAlerts: 4, |
| 2329 | }, |
| 2330 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2331 | protocol: dtls, |
| 2332 | name: "SendWarningAlerts-DTLS-Pass", |
| 2333 | config: Config{ |
| 2334 | MaxVersion: VersionTLS12, |
| 2335 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2336 | sendWarningAlerts: 4, |
| 2337 | }, |
| 2338 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2339 | name: "SendWarningAlerts-TLS13", |
| 2340 | config: Config{ |
| 2341 | MaxVersion: VersionTLS13, |
| 2342 | }, |
| 2343 | sendWarningAlerts: 4, |
| 2344 | shouldFail: true, |
| 2345 | expectedError: ":BAD_ALERT:", |
| 2346 | expectedLocalError: "remote error: error decoding message", |
| 2347 | }, |
| 2348 | { |
| 2349 | name: "SendWarningAlerts", |
| 2350 | config: Config{ |
| 2351 | MaxVersion: VersionTLS12, |
| 2352 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2353 | sendWarningAlerts: 5, |
| 2354 | shouldFail: true, |
| 2355 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2356 | }, |
| 2357 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2358 | name: "SendWarningAlerts-Async", |
| 2359 | config: Config{ |
| 2360 | MaxVersion: VersionTLS12, |
| 2361 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2362 | sendWarningAlerts: 5, |
| 2363 | flags: []string{"-async"}, |
| 2364 | shouldFail: true, |
| 2365 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2366 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2367 | { |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 2368 | name: "SendBogusAlertType", |
| 2369 | sendBogusAlertType: true, |
| 2370 | shouldFail: true, |
| 2371 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2372 | expectedLocalError: "remote error: illegal parameter", |
| 2373 | }, |
| 2374 | { |
| 2375 | protocol: dtls, |
| 2376 | name: "SendBogusAlertType-DTLS", |
| 2377 | sendBogusAlertType: true, |
| 2378 | shouldFail: true, |
| 2379 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2380 | expectedLocalError: "remote error: illegal parameter", |
| 2381 | }, |
| 2382 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2383 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2384 | config: Config{ |
| 2385 | MaxVersion: VersionTLS13, |
| 2386 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2387 | sendKeyUpdates: 33, |
| 2388 | keyUpdateRequest: keyUpdateNotRequested, |
| 2389 | shouldFail: true, |
| 2390 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2391 | }, |
| 2392 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2393 | name: "EmptySessionID", |
| 2394 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2395 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2396 | SessionTicketsDisabled: true, |
| 2397 | }, |
| 2398 | noSessionCache: true, |
| 2399 | flags: []string{"-expect-no-session"}, |
| 2400 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2401 | { |
| 2402 | name: "Unclean-Shutdown", |
| 2403 | config: Config{ |
| 2404 | Bugs: ProtocolBugs{ |
| 2405 | NoCloseNotify: true, |
| 2406 | ExpectCloseNotify: true, |
| 2407 | }, |
| 2408 | }, |
| 2409 | shimShutsDown: true, |
| 2410 | flags: []string{"-check-close-notify"}, |
| 2411 | shouldFail: true, |
| 2412 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2413 | }, |
| 2414 | { |
| 2415 | name: "Unclean-Shutdown-Ignored", |
| 2416 | config: Config{ |
| 2417 | Bugs: ProtocolBugs{ |
| 2418 | NoCloseNotify: true, |
| 2419 | }, |
| 2420 | }, |
| 2421 | shimShutsDown: true, |
| 2422 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2423 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2424 | name: "Unclean-Shutdown-Alert", |
| 2425 | config: Config{ |
| 2426 | Bugs: ProtocolBugs{ |
| 2427 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2428 | ExpectCloseNotify: true, |
| 2429 | }, |
| 2430 | }, |
| 2431 | shimShutsDown: true, |
| 2432 | flags: []string{"-check-close-notify"}, |
| 2433 | shouldFail: true, |
| 2434 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2435 | }, |
| 2436 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2437 | name: "LargePlaintext", |
| 2438 | config: Config{ |
| 2439 | Bugs: ProtocolBugs{ |
| 2440 | SendLargeRecords: true, |
| 2441 | }, |
| 2442 | }, |
| 2443 | messageLen: maxPlaintext + 1, |
| 2444 | shouldFail: true, |
| 2445 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2446 | }, |
| 2447 | { |
| 2448 | protocol: dtls, |
| 2449 | name: "LargePlaintext-DTLS", |
| 2450 | config: Config{ |
| 2451 | Bugs: ProtocolBugs{ |
| 2452 | SendLargeRecords: true, |
| 2453 | }, |
| 2454 | }, |
| 2455 | messageLen: maxPlaintext + 1, |
| 2456 | shouldFail: true, |
| 2457 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2458 | }, |
| 2459 | { |
| 2460 | name: "LargeCiphertext", |
| 2461 | config: Config{ |
| 2462 | Bugs: ProtocolBugs{ |
| 2463 | SendLargeRecords: true, |
| 2464 | }, |
| 2465 | }, |
| 2466 | messageLen: maxPlaintext * 2, |
| 2467 | shouldFail: true, |
| 2468 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2469 | }, |
| 2470 | { |
| 2471 | protocol: dtls, |
| 2472 | name: "LargeCiphertext-DTLS", |
| 2473 | config: Config{ |
| 2474 | Bugs: ProtocolBugs{ |
| 2475 | SendLargeRecords: true, |
| 2476 | }, |
| 2477 | }, |
| 2478 | messageLen: maxPlaintext * 2, |
| 2479 | // Unlike the other four cases, DTLS drops records which |
| 2480 | // are invalid before authentication, so the connection |
| 2481 | // does not fail. |
| 2482 | expectMessageDropped: true, |
| 2483 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2484 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2485 | name: "BadHelloRequest-1", |
| 2486 | renegotiate: 1, |
| 2487 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2488 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2489 | Bugs: ProtocolBugs{ |
| 2490 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2491 | }, |
| 2492 | }, |
| 2493 | flags: []string{ |
| 2494 | "-renegotiate-freely", |
| 2495 | "-expect-total-renegotiations", "1", |
| 2496 | }, |
| 2497 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2498 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2499 | }, |
| 2500 | { |
| 2501 | name: "BadHelloRequest-2", |
| 2502 | renegotiate: 1, |
| 2503 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2504 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2505 | Bugs: ProtocolBugs{ |
| 2506 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2507 | }, |
| 2508 | }, |
| 2509 | flags: []string{ |
| 2510 | "-renegotiate-freely", |
| 2511 | "-expect-total-renegotiations", "1", |
| 2512 | }, |
| 2513 | shouldFail: true, |
| 2514 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2515 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2516 | { |
| 2517 | testType: serverTest, |
| 2518 | name: "SupportTicketsWithSessionID", |
| 2519 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2520 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2521 | SessionTicketsDisabled: true, |
| 2522 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2523 | resumeConfig: &Config{ |
| 2524 | MaxVersion: VersionTLS12, |
| 2525 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2526 | resumeSession: true, |
| 2527 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2528 | { |
| 2529 | protocol: dtls, |
| 2530 | name: "DTLS-SendExtraFinished", |
| 2531 | config: Config{ |
| 2532 | Bugs: ProtocolBugs{ |
| 2533 | SendExtraFinished: true, |
| 2534 | }, |
| 2535 | }, |
| 2536 | shouldFail: true, |
| 2537 | expectedError: ":UNEXPECTED_RECORD:", |
| 2538 | }, |
| 2539 | { |
| 2540 | protocol: dtls, |
| 2541 | name: "DTLS-SendExtraFinished-Reordered", |
| 2542 | config: Config{ |
| 2543 | Bugs: ProtocolBugs{ |
| 2544 | MaxHandshakeRecordLength: 2, |
| 2545 | ReorderHandshakeFragments: true, |
| 2546 | SendExtraFinished: true, |
| 2547 | }, |
| 2548 | }, |
| 2549 | shouldFail: true, |
| 2550 | expectedError: ":UNEXPECTED_RECORD:", |
| 2551 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2552 | { |
| 2553 | testType: serverTest, |
| 2554 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2555 | config: Config{ |
| 2556 | // Choose a cipher suite that does not involve |
| 2557 | // elliptic curves, so no extensions are |
| 2558 | // involved. |
| 2559 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2560 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2561 | Bugs: ProtocolBugs{ |
| 2562 | SendV2ClientHello: true, |
| 2563 | }, |
| 2564 | }, |
| 2565 | sendPrefix: string([]byte{ |
| 2566 | byte(recordTypeHandshake), |
| 2567 | 3, 1, // version |
| 2568 | 0, 0, // length |
| 2569 | }), |
| 2570 | // A no-op empty record may not be sent before V2ClientHello. |
| 2571 | shouldFail: true, |
| 2572 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2573 | }, |
| 2574 | { |
| 2575 | testType: serverTest, |
| 2576 | name: "V2ClientHello-WarningAlertPrefix", |
| 2577 | config: Config{ |
| 2578 | // Choose a cipher suite that does not involve |
| 2579 | // elliptic curves, so no extensions are |
| 2580 | // involved. |
| 2581 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2582 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2583 | Bugs: ProtocolBugs{ |
| 2584 | SendV2ClientHello: true, |
| 2585 | }, |
| 2586 | }, |
| 2587 | sendPrefix: string([]byte{ |
| 2588 | byte(recordTypeAlert), |
| 2589 | 3, 1, // version |
| 2590 | 0, 2, // length |
| 2591 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2592 | }), |
| 2593 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2594 | shouldFail: true, |
| 2595 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2596 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2597 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2598 | name: "KeyUpdate-Client", |
| 2599 | config: Config{ |
| 2600 | MaxVersion: VersionTLS13, |
| 2601 | }, |
| 2602 | sendKeyUpdates: 1, |
| 2603 | keyUpdateRequest: keyUpdateNotRequested, |
| 2604 | }, |
| 2605 | { |
| 2606 | testType: serverTest, |
| 2607 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2608 | config: Config{ |
| 2609 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2610 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2611 | sendKeyUpdates: 1, |
| 2612 | keyUpdateRequest: keyUpdateNotRequested, |
| 2613 | }, |
| 2614 | { |
| 2615 | name: "KeyUpdate-InvalidRequestMode", |
| 2616 | config: Config{ |
| 2617 | MaxVersion: VersionTLS13, |
| 2618 | }, |
| 2619 | sendKeyUpdates: 1, |
| 2620 | keyUpdateRequest: 42, |
| 2621 | shouldFail: true, |
| 2622 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2623 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2624 | { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 2625 | // Test that KeyUpdates are acknowledged properly. |
| 2626 | name: "KeyUpdate-RequestACK", |
| 2627 | config: Config{ |
| 2628 | MaxVersion: VersionTLS13, |
| 2629 | Bugs: ProtocolBugs{ |
| 2630 | RejectUnsolicitedKeyUpdate: true, |
| 2631 | }, |
| 2632 | }, |
| 2633 | // Test the shim receiving many KeyUpdates in a row. |
| 2634 | sendKeyUpdates: 5, |
| 2635 | messageCount: 5, |
| 2636 | keyUpdateRequest: keyUpdateRequested, |
| 2637 | }, |
| 2638 | { |
| 2639 | // Test that KeyUpdates are acknowledged properly if the |
| 2640 | // peer's KeyUpdate is discovered while a write is |
| 2641 | // pending. |
| 2642 | name: "KeyUpdate-RequestACK-UnfinishedWrite", |
| 2643 | config: Config{ |
| 2644 | MaxVersion: VersionTLS13, |
| 2645 | Bugs: ProtocolBugs{ |
| 2646 | RejectUnsolicitedKeyUpdate: true, |
| 2647 | }, |
| 2648 | }, |
| 2649 | // Test the shim receiving many KeyUpdates in a row. |
| 2650 | sendKeyUpdates: 5, |
| 2651 | messageCount: 5, |
| 2652 | keyUpdateRequest: keyUpdateRequested, |
| 2653 | readWithUnfinishedWrite: true, |
| 2654 | flags: []string{"-async"}, |
| 2655 | }, |
| 2656 | { |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2657 | name: "SendSNIWarningAlert", |
| 2658 | config: Config{ |
| 2659 | MaxVersion: VersionTLS12, |
| 2660 | Bugs: ProtocolBugs{ |
| 2661 | SendSNIWarningAlert: true, |
| 2662 | }, |
| 2663 | }, |
| 2664 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2665 | { |
| 2666 | testType: serverTest, |
| 2667 | name: "ExtraCompressionMethods-TLS12", |
| 2668 | config: Config{ |
| 2669 | MaxVersion: VersionTLS12, |
| 2670 | Bugs: ProtocolBugs{ |
| 2671 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2672 | }, |
| 2673 | }, |
| 2674 | }, |
| 2675 | { |
| 2676 | testType: serverTest, |
| 2677 | name: "ExtraCompressionMethods-TLS13", |
| 2678 | config: Config{ |
| 2679 | MaxVersion: VersionTLS13, |
| 2680 | Bugs: ProtocolBugs{ |
| 2681 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2682 | }, |
| 2683 | }, |
| 2684 | shouldFail: true, |
| 2685 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2686 | expectedLocalError: "remote error: illegal parameter", |
| 2687 | }, |
| 2688 | { |
| 2689 | testType: serverTest, |
| 2690 | name: "NoNullCompression-TLS12", |
| 2691 | config: Config{ |
| 2692 | MaxVersion: VersionTLS12, |
| 2693 | Bugs: ProtocolBugs{ |
| 2694 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2695 | }, |
| 2696 | }, |
| 2697 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2698 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2699 | expectedLocalError: "remote error: illegal parameter", |
| 2700 | }, |
| 2701 | { |
| 2702 | testType: serverTest, |
| 2703 | name: "NoNullCompression-TLS13", |
| 2704 | config: Config{ |
| 2705 | MaxVersion: VersionTLS13, |
| 2706 | Bugs: ProtocolBugs{ |
| 2707 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2708 | }, |
| 2709 | }, |
| 2710 | shouldFail: true, |
| 2711 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2712 | expectedLocalError: "remote error: illegal parameter", |
| 2713 | }, |
David Benjamin | 413e79e | 2017-07-01 10:11:53 -0400 | [diff] [blame] | 2714 | // Test that the client rejects invalid compression methods |
| 2715 | // from the server. |
| 2716 | { |
| 2717 | testType: clientTest, |
| 2718 | name: "InvalidCompressionMethod", |
| 2719 | config: Config{ |
| 2720 | MaxVersion: VersionTLS12, |
| 2721 | Bugs: ProtocolBugs{ |
| 2722 | SendCompressionMethod: 1, |
| 2723 | }, |
| 2724 | }, |
| 2725 | shouldFail: true, |
| 2726 | expectedError: ":UNSUPPORTED_COMPRESSION_ALGORITHM:", |
| 2727 | expectedLocalError: "remote error: illegal parameter", |
| 2728 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2729 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2730 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2731 | config: Config{ |
| 2732 | MaxVersion: VersionTLS12, |
| 2733 | Bugs: ProtocolBugs{ |
| 2734 | ExpectGREASE: true, |
| 2735 | }, |
| 2736 | }, |
| 2737 | flags: []string{"-enable-grease"}, |
| 2738 | }, |
| 2739 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2740 | name: "GREASE-Client-TLS13", |
| 2741 | config: Config{ |
| 2742 | MaxVersion: VersionTLS13, |
| 2743 | Bugs: ProtocolBugs{ |
| 2744 | ExpectGREASE: true, |
| 2745 | }, |
| 2746 | }, |
| 2747 | flags: []string{"-enable-grease"}, |
| 2748 | }, |
| 2749 | { |
| 2750 | testType: serverTest, |
| 2751 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2752 | config: Config{ |
| 2753 | MaxVersion: VersionTLS13, |
| 2754 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2755 | // TLS 1.3 servers are expected to |
| 2756 | // always enable GREASE. TLS 1.3 is new, |
| 2757 | // so there is no existing ecosystem to |
| 2758 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2759 | ExpectGREASE: true, |
| 2760 | }, |
| 2761 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2762 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2763 | { |
| 2764 | // Test the server so there is a large certificate as |
| 2765 | // well as application data. |
| 2766 | testType: serverTest, |
| 2767 | name: "MaxSendFragment", |
| 2768 | config: Config{ |
| 2769 | Bugs: ProtocolBugs{ |
| 2770 | MaxReceivePlaintext: 512, |
| 2771 | }, |
| 2772 | }, |
| 2773 | messageLen: 1024, |
| 2774 | flags: []string{ |
| 2775 | "-max-send-fragment", "512", |
| 2776 | "-read-size", "1024", |
| 2777 | }, |
| 2778 | }, |
| 2779 | { |
| 2780 | // Test the server so there is a large certificate as |
| 2781 | // well as application data. |
| 2782 | testType: serverTest, |
| 2783 | name: "MaxSendFragment-TooLarge", |
| 2784 | config: Config{ |
| 2785 | Bugs: ProtocolBugs{ |
| 2786 | // Ensure that some of the records are |
| 2787 | // 512. |
| 2788 | MaxReceivePlaintext: 511, |
| 2789 | }, |
| 2790 | }, |
| 2791 | messageLen: 1024, |
| 2792 | flags: []string{ |
| 2793 | "-max-send-fragment", "512", |
| 2794 | "-read-size", "1024", |
| 2795 | }, |
| 2796 | shouldFail: true, |
| 2797 | expectedLocalError: "local error: record overflow", |
| 2798 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2799 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2800 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2801 | |
| 2802 | // Test that very large messages can be received. |
| 2803 | cert := rsaCertificate |
| 2804 | for i := 0; i < 50; i++ { |
| 2805 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2806 | } |
| 2807 | testCases = append(testCases, testCase{ |
| 2808 | name: "LargeMessage", |
| 2809 | config: Config{ |
| 2810 | Certificates: []Certificate{cert}, |
| 2811 | }, |
| 2812 | }) |
| 2813 | testCases = append(testCases, testCase{ |
| 2814 | protocol: dtls, |
| 2815 | name: "LargeMessage-DTLS", |
| 2816 | config: Config{ |
| 2817 | Certificates: []Certificate{cert}, |
| 2818 | }, |
| 2819 | }) |
| 2820 | |
| 2821 | // They are rejected if the maximum certificate chain length is capped. |
| 2822 | testCases = append(testCases, testCase{ |
| 2823 | name: "LargeMessage-Reject", |
| 2824 | config: Config{ |
| 2825 | Certificates: []Certificate{cert}, |
| 2826 | }, |
| 2827 | flags: []string{"-max-cert-list", "16384"}, |
| 2828 | shouldFail: true, |
| 2829 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2830 | }) |
| 2831 | testCases = append(testCases, testCase{ |
| 2832 | protocol: dtls, |
| 2833 | name: "LargeMessage-Reject-DTLS", |
| 2834 | config: Config{ |
| 2835 | Certificates: []Certificate{cert}, |
| 2836 | }, |
| 2837 | flags: []string{"-max-cert-list", "16384"}, |
| 2838 | shouldFail: true, |
| 2839 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2840 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2841 | } |
| 2842 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2843 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2844 | const psk = "12345" |
| 2845 | const pskIdentity = "luggage combo" |
| 2846 | |
| 2847 | var prefix string |
| 2848 | if protocol == dtls { |
| 2849 | if !ver.hasDTLS { |
| 2850 | return |
| 2851 | } |
| 2852 | prefix = "D" |
| 2853 | } |
| 2854 | |
| 2855 | var cert Certificate |
| 2856 | var certFile string |
| 2857 | var keyFile string |
| 2858 | if hasComponent(suite.name, "ECDSA") { |
| 2859 | cert = ecdsaP256Certificate |
| 2860 | certFile = ecdsaP256CertificateFile |
| 2861 | keyFile = ecdsaP256KeyFile |
| 2862 | } else { |
| 2863 | cert = rsaCertificate |
| 2864 | certFile = rsaCertificateFile |
| 2865 | keyFile = rsaKeyFile |
| 2866 | } |
| 2867 | |
| 2868 | var flags []string |
| 2869 | if hasComponent(suite.name, "PSK") { |
| 2870 | flags = append(flags, |
| 2871 | "-psk", psk, |
| 2872 | "-psk-identity", pskIdentity) |
| 2873 | } |
| 2874 | if hasComponent(suite.name, "NULL") { |
| 2875 | // NULL ciphers must be explicitly enabled. |
| 2876 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2877 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2878 | |
| 2879 | var shouldServerFail, shouldClientFail bool |
| 2880 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2881 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2882 | // a BoringSSL server will never select it |
| 2883 | // because the extension is missing. |
| 2884 | shouldServerFail = true |
| 2885 | } |
| 2886 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2887 | shouldClientFail = true |
| 2888 | shouldServerFail = true |
| 2889 | } |
| 2890 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2891 | shouldClientFail = true |
| 2892 | shouldServerFail = true |
| 2893 | } |
| 2894 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2895 | shouldClientFail = true |
| 2896 | shouldServerFail = true |
| 2897 | } |
| 2898 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2899 | shouldClientFail = true |
| 2900 | shouldServerFail = true |
| 2901 | } |
| 2902 | |
| 2903 | var sendCipherSuite uint16 |
| 2904 | var expectedServerError, expectedClientError string |
| 2905 | serverCipherSuites := []uint16{suite.id} |
| 2906 | if shouldServerFail { |
| 2907 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2908 | } |
| 2909 | if shouldClientFail { |
| 2910 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2911 | // Configure the server to select ciphers as normal but |
| 2912 | // select an incompatible cipher in ServerHello. |
| 2913 | serverCipherSuites = nil |
| 2914 | sendCipherSuite = suite.id |
| 2915 | } |
| 2916 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2917 | // For cipher suites and versions where exporters are defined, verify |
| 2918 | // that they interoperate. |
| 2919 | var exportKeyingMaterial int |
| 2920 | if ver.version > VersionSSL30 { |
| 2921 | exportKeyingMaterial = 1024 |
| 2922 | } |
| 2923 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2924 | testCases = append(testCases, testCase{ |
| 2925 | testType: serverTest, |
| 2926 | protocol: protocol, |
| 2927 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2928 | config: Config{ |
| 2929 | MinVersion: ver.version, |
| 2930 | MaxVersion: ver.version, |
| 2931 | CipherSuites: []uint16{suite.id}, |
| 2932 | Certificates: []Certificate{cert}, |
| 2933 | PreSharedKey: []byte(psk), |
| 2934 | PreSharedKeyIdentity: pskIdentity, |
| 2935 | Bugs: ProtocolBugs{ |
| 2936 | AdvertiseAllConfiguredCiphers: true, |
| 2937 | }, |
| 2938 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2939 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2940 | certFile: certFile, |
| 2941 | keyFile: keyFile, |
| 2942 | flags: flags, |
| 2943 | resumeSession: true, |
| 2944 | shouldFail: shouldServerFail, |
| 2945 | expectedError: expectedServerError, |
| 2946 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2947 | }) |
| 2948 | |
| 2949 | testCases = append(testCases, testCase{ |
| 2950 | testType: clientTest, |
| 2951 | protocol: protocol, |
| 2952 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2953 | config: Config{ |
| 2954 | MinVersion: ver.version, |
| 2955 | MaxVersion: ver.version, |
| 2956 | CipherSuites: serverCipherSuites, |
| 2957 | Certificates: []Certificate{cert}, |
| 2958 | PreSharedKey: []byte(psk), |
| 2959 | PreSharedKeyIdentity: pskIdentity, |
| 2960 | Bugs: ProtocolBugs{ |
| 2961 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2962 | SendCipherSuite: sendCipherSuite, |
| 2963 | }, |
| 2964 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2965 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2966 | flags: flags, |
| 2967 | resumeSession: true, |
| 2968 | shouldFail: shouldClientFail, |
| 2969 | expectedError: expectedClientError, |
| 2970 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2971 | }) |
| 2972 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2973 | if shouldClientFail { |
| 2974 | return |
| 2975 | } |
| 2976 | |
| 2977 | // Ensure the maximum record size is accepted. |
| 2978 | testCases = append(testCases, testCase{ |
| 2979 | protocol: protocol, |
| 2980 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2981 | config: Config{ |
| 2982 | MinVersion: ver.version, |
| 2983 | MaxVersion: ver.version, |
| 2984 | CipherSuites: []uint16{suite.id}, |
| 2985 | Certificates: []Certificate{cert}, |
| 2986 | PreSharedKey: []byte(psk), |
| 2987 | PreSharedKeyIdentity: pskIdentity, |
| 2988 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2989 | tls13Variant: ver.tls13Variant, |
| 2990 | flags: flags, |
| 2991 | messageLen: maxPlaintext, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2992 | }) |
| 2993 | |
| 2994 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2995 | // and ignored in DTLS. |
| 2996 | var shouldFail bool |
| 2997 | var expectedError string |
| 2998 | if protocol == tls { |
| 2999 | shouldFail = true |
| 3000 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 3001 | } |
| 3002 | |
| 3003 | testCases = append(testCases, testCase{ |
| 3004 | protocol: protocol, |
| 3005 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 3006 | config: Config{ |
| 3007 | MinVersion: ver.version, |
| 3008 | MaxVersion: ver.version, |
| 3009 | CipherSuites: []uint16{suite.id}, |
| 3010 | Certificates: []Certificate{cert}, |
| 3011 | PreSharedKey: []byte(psk), |
| 3012 | PreSharedKeyIdentity: pskIdentity, |
| 3013 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3014 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 3015 | flags: flags, |
| 3016 | damageFirstWrite: true, |
| 3017 | messageLen: maxPlaintext, |
| 3018 | shouldFail: shouldFail, |
| 3019 | expectedError: expectedError, |
| 3020 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 3021 | } |
| 3022 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3023 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 3024 | const bogusCipher = 0xfe00 |
| 3025 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3026 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3027 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 3028 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 3029 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3030 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 3031 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3032 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 3033 | |
| 3034 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3035 | name: "NoSharedCipher", |
| 3036 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3037 | MaxVersion: VersionTLS12, |
| 3038 | CipherSuites: []uint16{}, |
| 3039 | }, |
| 3040 | shouldFail: true, |
| 3041 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 3042 | }) |
| 3043 | |
| 3044 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3045 | name: "NoSharedCipher-TLS13", |
| 3046 | config: Config{ |
| 3047 | MaxVersion: VersionTLS13, |
| 3048 | CipherSuites: []uint16{}, |
| 3049 | }, |
| 3050 | shouldFail: true, |
| 3051 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 3052 | }) |
| 3053 | |
| 3054 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3055 | name: "UnsupportedCipherSuite", |
| 3056 | config: Config{ |
| 3057 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 3058 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3059 | Bugs: ProtocolBugs{ |
| 3060 | IgnorePeerCipherPreferences: true, |
| 3061 | }, |
| 3062 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 3063 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3064 | shouldFail: true, |
| 3065 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 3066 | }) |
| 3067 | |
| 3068 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 3069 | name: "ServerHelloBogusCipher", |
| 3070 | config: Config{ |
| 3071 | MaxVersion: VersionTLS12, |
| 3072 | Bugs: ProtocolBugs{ |
| 3073 | SendCipherSuite: bogusCipher, |
| 3074 | }, |
| 3075 | }, |
| 3076 | shouldFail: true, |
| 3077 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 3078 | }) |
| 3079 | testCases = append(testCases, testCase{ |
| 3080 | name: "ServerHelloBogusCipher-TLS13", |
| 3081 | config: Config{ |
| 3082 | MaxVersion: VersionTLS13, |
| 3083 | Bugs: ProtocolBugs{ |
| 3084 | SendCipherSuite: bogusCipher, |
| 3085 | }, |
| 3086 | }, |
| 3087 | shouldFail: true, |
| 3088 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 3089 | }) |
| 3090 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3091 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3092 | testCases = append(testCases, testCase{ |
| 3093 | testType: serverTest, |
| 3094 | name: "UnknownCipher", |
| 3095 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3096 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3097 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3098 | Bugs: ProtocolBugs{ |
| 3099 | AdvertiseAllConfiguredCiphers: true, |
| 3100 | }, |
| 3101 | }, |
| 3102 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3103 | |
| 3104 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3105 | testCases = append(testCases, testCase{ |
| 3106 | testType: serverTest, |
| 3107 | name: "UnknownCipher-TLS13", |
| 3108 | config: Config{ |
| 3109 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3110 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3111 | Bugs: ProtocolBugs{ |
| 3112 | AdvertiseAllConfiguredCiphers: true, |
| 3113 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3114 | }, |
| 3115 | }) |
| 3116 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 3117 | // Test empty ECDHE_PSK identity hints work as expected. |
| 3118 | testCases = append(testCases, testCase{ |
| 3119 | name: "EmptyECDHEPSKHint", |
| 3120 | config: Config{ |
| 3121 | MaxVersion: VersionTLS12, |
| 3122 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3123 | PreSharedKey: []byte("secret"), |
| 3124 | }, |
| 3125 | flags: []string{"-psk", "secret"}, |
| 3126 | }) |
| 3127 | |
| 3128 | // Test empty PSK identity hints work as expected, even if an explicit |
| 3129 | // ServerKeyExchange is sent. |
| 3130 | testCases = append(testCases, testCase{ |
| 3131 | name: "ExplicitEmptyPSKHint", |
| 3132 | config: Config{ |
| 3133 | MaxVersion: VersionTLS12, |
| 3134 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3135 | PreSharedKey: []byte("secret"), |
| 3136 | Bugs: ProtocolBugs{ |
| 3137 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 3138 | }, |
| 3139 | }, |
| 3140 | flags: []string{"-psk", "secret"}, |
| 3141 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 3142 | |
| 3143 | // Test that clients enforce that the server-sent certificate and cipher |
| 3144 | // suite match in TLS 1.2. |
| 3145 | testCases = append(testCases, testCase{ |
| 3146 | name: "CertificateCipherMismatch-RSA", |
| 3147 | config: Config{ |
| 3148 | MaxVersion: VersionTLS12, |
| 3149 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3150 | Certificates: []Certificate{rsaCertificate}, |
| 3151 | Bugs: ProtocolBugs{ |
| 3152 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 3153 | }, |
| 3154 | }, |
| 3155 | shouldFail: true, |
| 3156 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3157 | }) |
| 3158 | testCases = append(testCases, testCase{ |
| 3159 | name: "CertificateCipherMismatch-ECDSA", |
| 3160 | config: Config{ |
| 3161 | MaxVersion: VersionTLS12, |
| 3162 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3163 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3164 | Bugs: ProtocolBugs{ |
| 3165 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3166 | }, |
| 3167 | }, |
| 3168 | shouldFail: true, |
| 3169 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3170 | }) |
| 3171 | testCases = append(testCases, testCase{ |
| 3172 | name: "CertificateCipherMismatch-Ed25519", |
| 3173 | config: Config{ |
| 3174 | MaxVersion: VersionTLS12, |
| 3175 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3176 | Certificates: []Certificate{ed25519Certificate}, |
| 3177 | Bugs: ProtocolBugs{ |
| 3178 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3179 | }, |
| 3180 | }, |
| 3181 | shouldFail: true, |
| 3182 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3183 | }) |
| 3184 | |
| 3185 | // Test that servers decline to select a cipher suite which is |
| 3186 | // inconsistent with their configured certificate. |
| 3187 | testCases = append(testCases, testCase{ |
| 3188 | testType: serverTest, |
| 3189 | name: "ServerCipherFilter-RSA", |
| 3190 | config: Config{ |
| 3191 | MaxVersion: VersionTLS12, |
| 3192 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3193 | }, |
| 3194 | flags: []string{ |
| 3195 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3196 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3197 | }, |
| 3198 | shouldFail: true, |
| 3199 | expectedError: ":NO_SHARED_CIPHER:", |
| 3200 | }) |
| 3201 | testCases = append(testCases, testCase{ |
| 3202 | testType: serverTest, |
| 3203 | name: "ServerCipherFilter-ECDSA", |
| 3204 | config: Config{ |
| 3205 | MaxVersion: VersionTLS12, |
| 3206 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3207 | }, |
| 3208 | flags: []string{ |
| 3209 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3210 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3211 | }, |
| 3212 | shouldFail: true, |
| 3213 | expectedError: ":NO_SHARED_CIPHER:", |
| 3214 | }) |
| 3215 | testCases = append(testCases, testCase{ |
| 3216 | testType: serverTest, |
| 3217 | name: "ServerCipherFilter-Ed25519", |
| 3218 | config: Config{ |
| 3219 | MaxVersion: VersionTLS12, |
| 3220 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3221 | }, |
| 3222 | flags: []string{ |
| 3223 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 3224 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 3225 | }, |
| 3226 | shouldFail: true, |
| 3227 | expectedError: ":NO_SHARED_CIPHER:", |
| 3228 | }) |
David Benjamin | 364af78 | 2017-07-01 10:35:27 -0400 | [diff] [blame] | 3229 | |
| 3230 | // Test cipher suite negotiation works as expected. Configure a |
| 3231 | // complicated cipher suite configuration. |
| 3232 | const negotiationTestCiphers = "" + |
| 3233 | "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3234 | "[TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384|TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]:" + |
| 3235 | "TLS_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3236 | "TLS_RSA_WITH_AES_128_CBC_SHA:" + |
| 3237 | "[TLS_RSA_WITH_AES_256_GCM_SHA384|TLS_RSA_WITH_AES_256_CBC_SHA]" |
| 3238 | negotiationTests := []struct { |
| 3239 | ciphers []uint16 |
| 3240 | expected uint16 |
| 3241 | }{ |
| 3242 | // Server preferences are honored, including when |
| 3243 | // equipreference groups are involved. |
| 3244 | { |
| 3245 | []uint16{ |
| 3246 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3247 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3248 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3249 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3250 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3251 | }, |
| 3252 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3253 | }, |
| 3254 | { |
| 3255 | []uint16{ |
| 3256 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3257 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3258 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3259 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3260 | }, |
| 3261 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3262 | }, |
| 3263 | { |
| 3264 | []uint16{ |
| 3265 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3266 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3267 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3268 | }, |
| 3269 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3270 | }, |
| 3271 | { |
| 3272 | []uint16{ |
| 3273 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3274 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3275 | }, |
| 3276 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3277 | }, |
| 3278 | // Equipreference groups use the client preference. |
| 3279 | { |
| 3280 | []uint16{ |
| 3281 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3282 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3283 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3284 | }, |
| 3285 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3286 | }, |
| 3287 | { |
| 3288 | []uint16{ |
| 3289 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3290 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3291 | }, |
| 3292 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3293 | }, |
| 3294 | { |
| 3295 | []uint16{ |
| 3296 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3297 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3298 | }, |
| 3299 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3300 | }, |
| 3301 | { |
| 3302 | []uint16{ |
| 3303 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3304 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3305 | }, |
| 3306 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3307 | }, |
| 3308 | { |
| 3309 | []uint16{ |
| 3310 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3311 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3312 | }, |
| 3313 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3314 | }, |
| 3315 | // If there are two equipreference groups, the preferred one |
| 3316 | // takes precedence. |
| 3317 | { |
| 3318 | []uint16{ |
| 3319 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3320 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3321 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3322 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3323 | }, |
| 3324 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3325 | }, |
| 3326 | } |
| 3327 | for i, t := range negotiationTests { |
| 3328 | testCases = append(testCases, testCase{ |
| 3329 | testType: serverTest, |
| 3330 | name: "CipherNegotiation-" + strconv.Itoa(i), |
| 3331 | config: Config{ |
| 3332 | MaxVersion: VersionTLS12, |
| 3333 | CipherSuites: t.ciphers, |
| 3334 | }, |
| 3335 | flags: []string{"-cipher", negotiationTestCiphers}, |
| 3336 | expectedCipher: t.expected, |
| 3337 | }) |
| 3338 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3339 | } |
| 3340 | |
| 3341 | func addBadECDSASignatureTests() { |
| 3342 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 3343 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3344 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3345 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 3346 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3347 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3348 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3349 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3350 | Bugs: ProtocolBugs{ |
| 3351 | BadECDSAR: badR, |
| 3352 | BadECDSAS: badS, |
| 3353 | }, |
| 3354 | }, |
| 3355 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3356 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3357 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3358 | testCases = append(testCases, testCase{ |
| 3359 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 3360 | config: Config{ |
| 3361 | MaxVersion: VersionTLS13, |
| 3362 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3363 | Bugs: ProtocolBugs{ |
| 3364 | BadECDSAR: badR, |
| 3365 | BadECDSAS: badS, |
| 3366 | }, |
| 3367 | }, |
| 3368 | shouldFail: true, |
| 3369 | expectedError: ":BAD_SIGNATURE:", |
| 3370 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3371 | } |
| 3372 | } |
| 3373 | } |
| 3374 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3375 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3376 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3377 | name: "MaxCBCPadding", |
| 3378 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3379 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3380 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3381 | Bugs: ProtocolBugs{ |
| 3382 | MaxPadding: true, |
| 3383 | }, |
| 3384 | }, |
| 3385 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3386 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3387 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3388 | name: "BadCBCPadding", |
| 3389 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3390 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3391 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3392 | Bugs: ProtocolBugs{ |
| 3393 | PaddingFirstByteBad: true, |
| 3394 | }, |
| 3395 | }, |
| 3396 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3397 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3398 | }) |
| 3399 | // OpenSSL previously had an issue where the first byte of padding in |
| 3400 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3401 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3402 | name: "BadCBCPadding255", |
| 3403 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3404 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3405 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3406 | Bugs: ProtocolBugs{ |
| 3407 | MaxPadding: true, |
| 3408 | PaddingFirstByteBadIf255: true, |
| 3409 | }, |
| 3410 | }, |
| 3411 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3412 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3413 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3414 | }) |
| 3415 | } |
| 3416 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3417 | func addCBCSplittingTests() { |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3418 | var cbcCiphers = []struct { |
| 3419 | name string |
| 3420 | cipher uint16 |
| 3421 | }{ |
| 3422 | {"3DES", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
| 3423 | {"AES128", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3424 | {"AES256", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
| 3425 | } |
| 3426 | for _, t := range cbcCiphers { |
| 3427 | testCases = append(testCases, testCase{ |
| 3428 | name: "CBCRecordSplitting-" + t.name, |
| 3429 | config: Config{ |
| 3430 | MaxVersion: VersionTLS10, |
| 3431 | MinVersion: VersionTLS10, |
| 3432 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3433 | Bugs: ProtocolBugs{ |
| 3434 | ExpectRecordSplitting: true, |
| 3435 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3436 | }, |
| 3437 | messageLen: -1, // read until EOF |
| 3438 | resumeSession: true, |
| 3439 | flags: []string{ |
| 3440 | "-async", |
| 3441 | "-write-different-record-sizes", |
| 3442 | "-cbc-record-splitting", |
| 3443 | }, |
| 3444 | }) |
| 3445 | testCases = append(testCases, testCase{ |
| 3446 | name: "CBCRecordSplittingPartialWrite-" + t.name, |
| 3447 | config: Config{ |
| 3448 | MaxVersion: VersionTLS10, |
| 3449 | MinVersion: VersionTLS10, |
| 3450 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3451 | Bugs: ProtocolBugs{ |
| 3452 | ExpectRecordSplitting: true, |
| 3453 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3454 | }, |
| 3455 | messageLen: -1, // read until EOF |
| 3456 | flags: []string{ |
| 3457 | "-async", |
| 3458 | "-write-different-record-sizes", |
| 3459 | "-cbc-record-splitting", |
| 3460 | "-partial-write", |
| 3461 | }, |
| 3462 | }) |
| 3463 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3464 | } |
| 3465 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3466 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3467 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3468 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3469 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 3470 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 3471 | if err != nil { |
| 3472 | panic(err) |
| 3473 | } |
| 3474 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3475 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3476 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3477 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3478 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3479 | testCases = append(testCases, testCase{ |
| 3480 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3481 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3482 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3483 | MinVersion: ver.version, |
| 3484 | MaxVersion: ver.version, |
| 3485 | ClientAuth: RequireAnyClientCert, |
| 3486 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3487 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3488 | tls13Variant: ver.tls13Variant, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3489 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3490 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3491 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3492 | }, |
| 3493 | }) |
| 3494 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3495 | testType: serverTest, |
| 3496 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3497 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3498 | MinVersion: ver.version, |
| 3499 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3500 | Certificates: []Certificate{rsaCertificate}, |
| 3501 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3502 | tls13Variant: ver.tls13Variant, |
| 3503 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3504 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3505 | if ver.version != VersionSSL30 { |
| 3506 | testCases = append(testCases, testCase{ |
| 3507 | testType: serverTest, |
| 3508 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3509 | config: Config{ |
| 3510 | MinVersion: ver.version, |
| 3511 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3512 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3513 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3514 | tls13Variant: ver.tls13Variant, |
| 3515 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3516 | }) |
| 3517 | testCases = append(testCases, testCase{ |
| 3518 | testType: clientTest, |
| 3519 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3520 | config: Config{ |
| 3521 | MinVersion: ver.version, |
| 3522 | MaxVersion: ver.version, |
| 3523 | ClientAuth: RequireAnyClientCert, |
| 3524 | ClientCAs: certPool, |
| 3525 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3526 | tls13Variant: ver.tls13Variant, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3527 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3528 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3529 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3530 | }, |
| 3531 | }) |
| 3532 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3533 | |
| 3534 | testCases = append(testCases, testCase{ |
| 3535 | name: "NoClientCertificate-" + ver.name, |
| 3536 | config: Config{ |
| 3537 | MinVersion: ver.version, |
| 3538 | MaxVersion: ver.version, |
| 3539 | ClientAuth: RequireAnyClientCert, |
| 3540 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3541 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3542 | shouldFail: true, |
| 3543 | expectedLocalError: "client didn't provide a certificate", |
| 3544 | }) |
| 3545 | |
| 3546 | testCases = append(testCases, testCase{ |
| 3547 | // Even if not configured to expect a certificate, OpenSSL will |
| 3548 | // return X509_V_OK as the verify_result. |
| 3549 | testType: serverTest, |
| 3550 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3551 | config: Config{ |
| 3552 | MinVersion: ver.version, |
| 3553 | MaxVersion: ver.version, |
| 3554 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3555 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3556 | flags: []string{ |
| 3557 | "-expect-verify-result", |
| 3558 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3559 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3560 | }) |
| 3561 | |
| 3562 | testCases = append(testCases, testCase{ |
| 3563 | // If a client certificate is not provided, OpenSSL will still |
| 3564 | // return X509_V_OK as the verify_result. |
| 3565 | testType: serverTest, |
| 3566 | name: "NoClientCertificate-Server-" + ver.name, |
| 3567 | config: Config{ |
| 3568 | MinVersion: ver.version, |
| 3569 | MaxVersion: ver.version, |
| 3570 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3571 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3572 | flags: []string{ |
| 3573 | "-expect-verify-result", |
| 3574 | "-verify-peer", |
| 3575 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3576 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3577 | }) |
| 3578 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3579 | certificateRequired := "remote error: certificate required" |
| 3580 | if ver.version < VersionTLS13 { |
| 3581 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3582 | // was used. |
| 3583 | certificateRequired = "remote error: handshake failure" |
| 3584 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3585 | testCases = append(testCases, testCase{ |
| 3586 | testType: serverTest, |
| 3587 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3588 | config: Config{ |
| 3589 | MinVersion: ver.version, |
| 3590 | MaxVersion: ver.version, |
| 3591 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3592 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3593 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3594 | shouldFail: true, |
| 3595 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3596 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3597 | }) |
| 3598 | |
| 3599 | if ver.version != VersionSSL30 { |
| 3600 | testCases = append(testCases, testCase{ |
| 3601 | testType: serverTest, |
| 3602 | name: "SkipClientCertificate-" + ver.name, |
| 3603 | config: Config{ |
| 3604 | MinVersion: ver.version, |
| 3605 | MaxVersion: ver.version, |
| 3606 | Bugs: ProtocolBugs{ |
| 3607 | SkipClientCertificate: true, |
| 3608 | }, |
| 3609 | }, |
| 3610 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3611 | flags: []string{"-verify-peer"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3612 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3613 | shouldFail: true, |
| 3614 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3615 | }) |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3616 | |
| 3617 | testCases = append(testCases, testCase{ |
| 3618 | testType: serverTest, |
| 3619 | name: "VerifyPeerIfNoOBC-NoChannelID-" + ver.name, |
| 3620 | config: Config{ |
| 3621 | MinVersion: ver.version, |
| 3622 | MaxVersion: ver.version, |
| 3623 | }, |
| 3624 | flags: []string{ |
| 3625 | "-enable-channel-id", |
| 3626 | "-verify-peer-if-no-obc", |
| 3627 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3628 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3629 | shouldFail: true, |
| 3630 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3631 | expectedLocalError: certificateRequired, |
| 3632 | }) |
| 3633 | |
| 3634 | testCases = append(testCases, testCase{ |
| 3635 | testType: serverTest, |
| 3636 | name: "VerifyPeerIfNoOBC-ChannelID-" + ver.name, |
| 3637 | config: Config{ |
| 3638 | MinVersion: ver.version, |
| 3639 | MaxVersion: ver.version, |
| 3640 | ChannelID: channelIDKey, |
| 3641 | }, |
| 3642 | expectChannelID: true, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3643 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3644 | flags: []string{ |
| 3645 | "-enable-channel-id", |
| 3646 | "-verify-peer-if-no-obc", |
| 3647 | }, |
| 3648 | }) |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3649 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3650 | |
| 3651 | testCases = append(testCases, testCase{ |
| 3652 | testType: serverTest, |
| 3653 | name: ver.name + "-Server-CertReq-CA-List", |
| 3654 | config: Config{ |
| 3655 | MinVersion: ver.version, |
| 3656 | MaxVersion: ver.version, |
| 3657 | Certificates: []Certificate{rsaCertificate}, |
| 3658 | Bugs: ProtocolBugs{ |
| 3659 | ExpectCertificateReqNames: caNames, |
| 3660 | }, |
| 3661 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3662 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3663 | flags: []string{ |
| 3664 | "-require-any-client-certificate", |
| 3665 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3666 | }, |
| 3667 | }) |
| 3668 | |
| 3669 | testCases = append(testCases, testCase{ |
| 3670 | testType: clientTest, |
| 3671 | name: ver.name + "-Client-CertReq-CA-List", |
| 3672 | config: Config{ |
| 3673 | MinVersion: ver.version, |
| 3674 | MaxVersion: ver.version, |
| 3675 | Certificates: []Certificate{rsaCertificate}, |
| 3676 | ClientAuth: RequireAnyClientCert, |
| 3677 | ClientCAs: certPool, |
| 3678 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3679 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3680 | flags: []string{ |
| 3681 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3682 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3683 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3684 | }, |
| 3685 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3686 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3687 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3688 | // Client auth is only legal in certificate-based ciphers. |
| 3689 | testCases = append(testCases, testCase{ |
| 3690 | testType: clientTest, |
| 3691 | name: "ClientAuth-PSK", |
| 3692 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3693 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3694 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3695 | PreSharedKey: []byte("secret"), |
| 3696 | ClientAuth: RequireAnyClientCert, |
| 3697 | }, |
| 3698 | flags: []string{ |
| 3699 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3700 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3701 | "-psk", "secret", |
| 3702 | }, |
| 3703 | shouldFail: true, |
| 3704 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3705 | }) |
| 3706 | testCases = append(testCases, testCase{ |
| 3707 | testType: clientTest, |
| 3708 | name: "ClientAuth-ECDHE_PSK", |
| 3709 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3710 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3711 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3712 | PreSharedKey: []byte("secret"), |
| 3713 | ClientAuth: RequireAnyClientCert, |
| 3714 | }, |
| 3715 | flags: []string{ |
| 3716 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3717 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3718 | "-psk", "secret", |
| 3719 | }, |
| 3720 | shouldFail: true, |
| 3721 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3722 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3723 | |
| 3724 | // Regression test for a bug where the client CA list, if explicitly |
| 3725 | // set to NULL, was mis-encoded. |
| 3726 | testCases = append(testCases, testCase{ |
| 3727 | testType: serverTest, |
| 3728 | name: "Null-Client-CA-List", |
| 3729 | config: Config{ |
| 3730 | MaxVersion: VersionTLS12, |
| 3731 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3732 | Bugs: ProtocolBugs{ |
| 3733 | ExpectCertificateReqNames: [][]byte{}, |
| 3734 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3735 | }, |
| 3736 | flags: []string{ |
| 3737 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3738 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3739 | }, |
| 3740 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3741 | } |
| 3742 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3743 | func addExtendedMasterSecretTests() { |
| 3744 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3745 | |
| 3746 | for _, with := range []bool{false, true} { |
| 3747 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3748 | if with { |
| 3749 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3750 | } |
| 3751 | |
| 3752 | for _, isClient := range []bool{false, true} { |
| 3753 | suffix := "-Server" |
| 3754 | testType := serverTest |
| 3755 | if isClient { |
| 3756 | suffix = "-Client" |
| 3757 | testType = clientTest |
| 3758 | } |
| 3759 | |
| 3760 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3761 | // In TLS 1.3, the extension is irrelevant and |
| 3762 | // always reports as enabled. |
| 3763 | var flags []string |
| 3764 | if with || ver.version >= VersionTLS13 { |
| 3765 | flags = []string{expectEMSFlag} |
| 3766 | } |
| 3767 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3768 | test := testCase{ |
| 3769 | testType: testType, |
| 3770 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3771 | config: Config{ |
| 3772 | MinVersion: ver.version, |
| 3773 | MaxVersion: ver.version, |
| 3774 | Bugs: ProtocolBugs{ |
| 3775 | NoExtendedMasterSecret: !with, |
| 3776 | RequireExtendedMasterSecret: with, |
| 3777 | }, |
| 3778 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3779 | tls13Variant: ver.tls13Variant, |
| 3780 | flags: flags, |
| 3781 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3782 | } |
| 3783 | if test.shouldFail { |
| 3784 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3785 | } |
| 3786 | testCases = append(testCases, test) |
| 3787 | } |
| 3788 | } |
| 3789 | } |
| 3790 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3791 | for _, isClient := range []bool{false, true} { |
| 3792 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3793 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3794 | boolToWord := func(b bool) string { |
| 3795 | if b { |
| 3796 | return "Yes" |
| 3797 | } |
| 3798 | return "No" |
| 3799 | } |
| 3800 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3801 | if isClient { |
| 3802 | suffix += "Client" |
| 3803 | } else { |
| 3804 | suffix += "Server" |
| 3805 | } |
| 3806 | |
| 3807 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3808 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3809 | Bugs: ProtocolBugs{ |
| 3810 | RequireExtendedMasterSecret: true, |
| 3811 | }, |
| 3812 | } |
| 3813 | |
| 3814 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3815 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3816 | Bugs: ProtocolBugs{ |
| 3817 | NoExtendedMasterSecret: true, |
| 3818 | }, |
| 3819 | } |
| 3820 | |
| 3821 | test := testCase{ |
| 3822 | name: "ExtendedMasterSecret-" + suffix, |
| 3823 | resumeSession: true, |
| 3824 | } |
| 3825 | |
| 3826 | if !isClient { |
| 3827 | test.testType = serverTest |
| 3828 | } |
| 3829 | |
| 3830 | if supportedInFirstConnection { |
| 3831 | test.config = supportedConfig |
| 3832 | } else { |
| 3833 | test.config = noSupportConfig |
| 3834 | } |
| 3835 | |
| 3836 | if supportedInResumeConnection { |
| 3837 | test.resumeConfig = &supportedConfig |
| 3838 | } else { |
| 3839 | test.resumeConfig = &noSupportConfig |
| 3840 | } |
| 3841 | |
| 3842 | switch suffix { |
| 3843 | case "YesToYes-Client", "YesToYes-Server": |
| 3844 | // When a session is resumed, it should |
| 3845 | // still be aware that its master |
| 3846 | // secret was generated via EMS and |
| 3847 | // thus it's safe to use tls-unique. |
| 3848 | test.flags = []string{expectEMSFlag} |
| 3849 | case "NoToYes-Server": |
| 3850 | // If an original connection did not |
| 3851 | // contain EMS, but a resumption |
| 3852 | // handshake does, then a server should |
| 3853 | // not resume the session. |
| 3854 | test.expectResumeRejected = true |
| 3855 | case "YesToNo-Server": |
| 3856 | // Resuming an EMS session without the |
| 3857 | // EMS extension should cause the |
| 3858 | // server to abort the connection. |
| 3859 | test.shouldFail = true |
| 3860 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3861 | case "NoToYes-Client": |
| 3862 | // A client should abort a connection |
| 3863 | // where the server resumed a non-EMS |
| 3864 | // session but echoed the EMS |
| 3865 | // extension. |
| 3866 | test.shouldFail = true |
| 3867 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3868 | case "YesToNo-Client": |
| 3869 | // A client should abort a connection |
| 3870 | // where the server didn't echo EMS |
| 3871 | // when the session used it. |
| 3872 | test.shouldFail = true |
| 3873 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3874 | } |
| 3875 | |
| 3876 | testCases = append(testCases, test) |
| 3877 | } |
| 3878 | } |
| 3879 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3880 | |
| 3881 | // Switching EMS on renegotiation is forbidden. |
| 3882 | testCases = append(testCases, testCase{ |
| 3883 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3884 | config: Config{ |
| 3885 | MaxVersion: VersionTLS12, |
| 3886 | Bugs: ProtocolBugs{ |
| 3887 | NoExtendedMasterSecret: true, |
| 3888 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3889 | }, |
| 3890 | }, |
| 3891 | renegotiate: 1, |
| 3892 | flags: []string{ |
| 3893 | "-renegotiate-freely", |
| 3894 | "-expect-total-renegotiations", "1", |
| 3895 | }, |
| 3896 | }) |
| 3897 | |
| 3898 | testCases = append(testCases, testCase{ |
| 3899 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3900 | config: Config{ |
| 3901 | MaxVersion: VersionTLS12, |
| 3902 | Bugs: ProtocolBugs{ |
| 3903 | NoExtendedMasterSecret: true, |
| 3904 | }, |
| 3905 | }, |
| 3906 | renegotiate: 1, |
| 3907 | flags: []string{ |
| 3908 | "-renegotiate-freely", |
| 3909 | "-expect-total-renegotiations", "1", |
| 3910 | }, |
| 3911 | shouldFail: true, |
| 3912 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3913 | }) |
| 3914 | |
| 3915 | testCases = append(testCases, testCase{ |
| 3916 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3917 | config: Config{ |
| 3918 | MaxVersion: VersionTLS12, |
| 3919 | Bugs: ProtocolBugs{ |
| 3920 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3921 | }, |
| 3922 | }, |
| 3923 | renegotiate: 1, |
| 3924 | flags: []string{ |
| 3925 | "-renegotiate-freely", |
| 3926 | "-expect-total-renegotiations", "1", |
| 3927 | }, |
| 3928 | shouldFail: true, |
| 3929 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3930 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3931 | } |
| 3932 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3933 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3934 | protocol protocol |
| 3935 | async bool |
| 3936 | splitHandshake bool |
| 3937 | packHandshakeFlight bool |
| 3938 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3939 | } |
| 3940 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3941 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3942 | // various conditions. Some of these are redundant with other tests, but they |
| 3943 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3944 | func addAllStateMachineCoverageTests() { |
| 3945 | for _, async := range []bool{false, true} { |
| 3946 | for _, protocol := range []protocol{tls, dtls} { |
| 3947 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3948 | protocol: protocol, |
| 3949 | async: async, |
| 3950 | }) |
| 3951 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3952 | protocol: protocol, |
| 3953 | async: async, |
| 3954 | implicitHandshake: true, |
| 3955 | }) |
| 3956 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3957 | protocol: protocol, |
| 3958 | async: async, |
| 3959 | splitHandshake: true, |
| 3960 | }) |
| 3961 | if protocol == tls { |
| 3962 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3963 | protocol: protocol, |
| 3964 | async: async, |
| 3965 | packHandshakeFlight: true, |
| 3966 | }) |
| 3967 | } |
| 3968 | } |
| 3969 | } |
| 3970 | } |
| 3971 | |
| 3972 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3973 | var tests []testCase |
| 3974 | |
| 3975 | // Basic handshake, with resumption. Client and server, |
| 3976 | // session ID and session ticket. |
| 3977 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3978 | name: "Basic-Client", |
| 3979 | config: Config{ |
| 3980 | MaxVersion: VersionTLS12, |
| 3981 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3982 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3983 | // Ensure session tickets are used, not session IDs. |
| 3984 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3985 | }) |
| 3986 | tests = append(tests, testCase{ |
| 3987 | name: "Basic-Client-RenewTicket", |
| 3988 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3989 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3990 | Bugs: ProtocolBugs{ |
| 3991 | RenewTicketOnResume: true, |
| 3992 | }, |
| 3993 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3994 | flags: []string{"-expect-ticket-renewal"}, |
| 3995 | resumeSession: true, |
| 3996 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3997 | }) |
| 3998 | tests = append(tests, testCase{ |
| 3999 | name: "Basic-Client-NoTicket", |
| 4000 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4001 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4002 | SessionTicketsDisabled: true, |
| 4003 | }, |
| 4004 | resumeSession: true, |
| 4005 | }) |
| 4006 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 4007 | testType: serverTest, |
| 4008 | name: "Basic-Server", |
| 4009 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4010 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 4011 | Bugs: ProtocolBugs{ |
| 4012 | RequireSessionTickets: true, |
| 4013 | }, |
| 4014 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4015 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 4016 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4017 | }) |
| 4018 | tests = append(tests, testCase{ |
| 4019 | testType: serverTest, |
| 4020 | name: "Basic-Server-NoTickets", |
| 4021 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4022 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4023 | SessionTicketsDisabled: true, |
| 4024 | }, |
| 4025 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 4026 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4027 | }) |
| 4028 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4029 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4030 | name: "Basic-Server-EarlyCallback", |
| 4031 | config: Config{ |
| 4032 | MaxVersion: VersionTLS12, |
| 4033 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4034 | flags: []string{"-use-early-callback"}, |
| 4035 | resumeSession: true, |
| 4036 | }) |
| 4037 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4038 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4039 | if config.protocol == tls { |
| 4040 | tests = append(tests, testCase{ |
| 4041 | name: "TLS13-1RTT-Client", |
| 4042 | config: Config{ |
| 4043 | MaxVersion: VersionTLS13, |
| 4044 | MinVersion: VersionTLS13, |
| 4045 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 4046 | resumeSession: true, |
| 4047 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4048 | }) |
| 4049 | |
| 4050 | tests = append(tests, testCase{ |
| 4051 | testType: serverTest, |
| 4052 | name: "TLS13-1RTT-Server", |
| 4053 | config: Config{ |
| 4054 | MaxVersion: VersionTLS13, |
| 4055 | MinVersion: VersionTLS13, |
| 4056 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 4057 | resumeSession: true, |
| 4058 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 4059 | // TLS 1.3 uses tickets, so the session should not be |
| 4060 | // cached statefully. |
| 4061 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4062 | }) |
| 4063 | |
| 4064 | tests = append(tests, testCase{ |
| 4065 | name: "TLS13-HelloRetryRequest-Client", |
| 4066 | config: Config{ |
| 4067 | MaxVersion: VersionTLS13, |
| 4068 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 4069 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 4070 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4071 | CurvePreferences: []CurveID{CurveP384}, |
| 4072 | Bugs: ProtocolBugs{ |
| 4073 | ExpectMissingKeyShare: true, |
| 4074 | }, |
| 4075 | }, |
| 4076 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 4077 | resumeSession: true, |
| 4078 | }) |
| 4079 | |
| 4080 | tests = append(tests, testCase{ |
| 4081 | testType: serverTest, |
| 4082 | name: "TLS13-HelloRetryRequest-Server", |
| 4083 | config: Config{ |
| 4084 | MaxVersion: VersionTLS13, |
| 4085 | MinVersion: VersionTLS13, |
| 4086 | // Require a HelloRetryRequest for every curve. |
| 4087 | DefaultCurves: []CurveID{}, |
| 4088 | }, |
| 4089 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 4090 | resumeSession: true, |
| 4091 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4092 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4093 | tests = append(tests, testCase{ |
| 4094 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4095 | name: "TLS13-EarlyData-TooMuchData-Client", |
| 4096 | config: Config{ |
| 4097 | MaxVersion: VersionTLS13, |
| 4098 | MinVersion: VersionTLS13, |
| 4099 | MaxEarlyDataSize: 2, |
| 4100 | }, |
| 4101 | resumeConfig: &Config{ |
| 4102 | MaxVersion: VersionTLS13, |
| 4103 | MinVersion: VersionTLS13, |
| 4104 | MaxEarlyDataSize: 2, |
| 4105 | Bugs: ProtocolBugs{ |
| 4106 | ExpectEarlyData: [][]byte{{'h', 'e'}}, |
| 4107 | }, |
| 4108 | }, |
| 4109 | resumeShimPrefix: "llo", |
| 4110 | resumeSession: true, |
| 4111 | flags: []string{ |
| 4112 | "-enable-early-data", |
| 4113 | "-expect-early-data-info", |
| 4114 | "-expect-accept-early-data", |
| 4115 | "-on-resume-shim-writes-first", |
| 4116 | }, |
| 4117 | }) |
| 4118 | |
| 4119 | // Unfinished writes can only be tested when operations are async. EarlyData |
| 4120 | // can't be tested as part of an ImplicitHandshake in this case since |
| 4121 | // otherwise the early data will be sent as normal data. |
| 4122 | if config.async && !config.implicitHandshake { |
| 4123 | tests = append(tests, testCase{ |
| 4124 | testType: clientTest, |
| 4125 | name: "TLS13-EarlyData-UnfinishedWrite-Client", |
| 4126 | config: Config{ |
| 4127 | MaxVersion: VersionTLS13, |
| 4128 | MinVersion: VersionTLS13, |
| 4129 | MaxEarlyDataSize: 16384, |
| 4130 | }, |
| 4131 | resumeConfig: &Config{ |
| 4132 | MaxVersion: VersionTLS13, |
| 4133 | MinVersion: VersionTLS13, |
| 4134 | MaxEarlyDataSize: 16384, |
| 4135 | Bugs: ProtocolBugs{ |
| 4136 | ExpectLateEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4137 | }, |
| 4138 | }, |
| 4139 | resumeSession: true, |
| 4140 | flags: []string{ |
| 4141 | "-enable-early-data", |
| 4142 | "-expect-early-data-info", |
| 4143 | "-expect-accept-early-data", |
| 4144 | "-on-resume-read-with-unfinished-write", |
| 4145 | "-on-resume-shim-writes-first", |
| 4146 | }, |
| 4147 | }) |
| 4148 | |
| 4149 | // Rejected unfinished writes are discarded (from the |
| 4150 | // perspective of the calling application) on 0-RTT |
| 4151 | // reject. |
| 4152 | tests = append(tests, testCase{ |
| 4153 | testType: clientTest, |
| 4154 | name: "TLS13-EarlyData-RejectUnfinishedWrite-Client", |
| 4155 | config: Config{ |
| 4156 | MaxVersion: VersionTLS13, |
| 4157 | MinVersion: VersionTLS13, |
| 4158 | MaxEarlyDataSize: 16384, |
| 4159 | }, |
| 4160 | resumeConfig: &Config{ |
| 4161 | MaxVersion: VersionTLS13, |
| 4162 | MinVersion: VersionTLS13, |
| 4163 | MaxEarlyDataSize: 16384, |
| 4164 | Bugs: ProtocolBugs{ |
| 4165 | AlwaysRejectEarlyData: true, |
| 4166 | }, |
| 4167 | }, |
| 4168 | resumeSession: true, |
| 4169 | flags: []string{ |
| 4170 | "-enable-early-data", |
| 4171 | "-expect-early-data-info", |
| 4172 | "-expect-reject-early-data", |
| 4173 | "-on-resume-read-with-unfinished-write", |
| 4174 | "-on-resume-shim-writes-first", |
| 4175 | }, |
| 4176 | }) |
| 4177 | } |
| 4178 | |
| 4179 | tests = append(tests, testCase{ |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4180 | testType: serverTest, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4181 | name: "TLS13-MaxEarlyData-Server", |
| 4182 | config: Config{ |
| 4183 | MaxVersion: VersionTLS13, |
| 4184 | MinVersion: VersionTLS13, |
| 4185 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 4186 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4187 | ExpectEarlyDataAccepted: true, |
| 4188 | }, |
| 4189 | }, |
| 4190 | messageCount: 2, |
| 4191 | resumeSession: true, |
| 4192 | flags: []string{ |
| 4193 | "-enable-early-data", |
| 4194 | "-expect-accept-early-data", |
| 4195 | }, |
| 4196 | shouldFail: true, |
| 4197 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 4198 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4199 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4200 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4201 | // TLS client auth. |
| 4202 | tests = append(tests, testCase{ |
| 4203 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4204 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4205 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4206 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4207 | ClientAuth: RequestClientCert, |
| 4208 | }, |
| 4209 | }) |
| 4210 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4211 | testType: serverTest, |
| 4212 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4213 | config: Config{ |
| 4214 | MaxVersion: VersionTLS12, |
| 4215 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4216 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4217 | flags: []string{"-verify-peer"}, |
| 4218 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4219 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4220 | tests = append(tests, testCase{ |
| 4221 | testType: clientTest, |
| 4222 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 4223 | config: Config{ |
| 4224 | MaxVersion: VersionSSL30, |
| 4225 | ClientAuth: RequestClientCert, |
| 4226 | }, |
| 4227 | }) |
| 4228 | tests = append(tests, testCase{ |
| 4229 | testType: serverTest, |
| 4230 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 4231 | config: Config{ |
| 4232 | MaxVersion: VersionSSL30, |
| 4233 | }, |
| 4234 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4235 | flags: []string{"-verify-peer"}, |
| 4236 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4237 | tests = append(tests, testCase{ |
| 4238 | testType: clientTest, |
| 4239 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 4240 | config: Config{ |
| 4241 | MaxVersion: VersionTLS13, |
| 4242 | ClientAuth: RequestClientCert, |
| 4243 | }, |
| 4244 | }) |
| 4245 | tests = append(tests, testCase{ |
| 4246 | testType: serverTest, |
| 4247 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 4248 | config: Config{ |
| 4249 | MaxVersion: VersionTLS13, |
| 4250 | }, |
| 4251 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4252 | flags: []string{"-verify-peer"}, |
| 4253 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4254 | } |
| 4255 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4256 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4257 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4258 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4259 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4260 | ClientAuth: RequireAnyClientCert, |
| 4261 | }, |
| 4262 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 4263 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4264 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4265 | }, |
| 4266 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4267 | tests = append(tests, testCase{ |
| 4268 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4269 | name: "ClientAuth-RSA-Client-TLS13", |
| 4270 | config: Config{ |
| 4271 | MaxVersion: VersionTLS13, |
| 4272 | ClientAuth: RequireAnyClientCert, |
| 4273 | }, |
| 4274 | flags: []string{ |
| 4275 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4276 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4277 | }, |
| 4278 | }) |
| 4279 | tests = append(tests, testCase{ |
| 4280 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4281 | name: "ClientAuth-ECDSA-Client", |
| 4282 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4283 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4284 | ClientAuth: RequireAnyClientCert, |
| 4285 | }, |
| 4286 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4287 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4288 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4289 | }, |
| 4290 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4291 | tests = append(tests, testCase{ |
| 4292 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4293 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 4294 | config: Config{ |
| 4295 | MaxVersion: VersionTLS13, |
| 4296 | ClientAuth: RequireAnyClientCert, |
| 4297 | }, |
| 4298 | flags: []string{ |
| 4299 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4300 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 4301 | }, |
| 4302 | }) |
| 4303 | tests = append(tests, testCase{ |
| 4304 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4305 | name: "ClientAuth-NoCertificate-OldCallback", |
| 4306 | config: Config{ |
| 4307 | MaxVersion: VersionTLS12, |
| 4308 | ClientAuth: RequestClientCert, |
| 4309 | }, |
| 4310 | flags: []string{"-use-old-client-cert-callback"}, |
| 4311 | }) |
| 4312 | tests = append(tests, testCase{ |
| 4313 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4314 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 4315 | config: Config{ |
| 4316 | MaxVersion: VersionTLS13, |
| 4317 | ClientAuth: RequestClientCert, |
| 4318 | }, |
| 4319 | flags: []string{"-use-old-client-cert-callback"}, |
| 4320 | }) |
| 4321 | tests = append(tests, testCase{ |
| 4322 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4323 | name: "ClientAuth-OldCallback", |
| 4324 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4325 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4326 | ClientAuth: RequireAnyClientCert, |
| 4327 | }, |
| 4328 | flags: []string{ |
| 4329 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4330 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4331 | "-use-old-client-cert-callback", |
| 4332 | }, |
| 4333 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4334 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4335 | testType: clientTest, |
| 4336 | name: "ClientAuth-OldCallback-TLS13", |
| 4337 | config: Config{ |
| 4338 | MaxVersion: VersionTLS13, |
| 4339 | ClientAuth: RequireAnyClientCert, |
| 4340 | }, |
| 4341 | flags: []string{ |
| 4342 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4343 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4344 | "-use-old-client-cert-callback", |
| 4345 | }, |
| 4346 | }) |
| 4347 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4348 | testType: serverTest, |
| 4349 | name: "ClientAuth-Server", |
| 4350 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4351 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4352 | Certificates: []Certificate{rsaCertificate}, |
| 4353 | }, |
| 4354 | flags: []string{"-require-any-client-certificate"}, |
| 4355 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4356 | tests = append(tests, testCase{ |
| 4357 | testType: serverTest, |
| 4358 | name: "ClientAuth-Server-TLS13", |
| 4359 | config: Config{ |
| 4360 | MaxVersion: VersionTLS13, |
| 4361 | Certificates: []Certificate{rsaCertificate}, |
| 4362 | }, |
| 4363 | flags: []string{"-require-any-client-certificate"}, |
| 4364 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4365 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4366 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4367 | tests = append(tests, testCase{ |
| 4368 | testType: serverTest, |
| 4369 | name: "Basic-Server-RSA", |
| 4370 | config: Config{ |
| 4371 | MaxVersion: VersionTLS12, |
| 4372 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4373 | }, |
| 4374 | flags: []string{ |
| 4375 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4376 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4377 | }, |
| 4378 | }) |
| 4379 | tests = append(tests, testCase{ |
| 4380 | testType: serverTest, |
| 4381 | name: "Basic-Server-ECDHE-RSA", |
| 4382 | config: Config{ |
| 4383 | MaxVersion: VersionTLS12, |
| 4384 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4385 | }, |
| 4386 | flags: []string{ |
| 4387 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4388 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4389 | }, |
| 4390 | }) |
| 4391 | tests = append(tests, testCase{ |
| 4392 | testType: serverTest, |
| 4393 | name: "Basic-Server-ECDHE-ECDSA", |
| 4394 | config: Config{ |
| 4395 | MaxVersion: VersionTLS12, |
| 4396 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4397 | }, |
| 4398 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4399 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4400 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4401 | }, |
| 4402 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4403 | tests = append(tests, testCase{ |
| 4404 | testType: serverTest, |
| 4405 | name: "Basic-Server-Ed25519", |
| 4406 | config: Config{ |
| 4407 | MaxVersion: VersionTLS12, |
| 4408 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4409 | }, |
| 4410 | flags: []string{ |
| 4411 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4412 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4413 | "-enable-ed25519", |
| 4414 | }, |
| 4415 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4416 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4417 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4418 | tests = append(tests, testCase{ |
| 4419 | name: "SessionTicketsDisabled-Client", |
| 4420 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4421 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4422 | SessionTicketsDisabled: true, |
| 4423 | }, |
| 4424 | }) |
| 4425 | tests = append(tests, testCase{ |
| 4426 | testType: serverTest, |
| 4427 | name: "SessionTicketsDisabled-Server", |
| 4428 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4429 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4430 | SessionTicketsDisabled: true, |
| 4431 | }, |
| 4432 | }) |
| 4433 | |
| 4434 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4435 | // identity hint. |
| 4436 | tests = append(tests, testCase{ |
| 4437 | name: "EmptyPSKHint-Client", |
| 4438 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4439 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4440 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4441 | PreSharedKey: []byte("secret"), |
| 4442 | }, |
| 4443 | flags: []string{"-psk", "secret"}, |
| 4444 | }) |
| 4445 | tests = append(tests, testCase{ |
| 4446 | testType: serverTest, |
| 4447 | name: "EmptyPSKHint-Server", |
| 4448 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4449 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4450 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4451 | PreSharedKey: []byte("secret"), |
| 4452 | }, |
| 4453 | flags: []string{"-psk", "secret"}, |
| 4454 | }) |
| 4455 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4456 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4457 | tests = append(tests, testCase{ |
| 4458 | testType: clientTest, |
| 4459 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4460 | config: Config{ |
| 4461 | MaxVersion: VersionTLS12, |
| 4462 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4463 | flags: []string{ |
| 4464 | "-enable-ocsp-stapling", |
| 4465 | "-expect-ocsp-response", |
| 4466 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4467 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4468 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4469 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4470 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4471 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4472 | testType: serverTest, |
| 4473 | name: "OCSPStapling-Server", |
| 4474 | config: Config{ |
| 4475 | MaxVersion: VersionTLS12, |
| 4476 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4477 | expectedOCSPResponse: testOCSPResponse, |
| 4478 | flags: []string{ |
| 4479 | "-ocsp-response", |
| 4480 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4481 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4482 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4483 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4484 | tests = append(tests, testCase{ |
| 4485 | testType: clientTest, |
| 4486 | name: "OCSPStapling-Client-TLS13", |
| 4487 | config: Config{ |
| 4488 | MaxVersion: VersionTLS13, |
| 4489 | }, |
| 4490 | flags: []string{ |
| 4491 | "-enable-ocsp-stapling", |
| 4492 | "-expect-ocsp-response", |
| 4493 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4494 | "-verify-peer", |
| 4495 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4496 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4497 | }) |
| 4498 | tests = append(tests, testCase{ |
| 4499 | testType: serverTest, |
| 4500 | name: "OCSPStapling-Server-TLS13", |
| 4501 | config: Config{ |
| 4502 | MaxVersion: VersionTLS13, |
| 4503 | }, |
| 4504 | expectedOCSPResponse: testOCSPResponse, |
| 4505 | flags: []string{ |
| 4506 | "-ocsp-response", |
| 4507 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4508 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4509 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4510 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4511 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4512 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4513 | for _, vers := range tlsVersions { |
| 4514 | if config.protocol == dtls && !vers.hasDTLS { |
| 4515 | continue |
| 4516 | } |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4517 | for _, useCustomCallback := range []bool{false, true} { |
| 4518 | for _, testType := range []testType{clientTest, serverTest} { |
| 4519 | suffix := "-Client" |
| 4520 | if testType == serverTest { |
| 4521 | suffix = "-Server" |
| 4522 | } |
| 4523 | suffix += "-" + vers.name |
| 4524 | if useCustomCallback { |
| 4525 | suffix += "-CustomCallback" |
| 4526 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4527 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4528 | flags := []string{"-verify-peer"} |
| 4529 | if testType == serverTest { |
| 4530 | flags = append(flags, "-require-any-client-certificate") |
| 4531 | } |
| 4532 | if useCustomCallback { |
| 4533 | flags = append(flags, "-use-custom-verify-callback") |
| 4534 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4535 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4536 | tests = append(tests, testCase{ |
| 4537 | testType: testType, |
| 4538 | name: "CertificateVerificationSucceed" + suffix, |
| 4539 | config: Config{ |
| 4540 | MaxVersion: vers.version, |
| 4541 | Certificates: []Certificate{rsaCertificate}, |
| 4542 | }, |
| 4543 | tls13Variant: vers.tls13Variant, |
| 4544 | flags: append([]string{"-expect-verify-result"}, flags...), |
| 4545 | resumeSession: true, |
| 4546 | }) |
| 4547 | tests = append(tests, testCase{ |
| 4548 | testType: testType, |
| 4549 | name: "CertificateVerificationFail" + suffix, |
| 4550 | config: Config{ |
| 4551 | MaxVersion: vers.version, |
| 4552 | Certificates: []Certificate{rsaCertificate}, |
| 4553 | }, |
| 4554 | tls13Variant: vers.tls13Variant, |
| 4555 | flags: append([]string{"-verify-fail"}, flags...), |
| 4556 | shouldFail: true, |
| 4557 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4558 | }) |
| 4559 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4560 | } |
| 4561 | |
| 4562 | // By default, the client is in a soft fail mode where the peer |
| 4563 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4564 | tests = append(tests, testCase{ |
| 4565 | testType: clientTest, |
| 4566 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4567 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4568 | MaxVersion: vers.version, |
| 4569 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4570 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4571 | tls13Variant: vers.tls13Variant, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4572 | flags: []string{ |
| 4573 | "-verify-fail", |
| 4574 | "-expect-verify-result", |
| 4575 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4576 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4577 | }) |
| 4578 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4579 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4580 | tests = append(tests, testCase{ |
| 4581 | name: "ShimSendAlert", |
| 4582 | flags: []string{"-send-alert"}, |
| 4583 | shimWritesFirst: true, |
| 4584 | shouldFail: true, |
| 4585 | expectedLocalError: "remote error: decompression failure", |
| 4586 | }) |
| 4587 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4588 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4589 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4590 | name: "Renegotiate-Client", |
| 4591 | config: Config{ |
| 4592 | MaxVersion: VersionTLS12, |
| 4593 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4594 | renegotiate: 1, |
| 4595 | flags: []string{ |
| 4596 | "-renegotiate-freely", |
| 4597 | "-expect-total-renegotiations", "1", |
| 4598 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4599 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4600 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4601 | tests = append(tests, testCase{ |
| 4602 | name: "SendHalfHelloRequest", |
| 4603 | config: Config{ |
| 4604 | MaxVersion: VersionTLS12, |
| 4605 | Bugs: ProtocolBugs{ |
| 4606 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4607 | }, |
| 4608 | }, |
| 4609 | sendHalfHelloRequest: true, |
| 4610 | flags: []string{"-renegotiate-ignore"}, |
| 4611 | shouldFail: true, |
| 4612 | expectedError: ":UNEXPECTED_RECORD:", |
| 4613 | }) |
| 4614 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4615 | // NPN on client and server; results in post-handshake message. |
| 4616 | tests = append(tests, testCase{ |
| 4617 | name: "NPN-Client", |
| 4618 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4619 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4620 | NextProtos: []string{"foo"}, |
| 4621 | }, |
| 4622 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4623 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4624 | expectedNextProto: "foo", |
| 4625 | expectedNextProtoType: npn, |
| 4626 | }) |
| 4627 | tests = append(tests, testCase{ |
| 4628 | testType: serverTest, |
| 4629 | name: "NPN-Server", |
| 4630 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4631 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4632 | NextProtos: []string{"bar"}, |
| 4633 | }, |
| 4634 | flags: []string{ |
| 4635 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4636 | "-expect-next-proto", "bar", |
| 4637 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4638 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4639 | expectedNextProto: "bar", |
| 4640 | expectedNextProtoType: npn, |
| 4641 | }) |
| 4642 | |
| 4643 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4644 | |
| 4645 | // Client does False Start and negotiates NPN. |
| 4646 | tests = append(tests, testCase{ |
| 4647 | name: "FalseStart", |
| 4648 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4649 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4650 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4651 | NextProtos: []string{"foo"}, |
| 4652 | Bugs: ProtocolBugs{ |
| 4653 | ExpectFalseStart: true, |
| 4654 | }, |
| 4655 | }, |
| 4656 | flags: []string{ |
| 4657 | "-false-start", |
| 4658 | "-select-next-proto", "foo", |
| 4659 | }, |
| 4660 | shimWritesFirst: true, |
| 4661 | resumeSession: true, |
| 4662 | }) |
| 4663 | |
| 4664 | // Client does False Start and negotiates ALPN. |
| 4665 | tests = append(tests, testCase{ |
| 4666 | name: "FalseStart-ALPN", |
| 4667 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4668 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4669 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4670 | NextProtos: []string{"foo"}, |
| 4671 | Bugs: ProtocolBugs{ |
| 4672 | ExpectFalseStart: true, |
| 4673 | }, |
| 4674 | }, |
| 4675 | flags: []string{ |
| 4676 | "-false-start", |
| 4677 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4678 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4679 | }, |
| 4680 | shimWritesFirst: true, |
| 4681 | resumeSession: true, |
| 4682 | }) |
| 4683 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4684 | // False Start without session tickets. |
| 4685 | tests = append(tests, testCase{ |
| 4686 | name: "FalseStart-SessionTicketsDisabled", |
| 4687 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4688 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4689 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4690 | NextProtos: []string{"foo"}, |
| 4691 | SessionTicketsDisabled: true, |
| 4692 | Bugs: ProtocolBugs{ |
| 4693 | ExpectFalseStart: true, |
| 4694 | }, |
| 4695 | }, |
| 4696 | flags: []string{ |
| 4697 | "-false-start", |
| 4698 | "-select-next-proto", "foo", |
| 4699 | }, |
| 4700 | shimWritesFirst: true, |
| 4701 | }) |
| 4702 | |
| 4703 | // Server parses a V2ClientHello. |
| 4704 | tests = append(tests, testCase{ |
| 4705 | testType: serverTest, |
| 4706 | name: "SendV2ClientHello", |
| 4707 | config: Config{ |
| 4708 | // Choose a cipher suite that does not involve |
| 4709 | // elliptic curves, so no extensions are |
| 4710 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4711 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4712 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4713 | Bugs: ProtocolBugs{ |
| 4714 | SendV2ClientHello: true, |
| 4715 | }, |
| 4716 | }, |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 4717 | flags: []string{ |
| 4718 | "-expect-msg-callback", |
| 4719 | `read v2clienthello |
| 4720 | write hs 2 |
| 4721 | write hs 11 |
| 4722 | write hs 14 |
| 4723 | read hs 16 |
| 4724 | read ccs |
| 4725 | read hs 20 |
| 4726 | write ccs |
| 4727 | write hs 20 |
| 4728 | read alert 1 0 |
| 4729 | `, |
| 4730 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4731 | }) |
| 4732 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4733 | // Test Channel ID |
| 4734 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4735 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4736 | continue |
| 4737 | } |
| 4738 | // Client sends a Channel ID. |
| 4739 | tests = append(tests, testCase{ |
| 4740 | name: "ChannelID-Client-" + ver.name, |
| 4741 | config: Config{ |
| 4742 | MaxVersion: ver.version, |
| 4743 | RequestChannelID: true, |
| 4744 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4745 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4746 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4747 | resumeSession: true, |
| 4748 | expectChannelID: true, |
| 4749 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4750 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4751 | // Server accepts a Channel ID. |
| 4752 | tests = append(tests, testCase{ |
| 4753 | testType: serverTest, |
| 4754 | name: "ChannelID-Server-" + ver.name, |
| 4755 | config: Config{ |
| 4756 | MaxVersion: ver.version, |
| 4757 | ChannelID: channelIDKey, |
| 4758 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4759 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4760 | flags: []string{ |
| 4761 | "-expect-channel-id", |
| 4762 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4763 | }, |
| 4764 | resumeSession: true, |
| 4765 | expectChannelID: true, |
| 4766 | }) |
| 4767 | |
| 4768 | tests = append(tests, testCase{ |
| 4769 | testType: serverTest, |
| 4770 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4771 | config: Config{ |
| 4772 | MaxVersion: ver.version, |
| 4773 | ChannelID: channelIDKey, |
| 4774 | Bugs: ProtocolBugs{ |
| 4775 | InvalidChannelIDSignature: true, |
| 4776 | }, |
| 4777 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4778 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4779 | flags: []string{"-enable-channel-id"}, |
| 4780 | shouldFail: true, |
| 4781 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4782 | }) |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 4783 | |
| 4784 | if ver.version < VersionTLS13 { |
| 4785 | // Channel ID requires ECDHE ciphers. |
| 4786 | tests = append(tests, testCase{ |
| 4787 | testType: serverTest, |
| 4788 | name: "ChannelID-NoECDHE-" + ver.name, |
| 4789 | config: Config{ |
| 4790 | MaxVersion: ver.version, |
| 4791 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 4792 | ChannelID: channelIDKey, |
| 4793 | }, |
| 4794 | expectChannelID: false, |
| 4795 | flags: []string{"-enable-channel-id"}, |
| 4796 | }) |
| 4797 | |
| 4798 | // Sanity-check setting expectChannelID false works. |
| 4799 | tests = append(tests, testCase{ |
| 4800 | testType: serverTest, |
| 4801 | name: "ChannelID-ECDHE-" + ver.name, |
| 4802 | config: Config{ |
| 4803 | MaxVersion: ver.version, |
| 4804 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 4805 | ChannelID: channelIDKey, |
| 4806 | }, |
| 4807 | expectChannelID: false, |
| 4808 | flags: []string{"-enable-channel-id"}, |
| 4809 | shouldFail: true, |
| 4810 | expectedLocalError: "channel ID unexpectedly negotiated", |
| 4811 | }) |
| 4812 | } |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4813 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4814 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4815 | // Channel ID and NPN at the same time, to ensure their relative |
| 4816 | // ordering is correct. |
| 4817 | tests = append(tests, testCase{ |
| 4818 | name: "ChannelID-NPN-Client", |
| 4819 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4820 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4821 | RequestChannelID: true, |
| 4822 | NextProtos: []string{"foo"}, |
| 4823 | }, |
| 4824 | flags: []string{ |
| 4825 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4826 | "-select-next-proto", "foo", |
| 4827 | }, |
| 4828 | resumeSession: true, |
| 4829 | expectChannelID: true, |
| 4830 | expectedNextProto: "foo", |
| 4831 | expectedNextProtoType: npn, |
| 4832 | }) |
| 4833 | tests = append(tests, testCase{ |
| 4834 | testType: serverTest, |
| 4835 | name: "ChannelID-NPN-Server", |
| 4836 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4837 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4838 | ChannelID: channelIDKey, |
| 4839 | NextProtos: []string{"bar"}, |
| 4840 | }, |
| 4841 | flags: []string{ |
| 4842 | "-expect-channel-id", |
| 4843 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4844 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4845 | "-expect-next-proto", "bar", |
| 4846 | }, |
| 4847 | resumeSession: true, |
| 4848 | expectChannelID: true, |
| 4849 | expectedNextProto: "bar", |
| 4850 | expectedNextProtoType: npn, |
| 4851 | }) |
| 4852 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4853 | // Bidirectional shutdown with the runner initiating. |
| 4854 | tests = append(tests, testCase{ |
| 4855 | name: "Shutdown-Runner", |
| 4856 | config: Config{ |
| 4857 | Bugs: ProtocolBugs{ |
| 4858 | ExpectCloseNotify: true, |
| 4859 | }, |
| 4860 | }, |
| 4861 | flags: []string{"-check-close-notify"}, |
| 4862 | }) |
| 4863 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4864 | if !config.implicitHandshake { |
| 4865 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4866 | // in the meantime, sends garbage before the close_notify which |
| 4867 | // the shim must ignore. This test is disabled under implicit |
| 4868 | // handshake tests because the shim never reads or writes. |
| 4869 | tests = append(tests, testCase{ |
| 4870 | name: "Shutdown-Shim", |
| 4871 | config: Config{ |
| 4872 | MaxVersion: VersionTLS12, |
| 4873 | Bugs: ProtocolBugs{ |
| 4874 | ExpectCloseNotify: true, |
| 4875 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4876 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4877 | shimShutsDown: true, |
| 4878 | sendEmptyRecords: 1, |
| 4879 | sendWarningAlerts: 1, |
| 4880 | flags: []string{"-check-close-notify"}, |
| 4881 | }) |
| 4882 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4883 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4884 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4885 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4886 | tests = append(tests, testCase{ |
| 4887 | name: "SkipHelloVerifyRequest", |
| 4888 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4889 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4890 | Bugs: ProtocolBugs{ |
| 4891 | SkipHelloVerifyRequest: true, |
| 4892 | }, |
| 4893 | }, |
| 4894 | }) |
| 4895 | } |
| 4896 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4897 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4898 | test.protocol = config.protocol |
| 4899 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4900 | test.name += "-DTLS" |
| 4901 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4902 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4903 | test.name += "-Async" |
| 4904 | test.flags = append(test.flags, "-async") |
| 4905 | } else { |
| 4906 | test.name += "-Sync" |
| 4907 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4908 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4909 | test.name += "-SplitHandshakeRecords" |
| 4910 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4911 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4912 | test.config.Bugs.MaxPacketLength = 256 |
| 4913 | test.flags = append(test.flags, "-mtu", "256") |
| 4914 | } |
| 4915 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4916 | if config.packHandshakeFlight { |
| 4917 | test.name += "-PackHandshakeFlight" |
| 4918 | test.config.Bugs.PackHandshakeFlight = true |
| 4919 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4920 | if config.implicitHandshake { |
| 4921 | test.name += "-ImplicitHandshake" |
| 4922 | test.flags = append(test.flags, "-implicit-handshake") |
| 4923 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4924 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4925 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4926 | } |
| 4927 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4928 | func addDDoSCallbackTests() { |
| 4929 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4930 | for _, resume := range []bool{false, true} { |
| 4931 | suffix := "Resume" |
| 4932 | if resume { |
| 4933 | suffix = "No" + suffix |
| 4934 | } |
| 4935 | |
| 4936 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4937 | testType: serverTest, |
| 4938 | name: "Server-DDoS-OK-" + suffix, |
| 4939 | config: Config{ |
| 4940 | MaxVersion: VersionTLS12, |
| 4941 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4942 | flags: []string{"-install-ddos-callback"}, |
| 4943 | resumeSession: resume, |
| 4944 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4945 | testCases = append(testCases, testCase{ |
| 4946 | testType: serverTest, |
| 4947 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4948 | config: Config{ |
| 4949 | MaxVersion: VersionTLS13, |
| 4950 | }, |
| 4951 | flags: []string{"-install-ddos-callback"}, |
| 4952 | resumeSession: resume, |
| 4953 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4954 | |
| 4955 | failFlag := "-fail-ddos-callback" |
| 4956 | if resume { |
| 4957 | failFlag = "-fail-second-ddos-callback" |
| 4958 | } |
| 4959 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4960 | testType: serverTest, |
| 4961 | name: "Server-DDoS-Reject-" + suffix, |
| 4962 | config: Config{ |
| 4963 | MaxVersion: VersionTLS12, |
| 4964 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4965 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4966 | resumeSession: resume, |
| 4967 | shouldFail: true, |
| 4968 | expectedError: ":CONNECTION_REJECTED:", |
| 4969 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4970 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4971 | testCases = append(testCases, testCase{ |
| 4972 | testType: serverTest, |
| 4973 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4974 | config: Config{ |
| 4975 | MaxVersion: VersionTLS13, |
| 4976 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4977 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4978 | resumeSession: resume, |
| 4979 | shouldFail: true, |
| 4980 | expectedError: ":CONNECTION_REJECTED:", |
| 4981 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4982 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4983 | } |
| 4984 | } |
| 4985 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4986 | func addVersionNegotiationTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4987 | for _, protocol := range []protocol{tls, dtls} { |
| 4988 | for _, shimVers := range allVersions(protocol) { |
| 4989 | // Assemble flags to disable all newer versions on the shim. |
| 4990 | var flags []string |
| 4991 | for _, vers := range allVersions(protocol) { |
| 4992 | if vers.version > shimVers.version { |
| 4993 | flags = append(flags, vers.excludeFlag) |
| 4994 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4995 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4996 | |
| 4997 | flags2 := []string{"-max-version", shimVers.shimFlag(protocol)} |
| 4998 | |
| 4999 | if shimVers.tls13Variant != 0 { |
| 5000 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5001 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5002 | } |
| 5003 | |
| 5004 | // Test configuring the runner's maximum version. |
| 5005 | for _, runnerVers := range allVersions(protocol) { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5006 | expectedVersion := shimVers.version |
| 5007 | if runnerVers.version < shimVers.version { |
| 5008 | expectedVersion = runnerVers.version |
| 5009 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5010 | // When running and shim have different TLS 1.3 variants enabled, |
| 5011 | // shim clients are expected to fall back to TLS 1.2, while shim |
| 5012 | // servers support both variants when enabled when the experiment is |
| 5013 | // enabled. |
| 5014 | expectedServerVersion := expectedVersion |
| 5015 | expectedClientVersion := expectedVersion |
| 5016 | if expectedVersion == VersionTLS13 && runnerVers.tls13Variant != shimVers.tls13Variant { |
| 5017 | expectedClientVersion = VersionTLS12 |
| 5018 | expectedServerVersion = VersionTLS12 |
| 5019 | if shimVers.tls13Variant != TLS13Default { |
| 5020 | expectedServerVersion = VersionTLS13 |
| 5021 | } |
| 5022 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5023 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5024 | suffix := shimVers.name + "-" + runnerVers.name |
| 5025 | if protocol == dtls { |
| 5026 | suffix += "-DTLS" |
| 5027 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5028 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5029 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5030 | clientVers := shimVers.version |
| 5031 | if clientVers > VersionTLS10 { |
| 5032 | clientVers = VersionTLS10 |
| 5033 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5034 | clientVers = recordVersionToWire(clientVers, protocol) |
| 5035 | serverVers := expectedServerVersion |
| 5036 | if expectedServerVersion >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5037 | serverVers = VersionTLS10 |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 5038 | if runnerVers.tls13Variant == TLS13Experiment2 || runnerVers.tls13Variant == TLS13Experiment3 { |
Steven Valdez | 1682126 | 2017-09-08 17:03:42 -0400 | [diff] [blame] | 5039 | serverVers = VersionTLS12 |
| 5040 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5041 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5042 | serverVers = recordVersionToWire(serverVers, protocol) |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5043 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5044 | testCases = append(testCases, testCase{ |
| 5045 | protocol: protocol, |
| 5046 | testType: clientTest, |
| 5047 | name: "VersionNegotiation-Client-" + suffix, |
| 5048 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5049 | MaxVersion: runnerVers.version, |
| 5050 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5051 | Bugs: ProtocolBugs{ |
| 5052 | ExpectInitialRecordVersion: clientVers, |
| 5053 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5054 | }, |
| 5055 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5056 | expectedVersion: expectedClientVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5057 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5058 | testCases = append(testCases, testCase{ |
| 5059 | protocol: protocol, |
| 5060 | testType: clientTest, |
| 5061 | name: "VersionNegotiation-Client2-" + suffix, |
| 5062 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5063 | MaxVersion: runnerVers.version, |
| 5064 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5065 | Bugs: ProtocolBugs{ |
| 5066 | ExpectInitialRecordVersion: clientVers, |
| 5067 | }, |
| 5068 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5069 | flags: flags2, |
| 5070 | expectedVersion: expectedClientVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5071 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5072 | |
| 5073 | testCases = append(testCases, testCase{ |
| 5074 | protocol: protocol, |
| 5075 | testType: serverTest, |
| 5076 | name: "VersionNegotiation-Server-" + suffix, |
| 5077 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5078 | MaxVersion: runnerVers.version, |
| 5079 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5080 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5081 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5082 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5083 | }, |
| 5084 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5085 | expectedVersion: expectedServerVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5086 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5087 | testCases = append(testCases, testCase{ |
| 5088 | protocol: protocol, |
| 5089 | testType: serverTest, |
| 5090 | name: "VersionNegotiation-Server2-" + suffix, |
| 5091 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5092 | MaxVersion: runnerVers.version, |
| 5093 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5094 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5095 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5096 | }, |
| 5097 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5098 | flags: flags2, |
| 5099 | expectedVersion: expectedServerVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5100 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5101 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5102 | } |
| 5103 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5104 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5105 | // Test the version extension at all versions. |
| 5106 | for _, vers := range tlsVersions { |
| 5107 | protocols := []protocol{tls} |
| 5108 | if vers.hasDTLS { |
| 5109 | protocols = append(protocols, dtls) |
| 5110 | } |
| 5111 | for _, protocol := range protocols { |
| 5112 | suffix := vers.name |
| 5113 | if protocol == dtls { |
| 5114 | suffix += "-DTLS" |
| 5115 | } |
| 5116 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5117 | testCases = append(testCases, testCase{ |
| 5118 | protocol: protocol, |
| 5119 | testType: serverTest, |
| 5120 | name: "VersionNegotiationExtension-" + suffix, |
| 5121 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5122 | TLS13Variant: vers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5123 | Bugs: ProtocolBugs{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5124 | SendSupportedVersions: []uint16{0x1111, vers.wire(protocol), 0x2222}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5125 | }, |
| 5126 | }, |
| 5127 | expectedVersion: vers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5128 | flags: []string{"-tls13-variant", strconv.Itoa(vers.tls13Variant)}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5129 | }) |
| 5130 | } |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5131 | } |
| 5132 | |
| 5133 | // If all versions are unknown, negotiation fails. |
| 5134 | testCases = append(testCases, testCase{ |
| 5135 | testType: serverTest, |
| 5136 | name: "NoSupportedVersions", |
| 5137 | config: Config{ |
| 5138 | Bugs: ProtocolBugs{ |
| 5139 | SendSupportedVersions: []uint16{0x1111}, |
| 5140 | }, |
| 5141 | }, |
| 5142 | shouldFail: true, |
| 5143 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5144 | }) |
| 5145 | testCases = append(testCases, testCase{ |
| 5146 | protocol: dtls, |
| 5147 | testType: serverTest, |
| 5148 | name: "NoSupportedVersions-DTLS", |
| 5149 | config: Config{ |
| 5150 | Bugs: ProtocolBugs{ |
| 5151 | SendSupportedVersions: []uint16{0x1111}, |
| 5152 | }, |
| 5153 | }, |
| 5154 | shouldFail: true, |
| 5155 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5156 | }) |
| 5157 | |
| 5158 | testCases = append(testCases, testCase{ |
| 5159 | testType: serverTest, |
| 5160 | name: "ClientHelloVersionTooHigh", |
| 5161 | config: Config{ |
| 5162 | MaxVersion: VersionTLS13, |
| 5163 | Bugs: ProtocolBugs{ |
| 5164 | SendClientVersion: 0x0304, |
| 5165 | OmitSupportedVersions: true, |
| 5166 | }, |
| 5167 | }, |
| 5168 | expectedVersion: VersionTLS12, |
| 5169 | }) |
| 5170 | |
| 5171 | testCases = append(testCases, testCase{ |
| 5172 | testType: serverTest, |
| 5173 | name: "ConflictingVersionNegotiation", |
| 5174 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5175 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5176 | SendClientVersion: VersionTLS12, |
| 5177 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5178 | }, |
| 5179 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5180 | // The extension takes precedence over the ClientHello version. |
| 5181 | expectedVersion: VersionTLS11, |
| 5182 | }) |
| 5183 | |
| 5184 | testCases = append(testCases, testCase{ |
| 5185 | testType: serverTest, |
| 5186 | name: "ConflictingVersionNegotiation-2", |
| 5187 | config: Config{ |
| 5188 | Bugs: ProtocolBugs{ |
| 5189 | SendClientVersion: VersionTLS11, |
| 5190 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 5191 | }, |
| 5192 | }, |
| 5193 | // The extension takes precedence over the ClientHello version. |
| 5194 | expectedVersion: VersionTLS12, |
| 5195 | }) |
| 5196 | |
| 5197 | testCases = append(testCases, testCase{ |
| 5198 | testType: serverTest, |
| 5199 | name: "RejectFinalTLS13", |
| 5200 | config: Config{ |
| 5201 | Bugs: ProtocolBugs{ |
| 5202 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 5203 | }, |
| 5204 | }, |
| 5205 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 5206 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5207 | expectedVersion: VersionTLS12, |
| 5208 | }) |
| 5209 | |
Steven Valdez | 038da9b | 2017-07-10 12:57:25 -0400 | [diff] [blame] | 5210 | // Test that TLS 1.2 isn't negotiated by the supported_versions extension in |
| 5211 | // the ServerHello. |
| 5212 | testCases = append(testCases, testCase{ |
| 5213 | testType: clientTest, |
| 5214 | name: "SupportedVersionSelection-TLS12", |
| 5215 | config: Config{ |
| 5216 | MaxVersion: VersionTLS12, |
| 5217 | Bugs: ProtocolBugs{ |
| 5218 | SendServerSupportedExtensionVersion: VersionTLS12, |
| 5219 | }, |
| 5220 | }, |
| 5221 | shouldFail: true, |
| 5222 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5223 | }) |
| 5224 | |
| 5225 | // Test that the non-experimental TLS 1.3 isn't negotiated by the |
| 5226 | // supported_versions extension in the ServerHello. |
| 5227 | testCases = append(testCases, testCase{ |
| 5228 | testType: clientTest, |
| 5229 | name: "SupportedVersionSelection-TLS13", |
| 5230 | config: Config{ |
| 5231 | MaxVersion: VersionTLS13, |
| 5232 | Bugs: ProtocolBugs{ |
| 5233 | SendServerSupportedExtensionVersion: tls13DraftVersion, |
| 5234 | }, |
| 5235 | }, |
| 5236 | shouldFail: true, |
| 5237 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5238 | }) |
| 5239 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 5240 | // Test that the maximum version is selected regardless of the |
| 5241 | // client-sent order. |
| 5242 | testCases = append(testCases, testCase{ |
| 5243 | testType: serverTest, |
| 5244 | name: "IgnoreClientVersionOrder", |
| 5245 | config: Config{ |
| 5246 | Bugs: ProtocolBugs{ |
| 5247 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 5248 | }, |
| 5249 | }, |
| 5250 | expectedVersion: VersionTLS13, |
| 5251 | }) |
| 5252 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5253 | // Test for version tolerance. |
| 5254 | testCases = append(testCases, testCase{ |
| 5255 | testType: serverTest, |
| 5256 | name: "MinorVersionTolerance", |
| 5257 | config: Config{ |
| 5258 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5259 | SendClientVersion: 0x03ff, |
| 5260 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5261 | }, |
| 5262 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5263 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5264 | }) |
| 5265 | testCases = append(testCases, testCase{ |
| 5266 | testType: serverTest, |
| 5267 | name: "MajorVersionTolerance", |
| 5268 | config: Config{ |
| 5269 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5270 | SendClientVersion: 0x0400, |
| 5271 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5272 | }, |
| 5273 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5274 | // TLS 1.3 must be negotiated with the supported_versions |
| 5275 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5276 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5277 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5278 | testCases = append(testCases, testCase{ |
| 5279 | testType: serverTest, |
| 5280 | name: "VersionTolerance-TLS13", |
| 5281 | config: Config{ |
| 5282 | Bugs: ProtocolBugs{ |
| 5283 | // Although TLS 1.3 does not use |
| 5284 | // ClientHello.version, it still tolerates high |
| 5285 | // values there. |
| 5286 | SendClientVersion: 0x0400, |
| 5287 | }, |
| 5288 | }, |
| 5289 | expectedVersion: VersionTLS13, |
| 5290 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5291 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5292 | testCases = append(testCases, testCase{ |
| 5293 | protocol: dtls, |
| 5294 | testType: serverTest, |
| 5295 | name: "MinorVersionTolerance-DTLS", |
| 5296 | config: Config{ |
| 5297 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5298 | SendClientVersion: 0xfe00, |
| 5299 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5300 | }, |
| 5301 | }, |
| 5302 | expectedVersion: VersionTLS12, |
| 5303 | }) |
| 5304 | testCases = append(testCases, testCase{ |
| 5305 | protocol: dtls, |
| 5306 | testType: serverTest, |
| 5307 | name: "MajorVersionTolerance-DTLS", |
| 5308 | config: Config{ |
| 5309 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5310 | SendClientVersion: 0xfdff, |
| 5311 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5312 | }, |
| 5313 | }, |
| 5314 | expectedVersion: VersionTLS12, |
| 5315 | }) |
| 5316 | |
| 5317 | // Test that versions below 3.0 are rejected. |
| 5318 | testCases = append(testCases, testCase{ |
| 5319 | testType: serverTest, |
| 5320 | name: "VersionTooLow", |
| 5321 | config: Config{ |
| 5322 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5323 | SendClientVersion: 0x0200, |
| 5324 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5325 | }, |
| 5326 | }, |
| 5327 | shouldFail: true, |
| 5328 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5329 | }) |
| 5330 | testCases = append(testCases, testCase{ |
| 5331 | protocol: dtls, |
| 5332 | testType: serverTest, |
| 5333 | name: "VersionTooLow-DTLS", |
| 5334 | config: Config{ |
| 5335 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 5336 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5337 | }, |
| 5338 | }, |
| 5339 | shouldFail: true, |
| 5340 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5341 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5342 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 5343 | testCases = append(testCases, testCase{ |
| 5344 | name: "ServerBogusVersion", |
| 5345 | config: Config{ |
| 5346 | Bugs: ProtocolBugs{ |
| 5347 | SendServerHelloVersion: 0x1234, |
| 5348 | }, |
| 5349 | }, |
| 5350 | shouldFail: true, |
| 5351 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5352 | }) |
| 5353 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5354 | // Test TLS 1.3's downgrade signal. |
| 5355 | testCases = append(testCases, testCase{ |
| 5356 | name: "Downgrade-TLS12-Client", |
| 5357 | config: Config{ |
| 5358 | Bugs: ProtocolBugs{ |
| 5359 | NegotiateVersion: VersionTLS12, |
| 5360 | }, |
| 5361 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5362 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5363 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5364 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5365 | }) |
| 5366 | testCases = append(testCases, testCase{ |
| 5367 | testType: serverTest, |
| 5368 | name: "Downgrade-TLS12-Server", |
| 5369 | config: Config{ |
| 5370 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5371 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5372 | }, |
| 5373 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5374 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5375 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5376 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5377 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5378 | } |
| 5379 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5380 | func addMinimumVersionTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5381 | for _, protocol := range []protocol{tls, dtls} { |
| 5382 | for _, shimVers := range allVersions(protocol) { |
| 5383 | // Assemble flags to disable all older versions on the shim. |
| 5384 | var flags []string |
| 5385 | for _, vers := range allVersions(protocol) { |
| 5386 | if vers.version < shimVers.version { |
| 5387 | flags = append(flags, vers.excludeFlag) |
| 5388 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5389 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5390 | |
| 5391 | flags2 := []string{"-min-version", shimVers.shimFlag(protocol)} |
| 5392 | |
| 5393 | if shimVers.tls13Variant != 0 { |
| 5394 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5395 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5396 | } |
| 5397 | |
| 5398 | for _, runnerVers := range allVersions(protocol) { |
| 5399 | // Different TLS 1.3 variants are incompatible with each other and don't |
| 5400 | // produce consistent minimum versions. |
| 5401 | // |
| 5402 | // TODO(davidben): Fold these tests (the main value is in the |
| 5403 | // NegotiateVersion bug) into addVersionNegotiationTests and test based |
| 5404 | // on intended shim behavior, not the shim + runner combination. |
| 5405 | if shimVers.tls13Variant != runnerVers.tls13Variant { |
| 5406 | continue |
| 5407 | } |
| 5408 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5409 | suffix := shimVers.name + "-" + runnerVers.name |
| 5410 | if protocol == dtls { |
| 5411 | suffix += "-DTLS" |
| 5412 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5413 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5414 | var expectedVersion uint16 |
| 5415 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5416 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5417 | if runnerVers.version >= shimVers.version { |
| 5418 | expectedVersion = runnerVers.version |
| 5419 | } else { |
| 5420 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5421 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 5422 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5423 | } |
| 5424 | |
| 5425 | testCases = append(testCases, testCase{ |
| 5426 | protocol: protocol, |
| 5427 | testType: clientTest, |
| 5428 | name: "MinimumVersion-Client-" + suffix, |
| 5429 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5430 | MaxVersion: runnerVers.version, |
| 5431 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5432 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5433 | // Ensure the server does not decline to |
| 5434 | // select a version (versions extension) or |
| 5435 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5436 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5437 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5438 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5439 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5440 | flags: flags, |
| 5441 | expectedVersion: expectedVersion, |
| 5442 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5443 | expectedError: expectedError, |
| 5444 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5445 | }) |
| 5446 | testCases = append(testCases, testCase{ |
| 5447 | protocol: protocol, |
| 5448 | testType: clientTest, |
| 5449 | name: "MinimumVersion-Client2-" + suffix, |
| 5450 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5451 | MaxVersion: runnerVers.version, |
| 5452 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5453 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5454 | // Ensure the server does not decline to |
| 5455 | // select a version (versions extension) or |
| 5456 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5457 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5458 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5459 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5460 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5461 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5462 | expectedVersion: expectedVersion, |
| 5463 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5464 | expectedError: expectedError, |
| 5465 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5466 | }) |
| 5467 | |
| 5468 | testCases = append(testCases, testCase{ |
| 5469 | protocol: protocol, |
| 5470 | testType: serverTest, |
| 5471 | name: "MinimumVersion-Server-" + suffix, |
| 5472 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5473 | MaxVersion: runnerVers.version, |
| 5474 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5475 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5476 | flags: flags, |
| 5477 | expectedVersion: expectedVersion, |
| 5478 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5479 | expectedError: expectedError, |
| 5480 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5481 | }) |
| 5482 | testCases = append(testCases, testCase{ |
| 5483 | protocol: protocol, |
| 5484 | testType: serverTest, |
| 5485 | name: "MinimumVersion-Server2-" + suffix, |
| 5486 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5487 | MaxVersion: runnerVers.version, |
| 5488 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5489 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5490 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5491 | expectedVersion: expectedVersion, |
| 5492 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5493 | expectedError: expectedError, |
| 5494 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5495 | }) |
| 5496 | } |
| 5497 | } |
| 5498 | } |
| 5499 | } |
| 5500 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5501 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5502 | // TODO(davidben): Extensions, where applicable, all move their server |
| 5503 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 5504 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 5505 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5506 | // Repeat extensions tests all versions except SSL 3.0. |
| 5507 | for _, ver := range tlsVersions { |
| 5508 | if ver.version == VersionSSL30 { |
| 5509 | continue |
| 5510 | } |
| 5511 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5512 | // Test that duplicate extensions are rejected. |
| 5513 | testCases = append(testCases, testCase{ |
| 5514 | testType: clientTest, |
| 5515 | name: "DuplicateExtensionClient-" + ver.name, |
| 5516 | config: Config{ |
| 5517 | MaxVersion: ver.version, |
| 5518 | Bugs: ProtocolBugs{ |
| 5519 | DuplicateExtension: true, |
| 5520 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5521 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5522 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5523 | shouldFail: true, |
| 5524 | expectedLocalError: "remote error: error decoding message", |
| 5525 | }) |
| 5526 | testCases = append(testCases, testCase{ |
| 5527 | testType: serverTest, |
| 5528 | name: "DuplicateExtensionServer-" + ver.name, |
| 5529 | config: Config{ |
| 5530 | MaxVersion: ver.version, |
| 5531 | Bugs: ProtocolBugs{ |
| 5532 | DuplicateExtension: true, |
| 5533 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5534 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5535 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5536 | shouldFail: true, |
| 5537 | expectedLocalError: "remote error: error decoding message", |
| 5538 | }) |
| 5539 | |
| 5540 | // Test SNI. |
| 5541 | testCases = append(testCases, testCase{ |
| 5542 | testType: clientTest, |
| 5543 | name: "ServerNameExtensionClient-" + ver.name, |
| 5544 | config: Config{ |
| 5545 | MaxVersion: ver.version, |
| 5546 | Bugs: ProtocolBugs{ |
| 5547 | ExpectServerName: "example.com", |
| 5548 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5549 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5550 | tls13Variant: ver.tls13Variant, |
| 5551 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5552 | }) |
| 5553 | testCases = append(testCases, testCase{ |
| 5554 | testType: clientTest, |
| 5555 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5556 | config: Config{ |
| 5557 | MaxVersion: ver.version, |
| 5558 | Bugs: ProtocolBugs{ |
| 5559 | ExpectServerName: "mismatch.com", |
| 5560 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5561 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5562 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5563 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5564 | shouldFail: true, |
| 5565 | expectedLocalError: "tls: unexpected server name", |
| 5566 | }) |
| 5567 | testCases = append(testCases, testCase{ |
| 5568 | testType: clientTest, |
| 5569 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5570 | config: Config{ |
| 5571 | MaxVersion: ver.version, |
| 5572 | Bugs: ProtocolBugs{ |
| 5573 | ExpectServerName: "missing.com", |
| 5574 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5575 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5576 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5577 | shouldFail: true, |
| 5578 | expectedLocalError: "tls: unexpected server name", |
| 5579 | }) |
| 5580 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5581 | testType: clientTest, |
| 5582 | name: "TolerateServerNameAck-" + ver.name, |
| 5583 | config: Config{ |
| 5584 | MaxVersion: ver.version, |
| 5585 | Bugs: ProtocolBugs{ |
| 5586 | SendServerNameAck: true, |
| 5587 | }, |
| 5588 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5589 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5590 | flags: []string{"-host-name", "example.com"}, |
| 5591 | resumeSession: true, |
| 5592 | }) |
| 5593 | testCases = append(testCases, testCase{ |
| 5594 | testType: clientTest, |
| 5595 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5596 | config: Config{ |
| 5597 | MaxVersion: ver.version, |
| 5598 | Bugs: ProtocolBugs{ |
| 5599 | SendServerNameAck: true, |
| 5600 | }, |
| 5601 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5602 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5603 | shouldFail: true, |
| 5604 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5605 | expectedLocalError: "remote error: unsupported extension", |
| 5606 | }) |
| 5607 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5608 | testType: serverTest, |
| 5609 | name: "ServerNameExtensionServer-" + ver.name, |
| 5610 | config: Config{ |
| 5611 | MaxVersion: ver.version, |
| 5612 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 5613 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5614 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5615 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5616 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5617 | }) |
| 5618 | |
| 5619 | // Test ALPN. |
| 5620 | testCases = append(testCases, testCase{ |
| 5621 | testType: clientTest, |
| 5622 | name: "ALPNClient-" + ver.name, |
| 5623 | config: Config{ |
| 5624 | MaxVersion: ver.version, |
| 5625 | NextProtos: []string{"foo"}, |
| 5626 | }, |
| 5627 | flags: []string{ |
| 5628 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5629 | "-expect-alpn", "foo", |
| 5630 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5631 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5632 | expectedNextProto: "foo", |
| 5633 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5634 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5635 | }) |
| 5636 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5637 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5638 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5639 | config: Config{ |
| 5640 | MaxVersion: ver.version, |
| 5641 | Bugs: ProtocolBugs{ |
| 5642 | SendALPN: "baz", |
| 5643 | }, |
| 5644 | }, |
| 5645 | flags: []string{ |
| 5646 | "-advertise-alpn", "\x03foo\x03bar", |
| 5647 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5648 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5649 | shouldFail: true, |
| 5650 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5651 | expectedLocalError: "remote error: illegal parameter", |
| 5652 | }) |
| 5653 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5654 | testType: clientTest, |
| 5655 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5656 | config: Config{ |
| 5657 | MaxVersion: ver.version, |
| 5658 | Bugs: ProtocolBugs{ |
| 5659 | SendALPN: "baz", |
| 5660 | }, |
| 5661 | }, |
| 5662 | flags: []string{ |
| 5663 | "-advertise-alpn", "\x03foo\x03bar", |
| 5664 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5665 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5666 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5667 | tls13Variant: ver.tls13Variant, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5668 | }) |
| 5669 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5670 | testType: serverTest, |
| 5671 | name: "ALPNServer-" + ver.name, |
| 5672 | config: Config{ |
| 5673 | MaxVersion: ver.version, |
| 5674 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5675 | }, |
| 5676 | flags: []string{ |
| 5677 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5678 | "-select-alpn", "foo", |
| 5679 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5680 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5681 | expectedNextProto: "foo", |
| 5682 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5683 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5684 | }) |
| 5685 | testCases = append(testCases, testCase{ |
| 5686 | testType: serverTest, |
| 5687 | name: "ALPNServer-Decline-" + ver.name, |
| 5688 | config: Config{ |
| 5689 | MaxVersion: ver.version, |
| 5690 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5691 | }, |
| 5692 | flags: []string{"-decline-alpn"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5693 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5694 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5695 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5696 | }) |
| 5697 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5698 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5699 | // called once. |
| 5700 | testCases = append(testCases, testCase{ |
| 5701 | testType: serverTest, |
| 5702 | name: "ALPNServer-Async-" + ver.name, |
| 5703 | config: Config{ |
| 5704 | MaxVersion: ver.version, |
| 5705 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5706 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5707 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5708 | }, |
| 5709 | flags: []string{ |
| 5710 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5711 | "-select-alpn", "foo", |
| 5712 | "-async", |
| 5713 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5714 | tls13Variant: ver.tls13Variant, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5715 | expectedNextProto: "foo", |
| 5716 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5717 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5718 | }) |
| 5719 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5720 | var emptyString string |
| 5721 | testCases = append(testCases, testCase{ |
| 5722 | testType: clientTest, |
| 5723 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5724 | config: Config{ |
| 5725 | MaxVersion: ver.version, |
| 5726 | NextProtos: []string{""}, |
| 5727 | Bugs: ProtocolBugs{ |
| 5728 | // A server returning an empty ALPN protocol |
| 5729 | // should be rejected. |
| 5730 | ALPNProtocol: &emptyString, |
| 5731 | }, |
| 5732 | }, |
| 5733 | flags: []string{ |
| 5734 | "-advertise-alpn", "\x03foo", |
| 5735 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5736 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5737 | shouldFail: true, |
| 5738 | expectedError: ":PARSE_TLSEXT:", |
| 5739 | }) |
| 5740 | testCases = append(testCases, testCase{ |
| 5741 | testType: serverTest, |
| 5742 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5743 | config: Config{ |
| 5744 | MaxVersion: ver.version, |
| 5745 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5746 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5747 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5748 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5749 | flags: []string{ |
| 5750 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5751 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5752 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5753 | shouldFail: true, |
| 5754 | expectedError: ":PARSE_TLSEXT:", |
| 5755 | }) |
| 5756 | |
| 5757 | // Test NPN and the interaction with ALPN. |
| 5758 | if ver.version < VersionTLS13 { |
| 5759 | // Test that the server prefers ALPN over NPN. |
| 5760 | testCases = append(testCases, testCase{ |
| 5761 | testType: serverTest, |
| 5762 | name: "ALPNServer-Preferred-" + ver.name, |
| 5763 | config: Config{ |
| 5764 | MaxVersion: ver.version, |
| 5765 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5766 | }, |
| 5767 | flags: []string{ |
| 5768 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5769 | "-select-alpn", "foo", |
| 5770 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5771 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5772 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5773 | expectedNextProto: "foo", |
| 5774 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5775 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5776 | }) |
| 5777 | testCases = append(testCases, testCase{ |
| 5778 | testType: serverTest, |
| 5779 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5780 | config: Config{ |
| 5781 | MaxVersion: ver.version, |
| 5782 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5783 | Bugs: ProtocolBugs{ |
| 5784 | SwapNPNAndALPN: true, |
| 5785 | }, |
| 5786 | }, |
| 5787 | flags: []string{ |
| 5788 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5789 | "-select-alpn", "foo", |
| 5790 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5791 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5792 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5793 | expectedNextProto: "foo", |
| 5794 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5795 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5796 | }) |
| 5797 | |
| 5798 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5799 | testCases = append(testCases, testCase{ |
| 5800 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5801 | config: Config{ |
| 5802 | MaxVersion: ver.version, |
| 5803 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5804 | Bugs: ProtocolBugs{ |
| 5805 | NegotiateALPNAndNPN: true, |
| 5806 | }, |
| 5807 | }, |
| 5808 | flags: []string{ |
| 5809 | "-advertise-alpn", "\x03foo", |
| 5810 | "-select-next-proto", "foo", |
| 5811 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5812 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5813 | shouldFail: true, |
| 5814 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5815 | }) |
| 5816 | testCases = append(testCases, testCase{ |
| 5817 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5818 | config: Config{ |
| 5819 | MaxVersion: ver.version, |
| 5820 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5821 | Bugs: ProtocolBugs{ |
| 5822 | NegotiateALPNAndNPN: true, |
| 5823 | SwapNPNAndALPN: true, |
| 5824 | }, |
| 5825 | }, |
| 5826 | flags: []string{ |
| 5827 | "-advertise-alpn", "\x03foo", |
| 5828 | "-select-next-proto", "foo", |
| 5829 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5830 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5831 | shouldFail: true, |
| 5832 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5833 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5834 | } |
| 5835 | |
| 5836 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5837 | |
| 5838 | // Resume with a corrupt ticket. |
| 5839 | testCases = append(testCases, testCase{ |
| 5840 | testType: serverTest, |
| 5841 | name: "CorruptTicket-" + ver.name, |
| 5842 | config: Config{ |
| 5843 | MaxVersion: ver.version, |
| 5844 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5845 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5846 | in[len(in)-1] ^= 1 |
| 5847 | return in, nil |
| 5848 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5849 | }, |
| 5850 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5851 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5852 | resumeSession: true, |
| 5853 | expectResumeRejected: true, |
| 5854 | }) |
| 5855 | // Test the ticket callback, with and without renewal. |
| 5856 | testCases = append(testCases, testCase{ |
| 5857 | testType: serverTest, |
| 5858 | name: "TicketCallback-" + ver.name, |
| 5859 | config: Config{ |
| 5860 | MaxVersion: ver.version, |
| 5861 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5862 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5863 | resumeSession: true, |
| 5864 | flags: []string{"-use-ticket-callback"}, |
| 5865 | }) |
| 5866 | testCases = append(testCases, testCase{ |
| 5867 | testType: serverTest, |
| 5868 | name: "TicketCallback-Renew-" + ver.name, |
| 5869 | config: Config{ |
| 5870 | MaxVersion: ver.version, |
| 5871 | Bugs: ProtocolBugs{ |
| 5872 | ExpectNewTicket: true, |
| 5873 | }, |
| 5874 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5875 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5876 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5877 | resumeSession: true, |
| 5878 | }) |
| 5879 | |
| 5880 | // Test that the ticket callback is only called once when everything before |
| 5881 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5882 | // certificate selection callbacks run. |
| 5883 | testCases = append(testCases, testCase{ |
| 5884 | testType: serverTest, |
| 5885 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5886 | config: Config{ |
| 5887 | MaxVersion: ver.version, |
| 5888 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5889 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5890 | in[len(in)-1] ^= 1 |
| 5891 | return in, nil |
| 5892 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5893 | }, |
| 5894 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5895 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5896 | resumeSession: true, |
| 5897 | expectResumeRejected: true, |
| 5898 | flags: []string{ |
| 5899 | "-use-ticket-callback", |
| 5900 | "-async", |
| 5901 | }, |
| 5902 | }) |
| 5903 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5904 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5905 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5906 | testCases = append(testCases, testCase{ |
| 5907 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5908 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5909 | config: Config{ |
| 5910 | MaxVersion: ver.version, |
| 5911 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5912 | EmptyTicketSessionID: true, |
| 5913 | }, |
| 5914 | }, |
| 5915 | resumeSession: true, |
| 5916 | }) |
| 5917 | testCases = append(testCases, testCase{ |
| 5918 | testType: serverTest, |
| 5919 | name: "TicketSessionIDLength-16-" + ver.name, |
| 5920 | config: Config{ |
| 5921 | MaxVersion: ver.version, |
| 5922 | Bugs: ProtocolBugs{ |
| 5923 | TicketSessionIDLength: 16, |
| 5924 | }, |
| 5925 | }, |
| 5926 | resumeSession: true, |
| 5927 | }) |
| 5928 | testCases = append(testCases, testCase{ |
| 5929 | testType: serverTest, |
| 5930 | name: "TicketSessionIDLength-32-" + ver.name, |
| 5931 | config: Config{ |
| 5932 | MaxVersion: ver.version, |
| 5933 | Bugs: ProtocolBugs{ |
| 5934 | TicketSessionIDLength: 32, |
| 5935 | }, |
| 5936 | }, |
| 5937 | resumeSession: true, |
| 5938 | }) |
| 5939 | testCases = append(testCases, testCase{ |
| 5940 | testType: serverTest, |
| 5941 | name: "TicketSessionIDLength-33-" + ver.name, |
| 5942 | config: Config{ |
| 5943 | MaxVersion: ver.version, |
| 5944 | Bugs: ProtocolBugs{ |
| 5945 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5946 | }, |
| 5947 | }, |
| 5948 | resumeSession: true, |
| 5949 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5950 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5951 | expectedError: ":DECODE_ERROR:", |
| 5952 | }) |
| 5953 | } |
| 5954 | |
| 5955 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5956 | // are ignored. |
| 5957 | if ver.hasDTLS { |
| 5958 | testCases = append(testCases, testCase{ |
| 5959 | protocol: dtls, |
| 5960 | name: "SRTP-Client-" + ver.name, |
| 5961 | config: Config{ |
| 5962 | MaxVersion: ver.version, |
| 5963 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5964 | }, |
| 5965 | flags: []string{ |
| 5966 | "-srtp-profiles", |
| 5967 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5968 | }, |
| 5969 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5970 | }) |
| 5971 | testCases = append(testCases, testCase{ |
| 5972 | protocol: dtls, |
| 5973 | testType: serverTest, |
| 5974 | name: "SRTP-Server-" + ver.name, |
| 5975 | config: Config{ |
| 5976 | MaxVersion: ver.version, |
| 5977 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5978 | }, |
| 5979 | flags: []string{ |
| 5980 | "-srtp-profiles", |
| 5981 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5982 | }, |
| 5983 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5984 | }) |
| 5985 | // Test that the MKI is ignored. |
| 5986 | testCases = append(testCases, testCase{ |
| 5987 | protocol: dtls, |
| 5988 | testType: serverTest, |
| 5989 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5990 | config: Config{ |
| 5991 | MaxVersion: ver.version, |
| 5992 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5993 | Bugs: ProtocolBugs{ |
| 5994 | SRTPMasterKeyIdentifer: "bogus", |
| 5995 | }, |
| 5996 | }, |
| 5997 | flags: []string{ |
| 5998 | "-srtp-profiles", |
| 5999 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6000 | }, |
| 6001 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6002 | }) |
| 6003 | // Test that SRTP isn't negotiated on the server if there were |
| 6004 | // no matching profiles. |
| 6005 | testCases = append(testCases, testCase{ |
| 6006 | protocol: dtls, |
| 6007 | testType: serverTest, |
| 6008 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 6009 | config: Config{ |
| 6010 | MaxVersion: ver.version, |
| 6011 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 6012 | }, |
| 6013 | flags: []string{ |
| 6014 | "-srtp-profiles", |
| 6015 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6016 | }, |
| 6017 | expectedSRTPProtectionProfile: 0, |
| 6018 | }) |
| 6019 | // Test that the server returning an invalid SRTP profile is |
| 6020 | // flagged as an error by the client. |
| 6021 | testCases = append(testCases, testCase{ |
| 6022 | protocol: dtls, |
| 6023 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 6024 | config: Config{ |
| 6025 | MaxVersion: ver.version, |
| 6026 | Bugs: ProtocolBugs{ |
| 6027 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 6028 | }, |
| 6029 | }, |
| 6030 | flags: []string{ |
| 6031 | "-srtp-profiles", |
| 6032 | "SRTP_AES128_CM_SHA1_80", |
| 6033 | }, |
| 6034 | shouldFail: true, |
| 6035 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 6036 | }) |
| 6037 | } |
| 6038 | |
| 6039 | // Test SCT list. |
| 6040 | testCases = append(testCases, testCase{ |
| 6041 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 6042 | testType: clientTest, |
| 6043 | config: Config{ |
| 6044 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 6045 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6046 | flags: []string{ |
| 6047 | "-enable-signed-cert-timestamps", |
| 6048 | "-expect-signed-cert-timestamps", |
| 6049 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6050 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6051 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6052 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6053 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6054 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6055 | var differentSCTList []byte |
| 6056 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6057 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6058 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6059 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 6060 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6061 | testCases = append(testCases, testCase{ |
| 6062 | name: "SendSCTListOnResume-" + ver.name, |
| 6063 | config: Config{ |
| 6064 | MaxVersion: ver.version, |
| 6065 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6066 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6067 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 6068 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6069 | flags: []string{ |
| 6070 | "-enable-signed-cert-timestamps", |
| 6071 | "-expect-signed-cert-timestamps", |
| 6072 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6073 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6074 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6075 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6076 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6077 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6078 | testCases = append(testCases, testCase{ |
| 6079 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 6080 | testType: serverTest, |
| 6081 | config: Config{ |
| 6082 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6083 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6084 | flags: []string{ |
| 6085 | "-signed-cert-timestamps", |
| 6086 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6087 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6088 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6089 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6090 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6091 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6092 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6093 | emptySCTListCert := *testCerts[0].cert |
| 6094 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 6095 | |
| 6096 | // Test empty SCT list. |
| 6097 | testCases = append(testCases, testCase{ |
| 6098 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 6099 | testType: clientTest, |
| 6100 | config: Config{ |
| 6101 | MaxVersion: ver.version, |
| 6102 | Certificates: []Certificate{emptySCTListCert}, |
| 6103 | }, |
| 6104 | flags: []string{ |
| 6105 | "-enable-signed-cert-timestamps", |
| 6106 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6107 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6108 | shouldFail: true, |
| 6109 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6110 | }) |
| 6111 | |
| 6112 | emptySCTCert := *testCerts[0].cert |
| 6113 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 6114 | |
| 6115 | // Test empty SCT in non-empty list. |
| 6116 | testCases = append(testCases, testCase{ |
| 6117 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 6118 | testType: clientTest, |
| 6119 | config: Config{ |
| 6120 | MaxVersion: ver.version, |
| 6121 | Certificates: []Certificate{emptySCTCert}, |
| 6122 | }, |
| 6123 | flags: []string{ |
| 6124 | "-enable-signed-cert-timestamps", |
| 6125 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6126 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6127 | shouldFail: true, |
| 6128 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6129 | }) |
| 6130 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6131 | // Test that certificate-related extensions are not sent unsolicited. |
| 6132 | testCases = append(testCases, testCase{ |
| 6133 | testType: serverTest, |
| 6134 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 6135 | config: Config{ |
| 6136 | MaxVersion: ver.version, |
| 6137 | Bugs: ProtocolBugs{ |
| 6138 | NoOCSPStapling: true, |
| 6139 | NoSignedCertificateTimestamps: true, |
| 6140 | }, |
| 6141 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6142 | tls13Variant: ver.tls13Variant, |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6143 | flags: []string{ |
| 6144 | "-ocsp-response", |
| 6145 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6146 | "-signed-cert-timestamps", |
| 6147 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6148 | }, |
| 6149 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6150 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6151 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 6152 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 6153 | testType: clientTest, |
| 6154 | name: "ClientHelloPadding", |
| 6155 | config: Config{ |
| 6156 | Bugs: ProtocolBugs{ |
| 6157 | RequireClientHelloSize: 512, |
| 6158 | }, |
| 6159 | }, |
| 6160 | // This hostname just needs to be long enough to push the |
| 6161 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 6162 | // long. |
| 6163 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 6164 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6165 | |
| 6166 | // Extensions should not function in SSL 3.0. |
| 6167 | testCases = append(testCases, testCase{ |
| 6168 | testType: serverTest, |
| 6169 | name: "SSLv3Extensions-NoALPN", |
| 6170 | config: Config{ |
| 6171 | MaxVersion: VersionSSL30, |
| 6172 | NextProtos: []string{"foo", "bar", "baz"}, |
| 6173 | }, |
| 6174 | flags: []string{ |
| 6175 | "-select-alpn", "foo", |
| 6176 | }, |
| 6177 | expectNoNextProto: true, |
| 6178 | }) |
| 6179 | |
| 6180 | // Test session tickets separately as they follow a different codepath. |
| 6181 | testCases = append(testCases, testCase{ |
| 6182 | testType: serverTest, |
| 6183 | name: "SSLv3Extensions-NoTickets", |
| 6184 | config: Config{ |
| 6185 | MaxVersion: VersionSSL30, |
| 6186 | Bugs: ProtocolBugs{ |
| 6187 | // Historically, session tickets in SSL 3.0 |
| 6188 | // failed in different ways depending on whether |
| 6189 | // the client supported renegotiation_info. |
| 6190 | NoRenegotiationInfo: true, |
| 6191 | }, |
| 6192 | }, |
| 6193 | resumeSession: true, |
| 6194 | }) |
| 6195 | testCases = append(testCases, testCase{ |
| 6196 | testType: serverTest, |
| 6197 | name: "SSLv3Extensions-NoTickets2", |
| 6198 | config: Config{ |
| 6199 | MaxVersion: VersionSSL30, |
| 6200 | }, |
| 6201 | resumeSession: true, |
| 6202 | }) |
| 6203 | |
| 6204 | // But SSL 3.0 does send and process renegotiation_info. |
| 6205 | testCases = append(testCases, testCase{ |
| 6206 | testType: serverTest, |
| 6207 | name: "SSLv3Extensions-RenegotiationInfo", |
| 6208 | config: Config{ |
| 6209 | MaxVersion: VersionSSL30, |
| 6210 | Bugs: ProtocolBugs{ |
| 6211 | RequireRenegotiationInfo: true, |
| 6212 | }, |
| 6213 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6214 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6215 | }) |
| 6216 | testCases = append(testCases, testCase{ |
| 6217 | testType: serverTest, |
| 6218 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 6219 | config: Config{ |
| 6220 | MaxVersion: VersionSSL30, |
| 6221 | Bugs: ProtocolBugs{ |
| 6222 | NoRenegotiationInfo: true, |
| 6223 | SendRenegotiationSCSV: true, |
| 6224 | RequireRenegotiationInfo: true, |
| 6225 | }, |
| 6226 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6227 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6228 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6229 | |
| 6230 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 6231 | // in ServerHello. |
| 6232 | testCases = append(testCases, testCase{ |
| 6233 | name: "NPN-Forbidden-TLS13", |
| 6234 | config: Config{ |
| 6235 | MaxVersion: VersionTLS13, |
| 6236 | NextProtos: []string{"foo"}, |
| 6237 | Bugs: ProtocolBugs{ |
| 6238 | NegotiateNPNAtAllVersions: true, |
| 6239 | }, |
| 6240 | }, |
| 6241 | flags: []string{"-select-next-proto", "foo"}, |
| 6242 | shouldFail: true, |
| 6243 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6244 | }) |
| 6245 | testCases = append(testCases, testCase{ |
| 6246 | name: "EMS-Forbidden-TLS13", |
| 6247 | config: Config{ |
| 6248 | MaxVersion: VersionTLS13, |
| 6249 | Bugs: ProtocolBugs{ |
| 6250 | NegotiateEMSAtAllVersions: true, |
| 6251 | }, |
| 6252 | }, |
| 6253 | shouldFail: true, |
| 6254 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6255 | }) |
| 6256 | testCases = append(testCases, testCase{ |
| 6257 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 6258 | config: Config{ |
| 6259 | MaxVersion: VersionTLS13, |
| 6260 | Bugs: ProtocolBugs{ |
| 6261 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 6262 | }, |
| 6263 | }, |
| 6264 | shouldFail: true, |
| 6265 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6266 | }) |
| 6267 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6268 | name: "Ticket-Forbidden-TLS13", |
| 6269 | config: Config{ |
| 6270 | MaxVersion: VersionTLS12, |
| 6271 | }, |
| 6272 | resumeConfig: &Config{ |
| 6273 | MaxVersion: VersionTLS13, |
| 6274 | Bugs: ProtocolBugs{ |
| 6275 | AdvertiseTicketExtension: true, |
| 6276 | }, |
| 6277 | }, |
| 6278 | resumeSession: true, |
| 6279 | shouldFail: true, |
| 6280 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6281 | }) |
| 6282 | |
| 6283 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 6284 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 6285 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 6286 | // implicit in every test.) |
| 6287 | testCases = append(testCases, testCase{ |
| 6288 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 6289 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6290 | config: Config{ |
| 6291 | MaxVersion: VersionTLS13, |
| 6292 | NextProtos: []string{"bar"}, |
| 6293 | }, |
| 6294 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 6295 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 6296 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6297 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 6298 | // tolerated. |
| 6299 | testCases = append(testCases, testCase{ |
| 6300 | name: "SendOCSPResponseOnResume-TLS12", |
| 6301 | config: Config{ |
| 6302 | MaxVersion: VersionTLS12, |
| 6303 | Bugs: ProtocolBugs{ |
| 6304 | SendOCSPResponseOnResume: []byte("bogus"), |
| 6305 | }, |
| 6306 | }, |
| 6307 | flags: []string{ |
| 6308 | "-enable-ocsp-stapling", |
| 6309 | "-expect-ocsp-response", |
| 6310 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6311 | }, |
| 6312 | resumeSession: true, |
| 6313 | }) |
| 6314 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6315 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6316 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6317 | config: Config{ |
| 6318 | MaxVersion: VersionTLS13, |
| 6319 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6320 | SendExtensionOnCertificate: testOCSPExtension, |
| 6321 | }, |
| 6322 | }, |
| 6323 | shouldFail: true, |
| 6324 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6325 | }) |
| 6326 | |
| 6327 | testCases = append(testCases, testCase{ |
| 6328 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 6329 | config: Config{ |
| 6330 | MaxVersion: VersionTLS13, |
| 6331 | Bugs: ProtocolBugs{ |
| 6332 | SendExtensionOnCertificate: testSCTExtension, |
| 6333 | }, |
| 6334 | }, |
| 6335 | shouldFail: true, |
| 6336 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6337 | }) |
| 6338 | |
| 6339 | // Test that extensions on client certificates are never accepted. |
| 6340 | testCases = append(testCases, testCase{ |
| 6341 | name: "SendExtensionOnClientCertificate-TLS13", |
| 6342 | testType: serverTest, |
| 6343 | config: Config{ |
| 6344 | MaxVersion: VersionTLS13, |
| 6345 | Certificates: []Certificate{rsaCertificate}, |
| 6346 | Bugs: ProtocolBugs{ |
| 6347 | SendExtensionOnCertificate: testOCSPExtension, |
| 6348 | }, |
| 6349 | }, |
| 6350 | flags: []string{ |
| 6351 | "-enable-ocsp-stapling", |
| 6352 | "-require-any-client-certificate", |
| 6353 | }, |
| 6354 | shouldFail: true, |
| 6355 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6356 | }) |
| 6357 | |
| 6358 | testCases = append(testCases, testCase{ |
| 6359 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 6360 | config: Config{ |
| 6361 | MaxVersion: VersionTLS13, |
| 6362 | Bugs: ProtocolBugs{ |
| 6363 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 6364 | }, |
| 6365 | }, |
| 6366 | shouldFail: true, |
| 6367 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6368 | }) |
| 6369 | |
| 6370 | // Test that extensions on intermediates are allowed but ignored. |
| 6371 | testCases = append(testCases, testCase{ |
| 6372 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 6373 | config: Config{ |
| 6374 | MaxVersion: VersionTLS13, |
| 6375 | Certificates: []Certificate{rsaChainCertificate}, |
| 6376 | Bugs: ProtocolBugs{ |
| 6377 | // Send different values on the intermediate. This tests |
| 6378 | // the intermediate's extensions do not override the |
| 6379 | // leaf's. |
David Benjamin | 5c4271f | 2017-08-23 22:09:41 -0700 | [diff] [blame] | 6380 | SendOCSPOnIntermediates: testOCSPResponse2, |
| 6381 | SendSCTOnIntermediates: testSCTList2, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6382 | }, |
| 6383 | }, |
| 6384 | flags: []string{ |
| 6385 | "-enable-ocsp-stapling", |
| 6386 | "-expect-ocsp-response", |
| 6387 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6388 | "-enable-signed-cert-timestamps", |
| 6389 | "-expect-signed-cert-timestamps", |
| 6390 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6391 | }, |
| 6392 | resumeSession: true, |
| 6393 | }) |
| 6394 | |
| 6395 | // Test that extensions are not sent on intermediates when configured |
| 6396 | // only for a leaf. |
| 6397 | testCases = append(testCases, testCase{ |
| 6398 | testType: serverTest, |
| 6399 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 6400 | config: Config{ |
| 6401 | MaxVersion: VersionTLS13, |
| 6402 | Bugs: ProtocolBugs{ |
| 6403 | ExpectNoExtensionsOnIntermediate: true, |
| 6404 | }, |
| 6405 | }, |
| 6406 | flags: []string{ |
| 6407 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 6408 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 6409 | "-ocsp-response", |
| 6410 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6411 | "-signed-cert-timestamps", |
| 6412 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6413 | }, |
| 6414 | }) |
| 6415 | |
| 6416 | // Test that extensions are not sent on client certificates. |
| 6417 | testCases = append(testCases, testCase{ |
| 6418 | name: "SendNoClientCertificateExtensions-TLS13", |
| 6419 | config: Config{ |
| 6420 | MaxVersion: VersionTLS13, |
| 6421 | ClientAuth: RequireAnyClientCert, |
| 6422 | }, |
| 6423 | flags: []string{ |
| 6424 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6425 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6426 | "-ocsp-response", |
| 6427 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6428 | "-signed-cert-timestamps", |
| 6429 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6430 | }, |
| 6431 | }) |
| 6432 | |
| 6433 | testCases = append(testCases, testCase{ |
| 6434 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 6435 | config: Config{ |
| 6436 | MaxVersion: VersionTLS13, |
| 6437 | Bugs: ProtocolBugs{ |
| 6438 | SendDuplicateCertExtensions: true, |
| 6439 | }, |
| 6440 | }, |
| 6441 | flags: []string{ |
| 6442 | "-enable-ocsp-stapling", |
| 6443 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6444 | }, |
| 6445 | resumeSession: true, |
| 6446 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6447 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6448 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6449 | |
| 6450 | testCases = append(testCases, testCase{ |
| 6451 | name: "SignedCertificateTimestampListInvalid-Server", |
| 6452 | testType: serverTest, |
| 6453 | flags: []string{ |
| 6454 | "-signed-cert-timestamps", |
| 6455 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 6456 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 6457 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6458 | expectedError: ":INVALID_SCT_LIST:", |
| 6459 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 6460 | } |
| 6461 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6462 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6463 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6464 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6465 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 6466 | // have session IDs, so skip their cross-resumption |
| 6467 | // tests. |
| 6468 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 6469 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 6470 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6471 | } |
| 6472 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6473 | protocols := []protocol{tls} |
| 6474 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 6475 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 6476 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6477 | for _, protocol := range protocols { |
| 6478 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 6479 | if protocol == dtls { |
| 6480 | suffix += "-DTLS" |
| 6481 | } |
| 6482 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6483 | // We can't resume across TLS 1.3 variants and error out earlier in the |
| 6484 | // session resumption. |
| 6485 | if sessionVers.tls13Variant != resumeVers.tls13Variant { |
| 6486 | continue |
| 6487 | } |
| 6488 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6489 | if sessionVers.version == resumeVers.version { |
| 6490 | testCases = append(testCases, testCase{ |
| 6491 | protocol: protocol, |
| 6492 | name: "Resume-Client" + suffix, |
| 6493 | resumeSession: true, |
| 6494 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6495 | MaxVersion: sessionVers.version, |
| 6496 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6497 | Bugs: ProtocolBugs{ |
| 6498 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 6499 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 6500 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6501 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6502 | expectedVersion: sessionVers.version, |
| 6503 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6504 | flags: []string{ |
| 6505 | "-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6506 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6507 | }) |
| 6508 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6509 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 6510 | |
| 6511 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 6512 | // there is no way to convince a non-lookahead client the |
| 6513 | // session was resumed. It will appear to the client that a |
| 6514 | // stray ChangeCipherSpec was sent. |
| 6515 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 6516 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6517 | } |
| 6518 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6519 | testCases = append(testCases, testCase{ |
| 6520 | protocol: protocol, |
| 6521 | name: "Resume-Client-Mismatch" + suffix, |
| 6522 | resumeSession: true, |
| 6523 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6524 | MaxVersion: sessionVers.version, |
| 6525 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6526 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6527 | expectedVersion: sessionVers.version, |
| 6528 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6529 | MaxVersion: resumeVers.version, |
| 6530 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6531 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6532 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6533 | }, |
| 6534 | }, |
| 6535 | expectedResumeVersion: resumeVers.version, |
| 6536 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6537 | expectedError: error, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6538 | flags: []string{ |
| 6539 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6540 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6541 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6542 | }) |
| 6543 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6544 | |
| 6545 | testCases = append(testCases, testCase{ |
| 6546 | protocol: protocol, |
| 6547 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6548 | resumeSession: true, |
| 6549 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6550 | MaxVersion: sessionVers.version, |
| 6551 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6552 | }, |
| 6553 | expectedVersion: sessionVers.version, |
| 6554 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6555 | MaxVersion: resumeVers.version, |
| 6556 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6557 | }, |
| 6558 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6559 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6560 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6561 | flags: []string{ |
| 6562 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6563 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6564 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6565 | }) |
| 6566 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6567 | testCases = append(testCases, testCase{ |
| 6568 | protocol: protocol, |
| 6569 | testType: serverTest, |
| 6570 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6571 | resumeSession: true, |
| 6572 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6573 | MaxVersion: sessionVers.version, |
| 6574 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6575 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6576 | expectedVersion: sessionVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6577 | expectResumeRejected: sessionVers != resumeVers, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6578 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6579 | MaxVersion: resumeVers.version, |
| 6580 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6581 | Bugs: ProtocolBugs{ |
| 6582 | SendBothTickets: true, |
| 6583 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6584 | }, |
| 6585 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6586 | flags: []string{ |
| 6587 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6588 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6589 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6590 | }) |
| 6591 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6592 | } |
| 6593 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6594 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6595 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6596 | testCases = append(testCases, testCase{ |
| 6597 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6598 | name: "ShimTicketRewritable", |
| 6599 | resumeSession: true, |
| 6600 | config: Config{ |
| 6601 | MaxVersion: VersionTLS12, |
| 6602 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6603 | Bugs: ProtocolBugs{ |
| 6604 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6605 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6606 | if err != nil { |
| 6607 | return nil, err |
| 6608 | } |
| 6609 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6610 | }, |
| 6611 | }, |
| 6612 | }, |
| 6613 | flags: []string{ |
| 6614 | "-ticket-key", |
| 6615 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6616 | }, |
| 6617 | }) |
| 6618 | |
| 6619 | // Resumptions are declined if the version does not match. |
| 6620 | testCases = append(testCases, testCase{ |
| 6621 | testType: serverTest, |
| 6622 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6623 | resumeSession: true, |
| 6624 | config: Config{ |
| 6625 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6626 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6627 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6628 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6629 | return SetShimTicketVersion(in, VersionTLS13) |
| 6630 | }, |
| 6631 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6632 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6633 | flags: []string{ |
| 6634 | "-ticket-key", |
| 6635 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6636 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6637 | expectResumeRejected: true, |
| 6638 | }) |
| 6639 | |
| 6640 | testCases = append(testCases, testCase{ |
| 6641 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6642 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6643 | resumeSession: true, |
| 6644 | config: Config{ |
| 6645 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6646 | Bugs: ProtocolBugs{ |
| 6647 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6648 | return SetShimTicketVersion(in, VersionTLS12) |
| 6649 | }, |
| 6650 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6651 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6652 | flags: []string{ |
| 6653 | "-ticket-key", |
| 6654 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6655 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6656 | expectResumeRejected: true, |
| 6657 | }) |
| 6658 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6659 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6660 | testCases = append(testCases, testCase{ |
| 6661 | testType: serverTest, |
| 6662 | name: "Resume-Server-DeclineBadCipher", |
| 6663 | resumeSession: true, |
| 6664 | config: Config{ |
| 6665 | MaxVersion: VersionTLS12, |
| 6666 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6667 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6668 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6669 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6670 | }, |
| 6671 | }, |
| 6672 | }, |
| 6673 | flags: []string{ |
| 6674 | "-ticket-key", |
| 6675 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6676 | }, |
| 6677 | expectResumeRejected: true, |
| 6678 | }) |
| 6679 | |
| 6680 | testCases = append(testCases, testCase{ |
| 6681 | testType: serverTest, |
| 6682 | name: "Resume-Server-DeclineBadCipher-2", |
| 6683 | resumeSession: true, |
| 6684 | config: Config{ |
| 6685 | MaxVersion: VersionTLS12, |
| 6686 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6687 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6688 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6689 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6690 | }, |
| 6691 | }, |
| 6692 | }, |
| 6693 | flags: []string{ |
| 6694 | "-cipher", "AES128", |
| 6695 | "-ticket-key", |
| 6696 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6697 | }, |
| 6698 | expectResumeRejected: true, |
| 6699 | }) |
| 6700 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6701 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6702 | testCases = append(testCases, testCase{ |
| 6703 | testType: serverTest, |
| 6704 | name: "Resume-Server-CipherNotPreferred", |
| 6705 | resumeSession: true, |
| 6706 | config: Config{ |
| 6707 | MaxVersion: VersionTLS12, |
| 6708 | Bugs: ProtocolBugs{ |
| 6709 | ExpectNewTicket: true, |
| 6710 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6711 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6712 | }, |
| 6713 | }, |
| 6714 | }, |
| 6715 | flags: []string{ |
| 6716 | "-ticket-key", |
| 6717 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6718 | }, |
| 6719 | shouldFail: false, |
| 6720 | expectResumeRejected: true, |
| 6721 | }) |
| 6722 | |
| 6723 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6724 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6725 | testCases = append(testCases, testCase{ |
| 6726 | testType: serverTest, |
| 6727 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6728 | resumeSession: true, |
| 6729 | config: Config{ |
| 6730 | MaxVersion: VersionTLS13, |
| 6731 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6732 | Bugs: ProtocolBugs{ |
| 6733 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6734 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6735 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6736 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6737 | }, |
| 6738 | }, |
| 6739 | }, |
| 6740 | flags: []string{ |
| 6741 | "-ticket-key", |
| 6742 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6743 | }, |
| 6744 | shouldFail: false, |
| 6745 | expectResumeRejected: true, |
| 6746 | }) |
| 6747 | |
| 6748 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6749 | testCases = append(testCases, testCase{ |
| 6750 | testType: serverTest, |
| 6751 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6752 | resumeSession: true, |
| 6753 | config: Config{ |
| 6754 | MaxVersion: VersionTLS13, |
| 6755 | Bugs: ProtocolBugs{ |
| 6756 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6757 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6758 | }, |
| 6759 | }, |
| 6760 | }, |
| 6761 | flags: []string{ |
| 6762 | "-ticket-key", |
| 6763 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6764 | }, |
| 6765 | expectResumeRejected: true, |
| 6766 | }) |
| 6767 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6768 | // If the client does not offer the cipher from the session, decline to |
| 6769 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6770 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6771 | testCases = append(testCases, testCase{ |
| 6772 | testType: serverTest, |
| 6773 | name: "Resume-Server-UnofferedCipher", |
| 6774 | resumeSession: true, |
| 6775 | config: Config{ |
| 6776 | MaxVersion: VersionTLS12, |
| 6777 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6778 | }, |
| 6779 | resumeConfig: &Config{ |
| 6780 | MaxVersion: VersionTLS12, |
| 6781 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6782 | Bugs: ProtocolBugs{ |
| 6783 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6784 | }, |
| 6785 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6786 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6787 | }) |
| 6788 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6789 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6790 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6791 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6792 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6793 | testCases = append(testCases, testCase{ |
| 6794 | testType: serverTest, |
| 6795 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6796 | resumeSession: true, |
| 6797 | config: Config{ |
| 6798 | MaxVersion: VersionTLS13, |
| 6799 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6800 | }, |
| 6801 | resumeConfig: &Config{ |
| 6802 | MaxVersion: VersionTLS13, |
| 6803 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6804 | Bugs: ProtocolBugs{ |
| 6805 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6806 | }, |
| 6807 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6808 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6809 | }) |
| 6810 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6811 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6812 | testCases = append(testCases, testCase{ |
| 6813 | name: "Resume-Client-CipherMismatch", |
| 6814 | resumeSession: true, |
| 6815 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6816 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6817 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6818 | }, |
| 6819 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6820 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6821 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6822 | Bugs: ProtocolBugs{ |
| 6823 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6824 | }, |
| 6825 | }, |
| 6826 | shouldFail: true, |
| 6827 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6828 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6829 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6830 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6831 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6832 | testCases = append(testCases, testCase{ |
| 6833 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6834 | resumeSession: true, |
| 6835 | config: Config{ |
| 6836 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6837 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6838 | }, |
| 6839 | resumeConfig: &Config{ |
| 6840 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6841 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6842 | }, |
| 6843 | }) |
| 6844 | |
| 6845 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6846 | testCases = append(testCases, testCase{ |
| 6847 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6848 | resumeSession: true, |
| 6849 | config: Config{ |
| 6850 | MaxVersion: VersionTLS13, |
| 6851 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6852 | }, |
| 6853 | resumeConfig: &Config{ |
| 6854 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6855 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6856 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6857 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6858 | }, |
| 6859 | }, |
| 6860 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6861 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6862 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6863 | |
| 6864 | testCases = append(testCases, testCase{ |
| 6865 | testType: serverTest, |
| 6866 | name: "Resume-Server-BinderWrongLength", |
| 6867 | resumeSession: true, |
| 6868 | config: Config{ |
| 6869 | MaxVersion: VersionTLS13, |
| 6870 | Bugs: ProtocolBugs{ |
| 6871 | SendShortPSKBinder: true, |
| 6872 | }, |
| 6873 | }, |
| 6874 | shouldFail: true, |
| 6875 | expectedLocalError: "remote error: error decrypting message", |
| 6876 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6877 | }) |
| 6878 | |
| 6879 | testCases = append(testCases, testCase{ |
| 6880 | testType: serverTest, |
| 6881 | name: "Resume-Server-NoPSKBinder", |
| 6882 | resumeSession: true, |
| 6883 | config: Config{ |
| 6884 | MaxVersion: VersionTLS13, |
| 6885 | Bugs: ProtocolBugs{ |
| 6886 | SendNoPSKBinder: true, |
| 6887 | }, |
| 6888 | }, |
| 6889 | shouldFail: true, |
| 6890 | expectedLocalError: "remote error: error decoding message", |
| 6891 | expectedError: ":DECODE_ERROR:", |
| 6892 | }) |
| 6893 | |
| 6894 | testCases = append(testCases, testCase{ |
| 6895 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6896 | name: "Resume-Server-ExtraPSKBinder", |
| 6897 | resumeSession: true, |
| 6898 | config: Config{ |
| 6899 | MaxVersion: VersionTLS13, |
| 6900 | Bugs: ProtocolBugs{ |
| 6901 | SendExtraPSKBinder: true, |
| 6902 | }, |
| 6903 | }, |
| 6904 | shouldFail: true, |
| 6905 | expectedLocalError: "remote error: illegal parameter", |
| 6906 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6907 | }) |
| 6908 | |
| 6909 | testCases = append(testCases, testCase{ |
| 6910 | testType: serverTest, |
| 6911 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6912 | resumeSession: true, |
| 6913 | config: Config{ |
| 6914 | MaxVersion: VersionTLS13, |
| 6915 | Bugs: ProtocolBugs{ |
| 6916 | ExtraPSKIdentity: true, |
| 6917 | }, |
| 6918 | }, |
| 6919 | shouldFail: true, |
| 6920 | expectedLocalError: "remote error: illegal parameter", |
| 6921 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6922 | }) |
| 6923 | |
| 6924 | testCases = append(testCases, testCase{ |
| 6925 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6926 | name: "Resume-Server-InvalidPSKBinder", |
| 6927 | resumeSession: true, |
| 6928 | config: Config{ |
| 6929 | MaxVersion: VersionTLS13, |
| 6930 | Bugs: ProtocolBugs{ |
| 6931 | SendInvalidPSKBinder: true, |
| 6932 | }, |
| 6933 | }, |
| 6934 | shouldFail: true, |
| 6935 | expectedLocalError: "remote error: error decrypting message", |
| 6936 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6937 | }) |
| 6938 | |
| 6939 | testCases = append(testCases, testCase{ |
| 6940 | testType: serverTest, |
| 6941 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6942 | resumeSession: true, |
| 6943 | config: Config{ |
| 6944 | MaxVersion: VersionTLS13, |
| 6945 | Bugs: ProtocolBugs{ |
| 6946 | PSKBinderFirst: true, |
| 6947 | }, |
| 6948 | }, |
| 6949 | shouldFail: true, |
| 6950 | expectedLocalError: "remote error: illegal parameter", |
| 6951 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6952 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6953 | } |
| 6954 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6955 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6956 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6957 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6958 | testType: serverTest, |
| 6959 | name: "Renegotiate-Server-Forbidden", |
| 6960 | config: Config{ |
| 6961 | MaxVersion: VersionTLS12, |
| 6962 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6963 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6964 | shouldFail: true, |
| 6965 | expectedError: ":NO_RENEGOTIATION:", |
| 6966 | expectedLocalError: "remote error: no renegotiation", |
| 6967 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6968 | // The server shouldn't echo the renegotiation extension unless |
| 6969 | // requested by the client. |
| 6970 | testCases = append(testCases, testCase{ |
| 6971 | testType: serverTest, |
| 6972 | name: "Renegotiate-Server-NoExt", |
| 6973 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6974 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6975 | Bugs: ProtocolBugs{ |
| 6976 | NoRenegotiationInfo: true, |
| 6977 | RequireRenegotiationInfo: true, |
| 6978 | }, |
| 6979 | }, |
| 6980 | shouldFail: true, |
| 6981 | expectedLocalError: "renegotiation extension missing", |
| 6982 | }) |
| 6983 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6984 | // the extension. |
| 6985 | testCases = append(testCases, testCase{ |
| 6986 | testType: serverTest, |
| 6987 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6988 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6989 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6990 | Bugs: ProtocolBugs{ |
| 6991 | NoRenegotiationInfo: true, |
| 6992 | SendRenegotiationSCSV: true, |
| 6993 | RequireRenegotiationInfo: true, |
| 6994 | }, |
| 6995 | }, |
| 6996 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6997 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6998 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6999 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7000 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7001 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7002 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7003 | }, |
| 7004 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7005 | renegotiate: 1, |
David Benjamin | d0beda0 | 2017-09-06 16:46:50 -0400 | [diff] [blame] | 7006 | // Test renegotiation after both an initial and resumption |
| 7007 | // handshake. |
| 7008 | resumeSession: true, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7009 | flags: []string{ |
| 7010 | "-renegotiate-freely", |
| 7011 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7012 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7013 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7014 | }) |
| 7015 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7016 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7017 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7018 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7019 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7020 | Bugs: ProtocolBugs{ |
| 7021 | EmptyRenegotiationInfo: true, |
| 7022 | }, |
| 7023 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7024 | flags: []string{"-renegotiate-freely"}, |
| 7025 | shouldFail: true, |
| 7026 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7027 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7028 | }) |
| 7029 | testCases = append(testCases, testCase{ |
| 7030 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7031 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7032 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7033 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7034 | Bugs: ProtocolBugs{ |
| 7035 | BadRenegotiationInfo: true, |
| 7036 | }, |
| 7037 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7038 | flags: []string{"-renegotiate-freely"}, |
| 7039 | shouldFail: true, |
| 7040 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7041 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7042 | }) |
| 7043 | testCases = append(testCases, testCase{ |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7044 | name: "Renegotiate-Client-BadExt2", |
| 7045 | renegotiate: 1, |
| 7046 | config: Config{ |
| 7047 | MaxVersion: VersionTLS12, |
| 7048 | Bugs: ProtocolBugs{ |
| 7049 | BadRenegotiationInfoEnd: true, |
| 7050 | }, |
| 7051 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7052 | flags: []string{"-renegotiate-freely"}, |
| 7053 | shouldFail: true, |
| 7054 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7055 | expectedLocalError: "handshake failure", |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7056 | }) |
| 7057 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7058 | name: "Renegotiate-Client-Downgrade", |
| 7059 | renegotiate: 1, |
| 7060 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7061 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7062 | Bugs: ProtocolBugs{ |
| 7063 | NoRenegotiationInfoAfterInitial: true, |
| 7064 | }, |
| 7065 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7066 | flags: []string{"-renegotiate-freely"}, |
| 7067 | shouldFail: true, |
| 7068 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7069 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7070 | }) |
| 7071 | testCases = append(testCases, testCase{ |
| 7072 | name: "Renegotiate-Client-Upgrade", |
| 7073 | renegotiate: 1, |
| 7074 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7075 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7076 | Bugs: ProtocolBugs{ |
| 7077 | NoRenegotiationInfoInInitial: true, |
| 7078 | }, |
| 7079 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7080 | flags: []string{"-renegotiate-freely"}, |
| 7081 | shouldFail: true, |
| 7082 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7083 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7084 | }) |
| 7085 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7086 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7087 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7088 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7089 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7090 | Bugs: ProtocolBugs{ |
| 7091 | NoRenegotiationInfo: true, |
| 7092 | }, |
| 7093 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7094 | flags: []string{ |
| 7095 | "-renegotiate-freely", |
| 7096 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7097 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7098 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7099 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7100 | |
| 7101 | // Test that the server may switch ciphers on renegotiation without |
| 7102 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7103 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7104 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7105 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7106 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7107 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7108 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7109 | }, |
| 7110 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7111 | flags: []string{ |
| 7112 | "-renegotiate-freely", |
| 7113 | "-expect-total-renegotiations", "1", |
| 7114 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7115 | }) |
| 7116 | testCases = append(testCases, testCase{ |
| 7117 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7118 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7119 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7120 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7121 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7122 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7123 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7124 | flags: []string{ |
| 7125 | "-renegotiate-freely", |
| 7126 | "-expect-total-renegotiations", "1", |
| 7127 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7128 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7129 | |
| 7130 | // Test that the server may not switch versions on renegotiation. |
| 7131 | testCases = append(testCases, testCase{ |
| 7132 | name: "Renegotiate-Client-SwitchVersion", |
| 7133 | config: Config{ |
| 7134 | MaxVersion: VersionTLS12, |
| 7135 | // Pick a cipher which exists at both versions. |
| 7136 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 7137 | Bugs: ProtocolBugs{ |
| 7138 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 7139 | // Avoid failing early at the record layer. |
| 7140 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7141 | }, |
| 7142 | }, |
| 7143 | renegotiate: 1, |
| 7144 | flags: []string{ |
| 7145 | "-renegotiate-freely", |
| 7146 | "-expect-total-renegotiations", "1", |
| 7147 | }, |
| 7148 | shouldFail: true, |
| 7149 | expectedError: ":WRONG_SSL_VERSION:", |
| 7150 | }) |
| 7151 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7152 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7153 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7154 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7155 | config: Config{ |
| 7156 | MaxVersion: VersionTLS10, |
| 7157 | Bugs: ProtocolBugs{ |
| 7158 | RequireSameRenegoClientVersion: true, |
| 7159 | }, |
| 7160 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7161 | flags: []string{ |
| 7162 | "-renegotiate-freely", |
| 7163 | "-expect-total-renegotiations", "1", |
| 7164 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7165 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7166 | testCases = append(testCases, testCase{ |
| 7167 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7168 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7169 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7170 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7171 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7172 | NextProtos: []string{"foo"}, |
| 7173 | }, |
| 7174 | flags: []string{ |
| 7175 | "-false-start", |
| 7176 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7177 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 7178 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7179 | }, |
| 7180 | shimWritesFirst: true, |
| 7181 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7182 | |
| 7183 | // Client-side renegotiation controls. |
| 7184 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7185 | name: "Renegotiate-Client-Forbidden-1", |
| 7186 | config: Config{ |
| 7187 | MaxVersion: VersionTLS12, |
| 7188 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7189 | renegotiate: 1, |
| 7190 | shouldFail: true, |
| 7191 | expectedError: ":NO_RENEGOTIATION:", |
| 7192 | expectedLocalError: "remote error: no renegotiation", |
| 7193 | }) |
| 7194 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7195 | name: "Renegotiate-Client-Once-1", |
| 7196 | config: Config{ |
| 7197 | MaxVersion: VersionTLS12, |
| 7198 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7199 | renegotiate: 1, |
| 7200 | flags: []string{ |
| 7201 | "-renegotiate-once", |
| 7202 | "-expect-total-renegotiations", "1", |
| 7203 | }, |
| 7204 | }) |
| 7205 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7206 | name: "Renegotiate-Client-Freely-1", |
| 7207 | config: Config{ |
| 7208 | MaxVersion: VersionTLS12, |
| 7209 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7210 | renegotiate: 1, |
| 7211 | flags: []string{ |
| 7212 | "-renegotiate-freely", |
| 7213 | "-expect-total-renegotiations", "1", |
| 7214 | }, |
| 7215 | }) |
| 7216 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7217 | name: "Renegotiate-Client-Once-2", |
| 7218 | config: Config{ |
| 7219 | MaxVersion: VersionTLS12, |
| 7220 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7221 | renegotiate: 2, |
| 7222 | flags: []string{"-renegotiate-once"}, |
| 7223 | shouldFail: true, |
| 7224 | expectedError: ":NO_RENEGOTIATION:", |
| 7225 | expectedLocalError: "remote error: no renegotiation", |
| 7226 | }) |
| 7227 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7228 | name: "Renegotiate-Client-Freely-2", |
| 7229 | config: Config{ |
| 7230 | MaxVersion: VersionTLS12, |
| 7231 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7232 | renegotiate: 2, |
| 7233 | flags: []string{ |
| 7234 | "-renegotiate-freely", |
| 7235 | "-expect-total-renegotiations", "2", |
| 7236 | }, |
| 7237 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7238 | testCases = append(testCases, testCase{ |
| 7239 | name: "Renegotiate-Client-NoIgnore", |
| 7240 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7241 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7242 | Bugs: ProtocolBugs{ |
| 7243 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7244 | }, |
| 7245 | }, |
| 7246 | shouldFail: true, |
| 7247 | expectedError: ":NO_RENEGOTIATION:", |
| 7248 | }) |
| 7249 | testCases = append(testCases, testCase{ |
| 7250 | name: "Renegotiate-Client-Ignore", |
| 7251 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7252 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7253 | Bugs: ProtocolBugs{ |
| 7254 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7255 | }, |
| 7256 | }, |
| 7257 | flags: []string{ |
| 7258 | "-renegotiate-ignore", |
| 7259 | "-expect-total-renegotiations", "0", |
| 7260 | }, |
| 7261 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7262 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 7263 | // Renegotiation is not allowed at SSL 3.0. |
| 7264 | testCases = append(testCases, testCase{ |
| 7265 | name: "Renegotiate-Client-SSL3", |
| 7266 | config: Config{ |
| 7267 | MaxVersion: VersionSSL30, |
| 7268 | }, |
| 7269 | renegotiate: 1, |
| 7270 | flags: []string{ |
| 7271 | "-renegotiate-freely", |
| 7272 | "-expect-total-renegotiations", "1", |
| 7273 | }, |
| 7274 | shouldFail: true, |
| 7275 | expectedError: ":NO_RENEGOTIATION:", |
| 7276 | expectedLocalError: "remote error: no renegotiation", |
| 7277 | }) |
| 7278 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7279 | // Renegotiation is not allowed when there is an unfinished write. |
| 7280 | testCases = append(testCases, testCase{ |
| 7281 | name: "Renegotiate-Client-UnfinishedWrite", |
| 7282 | config: Config{ |
| 7283 | MaxVersion: VersionTLS12, |
| 7284 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 7285 | renegotiate: 1, |
| 7286 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7287 | flags: []string{ |
| 7288 | "-async", |
| 7289 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7290 | }, |
| 7291 | shouldFail: true, |
| 7292 | expectedError: ":NO_RENEGOTIATION:", |
| 7293 | // We do not successfully send the no_renegotiation alert in |
| 7294 | // this case. https://crbug.com/boringssl/130 |
| 7295 | }) |
| 7296 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7297 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7298 | testCases = append(testCases, testCase{ |
| 7299 | name: "StrayHelloRequest", |
| 7300 | config: Config{ |
| 7301 | MaxVersion: VersionTLS12, |
| 7302 | Bugs: ProtocolBugs{ |
| 7303 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7304 | }, |
| 7305 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7306 | shouldFail: true, |
| 7307 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7308 | }) |
| 7309 | testCases = append(testCases, testCase{ |
| 7310 | name: "StrayHelloRequest-Packed", |
| 7311 | config: Config{ |
| 7312 | MaxVersion: VersionTLS12, |
| 7313 | Bugs: ProtocolBugs{ |
| 7314 | PackHandshakeFlight: true, |
| 7315 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7316 | }, |
| 7317 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7318 | shouldFail: true, |
| 7319 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7320 | }) |
| 7321 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 7322 | // Test renegotiation works if HelloRequest and server Finished come in |
| 7323 | // the same record. |
| 7324 | testCases = append(testCases, testCase{ |
| 7325 | name: "Renegotiate-Client-Packed", |
| 7326 | config: Config{ |
| 7327 | MaxVersion: VersionTLS12, |
| 7328 | Bugs: ProtocolBugs{ |
| 7329 | PackHandshakeFlight: true, |
| 7330 | PackHelloRequestWithFinished: true, |
| 7331 | }, |
| 7332 | }, |
| 7333 | renegotiate: 1, |
| 7334 | flags: []string{ |
| 7335 | "-renegotiate-freely", |
| 7336 | "-expect-total-renegotiations", "1", |
| 7337 | }, |
| 7338 | }) |
| 7339 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7340 | // Renegotiation is forbidden in TLS 1.3. |
| 7341 | testCases = append(testCases, testCase{ |
| 7342 | name: "Renegotiate-Client-TLS13", |
| 7343 | config: Config{ |
| 7344 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7345 | Bugs: ProtocolBugs{ |
| 7346 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7347 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7348 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7349 | flags: []string{ |
| 7350 | "-renegotiate-freely", |
| 7351 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 7352 | shouldFail: true, |
| 7353 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7354 | }) |
| 7355 | |
| 7356 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 7357 | testCases = append(testCases, testCase{ |
| 7358 | name: "StrayHelloRequest-TLS13", |
| 7359 | config: Config{ |
| 7360 | MaxVersion: VersionTLS13, |
| 7361 | Bugs: ProtocolBugs{ |
| 7362 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7363 | }, |
| 7364 | }, |
| 7365 | shouldFail: true, |
| 7366 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7367 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7368 | |
| 7369 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 7370 | // always reads as supporting it, regardless of whether it was |
| 7371 | // negotiated. |
| 7372 | testCases = append(testCases, testCase{ |
| 7373 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 7374 | config: Config{ |
| 7375 | MaxVersion: VersionTLS13, |
| 7376 | Bugs: ProtocolBugs{ |
| 7377 | NoRenegotiationInfo: true, |
| 7378 | }, |
| 7379 | }, |
| 7380 | flags: []string{ |
| 7381 | "-expect-secure-renegotiation", |
| 7382 | }, |
| 7383 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 7384 | |
| 7385 | // Certificates may not change on renegotiation. |
| 7386 | testCases = append(testCases, testCase{ |
| 7387 | name: "Renegotiation-CertificateChange", |
| 7388 | config: Config{ |
| 7389 | MaxVersion: VersionTLS12, |
| 7390 | Certificates: []Certificate{rsaCertificate}, |
| 7391 | Bugs: ProtocolBugs{ |
| 7392 | RenegotiationCertificate: &rsaChainCertificate, |
| 7393 | }, |
| 7394 | }, |
| 7395 | renegotiate: 1, |
| 7396 | flags: []string{"-renegotiate-freely"}, |
| 7397 | shouldFail: true, |
| 7398 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7399 | }) |
| 7400 | testCases = append(testCases, testCase{ |
| 7401 | name: "Renegotiation-CertificateChange-2", |
| 7402 | config: Config{ |
| 7403 | MaxVersion: VersionTLS12, |
| 7404 | Certificates: []Certificate{rsaCertificate}, |
| 7405 | Bugs: ProtocolBugs{ |
| 7406 | RenegotiationCertificate: &rsa1024Certificate, |
| 7407 | }, |
| 7408 | }, |
| 7409 | renegotiate: 1, |
| 7410 | flags: []string{"-renegotiate-freely"}, |
| 7411 | shouldFail: true, |
| 7412 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7413 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 7414 | |
| 7415 | // We do not negotiate ALPN after the initial handshake. This is |
| 7416 | // error-prone and only risks bugs in consumers. |
| 7417 | testCases = append(testCases, testCase{ |
| 7418 | testType: clientTest, |
| 7419 | name: "Renegotiation-ForbidALPN", |
| 7420 | config: Config{ |
| 7421 | MaxVersion: VersionTLS12, |
| 7422 | Bugs: ProtocolBugs{ |
| 7423 | // Forcibly negotiate ALPN on both initial and |
| 7424 | // renegotiation handshakes. The test stack will |
| 7425 | // internally check the client does not offer |
| 7426 | // it. |
| 7427 | SendALPN: "foo", |
| 7428 | }, |
| 7429 | }, |
| 7430 | flags: []string{ |
| 7431 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 7432 | "-expect-alpn", "foo", |
| 7433 | "-renegotiate-freely", |
| 7434 | }, |
| 7435 | renegotiate: 1, |
| 7436 | shouldFail: true, |
| 7437 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7438 | }) |
David Benjamin | 5c4271f | 2017-08-23 22:09:41 -0700 | [diff] [blame] | 7439 | |
| 7440 | // The server may send different stapled OCSP responses or SCT lists on |
| 7441 | // renegotiation, but BoringSSL ignores this and reports the old values. |
| 7442 | // Also test that non-fatal verify results are preserved. |
| 7443 | testCases = append(testCases, testCase{ |
| 7444 | testType: clientTest, |
| 7445 | name: "Renegotiation-ChangeAuthProperties", |
| 7446 | config: Config{ |
| 7447 | MaxVersion: VersionTLS12, |
| 7448 | Bugs: ProtocolBugs{ |
| 7449 | SendOCSPResponseOnRenegotiation: testOCSPResponse2, |
| 7450 | SendSCTListOnRenegotiation: testSCTList2, |
| 7451 | }, |
| 7452 | }, |
| 7453 | renegotiate: 1, |
| 7454 | flags: []string{ |
| 7455 | "-renegotiate-freely", |
| 7456 | "-expect-total-renegotiations", "1", |
| 7457 | "-enable-ocsp-stapling", |
| 7458 | "-expect-ocsp-response", |
| 7459 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 7460 | "-enable-signed-cert-timestamps", |
| 7461 | "-expect-signed-cert-timestamps", |
| 7462 | base64.StdEncoding.EncodeToString(testSCTList), |
| 7463 | "-verify-fail", |
| 7464 | "-expect-verify-result", |
| 7465 | }, |
| 7466 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7467 | } |
| 7468 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7469 | func addDTLSReplayTests() { |
| 7470 | // Test that sequence number replays are detected. |
| 7471 | testCases = append(testCases, testCase{ |
| 7472 | protocol: dtls, |
| 7473 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7474 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7475 | replayWrites: true, |
| 7476 | }) |
| 7477 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7478 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7479 | // than the retransmit window. |
| 7480 | testCases = append(testCases, testCase{ |
| 7481 | protocol: dtls, |
| 7482 | name: "DTLS-Replay-LargeGaps", |
| 7483 | config: Config{ |
| 7484 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7485 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7486 | return in * 127 |
| 7487 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7488 | }, |
| 7489 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7490 | messageCount: 200, |
| 7491 | replayWrites: true, |
| 7492 | }) |
| 7493 | |
| 7494 | // Test the incoming sequence number changing non-monotonically. |
| 7495 | testCases = append(testCases, testCase{ |
| 7496 | protocol: dtls, |
| 7497 | name: "DTLS-Replay-NonMonotonic", |
| 7498 | config: Config{ |
| 7499 | Bugs: ProtocolBugs{ |
| 7500 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7501 | return in ^ 31 |
| 7502 | }, |
| 7503 | }, |
| 7504 | }, |
| 7505 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7506 | replayWrites: true, |
| 7507 | }) |
| 7508 | } |
| 7509 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7510 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7511 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7512 | id signatureAlgorithm |
| 7513 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7514 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7515 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 7516 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 7517 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 7518 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7519 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7520 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 7521 | // hash function doesn't have to match the curve and so the same |
| 7522 | // signature algorithm works with P-224. |
| 7523 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7524 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 7525 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 7526 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7527 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 7528 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 7529 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7530 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7531 | // Tests for key types prior to TLS 1.2. |
| 7532 | {"RSA", 0, testCertRSA}, |
| 7533 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7534 | } |
| 7535 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7536 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 7537 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 7538 | |
| 7539 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7540 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 7541 | // versions a signing cipher. |
| 7542 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7543 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7544 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 7545 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7546 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 7547 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7548 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7549 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7550 | var allAlgorithms []signatureAlgorithm |
| 7551 | for _, alg := range testSignatureAlgorithms { |
| 7552 | if alg.id != 0 { |
| 7553 | allAlgorithms = append(allAlgorithms, alg.id) |
| 7554 | } |
| 7555 | } |
| 7556 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7557 | // Make sure each signature algorithm works. Include some fake values in |
| 7558 | // the list and ensure they're ignored. |
| 7559 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7560 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7561 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 7562 | continue |
| 7563 | } |
| 7564 | |
| 7565 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 7566 | // or remove it in C. |
| 7567 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7568 | continue |
| 7569 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7570 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7571 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7572 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7573 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7574 | shouldSignFail = true |
| 7575 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7576 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7577 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7578 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 7579 | shouldSignFail = true |
| 7580 | shouldVerifyFail = true |
| 7581 | } |
| 7582 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 7583 | // the curve has to match the hash size. |
| 7584 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7585 | shouldSignFail = true |
| 7586 | shouldVerifyFail = true |
| 7587 | } |
| 7588 | |
| 7589 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 7590 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 7591 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7592 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7593 | |
| 7594 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7595 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7596 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7597 | } |
| 7598 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7599 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7600 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7601 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7602 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 7603 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7604 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7605 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7606 | config: Config{ |
| 7607 | MaxVersion: ver.version, |
| 7608 | ClientAuth: RequireAnyClientCert, |
| 7609 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7610 | fakeSigAlg1, |
| 7611 | alg.id, |
| 7612 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7613 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7614 | }, |
| 7615 | flags: []string{ |
| 7616 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7617 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7618 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7619 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7620 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7621 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7622 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7623 | expectedError: signError, |
| 7624 | expectedPeerSignatureAlgorithm: alg.id, |
| 7625 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7626 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7627 | testCases = append(testCases, testCase{ |
| 7628 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7629 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7630 | config: Config{ |
| 7631 | MaxVersion: ver.version, |
| 7632 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7633 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7634 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7635 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7636 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7637 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7638 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7639 | // Some signature algorithms may not be advertised. |
| 7640 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7641 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7642 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7643 | tls13Variant: ver.tls13Variant, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7644 | flags: []string{ |
| 7645 | "-require-any-client-certificate", |
| 7646 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7647 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7648 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7649 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7650 | // Resume the session to assert the peer signature |
| 7651 | // algorithm is reported on both handshakes. |
| 7652 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7653 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7654 | expectedError: verifyError, |
| 7655 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7656 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7657 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7658 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7659 | testCases = append(testCases, testCase{ |
| 7660 | testType: serverTest, |
| 7661 | name: "ServerAuth-Sign" + suffix, |
| 7662 | config: Config{ |
| 7663 | MaxVersion: ver.version, |
| 7664 | CipherSuites: signingCiphers, |
| 7665 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7666 | fakeSigAlg1, |
| 7667 | alg.id, |
| 7668 | fakeSigAlg2, |
| 7669 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7670 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7671 | tls13Variant: ver.tls13Variant, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7672 | flags: []string{ |
| 7673 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7674 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7675 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7676 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7677 | }, |
| 7678 | shouldFail: shouldSignFail, |
| 7679 | expectedError: signError, |
| 7680 | expectedPeerSignatureAlgorithm: alg.id, |
| 7681 | }) |
| 7682 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7683 | |
| 7684 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7685 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7686 | config: Config{ |
| 7687 | MaxVersion: ver.version, |
| 7688 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7689 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7690 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7691 | alg.id, |
| 7692 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7693 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7694 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7695 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7696 | // Some signature algorithms may not be advertised. |
| 7697 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7698 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7699 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7700 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7701 | flags: []string{ |
| 7702 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7703 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7704 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7705 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7706 | // Resume the session to assert the peer signature |
| 7707 | // algorithm is reported on both handshakes. |
| 7708 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7709 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7710 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7711 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7712 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7713 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7714 | testCases = append(testCases, testCase{ |
| 7715 | testType: serverTest, |
| 7716 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7717 | config: Config{ |
| 7718 | MaxVersion: ver.version, |
| 7719 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7720 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7721 | alg.id, |
| 7722 | }, |
| 7723 | Bugs: ProtocolBugs{ |
| 7724 | InvalidSignature: true, |
| 7725 | }, |
| 7726 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7727 | tls13Variant: ver.tls13Variant, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7728 | flags: []string{ |
| 7729 | "-require-any-client-certificate", |
| 7730 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7731 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7732 | }, |
| 7733 | shouldFail: true, |
| 7734 | expectedError: ":BAD_SIGNATURE:", |
| 7735 | }) |
| 7736 | |
| 7737 | testCases = append(testCases, testCase{ |
| 7738 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7739 | config: Config{ |
| 7740 | MaxVersion: ver.version, |
| 7741 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7742 | CipherSuites: signingCiphers, |
| 7743 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7744 | alg.id, |
| 7745 | }, |
| 7746 | Bugs: ProtocolBugs{ |
| 7747 | InvalidSignature: true, |
| 7748 | }, |
| 7749 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7750 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7751 | flags: []string{ |
| 7752 | "-enable-all-curves", |
| 7753 | "-enable-ed25519", |
| 7754 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7755 | shouldFail: true, |
| 7756 | expectedError: ":BAD_SIGNATURE:", |
| 7757 | }) |
| 7758 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7759 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7760 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7761 | testCases = append(testCases, testCase{ |
| 7762 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7763 | config: Config{ |
| 7764 | MaxVersion: ver.version, |
| 7765 | ClientAuth: RequireAnyClientCert, |
| 7766 | VerifySignatureAlgorithms: allAlgorithms, |
| 7767 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7768 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7769 | flags: []string{ |
| 7770 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7771 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7772 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7773 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7774 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7775 | }, |
| 7776 | expectedPeerSignatureAlgorithm: alg.id, |
| 7777 | }) |
| 7778 | |
| 7779 | testCases = append(testCases, testCase{ |
| 7780 | testType: serverTest, |
| 7781 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7782 | config: Config{ |
| 7783 | MaxVersion: ver.version, |
| 7784 | CipherSuites: signingCiphers, |
| 7785 | VerifySignatureAlgorithms: allAlgorithms, |
| 7786 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7787 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7788 | flags: []string{ |
| 7789 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7790 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7791 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7792 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7793 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7794 | }, |
| 7795 | expectedPeerSignatureAlgorithm: alg.id, |
| 7796 | }) |
| 7797 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7798 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7799 | } |
| 7800 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7801 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7802 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7803 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7804 | config: Config{ |
| 7805 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7806 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7807 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7808 | signatureECDSAWithP521AndSHA512, |
| 7809 | signatureRSAPKCS1WithSHA384, |
| 7810 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7811 | }, |
| 7812 | }, |
| 7813 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7814 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7815 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7816 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7817 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7818 | }) |
| 7819 | |
| 7820 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7821 | name: "ClientAuth-SignatureType-TLS13", |
| 7822 | config: Config{ |
| 7823 | ClientAuth: RequireAnyClientCert, |
| 7824 | MaxVersion: VersionTLS13, |
| 7825 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7826 | signatureECDSAWithP521AndSHA512, |
| 7827 | signatureRSAPKCS1WithSHA384, |
| 7828 | signatureRSAPSSWithSHA384, |
| 7829 | signatureECDSAWithSHA1, |
| 7830 | }, |
| 7831 | }, |
| 7832 | flags: []string{ |
| 7833 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7834 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7835 | }, |
| 7836 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7837 | }) |
| 7838 | |
| 7839 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7840 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7841 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7842 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7843 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7844 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7845 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7846 | signatureECDSAWithP521AndSHA512, |
| 7847 | signatureRSAPKCS1WithSHA384, |
| 7848 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7849 | }, |
| 7850 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7851 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7852 | }) |
| 7853 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7854 | testCases = append(testCases, testCase{ |
| 7855 | testType: serverTest, |
| 7856 | name: "ServerAuth-SignatureType-TLS13", |
| 7857 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7858 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7859 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7860 | signatureECDSAWithP521AndSHA512, |
| 7861 | signatureRSAPKCS1WithSHA384, |
| 7862 | signatureRSAPSSWithSHA384, |
| 7863 | signatureECDSAWithSHA1, |
| 7864 | }, |
| 7865 | }, |
| 7866 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7867 | }) |
| 7868 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7869 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7870 | testCases = append(testCases, testCase{ |
| 7871 | testType: serverTest, |
| 7872 | name: "Verify-ClientAuth-SignatureType", |
| 7873 | config: Config{ |
| 7874 | MaxVersion: VersionTLS12, |
| 7875 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7876 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7877 | signatureRSAPKCS1WithSHA256, |
| 7878 | }, |
| 7879 | Bugs: ProtocolBugs{ |
| 7880 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7881 | }, |
| 7882 | }, |
| 7883 | flags: []string{ |
| 7884 | "-require-any-client-certificate", |
| 7885 | }, |
| 7886 | shouldFail: true, |
| 7887 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7888 | }) |
| 7889 | |
| 7890 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7891 | testType: serverTest, |
| 7892 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7893 | config: Config{ |
| 7894 | MaxVersion: VersionTLS13, |
| 7895 | Certificates: []Certificate{rsaCertificate}, |
| 7896 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7897 | signatureRSAPSSWithSHA256, |
| 7898 | }, |
| 7899 | Bugs: ProtocolBugs{ |
| 7900 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7901 | }, |
| 7902 | }, |
| 7903 | flags: []string{ |
| 7904 | "-require-any-client-certificate", |
| 7905 | }, |
| 7906 | shouldFail: true, |
| 7907 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7908 | }) |
| 7909 | |
| 7910 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7911 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7912 | config: Config{ |
| 7913 | MaxVersion: VersionTLS12, |
| 7914 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7915 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7916 | signatureRSAPKCS1WithSHA256, |
| 7917 | }, |
| 7918 | Bugs: ProtocolBugs{ |
| 7919 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7920 | }, |
| 7921 | }, |
| 7922 | shouldFail: true, |
| 7923 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7924 | }) |
| 7925 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7926 | testCases = append(testCases, testCase{ |
| 7927 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7928 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7929 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7930 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7931 | signatureRSAPSSWithSHA256, |
| 7932 | }, |
| 7933 | Bugs: ProtocolBugs{ |
| 7934 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7935 | }, |
| 7936 | }, |
| 7937 | shouldFail: true, |
| 7938 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7939 | }) |
| 7940 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7941 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 7942 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7943 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7944 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7945 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7946 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7947 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7948 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7949 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7950 | }, |
| 7951 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7952 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7953 | }, |
| 7954 | }, |
| 7955 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7956 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7957 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7958 | }, |
| 7959 | }) |
| 7960 | |
| 7961 | testCases = append(testCases, testCase{ |
| 7962 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7963 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7964 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7965 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7966 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7967 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7968 | }, |
| 7969 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7970 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7971 | }, |
| 7972 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7973 | flags: []string{ |
| 7974 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7975 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7976 | }, |
| 7977 | }) |
| 7978 | |
| 7979 | testCases = append(testCases, testCase{ |
| 7980 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 7981 | config: Config{ |
| 7982 | MaxVersion: VersionTLS12, |
| 7983 | ClientAuth: RequireAnyClientCert, |
| 7984 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7985 | signatureECDSAWithSHA1, |
| 7986 | }, |
| 7987 | Bugs: ProtocolBugs{ |
| 7988 | NoSignatureAlgorithms: true, |
| 7989 | }, |
| 7990 | }, |
| 7991 | flags: []string{ |
| 7992 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7993 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7994 | }, |
| 7995 | }) |
| 7996 | |
| 7997 | testCases = append(testCases, testCase{ |
| 7998 | testType: serverTest, |
| 7999 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 8000 | config: Config{ |
| 8001 | MaxVersion: VersionTLS12, |
| 8002 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8003 | signatureECDSAWithSHA1, |
| 8004 | }, |
| 8005 | Bugs: ProtocolBugs{ |
| 8006 | NoSignatureAlgorithms: true, |
| 8007 | }, |
| 8008 | }, |
| 8009 | flags: []string{ |
| 8010 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8011 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8012 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8013 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8014 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8015 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8016 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8017 | config: Config{ |
| 8018 | MaxVersion: VersionTLS13, |
| 8019 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8020 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8021 | signatureRSAPKCS1WithSHA1, |
| 8022 | }, |
| 8023 | Bugs: ProtocolBugs{ |
| 8024 | NoSignatureAlgorithms: true, |
| 8025 | }, |
| 8026 | }, |
| 8027 | flags: []string{ |
| 8028 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8029 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8030 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 8031 | shouldFail: true, |
| 8032 | // An empty CertificateRequest signature algorithm list is a |
| 8033 | // syntax error in TLS 1.3. |
| 8034 | expectedError: ":DECODE_ERROR:", |
| 8035 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8036 | }) |
| 8037 | |
| 8038 | testCases = append(testCases, testCase{ |
| 8039 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8040 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8041 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8042 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8043 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8044 | signatureRSAPKCS1WithSHA1, |
| 8045 | }, |
| 8046 | Bugs: ProtocolBugs{ |
| 8047 | NoSignatureAlgorithms: true, |
| 8048 | }, |
| 8049 | }, |
| 8050 | shouldFail: true, |
| 8051 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8052 | }) |
| 8053 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8054 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 8055 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8056 | testCases = append(testCases, testCase{ |
| 8057 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8058 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8059 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8060 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8061 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8062 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8063 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8064 | }, |
| 8065 | Bugs: ProtocolBugs{ |
| 8066 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8067 | }, |
| 8068 | }, |
| 8069 | flags: []string{"-require-any-client-certificate"}, |
| 8070 | shouldFail: true, |
| 8071 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8072 | }) |
| 8073 | |
| 8074 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8075 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8076 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8077 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8078 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8079 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8080 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8081 | }, |
| 8082 | Bugs: ProtocolBugs{ |
| 8083 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8084 | }, |
| 8085 | }, |
| 8086 | shouldFail: true, |
| 8087 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8088 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8089 | testCases = append(testCases, testCase{ |
| 8090 | testType: serverTest, |
| 8091 | name: "ClientAuth-Enforced-TLS13", |
| 8092 | config: Config{ |
| 8093 | MaxVersion: VersionTLS13, |
| 8094 | Certificates: []Certificate{rsaCertificate}, |
| 8095 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8096 | signatureRSAPKCS1WithMD5, |
| 8097 | }, |
| 8098 | Bugs: ProtocolBugs{ |
| 8099 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8100 | IgnoreSignatureVersionChecks: true, |
| 8101 | }, |
| 8102 | }, |
| 8103 | flags: []string{"-require-any-client-certificate"}, |
| 8104 | shouldFail: true, |
| 8105 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8106 | }) |
| 8107 | |
| 8108 | testCases = append(testCases, testCase{ |
| 8109 | name: "ServerAuth-Enforced-TLS13", |
| 8110 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8111 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8112 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8113 | signatureRSAPKCS1WithMD5, |
| 8114 | }, |
| 8115 | Bugs: ProtocolBugs{ |
| 8116 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8117 | IgnoreSignatureVersionChecks: true, |
| 8118 | }, |
| 8119 | }, |
| 8120 | shouldFail: true, |
| 8121 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8122 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8123 | |
| 8124 | // Test that the agreed upon digest respects the client preferences and |
| 8125 | // the server digests. |
| 8126 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8127 | name: "NoCommonAlgorithms-Digests", |
| 8128 | config: Config{ |
| 8129 | MaxVersion: VersionTLS12, |
| 8130 | ClientAuth: RequireAnyClientCert, |
| 8131 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8132 | signatureRSAPKCS1WithSHA512, |
| 8133 | signatureRSAPKCS1WithSHA1, |
| 8134 | }, |
| 8135 | }, |
| 8136 | flags: []string{ |
| 8137 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8138 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8139 | "-digest-prefs", "SHA256", |
| 8140 | }, |
| 8141 | shouldFail: true, |
| 8142 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8143 | }) |
| 8144 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8145 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8146 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8147 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8148 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8149 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8150 | signatureRSAPKCS1WithSHA512, |
| 8151 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8152 | }, |
| 8153 | }, |
| 8154 | flags: []string{ |
| 8155 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8156 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8157 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8158 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8159 | shouldFail: true, |
| 8160 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8161 | }) |
| 8162 | testCases = append(testCases, testCase{ |
| 8163 | name: "NoCommonAlgorithms-TLS13", |
| 8164 | config: Config{ |
| 8165 | MaxVersion: VersionTLS13, |
| 8166 | ClientAuth: RequireAnyClientCert, |
| 8167 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8168 | signatureRSAPSSWithSHA512, |
| 8169 | signatureRSAPSSWithSHA384, |
| 8170 | }, |
| 8171 | }, |
| 8172 | flags: []string{ |
| 8173 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8174 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8175 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 8176 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8177 | shouldFail: true, |
| 8178 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8179 | }) |
| 8180 | testCases = append(testCases, testCase{ |
| 8181 | name: "Agree-Digest-SHA256", |
| 8182 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8183 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8184 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8185 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8186 | signatureRSAPKCS1WithSHA1, |
| 8187 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8188 | }, |
| 8189 | }, |
| 8190 | flags: []string{ |
| 8191 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8192 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8193 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8194 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8195 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8196 | }) |
| 8197 | testCases = append(testCases, testCase{ |
| 8198 | name: "Agree-Digest-SHA1", |
| 8199 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8200 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8201 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8202 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8203 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8204 | }, |
| 8205 | }, |
| 8206 | flags: []string{ |
| 8207 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8208 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8209 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8210 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8211 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8212 | }) |
| 8213 | testCases = append(testCases, testCase{ |
| 8214 | name: "Agree-Digest-Default", |
| 8215 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8216 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8217 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8218 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8219 | signatureRSAPKCS1WithSHA256, |
| 8220 | signatureECDSAWithP256AndSHA256, |
| 8221 | signatureRSAPKCS1WithSHA1, |
| 8222 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8223 | }, |
| 8224 | }, |
| 8225 | flags: []string{ |
| 8226 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8227 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8228 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8229 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8230 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8231 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8232 | // Test that the signing preference list may include extra algorithms |
| 8233 | // without negotiation problems. |
| 8234 | testCases = append(testCases, testCase{ |
| 8235 | testType: serverTest, |
| 8236 | name: "FilterExtraAlgorithms", |
| 8237 | config: Config{ |
| 8238 | MaxVersion: VersionTLS12, |
| 8239 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8240 | signatureRSAPKCS1WithSHA256, |
| 8241 | }, |
| 8242 | }, |
| 8243 | flags: []string{ |
| 8244 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8245 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8246 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 8247 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 8248 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 8249 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 8250 | }, |
| 8251 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 8252 | }) |
| 8253 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8254 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 8255 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8256 | testCases = append(testCases, testCase{ |
| 8257 | name: "CheckLeafCurve", |
| 8258 | config: Config{ |
| 8259 | MaxVersion: VersionTLS12, |
| 8260 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8261 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8262 | }, |
| 8263 | flags: []string{"-p384-only"}, |
| 8264 | shouldFail: true, |
| 8265 | expectedError: ":BAD_ECC_CERT:", |
| 8266 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8267 | |
| 8268 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 8269 | testCases = append(testCases, testCase{ |
| 8270 | name: "CheckLeafCurve-TLS13", |
| 8271 | config: Config{ |
| 8272 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8273 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 8274 | }, |
| 8275 | flags: []string{"-p384-only"}, |
| 8276 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8277 | |
| 8278 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 8279 | testCases = append(testCases, testCase{ |
| 8280 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 8281 | config: Config{ |
| 8282 | MaxVersion: VersionTLS12, |
| 8283 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 8284 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8285 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8286 | signatureECDSAWithP384AndSHA384, |
| 8287 | }, |
| 8288 | }, |
| 8289 | }) |
| 8290 | |
| 8291 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 8292 | testCases = append(testCases, testCase{ |
| 8293 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 8294 | config: Config{ |
| 8295 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8296 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8297 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8298 | signatureECDSAWithP384AndSHA384, |
| 8299 | }, |
| 8300 | Bugs: ProtocolBugs{ |
| 8301 | SkipECDSACurveCheck: true, |
| 8302 | }, |
| 8303 | }, |
| 8304 | shouldFail: true, |
| 8305 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8306 | }) |
| 8307 | |
| 8308 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 8309 | // account. |
| 8310 | testCases = append(testCases, testCase{ |
| 8311 | testType: serverTest, |
| 8312 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 8313 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8314 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8315 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8316 | signatureECDSAWithP384AndSHA384, |
| 8317 | signatureECDSAWithP256AndSHA256, |
| 8318 | }, |
| 8319 | }, |
| 8320 | flags: []string{ |
| 8321 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8322 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8323 | }, |
| 8324 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8325 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 8326 | |
| 8327 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 8328 | // server does not attempt to sign in that case. |
| 8329 | testCases = append(testCases, testCase{ |
| 8330 | testType: serverTest, |
| 8331 | name: "RSA-PSS-Large", |
| 8332 | config: Config{ |
| 8333 | MaxVersion: VersionTLS13, |
| 8334 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8335 | signatureRSAPSSWithSHA512, |
| 8336 | }, |
| 8337 | }, |
| 8338 | flags: []string{ |
| 8339 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 8340 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 8341 | }, |
| 8342 | shouldFail: true, |
| 8343 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8344 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 8345 | |
| 8346 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 8347 | testCases = append(testCases, testCase{ |
| 8348 | testType: clientTest, |
| 8349 | name: "RSA-PSS-Default-Verify", |
| 8350 | config: Config{ |
| 8351 | MaxVersion: VersionTLS12, |
| 8352 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8353 | signatureRSAPSSWithSHA256, |
| 8354 | }, |
| 8355 | }, |
| 8356 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8357 | }) |
| 8358 | |
| 8359 | testCases = append(testCases, testCase{ |
| 8360 | testType: serverTest, |
| 8361 | name: "RSA-PSS-Default-Sign", |
| 8362 | config: Config{ |
| 8363 | MaxVersion: VersionTLS12, |
| 8364 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8365 | signatureRSAPSSWithSHA256, |
| 8366 | }, |
| 8367 | }, |
| 8368 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8369 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 8370 | |
| 8371 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 8372 | // Ed25519's signature algorithm. |
| 8373 | testCases = append(testCases, testCase{ |
| 8374 | testType: clientTest, |
| 8375 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 8376 | config: Config{ |
| 8377 | MaxVersion: VersionTLS11, |
| 8378 | Certificates: []Certificate{ed25519Certificate}, |
| 8379 | Bugs: ProtocolBugs{ |
| 8380 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8381 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8382 | }, |
| 8383 | }, |
| 8384 | flags: []string{"-enable-ed25519"}, |
| 8385 | shouldFail: true, |
| 8386 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8387 | }) |
| 8388 | testCases = append(testCases, testCase{ |
| 8389 | testType: serverTest, |
| 8390 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 8391 | config: Config{ |
| 8392 | MaxVersion: VersionTLS11, |
| 8393 | }, |
| 8394 | flags: []string{ |
| 8395 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8396 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8397 | }, |
| 8398 | shouldFail: true, |
| 8399 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8400 | }) |
| 8401 | testCases = append(testCases, testCase{ |
| 8402 | testType: serverTest, |
| 8403 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 8404 | config: Config{ |
| 8405 | MaxVersion: VersionTLS11, |
| 8406 | Certificates: []Certificate{ed25519Certificate}, |
| 8407 | Bugs: ProtocolBugs{ |
| 8408 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8409 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8410 | }, |
| 8411 | }, |
| 8412 | flags: []string{ |
| 8413 | "-enable-ed25519", |
| 8414 | "-require-any-client-certificate", |
| 8415 | }, |
| 8416 | shouldFail: true, |
| 8417 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8418 | }) |
| 8419 | testCases = append(testCases, testCase{ |
| 8420 | testType: clientTest, |
| 8421 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 8422 | config: Config{ |
| 8423 | MaxVersion: VersionTLS11, |
| 8424 | ClientAuth: RequireAnyClientCert, |
| 8425 | }, |
| 8426 | flags: []string{ |
| 8427 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8428 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8429 | }, |
| 8430 | shouldFail: true, |
| 8431 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8432 | }) |
| 8433 | |
| 8434 | // Test Ed25519 is not advertised by default. |
| 8435 | testCases = append(testCases, testCase{ |
| 8436 | testType: clientTest, |
| 8437 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 8438 | config: Config{ |
| 8439 | Certificates: []Certificate{ed25519Certificate}, |
| 8440 | }, |
| 8441 | shouldFail: true, |
| 8442 | expectedLocalError: "tls: no common signature algorithms", |
| 8443 | }) |
| 8444 | |
| 8445 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 8446 | // preferences. |
| 8447 | testCases = append(testCases, testCase{ |
| 8448 | testType: clientTest, |
| 8449 | name: "Ed25519DefaultDisable-NoAccept", |
| 8450 | config: Config{ |
| 8451 | Certificates: []Certificate{ed25519Certificate}, |
| 8452 | Bugs: ProtocolBugs{ |
| 8453 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8454 | }, |
| 8455 | }, |
| 8456 | shouldFail: true, |
| 8457 | expectedLocalError: "remote error: illegal parameter", |
| 8458 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8459 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 8460 | |
| 8461 | // Test that configuring verify preferences changes what the client |
| 8462 | // advertises. |
| 8463 | testCases = append(testCases, testCase{ |
| 8464 | name: "VerifyPreferences-Advertised", |
| 8465 | config: Config{ |
| 8466 | Certificates: []Certificate{rsaCertificate}, |
| 8467 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8468 | signatureRSAPSSWithSHA256, |
| 8469 | signatureRSAPSSWithSHA384, |
| 8470 | signatureRSAPSSWithSHA512, |
| 8471 | }, |
| 8472 | }, |
| 8473 | flags: []string{ |
| 8474 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8475 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8476 | }, |
| 8477 | }) |
| 8478 | |
| 8479 | // Test that the client advertises a set which the runner can find |
| 8480 | // nothing in common with. |
| 8481 | testCases = append(testCases, testCase{ |
| 8482 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 8483 | config: Config{ |
| 8484 | Certificates: []Certificate{rsaCertificate}, |
| 8485 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8486 | signatureRSAPSSWithSHA256, |
| 8487 | signatureRSAPSSWithSHA512, |
| 8488 | }, |
| 8489 | }, |
| 8490 | flags: []string{ |
| 8491 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8492 | }, |
| 8493 | shouldFail: true, |
| 8494 | expectedLocalError: "tls: no common signature algorithms", |
| 8495 | }) |
| 8496 | |
| 8497 | // Test that the client enforces its preferences when configured. |
| 8498 | testCases = append(testCases, testCase{ |
| 8499 | name: "VerifyPreferences-Enforced", |
| 8500 | config: Config{ |
| 8501 | Certificates: []Certificate{rsaCertificate}, |
| 8502 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8503 | signatureRSAPSSWithSHA256, |
| 8504 | signatureRSAPSSWithSHA512, |
| 8505 | }, |
| 8506 | Bugs: ProtocolBugs{ |
| 8507 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8508 | }, |
| 8509 | }, |
| 8510 | flags: []string{ |
| 8511 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8512 | }, |
| 8513 | shouldFail: true, |
| 8514 | expectedLocalError: "remote error: illegal parameter", |
| 8515 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8516 | }) |
| 8517 | |
| 8518 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 8519 | // boolean toggle. |
| 8520 | testCases = append(testCases, testCase{ |
| 8521 | name: "VerifyPreferences-Ed25519", |
| 8522 | config: Config{ |
| 8523 | Certificates: []Certificate{ed25519Certificate}, |
| 8524 | }, |
| 8525 | flags: []string{ |
| 8526 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 8527 | }, |
| 8528 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8529 | } |
| 8530 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8531 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 8532 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 8533 | var timeouts = []time.Duration{ |
| 8534 | 1 * time.Second, |
| 8535 | 2 * time.Second, |
| 8536 | 4 * time.Second, |
| 8537 | 8 * time.Second, |
| 8538 | 16 * time.Second, |
| 8539 | 32 * time.Second, |
| 8540 | 60 * time.Second, |
| 8541 | 60 * time.Second, |
| 8542 | 60 * time.Second, |
| 8543 | 60 * time.Second, |
| 8544 | 60 * time.Second, |
| 8545 | 60 * time.Second, |
| 8546 | 60 * time.Second, |
| 8547 | } |
| 8548 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 8549 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 8550 | // initial timeout duration was set to 250ms. |
| 8551 | var shortTimeouts = []time.Duration{ |
| 8552 | 250 * time.Millisecond, |
| 8553 | 500 * time.Millisecond, |
| 8554 | 1 * time.Second, |
| 8555 | 2 * time.Second, |
| 8556 | 4 * time.Second, |
| 8557 | 8 * time.Second, |
| 8558 | 16 * time.Second, |
| 8559 | 32 * time.Second, |
| 8560 | 60 * time.Second, |
| 8561 | 60 * time.Second, |
| 8562 | 60 * time.Second, |
| 8563 | 60 * time.Second, |
| 8564 | 60 * time.Second, |
| 8565 | } |
| 8566 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8567 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 8568 | // These tests work by coordinating some behavior on both the shim and |
| 8569 | // the runner. |
| 8570 | // |
| 8571 | // TimeoutSchedule configures the runner to send a series of timeout |
| 8572 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 8573 | // each peer handshake flight N. The timeout opcode both simulates a |
| 8574 | // timeout in the shim and acts as a synchronization point to help the |
| 8575 | // runner bracket each handshake flight. |
| 8576 | // |
| 8577 | // We assume the shim does not read from the channel eagerly. It must |
| 8578 | // first wait until it has sent flight N and is ready to receive |
| 8579 | // handshake flight N+1. At this point, it will process the timeout |
| 8580 | // opcode. It must then immediately respond with a timeout ACK and act |
| 8581 | // as if the shim was idle for the specified amount of time. |
| 8582 | // |
| 8583 | // The runner then drops all packets received before the ACK and |
| 8584 | // continues waiting for flight N. This ordering results in one attempt |
| 8585 | // at sending flight N to be dropped. For the test to complete, the |
| 8586 | // shim must send flight N again, testing that the shim implements DTLS |
| 8587 | // retransmit on a timeout. |
| 8588 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8589 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8590 | // likely be more epochs to cross and the final message's retransmit may |
| 8591 | // be more complex. |
| 8592 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8593 | // Test that this is indeed the timeout schedule. Stress all |
| 8594 | // four patterns of handshake. |
| 8595 | for i := 1; i < len(timeouts); i++ { |
| 8596 | number := strconv.Itoa(i) |
| 8597 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8598 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8599 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8600 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8601 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8602 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8603 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8604 | }, |
| 8605 | }, |
| 8606 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8607 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8608 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8609 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8610 | protocol: dtls, |
| 8611 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8612 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8613 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8614 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8615 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8616 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8617 | }, |
| 8618 | }, |
| 8619 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8620 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8621 | }) |
| 8622 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8623 | |
| 8624 | // Test that exceeding the timeout schedule hits a read |
| 8625 | // timeout. |
| 8626 | testCases = append(testCases, testCase{ |
| 8627 | protocol: dtls, |
| 8628 | name: "DTLS-Retransmit-Timeout", |
| 8629 | config: Config{ |
| 8630 | MaxVersion: VersionTLS12, |
| 8631 | Bugs: ProtocolBugs{ |
| 8632 | TimeoutSchedule: timeouts, |
| 8633 | }, |
| 8634 | }, |
| 8635 | resumeSession: true, |
| 8636 | flags: []string{"-async"}, |
| 8637 | shouldFail: true, |
| 8638 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8639 | }) |
| 8640 | |
| 8641 | // Test that timeout handling has a fudge factor, due to API |
| 8642 | // problems. |
| 8643 | testCases = append(testCases, testCase{ |
| 8644 | protocol: dtls, |
| 8645 | name: "DTLS-Retransmit-Fudge", |
| 8646 | config: Config{ |
| 8647 | MaxVersion: VersionTLS12, |
| 8648 | Bugs: ProtocolBugs{ |
| 8649 | TimeoutSchedule: []time.Duration{ |
| 8650 | timeouts[0] - 10*time.Millisecond, |
| 8651 | }, |
| 8652 | }, |
| 8653 | }, |
| 8654 | resumeSession: true, |
| 8655 | flags: []string{"-async"}, |
| 8656 | }) |
| 8657 | |
| 8658 | // Test that the final Finished retransmitting isn't |
| 8659 | // duplicated if the peer badly fragments everything. |
| 8660 | testCases = append(testCases, testCase{ |
| 8661 | testType: serverTest, |
| 8662 | protocol: dtls, |
| 8663 | name: "DTLS-Retransmit-Fragmented", |
| 8664 | config: Config{ |
| 8665 | MaxVersion: VersionTLS12, |
| 8666 | Bugs: ProtocolBugs{ |
| 8667 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8668 | MaxHandshakeRecordLength: 2, |
| 8669 | }, |
| 8670 | }, |
| 8671 | flags: []string{"-async"}, |
| 8672 | }) |
| 8673 | |
| 8674 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8675 | testCases = append(testCases, testCase{ |
| 8676 | protocol: dtls, |
| 8677 | name: "DTLS-Retransmit-Short-Client", |
| 8678 | config: Config{ |
| 8679 | MaxVersion: VersionTLS12, |
| 8680 | Bugs: ProtocolBugs{ |
| 8681 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8682 | }, |
| 8683 | }, |
| 8684 | resumeSession: true, |
| 8685 | flags: []string{ |
| 8686 | "-async", |
| 8687 | "-initial-timeout-duration-ms", "250", |
| 8688 | }, |
| 8689 | }) |
| 8690 | testCases = append(testCases, testCase{ |
| 8691 | protocol: dtls, |
| 8692 | testType: serverTest, |
| 8693 | name: "DTLS-Retransmit-Short-Server", |
| 8694 | config: Config{ |
| 8695 | MaxVersion: VersionTLS12, |
| 8696 | Bugs: ProtocolBugs{ |
| 8697 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8698 | }, |
| 8699 | }, |
| 8700 | resumeSession: true, |
| 8701 | flags: []string{ |
| 8702 | "-async", |
| 8703 | "-initial-timeout-duration-ms", "250", |
| 8704 | }, |
| 8705 | }) |
David Benjamin | 302b818 | 2017-08-22 14:47:22 -0700 | [diff] [blame] | 8706 | |
| 8707 | // If the shim sends the last Finished (server full or client resume |
| 8708 | // handshakes), it must retransmit that Finished when it sees a |
| 8709 | // post-handshake penultimate Finished from the runner. The above tests |
| 8710 | // cover this. Conversely, if the shim sends the penultimate Finished |
| 8711 | // (client full or server resume), test that it does not retransmit. |
| 8712 | testCases = append(testCases, testCase{ |
| 8713 | protocol: dtls, |
| 8714 | testType: clientTest, |
| 8715 | name: "DTLS-StrayRetransmitFinished-ClientFull", |
| 8716 | config: Config{ |
| 8717 | MaxVersion: VersionTLS12, |
| 8718 | Bugs: ProtocolBugs{ |
| 8719 | RetransmitFinished: true, |
| 8720 | }, |
| 8721 | }, |
| 8722 | }) |
| 8723 | testCases = append(testCases, testCase{ |
| 8724 | protocol: dtls, |
| 8725 | testType: serverTest, |
| 8726 | name: "DTLS-StrayRetransmitFinished-ServerResume", |
| 8727 | config: Config{ |
| 8728 | MaxVersion: VersionTLS12, |
| 8729 | }, |
| 8730 | resumeConfig: &Config{ |
| 8731 | MaxVersion: VersionTLS12, |
| 8732 | Bugs: ProtocolBugs{ |
| 8733 | RetransmitFinished: true, |
| 8734 | }, |
| 8735 | }, |
| 8736 | resumeSession: true, |
| 8737 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8738 | } |
| 8739 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8740 | func addExportKeyingMaterialTests() { |
| 8741 | for _, vers := range tlsVersions { |
| 8742 | if vers.version == VersionSSL30 { |
| 8743 | continue |
| 8744 | } |
| 8745 | testCases = append(testCases, testCase{ |
| 8746 | name: "ExportKeyingMaterial-" + vers.name, |
| 8747 | config: Config{ |
| 8748 | MaxVersion: vers.version, |
| 8749 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8750 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8751 | exportKeyingMaterial: 1024, |
| 8752 | exportLabel: "label", |
| 8753 | exportContext: "context", |
| 8754 | useExportContext: true, |
| 8755 | }) |
| 8756 | testCases = append(testCases, testCase{ |
| 8757 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8758 | config: Config{ |
| 8759 | MaxVersion: vers.version, |
| 8760 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8761 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8762 | exportKeyingMaterial: 1024, |
| 8763 | }) |
| 8764 | testCases = append(testCases, testCase{ |
| 8765 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8766 | config: Config{ |
| 8767 | MaxVersion: vers.version, |
| 8768 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8769 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8770 | exportKeyingMaterial: 1024, |
| 8771 | useExportContext: true, |
| 8772 | }) |
| 8773 | testCases = append(testCases, testCase{ |
| 8774 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8775 | config: Config{ |
| 8776 | MaxVersion: vers.version, |
| 8777 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8778 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8779 | exportKeyingMaterial: 1, |
| 8780 | exportLabel: "label", |
| 8781 | exportContext: "context", |
| 8782 | useExportContext: true, |
| 8783 | }) |
| 8784 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8785 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8786 | testCases = append(testCases, testCase{ |
| 8787 | name: "ExportKeyingMaterial-SSL3", |
| 8788 | config: Config{ |
| 8789 | MaxVersion: VersionSSL30, |
| 8790 | }, |
| 8791 | exportKeyingMaterial: 1024, |
| 8792 | exportLabel: "label", |
| 8793 | exportContext: "context", |
| 8794 | useExportContext: true, |
| 8795 | shouldFail: true, |
| 8796 | expectedError: "failed to export keying material", |
| 8797 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8798 | |
| 8799 | // Exporters work during a False Start. |
| 8800 | testCases = append(testCases, testCase{ |
| 8801 | name: "ExportKeyingMaterial-FalseStart", |
| 8802 | config: Config{ |
| 8803 | MaxVersion: VersionTLS12, |
| 8804 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8805 | NextProtos: []string{"foo"}, |
| 8806 | Bugs: ProtocolBugs{ |
| 8807 | ExpectFalseStart: true, |
| 8808 | }, |
| 8809 | }, |
| 8810 | flags: []string{ |
| 8811 | "-false-start", |
| 8812 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8813 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8814 | }, |
| 8815 | shimWritesFirst: true, |
| 8816 | exportKeyingMaterial: 1024, |
| 8817 | exportLabel: "label", |
| 8818 | exportContext: "context", |
| 8819 | useExportContext: true, |
| 8820 | }) |
| 8821 | |
| 8822 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8823 | // triggering the exporter after every SSL_read call and configuring the |
| 8824 | // shim to run asynchronously. |
| 8825 | testCases = append(testCases, testCase{ |
| 8826 | name: "ExportKeyingMaterial-Renegotiate", |
| 8827 | config: Config{ |
| 8828 | MaxVersion: VersionTLS12, |
| 8829 | }, |
| 8830 | renegotiate: 1, |
| 8831 | flags: []string{ |
| 8832 | "-async", |
| 8833 | "-use-exporter-between-reads", |
| 8834 | "-renegotiate-freely", |
| 8835 | "-expect-total-renegotiations", "1", |
| 8836 | }, |
| 8837 | shouldFail: true, |
| 8838 | expectedError: "failed to export keying material", |
| 8839 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8840 | } |
| 8841 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8842 | func addTLSUniqueTests() { |
| 8843 | for _, isClient := range []bool{false, true} { |
| 8844 | for _, isResumption := range []bool{false, true} { |
| 8845 | for _, hasEMS := range []bool{false, true} { |
| 8846 | var suffix string |
| 8847 | if isResumption { |
| 8848 | suffix = "Resume-" |
| 8849 | } else { |
| 8850 | suffix = "Full-" |
| 8851 | } |
| 8852 | |
| 8853 | if hasEMS { |
| 8854 | suffix += "EMS-" |
| 8855 | } else { |
| 8856 | suffix += "NoEMS-" |
| 8857 | } |
| 8858 | |
| 8859 | if isClient { |
| 8860 | suffix += "Client" |
| 8861 | } else { |
| 8862 | suffix += "Server" |
| 8863 | } |
| 8864 | |
| 8865 | test := testCase{ |
| 8866 | name: "TLSUnique-" + suffix, |
| 8867 | testTLSUnique: true, |
| 8868 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8869 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8870 | Bugs: ProtocolBugs{ |
| 8871 | NoExtendedMasterSecret: !hasEMS, |
| 8872 | }, |
| 8873 | }, |
| 8874 | } |
| 8875 | |
| 8876 | if isResumption { |
| 8877 | test.resumeSession = true |
| 8878 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8879 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8880 | Bugs: ProtocolBugs{ |
| 8881 | NoExtendedMasterSecret: !hasEMS, |
| 8882 | }, |
| 8883 | } |
| 8884 | } |
| 8885 | |
| 8886 | if isResumption && !hasEMS { |
| 8887 | test.shouldFail = true |
| 8888 | test.expectedError = "failed to get tls-unique" |
| 8889 | } |
| 8890 | |
| 8891 | testCases = append(testCases, test) |
| 8892 | } |
| 8893 | } |
| 8894 | } |
| 8895 | } |
| 8896 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8897 | func addCustomExtensionTests() { |
| 8898 | expectedContents := "custom extension" |
| 8899 | emptyString := "" |
| 8900 | |
| 8901 | for _, isClient := range []bool{false, true} { |
| 8902 | suffix := "Server" |
| 8903 | flag := "-enable-server-custom-extension" |
| 8904 | testType := serverTest |
| 8905 | if isClient { |
| 8906 | suffix = "Client" |
| 8907 | flag = "-enable-client-custom-extension" |
| 8908 | testType = clientTest |
| 8909 | } |
| 8910 | |
| 8911 | testCases = append(testCases, testCase{ |
| 8912 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8913 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8914 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8915 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8916 | Bugs: ProtocolBugs{ |
| 8917 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8918 | ExpectedCustomExtension: &expectedContents, |
| 8919 | }, |
| 8920 | }, |
| 8921 | flags: []string{flag}, |
| 8922 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8923 | testCases = append(testCases, testCase{ |
| 8924 | testType: testType, |
| 8925 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8926 | config: Config{ |
| 8927 | MaxVersion: VersionTLS13, |
| 8928 | Bugs: ProtocolBugs{ |
| 8929 | CustomExtension: expectedContents, |
| 8930 | ExpectedCustomExtension: &expectedContents, |
| 8931 | }, |
| 8932 | }, |
| 8933 | flags: []string{flag}, |
| 8934 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8935 | |
| 8936 | // If the parse callback fails, the handshake should also fail. |
| 8937 | testCases = append(testCases, testCase{ |
| 8938 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8939 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8940 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8941 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8942 | Bugs: ProtocolBugs{ |
| 8943 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8944 | ExpectedCustomExtension: &expectedContents, |
| 8945 | }, |
| 8946 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8947 | flags: []string{flag}, |
| 8948 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8949 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8950 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8951 | testCases = append(testCases, testCase{ |
| 8952 | testType: testType, |
| 8953 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 8954 | config: Config{ |
| 8955 | MaxVersion: VersionTLS13, |
| 8956 | Bugs: ProtocolBugs{ |
| 8957 | CustomExtension: expectedContents + "foo", |
| 8958 | ExpectedCustomExtension: &expectedContents, |
| 8959 | }, |
| 8960 | }, |
| 8961 | flags: []string{flag}, |
| 8962 | shouldFail: true, |
| 8963 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8964 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8965 | |
| 8966 | // If the add callback fails, the handshake should also fail. |
| 8967 | testCases = append(testCases, testCase{ |
| 8968 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8969 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8970 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8971 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8972 | Bugs: ProtocolBugs{ |
| 8973 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8974 | ExpectedCustomExtension: &expectedContents, |
| 8975 | }, |
| 8976 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8977 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8978 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8979 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8980 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8981 | testCases = append(testCases, testCase{ |
| 8982 | testType: testType, |
| 8983 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 8984 | config: Config{ |
| 8985 | MaxVersion: VersionTLS13, |
| 8986 | Bugs: ProtocolBugs{ |
| 8987 | CustomExtension: expectedContents, |
| 8988 | ExpectedCustomExtension: &expectedContents, |
| 8989 | }, |
| 8990 | }, |
| 8991 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8992 | shouldFail: true, |
| 8993 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8994 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8995 | |
| 8996 | // If the add callback returns zero, no extension should be |
| 8997 | // added. |
| 8998 | skipCustomExtension := expectedContents |
| 8999 | if isClient { |
| 9000 | // For the case where the client skips sending the |
| 9001 | // custom extension, the server must not “echo” it. |
| 9002 | skipCustomExtension = "" |
| 9003 | } |
| 9004 | testCases = append(testCases, testCase{ |
| 9005 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9006 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9007 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9008 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9009 | Bugs: ProtocolBugs{ |
| 9010 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9011 | ExpectedCustomExtension: &emptyString, |
| 9012 | }, |
| 9013 | }, |
| 9014 | flags: []string{flag, "-custom-extension-skip"}, |
| 9015 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9016 | testCases = append(testCases, testCase{ |
| 9017 | testType: testType, |
| 9018 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 9019 | config: Config{ |
| 9020 | MaxVersion: VersionTLS13, |
| 9021 | Bugs: ProtocolBugs{ |
| 9022 | CustomExtension: skipCustomExtension, |
| 9023 | ExpectedCustomExtension: &emptyString, |
| 9024 | }, |
| 9025 | }, |
| 9026 | flags: []string{flag, "-custom-extension-skip"}, |
| 9027 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9028 | } |
| 9029 | |
Steven Valdez | f4ecc84 | 2017-08-10 14:02:56 -0400 | [diff] [blame] | 9030 | // If the client sends both early data and custom extension, the handshake |
| 9031 | // should succeed as long as both the extensions aren't returned by the |
| 9032 | // server. |
| 9033 | testCases = append(testCases, testCase{ |
| 9034 | testType: clientTest, |
| 9035 | name: "CustomExtensions-Client-EarlyData-None", |
| 9036 | config: Config{ |
| 9037 | MaxVersion: VersionTLS13, |
| 9038 | MaxEarlyDataSize: 16384, |
| 9039 | Bugs: ProtocolBugs{ |
| 9040 | ExpectedCustomExtension: &expectedContents, |
| 9041 | AlwaysRejectEarlyData: true, |
| 9042 | }, |
| 9043 | }, |
| 9044 | resumeSession: true, |
| 9045 | flags: []string{ |
| 9046 | "-enable-client-custom-extension", |
| 9047 | "-enable-early-data", |
| 9048 | "-expect-early-data-info", |
| 9049 | "-expect-reject-early-data", |
| 9050 | }, |
| 9051 | }) |
| 9052 | |
| 9053 | testCases = append(testCases, testCase{ |
| 9054 | testType: clientTest, |
| 9055 | name: "CustomExtensions-Client-EarlyData-EarlyDataAccepted", |
| 9056 | config: Config{ |
| 9057 | MaxVersion: VersionTLS13, |
| 9058 | MaxEarlyDataSize: 16384, |
| 9059 | Bugs: ProtocolBugs{ |
| 9060 | ExpectedCustomExtension: &expectedContents, |
| 9061 | }, |
| 9062 | }, |
| 9063 | resumeSession: true, |
| 9064 | flags: []string{ |
| 9065 | "-enable-client-custom-extension", |
| 9066 | "-enable-early-data", |
| 9067 | "-expect-early-data-info", |
| 9068 | "-expect-accept-early-data", |
| 9069 | }, |
| 9070 | }) |
| 9071 | |
| 9072 | testCases = append(testCases, testCase{ |
| 9073 | testType: clientTest, |
| 9074 | name: "CustomExtensions-Client-EarlyData-CustomExtensionAccepted", |
| 9075 | config: Config{ |
| 9076 | MaxVersion: VersionTLS13, |
| 9077 | MaxEarlyDataSize: 16384, |
| 9078 | Bugs: ProtocolBugs{ |
| 9079 | AlwaysRejectEarlyData: true, |
| 9080 | CustomExtension: expectedContents, |
| 9081 | ExpectedCustomExtension: &expectedContents, |
| 9082 | }, |
| 9083 | }, |
| 9084 | resumeSession: true, |
| 9085 | flags: []string{ |
| 9086 | "-enable-client-custom-extension", |
| 9087 | "-enable-early-data", |
| 9088 | "-expect-early-data-info", |
| 9089 | "-expect-reject-early-data", |
| 9090 | }, |
| 9091 | }) |
| 9092 | |
| 9093 | testCases = append(testCases, testCase{ |
| 9094 | testType: clientTest, |
| 9095 | name: "CustomExtensions-Client-EarlyDataAndCustomExtensions", |
| 9096 | config: Config{ |
| 9097 | MaxVersion: VersionTLS13, |
| 9098 | MaxEarlyDataSize: 16384, |
| 9099 | Bugs: ProtocolBugs{ |
| 9100 | CustomExtension: expectedContents, |
| 9101 | ExpectedCustomExtension: &expectedContents, |
| 9102 | }, |
| 9103 | }, |
| 9104 | resumeConfig: &Config{ |
| 9105 | MaxVersion: VersionTLS13, |
| 9106 | MaxEarlyDataSize: 16384, |
| 9107 | Bugs: ProtocolBugs{ |
| 9108 | CustomExtension: expectedContents, |
| 9109 | ExpectedCustomExtension: &expectedContents, |
| 9110 | SendEarlyDataExtension: true, |
| 9111 | }, |
| 9112 | }, |
| 9113 | resumeSession: true, |
| 9114 | shouldFail: true, |
| 9115 | expectedError: ":UNEXPECTED_EXTENSION_ON_EARLY_DATA:", |
| 9116 | flags: []string{ |
| 9117 | "-enable-client-custom-extension", |
| 9118 | "-enable-early-data", |
| 9119 | "-expect-early-data-info", |
| 9120 | }, |
| 9121 | }) |
| 9122 | |
| 9123 | // If the server receives both early data and custom extension, only the |
| 9124 | // custom extension should be accepted. |
| 9125 | testCases = append(testCases, testCase{ |
| 9126 | testType: serverTest, |
| 9127 | name: "CustomExtensions-Server-EarlyDataAccepted", |
| 9128 | config: Config{ |
| 9129 | MaxVersion: VersionTLS13, |
| 9130 | MaxEarlyDataSize: 16384, |
| 9131 | Bugs: ProtocolBugs{ |
| 9132 | CustomExtension: expectedContents, |
| 9133 | ExpectedCustomExtension: &expectedContents, |
| 9134 | ExpectEarlyDataAccepted: false, |
| 9135 | }, |
| 9136 | }, |
| 9137 | resumeSession: true, |
| 9138 | flags: []string{ |
| 9139 | "-enable-server-custom-extension", |
| 9140 | "-enable-early-data", |
| 9141 | "-expect-early-data-info", |
| 9142 | }, |
| 9143 | }) |
| 9144 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9145 | // The custom extension add callback should not be called if the client |
| 9146 | // doesn't send the extension. |
| 9147 | testCases = append(testCases, testCase{ |
| 9148 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9149 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9150 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9151 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9152 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9153 | ExpectedCustomExtension: &emptyString, |
| 9154 | }, |
| 9155 | }, |
| 9156 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9157 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9158 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9159 | testCases = append(testCases, testCase{ |
| 9160 | testType: serverTest, |
| 9161 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 9162 | config: Config{ |
| 9163 | MaxVersion: VersionTLS13, |
| 9164 | Bugs: ProtocolBugs{ |
| 9165 | ExpectedCustomExtension: &emptyString, |
| 9166 | }, |
| 9167 | }, |
| 9168 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9169 | }) |
| 9170 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9171 | // Test an unknown extension from the server. |
| 9172 | testCases = append(testCases, testCase{ |
| 9173 | testType: clientTest, |
| 9174 | name: "UnknownExtension-Client", |
| 9175 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9176 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9177 | Bugs: ProtocolBugs{ |
| 9178 | CustomExtension: expectedContents, |
| 9179 | }, |
| 9180 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9181 | shouldFail: true, |
| 9182 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9183 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9184 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9185 | testCases = append(testCases, testCase{ |
| 9186 | testType: clientTest, |
| 9187 | name: "UnknownExtension-Client-TLS13", |
| 9188 | config: Config{ |
| 9189 | MaxVersion: VersionTLS13, |
| 9190 | Bugs: ProtocolBugs{ |
| 9191 | CustomExtension: expectedContents, |
| 9192 | }, |
| 9193 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9194 | shouldFail: true, |
| 9195 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9196 | expectedLocalError: "remote error: unsupported extension", |
| 9197 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 9198 | testCases = append(testCases, testCase{ |
| 9199 | testType: clientTest, |
| 9200 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 9201 | config: Config{ |
| 9202 | MaxVersion: VersionTLS13, |
| 9203 | Bugs: ProtocolBugs{ |
| 9204 | CustomUnencryptedExtension: expectedContents, |
| 9205 | }, |
| 9206 | }, |
| 9207 | shouldFail: true, |
| 9208 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9209 | // The shim must send an alert, but alerts at this point do not |
| 9210 | // get successfully decrypted by the runner. |
| 9211 | expectedLocalError: "local error: bad record MAC", |
| 9212 | }) |
| 9213 | testCases = append(testCases, testCase{ |
| 9214 | testType: clientTest, |
| 9215 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 9216 | config: Config{ |
| 9217 | MaxVersion: VersionTLS13, |
| 9218 | Bugs: ProtocolBugs{ |
| 9219 | SendUnencryptedALPN: "foo", |
| 9220 | }, |
| 9221 | }, |
| 9222 | flags: []string{ |
| 9223 | "-advertise-alpn", "\x03foo\x03bar", |
| 9224 | }, |
| 9225 | shouldFail: true, |
| 9226 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9227 | // The shim must send an alert, but alerts at this point do not |
| 9228 | // get successfully decrypted by the runner. |
| 9229 | expectedLocalError: "local error: bad record MAC", |
| 9230 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9231 | |
| 9232 | // Test a known but unoffered extension from the server. |
| 9233 | testCases = append(testCases, testCase{ |
| 9234 | testType: clientTest, |
| 9235 | name: "UnofferedExtension-Client", |
| 9236 | config: Config{ |
| 9237 | MaxVersion: VersionTLS12, |
| 9238 | Bugs: ProtocolBugs{ |
| 9239 | SendALPN: "alpn", |
| 9240 | }, |
| 9241 | }, |
| 9242 | shouldFail: true, |
| 9243 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9244 | expectedLocalError: "remote error: unsupported extension", |
| 9245 | }) |
| 9246 | testCases = append(testCases, testCase{ |
| 9247 | testType: clientTest, |
| 9248 | name: "UnofferedExtension-Client-TLS13", |
| 9249 | config: Config{ |
| 9250 | MaxVersion: VersionTLS13, |
| 9251 | Bugs: ProtocolBugs{ |
| 9252 | SendALPN: "alpn", |
| 9253 | }, |
| 9254 | }, |
| 9255 | shouldFail: true, |
| 9256 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9257 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9258 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9259 | } |
| 9260 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9261 | func addRSAClientKeyExchangeTests() { |
| 9262 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 9263 | testCases = append(testCases, testCase{ |
| 9264 | testType: serverTest, |
| 9265 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 9266 | config: Config{ |
| 9267 | // Ensure the ClientHello version and final |
| 9268 | // version are different, to detect if the |
| 9269 | // server uses the wrong one. |
| 9270 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 9271 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9272 | Bugs: ProtocolBugs{ |
| 9273 | BadRSAClientKeyExchange: bad, |
| 9274 | }, |
| 9275 | }, |
| 9276 | shouldFail: true, |
| 9277 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9278 | }) |
| 9279 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 9280 | |
| 9281 | // The server must compare whatever was in ClientHello.version for the |
| 9282 | // RSA premaster. |
| 9283 | testCases = append(testCases, testCase{ |
| 9284 | testType: serverTest, |
| 9285 | name: "SendClientVersion-RSA", |
| 9286 | config: Config{ |
| 9287 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 9288 | Bugs: ProtocolBugs{ |
| 9289 | SendClientVersion: 0x1234, |
| 9290 | }, |
| 9291 | }, |
| 9292 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9293 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9294 | } |
| 9295 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9296 | var testCurves = []struct { |
| 9297 | name string |
| 9298 | id CurveID |
| 9299 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 9300 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9301 | {"P-256", CurveP256}, |
| 9302 | {"P-384", CurveP384}, |
| 9303 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 9304 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9305 | } |
| 9306 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9307 | const bogusCurve = 0x1234 |
| 9308 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9309 | func addCurveTests() { |
| 9310 | for _, curve := range testCurves { |
| 9311 | testCases = append(testCases, testCase{ |
| 9312 | name: "CurveTest-Client-" + curve.name, |
| 9313 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9314 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9315 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9316 | CurvePreferences: []CurveID{curve.id}, |
| 9317 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9318 | flags: []string{ |
| 9319 | "-enable-all-curves", |
| 9320 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9321 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9322 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9323 | }) |
| 9324 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9325 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 9326 | config: Config{ |
| 9327 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9328 | CurvePreferences: []CurveID{curve.id}, |
| 9329 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9330 | flags: []string{ |
| 9331 | "-enable-all-curves", |
| 9332 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9333 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9334 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9335 | }) |
| 9336 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9337 | testType: serverTest, |
| 9338 | name: "CurveTest-Server-" + curve.name, |
| 9339 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9340 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9341 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9342 | CurvePreferences: []CurveID{curve.id}, |
| 9343 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9344 | flags: []string{ |
| 9345 | "-enable-all-curves", |
| 9346 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9347 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9348 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9349 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9350 | testCases = append(testCases, testCase{ |
| 9351 | testType: serverTest, |
| 9352 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 9353 | config: Config{ |
| 9354 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9355 | CurvePreferences: []CurveID{curve.id}, |
| 9356 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9357 | flags: []string{ |
| 9358 | "-enable-all-curves", |
| 9359 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9360 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9361 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9362 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9363 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9364 | |
| 9365 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9366 | testCases = append(testCases, testCase{ |
| 9367 | testType: serverTest, |
| 9368 | name: "UnknownCurve", |
| 9369 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9370 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9371 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9372 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9373 | }, |
| 9374 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9375 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9376 | // The server must be tolerant to bogus curves. |
| 9377 | testCases = append(testCases, testCase{ |
| 9378 | testType: serverTest, |
| 9379 | name: "UnknownCurve-TLS13", |
| 9380 | config: Config{ |
| 9381 | MaxVersion: VersionTLS13, |
| 9382 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9383 | }, |
| 9384 | }) |
| 9385 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9386 | // The server must not consider ECDHE ciphers when there are no |
| 9387 | // supported curves. |
| 9388 | testCases = append(testCases, testCase{ |
| 9389 | testType: serverTest, |
| 9390 | name: "NoSupportedCurves", |
| 9391 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9392 | MaxVersion: VersionTLS12, |
| 9393 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9394 | Bugs: ProtocolBugs{ |
| 9395 | NoSupportedCurves: true, |
| 9396 | }, |
| 9397 | }, |
| 9398 | shouldFail: true, |
| 9399 | expectedError: ":NO_SHARED_CIPHER:", |
| 9400 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9401 | testCases = append(testCases, testCase{ |
| 9402 | testType: serverTest, |
| 9403 | name: "NoSupportedCurves-TLS13", |
| 9404 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9405 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9406 | Bugs: ProtocolBugs{ |
| 9407 | NoSupportedCurves: true, |
| 9408 | }, |
| 9409 | }, |
| 9410 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9411 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9412 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9413 | |
| 9414 | // The server must fall back to another cipher when there are no |
| 9415 | // supported curves. |
| 9416 | testCases = append(testCases, testCase{ |
| 9417 | testType: serverTest, |
| 9418 | name: "NoCommonCurves", |
| 9419 | config: Config{ |
| 9420 | MaxVersion: VersionTLS12, |
| 9421 | CipherSuites: []uint16{ |
| 9422 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9423 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9424 | }, |
| 9425 | CurvePreferences: []CurveID{CurveP224}, |
| 9426 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9427 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9428 | }) |
| 9429 | |
| 9430 | // The client must reject bogus curves and disabled curves. |
| 9431 | testCases = append(testCases, testCase{ |
| 9432 | name: "BadECDHECurve", |
| 9433 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9434 | MaxVersion: VersionTLS12, |
| 9435 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9436 | Bugs: ProtocolBugs{ |
| 9437 | SendCurve: bogusCurve, |
| 9438 | }, |
| 9439 | }, |
| 9440 | shouldFail: true, |
| 9441 | expectedError: ":WRONG_CURVE:", |
| 9442 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9443 | testCases = append(testCases, testCase{ |
| 9444 | name: "BadECDHECurve-TLS13", |
| 9445 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9446 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9447 | Bugs: ProtocolBugs{ |
| 9448 | SendCurve: bogusCurve, |
| 9449 | }, |
| 9450 | }, |
| 9451 | shouldFail: true, |
| 9452 | expectedError: ":WRONG_CURVE:", |
| 9453 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9454 | |
| 9455 | testCases = append(testCases, testCase{ |
| 9456 | name: "UnsupportedCurve", |
| 9457 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9458 | MaxVersion: VersionTLS12, |
| 9459 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9460 | CurvePreferences: []CurveID{CurveP256}, |
| 9461 | Bugs: ProtocolBugs{ |
| 9462 | IgnorePeerCurvePreferences: true, |
| 9463 | }, |
| 9464 | }, |
| 9465 | flags: []string{"-p384-only"}, |
| 9466 | shouldFail: true, |
| 9467 | expectedError: ":WRONG_CURVE:", |
| 9468 | }) |
| 9469 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9470 | testCases = append(testCases, testCase{ |
| 9471 | // TODO(davidben): Add a TLS 1.3 version where |
| 9472 | // HelloRetryRequest requests an unsupported curve. |
| 9473 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 9474 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9475 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9476 | CurvePreferences: []CurveID{CurveP384}, |
| 9477 | Bugs: ProtocolBugs{ |
| 9478 | SendCurve: CurveP256, |
| 9479 | }, |
| 9480 | }, |
| 9481 | flags: []string{"-p384-only"}, |
| 9482 | shouldFail: true, |
| 9483 | expectedError: ":WRONG_CURVE:", |
| 9484 | }) |
| 9485 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9486 | // Test invalid curve points. |
| 9487 | testCases = append(testCases, testCase{ |
| 9488 | name: "InvalidECDHPoint-Client", |
| 9489 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9490 | MaxVersion: VersionTLS12, |
| 9491 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9492 | CurvePreferences: []CurveID{CurveP256}, |
| 9493 | Bugs: ProtocolBugs{ |
| 9494 | InvalidECDHPoint: true, |
| 9495 | }, |
| 9496 | }, |
| 9497 | shouldFail: true, |
| 9498 | expectedError: ":INVALID_ENCODING:", |
| 9499 | }) |
| 9500 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9501 | name: "InvalidECDHPoint-Client-TLS13", |
| 9502 | config: Config{ |
| 9503 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9504 | CurvePreferences: []CurveID{CurveP256}, |
| 9505 | Bugs: ProtocolBugs{ |
| 9506 | InvalidECDHPoint: true, |
| 9507 | }, |
| 9508 | }, |
| 9509 | shouldFail: true, |
| 9510 | expectedError: ":INVALID_ENCODING:", |
| 9511 | }) |
| 9512 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9513 | testType: serverTest, |
| 9514 | name: "InvalidECDHPoint-Server", |
| 9515 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9516 | MaxVersion: VersionTLS12, |
| 9517 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9518 | CurvePreferences: []CurveID{CurveP256}, |
| 9519 | Bugs: ProtocolBugs{ |
| 9520 | InvalidECDHPoint: true, |
| 9521 | }, |
| 9522 | }, |
| 9523 | shouldFail: true, |
| 9524 | expectedError: ":INVALID_ENCODING:", |
| 9525 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9526 | testCases = append(testCases, testCase{ |
| 9527 | testType: serverTest, |
| 9528 | name: "InvalidECDHPoint-Server-TLS13", |
| 9529 | config: Config{ |
| 9530 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9531 | CurvePreferences: []CurveID{CurveP256}, |
| 9532 | Bugs: ProtocolBugs{ |
| 9533 | InvalidECDHPoint: true, |
| 9534 | }, |
| 9535 | }, |
| 9536 | shouldFail: true, |
| 9537 | expectedError: ":INVALID_ENCODING:", |
| 9538 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9539 | |
| 9540 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 9541 | testCases = append(testCases, testCase{ |
| 9542 | name: "CurveID-Resume-Client", |
| 9543 | config: Config{ |
| 9544 | MaxVersion: VersionTLS12, |
| 9545 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9546 | CurvePreferences: []CurveID{CurveX25519}, |
| 9547 | }, |
| 9548 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9549 | resumeSession: true, |
| 9550 | }) |
| 9551 | testCases = append(testCases, testCase{ |
| 9552 | testType: serverTest, |
| 9553 | name: "CurveID-Resume-Server", |
| 9554 | config: Config{ |
| 9555 | MaxVersion: VersionTLS12, |
| 9556 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9557 | CurvePreferences: []CurveID{CurveX25519}, |
| 9558 | }, |
| 9559 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9560 | resumeSession: true, |
| 9561 | }) |
| 9562 | |
| 9563 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 9564 | // one should be reported. |
| 9565 | testCases = append(testCases, testCase{ |
| 9566 | name: "CurveID-Resume-Client-TLS13", |
| 9567 | config: Config{ |
| 9568 | MaxVersion: VersionTLS13, |
| 9569 | CurvePreferences: []CurveID{CurveX25519}, |
| 9570 | }, |
| 9571 | resumeConfig: &Config{ |
| 9572 | MaxVersion: VersionTLS13, |
| 9573 | CurvePreferences: []CurveID{CurveP256}, |
| 9574 | }, |
| 9575 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9576 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9577 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9578 | }, |
| 9579 | resumeSession: true, |
| 9580 | }) |
| 9581 | testCases = append(testCases, testCase{ |
| 9582 | testType: serverTest, |
| 9583 | name: "CurveID-Resume-Server-TLS13", |
| 9584 | config: Config{ |
| 9585 | MaxVersion: VersionTLS13, |
| 9586 | CurvePreferences: []CurveID{CurveX25519}, |
| 9587 | }, |
| 9588 | resumeConfig: &Config{ |
| 9589 | MaxVersion: VersionTLS13, |
| 9590 | CurvePreferences: []CurveID{CurveP256}, |
| 9591 | }, |
| 9592 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9593 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9594 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9595 | }, |
| 9596 | resumeSession: true, |
| 9597 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9598 | |
| 9599 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 9600 | testCases = append(testCases, testCase{ |
| 9601 | name: "PointFormat-ServerHello-TLS12", |
| 9602 | config: Config{ |
| 9603 | MaxVersion: VersionTLS12, |
| 9604 | Bugs: ProtocolBugs{ |
| 9605 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9606 | }, |
| 9607 | }, |
| 9608 | }) |
| 9609 | testCases = append(testCases, testCase{ |
| 9610 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 9611 | config: Config{ |
| 9612 | MaxVersion: VersionTLS13, |
| 9613 | Bugs: ProtocolBugs{ |
| 9614 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9615 | }, |
| 9616 | }, |
| 9617 | shouldFail: true, |
| 9618 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9619 | }) |
| 9620 | |
David Benjamin | 6c1f2b7 | 2017-10-04 17:01:22 -0400 | [diff] [blame] | 9621 | // Server-sent supported groups/curves are legal in TLS 1.3. They are |
| 9622 | // illegal in TLS 1.2, but some servers send them anyway, so we must |
| 9623 | // tolerate them. |
| 9624 | testCases = append(testCases, testCase{ |
| 9625 | name: "SupportedCurves-ServerHello-TLS12", |
| 9626 | config: Config{ |
| 9627 | MaxVersion: VersionTLS12, |
| 9628 | Bugs: ProtocolBugs{ |
| 9629 | SendServerSupportedCurves: true, |
| 9630 | }, |
| 9631 | }, |
| 9632 | }) |
| 9633 | testCases = append(testCases, testCase{ |
| 9634 | name: "SupportedCurves-EncryptedExtensions-TLS13", |
| 9635 | config: Config{ |
| 9636 | MaxVersion: VersionTLS13, |
| 9637 | Bugs: ProtocolBugs{ |
| 9638 | SendServerSupportedCurves: true, |
| 9639 | }, |
| 9640 | }, |
| 9641 | }) |
| 9642 | |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9643 | // Test that we tolerate unknown point formats, as long as |
| 9644 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 9645 | // check they are still functional. |
| 9646 | testCases = append(testCases, testCase{ |
| 9647 | name: "PointFormat-Client-Tolerance", |
| 9648 | config: Config{ |
| 9649 | MaxVersion: VersionTLS12, |
| 9650 | Bugs: ProtocolBugs{ |
| 9651 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9652 | }, |
| 9653 | }, |
| 9654 | }) |
| 9655 | testCases = append(testCases, testCase{ |
| 9656 | testType: serverTest, |
| 9657 | name: "PointFormat-Server-Tolerance", |
| 9658 | config: Config{ |
| 9659 | MaxVersion: VersionTLS12, |
| 9660 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9661 | Bugs: ProtocolBugs{ |
| 9662 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9663 | }, |
| 9664 | }, |
| 9665 | }) |
| 9666 | |
| 9667 | // Test TLS 1.2 does not require the point format extension to be |
| 9668 | // present. |
| 9669 | testCases = append(testCases, testCase{ |
| 9670 | name: "PointFormat-Client-Missing", |
| 9671 | config: Config{ |
| 9672 | MaxVersion: VersionTLS12, |
| 9673 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9674 | Bugs: ProtocolBugs{ |
| 9675 | SendSupportedPointFormats: []byte{}, |
| 9676 | }, |
| 9677 | }, |
| 9678 | }) |
| 9679 | testCases = append(testCases, testCase{ |
| 9680 | testType: serverTest, |
| 9681 | name: "PointFormat-Server-Missing", |
| 9682 | config: Config{ |
| 9683 | MaxVersion: VersionTLS12, |
| 9684 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9685 | Bugs: ProtocolBugs{ |
| 9686 | SendSupportedPointFormats: []byte{}, |
| 9687 | }, |
| 9688 | }, |
| 9689 | }) |
| 9690 | |
| 9691 | // If the point format extension is present, uncompressed points must be |
| 9692 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 9693 | testCases = append(testCases, testCase{ |
| 9694 | name: "PointFormat-Client-MissingUncompressed", |
| 9695 | config: Config{ |
| 9696 | MaxVersion: VersionTLS12, |
| 9697 | Bugs: ProtocolBugs{ |
| 9698 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9699 | }, |
| 9700 | }, |
| 9701 | shouldFail: true, |
| 9702 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9703 | }) |
| 9704 | testCases = append(testCases, testCase{ |
| 9705 | testType: serverTest, |
| 9706 | name: "PointFormat-Server-MissingUncompressed", |
| 9707 | config: Config{ |
| 9708 | MaxVersion: VersionTLS12, |
| 9709 | Bugs: ProtocolBugs{ |
| 9710 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9711 | }, |
| 9712 | }, |
| 9713 | shouldFail: true, |
| 9714 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9715 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9716 | } |
| 9717 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9718 | func addTLS13RecordTests() { |
| 9719 | testCases = append(testCases, testCase{ |
| 9720 | name: "TLS13-RecordPadding", |
| 9721 | config: Config{ |
| 9722 | MaxVersion: VersionTLS13, |
| 9723 | MinVersion: VersionTLS13, |
| 9724 | Bugs: ProtocolBugs{ |
| 9725 | RecordPadding: 10, |
| 9726 | }, |
| 9727 | }, |
| 9728 | }) |
| 9729 | |
| 9730 | testCases = append(testCases, testCase{ |
| 9731 | name: "TLS13-EmptyRecords", |
| 9732 | config: Config{ |
| 9733 | MaxVersion: VersionTLS13, |
| 9734 | MinVersion: VersionTLS13, |
| 9735 | Bugs: ProtocolBugs{ |
| 9736 | OmitRecordContents: true, |
| 9737 | }, |
| 9738 | }, |
| 9739 | shouldFail: true, |
| 9740 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9741 | }) |
| 9742 | |
| 9743 | testCases = append(testCases, testCase{ |
| 9744 | name: "TLS13-OnlyPadding", |
| 9745 | config: Config{ |
| 9746 | MaxVersion: VersionTLS13, |
| 9747 | MinVersion: VersionTLS13, |
| 9748 | Bugs: ProtocolBugs{ |
| 9749 | OmitRecordContents: true, |
| 9750 | RecordPadding: 10, |
| 9751 | }, |
| 9752 | }, |
| 9753 | shouldFail: true, |
| 9754 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9755 | }) |
| 9756 | |
| 9757 | testCases = append(testCases, testCase{ |
| 9758 | name: "TLS13-WrongOuterRecord", |
| 9759 | config: Config{ |
| 9760 | MaxVersion: VersionTLS13, |
| 9761 | MinVersion: VersionTLS13, |
| 9762 | Bugs: ProtocolBugs{ |
| 9763 | OuterRecordType: recordTypeHandshake, |
| 9764 | }, |
| 9765 | }, |
| 9766 | shouldFail: true, |
| 9767 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 9768 | }) |
| 9769 | } |
| 9770 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9771 | func addSessionTicketTests() { |
| 9772 | testCases = append(testCases, testCase{ |
| 9773 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 9774 | // mean the server changed its mind on sending a ticket. |
| 9775 | name: "SendEmptySessionTicket", |
| 9776 | config: Config{ |
| 9777 | MaxVersion: VersionTLS12, |
| 9778 | Bugs: ProtocolBugs{ |
| 9779 | SendEmptySessionTicket: true, |
| 9780 | }, |
| 9781 | }, |
| 9782 | flags: []string{"-expect-no-session"}, |
| 9783 | }) |
| 9784 | |
| 9785 | // Test that the server ignores unknown PSK modes. |
| 9786 | testCases = append(testCases, testCase{ |
| 9787 | testType: serverTest, |
| 9788 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9789 | config: Config{ |
| 9790 | MaxVersion: VersionTLS13, |
| 9791 | Bugs: ProtocolBugs{ |
| 9792 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9793 | }, |
| 9794 | }, |
| 9795 | resumeSession: true, |
| 9796 | expectedResumeVersion: VersionTLS13, |
| 9797 | }) |
| 9798 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9799 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9800 | testCases = append(testCases, testCase{ |
| 9801 | testType: serverTest, |
| 9802 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9803 | config: Config{ |
| 9804 | MaxVersion: VersionTLS13, |
| 9805 | Bugs: ProtocolBugs{ |
| 9806 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9807 | ExpectNoNewSessionTicket: true, |
| 9808 | }, |
| 9809 | }, |
| 9810 | }) |
| 9811 | |
| 9812 | // 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] | 9813 | testCases = append(testCases, testCase{ |
| 9814 | testType: serverTest, |
| 9815 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9816 | config: Config{ |
| 9817 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9818 | }, |
| 9819 | resumeConfig: &Config{ |
| 9820 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9821 | Bugs: ProtocolBugs{ |
| 9822 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9823 | }, |
| 9824 | }, |
| 9825 | resumeSession: true, |
| 9826 | expectResumeRejected: true, |
| 9827 | }) |
| 9828 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9829 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9830 | testCases = append(testCases, testCase{ |
| 9831 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9832 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9833 | config: Config{ |
| 9834 | MaxVersion: VersionTLS13, |
| 9835 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9836 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9837 | }, |
| 9838 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9839 | resumeSession: true, |
| 9840 | flags: []string{ |
| 9841 | "-resumption-delay", "10", |
| 9842 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9843 | }) |
| 9844 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9845 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9846 | testCases = append(testCases, testCase{ |
| 9847 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9848 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9849 | config: Config{ |
| 9850 | MaxVersion: VersionTLS13, |
| 9851 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9852 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9853 | }, |
| 9854 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9855 | resumeSession: true, |
| 9856 | shouldFail: true, |
| 9857 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9858 | }) |
| 9859 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9860 | // Test that the server's ticket age skew reporting works. |
| 9861 | testCases = append(testCases, testCase{ |
| 9862 | testType: serverTest, |
| 9863 | name: "TLS13-TicketAgeSkew-Forward", |
| 9864 | config: Config{ |
| 9865 | MaxVersion: VersionTLS13, |
| 9866 | Bugs: ProtocolBugs{ |
| 9867 | SendTicketAge: 15 * time.Second, |
| 9868 | }, |
| 9869 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9870 | resumeSession: true, |
| 9871 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9872 | flags: []string{ |
| 9873 | "-resumption-delay", "10", |
| 9874 | "-expect-ticket-age-skew", "5", |
| 9875 | }, |
| 9876 | }) |
| 9877 | testCases = append(testCases, testCase{ |
| 9878 | testType: serverTest, |
| 9879 | name: "TLS13-TicketAgeSkew-Backward", |
| 9880 | config: Config{ |
| 9881 | MaxVersion: VersionTLS13, |
| 9882 | Bugs: ProtocolBugs{ |
| 9883 | SendTicketAge: 5 * time.Second, |
| 9884 | }, |
| 9885 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9886 | resumeSession: true, |
| 9887 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9888 | flags: []string{ |
| 9889 | "-resumption-delay", "10", |
| 9890 | "-expect-ticket-age-skew", "-5", |
| 9891 | }, |
| 9892 | }) |
| 9893 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9894 | testCases = append(testCases, testCase{ |
| 9895 | testType: clientTest, |
| 9896 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9897 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9898 | MaxVersion: VersionTLS13, |
| 9899 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9900 | }, |
| 9901 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9902 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9903 | "-expect-early-data-info", |
| 9904 | }, |
| 9905 | }) |
| 9906 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9907 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9908 | testCases = append(testCases, testCase{ |
| 9909 | testType: clientTest, |
| 9910 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9911 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9912 | MaxVersion: VersionTLS13, |
| 9913 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9914 | }, |
| 9915 | }) |
| 9916 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9917 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9918 | testType: clientTest, |
| 9919 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9920 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9921 | MaxVersion: VersionTLS13, |
| 9922 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9923 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9924 | DuplicateTicketEarlyDataInfo: true, |
| 9925 | }, |
| 9926 | }, |
| 9927 | shouldFail: true, |
| 9928 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9929 | expectedLocalError: "remote error: illegal parameter", |
| 9930 | }) |
| 9931 | |
| 9932 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9933 | testType: serverTest, |
| 9934 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9935 | config: Config{ |
| 9936 | MaxVersion: VersionTLS13, |
| 9937 | Bugs: ProtocolBugs{ |
| 9938 | ExpectTicketEarlyDataInfo: true, |
| 9939 | }, |
| 9940 | }, |
| 9941 | flags: []string{ |
| 9942 | "-enable-early-data", |
| 9943 | }, |
| 9944 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9945 | |
| 9946 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9947 | // is honored. |
| 9948 | testCases = append(testCases, testCase{ |
| 9949 | testType: clientTest, |
| 9950 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9951 | config: Config{ |
| 9952 | MaxVersion: VersionTLS13, |
| 9953 | Bugs: ProtocolBugs{ |
| 9954 | SendTicketLifetime: 20 * time.Second, |
| 9955 | }, |
| 9956 | }, |
| 9957 | flags: []string{ |
| 9958 | "-resumption-delay", "19", |
| 9959 | }, |
| 9960 | resumeSession: true, |
| 9961 | }) |
| 9962 | testCases = append(testCases, testCase{ |
| 9963 | testType: clientTest, |
| 9964 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9965 | config: Config{ |
| 9966 | MaxVersion: VersionTLS13, |
| 9967 | Bugs: ProtocolBugs{ |
| 9968 | SendTicketLifetime: 20 * time.Second, |
| 9969 | // The client should not offer the expired session. |
| 9970 | ExpectNoTLS13PSK: true, |
| 9971 | }, |
| 9972 | }, |
| 9973 | flags: []string{ |
| 9974 | "-resumption-delay", "21", |
| 9975 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 9976 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9977 | expectResumeRejected: true, |
| 9978 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9979 | } |
| 9980 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9981 | func addChangeCipherSpecTests() { |
| 9982 | // Test missing ChangeCipherSpecs. |
| 9983 | testCases = append(testCases, testCase{ |
| 9984 | name: "SkipChangeCipherSpec-Client", |
| 9985 | config: Config{ |
| 9986 | MaxVersion: VersionTLS12, |
| 9987 | Bugs: ProtocolBugs{ |
| 9988 | SkipChangeCipherSpec: true, |
| 9989 | }, |
| 9990 | }, |
| 9991 | shouldFail: true, |
| 9992 | expectedError: ":UNEXPECTED_RECORD:", |
| 9993 | }) |
| 9994 | testCases = append(testCases, testCase{ |
| 9995 | testType: serverTest, |
| 9996 | name: "SkipChangeCipherSpec-Server", |
| 9997 | config: Config{ |
| 9998 | MaxVersion: VersionTLS12, |
| 9999 | Bugs: ProtocolBugs{ |
| 10000 | SkipChangeCipherSpec: true, |
| 10001 | }, |
| 10002 | }, |
| 10003 | shouldFail: true, |
| 10004 | expectedError: ":UNEXPECTED_RECORD:", |
| 10005 | }) |
| 10006 | testCases = append(testCases, testCase{ |
| 10007 | testType: serverTest, |
| 10008 | name: "SkipChangeCipherSpec-Server-NPN", |
| 10009 | config: Config{ |
| 10010 | MaxVersion: VersionTLS12, |
| 10011 | NextProtos: []string{"bar"}, |
| 10012 | Bugs: ProtocolBugs{ |
| 10013 | SkipChangeCipherSpec: true, |
| 10014 | }, |
| 10015 | }, |
| 10016 | flags: []string{ |
| 10017 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 10018 | }, |
| 10019 | shouldFail: true, |
| 10020 | expectedError: ":UNEXPECTED_RECORD:", |
| 10021 | }) |
| 10022 | |
| 10023 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 10024 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 10025 | // rejected. Test both with and without handshake packing to handle both |
| 10026 | // when the partial post-CCS message is in its own record and when it is |
| 10027 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10028 | for _, packed := range []bool{false, true} { |
| 10029 | var suffix string |
| 10030 | if packed { |
| 10031 | suffix = "-Packed" |
| 10032 | } |
| 10033 | |
| 10034 | testCases = append(testCases, testCase{ |
| 10035 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 10036 | config: Config{ |
| 10037 | MaxVersion: VersionTLS12, |
| 10038 | Bugs: ProtocolBugs{ |
| 10039 | FragmentAcrossChangeCipherSpec: true, |
| 10040 | PackHandshakeFlight: packed, |
| 10041 | }, |
| 10042 | }, |
| 10043 | shouldFail: true, |
| 10044 | expectedError: ":UNEXPECTED_RECORD:", |
| 10045 | }) |
| 10046 | testCases = append(testCases, testCase{ |
| 10047 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 10048 | config: Config{ |
| 10049 | MaxVersion: VersionTLS12, |
| 10050 | }, |
| 10051 | resumeSession: true, |
| 10052 | resumeConfig: &Config{ |
| 10053 | MaxVersion: VersionTLS12, |
| 10054 | Bugs: ProtocolBugs{ |
| 10055 | FragmentAcrossChangeCipherSpec: true, |
| 10056 | PackHandshakeFlight: packed, |
| 10057 | }, |
| 10058 | }, |
| 10059 | shouldFail: true, |
| 10060 | expectedError: ":UNEXPECTED_RECORD:", |
| 10061 | }) |
| 10062 | testCases = append(testCases, testCase{ |
| 10063 | testType: serverTest, |
| 10064 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 10065 | config: Config{ |
| 10066 | MaxVersion: VersionTLS12, |
| 10067 | Bugs: ProtocolBugs{ |
| 10068 | FragmentAcrossChangeCipherSpec: true, |
| 10069 | PackHandshakeFlight: packed, |
| 10070 | }, |
| 10071 | }, |
| 10072 | shouldFail: true, |
| 10073 | expectedError: ":UNEXPECTED_RECORD:", |
| 10074 | }) |
| 10075 | testCases = append(testCases, testCase{ |
| 10076 | testType: serverTest, |
| 10077 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 10078 | config: Config{ |
| 10079 | MaxVersion: VersionTLS12, |
| 10080 | }, |
| 10081 | resumeSession: true, |
| 10082 | resumeConfig: &Config{ |
| 10083 | MaxVersion: VersionTLS12, |
| 10084 | Bugs: ProtocolBugs{ |
| 10085 | FragmentAcrossChangeCipherSpec: true, |
| 10086 | PackHandshakeFlight: packed, |
| 10087 | }, |
| 10088 | }, |
| 10089 | shouldFail: true, |
| 10090 | expectedError: ":UNEXPECTED_RECORD:", |
| 10091 | }) |
| 10092 | testCases = append(testCases, testCase{ |
| 10093 | testType: serverTest, |
| 10094 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 10095 | config: Config{ |
| 10096 | MaxVersion: VersionTLS12, |
| 10097 | NextProtos: []string{"bar"}, |
| 10098 | Bugs: ProtocolBugs{ |
| 10099 | FragmentAcrossChangeCipherSpec: true, |
| 10100 | PackHandshakeFlight: packed, |
| 10101 | }, |
| 10102 | }, |
| 10103 | flags: []string{ |
| 10104 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 10105 | }, |
| 10106 | shouldFail: true, |
| 10107 | expectedError: ":UNEXPECTED_RECORD:", |
| 10108 | }) |
| 10109 | } |
| 10110 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 10111 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 10112 | // messages in the handshake queue. Do this by testing the server |
| 10113 | // reading the client Finished, reversing the flight so Finished comes |
| 10114 | // first. |
| 10115 | testCases = append(testCases, testCase{ |
| 10116 | protocol: dtls, |
| 10117 | testType: serverTest, |
| 10118 | name: "SendUnencryptedFinished-DTLS", |
| 10119 | config: Config{ |
| 10120 | MaxVersion: VersionTLS12, |
| 10121 | Bugs: ProtocolBugs{ |
| 10122 | SendUnencryptedFinished: true, |
| 10123 | ReverseHandshakeFragments: true, |
| 10124 | }, |
| 10125 | }, |
| 10126 | shouldFail: true, |
| 10127 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10128 | }) |
| 10129 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10130 | // Test synchronization between encryption changes and the handshake in |
| 10131 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 10132 | testCases = append(testCases, testCase{ |
| 10133 | name: "PartialEncryptedExtensionsWithServerHello", |
| 10134 | config: Config{ |
| 10135 | MaxVersion: VersionTLS13, |
| 10136 | Bugs: ProtocolBugs{ |
| 10137 | PartialEncryptedExtensionsWithServerHello: true, |
| 10138 | }, |
| 10139 | }, |
| 10140 | shouldFail: true, |
| 10141 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10142 | }) |
| 10143 | testCases = append(testCases, testCase{ |
| 10144 | testType: serverTest, |
| 10145 | name: "PartialClientFinishedWithClientHello", |
| 10146 | config: Config{ |
| 10147 | MaxVersion: VersionTLS13, |
| 10148 | Bugs: ProtocolBugs{ |
| 10149 | PartialClientFinishedWithClientHello: true, |
| 10150 | }, |
| 10151 | }, |
| 10152 | shouldFail: true, |
| 10153 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10154 | }) |
| 10155 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10156 | // Test that early ChangeCipherSpecs are handled correctly. |
| 10157 | testCases = append(testCases, testCase{ |
| 10158 | testType: serverTest, |
| 10159 | name: "EarlyChangeCipherSpec-server-1", |
| 10160 | config: Config{ |
| 10161 | MaxVersion: VersionTLS12, |
| 10162 | Bugs: ProtocolBugs{ |
| 10163 | EarlyChangeCipherSpec: 1, |
| 10164 | }, |
| 10165 | }, |
| 10166 | shouldFail: true, |
| 10167 | expectedError: ":UNEXPECTED_RECORD:", |
| 10168 | }) |
| 10169 | testCases = append(testCases, testCase{ |
| 10170 | testType: serverTest, |
| 10171 | name: "EarlyChangeCipherSpec-server-2", |
| 10172 | config: Config{ |
| 10173 | MaxVersion: VersionTLS12, |
| 10174 | Bugs: ProtocolBugs{ |
| 10175 | EarlyChangeCipherSpec: 2, |
| 10176 | }, |
| 10177 | }, |
| 10178 | shouldFail: true, |
| 10179 | expectedError: ":UNEXPECTED_RECORD:", |
| 10180 | }) |
| 10181 | testCases = append(testCases, testCase{ |
| 10182 | protocol: dtls, |
| 10183 | name: "StrayChangeCipherSpec", |
| 10184 | config: Config{ |
| 10185 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 10186 | // that stray ChangeCipherSpec messages are |
| 10187 | // rejected. |
| 10188 | MaxVersion: VersionTLS12, |
| 10189 | Bugs: ProtocolBugs{ |
| 10190 | StrayChangeCipherSpec: true, |
| 10191 | }, |
| 10192 | }, |
| 10193 | }) |
| 10194 | |
David Benjamin | b0c761e | 2017-06-25 22:42:55 -0400 | [diff] [blame] | 10195 | // Test that reordered ChangeCipherSpecs are tolerated. |
| 10196 | testCases = append(testCases, testCase{ |
| 10197 | protocol: dtls, |
| 10198 | name: "ReorderChangeCipherSpec-DTLS-Client", |
| 10199 | config: Config{ |
| 10200 | MaxVersion: VersionTLS12, |
| 10201 | Bugs: ProtocolBugs{ |
| 10202 | ReorderChangeCipherSpec: true, |
| 10203 | }, |
| 10204 | }, |
| 10205 | resumeSession: true, |
| 10206 | }) |
| 10207 | testCases = append(testCases, testCase{ |
| 10208 | testType: serverTest, |
| 10209 | protocol: dtls, |
| 10210 | name: "ReorderChangeCipherSpec-DTLS-Server", |
| 10211 | config: Config{ |
| 10212 | MaxVersion: VersionTLS12, |
| 10213 | Bugs: ProtocolBugs{ |
| 10214 | ReorderChangeCipherSpec: true, |
| 10215 | }, |
| 10216 | }, |
| 10217 | resumeSession: true, |
| 10218 | }) |
| 10219 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10220 | // Test that the contents of ChangeCipherSpec are checked. |
| 10221 | testCases = append(testCases, testCase{ |
| 10222 | name: "BadChangeCipherSpec-1", |
| 10223 | config: Config{ |
| 10224 | MaxVersion: VersionTLS12, |
| 10225 | Bugs: ProtocolBugs{ |
| 10226 | BadChangeCipherSpec: []byte{2}, |
| 10227 | }, |
| 10228 | }, |
| 10229 | shouldFail: true, |
| 10230 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10231 | }) |
| 10232 | testCases = append(testCases, testCase{ |
| 10233 | name: "BadChangeCipherSpec-2", |
| 10234 | config: Config{ |
| 10235 | MaxVersion: VersionTLS12, |
| 10236 | Bugs: ProtocolBugs{ |
| 10237 | BadChangeCipherSpec: []byte{1, 1}, |
| 10238 | }, |
| 10239 | }, |
| 10240 | shouldFail: true, |
| 10241 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10242 | }) |
| 10243 | testCases = append(testCases, testCase{ |
| 10244 | protocol: dtls, |
| 10245 | name: "BadChangeCipherSpec-DTLS-1", |
| 10246 | config: Config{ |
| 10247 | MaxVersion: VersionTLS12, |
| 10248 | Bugs: ProtocolBugs{ |
| 10249 | BadChangeCipherSpec: []byte{2}, |
| 10250 | }, |
| 10251 | }, |
| 10252 | shouldFail: true, |
| 10253 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10254 | }) |
| 10255 | testCases = append(testCases, testCase{ |
| 10256 | protocol: dtls, |
| 10257 | name: "BadChangeCipherSpec-DTLS-2", |
| 10258 | config: Config{ |
| 10259 | MaxVersion: VersionTLS12, |
| 10260 | Bugs: ProtocolBugs{ |
| 10261 | BadChangeCipherSpec: []byte{1, 1}, |
| 10262 | }, |
| 10263 | }, |
| 10264 | shouldFail: true, |
| 10265 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10266 | }) |
| 10267 | } |
| 10268 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10269 | type perMessageTest struct { |
| 10270 | messageType uint8 |
| 10271 | test testCase |
| 10272 | } |
| 10273 | |
| 10274 | // makePerMessageTests returns a series of test templates which cover each |
| 10275 | // message in the TLS handshake. These may be used with bugs like |
| 10276 | // WrongMessageType to fully test a per-message bug. |
| 10277 | func makePerMessageTests() []perMessageTest { |
| 10278 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10279 | for _, protocol := range []protocol{tls, dtls} { |
| 10280 | var suffix string |
| 10281 | if protocol == dtls { |
| 10282 | suffix = "-DTLS" |
| 10283 | } |
| 10284 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10285 | ret = append(ret, perMessageTest{ |
| 10286 | messageType: typeClientHello, |
| 10287 | test: testCase{ |
| 10288 | protocol: protocol, |
| 10289 | testType: serverTest, |
| 10290 | name: "ClientHello" + suffix, |
| 10291 | config: Config{ |
| 10292 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10293 | }, |
| 10294 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10295 | }) |
| 10296 | |
| 10297 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10298 | ret = append(ret, perMessageTest{ |
| 10299 | messageType: typeHelloVerifyRequest, |
| 10300 | test: testCase{ |
| 10301 | protocol: protocol, |
| 10302 | name: "HelloVerifyRequest" + suffix, |
| 10303 | config: Config{ |
| 10304 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10305 | }, |
| 10306 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10307 | }) |
| 10308 | } |
| 10309 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10310 | ret = append(ret, perMessageTest{ |
| 10311 | messageType: typeServerHello, |
| 10312 | test: testCase{ |
| 10313 | protocol: protocol, |
| 10314 | name: "ServerHello" + suffix, |
| 10315 | config: Config{ |
| 10316 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10317 | }, |
| 10318 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10319 | }) |
| 10320 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10321 | ret = append(ret, perMessageTest{ |
| 10322 | messageType: typeCertificate, |
| 10323 | test: testCase{ |
| 10324 | protocol: protocol, |
| 10325 | name: "ServerCertificate" + suffix, |
| 10326 | config: Config{ |
| 10327 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10328 | }, |
| 10329 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10330 | }) |
| 10331 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10332 | ret = append(ret, perMessageTest{ |
| 10333 | messageType: typeCertificateStatus, |
| 10334 | test: testCase{ |
| 10335 | protocol: protocol, |
| 10336 | name: "CertificateStatus" + suffix, |
| 10337 | config: Config{ |
| 10338 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10339 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10340 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10341 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10342 | }) |
| 10343 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10344 | ret = append(ret, perMessageTest{ |
| 10345 | messageType: typeServerKeyExchange, |
| 10346 | test: testCase{ |
| 10347 | protocol: protocol, |
| 10348 | name: "ServerKeyExchange" + suffix, |
| 10349 | config: Config{ |
| 10350 | MaxVersion: VersionTLS12, |
| 10351 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10352 | }, |
| 10353 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10354 | }) |
| 10355 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10356 | ret = append(ret, perMessageTest{ |
| 10357 | messageType: typeCertificateRequest, |
| 10358 | test: testCase{ |
| 10359 | protocol: protocol, |
| 10360 | name: "CertificateRequest" + suffix, |
| 10361 | config: Config{ |
| 10362 | MaxVersion: VersionTLS12, |
| 10363 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10364 | }, |
| 10365 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10366 | }) |
| 10367 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10368 | ret = append(ret, perMessageTest{ |
| 10369 | messageType: typeServerHelloDone, |
| 10370 | test: testCase{ |
| 10371 | protocol: protocol, |
| 10372 | name: "ServerHelloDone" + suffix, |
| 10373 | config: Config{ |
| 10374 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10375 | }, |
| 10376 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10377 | }) |
| 10378 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10379 | ret = append(ret, perMessageTest{ |
| 10380 | messageType: typeCertificate, |
| 10381 | test: testCase{ |
| 10382 | testType: serverTest, |
| 10383 | protocol: protocol, |
| 10384 | name: "ClientCertificate" + suffix, |
| 10385 | config: Config{ |
| 10386 | Certificates: []Certificate{rsaCertificate}, |
| 10387 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10388 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10389 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10390 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10391 | }) |
| 10392 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10393 | ret = append(ret, perMessageTest{ |
| 10394 | messageType: typeCertificateVerify, |
| 10395 | test: testCase{ |
| 10396 | testType: serverTest, |
| 10397 | protocol: protocol, |
| 10398 | name: "CertificateVerify" + suffix, |
| 10399 | config: Config{ |
| 10400 | Certificates: []Certificate{rsaCertificate}, |
| 10401 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10402 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10403 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10404 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10405 | }) |
| 10406 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10407 | ret = append(ret, perMessageTest{ |
| 10408 | messageType: typeClientKeyExchange, |
| 10409 | test: testCase{ |
| 10410 | testType: serverTest, |
| 10411 | protocol: protocol, |
| 10412 | name: "ClientKeyExchange" + suffix, |
| 10413 | config: Config{ |
| 10414 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10415 | }, |
| 10416 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10417 | }) |
| 10418 | |
| 10419 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10420 | ret = append(ret, perMessageTest{ |
| 10421 | messageType: typeNextProtocol, |
| 10422 | test: testCase{ |
| 10423 | testType: serverTest, |
| 10424 | protocol: protocol, |
| 10425 | name: "NextProtocol" + suffix, |
| 10426 | config: Config{ |
| 10427 | MaxVersion: VersionTLS12, |
| 10428 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10429 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10430 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10431 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10432 | }) |
| 10433 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10434 | ret = append(ret, perMessageTest{ |
| 10435 | messageType: typeChannelID, |
| 10436 | test: testCase{ |
| 10437 | testType: serverTest, |
| 10438 | protocol: protocol, |
| 10439 | name: "ChannelID" + suffix, |
| 10440 | config: Config{ |
| 10441 | MaxVersion: VersionTLS12, |
| 10442 | ChannelID: channelIDKey, |
| 10443 | }, |
| 10444 | flags: []string{ |
| 10445 | "-expect-channel-id", |
| 10446 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10447 | }, |
| 10448 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10449 | }) |
| 10450 | } |
| 10451 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10452 | ret = append(ret, perMessageTest{ |
| 10453 | messageType: typeFinished, |
| 10454 | test: testCase{ |
| 10455 | testType: serverTest, |
| 10456 | protocol: protocol, |
| 10457 | name: "ClientFinished" + suffix, |
| 10458 | config: Config{ |
| 10459 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10460 | }, |
| 10461 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10462 | }) |
| 10463 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10464 | ret = append(ret, perMessageTest{ |
| 10465 | messageType: typeNewSessionTicket, |
| 10466 | test: testCase{ |
| 10467 | protocol: protocol, |
| 10468 | name: "NewSessionTicket" + suffix, |
| 10469 | config: Config{ |
| 10470 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10471 | }, |
| 10472 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10473 | }) |
| 10474 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10475 | ret = append(ret, perMessageTest{ |
| 10476 | messageType: typeFinished, |
| 10477 | test: testCase{ |
| 10478 | protocol: protocol, |
| 10479 | name: "ServerFinished" + suffix, |
| 10480 | config: Config{ |
| 10481 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10482 | }, |
| 10483 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10484 | }) |
| 10485 | |
| 10486 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10487 | |
| 10488 | ret = append(ret, perMessageTest{ |
| 10489 | messageType: typeClientHello, |
| 10490 | test: testCase{ |
| 10491 | testType: serverTest, |
| 10492 | name: "TLS13-ClientHello", |
| 10493 | config: Config{ |
| 10494 | MaxVersion: VersionTLS13, |
| 10495 | }, |
| 10496 | }, |
| 10497 | }) |
| 10498 | |
| 10499 | ret = append(ret, perMessageTest{ |
| 10500 | messageType: typeServerHello, |
| 10501 | test: testCase{ |
| 10502 | name: "TLS13-ServerHello", |
| 10503 | config: Config{ |
| 10504 | MaxVersion: VersionTLS13, |
| 10505 | }, |
| 10506 | }, |
| 10507 | }) |
| 10508 | |
| 10509 | ret = append(ret, perMessageTest{ |
| 10510 | messageType: typeEncryptedExtensions, |
| 10511 | test: testCase{ |
| 10512 | name: "TLS13-EncryptedExtensions", |
| 10513 | config: Config{ |
| 10514 | MaxVersion: VersionTLS13, |
| 10515 | }, |
| 10516 | }, |
| 10517 | }) |
| 10518 | |
| 10519 | ret = append(ret, perMessageTest{ |
| 10520 | messageType: typeCertificateRequest, |
| 10521 | test: testCase{ |
| 10522 | name: "TLS13-CertificateRequest", |
| 10523 | config: Config{ |
| 10524 | MaxVersion: VersionTLS13, |
| 10525 | ClientAuth: RequireAnyClientCert, |
| 10526 | }, |
| 10527 | }, |
| 10528 | }) |
| 10529 | |
| 10530 | ret = append(ret, perMessageTest{ |
| 10531 | messageType: typeCertificate, |
| 10532 | test: testCase{ |
| 10533 | name: "TLS13-ServerCertificate", |
| 10534 | config: Config{ |
| 10535 | MaxVersion: VersionTLS13, |
| 10536 | }, |
| 10537 | }, |
| 10538 | }) |
| 10539 | |
| 10540 | ret = append(ret, perMessageTest{ |
| 10541 | messageType: typeCertificateVerify, |
| 10542 | test: testCase{ |
| 10543 | name: "TLS13-ServerCertificateVerify", |
| 10544 | config: Config{ |
| 10545 | MaxVersion: VersionTLS13, |
| 10546 | }, |
| 10547 | }, |
| 10548 | }) |
| 10549 | |
| 10550 | ret = append(ret, perMessageTest{ |
| 10551 | messageType: typeFinished, |
| 10552 | test: testCase{ |
| 10553 | name: "TLS13-ServerFinished", |
| 10554 | config: Config{ |
| 10555 | MaxVersion: VersionTLS13, |
| 10556 | }, |
| 10557 | }, |
| 10558 | }) |
| 10559 | |
| 10560 | ret = append(ret, perMessageTest{ |
| 10561 | messageType: typeCertificate, |
| 10562 | test: testCase{ |
| 10563 | testType: serverTest, |
| 10564 | name: "TLS13-ClientCertificate", |
| 10565 | config: Config{ |
| 10566 | Certificates: []Certificate{rsaCertificate}, |
| 10567 | MaxVersion: VersionTLS13, |
| 10568 | }, |
| 10569 | flags: []string{"-require-any-client-certificate"}, |
| 10570 | }, |
| 10571 | }) |
| 10572 | |
| 10573 | ret = append(ret, perMessageTest{ |
| 10574 | messageType: typeCertificateVerify, |
| 10575 | test: testCase{ |
| 10576 | testType: serverTest, |
| 10577 | name: "TLS13-ClientCertificateVerify", |
| 10578 | config: Config{ |
| 10579 | Certificates: []Certificate{rsaCertificate}, |
| 10580 | MaxVersion: VersionTLS13, |
| 10581 | }, |
| 10582 | flags: []string{"-require-any-client-certificate"}, |
| 10583 | }, |
| 10584 | }) |
| 10585 | |
| 10586 | ret = append(ret, perMessageTest{ |
| 10587 | messageType: typeFinished, |
| 10588 | test: testCase{ |
| 10589 | testType: serverTest, |
| 10590 | name: "TLS13-ClientFinished", |
| 10591 | config: Config{ |
| 10592 | MaxVersion: VersionTLS13, |
| 10593 | }, |
| 10594 | }, |
| 10595 | }) |
| 10596 | |
| 10597 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10598 | } |
| 10599 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10600 | func addWrongMessageTypeTests() { |
| 10601 | for _, t := range makePerMessageTests() { |
| 10602 | t.test.name = "WrongMessageType-" + t.test.name |
| 10603 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 10604 | t.test.shouldFail = true |
| 10605 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 10606 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10607 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10608 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10609 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10610 | // an unencrypted alert while the server expects |
| 10611 | // encryption, so the alert is not readable by runner. |
| 10612 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10613 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10614 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10615 | testCases = append(testCases, t.test) |
| 10616 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 10617 | |
| 10618 | // The processing order for TLS 1.3 version negotiation is such that one |
| 10619 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 10620 | // TLS 1.2. Test that we do not do this. |
| 10621 | testCases = append(testCases, testCase{ |
| 10622 | name: "SendServerHelloAsHelloRetryRequest", |
| 10623 | config: Config{ |
| 10624 | MaxVersion: VersionTLS12, |
| 10625 | Bugs: ProtocolBugs{ |
| 10626 | SendServerHelloAsHelloRetryRequest: true, |
| 10627 | }, |
| 10628 | }, |
| 10629 | shouldFail: true, |
| 10630 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10631 | expectedLocalError: "remote error: unexpected message", |
| 10632 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10633 | } |
| 10634 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10635 | func addTrailingMessageDataTests() { |
| 10636 | for _, t := range makePerMessageTests() { |
| 10637 | t.test.name = "TrailingMessageData-" + t.test.name |
| 10638 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 10639 | t.test.shouldFail = true |
| 10640 | t.test.expectedError = ":DECODE_ERROR:" |
| 10641 | t.test.expectedLocalError = "remote error: error decoding message" |
| 10642 | |
| 10643 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10644 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10645 | // an unencrypted alert while the server expects |
| 10646 | // encryption, so the alert is not readable by runner. |
| 10647 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10648 | } |
| 10649 | |
| 10650 | if t.messageType == typeFinished { |
| 10651 | // Bad Finished messages read as the verify data having |
| 10652 | // the wrong length. |
| 10653 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 10654 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 10655 | } |
| 10656 | |
| 10657 | testCases = append(testCases, t.test) |
| 10658 | } |
| 10659 | } |
| 10660 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10661 | func addTLS13HandshakeTests() { |
| 10662 | testCases = append(testCases, testCase{ |
| 10663 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10664 | name: "NegotiatePSKResumption-TLS13", |
| 10665 | config: Config{ |
| 10666 | MaxVersion: VersionTLS13, |
| 10667 | Bugs: ProtocolBugs{ |
| 10668 | NegotiatePSKResumption: true, |
| 10669 | }, |
| 10670 | }, |
| 10671 | resumeSession: true, |
| 10672 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10673 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10674 | }) |
| 10675 | |
| 10676 | testCases = append(testCases, testCase{ |
| 10677 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10678 | name: "MissingKeyShare-Client", |
| 10679 | config: Config{ |
| 10680 | MaxVersion: VersionTLS13, |
| 10681 | Bugs: ProtocolBugs{ |
| 10682 | MissingKeyShare: true, |
| 10683 | }, |
| 10684 | }, |
| 10685 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10686 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10687 | }) |
| 10688 | |
| 10689 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10690 | testType: serverTest, |
| 10691 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10692 | config: Config{ |
| 10693 | MaxVersion: VersionTLS13, |
| 10694 | Bugs: ProtocolBugs{ |
| 10695 | MissingKeyShare: true, |
| 10696 | }, |
| 10697 | }, |
| 10698 | shouldFail: true, |
| 10699 | expectedError: ":MISSING_KEY_SHARE:", |
| 10700 | }) |
| 10701 | |
| 10702 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10703 | testType: serverTest, |
| 10704 | name: "DuplicateKeyShares", |
| 10705 | config: Config{ |
| 10706 | MaxVersion: VersionTLS13, |
| 10707 | Bugs: ProtocolBugs{ |
| 10708 | DuplicateKeyShares: true, |
| 10709 | }, |
| 10710 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10711 | shouldFail: true, |
| 10712 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10713 | }) |
| 10714 | |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10715 | for _, version := range allVersions(tls) { |
| 10716 | if version.version != VersionTLS13 { |
| 10717 | continue |
| 10718 | } |
| 10719 | name := version.name |
| 10720 | variant := version.tls13Variant |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10721 | |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10722 | testCases = append(testCases, testCase{ |
| 10723 | testType: serverTest, |
| 10724 | name: "SkipEarlyData-" + name, |
| 10725 | config: Config{ |
| 10726 | MaxVersion: VersionTLS13, |
| 10727 | Bugs: ProtocolBugs{ |
| 10728 | SendFakeEarlyDataLength: 4, |
| 10729 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10730 | }, |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10731 | tls13Variant: variant, |
| 10732 | }) |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10733 | |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10734 | // Test that enabling a TLS 1.3 variant does not interfere with |
| 10735 | // TLS 1.2 session ID resumption. |
| 10736 | testCases = append(testCases, testCase{ |
| 10737 | testType: clientTest, |
| 10738 | name: "ResumeTLS12SessionID-" + name, |
| 10739 | config: Config{ |
| 10740 | MaxVersion: VersionTLS12, |
| 10741 | SessionTicketsDisabled: true, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10742 | }, |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10743 | tls13Variant: variant, |
| 10744 | resumeSession: true, |
| 10745 | }) |
| 10746 | |
| 10747 | // Test that the server correctly echoes back session IDs of |
| 10748 | // various lengths. |
| 10749 | testCases = append(testCases, testCase{ |
| 10750 | testType: serverTest, |
| 10751 | name: "EmptySessionID-" + name, |
| 10752 | config: Config{ |
| 10753 | MaxVersion: VersionTLS13, |
| 10754 | Bugs: ProtocolBugs{ |
| 10755 | SendClientHelloSessionID: []byte{}, |
| 10756 | }, |
| 10757 | }, |
| 10758 | tls13Variant: variant, |
| 10759 | }) |
| 10760 | |
| 10761 | testCases = append(testCases, testCase{ |
| 10762 | testType: serverTest, |
| 10763 | name: "ShortSessionID-" + name, |
| 10764 | config: Config{ |
| 10765 | MaxVersion: VersionTLS13, |
| 10766 | Bugs: ProtocolBugs{ |
| 10767 | SendClientHelloSessionID: make([]byte, 16), |
| 10768 | }, |
| 10769 | }, |
| 10770 | tls13Variant: variant, |
| 10771 | }) |
| 10772 | |
| 10773 | testCases = append(testCases, testCase{ |
| 10774 | testType: serverTest, |
| 10775 | name: "FullSessionID-" + name, |
| 10776 | config: Config{ |
| 10777 | MaxVersion: VersionTLS13, |
| 10778 | Bugs: ProtocolBugs{ |
| 10779 | SendClientHelloSessionID: make([]byte, 32), |
| 10780 | }, |
| 10781 | }, |
| 10782 | tls13Variant: variant, |
| 10783 | }) |
| 10784 | |
| 10785 | hasSessionID := false |
Steven Valdez | 4c7f5fa | 2017-10-02 15:53:57 -0400 | [diff] [blame] | 10786 | if variant != TLS13Default { |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10787 | hasSessionID = true |
| 10788 | } |
| 10789 | |
| 10790 | // Test that the client sends a fake session ID in the correct experiments. |
| 10791 | testCases = append(testCases, testCase{ |
| 10792 | testType: clientTest, |
| 10793 | name: "TLS13SessionID-" + name, |
| 10794 | config: Config{ |
| 10795 | MaxVersion: VersionTLS13, |
| 10796 | Bugs: ProtocolBugs{ |
Steven Valdez | 4c7f5fa | 2017-10-02 15:53:57 -0400 | [diff] [blame] | 10797 | ExpectClientHelloSessionID: hasSessionID, |
Steven Valdez | c7d4d21 | 2017-09-11 13:53:08 -0400 | [diff] [blame] | 10798 | }, |
| 10799 | }, |
| 10800 | tls13Variant: variant, |
| 10801 | }) |
| 10802 | |
| 10803 | testCases = append(testCases, testCase{ |
| 10804 | testType: clientTest, |
| 10805 | name: "EarlyData-Client-" + name, |
| 10806 | config: Config{ |
| 10807 | MaxVersion: VersionTLS13, |
| 10808 | MinVersion: VersionTLS13, |
| 10809 | MaxEarlyDataSize: 16384, |
| 10810 | }, |
| 10811 | resumeConfig: &Config{ |
| 10812 | MaxVersion: VersionTLS13, |
| 10813 | MinVersion: VersionTLS13, |
| 10814 | MaxEarlyDataSize: 16384, |
| 10815 | Bugs: ProtocolBugs{ |
| 10816 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 10817 | }, |
| 10818 | }, |
| 10819 | tls13Variant: variant, |
| 10820 | resumeSession: true, |
| 10821 | flags: []string{ |
| 10822 | "-enable-early-data", |
| 10823 | "-expect-early-data-info", |
| 10824 | "-expect-accept-early-data", |
| 10825 | "-on-resume-shim-writes-first", |
| 10826 | }, |
| 10827 | }) |
| 10828 | |
| 10829 | testCases = append(testCases, testCase{ |
| 10830 | testType: clientTest, |
| 10831 | name: "EarlyData-Reject-Client-" + name, |
| 10832 | config: Config{ |
| 10833 | MaxVersion: VersionTLS13, |
| 10834 | MaxEarlyDataSize: 16384, |
| 10835 | }, |
| 10836 | resumeConfig: &Config{ |
| 10837 | MaxVersion: VersionTLS13, |
| 10838 | MaxEarlyDataSize: 16384, |
| 10839 | Bugs: ProtocolBugs{ |
| 10840 | AlwaysRejectEarlyData: true, |
| 10841 | }, |
| 10842 | }, |
| 10843 | tls13Variant: variant, |
| 10844 | resumeSession: true, |
| 10845 | flags: []string{ |
| 10846 | "-enable-early-data", |
| 10847 | "-expect-early-data-info", |
| 10848 | "-expect-reject-early-data", |
| 10849 | "-on-resume-shim-writes-first", |
| 10850 | }, |
| 10851 | }) |
| 10852 | |
| 10853 | testCases = append(testCases, testCase{ |
| 10854 | testType: serverTest, |
| 10855 | name: "EarlyData-Server-" + name, |
| 10856 | config: Config{ |
| 10857 | MaxVersion: VersionTLS13, |
| 10858 | MinVersion: VersionTLS13, |
| 10859 | Bugs: ProtocolBugs{ |
| 10860 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 10861 | ExpectEarlyDataAccepted: true, |
| 10862 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 10863 | }, |
| 10864 | }, |
| 10865 | tls13Variant: variant, |
| 10866 | messageCount: 2, |
| 10867 | resumeSession: true, |
| 10868 | flags: []string{ |
| 10869 | "-enable-early-data", |
| 10870 | "-expect-accept-early-data", |
| 10871 | }, |
| 10872 | }) |
| 10873 | |
| 10874 | } |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10875 | |
| 10876 | testCases = append(testCases, testCase{ |
| 10877 | testType: serverTest, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10878 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 10879 | config: Config{ |
| 10880 | MaxVersion: VersionTLS13, |
| 10881 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10882 | SendFakeEarlyDataLength: 4, |
| 10883 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10884 | }, |
| 10885 | }, |
| 10886 | shouldFail: true, |
| 10887 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10888 | }) |
| 10889 | |
| 10890 | testCases = append(testCases, testCase{ |
| 10891 | testType: serverTest, |
| 10892 | name: "SkipEarlyData-TooMuchData", |
| 10893 | config: Config{ |
| 10894 | MaxVersion: VersionTLS13, |
| 10895 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10896 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10897 | }, |
| 10898 | }, |
| 10899 | shouldFail: true, |
| 10900 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10901 | }) |
| 10902 | |
| 10903 | testCases = append(testCases, testCase{ |
| 10904 | testType: serverTest, |
| 10905 | name: "SkipEarlyData-Interleaved", |
| 10906 | config: Config{ |
| 10907 | MaxVersion: VersionTLS13, |
| 10908 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10909 | SendFakeEarlyDataLength: 4, |
| 10910 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10911 | }, |
| 10912 | }, |
| 10913 | shouldFail: true, |
| 10914 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10915 | }) |
| 10916 | |
| 10917 | testCases = append(testCases, testCase{ |
| 10918 | testType: serverTest, |
| 10919 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 10920 | config: Config{ |
| 10921 | MaxVersion: VersionTLS13, |
| 10922 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10923 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10924 | }, |
| 10925 | }, |
| 10926 | shouldFail: true, |
| 10927 | expectedError: ":UNEXPECTED_RECORD:", |
| 10928 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 10929 | }) |
| 10930 | |
| 10931 | testCases = append(testCases, testCase{ |
| 10932 | testType: serverTest, |
| 10933 | name: "SkipEarlyData-HRR", |
| 10934 | config: Config{ |
| 10935 | MaxVersion: VersionTLS13, |
| 10936 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10937 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10938 | }, |
| 10939 | DefaultCurves: []CurveID{}, |
| 10940 | }, |
| 10941 | }) |
| 10942 | |
| 10943 | testCases = append(testCases, testCase{ |
| 10944 | testType: serverTest, |
| 10945 | name: "SkipEarlyData-HRR-Interleaved", |
| 10946 | config: Config{ |
| 10947 | MaxVersion: VersionTLS13, |
| 10948 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10949 | SendFakeEarlyDataLength: 4, |
| 10950 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10951 | }, |
| 10952 | DefaultCurves: []CurveID{}, |
| 10953 | }, |
| 10954 | shouldFail: true, |
| 10955 | expectedError: ":UNEXPECTED_RECORD:", |
| 10956 | }) |
| 10957 | |
| 10958 | testCases = append(testCases, testCase{ |
| 10959 | testType: serverTest, |
| 10960 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10961 | config: Config{ |
| 10962 | MaxVersion: VersionTLS13, |
| 10963 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10964 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10965 | }, |
| 10966 | DefaultCurves: []CurveID{}, |
| 10967 | }, |
| 10968 | shouldFail: true, |
| 10969 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10970 | }) |
| 10971 | |
| 10972 | // Test that skipping early data looking for cleartext correctly |
| 10973 | // processes an alert record. |
| 10974 | testCases = append(testCases, testCase{ |
| 10975 | testType: serverTest, |
| 10976 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10977 | config: Config{ |
| 10978 | MaxVersion: VersionTLS13, |
| 10979 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10980 | SendEarlyAlert: true, |
| 10981 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10982 | }, |
| 10983 | DefaultCurves: []CurveID{}, |
| 10984 | }, |
| 10985 | shouldFail: true, |
| 10986 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10987 | }) |
| 10988 | |
| 10989 | testCases = append(testCases, testCase{ |
| 10990 | testType: serverTest, |
| 10991 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10992 | config: Config{ |
| 10993 | MaxVersion: VersionTLS13, |
| 10994 | Bugs: ProtocolBugs{ |
| 10995 | SendEarlyDataOnSecondClientHello: true, |
| 10996 | }, |
| 10997 | DefaultCurves: []CurveID{}, |
| 10998 | }, |
| 10999 | shouldFail: true, |
| 11000 | expectedLocalError: "remote error: bad record MAC", |
| 11001 | }) |
| 11002 | |
| 11003 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11004 | testType: clientTest, |
| 11005 | name: "EmptyEncryptedExtensions", |
| 11006 | config: Config{ |
| 11007 | MaxVersion: VersionTLS13, |
| 11008 | Bugs: ProtocolBugs{ |
| 11009 | EmptyEncryptedExtensions: true, |
| 11010 | }, |
| 11011 | }, |
| 11012 | shouldFail: true, |
| 11013 | expectedLocalError: "remote error: error decoding message", |
| 11014 | }) |
| 11015 | |
| 11016 | testCases = append(testCases, testCase{ |
| 11017 | testType: clientTest, |
| 11018 | name: "EncryptedExtensionsWithKeyShare", |
| 11019 | config: Config{ |
| 11020 | MaxVersion: VersionTLS13, |
| 11021 | Bugs: ProtocolBugs{ |
| 11022 | EncryptedExtensionsWithKeyShare: true, |
| 11023 | }, |
| 11024 | }, |
| 11025 | shouldFail: true, |
| 11026 | expectedLocalError: "remote error: unsupported extension", |
| 11027 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 11028 | |
| 11029 | testCases = append(testCases, testCase{ |
| 11030 | testType: serverTest, |
| 11031 | name: "SendHelloRetryRequest", |
| 11032 | config: Config{ |
| 11033 | MaxVersion: VersionTLS13, |
| 11034 | // Require a HelloRetryRequest for every curve. |
| 11035 | DefaultCurves: []CurveID{}, |
| 11036 | }, |
| 11037 | expectedCurveID: CurveX25519, |
| 11038 | }) |
| 11039 | |
| 11040 | testCases = append(testCases, testCase{ |
| 11041 | testType: serverTest, |
| 11042 | name: "SendHelloRetryRequest-2", |
| 11043 | config: Config{ |
| 11044 | MaxVersion: VersionTLS13, |
| 11045 | DefaultCurves: []CurveID{CurveP384}, |
| 11046 | }, |
| 11047 | // Although the ClientHello did not predict our preferred curve, |
| 11048 | // we always select it whether it is predicted or not. |
| 11049 | expectedCurveID: CurveX25519, |
| 11050 | }) |
| 11051 | |
| 11052 | testCases = append(testCases, testCase{ |
| 11053 | name: "UnknownCurve-HelloRetryRequest", |
| 11054 | config: Config{ |
| 11055 | MaxVersion: VersionTLS13, |
| 11056 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11057 | CurvePreferences: []CurveID{CurveP384}, |
| 11058 | Bugs: ProtocolBugs{ |
| 11059 | SendHelloRetryRequestCurve: bogusCurve, |
| 11060 | }, |
| 11061 | }, |
| 11062 | shouldFail: true, |
| 11063 | expectedError: ":WRONG_CURVE:", |
| 11064 | }) |
| 11065 | |
| 11066 | testCases = append(testCases, testCase{ |
| 11067 | name: "DisabledCurve-HelloRetryRequest", |
| 11068 | config: Config{ |
| 11069 | MaxVersion: VersionTLS13, |
| 11070 | CurvePreferences: []CurveID{CurveP256}, |
| 11071 | Bugs: ProtocolBugs{ |
| 11072 | IgnorePeerCurvePreferences: true, |
| 11073 | }, |
| 11074 | }, |
| 11075 | flags: []string{"-p384-only"}, |
| 11076 | shouldFail: true, |
| 11077 | expectedError: ":WRONG_CURVE:", |
| 11078 | }) |
| 11079 | |
| 11080 | testCases = append(testCases, testCase{ |
| 11081 | name: "UnnecessaryHelloRetryRequest", |
| 11082 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 11083 | MaxVersion: VersionTLS13, |
| 11084 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 11085 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 11086 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 11087 | }, |
| 11088 | }, |
| 11089 | shouldFail: true, |
| 11090 | expectedError: ":WRONG_CURVE:", |
| 11091 | }) |
| 11092 | |
| 11093 | testCases = append(testCases, testCase{ |
| 11094 | name: "SecondHelloRetryRequest", |
| 11095 | config: Config{ |
| 11096 | MaxVersion: VersionTLS13, |
| 11097 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11098 | CurvePreferences: []CurveID{CurveP384}, |
| 11099 | Bugs: ProtocolBugs{ |
| 11100 | SecondHelloRetryRequest: true, |
| 11101 | }, |
| 11102 | }, |
| 11103 | shouldFail: true, |
| 11104 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 11105 | }) |
| 11106 | |
| 11107 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 11108 | name: "HelloRetryRequest-Empty", |
| 11109 | config: Config{ |
| 11110 | MaxVersion: VersionTLS13, |
| 11111 | Bugs: ProtocolBugs{ |
| 11112 | AlwaysSendHelloRetryRequest: true, |
| 11113 | }, |
| 11114 | }, |
| 11115 | shouldFail: true, |
| 11116 | expectedError: ":DECODE_ERROR:", |
| 11117 | }) |
| 11118 | |
| 11119 | testCases = append(testCases, testCase{ |
| 11120 | name: "HelloRetryRequest-DuplicateCurve", |
| 11121 | config: Config{ |
| 11122 | MaxVersion: VersionTLS13, |
| 11123 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 11124 | // configuration. Assert this ExpectMissingKeyShare. |
| 11125 | CurvePreferences: []CurveID{CurveP384}, |
| 11126 | Bugs: ProtocolBugs{ |
| 11127 | ExpectMissingKeyShare: true, |
| 11128 | DuplicateHelloRetryRequestExtensions: true, |
| 11129 | }, |
| 11130 | }, |
| 11131 | shouldFail: true, |
| 11132 | expectedError: ":DUPLICATE_EXTENSION:", |
| 11133 | expectedLocalError: "remote error: illegal parameter", |
| 11134 | }) |
| 11135 | |
| 11136 | testCases = append(testCases, testCase{ |
| 11137 | name: "HelloRetryRequest-Cookie", |
| 11138 | config: Config{ |
| 11139 | MaxVersion: VersionTLS13, |
| 11140 | Bugs: ProtocolBugs{ |
| 11141 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 11142 | }, |
| 11143 | }, |
| 11144 | }) |
| 11145 | |
| 11146 | testCases = append(testCases, testCase{ |
| 11147 | name: "HelloRetryRequest-DuplicateCookie", |
| 11148 | config: Config{ |
| 11149 | MaxVersion: VersionTLS13, |
| 11150 | Bugs: ProtocolBugs{ |
| 11151 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 11152 | DuplicateHelloRetryRequestExtensions: true, |
| 11153 | }, |
| 11154 | }, |
| 11155 | shouldFail: true, |
| 11156 | expectedError: ":DUPLICATE_EXTENSION:", |
| 11157 | expectedLocalError: "remote error: illegal parameter", |
| 11158 | }) |
| 11159 | |
| 11160 | testCases = append(testCases, testCase{ |
| 11161 | name: "HelloRetryRequest-EmptyCookie", |
| 11162 | config: Config{ |
| 11163 | MaxVersion: VersionTLS13, |
| 11164 | Bugs: ProtocolBugs{ |
| 11165 | SendHelloRetryRequestCookie: []byte{}, |
| 11166 | }, |
| 11167 | }, |
| 11168 | shouldFail: true, |
| 11169 | expectedError: ":DECODE_ERROR:", |
| 11170 | }) |
| 11171 | |
| 11172 | testCases = append(testCases, testCase{ |
| 11173 | name: "HelloRetryRequest-Cookie-Curve", |
| 11174 | config: Config{ |
| 11175 | MaxVersion: VersionTLS13, |
| 11176 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11177 | CurvePreferences: []CurveID{CurveP384}, |
| 11178 | Bugs: ProtocolBugs{ |
| 11179 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 11180 | ExpectMissingKeyShare: true, |
| 11181 | }, |
| 11182 | }, |
| 11183 | }) |
| 11184 | |
| 11185 | testCases = append(testCases, testCase{ |
| 11186 | name: "HelloRetryRequest-Unknown", |
| 11187 | config: Config{ |
| 11188 | MaxVersion: VersionTLS13, |
| 11189 | Bugs: ProtocolBugs{ |
| 11190 | CustomHelloRetryRequestExtension: "extension", |
| 11191 | }, |
| 11192 | }, |
| 11193 | shouldFail: true, |
| 11194 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11195 | expectedLocalError: "remote error: unsupported extension", |
| 11196 | }) |
| 11197 | |
| 11198 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 11199 | testType: serverTest, |
| 11200 | name: "SecondClientHelloMissingKeyShare", |
| 11201 | config: Config{ |
| 11202 | MaxVersion: VersionTLS13, |
| 11203 | DefaultCurves: []CurveID{}, |
| 11204 | Bugs: ProtocolBugs{ |
| 11205 | SecondClientHelloMissingKeyShare: true, |
| 11206 | }, |
| 11207 | }, |
| 11208 | shouldFail: true, |
| 11209 | expectedError: ":MISSING_KEY_SHARE:", |
| 11210 | }) |
| 11211 | |
| 11212 | testCases = append(testCases, testCase{ |
| 11213 | testType: serverTest, |
| 11214 | name: "SecondClientHelloWrongCurve", |
| 11215 | config: Config{ |
| 11216 | MaxVersion: VersionTLS13, |
| 11217 | DefaultCurves: []CurveID{}, |
| 11218 | Bugs: ProtocolBugs{ |
| 11219 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 11220 | }, |
| 11221 | }, |
| 11222 | shouldFail: true, |
| 11223 | expectedError: ":WRONG_CURVE:", |
| 11224 | }) |
| 11225 | |
| 11226 | testCases = append(testCases, testCase{ |
| 11227 | name: "HelloRetryRequestVersionMismatch", |
| 11228 | config: Config{ |
| 11229 | MaxVersion: VersionTLS13, |
| 11230 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11231 | CurvePreferences: []CurveID{CurveP384}, |
| 11232 | Bugs: ProtocolBugs{ |
| 11233 | SendServerHelloVersion: 0x0305, |
| 11234 | }, |
| 11235 | }, |
| 11236 | shouldFail: true, |
| 11237 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11238 | }) |
| 11239 | |
| 11240 | testCases = append(testCases, testCase{ |
| 11241 | name: "HelloRetryRequestCurveMismatch", |
| 11242 | config: Config{ |
| 11243 | MaxVersion: VersionTLS13, |
| 11244 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11245 | CurvePreferences: []CurveID{CurveP384}, |
| 11246 | Bugs: ProtocolBugs{ |
| 11247 | // Send P-384 (correct) in the HelloRetryRequest. |
| 11248 | SendHelloRetryRequestCurve: CurveP384, |
| 11249 | // But send P-256 in the ServerHello. |
| 11250 | SendCurve: CurveP256, |
| 11251 | }, |
| 11252 | }, |
| 11253 | shouldFail: true, |
| 11254 | expectedError: ":WRONG_CURVE:", |
| 11255 | }) |
| 11256 | |
| 11257 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 11258 | // without sending it. |
| 11259 | testCases = append(testCases, testCase{ |
| 11260 | name: "SkipHelloRetryRequest", |
| 11261 | config: Config{ |
| 11262 | MaxVersion: VersionTLS13, |
| 11263 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11264 | CurvePreferences: []CurveID{CurveP384}, |
| 11265 | Bugs: ProtocolBugs{ |
| 11266 | SkipHelloRetryRequest: true, |
| 11267 | }, |
| 11268 | }, |
| 11269 | shouldFail: true, |
| 11270 | expectedError: ":WRONG_CURVE:", |
| 11271 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 11272 | |
| 11273 | testCases = append(testCases, testCase{ |
| 11274 | name: "TLS13-RequestContextInHandshake", |
| 11275 | config: Config{ |
| 11276 | MaxVersion: VersionTLS13, |
| 11277 | MinVersion: VersionTLS13, |
| 11278 | ClientAuth: RequireAnyClientCert, |
| 11279 | Bugs: ProtocolBugs{ |
| 11280 | SendRequestContext: []byte("request context"), |
| 11281 | }, |
| 11282 | }, |
| 11283 | flags: []string{ |
| 11284 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11285 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 11286 | }, |
| 11287 | shouldFail: true, |
| 11288 | expectedError: ":DECODE_ERROR:", |
| 11289 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 11290 | |
| 11291 | testCases = append(testCases, testCase{ |
| 11292 | testType: serverTest, |
| 11293 | name: "TLS13-TrailingKeyShareData", |
| 11294 | config: Config{ |
| 11295 | MaxVersion: VersionTLS13, |
| 11296 | Bugs: ProtocolBugs{ |
| 11297 | TrailingKeyShareData: true, |
| 11298 | }, |
| 11299 | }, |
| 11300 | shouldFail: true, |
| 11301 | expectedError: ":DECODE_ERROR:", |
| 11302 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 11303 | |
| 11304 | testCases = append(testCases, testCase{ |
| 11305 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 11306 | config: Config{ |
| 11307 | MaxVersion: VersionTLS13, |
| 11308 | Bugs: ProtocolBugs{ |
| 11309 | AlwaysSelectPSKIdentity: true, |
| 11310 | }, |
| 11311 | }, |
| 11312 | shouldFail: true, |
| 11313 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11314 | }) |
| 11315 | |
| 11316 | testCases = append(testCases, testCase{ |
| 11317 | name: "TLS13-InvalidPSKIdentity", |
| 11318 | config: Config{ |
| 11319 | MaxVersion: VersionTLS13, |
| 11320 | Bugs: ProtocolBugs{ |
| 11321 | SelectPSKIdentityOnResume: 1, |
| 11322 | }, |
| 11323 | }, |
| 11324 | resumeSession: true, |
| 11325 | shouldFail: true, |
| 11326 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 11327 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11328 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11329 | testCases = append(testCases, testCase{ |
| 11330 | testType: serverTest, |
| 11331 | name: "TLS13-ExtraPSKIdentity", |
| 11332 | config: Config{ |
| 11333 | MaxVersion: VersionTLS13, |
| 11334 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 11335 | ExtraPSKIdentity: true, |
| 11336 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11337 | }, |
| 11338 | }, |
| 11339 | resumeSession: true, |
| 11340 | }) |
| 11341 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11342 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 11343 | testCases = append(testCases, testCase{ |
| 11344 | name: "TLS13-CustomTicketExtension", |
| 11345 | config: Config{ |
| 11346 | MaxVersion: VersionTLS13, |
| 11347 | Bugs: ProtocolBugs{ |
| 11348 | CustomTicketExtension: "1234", |
| 11349 | }, |
| 11350 | }, |
| 11351 | }) |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11352 | testCases = append(testCases, testCase{ |
| 11353 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11354 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 11355 | config: Config{ |
| 11356 | MaxVersion: VersionTLS13, |
| 11357 | MaxEarlyDataSize: 16384, |
| 11358 | Certificates: []Certificate{rsaCertificate}, |
| 11359 | }, |
| 11360 | resumeConfig: &Config{ |
| 11361 | MaxVersion: VersionTLS13, |
| 11362 | MaxEarlyDataSize: 16384, |
| 11363 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 11364 | SessionTicketsDisabled: true, |
| 11365 | }, |
| 11366 | resumeSession: true, |
| 11367 | expectResumeRejected: true, |
| 11368 | flags: []string{ |
| 11369 | "-enable-early-data", |
| 11370 | "-expect-early-data-info", |
| 11371 | "-expect-reject-early-data", |
| 11372 | "-on-resume-shim-writes-first", |
| 11373 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11374 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11375 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 11376 | // Session tickets are disabled, so the runner will not send a ticket. |
| 11377 | "-on-retry-expect-no-session", |
| 11378 | }, |
| 11379 | }) |
| 11380 | |
| 11381 | testCases = append(testCases, testCase{ |
| 11382 | testType: clientTest, |
| 11383 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11384 | config: Config{ |
| 11385 | MaxVersion: VersionTLS13, |
| 11386 | MaxEarlyDataSize: 16384, |
| 11387 | }, |
| 11388 | resumeConfig: &Config{ |
| 11389 | MaxVersion: VersionTLS13, |
| 11390 | MaxEarlyDataSize: 16384, |
| 11391 | Bugs: ProtocolBugs{ |
| 11392 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11393 | }, |
| 11394 | }, |
| 11395 | resumeSession: true, |
| 11396 | flags: []string{ |
| 11397 | "-enable-early-data", |
| 11398 | "-expect-early-data-info", |
| 11399 | "-expect-reject-early-data", |
| 11400 | }, |
| 11401 | }) |
| 11402 | |
| 11403 | // The client must check the server does not send the early_data |
| 11404 | // extension while rejecting the session. |
| 11405 | testCases = append(testCases, testCase{ |
| 11406 | testType: clientTest, |
| 11407 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 11408 | config: Config{ |
| 11409 | MaxVersion: VersionTLS13, |
| 11410 | MaxEarlyDataSize: 16384, |
| 11411 | }, |
| 11412 | resumeConfig: &Config{ |
| 11413 | MaxVersion: VersionTLS13, |
| 11414 | SessionTicketsDisabled: true, |
| 11415 | Bugs: ProtocolBugs{ |
| 11416 | SendEarlyDataExtension: true, |
| 11417 | }, |
| 11418 | }, |
| 11419 | resumeSession: true, |
| 11420 | flags: []string{ |
| 11421 | "-enable-early-data", |
| 11422 | "-expect-early-data-info", |
| 11423 | }, |
| 11424 | shouldFail: true, |
| 11425 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11426 | }) |
| 11427 | |
| 11428 | // The client must fail with a dedicated error code if the server |
| 11429 | // responds with TLS 1.2 when offering 0-RTT. |
| 11430 | testCases = append(testCases, testCase{ |
| 11431 | testType: clientTest, |
| 11432 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 11433 | config: Config{ |
| 11434 | MaxVersion: VersionTLS13, |
| 11435 | MaxEarlyDataSize: 16384, |
| 11436 | }, |
| 11437 | resumeConfig: &Config{ |
| 11438 | MaxVersion: VersionTLS12, |
| 11439 | }, |
| 11440 | resumeSession: true, |
| 11441 | flags: []string{ |
| 11442 | "-enable-early-data", |
| 11443 | "-expect-early-data-info", |
| 11444 | }, |
| 11445 | shouldFail: true, |
| 11446 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 11447 | }) |
| 11448 | |
| 11449 | // Test that the client rejects an (unsolicited) early_data extension if |
| 11450 | // the server sent an HRR. |
| 11451 | testCases = append(testCases, testCase{ |
| 11452 | testType: clientTest, |
| 11453 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 11454 | config: Config{ |
| 11455 | MaxVersion: VersionTLS13, |
| 11456 | MaxEarlyDataSize: 16384, |
| 11457 | }, |
| 11458 | resumeConfig: &Config{ |
| 11459 | MaxVersion: VersionTLS13, |
| 11460 | MaxEarlyDataSize: 16384, |
| 11461 | Bugs: ProtocolBugs{ |
| 11462 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11463 | SendEarlyDataExtension: true, |
| 11464 | }, |
| 11465 | }, |
| 11466 | resumeSession: true, |
| 11467 | flags: []string{ |
| 11468 | "-enable-early-data", |
| 11469 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11470 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11471 | }, |
| 11472 | shouldFail: true, |
| 11473 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11474 | }) |
| 11475 | |
| 11476 | fooString := "foo" |
| 11477 | barString := "bar" |
| 11478 | |
| 11479 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 11480 | // that changed it. |
| 11481 | testCases = append(testCases, testCase{ |
| 11482 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11483 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11484 | config: Config{ |
| 11485 | MaxVersion: VersionTLS13, |
| 11486 | MaxEarlyDataSize: 16384, |
| 11487 | Bugs: ProtocolBugs{ |
| 11488 | ALPNProtocol: &fooString, |
| 11489 | }, |
| 11490 | }, |
| 11491 | resumeConfig: &Config{ |
| 11492 | MaxVersion: VersionTLS13, |
| 11493 | MaxEarlyDataSize: 16384, |
| 11494 | Bugs: ProtocolBugs{ |
| 11495 | ALPNProtocol: &barString, |
| 11496 | }, |
| 11497 | }, |
| 11498 | resumeSession: true, |
| 11499 | flags: []string{ |
| 11500 | "-advertise-alpn", "\x03foo\x03bar", |
| 11501 | "-enable-early-data", |
| 11502 | "-expect-early-data-info", |
| 11503 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11504 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11505 | "-on-resume-expect-alpn", "foo", |
| 11506 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11507 | }, |
| 11508 | }) |
| 11509 | |
| 11510 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11511 | // ALPN was omitted from the first connection. |
| 11512 | testCases = append(testCases, testCase{ |
| 11513 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11514 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11515 | config: Config{ |
| 11516 | MaxVersion: VersionTLS13, |
| 11517 | MaxEarlyDataSize: 16384, |
| 11518 | }, |
| 11519 | resumeConfig: &Config{ |
| 11520 | MaxVersion: VersionTLS13, |
| 11521 | MaxEarlyDataSize: 16384, |
| 11522 | NextProtos: []string{"foo"}, |
| 11523 | }, |
| 11524 | resumeSession: true, |
| 11525 | flags: []string{ |
| 11526 | "-advertise-alpn", "\x03foo\x03bar", |
| 11527 | "-enable-early-data", |
| 11528 | "-expect-early-data-info", |
| 11529 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11530 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11531 | "-on-resume-expect-alpn", "", |
| 11532 | "-on-retry-expect-alpn", "foo", |
| 11533 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11534 | }, |
| 11535 | }) |
| 11536 | |
| 11537 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11538 | // ALPN was omitted from the second connection. |
| 11539 | testCases = append(testCases, testCase{ |
| 11540 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11541 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11542 | config: Config{ |
| 11543 | MaxVersion: VersionTLS13, |
| 11544 | MaxEarlyDataSize: 16384, |
| 11545 | NextProtos: []string{"foo"}, |
| 11546 | }, |
| 11547 | resumeConfig: &Config{ |
| 11548 | MaxVersion: VersionTLS13, |
| 11549 | MaxEarlyDataSize: 16384, |
| 11550 | }, |
| 11551 | resumeSession: true, |
| 11552 | flags: []string{ |
| 11553 | "-advertise-alpn", "\x03foo\x03bar", |
| 11554 | "-enable-early-data", |
| 11555 | "-expect-early-data-info", |
| 11556 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11557 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11558 | "-on-resume-expect-alpn", "foo", |
| 11559 | "-on-retry-expect-alpn", "", |
| 11560 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11561 | }, |
| 11562 | }) |
| 11563 | |
| 11564 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 11565 | testCases = append(testCases, testCase{ |
| 11566 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11567 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11568 | config: Config{ |
| 11569 | MaxVersion: VersionTLS13, |
| 11570 | MaxEarlyDataSize: 16384, |
| 11571 | Bugs: ProtocolBugs{ |
| 11572 | ALPNProtocol: &fooString, |
| 11573 | }, |
| 11574 | }, |
| 11575 | resumeConfig: &Config{ |
| 11576 | MaxVersion: VersionTLS13, |
| 11577 | MaxEarlyDataSize: 16384, |
| 11578 | Bugs: ProtocolBugs{ |
| 11579 | AlwaysAcceptEarlyData: true, |
| 11580 | ALPNProtocol: &barString, |
| 11581 | }, |
| 11582 | }, |
| 11583 | resumeSession: true, |
| 11584 | flags: []string{ |
| 11585 | "-advertise-alpn", "\x03foo\x03bar", |
| 11586 | "-enable-early-data", |
| 11587 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11588 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11589 | "-on-resume-expect-alpn", "foo", |
| 11590 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11591 | }, |
| 11592 | shouldFail: true, |
| 11593 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 11594 | }) |
| 11595 | |
| 11596 | // Test that the server correctly rejects 0-RTT when the previous |
| 11597 | // session did not allow early data on resumption. |
| 11598 | testCases = append(testCases, testCase{ |
| 11599 | testType: serverTest, |
| 11600 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 11601 | config: Config{ |
| 11602 | MaxVersion: VersionTLS13, |
| 11603 | }, |
| 11604 | resumeConfig: &Config{ |
| 11605 | MaxVersion: VersionTLS13, |
| 11606 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11607 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11608 | ExpectEarlyDataAccepted: false, |
| 11609 | }, |
| 11610 | }, |
| 11611 | resumeSession: true, |
| 11612 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11613 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11614 | "-expect-reject-early-data", |
| 11615 | }, |
| 11616 | }) |
| 11617 | |
| 11618 | // Test that we reject early data where ALPN is omitted from the first |
| 11619 | // connection. |
| 11620 | testCases = append(testCases, testCase{ |
| 11621 | testType: serverTest, |
| 11622 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 11623 | config: Config{ |
| 11624 | MaxVersion: VersionTLS13, |
| 11625 | NextProtos: []string{}, |
| 11626 | }, |
| 11627 | resumeConfig: &Config{ |
| 11628 | MaxVersion: VersionTLS13, |
| 11629 | NextProtos: []string{"foo"}, |
| 11630 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11631 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11632 | ExpectEarlyDataAccepted: false, |
| 11633 | }, |
| 11634 | }, |
| 11635 | resumeSession: true, |
| 11636 | flags: []string{ |
| 11637 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11638 | "-on-initial-select-alpn", "", |
| 11639 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11640 | }, |
| 11641 | }) |
| 11642 | |
| 11643 | // Test that we reject early data where ALPN is omitted from the second |
| 11644 | // connection. |
| 11645 | testCases = append(testCases, testCase{ |
| 11646 | testType: serverTest, |
| 11647 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 11648 | config: Config{ |
| 11649 | MaxVersion: VersionTLS13, |
| 11650 | NextProtos: []string{"foo"}, |
| 11651 | }, |
| 11652 | resumeConfig: &Config{ |
| 11653 | MaxVersion: VersionTLS13, |
| 11654 | NextProtos: []string{}, |
| 11655 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11656 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11657 | ExpectEarlyDataAccepted: false, |
| 11658 | }, |
| 11659 | }, |
| 11660 | resumeSession: true, |
| 11661 | flags: []string{ |
| 11662 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11663 | "-on-initial-select-alpn", "foo", |
| 11664 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11665 | }, |
| 11666 | }) |
| 11667 | |
| 11668 | // Test that we reject early data with mismatched ALPN. |
| 11669 | testCases = append(testCases, testCase{ |
| 11670 | testType: serverTest, |
| 11671 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 11672 | config: Config{ |
| 11673 | MaxVersion: VersionTLS13, |
| 11674 | NextProtos: []string{"foo"}, |
| 11675 | }, |
| 11676 | resumeConfig: &Config{ |
| 11677 | MaxVersion: VersionTLS13, |
| 11678 | NextProtos: []string{"bar"}, |
| 11679 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11680 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11681 | ExpectEarlyDataAccepted: false, |
| 11682 | }, |
| 11683 | }, |
| 11684 | resumeSession: true, |
| 11685 | flags: []string{ |
| 11686 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11687 | "-on-initial-select-alpn", "foo", |
| 11688 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11689 | }, |
| 11690 | }) |
| 11691 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11692 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 11693 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11694 | testCases = append(testCases, testCase{ |
| 11695 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11696 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11697 | config: Config{ |
| 11698 | MaxVersion: VersionTLS13, |
| 11699 | MaxEarlyDataSize: 16384, |
| 11700 | RequestChannelID: true, |
| 11701 | }, |
| 11702 | resumeSession: true, |
| 11703 | expectChannelID: true, |
| 11704 | shouldFail: true, |
Steven Valdez | f4ecc84 | 2017-08-10 14:02:56 -0400 | [diff] [blame] | 11705 | expectedError: ":UNEXPECTED_EXTENSION_ON_EARLY_DATA:", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11706 | flags: []string{ |
| 11707 | "-enable-early-data", |
| 11708 | "-expect-early-data-info", |
| 11709 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11710 | }, |
| 11711 | }) |
| 11712 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11713 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11714 | // to decline 0-RTT. |
| 11715 | testCases = append(testCases, testCase{ |
| 11716 | testType: clientTest, |
| 11717 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 11718 | config: Config{ |
| 11719 | MaxVersion: VersionTLS13, |
| 11720 | MaxEarlyDataSize: 16384, |
| 11721 | RequestChannelID: true, |
| 11722 | Bugs: ProtocolBugs{ |
| 11723 | AlwaysRejectEarlyData: true, |
| 11724 | }, |
| 11725 | }, |
| 11726 | resumeSession: true, |
| 11727 | expectChannelID: true, |
| 11728 | flags: []string{ |
| 11729 | "-enable-early-data", |
| 11730 | "-expect-early-data-info", |
| 11731 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11732 | "-expect-reject-early-data", |
| 11733 | }, |
| 11734 | }) |
| 11735 | |
| 11736 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11737 | // to decline Channel ID. |
| 11738 | testCases = append(testCases, testCase{ |
| 11739 | testType: clientTest, |
| 11740 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 11741 | config: Config{ |
| 11742 | MaxVersion: VersionTLS13, |
| 11743 | MaxEarlyDataSize: 16384, |
| 11744 | }, |
| 11745 | resumeSession: true, |
| 11746 | flags: []string{ |
| 11747 | "-enable-early-data", |
| 11748 | "-expect-early-data-info", |
| 11749 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11750 | "-expect-accept-early-data", |
| 11751 | }, |
| 11752 | }) |
| 11753 | |
| 11754 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 11755 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11756 | testCases = append(testCases, testCase{ |
| 11757 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11758 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11759 | config: Config{ |
| 11760 | MaxVersion: VersionTLS13, |
| 11761 | ChannelID: channelIDKey, |
| 11762 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11763 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11764 | ExpectEarlyDataAccepted: false, |
| 11765 | }, |
| 11766 | }, |
| 11767 | resumeSession: true, |
| 11768 | expectChannelID: true, |
| 11769 | flags: []string{ |
| 11770 | "-enable-early-data", |
| 11771 | "-expect-reject-early-data", |
| 11772 | "-expect-channel-id", |
| 11773 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 11774 | }, |
| 11775 | }) |
| 11776 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11777 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 11778 | // if not offered Channel ID. |
| 11779 | testCases = append(testCases, testCase{ |
| 11780 | testType: serverTest, |
| 11781 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 11782 | config: Config{ |
| 11783 | MaxVersion: VersionTLS13, |
| 11784 | Bugs: ProtocolBugs{ |
| 11785 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11786 | ExpectEarlyDataAccepted: true, |
| 11787 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11788 | }, |
| 11789 | }, |
| 11790 | resumeSession: true, |
| 11791 | expectChannelID: false, |
| 11792 | flags: []string{ |
| 11793 | "-enable-early-data", |
| 11794 | "-expect-accept-early-data", |
| 11795 | "-enable-channel-id", |
| 11796 | }, |
| 11797 | }) |
| 11798 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11799 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 11800 | // The subsequent records should fail to decrypt. |
| 11801 | testCases = append(testCases, testCase{ |
| 11802 | testType: serverTest, |
| 11803 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 11804 | config: Config{ |
| 11805 | MaxVersion: VersionTLS13, |
| 11806 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11807 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11808 | ExpectEarlyDataAccepted: true, |
| 11809 | SkipEndOfEarlyData: true, |
| 11810 | }, |
| 11811 | }, |
| 11812 | resumeSession: true, |
| 11813 | flags: []string{"-enable-early-data"}, |
| 11814 | shouldFail: true, |
| 11815 | expectedLocalError: "remote error: bad record MAC", |
| 11816 | expectedError: ":BAD_DECRYPT:", |
| 11817 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11818 | |
| 11819 | testCases = append(testCases, testCase{ |
| 11820 | testType: serverTest, |
| 11821 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 11822 | config: Config{ |
| 11823 | MaxVersion: VersionTLS13, |
| 11824 | }, |
| 11825 | resumeConfig: &Config{ |
| 11826 | MaxVersion: VersionTLS13, |
| 11827 | Bugs: ProtocolBugs{ |
| 11828 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11829 | SendStrayEarlyHandshake: true, |
David Benjamin | 4a37de0 | 2017-08-08 20:15:40 -0400 | [diff] [blame] | 11830 | ExpectEarlyDataAccepted: true, |
| 11831 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11832 | }, |
| 11833 | resumeSession: true, |
| 11834 | shouldFail: true, |
| 11835 | expectedError: ":UNEXPECTED_RECORD:", |
| 11836 | expectedLocalError: "remote error: unexpected message", |
| 11837 | flags: []string{ |
| 11838 | "-enable-early-data", |
| 11839 | }, |
| 11840 | }) |
David Benjamin | d9cbb53 | 2017-07-07 13:17:19 -0400 | [diff] [blame] | 11841 | |
| 11842 | // Test that the client reports TLS 1.3 as the version while sending |
| 11843 | // early data. |
| 11844 | testCases = append(testCases, testCase{ |
| 11845 | testType: clientTest, |
| 11846 | name: "TLS13-EarlyData-Client-VersionAPI", |
| 11847 | config: Config{ |
| 11848 | MaxVersion: VersionTLS13, |
| 11849 | MaxEarlyDataSize: 16384, |
| 11850 | }, |
| 11851 | resumeSession: true, |
| 11852 | flags: []string{ |
| 11853 | "-enable-early-data", |
| 11854 | "-expect-early-data-info", |
| 11855 | "-expect-accept-early-data", |
| 11856 | "-expect-version", strconv.Itoa(VersionTLS13), |
| 11857 | }, |
| 11858 | }) |
David Benjamin | 4a37de0 | 2017-08-08 20:15:40 -0400 | [diff] [blame] | 11859 | |
| 11860 | // Test that client and server both notice handshake errors after data |
| 11861 | // has started flowing. |
| 11862 | testCases = append(testCases, testCase{ |
| 11863 | testType: clientTest, |
| 11864 | name: "TLS13-EarlyData-Client-BadFinished", |
| 11865 | config: Config{ |
| 11866 | MaxVersion: VersionTLS13, |
| 11867 | MaxEarlyDataSize: 16384, |
| 11868 | }, |
| 11869 | resumeConfig: &Config{ |
| 11870 | MaxVersion: VersionTLS13, |
| 11871 | MaxEarlyDataSize: 16384, |
| 11872 | Bugs: ProtocolBugs{ |
| 11873 | BadFinished: true, |
| 11874 | }, |
| 11875 | }, |
| 11876 | resumeSession: true, |
| 11877 | flags: []string{ |
| 11878 | "-enable-early-data", |
| 11879 | "-expect-early-data-info", |
| 11880 | "-expect-accept-early-data", |
| 11881 | }, |
| 11882 | shouldFail: true, |
| 11883 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 11884 | expectedLocalError: "remote error: error decrypting message", |
| 11885 | }) |
| 11886 | testCases = append(testCases, testCase{ |
| 11887 | testType: serverTest, |
| 11888 | name: "TLS13-EarlyData-Server-BadFinished", |
| 11889 | config: Config{ |
| 11890 | MaxVersion: VersionTLS13, |
| 11891 | MaxEarlyDataSize: 16384, |
| 11892 | }, |
| 11893 | resumeConfig: &Config{ |
| 11894 | MaxVersion: VersionTLS13, |
| 11895 | MaxEarlyDataSize: 16384, |
| 11896 | Bugs: ProtocolBugs{ |
| 11897 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11898 | ExpectEarlyDataAccepted: true, |
| 11899 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11900 | BadFinished: true, |
| 11901 | }, |
| 11902 | }, |
| 11903 | resumeSession: true, |
| 11904 | flags: []string{ |
| 11905 | "-enable-early-data", |
| 11906 | "-expect-accept-early-data", |
| 11907 | }, |
| 11908 | shouldFail: true, |
| 11909 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 11910 | expectedLocalError: "remote error: error decrypting message", |
| 11911 | }) |
Dimitar Vlahovski | bd70845 | 2017-08-10 18:01:06 +0200 | [diff] [blame] | 11912 | testCases = append(testCases, testCase{ |
| 11913 | testType: serverTest, |
| 11914 | name: "TLS13-ServerSkipCertificateVerify", |
| 11915 | config: Config{ |
| 11916 | MinVersion: VersionTLS13, |
| 11917 | MaxVersion: VersionTLS13, |
| 11918 | Certificates: []Certificate{rsaChainCertificate}, |
| 11919 | Bugs: ProtocolBugs{ |
| 11920 | SkipCertificateVerify: true, |
| 11921 | }, |
| 11922 | }, |
| 11923 | expectPeerCertificate: &rsaChainCertificate, |
| 11924 | flags: []string{ |
| 11925 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11926 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11927 | "-require-any-client-certificate", |
| 11928 | }, |
| 11929 | shouldFail: true, |
| 11930 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 11931 | expectedLocalError: "remote error: unexpected message", |
| 11932 | }) |
| 11933 | testCases = append(testCases, testCase{ |
| 11934 | testType: clientTest, |
| 11935 | name: "TLS13-ClientSkipCertificateVerify", |
| 11936 | config: Config{ |
| 11937 | MinVersion: VersionTLS13, |
| 11938 | MaxVersion: VersionTLS13, |
| 11939 | Certificates: []Certificate{rsaChainCertificate}, |
| 11940 | Bugs: ProtocolBugs{ |
| 11941 | SkipCertificateVerify: true, |
| 11942 | }, |
| 11943 | }, |
| 11944 | expectPeerCertificate: &rsaChainCertificate, |
| 11945 | flags: []string{ |
| 11946 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11947 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11948 | }, |
| 11949 | shouldFail: true, |
| 11950 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 11951 | expectedLocalError: "remote error: unexpected message", |
| 11952 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11953 | } |
| 11954 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 11955 | func addTLS13CipherPreferenceTests() { |
| 11956 | // Test that client preference is honored if the shim has AES hardware |
| 11957 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 11958 | testCases = append(testCases, testCase{ |
| 11959 | testType: serverTest, |
| 11960 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 11961 | config: Config{ |
| 11962 | MaxVersion: VersionTLS13, |
| 11963 | CipherSuites: []uint16{ |
| 11964 | TLS_CHACHA20_POLY1305_SHA256, |
| 11965 | TLS_AES_128_GCM_SHA256, |
| 11966 | }, |
| 11967 | }, |
| 11968 | flags: []string{ |
| 11969 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11970 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11971 | }, |
| 11972 | }) |
| 11973 | |
| 11974 | testCases = append(testCases, testCase{ |
| 11975 | testType: serverTest, |
| 11976 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 11977 | config: Config{ |
| 11978 | MaxVersion: VersionTLS13, |
| 11979 | CipherSuites: []uint16{ |
| 11980 | TLS_AES_128_GCM_SHA256, |
| 11981 | TLS_CHACHA20_POLY1305_SHA256, |
| 11982 | }, |
| 11983 | }, |
| 11984 | flags: []string{ |
| 11985 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11986 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11987 | }, |
| 11988 | }) |
| 11989 | |
| 11990 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 11991 | // whether it has AES hardware. |
| 11992 | testCases = append(testCases, testCase{ |
| 11993 | name: "TLS13-CipherPreference-Client", |
| 11994 | config: Config{ |
| 11995 | MaxVersion: VersionTLS13, |
| 11996 | // Use the client cipher order. (This is the default but |
| 11997 | // is listed to be explicit.) |
| 11998 | PreferServerCipherSuites: false, |
| 11999 | }, |
| 12000 | flags: []string{ |
| 12001 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 12002 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 12003 | }, |
| 12004 | }) |
| 12005 | } |
| 12006 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12007 | func addPeekTests() { |
| 12008 | // Test SSL_peek works, including on empty records. |
| 12009 | testCases = append(testCases, testCase{ |
| 12010 | name: "Peek-Basic", |
| 12011 | sendEmptyRecords: 1, |
| 12012 | flags: []string{"-peek-then-read"}, |
| 12013 | }) |
| 12014 | |
| 12015 | // Test SSL_peek can drive the initial handshake. |
| 12016 | testCases = append(testCases, testCase{ |
| 12017 | name: "Peek-ImplicitHandshake", |
| 12018 | flags: []string{ |
| 12019 | "-peek-then-read", |
| 12020 | "-implicit-handshake", |
| 12021 | }, |
| 12022 | }) |
| 12023 | |
| 12024 | // Test SSL_peek can discover and drive a renegotiation. |
| 12025 | testCases = append(testCases, testCase{ |
| 12026 | name: "Peek-Renegotiate", |
| 12027 | config: Config{ |
| 12028 | MaxVersion: VersionTLS12, |
| 12029 | }, |
| 12030 | renegotiate: 1, |
| 12031 | flags: []string{ |
| 12032 | "-peek-then-read", |
| 12033 | "-renegotiate-freely", |
| 12034 | "-expect-total-renegotiations", "1", |
| 12035 | }, |
| 12036 | }) |
| 12037 | |
| 12038 | // Test SSL_peek can discover a close_notify. |
| 12039 | testCases = append(testCases, testCase{ |
| 12040 | name: "Peek-Shutdown", |
| 12041 | config: Config{ |
| 12042 | Bugs: ProtocolBugs{ |
| 12043 | ExpectCloseNotify: true, |
| 12044 | }, |
| 12045 | }, |
| 12046 | flags: []string{ |
| 12047 | "-peek-then-read", |
| 12048 | "-check-close-notify", |
| 12049 | }, |
| 12050 | }) |
| 12051 | |
| 12052 | // Test SSL_peek can discover an alert. |
| 12053 | testCases = append(testCases, testCase{ |
| 12054 | name: "Peek-Alert", |
| 12055 | config: Config{ |
| 12056 | Bugs: ProtocolBugs{ |
| 12057 | SendSpuriousAlert: alertRecordOverflow, |
| 12058 | }, |
| 12059 | }, |
| 12060 | flags: []string{"-peek-then-read"}, |
| 12061 | shouldFail: true, |
| 12062 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 12063 | }) |
| 12064 | |
| 12065 | // Test SSL_peek can handle KeyUpdate. |
| 12066 | testCases = append(testCases, testCase{ |
| 12067 | name: "Peek-KeyUpdate", |
| 12068 | config: Config{ |
| 12069 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12070 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 12071 | sendKeyUpdates: 1, |
| 12072 | keyUpdateRequest: keyUpdateNotRequested, |
| 12073 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12074 | }) |
| 12075 | } |
| 12076 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12077 | func addRecordVersionTests() { |
| 12078 | for _, ver := range tlsVersions { |
| 12079 | // Test that the record version is enforced. |
| 12080 | testCases = append(testCases, testCase{ |
| 12081 | name: "CheckRecordVersion-" + ver.name, |
| 12082 | config: Config{ |
| 12083 | MinVersion: ver.version, |
| 12084 | MaxVersion: ver.version, |
| 12085 | Bugs: ProtocolBugs{ |
| 12086 | SendRecordVersion: 0x03ff, |
| 12087 | }, |
| 12088 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12089 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12090 | shouldFail: true, |
| 12091 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 12092 | }) |
| 12093 | |
| 12094 | // Test that the ClientHello may use any record version, for |
| 12095 | // compatibility reasons. |
| 12096 | testCases = append(testCases, testCase{ |
| 12097 | testType: serverTest, |
| 12098 | name: "LooseInitialRecordVersion-" + ver.name, |
| 12099 | config: Config{ |
| 12100 | MinVersion: ver.version, |
| 12101 | MaxVersion: ver.version, |
| 12102 | Bugs: ProtocolBugs{ |
| 12103 | SendInitialRecordVersion: 0x03ff, |
| 12104 | }, |
| 12105 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12106 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12107 | }) |
| 12108 | |
| 12109 | // Test that garbage ClientHello record versions are rejected. |
| 12110 | testCases = append(testCases, testCase{ |
| 12111 | testType: serverTest, |
| 12112 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 12113 | config: Config{ |
| 12114 | MinVersion: ver.version, |
| 12115 | MaxVersion: ver.version, |
| 12116 | Bugs: ProtocolBugs{ |
| 12117 | SendInitialRecordVersion: 0xffff, |
| 12118 | }, |
| 12119 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12120 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12121 | shouldFail: true, |
| 12122 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 12123 | }) |
| 12124 | } |
| 12125 | } |
| 12126 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12127 | func addCertificateTests() { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12128 | for _, ver := range tlsVersions { |
David Benjamin | 3969fdf | 2017-08-29 15:50:58 -0400 | [diff] [blame] | 12129 | // Test that a certificate chain with intermediate may be sent |
| 12130 | // and received as both client and server. |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12131 | testCases = append(testCases, testCase{ |
| 12132 | testType: clientTest, |
| 12133 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 12134 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 12135 | MinVersion: ver.version, |
| 12136 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12137 | Certificates: []Certificate{rsaChainCertificate}, |
| 12138 | ClientAuth: RequireAnyClientCert, |
| 12139 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12140 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12141 | expectPeerCertificate: &rsaChainCertificate, |
| 12142 | flags: []string{ |
| 12143 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12144 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12145 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12146 | }, |
| 12147 | }) |
| 12148 | |
| 12149 | testCases = append(testCases, testCase{ |
| 12150 | testType: serverTest, |
| 12151 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 12152 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 12153 | MinVersion: ver.version, |
| 12154 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12155 | Certificates: []Certificate{rsaChainCertificate}, |
| 12156 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12157 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12158 | expectPeerCertificate: &rsaChainCertificate, |
| 12159 | flags: []string{ |
| 12160 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12161 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12162 | "-require-any-client-certificate", |
| 12163 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12164 | }, |
| 12165 | }) |
David Benjamin | 3969fdf | 2017-08-29 15:50:58 -0400 | [diff] [blame] | 12166 | |
| 12167 | // Test that garbage leaf certificates are properly rejected. |
| 12168 | testCases = append(testCases, testCase{ |
| 12169 | testType: clientTest, |
| 12170 | name: "GarbageCertificate-Client-" + ver.name, |
| 12171 | config: Config{ |
| 12172 | MinVersion: ver.version, |
| 12173 | MaxVersion: ver.version, |
| 12174 | Certificates: []Certificate{garbageCertificate}, |
| 12175 | }, |
| 12176 | tls13Variant: ver.tls13Variant, |
| 12177 | shouldFail: true, |
| 12178 | expectedError: ":CANNOT_PARSE_LEAF_CERT:", |
| 12179 | expectedLocalError: "remote error: error decoding message", |
| 12180 | }) |
| 12181 | |
| 12182 | testCases = append(testCases, testCase{ |
| 12183 | testType: serverTest, |
| 12184 | name: "GarbageCertificate-Server-" + ver.name, |
| 12185 | config: Config{ |
| 12186 | MinVersion: ver.version, |
| 12187 | MaxVersion: ver.version, |
| 12188 | Certificates: []Certificate{garbageCertificate}, |
| 12189 | }, |
| 12190 | tls13Variant: ver.tls13Variant, |
| 12191 | flags: []string{"-require-any-client-certificate"}, |
| 12192 | shouldFail: true, |
| 12193 | expectedError: ":CANNOT_PARSE_LEAF_CERT:", |
| 12194 | expectedLocalError: "remote error: error decoding message", |
| 12195 | }) |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12196 | } |
| 12197 | } |
| 12198 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12199 | func addRetainOnlySHA256ClientCertTests() { |
| 12200 | for _, ver := range tlsVersions { |
| 12201 | // Test that enabling |
| 12202 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 12203 | // actually requesting a client certificate is a no-op. |
| 12204 | testCases = append(testCases, testCase{ |
| 12205 | testType: serverTest, |
| 12206 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 12207 | config: Config{ |
| 12208 | MinVersion: ver.version, |
| 12209 | MaxVersion: ver.version, |
| 12210 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12211 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12212 | flags: []string{ |
David Benjamin | f216507 | 2017-08-23 23:01:37 -0700 | [diff] [blame] | 12213 | "-on-initial-retain-only-sha256-client-cert", |
| 12214 | "-on-resume-retain-only-sha256-client-cert", |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12215 | }, |
| 12216 | resumeSession: true, |
| 12217 | }) |
| 12218 | |
| 12219 | // Test that when retaining only a SHA-256 certificate is |
| 12220 | // enabled, the hash appears as expected. |
| 12221 | testCases = append(testCases, testCase{ |
| 12222 | testType: serverTest, |
| 12223 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 12224 | config: Config{ |
| 12225 | MinVersion: ver.version, |
| 12226 | MaxVersion: ver.version, |
| 12227 | Certificates: []Certificate{rsaCertificate}, |
| 12228 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12229 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12230 | flags: []string{ |
| 12231 | "-verify-peer", |
David Benjamin | f216507 | 2017-08-23 23:01:37 -0700 | [diff] [blame] | 12232 | "-on-initial-retain-only-sha256-client-cert", |
| 12233 | "-on-resume-retain-only-sha256-client-cert", |
| 12234 | "-on-initial-expect-sha256-client-cert", |
| 12235 | "-on-resume-expect-sha256-client-cert", |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12236 | }, |
| 12237 | resumeSession: true, |
| 12238 | }) |
| 12239 | |
| 12240 | // Test that when the config changes from on to off, a |
| 12241 | // resumption is rejected because the server now wants the full |
| 12242 | // certificate chain. |
| 12243 | testCases = append(testCases, testCase{ |
| 12244 | testType: serverTest, |
| 12245 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 12246 | config: Config{ |
| 12247 | MinVersion: ver.version, |
| 12248 | MaxVersion: ver.version, |
| 12249 | Certificates: []Certificate{rsaCertificate}, |
| 12250 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12251 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12252 | flags: []string{ |
| 12253 | "-verify-peer", |
David Benjamin | f216507 | 2017-08-23 23:01:37 -0700 | [diff] [blame] | 12254 | "-on-initial-retain-only-sha256-client-cert", |
| 12255 | "-on-initial-expect-sha256-client-cert", |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12256 | }, |
| 12257 | resumeSession: true, |
| 12258 | expectResumeRejected: true, |
| 12259 | }) |
| 12260 | |
| 12261 | // Test that when the config changes from off to on, a |
| 12262 | // resumption is rejected because the server now wants just the |
| 12263 | // hash. |
| 12264 | testCases = append(testCases, testCase{ |
| 12265 | testType: serverTest, |
| 12266 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 12267 | config: Config{ |
| 12268 | MinVersion: ver.version, |
| 12269 | MaxVersion: ver.version, |
| 12270 | Certificates: []Certificate{rsaCertificate}, |
| 12271 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12272 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12273 | flags: []string{ |
| 12274 | "-verify-peer", |
David Benjamin | f216507 | 2017-08-23 23:01:37 -0700 | [diff] [blame] | 12275 | "-on-resume-retain-only-sha256-client-cert", |
| 12276 | "-on-resume-expect-sha256-client-cert", |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12277 | }, |
| 12278 | resumeSession: true, |
| 12279 | expectResumeRejected: true, |
| 12280 | }) |
| 12281 | } |
| 12282 | } |
| 12283 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12284 | func addECDSAKeyUsageTests() { |
| 12285 | p256 := elliptic.P256() |
| 12286 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 12287 | if err != nil { |
| 12288 | panic(err) |
| 12289 | } |
| 12290 | |
| 12291 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 12292 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 12293 | if err != nil { |
| 12294 | panic(err) |
| 12295 | } |
| 12296 | |
| 12297 | template := x509.Certificate{ |
| 12298 | SerialNumber: serialNumber, |
| 12299 | Subject: pkix.Name{ |
| 12300 | Organization: []string{"Acme Co"}, |
| 12301 | }, |
| 12302 | NotBefore: time.Now(), |
| 12303 | NotAfter: time.Now(), |
| 12304 | |
| 12305 | // An ECC certificate with only the keyAgreement key usgae may |
| 12306 | // be used with ECDH, but not ECDSA. |
| 12307 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 12308 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 12309 | BasicConstraintsValid: true, |
| 12310 | } |
| 12311 | |
| 12312 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 12313 | if err != nil { |
| 12314 | panic(err) |
| 12315 | } |
| 12316 | |
| 12317 | cert := Certificate{ |
| 12318 | Certificate: [][]byte{derBytes}, |
| 12319 | PrivateKey: priv, |
| 12320 | } |
| 12321 | |
| 12322 | for _, ver := range tlsVersions { |
| 12323 | if ver.version < VersionTLS12 { |
| 12324 | continue |
| 12325 | } |
| 12326 | |
| 12327 | testCases = append(testCases, testCase{ |
| 12328 | testType: clientTest, |
| 12329 | name: "ECDSAKeyUsage-" + ver.name, |
| 12330 | config: Config{ |
| 12331 | MinVersion: ver.version, |
| 12332 | MaxVersion: ver.version, |
| 12333 | Certificates: []Certificate{cert}, |
| 12334 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12335 | tls13Variant: ver.tls13Variant, |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12336 | shouldFail: true, |
| 12337 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 12338 | }) |
| 12339 | } |
| 12340 | } |
| 12341 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12342 | func addExtraHandshakeTests() { |
| 12343 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 12344 | // to ensure there is no transport I/O. |
| 12345 | testCases = append(testCases, testCase{ |
| 12346 | testType: clientTest, |
| 12347 | name: "ExtraHandshake-Client-TLS12", |
| 12348 | config: Config{ |
| 12349 | MinVersion: VersionTLS12, |
| 12350 | MaxVersion: VersionTLS12, |
| 12351 | }, |
| 12352 | flags: []string{ |
| 12353 | "-async", |
| 12354 | "-no-op-extra-handshake", |
| 12355 | }, |
| 12356 | }) |
| 12357 | testCases = append(testCases, testCase{ |
| 12358 | testType: serverTest, |
| 12359 | name: "ExtraHandshake-Server-TLS12", |
| 12360 | config: Config{ |
| 12361 | MinVersion: VersionTLS12, |
| 12362 | MaxVersion: VersionTLS12, |
| 12363 | }, |
| 12364 | flags: []string{ |
| 12365 | "-async", |
| 12366 | "-no-op-extra-handshake", |
| 12367 | }, |
| 12368 | }) |
| 12369 | testCases = append(testCases, testCase{ |
| 12370 | testType: clientTest, |
| 12371 | name: "ExtraHandshake-Client-TLS13", |
| 12372 | config: Config{ |
| 12373 | MinVersion: VersionTLS13, |
| 12374 | MaxVersion: VersionTLS13, |
| 12375 | }, |
| 12376 | flags: []string{ |
| 12377 | "-async", |
| 12378 | "-no-op-extra-handshake", |
| 12379 | }, |
| 12380 | }) |
| 12381 | testCases = append(testCases, testCase{ |
| 12382 | testType: serverTest, |
| 12383 | name: "ExtraHandshake-Server-TLS13", |
| 12384 | config: Config{ |
| 12385 | MinVersion: VersionTLS13, |
| 12386 | MaxVersion: VersionTLS13, |
| 12387 | }, |
| 12388 | flags: []string{ |
| 12389 | "-async", |
| 12390 | "-no-op-extra-handshake", |
| 12391 | }, |
| 12392 | }) |
| 12393 | |
| 12394 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 12395 | testCases = append(testCases, testCase{ |
| 12396 | testType: serverTest, |
| 12397 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 12398 | config: Config{ |
| 12399 | MaxVersion: VersionTLS13, |
| 12400 | MinVersion: VersionTLS13, |
| 12401 | Bugs: ProtocolBugs{ |
| 12402 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 12403 | ExpectEarlyDataAccepted: true, |
| 12404 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 12405 | }, |
| 12406 | }, |
| 12407 | messageCount: 2, |
| 12408 | resumeSession: true, |
| 12409 | flags: []string{ |
| 12410 | "-async", |
| 12411 | "-enable-early-data", |
| 12412 | "-expect-accept-early-data", |
| 12413 | "-no-op-extra-handshake", |
| 12414 | }, |
| 12415 | }) |
| 12416 | |
| 12417 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 12418 | // Start. We test this by handshaking twice and asserting the False |
| 12419 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 12420 | // how the test works. |
| 12421 | testCases = append(testCases, testCase{ |
| 12422 | testType: clientTest, |
| 12423 | name: "ExtraHandshake-FalseStart", |
| 12424 | config: Config{ |
| 12425 | MaxVersion: VersionTLS12, |
| 12426 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 12427 | NextProtos: []string{"foo"}, |
| 12428 | Bugs: ProtocolBugs{ |
| 12429 | ExpectFalseStart: true, |
| 12430 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 12431 | }, |
| 12432 | }, |
| 12433 | flags: []string{ |
| 12434 | "-handshake-twice", |
| 12435 | "-false-start", |
| 12436 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 12437 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12438 | }, |
| 12439 | shimWritesFirst: true, |
| 12440 | shouldFail: true, |
| 12441 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 12442 | expectedLocalError: "tls: peer did not false start: EOF", |
| 12443 | }) |
| 12444 | } |
| 12445 | |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12446 | // Test that omitted and empty extensions blocks are tolerated. |
| 12447 | func addOmitExtensionsTests() { |
David Benjamin | 0a47191 | 2017-08-31 00:19:57 -0400 | [diff] [blame] | 12448 | // Check the ExpectOmitExtensions setting works. |
| 12449 | testCases = append(testCases, testCase{ |
| 12450 | testType: serverTest, |
| 12451 | name: "ExpectOmitExtensions", |
| 12452 | config: Config{ |
| 12453 | MinVersion: VersionTLS12, |
| 12454 | MaxVersion: VersionTLS12, |
| 12455 | Bugs: ProtocolBugs{ |
| 12456 | ExpectOmitExtensions: true, |
| 12457 | }, |
| 12458 | }, |
| 12459 | shouldFail: true, |
| 12460 | expectedLocalError: "tls: ServerHello did not omit extensions", |
| 12461 | }) |
| 12462 | |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12463 | for _, ver := range tlsVersions { |
| 12464 | if ver.version > VersionTLS12 { |
| 12465 | continue |
| 12466 | } |
| 12467 | |
| 12468 | testCases = append(testCases, testCase{ |
| 12469 | testType: serverTest, |
| 12470 | name: "OmitExtensions-ClientHello-" + ver.name, |
| 12471 | config: Config{ |
| 12472 | MinVersion: ver.version, |
| 12473 | MaxVersion: ver.version, |
| 12474 | SessionTicketsDisabled: true, |
| 12475 | Bugs: ProtocolBugs{ |
| 12476 | OmitExtensions: true, |
David Benjamin | 0a47191 | 2017-08-31 00:19:57 -0400 | [diff] [blame] | 12477 | // With no client extensions, the ServerHello must not have |
| 12478 | // extensions. It should then omit the extensions field. |
| 12479 | ExpectOmitExtensions: true, |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12480 | }, |
| 12481 | }, |
| 12482 | }) |
| 12483 | |
| 12484 | testCases = append(testCases, testCase{ |
| 12485 | testType: serverTest, |
| 12486 | name: "EmptyExtensions-ClientHello-" + ver.name, |
| 12487 | config: Config{ |
| 12488 | MinVersion: ver.version, |
| 12489 | MaxVersion: ver.version, |
| 12490 | SessionTicketsDisabled: true, |
| 12491 | Bugs: ProtocolBugs{ |
| 12492 | EmptyExtensions: true, |
David Benjamin | 0a47191 | 2017-08-31 00:19:57 -0400 | [diff] [blame] | 12493 | // With no client extensions, the ServerHello must not have |
| 12494 | // extensions. It should then omit the extensions field. |
| 12495 | ExpectOmitExtensions: true, |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12496 | }, |
| 12497 | }, |
| 12498 | }) |
| 12499 | |
| 12500 | testCases = append(testCases, testCase{ |
| 12501 | testType: clientTest, |
| 12502 | name: "OmitExtensions-ServerHello-" + ver.name, |
| 12503 | config: Config{ |
| 12504 | MinVersion: ver.version, |
| 12505 | MaxVersion: ver.version, |
| 12506 | SessionTicketsDisabled: true, |
| 12507 | Bugs: ProtocolBugs{ |
| 12508 | OmitExtensions: true, |
| 12509 | // Disable all ServerHello extensions so |
| 12510 | // OmitExtensions works. |
| 12511 | NoExtendedMasterSecret: true, |
| 12512 | NoRenegotiationInfo: true, |
| 12513 | }, |
| 12514 | }, |
| 12515 | }) |
| 12516 | |
| 12517 | testCases = append(testCases, testCase{ |
| 12518 | testType: clientTest, |
| 12519 | name: "EmptyExtensions-ServerHello-" + ver.name, |
| 12520 | config: Config{ |
| 12521 | MinVersion: ver.version, |
| 12522 | MaxVersion: ver.version, |
| 12523 | SessionTicketsDisabled: true, |
| 12524 | Bugs: ProtocolBugs{ |
| 12525 | EmptyExtensions: true, |
| 12526 | // Disable all ServerHello extensions so |
| 12527 | // EmptyExtensions works. |
| 12528 | NoExtendedMasterSecret: true, |
| 12529 | NoRenegotiationInfo: true, |
| 12530 | }, |
| 12531 | }, |
| 12532 | }) |
| 12533 | } |
| 12534 | } |
| 12535 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12536 | 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] | 12537 | defer wg.Done() |
| 12538 | |
| 12539 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12540 | var err error |
| 12541 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12542 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12543 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 12544 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12545 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12546 | if err != nil { |
| 12547 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 12548 | } |
| 12549 | break |
| 12550 | } |
| 12551 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12552 | } else if *repeatUntilFailure { |
| 12553 | for err == nil { |
| 12554 | statusChan <- statusMsg{test: test, started: true} |
| 12555 | err = runTest(test, shimPath, -1) |
| 12556 | } |
| 12557 | } else { |
| 12558 | statusChan <- statusMsg{test: test, started: true} |
| 12559 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12560 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12561 | statusChan <- statusMsg{test: test, err: err} |
| 12562 | } |
| 12563 | } |
| 12564 | |
| 12565 | type statusMsg struct { |
| 12566 | test *testCase |
| 12567 | started bool |
| 12568 | err error |
| 12569 | } |
| 12570 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12571 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12572 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12573 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12574 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12575 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12576 | if !*pipe { |
| 12577 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 12578 | var erase string |
| 12579 | for i := 0; i < lineLen; i++ { |
| 12580 | erase += "\b \b" |
| 12581 | } |
| 12582 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12583 | } |
| 12584 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12585 | if msg.started { |
| 12586 | started++ |
| 12587 | } else { |
| 12588 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12589 | |
| 12590 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12591 | if msg.err == errUnimplemented { |
| 12592 | if *pipe { |
| 12593 | // Print each test instead of a status line. |
| 12594 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 12595 | } |
| 12596 | unimplemented++ |
| 12597 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 12598 | } else { |
| 12599 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 12600 | failed++ |
| 12601 | testOutput.addResult(msg.test.name, "FAIL") |
| 12602 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12603 | } else { |
| 12604 | if *pipe { |
| 12605 | // Print each test instead of a status line. |
| 12606 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 12607 | } |
| 12608 | testOutput.addResult(msg.test.name, "PASS") |
| 12609 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12610 | } |
| 12611 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12612 | if !*pipe { |
| 12613 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12614 | 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] | 12615 | lineLen = len(line) |
| 12616 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12617 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12618 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12619 | |
| 12620 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12621 | } |
| 12622 | |
| 12623 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12624 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12625 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 12626 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12627 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12628 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12629 | addCipherSuiteTests() |
| 12630 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12631 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 12632 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 12633 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 12634 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 12635 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 12636 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 12637 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 12638 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 12639 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 12640 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 12641 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 12642 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 12643 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 12644 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 12645 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 12646 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 12647 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 12648 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 12649 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 12650 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 12651 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 12652 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 12653 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 12654 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12655 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12656 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12657 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12658 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12659 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12660 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12661 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12662 | addExtraHandshakeTests() |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12663 | addOmitExtensionsTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12664 | |
| 12665 | var wg sync.WaitGroup |
| 12666 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12667 | statusChan := make(chan statusMsg, *numWorkers) |
| 12668 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12669 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12670 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12671 | if len(*shimConfigFile) != 0 { |
| 12672 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 12673 | if err != nil { |
| 12674 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 12675 | os.Exit(1) |
| 12676 | } |
| 12677 | |
| 12678 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 12679 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 12680 | os.Exit(1) |
| 12681 | } |
| 12682 | } |
| 12683 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12684 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12685 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12686 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12687 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12688 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12689 | } |
| 12690 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12691 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12692 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12693 | matched := true |
| 12694 | if len(*testToRun) != 0 { |
| 12695 | var err error |
| 12696 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 12697 | if err != nil { |
| 12698 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 12699 | os.Exit(1) |
| 12700 | } |
| 12701 | } |
| 12702 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12703 | if !*includeDisabled { |
| 12704 | for pattern := range shimConfig.DisabledTests { |
| 12705 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 12706 | if err != nil { |
| 12707 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 12708 | os.Exit(1) |
| 12709 | } |
| 12710 | |
| 12711 | if isDisabled { |
| 12712 | matched = false |
| 12713 | break |
| 12714 | } |
| 12715 | } |
| 12716 | } |
| 12717 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12718 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12719 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12720 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12721 | |
| 12722 | // Only run one test if repeating until failure. |
| 12723 | if *repeatUntilFailure { |
| 12724 | break |
| 12725 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12726 | } |
| 12727 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12728 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12729 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12730 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12731 | os.Exit(1) |
| 12732 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12733 | |
| 12734 | close(testChan) |
| 12735 | wg.Wait() |
| 12736 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12737 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12738 | |
| 12739 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12740 | |
| 12741 | if *jsonOutput != "" { |
| 12742 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 12743 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 12744 | } |
| 12745 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12746 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12747 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 12748 | os.Exit(1) |
| 12749 | } |
| 12750 | |
| 12751 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12752 | os.Exit(1) |
| 12753 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12754 | } |