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 |
| 85 | } |
| 86 | |
| 87 | var shimConfig ShimConfiguration |
| 88 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 89 | type testCert int |
| 90 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 91 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 92 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 93 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 94 | testCertRSAChain |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 95 | testCertECDSAP224 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 96 | testCertECDSAP256 |
| 97 | testCertECDSAP384 |
| 98 | testCertECDSAP521 |
| 99 | ) |
| 100 | |
| 101 | const ( |
| 102 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 103 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 104 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 105 | ecdsaP224CertificateFile = "ecdsa_p224_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 106 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 107 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 108 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 109 | ) |
| 110 | |
| 111 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 112 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 113 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 114 | rsaChainKeyFile = "rsa_chain_key.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 115 | ecdsaP224KeyFile = "ecdsa_p224_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 116 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 117 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 118 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 119 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 120 | ) |
| 121 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 122 | var ( |
| 123 | rsaCertificate Certificate |
| 124 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 125 | rsaChainCertificate Certificate |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 126 | ecdsaP224Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 127 | ecdsaP256Certificate Certificate |
| 128 | ecdsaP384Certificate Certificate |
| 129 | ecdsaP521Certificate Certificate |
| 130 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 131 | |
| 132 | var testCerts = []struct { |
| 133 | id testCert |
| 134 | certFile, keyFile string |
| 135 | cert *Certificate |
| 136 | }{ |
| 137 | { |
| 138 | id: testCertRSA, |
| 139 | certFile: rsaCertificateFile, |
| 140 | keyFile: rsaKeyFile, |
| 141 | cert: &rsaCertificate, |
| 142 | }, |
| 143 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 144 | id: testCertRSA1024, |
| 145 | certFile: rsa1024CertificateFile, |
| 146 | keyFile: rsa1024KeyFile, |
| 147 | cert: &rsa1024Certificate, |
| 148 | }, |
| 149 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 150 | id: testCertRSAChain, |
| 151 | certFile: rsaChainCertificateFile, |
| 152 | keyFile: rsaChainKeyFile, |
| 153 | cert: &rsaChainCertificate, |
| 154 | }, |
| 155 | { |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 156 | id: testCertECDSAP224, |
| 157 | certFile: ecdsaP224CertificateFile, |
| 158 | keyFile: ecdsaP224KeyFile, |
| 159 | cert: &ecdsaP224Certificate, |
| 160 | }, |
| 161 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 162 | id: testCertECDSAP256, |
| 163 | certFile: ecdsaP256CertificateFile, |
| 164 | keyFile: ecdsaP256KeyFile, |
| 165 | cert: &ecdsaP256Certificate, |
| 166 | }, |
| 167 | { |
| 168 | id: testCertECDSAP384, |
| 169 | certFile: ecdsaP384CertificateFile, |
| 170 | keyFile: ecdsaP384KeyFile, |
| 171 | cert: &ecdsaP384Certificate, |
| 172 | }, |
| 173 | { |
| 174 | id: testCertECDSAP521, |
| 175 | certFile: ecdsaP521CertificateFile, |
| 176 | keyFile: ecdsaP521KeyFile, |
| 177 | cert: &ecdsaP521Certificate, |
| 178 | }, |
| 179 | } |
| 180 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 181 | var channelIDKey *ecdsa.PrivateKey |
| 182 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 183 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 184 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 185 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 186 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 187 | 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] | 188 | 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] | 189 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 190 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 191 | for i := range testCerts { |
| 192 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 193 | if err != nil { |
| 194 | panic(err) |
| 195 | } |
| 196 | cert.OCSPStaple = testOCSPResponse |
| 197 | cert.SignedCertificateTimestampList = testSCTList |
| 198 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 199 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 200 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 201 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 202 | if err != nil { |
| 203 | panic(err) |
| 204 | } |
| 205 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 206 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 207 | panic("bad key type") |
| 208 | } |
| 209 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 210 | if err != nil { |
| 211 | panic(err) |
| 212 | } |
| 213 | if channelIDKey.Curve != elliptic.P256() { |
| 214 | panic("bad curve") |
| 215 | } |
| 216 | |
| 217 | channelIDBytes = make([]byte, 64) |
| 218 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 219 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 220 | } |
| 221 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 222 | func getRunnerCertificate(t testCert) Certificate { |
| 223 | for _, cert := range testCerts { |
| 224 | if cert.id == t { |
| 225 | return *cert.cert |
| 226 | } |
| 227 | } |
| 228 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 229 | } |
| 230 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 231 | func getShimCertificate(t testCert) string { |
| 232 | for _, cert := range testCerts { |
| 233 | if cert.id == t { |
| 234 | return cert.certFile |
| 235 | } |
| 236 | } |
| 237 | panic("Unknown test certificate") |
| 238 | } |
| 239 | |
| 240 | func getShimKey(t testCert) string { |
| 241 | for _, cert := range testCerts { |
| 242 | if cert.id == t { |
| 243 | return cert.keyFile |
| 244 | } |
| 245 | } |
| 246 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 249 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 250 | func encodeDERValues(values [][]byte) string { |
| 251 | var ret string |
| 252 | for i, v := range values { |
| 253 | if i > 0 { |
| 254 | ret += "," |
| 255 | } |
| 256 | ret += hex.EncodeToString(v) |
| 257 | } |
| 258 | |
| 259 | return ret |
| 260 | } |
| 261 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 262 | type testType int |
| 263 | |
| 264 | const ( |
| 265 | clientTest testType = iota |
| 266 | serverTest |
| 267 | ) |
| 268 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 269 | type protocol int |
| 270 | |
| 271 | const ( |
| 272 | tls protocol = iota |
| 273 | dtls |
| 274 | ) |
| 275 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 276 | const ( |
| 277 | alpn = 1 |
| 278 | npn = 2 |
| 279 | ) |
| 280 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 281 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 282 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 283 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 284 | name string |
| 285 | config Config |
| 286 | shouldFail bool |
| 287 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 288 | // expectedLocalError, if not empty, contains a substring that must be |
| 289 | // found in the local error. |
| 290 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 291 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 292 | // negotiated. |
| 293 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 294 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 295 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 296 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 297 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 298 | // should be negotiated. |
| 299 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 300 | // expectChannelID controls whether the connection should have |
| 301 | // negotiated a Channel ID with channelIDKey. |
| 302 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 303 | // expectedNextProto controls whether the connection should |
| 304 | // negotiate a next protocol via NPN or ALPN. |
| 305 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 306 | // expectNoNextProto, if true, means that no next protocol should be |
| 307 | // negotiated. |
| 308 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 309 | // expectedNextProtoType, if non-zero, is the expected next |
| 310 | // protocol negotiation mechanism. |
| 311 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 312 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 313 | // should be negotiated. If zero, none should be negotiated. |
| 314 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 315 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 316 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 317 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 318 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 319 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 320 | // algorithm that the peer should have used in the handshake. |
| 321 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 322 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 323 | // have used. |
| 324 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 325 | // messageLen is the length, in bytes, of the test message that will be |
| 326 | // sent. |
| 327 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 328 | // messageCount is the number of test messages that will be sent. |
| 329 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 330 | // certFile is the path to the certificate to use for the server. |
| 331 | certFile string |
| 332 | // keyFile is the path to the private key to use for the server. |
| 333 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 334 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 335 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 336 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 337 | // resumeRenewedSession controls whether a third connection should be |
| 338 | // tested which attempts to resume the second connection's session. |
| 339 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 340 | // expectResumeRejected, if true, specifies that the attempted |
| 341 | // resumption must be rejected by the client. This is only valid for a |
| 342 | // serverTest. |
| 343 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 344 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 345 | // resumption. Unless newSessionsOnResume is set, |
| 346 | // SessionTicketKey, ServerSessionCache, and |
| 347 | // ClientSessionCache are copied from the initial connection's |
| 348 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 349 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 350 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 351 | // use a different session resumption context. |
| 352 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 353 | // noSessionCache, if true, will cause the server to run without a |
| 354 | // session cache. |
| 355 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 356 | // sendPrefix sends a prefix on the socket before actually performing a |
| 357 | // handshake. |
| 358 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 359 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 360 | // message before doing a roundtrip with the runner. |
| 361 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 362 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 363 | // connection immediately after the handshake rather than echoing |
| 364 | // messages from the runner. |
| 365 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 366 | // renegotiate indicates the number of times the connection should be |
| 367 | // renegotiated during the exchange. |
| 368 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 369 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 370 | // HelloRequest when the handshake completes. |
| 371 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 372 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 373 | // switched in just before renegotiation. |
| 374 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 375 | // replayWrites, if true, configures the underlying transport |
| 376 | // to replay every write it makes in DTLS tests. |
| 377 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 378 | // damageFirstWrite, if true, configures the underlying transport to |
| 379 | // damage the final byte of the first application data write. |
| 380 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 381 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 382 | // keying material and verify they match. |
| 383 | exportKeyingMaterial int |
| 384 | exportLabel string |
| 385 | exportContext string |
| 386 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 387 | // flags, if not empty, contains a list of command-line flags that will |
| 388 | // be passed to the shim program. |
| 389 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 390 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 391 | // which will be compared against the expected value. |
| 392 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 393 | // sendEmptyRecords is the number of consecutive empty records to send |
| 394 | // before and after the test message. |
| 395 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 396 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 397 | // before and after the test message. |
| 398 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 399 | // sendKeyUpdates is the number of consecutive key updates to send |
| 400 | // before and after the test message. |
| 401 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 402 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 403 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 404 | // expectMessageDropped, if true, means the test message is expected to |
| 405 | // be dropped by the client rather than echoed back. |
| 406 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 407 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 408 | // is expected to send. |
| 409 | expectPeerCertificate *Certificate |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 410 | // expectShortHeader is whether the short header extension should be negotiated. |
| 411 | expectShortHeader bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 414 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 415 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 416 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 417 | if len(data) == 0 { |
| 418 | return |
| 419 | } |
| 420 | |
| 421 | protocol := "tls" |
| 422 | if test.protocol == dtls { |
| 423 | protocol = "dtls" |
| 424 | } |
| 425 | |
| 426 | side := "client" |
| 427 | if test.testType == serverTest { |
| 428 | side = "server" |
| 429 | } |
| 430 | |
| 431 | dir := path.Join(*transcriptDir, protocol, side) |
| 432 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 433 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 434 | return |
| 435 | } |
| 436 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 437 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 438 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 439 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 440 | } |
| 441 | } |
| 442 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 443 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 444 | type timeoutConn struct { |
| 445 | net.Conn |
| 446 | timeout time.Duration |
| 447 | } |
| 448 | |
| 449 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 450 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 451 | return 0, err |
| 452 | } |
| 453 | return t.Conn.Read(b) |
| 454 | } |
| 455 | |
| 456 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 457 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 458 | return 0, err |
| 459 | } |
| 460 | return t.Conn.Write(b) |
| 461 | } |
| 462 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 463 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 464 | if !test.noSessionCache { |
| 465 | if config.ClientSessionCache == nil { |
| 466 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 467 | } |
| 468 | if config.ServerSessionCache == nil { |
| 469 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 470 | } |
| 471 | } |
| 472 | if test.testType == clientTest { |
| 473 | if len(config.Certificates) == 0 { |
| 474 | config.Certificates = []Certificate{rsaCertificate} |
| 475 | } |
| 476 | } else { |
| 477 | // Supply a ServerName to ensure a constant session cache key, |
| 478 | // rather than falling back to net.Conn.RemoteAddr. |
| 479 | if len(config.ServerName) == 0 { |
| 480 | config.ServerName = "test" |
| 481 | } |
| 482 | } |
| 483 | if *fuzzer { |
| 484 | config.Bugs.NullAllCiphers = true |
| 485 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 486 | if *deterministic { |
| 487 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 488 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 489 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 490 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 491 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 492 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 493 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 494 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 495 | } |
| 496 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 497 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 498 | local, peer := "client", "server" |
| 499 | if test.testType == clientTest { |
| 500 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 501 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 502 | connDebug := &recordingConn{ |
| 503 | Conn: conn, |
| 504 | isDatagram: test.protocol == dtls, |
| 505 | local: local, |
| 506 | peer: peer, |
| 507 | } |
| 508 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 509 | if *flagDebug { |
| 510 | defer connDebug.WriteTo(os.Stdout) |
| 511 | } |
| 512 | if len(*transcriptDir) != 0 { |
| 513 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 514 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 515 | }() |
| 516 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 517 | |
| 518 | if config.Bugs.PacketAdaptor != nil { |
| 519 | config.Bugs.PacketAdaptor.debug = connDebug |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | if test.replayWrites { |
| 524 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 525 | } |
| 526 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 527 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 528 | if test.damageFirstWrite { |
| 529 | connDamage = newDamageAdaptor(conn) |
| 530 | conn = connDamage |
| 531 | } |
| 532 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 533 | if test.sendPrefix != "" { |
| 534 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 535 | return err |
| 536 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 537 | } |
| 538 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 539 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 540 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 541 | if test.protocol == dtls { |
| 542 | tlsConn = DTLSServer(conn, config) |
| 543 | } else { |
| 544 | tlsConn = Server(conn, config) |
| 545 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 546 | } else { |
| 547 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 548 | if test.protocol == dtls { |
| 549 | tlsConn = DTLSClient(conn, config) |
| 550 | } else { |
| 551 | tlsConn = Client(conn, config) |
| 552 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 553 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 554 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 555 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 556 | if err := tlsConn.Handshake(); err != nil { |
| 557 | return err |
| 558 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 559 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 560 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 561 | // expectations struct that can be specified separately for the two |
| 562 | // legs. |
| 563 | expectedVersion := test.expectedVersion |
| 564 | if isResume && test.expectedResumeVersion != 0 { |
| 565 | expectedVersion = test.expectedResumeVersion |
| 566 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 567 | connState := tlsConn.ConnectionState() |
| 568 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 569 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 570 | } |
| 571 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 572 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 573 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 574 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 575 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 576 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 577 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 578 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 579 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 580 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 581 | if channelID == nil { |
| 582 | return fmt.Errorf("no channel ID negotiated") |
| 583 | } |
| 584 | if channelID.Curve != channelIDKey.Curve || |
| 585 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 586 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 587 | return fmt.Errorf("incorrect channel ID") |
| 588 | } |
| 589 | } |
| 590 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 591 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 592 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 593 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 594 | } |
| 595 | } |
| 596 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 597 | if test.expectNoNextProto { |
| 598 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 599 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 600 | } |
| 601 | } |
| 602 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 603 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 604 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 605 | return fmt.Errorf("next proto type mismatch") |
| 606 | } |
| 607 | } |
| 608 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 609 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 610 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 611 | } |
| 612 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 613 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 614 | 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] | 615 | } |
| 616 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 617 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 618 | return fmt.Errorf("SCT list mismatch") |
| 619 | } |
| 620 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 621 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 622 | 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] | 623 | } |
| 624 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 625 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 626 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 627 | } |
| 628 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 629 | if test.expectPeerCertificate != nil { |
| 630 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 631 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 632 | } |
| 633 | for i, cert := range connState.PeerCertificates { |
| 634 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 635 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 640 | if test.expectShortHeader != connState.ShortHeader { |
| 641 | return fmt.Errorf("ShortHeader is %t, but we expected the opposite", connState.ShortHeader) |
| 642 | } |
| 643 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 644 | if test.exportKeyingMaterial > 0 { |
| 645 | actual := make([]byte, test.exportKeyingMaterial) |
| 646 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 647 | return err |
| 648 | } |
| 649 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 650 | if err != nil { |
| 651 | return err |
| 652 | } |
| 653 | if !bytes.Equal(actual, expected) { |
| 654 | return fmt.Errorf("keying material mismatch") |
| 655 | } |
| 656 | } |
| 657 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 658 | if test.testTLSUnique { |
| 659 | var peersValue [12]byte |
| 660 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 661 | return err |
| 662 | } |
| 663 | expected := tlsConn.ConnectionState().TLSUnique |
| 664 | if !bytes.Equal(peersValue[:], expected) { |
| 665 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 666 | } |
| 667 | } |
| 668 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 669 | if test.shimWritesFirst { |
| 670 | var buf [5]byte |
| 671 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 672 | if err != nil { |
| 673 | return err |
| 674 | } |
| 675 | if string(buf[:]) != "hello" { |
| 676 | return fmt.Errorf("bad initial message") |
| 677 | } |
| 678 | } |
| 679 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 680 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 681 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 682 | return err |
| 683 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 684 | } |
| 685 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 686 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 687 | tlsConn.Write(nil) |
| 688 | } |
| 689 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 690 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 691 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 692 | } |
| 693 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 694 | if test.sendHalfHelloRequest { |
| 695 | tlsConn.SendHalfHelloRequest() |
| 696 | } |
| 697 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 698 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 699 | if test.renegotiateCiphers != nil { |
| 700 | config.CipherSuites = test.renegotiateCiphers |
| 701 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 702 | for i := 0; i < test.renegotiate; i++ { |
| 703 | if err := tlsConn.Renegotiate(); err != nil { |
| 704 | return err |
| 705 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 706 | } |
| 707 | } else if test.renegotiateCiphers != nil { |
| 708 | panic("renegotiateCiphers without renegotiate") |
| 709 | } |
| 710 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 711 | if test.damageFirstWrite { |
| 712 | connDamage.setDamage(true) |
| 713 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 714 | connDamage.setDamage(false) |
| 715 | } |
| 716 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 717 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 718 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 719 | if test.protocol == dtls { |
| 720 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 721 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 722 | // Read until EOF. |
| 723 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 724 | return err |
| 725 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 726 | if messageLen == 0 { |
| 727 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 728 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 729 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 730 | messageCount := test.messageCount |
| 731 | if messageCount == 0 { |
| 732 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 733 | } |
| 734 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 735 | for j := 0; j < messageCount; j++ { |
| 736 | testMessage := make([]byte, messageLen) |
| 737 | for i := range testMessage { |
| 738 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 739 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 740 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 741 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 742 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 743 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 744 | } |
| 745 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 746 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 747 | tlsConn.Write(nil) |
| 748 | } |
| 749 | |
| 750 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 751 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 752 | } |
| 753 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 754 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 755 | // The shim will not respond. |
| 756 | continue |
| 757 | } |
| 758 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 759 | buf := make([]byte, len(testMessage)) |
| 760 | if test.protocol == dtls { |
| 761 | bufTmp := make([]byte, len(buf)+1) |
| 762 | n, err := tlsConn.Read(bufTmp) |
| 763 | if err != nil { |
| 764 | return err |
| 765 | } |
| 766 | if n != len(buf) { |
| 767 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 768 | } |
| 769 | copy(buf, bufTmp) |
| 770 | } else { |
| 771 | _, err := io.ReadFull(tlsConn, buf) |
| 772 | if err != nil { |
| 773 | return err |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | for i, v := range buf { |
| 778 | if v != testMessage[i]^0xff { |
| 779 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 780 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 781 | } |
| 782 | } |
| 783 | |
| 784 | return nil |
| 785 | } |
| 786 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 787 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 788 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 789 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 790 | 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] | 791 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 792 | valgrindArgs = append(valgrindArgs, path) |
| 793 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 794 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 795 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 796 | } |
| 797 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 798 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 799 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 800 | xtermArgs = append(xtermArgs, path) |
| 801 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 802 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 803 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 804 | } |
| 805 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 806 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 807 | xtermArgs := []string{"-e", "lldb", "--"} |
| 808 | xtermArgs = append(xtermArgs, path) |
| 809 | xtermArgs = append(xtermArgs, args...) |
| 810 | |
| 811 | return exec.Command("xterm", xtermArgs...) |
| 812 | } |
| 813 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 814 | var ( |
| 815 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 816 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 817 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 818 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 819 | // accept accepts a connection from listener, unless waitChan signals a process |
| 820 | // exit first. |
| 821 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 822 | type connOrError struct { |
| 823 | conn net.Conn |
| 824 | err error |
| 825 | } |
| 826 | connChan := make(chan connOrError, 1) |
| 827 | go func() { |
| 828 | conn, err := listener.Accept() |
| 829 | connChan <- connOrError{conn, err} |
| 830 | close(connChan) |
| 831 | }() |
| 832 | select { |
| 833 | case result := <-connChan: |
| 834 | return result.conn, result.err |
| 835 | case childErr := <-waitChan: |
| 836 | waitChan <- childErr |
| 837 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 838 | } |
| 839 | } |
| 840 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 841 | func translateExpectedError(errorStr string) string { |
| 842 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 843 | return translated |
| 844 | } |
| 845 | |
| 846 | if *looseErrors { |
| 847 | return "" |
| 848 | } |
| 849 | |
| 850 | return errorStr |
| 851 | } |
| 852 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 853 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 854 | // Help debugging panics on the Go side. |
| 855 | defer func() { |
| 856 | if r := recover(); r != nil { |
| 857 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 858 | panic(r) |
| 859 | } |
| 860 | }() |
| 861 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 862 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 863 | panic("Error expected without shouldFail in " + test.name) |
| 864 | } |
| 865 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 866 | if test.expectResumeRejected && !test.resumeSession { |
| 867 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 868 | } |
| 869 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 870 | for _, ver := range tlsVersions { |
| 871 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 872 | continue |
| 873 | } |
| 874 | |
| 875 | if test.config.MaxVersion != 0 || test.config.MinVersion != 0 || test.expectedVersion != 0 { |
| 876 | continue |
| 877 | } |
| 878 | |
| 879 | 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)) |
| 880 | } |
| 881 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 882 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 883 | if err != nil { |
| 884 | panic(err) |
| 885 | } |
| 886 | defer func() { |
| 887 | if listener != nil { |
| 888 | listener.Close() |
| 889 | } |
| 890 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 891 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 892 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 893 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 894 | flags = append(flags, "-server") |
| 895 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 896 | flags = append(flags, "-key-file") |
| 897 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 898 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 899 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 900 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | flags = append(flags, "-cert-file") |
| 904 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 905 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 906 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 907 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 908 | } |
| 909 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 910 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 911 | if test.protocol == dtls { |
| 912 | flags = append(flags, "-dtls") |
| 913 | } |
| 914 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 915 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 916 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 917 | resumeCount++ |
| 918 | if test.resumeRenewedSession { |
| 919 | resumeCount++ |
| 920 | } |
| 921 | } |
| 922 | |
| 923 | if resumeCount > 0 { |
| 924 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 925 | } |
| 926 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 927 | if test.shimWritesFirst { |
| 928 | flags = append(flags, "-shim-writes-first") |
| 929 | } |
| 930 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 931 | if test.shimShutsDown { |
| 932 | flags = append(flags, "-shim-shuts-down") |
| 933 | } |
| 934 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 935 | if test.exportKeyingMaterial > 0 { |
| 936 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 937 | flags = append(flags, "-export-label", test.exportLabel) |
| 938 | flags = append(flags, "-export-context", test.exportContext) |
| 939 | if test.useExportContext { |
| 940 | flags = append(flags, "-use-export-context") |
| 941 | } |
| 942 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 943 | if test.expectResumeRejected { |
| 944 | flags = append(flags, "-expect-session-miss") |
| 945 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 946 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 947 | if test.testTLSUnique { |
| 948 | flags = append(flags, "-tls-unique") |
| 949 | } |
| 950 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 951 | flags = append(flags, test.flags...) |
| 952 | |
| 953 | var shim *exec.Cmd |
| 954 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 955 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 956 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 957 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 958 | } else if *useLLDB { |
| 959 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 960 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 961 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 962 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 963 | shim.Stdin = os.Stdin |
| 964 | var stdoutBuf, stderrBuf bytes.Buffer |
| 965 | shim.Stdout = &stdoutBuf |
| 966 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 967 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 968 | shim.Env = os.Environ() |
| 969 | 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] | 970 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 971 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 972 | } |
| 973 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 974 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 975 | |
| 976 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 977 | panic(err) |
| 978 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 979 | waitChan := make(chan error, 1) |
| 980 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 981 | |
| 982 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 983 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 984 | if *deterministic { |
| 985 | config.Rand = &deterministicRand{} |
| 986 | } |
| 987 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 988 | conn, err := acceptOrWait(listener, waitChan) |
| 989 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 990 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 991 | conn.Close() |
| 992 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 993 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 994 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 995 | var resumeConfig Config |
| 996 | if test.resumeConfig != nil { |
| 997 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 998 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 999 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1000 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1001 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1002 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1003 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1004 | } else { |
| 1005 | resumeConfig = config |
| 1006 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1007 | var connResume net.Conn |
| 1008 | connResume, err = acceptOrWait(listener, waitChan) |
| 1009 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 1010 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1011 | connResume.Close() |
| 1012 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1013 | } |
| 1014 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1015 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1016 | // open more connections than expected. |
| 1017 | listener.Close() |
| 1018 | listener = nil |
| 1019 | |
| 1020 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1021 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1022 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1023 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1024 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1025 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1026 | case 89: |
| 1027 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1028 | case 99: |
| 1029 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1030 | } |
| 1031 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1032 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1033 | // Account for Windows line endings. |
| 1034 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1035 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1036 | |
| 1037 | // Separate the errors from the shim and those from tools like |
| 1038 | // AddressSanitizer. |
| 1039 | var extraStderr string |
| 1040 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1041 | stderr = stderrParts[0] |
| 1042 | extraStderr = stderrParts[1] |
| 1043 | } |
| 1044 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1045 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1046 | expectedError := translateExpectedError(test.expectedError) |
| 1047 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1048 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1049 | localError := "none" |
| 1050 | if err != nil { |
| 1051 | localError = err.Error() |
| 1052 | } |
| 1053 | if len(test.expectedLocalError) != 0 { |
| 1054 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1055 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1056 | |
| 1057 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1058 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1059 | if childErr != nil { |
| 1060 | childError = childErr.Error() |
| 1061 | } |
| 1062 | |
| 1063 | var msg string |
| 1064 | switch { |
| 1065 | case failed && !test.shouldFail: |
| 1066 | msg = "unexpected failure" |
| 1067 | case !failed && test.shouldFail: |
| 1068 | msg = "unexpected success" |
| 1069 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1070 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1071 | default: |
| 1072 | panic("internal error") |
| 1073 | } |
| 1074 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1075 | 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] | 1076 | } |
| 1077 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1078 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1079 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1082 | if *useValgrind && isValgrindError { |
| 1083 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1084 | } |
| 1085 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1086 | return nil |
| 1087 | } |
| 1088 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1089 | type tlsVersion struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1090 | name string |
| 1091 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1092 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1093 | hasDTLS bool |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | var tlsVersions = []tlsVersion{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1097 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1098 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1099 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1100 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1101 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1104 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1105 | name string |
| 1106 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1110 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1111 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1112 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1113 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1114 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1115 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1116 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1117 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1118 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1119 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1120 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1121 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1122 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1123 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1124 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1125 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1126 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1127 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1128 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1129 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1130 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1131 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1132 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1133 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1134 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1135 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1136 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1137 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1138 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1139 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1140 | {"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] | 1141 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1142 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1143 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1144 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1145 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1146 | } |
| 1147 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1148 | func hasComponent(suiteName, component string) bool { |
| 1149 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1150 | } |
| 1151 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1152 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1153 | return hasComponent(suiteName, "GCM") || |
| 1154 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1155 | hasComponent(suiteName, "SHA384") || |
| 1156 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1157 | } |
| 1158 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1159 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1160 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1163 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1164 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1165 | } |
| 1166 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1167 | func bigFromHex(hex string) *big.Int { |
| 1168 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1169 | if !ok { |
| 1170 | panic("failed to parse hex number 0x" + hex) |
| 1171 | } |
| 1172 | return ret |
| 1173 | } |
| 1174 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1175 | func addBasicTests() { |
| 1176 | basicTests := []testCase{ |
| 1177 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1178 | name: "NoFallbackSCSV", |
| 1179 | config: Config{ |
| 1180 | Bugs: ProtocolBugs{ |
| 1181 | FailIfNotFallbackSCSV: true, |
| 1182 | }, |
| 1183 | }, |
| 1184 | shouldFail: true, |
| 1185 | expectedLocalError: "no fallback SCSV found", |
| 1186 | }, |
| 1187 | { |
| 1188 | name: "SendFallbackSCSV", |
| 1189 | config: Config{ |
| 1190 | Bugs: ProtocolBugs{ |
| 1191 | FailIfNotFallbackSCSV: true, |
| 1192 | }, |
| 1193 | }, |
| 1194 | flags: []string{"-fallback-scsv"}, |
| 1195 | }, |
| 1196 | { |
| 1197 | name: "ClientCertificateTypes", |
| 1198 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1199 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1200 | ClientAuth: RequestClientCert, |
| 1201 | ClientCertificateTypes: []byte{ |
| 1202 | CertTypeDSSSign, |
| 1203 | CertTypeRSASign, |
| 1204 | CertTypeECDSASign, |
| 1205 | }, |
| 1206 | }, |
| 1207 | flags: []string{ |
| 1208 | "-expect-certificate-types", |
| 1209 | base64.StdEncoding.EncodeToString([]byte{ |
| 1210 | CertTypeDSSSign, |
| 1211 | CertTypeRSASign, |
| 1212 | CertTypeECDSASign, |
| 1213 | }), |
| 1214 | }, |
| 1215 | }, |
| 1216 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1217 | name: "UnauthenticatedECDH", |
| 1218 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1219 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1220 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1221 | Bugs: ProtocolBugs{ |
| 1222 | UnauthenticatedECDH: true, |
| 1223 | }, |
| 1224 | }, |
| 1225 | shouldFail: true, |
| 1226 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1227 | }, |
| 1228 | { |
| 1229 | name: "SkipCertificateStatus", |
| 1230 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1231 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1232 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1233 | Bugs: ProtocolBugs{ |
| 1234 | SkipCertificateStatus: true, |
| 1235 | }, |
| 1236 | }, |
| 1237 | flags: []string{ |
| 1238 | "-enable-ocsp-stapling", |
| 1239 | }, |
| 1240 | }, |
| 1241 | { |
| 1242 | name: "SkipServerKeyExchange", |
| 1243 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1244 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1245 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1246 | Bugs: ProtocolBugs{ |
| 1247 | SkipServerKeyExchange: true, |
| 1248 | }, |
| 1249 | }, |
| 1250 | shouldFail: true, |
| 1251 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1252 | }, |
| 1253 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1254 | testType: serverTest, |
| 1255 | name: "Alert", |
| 1256 | config: Config{ |
| 1257 | Bugs: ProtocolBugs{ |
| 1258 | SendSpuriousAlert: alertRecordOverflow, |
| 1259 | }, |
| 1260 | }, |
| 1261 | shouldFail: true, |
| 1262 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1263 | }, |
| 1264 | { |
| 1265 | protocol: dtls, |
| 1266 | testType: serverTest, |
| 1267 | name: "Alert-DTLS", |
| 1268 | config: Config{ |
| 1269 | Bugs: ProtocolBugs{ |
| 1270 | SendSpuriousAlert: alertRecordOverflow, |
| 1271 | }, |
| 1272 | }, |
| 1273 | shouldFail: true, |
| 1274 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1275 | }, |
| 1276 | { |
| 1277 | testType: serverTest, |
| 1278 | name: "FragmentAlert", |
| 1279 | config: Config{ |
| 1280 | Bugs: ProtocolBugs{ |
| 1281 | FragmentAlert: true, |
| 1282 | SendSpuriousAlert: alertRecordOverflow, |
| 1283 | }, |
| 1284 | }, |
| 1285 | shouldFail: true, |
| 1286 | expectedError: ":BAD_ALERT:", |
| 1287 | }, |
| 1288 | { |
| 1289 | protocol: dtls, |
| 1290 | testType: serverTest, |
| 1291 | name: "FragmentAlert-DTLS", |
| 1292 | config: Config{ |
| 1293 | Bugs: ProtocolBugs{ |
| 1294 | FragmentAlert: true, |
| 1295 | SendSpuriousAlert: alertRecordOverflow, |
| 1296 | }, |
| 1297 | }, |
| 1298 | shouldFail: true, |
| 1299 | expectedError: ":BAD_ALERT:", |
| 1300 | }, |
| 1301 | { |
| 1302 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1303 | name: "DoubleAlert", |
| 1304 | config: Config{ |
| 1305 | Bugs: ProtocolBugs{ |
| 1306 | DoubleAlert: true, |
| 1307 | SendSpuriousAlert: alertRecordOverflow, |
| 1308 | }, |
| 1309 | }, |
| 1310 | shouldFail: true, |
| 1311 | expectedError: ":BAD_ALERT:", |
| 1312 | }, |
| 1313 | { |
| 1314 | protocol: dtls, |
| 1315 | testType: serverTest, |
| 1316 | name: "DoubleAlert-DTLS", |
| 1317 | config: Config{ |
| 1318 | Bugs: ProtocolBugs{ |
| 1319 | DoubleAlert: true, |
| 1320 | SendSpuriousAlert: alertRecordOverflow, |
| 1321 | }, |
| 1322 | }, |
| 1323 | shouldFail: true, |
| 1324 | expectedError: ":BAD_ALERT:", |
| 1325 | }, |
| 1326 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1327 | name: "SkipNewSessionTicket", |
| 1328 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1329 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1330 | Bugs: ProtocolBugs{ |
| 1331 | SkipNewSessionTicket: true, |
| 1332 | }, |
| 1333 | }, |
| 1334 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1335 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1336 | }, |
| 1337 | { |
| 1338 | testType: serverTest, |
| 1339 | name: "FallbackSCSV", |
| 1340 | config: Config{ |
| 1341 | MaxVersion: VersionTLS11, |
| 1342 | Bugs: ProtocolBugs{ |
| 1343 | SendFallbackSCSV: true, |
| 1344 | }, |
| 1345 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1346 | shouldFail: true, |
| 1347 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1348 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1349 | }, |
| 1350 | { |
| 1351 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1352 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1353 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1354 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1355 | Bugs: ProtocolBugs{ |
| 1356 | SendFallbackSCSV: true, |
| 1357 | }, |
| 1358 | }, |
| 1359 | }, |
| 1360 | { |
| 1361 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1362 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1363 | config: Config{ |
| 1364 | MaxVersion: VersionTLS12, |
| 1365 | Bugs: ProtocolBugs{ |
| 1366 | SendFallbackSCSV: true, |
| 1367 | }, |
| 1368 | }, |
| 1369 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1370 | }, |
| 1371 | { |
| 1372 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1373 | name: "FragmentedClientVersion", |
| 1374 | config: Config{ |
| 1375 | Bugs: ProtocolBugs{ |
| 1376 | MaxHandshakeRecordLength: 1, |
| 1377 | FragmentClientVersion: true, |
| 1378 | }, |
| 1379 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1380 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1381 | }, |
| 1382 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1383 | testType: serverTest, |
| 1384 | name: "HttpGET", |
| 1385 | sendPrefix: "GET / HTTP/1.0\n", |
| 1386 | shouldFail: true, |
| 1387 | expectedError: ":HTTP_REQUEST:", |
| 1388 | }, |
| 1389 | { |
| 1390 | testType: serverTest, |
| 1391 | name: "HttpPOST", |
| 1392 | sendPrefix: "POST / HTTP/1.0\n", |
| 1393 | shouldFail: true, |
| 1394 | expectedError: ":HTTP_REQUEST:", |
| 1395 | }, |
| 1396 | { |
| 1397 | testType: serverTest, |
| 1398 | name: "HttpHEAD", |
| 1399 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1400 | shouldFail: true, |
| 1401 | expectedError: ":HTTP_REQUEST:", |
| 1402 | }, |
| 1403 | { |
| 1404 | testType: serverTest, |
| 1405 | name: "HttpPUT", |
| 1406 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1407 | shouldFail: true, |
| 1408 | expectedError: ":HTTP_REQUEST:", |
| 1409 | }, |
| 1410 | { |
| 1411 | testType: serverTest, |
| 1412 | name: "HttpCONNECT", |
| 1413 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1414 | shouldFail: true, |
| 1415 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1416 | }, |
| 1417 | { |
| 1418 | testType: serverTest, |
| 1419 | name: "Garbage", |
| 1420 | sendPrefix: "blah", |
| 1421 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1422 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1423 | }, |
| 1424 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1425 | name: "RSAEphemeralKey", |
| 1426 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1427 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1428 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1429 | Bugs: ProtocolBugs{ |
| 1430 | RSAEphemeralKey: true, |
| 1431 | }, |
| 1432 | }, |
| 1433 | shouldFail: true, |
| 1434 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1435 | }, |
| 1436 | { |
| 1437 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1438 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1439 | shouldFail: true, |
| 1440 | expectedError: ":WRONG_SSL_VERSION:", |
| 1441 | }, |
| 1442 | { |
| 1443 | protocol: dtls, |
| 1444 | name: "DisableEverything-DTLS", |
| 1445 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1446 | shouldFail: true, |
| 1447 | expectedError: ":WRONG_SSL_VERSION:", |
| 1448 | }, |
| 1449 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1450 | protocol: dtls, |
| 1451 | testType: serverTest, |
| 1452 | name: "MTU", |
| 1453 | config: Config{ |
| 1454 | Bugs: ProtocolBugs{ |
| 1455 | MaxPacketLength: 256, |
| 1456 | }, |
| 1457 | }, |
| 1458 | flags: []string{"-mtu", "256"}, |
| 1459 | }, |
| 1460 | { |
| 1461 | protocol: dtls, |
| 1462 | testType: serverTest, |
| 1463 | name: "MTUExceeded", |
| 1464 | config: Config{ |
| 1465 | Bugs: ProtocolBugs{ |
| 1466 | MaxPacketLength: 255, |
| 1467 | }, |
| 1468 | }, |
| 1469 | flags: []string{"-mtu", "256"}, |
| 1470 | shouldFail: true, |
| 1471 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1472 | }, |
| 1473 | { |
| 1474 | name: "CertMismatchRSA", |
| 1475 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1476 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1477 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1478 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1479 | Bugs: ProtocolBugs{ |
| 1480 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1481 | }, |
| 1482 | }, |
| 1483 | shouldFail: true, |
| 1484 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1485 | }, |
| 1486 | { |
| 1487 | name: "CertMismatchECDSA", |
| 1488 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1489 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1490 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1491 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1492 | Bugs: ProtocolBugs{ |
| 1493 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1494 | }, |
| 1495 | }, |
| 1496 | shouldFail: true, |
| 1497 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1498 | }, |
| 1499 | { |
| 1500 | name: "EmptyCertificateList", |
| 1501 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1502 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1503 | Bugs: ProtocolBugs{ |
| 1504 | EmptyCertificateList: true, |
| 1505 | }, |
| 1506 | }, |
| 1507 | shouldFail: true, |
| 1508 | expectedError: ":DECODE_ERROR:", |
| 1509 | }, |
| 1510 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1511 | name: "EmptyCertificateList-TLS13", |
| 1512 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1513 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1514 | Bugs: ProtocolBugs{ |
| 1515 | EmptyCertificateList: true, |
| 1516 | }, |
| 1517 | }, |
| 1518 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1519 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1520 | }, |
| 1521 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1522 | name: "TLSFatalBadPackets", |
| 1523 | damageFirstWrite: true, |
| 1524 | shouldFail: true, |
| 1525 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1526 | }, |
| 1527 | { |
| 1528 | protocol: dtls, |
| 1529 | name: "DTLSIgnoreBadPackets", |
| 1530 | damageFirstWrite: true, |
| 1531 | }, |
| 1532 | { |
| 1533 | protocol: dtls, |
| 1534 | name: "DTLSIgnoreBadPackets-Async", |
| 1535 | damageFirstWrite: true, |
| 1536 | flags: []string{"-async"}, |
| 1537 | }, |
| 1538 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1539 | name: "AppDataBeforeHandshake", |
| 1540 | config: Config{ |
| 1541 | Bugs: ProtocolBugs{ |
| 1542 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1543 | }, |
| 1544 | }, |
| 1545 | shouldFail: true, |
| 1546 | expectedError: ":UNEXPECTED_RECORD:", |
| 1547 | }, |
| 1548 | { |
| 1549 | name: "AppDataBeforeHandshake-Empty", |
| 1550 | config: Config{ |
| 1551 | Bugs: ProtocolBugs{ |
| 1552 | AppDataBeforeHandshake: []byte{}, |
| 1553 | }, |
| 1554 | }, |
| 1555 | shouldFail: true, |
| 1556 | expectedError: ":UNEXPECTED_RECORD:", |
| 1557 | }, |
| 1558 | { |
| 1559 | protocol: dtls, |
| 1560 | name: "AppDataBeforeHandshake-DTLS", |
| 1561 | config: Config{ |
| 1562 | Bugs: ProtocolBugs{ |
| 1563 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1564 | }, |
| 1565 | }, |
| 1566 | shouldFail: true, |
| 1567 | expectedError: ":UNEXPECTED_RECORD:", |
| 1568 | }, |
| 1569 | { |
| 1570 | protocol: dtls, |
| 1571 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1572 | config: Config{ |
| 1573 | Bugs: ProtocolBugs{ |
| 1574 | AppDataBeforeHandshake: []byte{}, |
| 1575 | }, |
| 1576 | }, |
| 1577 | shouldFail: true, |
| 1578 | expectedError: ":UNEXPECTED_RECORD:", |
| 1579 | }, |
| 1580 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1581 | name: "AppDataAfterChangeCipherSpec", |
| 1582 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1583 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1584 | Bugs: ProtocolBugs{ |
| 1585 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1586 | }, |
| 1587 | }, |
| 1588 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1589 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1590 | }, |
| 1591 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1592 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1593 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1594 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1595 | Bugs: ProtocolBugs{ |
| 1596 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1597 | }, |
| 1598 | }, |
| 1599 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1600 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1601 | }, |
| 1602 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1603 | protocol: dtls, |
| 1604 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1605 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1606 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1607 | Bugs: ProtocolBugs{ |
| 1608 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1609 | }, |
| 1610 | }, |
| 1611 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1612 | // application data. |
| 1613 | }, |
| 1614 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1615 | protocol: dtls, |
| 1616 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1617 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1618 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1619 | Bugs: ProtocolBugs{ |
| 1620 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1621 | }, |
| 1622 | }, |
| 1623 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1624 | // application data. |
| 1625 | }, |
| 1626 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1627 | name: "AlertAfterChangeCipherSpec", |
| 1628 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1629 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1630 | Bugs: ProtocolBugs{ |
| 1631 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1632 | }, |
| 1633 | }, |
| 1634 | shouldFail: true, |
| 1635 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1636 | }, |
| 1637 | { |
| 1638 | protocol: dtls, |
| 1639 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1640 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1641 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1642 | Bugs: ProtocolBugs{ |
| 1643 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1644 | }, |
| 1645 | }, |
| 1646 | shouldFail: true, |
| 1647 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1648 | }, |
| 1649 | { |
| 1650 | protocol: dtls, |
| 1651 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1652 | config: Config{ |
| 1653 | Bugs: ProtocolBugs{ |
| 1654 | ReorderHandshakeFragments: true, |
| 1655 | // Small enough that every handshake message is |
| 1656 | // fragmented. |
| 1657 | MaxHandshakeRecordLength: 2, |
| 1658 | }, |
| 1659 | }, |
| 1660 | }, |
| 1661 | { |
| 1662 | protocol: dtls, |
| 1663 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1664 | config: Config{ |
| 1665 | Bugs: ProtocolBugs{ |
| 1666 | ReorderHandshakeFragments: true, |
| 1667 | // Large enough that no handshake message is |
| 1668 | // fragmented. |
| 1669 | MaxHandshakeRecordLength: 2048, |
| 1670 | }, |
| 1671 | }, |
| 1672 | }, |
| 1673 | { |
| 1674 | protocol: dtls, |
| 1675 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1676 | config: Config{ |
| 1677 | Bugs: ProtocolBugs{ |
| 1678 | ReorderHandshakeFragments: true, |
| 1679 | MixCompleteMessageWithFragments: true, |
| 1680 | MaxHandshakeRecordLength: 2, |
| 1681 | }, |
| 1682 | }, |
| 1683 | }, |
| 1684 | { |
| 1685 | name: "SendInvalidRecordType", |
| 1686 | config: Config{ |
| 1687 | Bugs: ProtocolBugs{ |
| 1688 | SendInvalidRecordType: true, |
| 1689 | }, |
| 1690 | }, |
| 1691 | shouldFail: true, |
| 1692 | expectedError: ":UNEXPECTED_RECORD:", |
| 1693 | }, |
| 1694 | { |
| 1695 | protocol: dtls, |
| 1696 | name: "SendInvalidRecordType-DTLS", |
| 1697 | config: Config{ |
| 1698 | Bugs: ProtocolBugs{ |
| 1699 | SendInvalidRecordType: true, |
| 1700 | }, |
| 1701 | }, |
| 1702 | shouldFail: true, |
| 1703 | expectedError: ":UNEXPECTED_RECORD:", |
| 1704 | }, |
| 1705 | { |
| 1706 | name: "FalseStart-SkipServerSecondLeg", |
| 1707 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1708 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1709 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1710 | NextProtos: []string{"foo"}, |
| 1711 | Bugs: ProtocolBugs{ |
| 1712 | SkipNewSessionTicket: true, |
| 1713 | SkipChangeCipherSpec: true, |
| 1714 | SkipFinished: true, |
| 1715 | ExpectFalseStart: true, |
| 1716 | }, |
| 1717 | }, |
| 1718 | flags: []string{ |
| 1719 | "-false-start", |
| 1720 | "-handshake-never-done", |
| 1721 | "-advertise-alpn", "\x03foo", |
| 1722 | }, |
| 1723 | shimWritesFirst: true, |
| 1724 | shouldFail: true, |
| 1725 | expectedError: ":UNEXPECTED_RECORD:", |
| 1726 | }, |
| 1727 | { |
| 1728 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1729 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1730 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1731 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1732 | NextProtos: []string{"foo"}, |
| 1733 | Bugs: ProtocolBugs{ |
| 1734 | SkipNewSessionTicket: true, |
| 1735 | SkipChangeCipherSpec: true, |
| 1736 | SkipFinished: true, |
| 1737 | }, |
| 1738 | }, |
| 1739 | flags: []string{ |
| 1740 | "-implicit-handshake", |
| 1741 | "-false-start", |
| 1742 | "-handshake-never-done", |
| 1743 | "-advertise-alpn", "\x03foo", |
| 1744 | }, |
| 1745 | shouldFail: true, |
| 1746 | expectedError: ":UNEXPECTED_RECORD:", |
| 1747 | }, |
| 1748 | { |
| 1749 | testType: serverTest, |
| 1750 | name: "FailEarlyCallback", |
| 1751 | flags: []string{"-fail-early-callback"}, |
| 1752 | shouldFail: true, |
| 1753 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1754 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1755 | }, |
| 1756 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1757 | name: "FailCertCallback-Client-TLS12", |
| 1758 | config: Config{ |
| 1759 | MaxVersion: VersionTLS12, |
| 1760 | ClientAuth: RequestClientCert, |
| 1761 | }, |
| 1762 | flags: []string{"-fail-cert-callback"}, |
| 1763 | shouldFail: true, |
| 1764 | expectedError: ":CERT_CB_ERROR:", |
| 1765 | expectedLocalError: "remote error: internal error", |
| 1766 | }, |
| 1767 | { |
| 1768 | testType: serverTest, |
| 1769 | name: "FailCertCallback-Server-TLS12", |
| 1770 | config: Config{ |
| 1771 | MaxVersion: VersionTLS12, |
| 1772 | }, |
| 1773 | flags: []string{"-fail-cert-callback"}, |
| 1774 | shouldFail: true, |
| 1775 | expectedError: ":CERT_CB_ERROR:", |
| 1776 | expectedLocalError: "remote error: internal error", |
| 1777 | }, |
| 1778 | { |
| 1779 | name: "FailCertCallback-Client-TLS13", |
| 1780 | config: Config{ |
| 1781 | MaxVersion: VersionTLS13, |
| 1782 | ClientAuth: RequestClientCert, |
| 1783 | }, |
| 1784 | flags: []string{"-fail-cert-callback"}, |
| 1785 | shouldFail: true, |
| 1786 | expectedError: ":CERT_CB_ERROR:", |
| 1787 | expectedLocalError: "remote error: internal error", |
| 1788 | }, |
| 1789 | { |
| 1790 | testType: serverTest, |
| 1791 | name: "FailCertCallback-Server-TLS13", |
| 1792 | config: Config{ |
| 1793 | MaxVersion: VersionTLS13, |
| 1794 | }, |
| 1795 | flags: []string{"-fail-cert-callback"}, |
| 1796 | shouldFail: true, |
| 1797 | expectedError: ":CERT_CB_ERROR:", |
| 1798 | expectedLocalError: "remote error: internal error", |
| 1799 | }, |
| 1800 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1801 | protocol: dtls, |
| 1802 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1803 | config: Config{ |
| 1804 | Bugs: ProtocolBugs{ |
| 1805 | MaxHandshakeRecordLength: 2, |
| 1806 | FragmentMessageTypeMismatch: true, |
| 1807 | }, |
| 1808 | }, |
| 1809 | shouldFail: true, |
| 1810 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1811 | }, |
| 1812 | { |
| 1813 | protocol: dtls, |
| 1814 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1815 | config: Config{ |
| 1816 | Bugs: ProtocolBugs{ |
| 1817 | MaxHandshakeRecordLength: 2, |
| 1818 | FragmentMessageLengthMismatch: true, |
| 1819 | }, |
| 1820 | }, |
| 1821 | shouldFail: true, |
| 1822 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1823 | }, |
| 1824 | { |
| 1825 | protocol: dtls, |
| 1826 | name: "SplitFragments-Header-DTLS", |
| 1827 | config: Config{ |
| 1828 | Bugs: ProtocolBugs{ |
| 1829 | SplitFragments: 2, |
| 1830 | }, |
| 1831 | }, |
| 1832 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1833 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1834 | }, |
| 1835 | { |
| 1836 | protocol: dtls, |
| 1837 | name: "SplitFragments-Boundary-DTLS", |
| 1838 | config: Config{ |
| 1839 | Bugs: ProtocolBugs{ |
| 1840 | SplitFragments: dtlsRecordHeaderLen, |
| 1841 | }, |
| 1842 | }, |
| 1843 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1844 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1845 | }, |
| 1846 | { |
| 1847 | protocol: dtls, |
| 1848 | name: "SplitFragments-Body-DTLS", |
| 1849 | config: Config{ |
| 1850 | Bugs: ProtocolBugs{ |
| 1851 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1852 | }, |
| 1853 | }, |
| 1854 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1855 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1856 | }, |
| 1857 | { |
| 1858 | protocol: dtls, |
| 1859 | name: "SendEmptyFragments-DTLS", |
| 1860 | config: Config{ |
| 1861 | Bugs: ProtocolBugs{ |
| 1862 | SendEmptyFragments: true, |
| 1863 | }, |
| 1864 | }, |
| 1865 | }, |
| 1866 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1867 | name: "BadFinished-Client", |
| 1868 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1869 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1870 | Bugs: ProtocolBugs{ |
| 1871 | BadFinished: true, |
| 1872 | }, |
| 1873 | }, |
| 1874 | shouldFail: true, |
| 1875 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1876 | }, |
| 1877 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1878 | name: "BadFinished-Client-TLS13", |
| 1879 | config: Config{ |
| 1880 | MaxVersion: VersionTLS13, |
| 1881 | Bugs: ProtocolBugs{ |
| 1882 | BadFinished: true, |
| 1883 | }, |
| 1884 | }, |
| 1885 | shouldFail: true, |
| 1886 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1887 | }, |
| 1888 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1889 | testType: serverTest, |
| 1890 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1891 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1892 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1893 | Bugs: ProtocolBugs{ |
| 1894 | BadFinished: true, |
| 1895 | }, |
| 1896 | }, |
| 1897 | shouldFail: true, |
| 1898 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1899 | }, |
| 1900 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1901 | testType: serverTest, |
| 1902 | name: "BadFinished-Server-TLS13", |
| 1903 | config: Config{ |
| 1904 | MaxVersion: VersionTLS13, |
| 1905 | Bugs: ProtocolBugs{ |
| 1906 | BadFinished: true, |
| 1907 | }, |
| 1908 | }, |
| 1909 | shouldFail: true, |
| 1910 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1911 | }, |
| 1912 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1913 | name: "FalseStart-BadFinished", |
| 1914 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1915 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1916 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1917 | NextProtos: []string{"foo"}, |
| 1918 | Bugs: ProtocolBugs{ |
| 1919 | BadFinished: true, |
| 1920 | ExpectFalseStart: true, |
| 1921 | }, |
| 1922 | }, |
| 1923 | flags: []string{ |
| 1924 | "-false-start", |
| 1925 | "-handshake-never-done", |
| 1926 | "-advertise-alpn", "\x03foo", |
| 1927 | }, |
| 1928 | shimWritesFirst: true, |
| 1929 | shouldFail: true, |
| 1930 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1931 | }, |
| 1932 | { |
| 1933 | name: "NoFalseStart-NoALPN", |
| 1934 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1935 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1936 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1937 | Bugs: ProtocolBugs{ |
| 1938 | ExpectFalseStart: true, |
| 1939 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1940 | }, |
| 1941 | }, |
| 1942 | flags: []string{ |
| 1943 | "-false-start", |
| 1944 | }, |
| 1945 | shimWritesFirst: true, |
| 1946 | shouldFail: true, |
| 1947 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1948 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1949 | }, |
| 1950 | { |
| 1951 | name: "NoFalseStart-NoAEAD", |
| 1952 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1953 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1954 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1955 | NextProtos: []string{"foo"}, |
| 1956 | Bugs: ProtocolBugs{ |
| 1957 | ExpectFalseStart: true, |
| 1958 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1959 | }, |
| 1960 | }, |
| 1961 | flags: []string{ |
| 1962 | "-false-start", |
| 1963 | "-advertise-alpn", "\x03foo", |
| 1964 | }, |
| 1965 | shimWritesFirst: true, |
| 1966 | shouldFail: true, |
| 1967 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1968 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1969 | }, |
| 1970 | { |
| 1971 | name: "NoFalseStart-RSA", |
| 1972 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1973 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1974 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1975 | NextProtos: []string{"foo"}, |
| 1976 | Bugs: ProtocolBugs{ |
| 1977 | ExpectFalseStart: true, |
| 1978 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1979 | }, |
| 1980 | }, |
| 1981 | flags: []string{ |
| 1982 | "-false-start", |
| 1983 | "-advertise-alpn", "\x03foo", |
| 1984 | }, |
| 1985 | shimWritesFirst: true, |
| 1986 | shouldFail: true, |
| 1987 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1988 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1989 | }, |
| 1990 | { |
| 1991 | name: "NoFalseStart-DHE_RSA", |
| 1992 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1993 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1994 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1995 | NextProtos: []string{"foo"}, |
| 1996 | Bugs: ProtocolBugs{ |
| 1997 | ExpectFalseStart: true, |
| 1998 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1999 | }, |
| 2000 | }, |
| 2001 | flags: []string{ |
| 2002 | "-false-start", |
| 2003 | "-advertise-alpn", "\x03foo", |
| 2004 | }, |
| 2005 | shimWritesFirst: true, |
| 2006 | shouldFail: true, |
| 2007 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2008 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2009 | }, |
| 2010 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2011 | protocol: dtls, |
| 2012 | name: "SendSplitAlert-Sync", |
| 2013 | config: Config{ |
| 2014 | Bugs: ProtocolBugs{ |
| 2015 | SendSplitAlert: true, |
| 2016 | }, |
| 2017 | }, |
| 2018 | }, |
| 2019 | { |
| 2020 | protocol: dtls, |
| 2021 | name: "SendSplitAlert-Async", |
| 2022 | config: Config{ |
| 2023 | Bugs: ProtocolBugs{ |
| 2024 | SendSplitAlert: true, |
| 2025 | }, |
| 2026 | }, |
| 2027 | flags: []string{"-async"}, |
| 2028 | }, |
| 2029 | { |
| 2030 | protocol: dtls, |
| 2031 | name: "PackDTLSHandshake", |
| 2032 | config: Config{ |
| 2033 | Bugs: ProtocolBugs{ |
| 2034 | MaxHandshakeRecordLength: 2, |
| 2035 | PackHandshakeFragments: 20, |
| 2036 | PackHandshakeRecords: 200, |
| 2037 | }, |
| 2038 | }, |
| 2039 | }, |
| 2040 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2041 | name: "SendEmptyRecords-Pass", |
| 2042 | sendEmptyRecords: 32, |
| 2043 | }, |
| 2044 | { |
| 2045 | name: "SendEmptyRecords", |
| 2046 | sendEmptyRecords: 33, |
| 2047 | shouldFail: true, |
| 2048 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2049 | }, |
| 2050 | { |
| 2051 | name: "SendEmptyRecords-Async", |
| 2052 | sendEmptyRecords: 33, |
| 2053 | flags: []string{"-async"}, |
| 2054 | shouldFail: true, |
| 2055 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2056 | }, |
| 2057 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2058 | name: "SendWarningAlerts-Pass", |
| 2059 | config: Config{ |
| 2060 | MaxVersion: VersionTLS12, |
| 2061 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2062 | sendWarningAlerts: 4, |
| 2063 | }, |
| 2064 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2065 | protocol: dtls, |
| 2066 | name: "SendWarningAlerts-DTLS-Pass", |
| 2067 | config: Config{ |
| 2068 | MaxVersion: VersionTLS12, |
| 2069 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2070 | sendWarningAlerts: 4, |
| 2071 | }, |
| 2072 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2073 | name: "SendWarningAlerts-TLS13", |
| 2074 | config: Config{ |
| 2075 | MaxVersion: VersionTLS13, |
| 2076 | }, |
| 2077 | sendWarningAlerts: 4, |
| 2078 | shouldFail: true, |
| 2079 | expectedError: ":BAD_ALERT:", |
| 2080 | expectedLocalError: "remote error: error decoding message", |
| 2081 | }, |
| 2082 | { |
| 2083 | name: "SendWarningAlerts", |
| 2084 | config: Config{ |
| 2085 | MaxVersion: VersionTLS12, |
| 2086 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2087 | sendWarningAlerts: 5, |
| 2088 | shouldFail: true, |
| 2089 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2090 | }, |
| 2091 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2092 | name: "SendWarningAlerts-Async", |
| 2093 | config: Config{ |
| 2094 | MaxVersion: VersionTLS12, |
| 2095 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2096 | sendWarningAlerts: 5, |
| 2097 | flags: []string{"-async"}, |
| 2098 | shouldFail: true, |
| 2099 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2100 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2101 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2102 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2103 | config: Config{ |
| 2104 | MaxVersion: VersionTLS13, |
| 2105 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2106 | sendKeyUpdates: 33, |
| 2107 | keyUpdateRequest: keyUpdateNotRequested, |
| 2108 | shouldFail: true, |
| 2109 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2110 | }, |
| 2111 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2112 | name: "EmptySessionID", |
| 2113 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2114 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2115 | SessionTicketsDisabled: true, |
| 2116 | }, |
| 2117 | noSessionCache: true, |
| 2118 | flags: []string{"-expect-no-session"}, |
| 2119 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2120 | { |
| 2121 | name: "Unclean-Shutdown", |
| 2122 | config: Config{ |
| 2123 | Bugs: ProtocolBugs{ |
| 2124 | NoCloseNotify: true, |
| 2125 | ExpectCloseNotify: true, |
| 2126 | }, |
| 2127 | }, |
| 2128 | shimShutsDown: true, |
| 2129 | flags: []string{"-check-close-notify"}, |
| 2130 | shouldFail: true, |
| 2131 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2132 | }, |
| 2133 | { |
| 2134 | name: "Unclean-Shutdown-Ignored", |
| 2135 | config: Config{ |
| 2136 | Bugs: ProtocolBugs{ |
| 2137 | NoCloseNotify: true, |
| 2138 | }, |
| 2139 | }, |
| 2140 | shimShutsDown: true, |
| 2141 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2142 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2143 | name: "Unclean-Shutdown-Alert", |
| 2144 | config: Config{ |
| 2145 | Bugs: ProtocolBugs{ |
| 2146 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2147 | ExpectCloseNotify: true, |
| 2148 | }, |
| 2149 | }, |
| 2150 | shimShutsDown: true, |
| 2151 | flags: []string{"-check-close-notify"}, |
| 2152 | shouldFail: true, |
| 2153 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2154 | }, |
| 2155 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2156 | name: "LargePlaintext", |
| 2157 | config: Config{ |
| 2158 | Bugs: ProtocolBugs{ |
| 2159 | SendLargeRecords: true, |
| 2160 | }, |
| 2161 | }, |
| 2162 | messageLen: maxPlaintext + 1, |
| 2163 | shouldFail: true, |
| 2164 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2165 | }, |
| 2166 | { |
| 2167 | protocol: dtls, |
| 2168 | name: "LargePlaintext-DTLS", |
| 2169 | config: Config{ |
| 2170 | Bugs: ProtocolBugs{ |
| 2171 | SendLargeRecords: true, |
| 2172 | }, |
| 2173 | }, |
| 2174 | messageLen: maxPlaintext + 1, |
| 2175 | shouldFail: true, |
| 2176 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2177 | }, |
| 2178 | { |
| 2179 | name: "LargeCiphertext", |
| 2180 | config: Config{ |
| 2181 | Bugs: ProtocolBugs{ |
| 2182 | SendLargeRecords: true, |
| 2183 | }, |
| 2184 | }, |
| 2185 | messageLen: maxPlaintext * 2, |
| 2186 | shouldFail: true, |
| 2187 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2188 | }, |
| 2189 | { |
| 2190 | protocol: dtls, |
| 2191 | name: "LargeCiphertext-DTLS", |
| 2192 | config: Config{ |
| 2193 | Bugs: ProtocolBugs{ |
| 2194 | SendLargeRecords: true, |
| 2195 | }, |
| 2196 | }, |
| 2197 | messageLen: maxPlaintext * 2, |
| 2198 | // Unlike the other four cases, DTLS drops records which |
| 2199 | // are invalid before authentication, so the connection |
| 2200 | // does not fail. |
| 2201 | expectMessageDropped: true, |
| 2202 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2203 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2204 | name: "BadHelloRequest-1", |
| 2205 | renegotiate: 1, |
| 2206 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2207 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2208 | Bugs: ProtocolBugs{ |
| 2209 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2210 | }, |
| 2211 | }, |
| 2212 | flags: []string{ |
| 2213 | "-renegotiate-freely", |
| 2214 | "-expect-total-renegotiations", "1", |
| 2215 | }, |
| 2216 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2217 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2218 | }, |
| 2219 | { |
| 2220 | name: "BadHelloRequest-2", |
| 2221 | renegotiate: 1, |
| 2222 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2223 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2224 | Bugs: ProtocolBugs{ |
| 2225 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2226 | }, |
| 2227 | }, |
| 2228 | flags: []string{ |
| 2229 | "-renegotiate-freely", |
| 2230 | "-expect-total-renegotiations", "1", |
| 2231 | }, |
| 2232 | shouldFail: true, |
| 2233 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2234 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2235 | { |
| 2236 | testType: serverTest, |
| 2237 | name: "SupportTicketsWithSessionID", |
| 2238 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2239 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2240 | SessionTicketsDisabled: true, |
| 2241 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2242 | resumeConfig: &Config{ |
| 2243 | MaxVersion: VersionTLS12, |
| 2244 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2245 | resumeSession: true, |
| 2246 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2247 | { |
| 2248 | protocol: dtls, |
| 2249 | name: "DTLS-SendExtraFinished", |
| 2250 | config: Config{ |
| 2251 | Bugs: ProtocolBugs{ |
| 2252 | SendExtraFinished: true, |
| 2253 | }, |
| 2254 | }, |
| 2255 | shouldFail: true, |
| 2256 | expectedError: ":UNEXPECTED_RECORD:", |
| 2257 | }, |
| 2258 | { |
| 2259 | protocol: dtls, |
| 2260 | name: "DTLS-SendExtraFinished-Reordered", |
| 2261 | config: Config{ |
| 2262 | Bugs: ProtocolBugs{ |
| 2263 | MaxHandshakeRecordLength: 2, |
| 2264 | ReorderHandshakeFragments: true, |
| 2265 | SendExtraFinished: true, |
| 2266 | }, |
| 2267 | }, |
| 2268 | shouldFail: true, |
| 2269 | expectedError: ":UNEXPECTED_RECORD:", |
| 2270 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2271 | { |
| 2272 | testType: serverTest, |
| 2273 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2274 | config: Config{ |
| 2275 | // Choose a cipher suite that does not involve |
| 2276 | // elliptic curves, so no extensions are |
| 2277 | // involved. |
| 2278 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2279 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2280 | Bugs: ProtocolBugs{ |
| 2281 | SendV2ClientHello: true, |
| 2282 | }, |
| 2283 | }, |
| 2284 | sendPrefix: string([]byte{ |
| 2285 | byte(recordTypeHandshake), |
| 2286 | 3, 1, // version |
| 2287 | 0, 0, // length |
| 2288 | }), |
| 2289 | // A no-op empty record may not be sent before V2ClientHello. |
| 2290 | shouldFail: true, |
| 2291 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2292 | }, |
| 2293 | { |
| 2294 | testType: serverTest, |
| 2295 | name: "V2ClientHello-WarningAlertPrefix", |
| 2296 | config: Config{ |
| 2297 | // Choose a cipher suite that does not involve |
| 2298 | // elliptic curves, so no extensions are |
| 2299 | // involved. |
| 2300 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2301 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2302 | Bugs: ProtocolBugs{ |
| 2303 | SendV2ClientHello: true, |
| 2304 | }, |
| 2305 | }, |
| 2306 | sendPrefix: string([]byte{ |
| 2307 | byte(recordTypeAlert), |
| 2308 | 3, 1, // version |
| 2309 | 0, 2, // length |
| 2310 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2311 | }), |
| 2312 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2313 | shouldFail: true, |
| 2314 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2315 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2316 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2317 | name: "KeyUpdate-Client", |
| 2318 | config: Config{ |
| 2319 | MaxVersion: VersionTLS13, |
| 2320 | }, |
| 2321 | sendKeyUpdates: 1, |
| 2322 | keyUpdateRequest: keyUpdateNotRequested, |
| 2323 | }, |
| 2324 | { |
| 2325 | testType: serverTest, |
| 2326 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2327 | config: Config{ |
| 2328 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2329 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2330 | sendKeyUpdates: 1, |
| 2331 | keyUpdateRequest: keyUpdateNotRequested, |
| 2332 | }, |
| 2333 | { |
| 2334 | name: "KeyUpdate-InvalidRequestMode", |
| 2335 | config: Config{ |
| 2336 | MaxVersion: VersionTLS13, |
| 2337 | }, |
| 2338 | sendKeyUpdates: 1, |
| 2339 | keyUpdateRequest: 42, |
| 2340 | shouldFail: true, |
| 2341 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2342 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2343 | { |
| 2344 | name: "SendSNIWarningAlert", |
| 2345 | config: Config{ |
| 2346 | MaxVersion: VersionTLS12, |
| 2347 | Bugs: ProtocolBugs{ |
| 2348 | SendSNIWarningAlert: true, |
| 2349 | }, |
| 2350 | }, |
| 2351 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2352 | { |
| 2353 | testType: serverTest, |
| 2354 | name: "ExtraCompressionMethods-TLS12", |
| 2355 | config: Config{ |
| 2356 | MaxVersion: VersionTLS12, |
| 2357 | Bugs: ProtocolBugs{ |
| 2358 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2359 | }, |
| 2360 | }, |
| 2361 | }, |
| 2362 | { |
| 2363 | testType: serverTest, |
| 2364 | name: "ExtraCompressionMethods-TLS13", |
| 2365 | config: Config{ |
| 2366 | MaxVersion: VersionTLS13, |
| 2367 | Bugs: ProtocolBugs{ |
| 2368 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2369 | }, |
| 2370 | }, |
| 2371 | shouldFail: true, |
| 2372 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2373 | expectedLocalError: "remote error: illegal parameter", |
| 2374 | }, |
| 2375 | { |
| 2376 | testType: serverTest, |
| 2377 | name: "NoNullCompression-TLS12", |
| 2378 | config: Config{ |
| 2379 | MaxVersion: VersionTLS12, |
| 2380 | Bugs: ProtocolBugs{ |
| 2381 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2382 | }, |
| 2383 | }, |
| 2384 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2385 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2386 | expectedLocalError: "remote error: illegal parameter", |
| 2387 | }, |
| 2388 | { |
| 2389 | testType: serverTest, |
| 2390 | name: "NoNullCompression-TLS13", |
| 2391 | config: Config{ |
| 2392 | MaxVersion: VersionTLS13, |
| 2393 | Bugs: ProtocolBugs{ |
| 2394 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2395 | }, |
| 2396 | }, |
| 2397 | shouldFail: true, |
| 2398 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2399 | expectedLocalError: "remote error: illegal parameter", |
| 2400 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2401 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2402 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2403 | config: Config{ |
| 2404 | MaxVersion: VersionTLS12, |
| 2405 | Bugs: ProtocolBugs{ |
| 2406 | ExpectGREASE: true, |
| 2407 | }, |
| 2408 | }, |
| 2409 | flags: []string{"-enable-grease"}, |
| 2410 | }, |
| 2411 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2412 | name: "GREASE-Client-TLS13", |
| 2413 | config: Config{ |
| 2414 | MaxVersion: VersionTLS13, |
| 2415 | Bugs: ProtocolBugs{ |
| 2416 | ExpectGREASE: true, |
| 2417 | }, |
| 2418 | }, |
| 2419 | flags: []string{"-enable-grease"}, |
| 2420 | }, |
| 2421 | { |
| 2422 | testType: serverTest, |
| 2423 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2424 | config: Config{ |
| 2425 | MaxVersion: VersionTLS13, |
| 2426 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2427 | // TLS 1.3 servers are expected to |
| 2428 | // always enable GREASE. TLS 1.3 is new, |
| 2429 | // so there is no existing ecosystem to |
| 2430 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2431 | ExpectGREASE: true, |
| 2432 | }, |
| 2433 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2434 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2435 | { |
| 2436 | // Test the server so there is a large certificate as |
| 2437 | // well as application data. |
| 2438 | testType: serverTest, |
| 2439 | name: "MaxSendFragment", |
| 2440 | config: Config{ |
| 2441 | Bugs: ProtocolBugs{ |
| 2442 | MaxReceivePlaintext: 512, |
| 2443 | }, |
| 2444 | }, |
| 2445 | messageLen: 1024, |
| 2446 | flags: []string{ |
| 2447 | "-max-send-fragment", "512", |
| 2448 | "-read-size", "1024", |
| 2449 | }, |
| 2450 | }, |
| 2451 | { |
| 2452 | // Test the server so there is a large certificate as |
| 2453 | // well as application data. |
| 2454 | testType: serverTest, |
| 2455 | name: "MaxSendFragment-TooLarge", |
| 2456 | config: Config{ |
| 2457 | Bugs: ProtocolBugs{ |
| 2458 | // Ensure that some of the records are |
| 2459 | // 512. |
| 2460 | MaxReceivePlaintext: 511, |
| 2461 | }, |
| 2462 | }, |
| 2463 | messageLen: 1024, |
| 2464 | flags: []string{ |
| 2465 | "-max-send-fragment", "512", |
| 2466 | "-read-size", "1024", |
| 2467 | }, |
| 2468 | shouldFail: true, |
| 2469 | expectedLocalError: "local error: record overflow", |
| 2470 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2471 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2472 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2473 | |
| 2474 | // Test that very large messages can be received. |
| 2475 | cert := rsaCertificate |
| 2476 | for i := 0; i < 50; i++ { |
| 2477 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2478 | } |
| 2479 | testCases = append(testCases, testCase{ |
| 2480 | name: "LargeMessage", |
| 2481 | config: Config{ |
| 2482 | Certificates: []Certificate{cert}, |
| 2483 | }, |
| 2484 | }) |
| 2485 | testCases = append(testCases, testCase{ |
| 2486 | protocol: dtls, |
| 2487 | name: "LargeMessage-DTLS", |
| 2488 | config: Config{ |
| 2489 | Certificates: []Certificate{cert}, |
| 2490 | }, |
| 2491 | }) |
| 2492 | |
| 2493 | // They are rejected if the maximum certificate chain length is capped. |
| 2494 | testCases = append(testCases, testCase{ |
| 2495 | name: "LargeMessage-Reject", |
| 2496 | config: Config{ |
| 2497 | Certificates: []Certificate{cert}, |
| 2498 | }, |
| 2499 | flags: []string{"-max-cert-list", "16384"}, |
| 2500 | shouldFail: true, |
| 2501 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2502 | }) |
| 2503 | testCases = append(testCases, testCase{ |
| 2504 | protocol: dtls, |
| 2505 | name: "LargeMessage-Reject-DTLS", |
| 2506 | config: Config{ |
| 2507 | Certificates: []Certificate{cert}, |
| 2508 | }, |
| 2509 | flags: []string{"-max-cert-list", "16384"}, |
| 2510 | shouldFail: true, |
| 2511 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2512 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2513 | } |
| 2514 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2515 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2516 | const psk = "12345" |
| 2517 | const pskIdentity = "luggage combo" |
| 2518 | |
| 2519 | var prefix string |
| 2520 | if protocol == dtls { |
| 2521 | if !ver.hasDTLS { |
| 2522 | return |
| 2523 | } |
| 2524 | prefix = "D" |
| 2525 | } |
| 2526 | |
| 2527 | var cert Certificate |
| 2528 | var certFile string |
| 2529 | var keyFile string |
| 2530 | if hasComponent(suite.name, "ECDSA") { |
| 2531 | cert = ecdsaP256Certificate |
| 2532 | certFile = ecdsaP256CertificateFile |
| 2533 | keyFile = ecdsaP256KeyFile |
| 2534 | } else { |
| 2535 | cert = rsaCertificate |
| 2536 | certFile = rsaCertificateFile |
| 2537 | keyFile = rsaKeyFile |
| 2538 | } |
| 2539 | |
| 2540 | var flags []string |
| 2541 | if hasComponent(suite.name, "PSK") { |
| 2542 | flags = append(flags, |
| 2543 | "-psk", psk, |
| 2544 | "-psk-identity", pskIdentity) |
| 2545 | } |
| 2546 | if hasComponent(suite.name, "NULL") { |
| 2547 | // NULL ciphers must be explicitly enabled. |
| 2548 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2549 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2550 | |
| 2551 | var shouldServerFail, shouldClientFail bool |
| 2552 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2553 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2554 | // a BoringSSL server will never select it |
| 2555 | // because the extension is missing. |
| 2556 | shouldServerFail = true |
| 2557 | } |
| 2558 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2559 | shouldClientFail = true |
| 2560 | shouldServerFail = true |
| 2561 | } |
| 2562 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2563 | shouldClientFail = true |
| 2564 | shouldServerFail = true |
| 2565 | } |
| 2566 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2567 | shouldClientFail = true |
| 2568 | shouldServerFail = true |
| 2569 | } |
| 2570 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2571 | shouldClientFail = true |
| 2572 | shouldServerFail = true |
| 2573 | } |
| 2574 | |
| 2575 | var sendCipherSuite uint16 |
| 2576 | var expectedServerError, expectedClientError string |
| 2577 | serverCipherSuites := []uint16{suite.id} |
| 2578 | if shouldServerFail { |
| 2579 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2580 | } |
| 2581 | if shouldClientFail { |
| 2582 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2583 | // Configure the server to select ciphers as normal but |
| 2584 | // select an incompatible cipher in ServerHello. |
| 2585 | serverCipherSuites = nil |
| 2586 | sendCipherSuite = suite.id |
| 2587 | } |
| 2588 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2589 | // For cipher suites and versions where exporters are defined, verify |
| 2590 | // that they interoperate. |
| 2591 | var exportKeyingMaterial int |
| 2592 | if ver.version > VersionSSL30 { |
| 2593 | exportKeyingMaterial = 1024 |
| 2594 | } |
| 2595 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2596 | testCases = append(testCases, testCase{ |
| 2597 | testType: serverTest, |
| 2598 | protocol: protocol, |
| 2599 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2600 | config: Config{ |
| 2601 | MinVersion: ver.version, |
| 2602 | MaxVersion: ver.version, |
| 2603 | CipherSuites: []uint16{suite.id}, |
| 2604 | Certificates: []Certificate{cert}, |
| 2605 | PreSharedKey: []byte(psk), |
| 2606 | PreSharedKeyIdentity: pskIdentity, |
| 2607 | Bugs: ProtocolBugs{ |
| 2608 | AdvertiseAllConfiguredCiphers: true, |
| 2609 | }, |
| 2610 | }, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2611 | certFile: certFile, |
| 2612 | keyFile: keyFile, |
| 2613 | flags: flags, |
| 2614 | resumeSession: true, |
| 2615 | shouldFail: shouldServerFail, |
| 2616 | expectedError: expectedServerError, |
| 2617 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2618 | }) |
| 2619 | |
| 2620 | testCases = append(testCases, testCase{ |
| 2621 | testType: clientTest, |
| 2622 | protocol: protocol, |
| 2623 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2624 | config: Config{ |
| 2625 | MinVersion: ver.version, |
| 2626 | MaxVersion: ver.version, |
| 2627 | CipherSuites: serverCipherSuites, |
| 2628 | Certificates: []Certificate{cert}, |
| 2629 | PreSharedKey: []byte(psk), |
| 2630 | PreSharedKeyIdentity: pskIdentity, |
| 2631 | Bugs: ProtocolBugs{ |
| 2632 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2633 | SendCipherSuite: sendCipherSuite, |
| 2634 | }, |
| 2635 | }, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2636 | flags: flags, |
| 2637 | resumeSession: true, |
| 2638 | shouldFail: shouldClientFail, |
| 2639 | expectedError: expectedClientError, |
| 2640 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2641 | }) |
| 2642 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2643 | if shouldClientFail { |
| 2644 | return |
| 2645 | } |
| 2646 | |
| 2647 | // Ensure the maximum record size is accepted. |
| 2648 | testCases = append(testCases, testCase{ |
| 2649 | protocol: protocol, |
| 2650 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2651 | config: Config{ |
| 2652 | MinVersion: ver.version, |
| 2653 | MaxVersion: ver.version, |
| 2654 | CipherSuites: []uint16{suite.id}, |
| 2655 | Certificates: []Certificate{cert}, |
| 2656 | PreSharedKey: []byte(psk), |
| 2657 | PreSharedKeyIdentity: pskIdentity, |
| 2658 | }, |
| 2659 | flags: flags, |
| 2660 | messageLen: maxPlaintext, |
| 2661 | }) |
| 2662 | |
| 2663 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2664 | // and ignored in DTLS. |
| 2665 | var shouldFail bool |
| 2666 | var expectedError string |
| 2667 | if protocol == tls { |
| 2668 | shouldFail = true |
| 2669 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2670 | } |
| 2671 | |
| 2672 | testCases = append(testCases, testCase{ |
| 2673 | protocol: protocol, |
| 2674 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2675 | config: Config{ |
| 2676 | MinVersion: ver.version, |
| 2677 | MaxVersion: ver.version, |
| 2678 | CipherSuites: []uint16{suite.id}, |
| 2679 | Certificates: []Certificate{cert}, |
| 2680 | PreSharedKey: []byte(psk), |
| 2681 | PreSharedKeyIdentity: pskIdentity, |
| 2682 | }, |
| 2683 | flags: flags, |
| 2684 | damageFirstWrite: true, |
| 2685 | messageLen: maxPlaintext, |
| 2686 | shouldFail: shouldFail, |
| 2687 | expectedError: expectedError, |
| 2688 | }) |
| 2689 | |
| 2690 | if ver.version >= VersionTLS13 { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2691 | testCases = append(testCases, testCase{ |
| 2692 | protocol: protocol, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2693 | name: prefix + ver.name + "-" + suite.name + "-ShortHeader", |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2694 | config: Config{ |
| 2695 | MinVersion: ver.version, |
| 2696 | MaxVersion: ver.version, |
| 2697 | CipherSuites: []uint16{suite.id}, |
| 2698 | Certificates: []Certificate{cert}, |
| 2699 | PreSharedKey: []byte(psk), |
| 2700 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2701 | Bugs: ProtocolBugs{ |
| 2702 | EnableShortHeader: true, |
| 2703 | }, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2704 | }, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2705 | flags: append([]string{"-enable-short-header"}, flags...), |
| 2706 | resumeSession: true, |
| 2707 | expectShortHeader: true, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2708 | }) |
| 2709 | } |
| 2710 | } |
| 2711 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2712 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2713 | const bogusCipher = 0xfe00 |
| 2714 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2715 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2716 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2717 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2718 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2719 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2720 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2721 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2722 | |
| 2723 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2724 | name: "NoSharedCipher", |
| 2725 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2726 | MaxVersion: VersionTLS12, |
| 2727 | CipherSuites: []uint16{}, |
| 2728 | }, |
| 2729 | shouldFail: true, |
| 2730 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2731 | }) |
| 2732 | |
| 2733 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2734 | name: "NoSharedCipher-TLS13", |
| 2735 | config: Config{ |
| 2736 | MaxVersion: VersionTLS13, |
| 2737 | CipherSuites: []uint16{}, |
| 2738 | }, |
| 2739 | shouldFail: true, |
| 2740 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2741 | }) |
| 2742 | |
| 2743 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2744 | name: "UnsupportedCipherSuite", |
| 2745 | config: Config{ |
| 2746 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2747 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2748 | Bugs: ProtocolBugs{ |
| 2749 | IgnorePeerCipherPreferences: true, |
| 2750 | }, |
| 2751 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2752 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2753 | shouldFail: true, |
| 2754 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2755 | }) |
| 2756 | |
| 2757 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2758 | name: "ServerHelloBogusCipher", |
| 2759 | config: Config{ |
| 2760 | MaxVersion: VersionTLS12, |
| 2761 | Bugs: ProtocolBugs{ |
| 2762 | SendCipherSuite: bogusCipher, |
| 2763 | }, |
| 2764 | }, |
| 2765 | shouldFail: true, |
| 2766 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2767 | }) |
| 2768 | testCases = append(testCases, testCase{ |
| 2769 | name: "ServerHelloBogusCipher-TLS13", |
| 2770 | config: Config{ |
| 2771 | MaxVersion: VersionTLS13, |
| 2772 | Bugs: ProtocolBugs{ |
| 2773 | SendCipherSuite: bogusCipher, |
| 2774 | }, |
| 2775 | }, |
| 2776 | shouldFail: true, |
| 2777 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2778 | }) |
| 2779 | |
| 2780 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2781 | name: "WeakDH", |
| 2782 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2783 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2784 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2785 | Bugs: ProtocolBugs{ |
| 2786 | // This is a 1023-bit prime number, generated |
| 2787 | // with: |
| 2788 | // openssl gendh 1023 | openssl asn1parse -i |
| 2789 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2790 | }, |
| 2791 | }, |
| 2792 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2793 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2794 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2795 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2796 | testCases = append(testCases, testCase{ |
| 2797 | name: "SillyDH", |
| 2798 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2799 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2800 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2801 | Bugs: ProtocolBugs{ |
| 2802 | // This is a 4097-bit prime number, generated |
| 2803 | // with: |
| 2804 | // openssl gendh 4097 | openssl asn1parse -i |
| 2805 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2806 | }, |
| 2807 | }, |
| 2808 | shouldFail: true, |
| 2809 | expectedError: ":DH_P_TOO_LONG:", |
| 2810 | }) |
| 2811 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2812 | // This test ensures that Diffie-Hellman public values are padded with |
| 2813 | // zeros so that they're the same length as the prime. This is to avoid |
| 2814 | // hitting a bug in yaSSL. |
| 2815 | testCases = append(testCases, testCase{ |
| 2816 | testType: serverTest, |
| 2817 | name: "DHPublicValuePadded", |
| 2818 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2819 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2820 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2821 | Bugs: ProtocolBugs{ |
| 2822 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2823 | }, |
| 2824 | }, |
| 2825 | flags: []string{"-use-sparse-dh-prime"}, |
| 2826 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2827 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2828 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2829 | testCases = append(testCases, testCase{ |
| 2830 | testType: serverTest, |
| 2831 | name: "UnknownCipher", |
| 2832 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2833 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2834 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2835 | Bugs: ProtocolBugs{ |
| 2836 | AdvertiseAllConfiguredCiphers: true, |
| 2837 | }, |
| 2838 | }, |
| 2839 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2840 | |
| 2841 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2842 | testCases = append(testCases, testCase{ |
| 2843 | testType: serverTest, |
| 2844 | name: "UnknownCipher-TLS13", |
| 2845 | config: Config{ |
| 2846 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2847 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2848 | Bugs: ProtocolBugs{ |
| 2849 | AdvertiseAllConfiguredCiphers: true, |
| 2850 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2851 | }, |
| 2852 | }) |
| 2853 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2854 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2855 | testCases = append(testCases, testCase{ |
| 2856 | name: "EmptyECDHEPSKHint", |
| 2857 | config: Config{ |
| 2858 | MaxVersion: VersionTLS12, |
| 2859 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2860 | PreSharedKey: []byte("secret"), |
| 2861 | }, |
| 2862 | flags: []string{"-psk", "secret"}, |
| 2863 | }) |
| 2864 | |
| 2865 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2866 | // ServerKeyExchange is sent. |
| 2867 | testCases = append(testCases, testCase{ |
| 2868 | name: "ExplicitEmptyPSKHint", |
| 2869 | config: Config{ |
| 2870 | MaxVersion: VersionTLS12, |
| 2871 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2872 | PreSharedKey: []byte("secret"), |
| 2873 | Bugs: ProtocolBugs{ |
| 2874 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2875 | }, |
| 2876 | }, |
| 2877 | flags: []string{"-psk", "secret"}, |
| 2878 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2879 | } |
| 2880 | |
| 2881 | func addBadECDSASignatureTests() { |
| 2882 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2883 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2884 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2885 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2886 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2887 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2888 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2889 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2890 | Bugs: ProtocolBugs{ |
| 2891 | BadECDSAR: badR, |
| 2892 | BadECDSAS: badS, |
| 2893 | }, |
| 2894 | }, |
| 2895 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2896 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2897 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2898 | testCases = append(testCases, testCase{ |
| 2899 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2900 | config: Config{ |
| 2901 | MaxVersion: VersionTLS13, |
| 2902 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2903 | Bugs: ProtocolBugs{ |
| 2904 | BadECDSAR: badR, |
| 2905 | BadECDSAS: badS, |
| 2906 | }, |
| 2907 | }, |
| 2908 | shouldFail: true, |
| 2909 | expectedError: ":BAD_SIGNATURE:", |
| 2910 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2911 | } |
| 2912 | } |
| 2913 | } |
| 2914 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2915 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2916 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2917 | name: "MaxCBCPadding", |
| 2918 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2919 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2920 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2921 | Bugs: ProtocolBugs{ |
| 2922 | MaxPadding: true, |
| 2923 | }, |
| 2924 | }, |
| 2925 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2926 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2927 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2928 | name: "BadCBCPadding", |
| 2929 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2930 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2931 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2932 | Bugs: ProtocolBugs{ |
| 2933 | PaddingFirstByteBad: true, |
| 2934 | }, |
| 2935 | }, |
| 2936 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2937 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2938 | }) |
| 2939 | // OpenSSL previously had an issue where the first byte of padding in |
| 2940 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2941 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2942 | name: "BadCBCPadding255", |
| 2943 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2944 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2945 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2946 | Bugs: ProtocolBugs{ |
| 2947 | MaxPadding: true, |
| 2948 | PaddingFirstByteBadIf255: true, |
| 2949 | }, |
| 2950 | }, |
| 2951 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2952 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2953 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2954 | }) |
| 2955 | } |
| 2956 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2957 | func addCBCSplittingTests() { |
| 2958 | testCases = append(testCases, testCase{ |
| 2959 | name: "CBCRecordSplitting", |
| 2960 | config: Config{ |
| 2961 | MaxVersion: VersionTLS10, |
| 2962 | MinVersion: VersionTLS10, |
| 2963 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2964 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2965 | messageLen: -1, // read until EOF |
| 2966 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2967 | flags: []string{ |
| 2968 | "-async", |
| 2969 | "-write-different-record-sizes", |
| 2970 | "-cbc-record-splitting", |
| 2971 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2972 | }) |
| 2973 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2974 | name: "CBCRecordSplittingPartialWrite", |
| 2975 | config: Config{ |
| 2976 | MaxVersion: VersionTLS10, |
| 2977 | MinVersion: VersionTLS10, |
| 2978 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2979 | }, |
| 2980 | messageLen: -1, // read until EOF |
| 2981 | flags: []string{ |
| 2982 | "-async", |
| 2983 | "-write-different-record-sizes", |
| 2984 | "-cbc-record-splitting", |
| 2985 | "-partial-write", |
| 2986 | }, |
| 2987 | }) |
| 2988 | } |
| 2989 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2990 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2991 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2992 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 2993 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 2994 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 2995 | if err != nil { |
| 2996 | panic(err) |
| 2997 | } |
| 2998 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2999 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3000 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3001 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3002 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3003 | testCases = append(testCases, testCase{ |
| 3004 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3005 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3006 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3007 | MinVersion: ver.version, |
| 3008 | MaxVersion: ver.version, |
| 3009 | ClientAuth: RequireAnyClientCert, |
| 3010 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3011 | }, |
| 3012 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3013 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3014 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3015 | }, |
| 3016 | }) |
| 3017 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3018 | testType: serverTest, |
| 3019 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3020 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3021 | MinVersion: ver.version, |
| 3022 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3023 | Certificates: []Certificate{rsaCertificate}, |
| 3024 | }, |
| 3025 | flags: []string{"-require-any-client-certificate"}, |
| 3026 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3027 | if ver.version != VersionSSL30 { |
| 3028 | testCases = append(testCases, testCase{ |
| 3029 | testType: serverTest, |
| 3030 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3031 | config: Config{ |
| 3032 | MinVersion: ver.version, |
| 3033 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3034 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3035 | }, |
| 3036 | flags: []string{"-require-any-client-certificate"}, |
| 3037 | }) |
| 3038 | testCases = append(testCases, testCase{ |
| 3039 | testType: clientTest, |
| 3040 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3041 | config: Config{ |
| 3042 | MinVersion: ver.version, |
| 3043 | MaxVersion: ver.version, |
| 3044 | ClientAuth: RequireAnyClientCert, |
| 3045 | ClientCAs: certPool, |
| 3046 | }, |
| 3047 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3048 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3049 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3050 | }, |
| 3051 | }) |
| 3052 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3053 | |
| 3054 | testCases = append(testCases, testCase{ |
| 3055 | name: "NoClientCertificate-" + ver.name, |
| 3056 | config: Config{ |
| 3057 | MinVersion: ver.version, |
| 3058 | MaxVersion: ver.version, |
| 3059 | ClientAuth: RequireAnyClientCert, |
| 3060 | }, |
| 3061 | shouldFail: true, |
| 3062 | expectedLocalError: "client didn't provide a certificate", |
| 3063 | }) |
| 3064 | |
| 3065 | testCases = append(testCases, testCase{ |
| 3066 | // Even if not configured to expect a certificate, OpenSSL will |
| 3067 | // return X509_V_OK as the verify_result. |
| 3068 | testType: serverTest, |
| 3069 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3070 | config: Config{ |
| 3071 | MinVersion: ver.version, |
| 3072 | MaxVersion: ver.version, |
| 3073 | }, |
| 3074 | flags: []string{ |
| 3075 | "-expect-verify-result", |
| 3076 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3077 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3078 | }) |
| 3079 | |
| 3080 | testCases = append(testCases, testCase{ |
| 3081 | // If a client certificate is not provided, OpenSSL will still |
| 3082 | // return X509_V_OK as the verify_result. |
| 3083 | testType: serverTest, |
| 3084 | name: "NoClientCertificate-Server-" + ver.name, |
| 3085 | config: Config{ |
| 3086 | MinVersion: ver.version, |
| 3087 | MaxVersion: ver.version, |
| 3088 | }, |
| 3089 | flags: []string{ |
| 3090 | "-expect-verify-result", |
| 3091 | "-verify-peer", |
| 3092 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3093 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3094 | }) |
| 3095 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3096 | certificateRequired := "remote error: certificate required" |
| 3097 | if ver.version < VersionTLS13 { |
| 3098 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3099 | // was used. |
| 3100 | certificateRequired = "remote error: handshake failure" |
| 3101 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3102 | testCases = append(testCases, testCase{ |
| 3103 | testType: serverTest, |
| 3104 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3105 | config: Config{ |
| 3106 | MinVersion: ver.version, |
| 3107 | MaxVersion: ver.version, |
| 3108 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3109 | flags: []string{"-require-any-client-certificate"}, |
| 3110 | shouldFail: true, |
| 3111 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3112 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3113 | }) |
| 3114 | |
| 3115 | if ver.version != VersionSSL30 { |
| 3116 | testCases = append(testCases, testCase{ |
| 3117 | testType: serverTest, |
| 3118 | name: "SkipClientCertificate-" + ver.name, |
| 3119 | config: Config{ |
| 3120 | MinVersion: ver.version, |
| 3121 | MaxVersion: ver.version, |
| 3122 | Bugs: ProtocolBugs{ |
| 3123 | SkipClientCertificate: true, |
| 3124 | }, |
| 3125 | }, |
| 3126 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3127 | flags: []string{"-verify-peer"}, |
| 3128 | shouldFail: true, |
| 3129 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3130 | }) |
| 3131 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3132 | |
| 3133 | testCases = append(testCases, testCase{ |
| 3134 | testType: serverTest, |
| 3135 | name: ver.name + "-Server-CertReq-CA-List", |
| 3136 | config: Config{ |
| 3137 | MinVersion: ver.version, |
| 3138 | MaxVersion: ver.version, |
| 3139 | Certificates: []Certificate{rsaCertificate}, |
| 3140 | Bugs: ProtocolBugs{ |
| 3141 | ExpectCertificateReqNames: caNames, |
| 3142 | }, |
| 3143 | }, |
| 3144 | flags: []string{ |
| 3145 | "-require-any-client-certificate", |
| 3146 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3147 | }, |
| 3148 | }) |
| 3149 | |
| 3150 | testCases = append(testCases, testCase{ |
| 3151 | testType: clientTest, |
| 3152 | name: ver.name + "-Client-CertReq-CA-List", |
| 3153 | config: Config{ |
| 3154 | MinVersion: ver.version, |
| 3155 | MaxVersion: ver.version, |
| 3156 | Certificates: []Certificate{rsaCertificate}, |
| 3157 | ClientAuth: RequireAnyClientCert, |
| 3158 | ClientCAs: certPool, |
| 3159 | }, |
| 3160 | flags: []string{ |
| 3161 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3162 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3163 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3164 | }, |
| 3165 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3166 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3167 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3168 | // Client auth is only legal in certificate-based ciphers. |
| 3169 | testCases = append(testCases, testCase{ |
| 3170 | testType: clientTest, |
| 3171 | name: "ClientAuth-PSK", |
| 3172 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3173 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3174 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3175 | PreSharedKey: []byte("secret"), |
| 3176 | ClientAuth: RequireAnyClientCert, |
| 3177 | }, |
| 3178 | flags: []string{ |
| 3179 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3180 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3181 | "-psk", "secret", |
| 3182 | }, |
| 3183 | shouldFail: true, |
| 3184 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3185 | }) |
| 3186 | testCases = append(testCases, testCase{ |
| 3187 | testType: clientTest, |
| 3188 | name: "ClientAuth-ECDHE_PSK", |
| 3189 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3190 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3191 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3192 | PreSharedKey: []byte("secret"), |
| 3193 | ClientAuth: RequireAnyClientCert, |
| 3194 | }, |
| 3195 | flags: []string{ |
| 3196 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3197 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3198 | "-psk", "secret", |
| 3199 | }, |
| 3200 | shouldFail: true, |
| 3201 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3202 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3203 | |
| 3204 | // Regression test for a bug where the client CA list, if explicitly |
| 3205 | // set to NULL, was mis-encoded. |
| 3206 | testCases = append(testCases, testCase{ |
| 3207 | testType: serverTest, |
| 3208 | name: "Null-Client-CA-List", |
| 3209 | config: Config{ |
| 3210 | MaxVersion: VersionTLS12, |
| 3211 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3212 | Bugs: ProtocolBugs{ |
| 3213 | ExpectCertificateReqNames: [][]byte{}, |
| 3214 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3215 | }, |
| 3216 | flags: []string{ |
| 3217 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3218 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3219 | }, |
| 3220 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3221 | } |
| 3222 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3223 | func addExtendedMasterSecretTests() { |
| 3224 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3225 | |
| 3226 | for _, with := range []bool{false, true} { |
| 3227 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3228 | if with { |
| 3229 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3230 | } |
| 3231 | |
| 3232 | for _, isClient := range []bool{false, true} { |
| 3233 | suffix := "-Server" |
| 3234 | testType := serverTest |
| 3235 | if isClient { |
| 3236 | suffix = "-Client" |
| 3237 | testType = clientTest |
| 3238 | } |
| 3239 | |
| 3240 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3241 | // In TLS 1.3, the extension is irrelevant and |
| 3242 | // always reports as enabled. |
| 3243 | var flags []string |
| 3244 | if with || ver.version >= VersionTLS13 { |
| 3245 | flags = []string{expectEMSFlag} |
| 3246 | } |
| 3247 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3248 | test := testCase{ |
| 3249 | testType: testType, |
| 3250 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3251 | config: Config{ |
| 3252 | MinVersion: ver.version, |
| 3253 | MaxVersion: ver.version, |
| 3254 | Bugs: ProtocolBugs{ |
| 3255 | NoExtendedMasterSecret: !with, |
| 3256 | RequireExtendedMasterSecret: with, |
| 3257 | }, |
| 3258 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3259 | flags: flags, |
| 3260 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3261 | } |
| 3262 | if test.shouldFail { |
| 3263 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3264 | } |
| 3265 | testCases = append(testCases, test) |
| 3266 | } |
| 3267 | } |
| 3268 | } |
| 3269 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3270 | for _, isClient := range []bool{false, true} { |
| 3271 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3272 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3273 | boolToWord := func(b bool) string { |
| 3274 | if b { |
| 3275 | return "Yes" |
| 3276 | } |
| 3277 | return "No" |
| 3278 | } |
| 3279 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3280 | if isClient { |
| 3281 | suffix += "Client" |
| 3282 | } else { |
| 3283 | suffix += "Server" |
| 3284 | } |
| 3285 | |
| 3286 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3287 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3288 | Bugs: ProtocolBugs{ |
| 3289 | RequireExtendedMasterSecret: true, |
| 3290 | }, |
| 3291 | } |
| 3292 | |
| 3293 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3294 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3295 | Bugs: ProtocolBugs{ |
| 3296 | NoExtendedMasterSecret: true, |
| 3297 | }, |
| 3298 | } |
| 3299 | |
| 3300 | test := testCase{ |
| 3301 | name: "ExtendedMasterSecret-" + suffix, |
| 3302 | resumeSession: true, |
| 3303 | } |
| 3304 | |
| 3305 | if !isClient { |
| 3306 | test.testType = serverTest |
| 3307 | } |
| 3308 | |
| 3309 | if supportedInFirstConnection { |
| 3310 | test.config = supportedConfig |
| 3311 | } else { |
| 3312 | test.config = noSupportConfig |
| 3313 | } |
| 3314 | |
| 3315 | if supportedInResumeConnection { |
| 3316 | test.resumeConfig = &supportedConfig |
| 3317 | } else { |
| 3318 | test.resumeConfig = &noSupportConfig |
| 3319 | } |
| 3320 | |
| 3321 | switch suffix { |
| 3322 | case "YesToYes-Client", "YesToYes-Server": |
| 3323 | // When a session is resumed, it should |
| 3324 | // still be aware that its master |
| 3325 | // secret was generated via EMS and |
| 3326 | // thus it's safe to use tls-unique. |
| 3327 | test.flags = []string{expectEMSFlag} |
| 3328 | case "NoToYes-Server": |
| 3329 | // If an original connection did not |
| 3330 | // contain EMS, but a resumption |
| 3331 | // handshake does, then a server should |
| 3332 | // not resume the session. |
| 3333 | test.expectResumeRejected = true |
| 3334 | case "YesToNo-Server": |
| 3335 | // Resuming an EMS session without the |
| 3336 | // EMS extension should cause the |
| 3337 | // server to abort the connection. |
| 3338 | test.shouldFail = true |
| 3339 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3340 | case "NoToYes-Client": |
| 3341 | // A client should abort a connection |
| 3342 | // where the server resumed a non-EMS |
| 3343 | // session but echoed the EMS |
| 3344 | // extension. |
| 3345 | test.shouldFail = true |
| 3346 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3347 | case "YesToNo-Client": |
| 3348 | // A client should abort a connection |
| 3349 | // where the server didn't echo EMS |
| 3350 | // when the session used it. |
| 3351 | test.shouldFail = true |
| 3352 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3353 | } |
| 3354 | |
| 3355 | testCases = append(testCases, test) |
| 3356 | } |
| 3357 | } |
| 3358 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3359 | |
| 3360 | // Switching EMS on renegotiation is forbidden. |
| 3361 | testCases = append(testCases, testCase{ |
| 3362 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3363 | config: Config{ |
| 3364 | MaxVersion: VersionTLS12, |
| 3365 | Bugs: ProtocolBugs{ |
| 3366 | NoExtendedMasterSecret: true, |
| 3367 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3368 | }, |
| 3369 | }, |
| 3370 | renegotiate: 1, |
| 3371 | flags: []string{ |
| 3372 | "-renegotiate-freely", |
| 3373 | "-expect-total-renegotiations", "1", |
| 3374 | }, |
| 3375 | }) |
| 3376 | |
| 3377 | testCases = append(testCases, testCase{ |
| 3378 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3379 | config: Config{ |
| 3380 | MaxVersion: VersionTLS12, |
| 3381 | Bugs: ProtocolBugs{ |
| 3382 | NoExtendedMasterSecret: true, |
| 3383 | }, |
| 3384 | }, |
| 3385 | renegotiate: 1, |
| 3386 | flags: []string{ |
| 3387 | "-renegotiate-freely", |
| 3388 | "-expect-total-renegotiations", "1", |
| 3389 | }, |
| 3390 | shouldFail: true, |
| 3391 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3392 | }) |
| 3393 | |
| 3394 | testCases = append(testCases, testCase{ |
| 3395 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3396 | config: Config{ |
| 3397 | MaxVersion: VersionTLS12, |
| 3398 | Bugs: ProtocolBugs{ |
| 3399 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3400 | }, |
| 3401 | }, |
| 3402 | renegotiate: 1, |
| 3403 | flags: []string{ |
| 3404 | "-renegotiate-freely", |
| 3405 | "-expect-total-renegotiations", "1", |
| 3406 | }, |
| 3407 | shouldFail: true, |
| 3408 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3409 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3410 | } |
| 3411 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3412 | type stateMachineTestConfig struct { |
| 3413 | protocol protocol |
| 3414 | async bool |
| 3415 | splitHandshake, packHandshakeFlight bool |
| 3416 | } |
| 3417 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3418 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3419 | // various conditions. Some of these are redundant with other tests, but they |
| 3420 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3421 | func addAllStateMachineCoverageTests() { |
| 3422 | for _, async := range []bool{false, true} { |
| 3423 | for _, protocol := range []protocol{tls, dtls} { |
| 3424 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3425 | protocol: protocol, |
| 3426 | async: async, |
| 3427 | }) |
| 3428 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3429 | protocol: protocol, |
| 3430 | async: async, |
| 3431 | splitHandshake: true, |
| 3432 | }) |
| 3433 | if protocol == tls { |
| 3434 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3435 | protocol: protocol, |
| 3436 | async: async, |
| 3437 | packHandshakeFlight: true, |
| 3438 | }) |
| 3439 | } |
| 3440 | } |
| 3441 | } |
| 3442 | } |
| 3443 | |
| 3444 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3445 | var tests []testCase |
| 3446 | |
| 3447 | // Basic handshake, with resumption. Client and server, |
| 3448 | // session ID and session ticket. |
| 3449 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3450 | name: "Basic-Client", |
| 3451 | config: Config{ |
| 3452 | MaxVersion: VersionTLS12, |
| 3453 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3454 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3455 | // Ensure session tickets are used, not session IDs. |
| 3456 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3457 | }) |
| 3458 | tests = append(tests, testCase{ |
| 3459 | name: "Basic-Client-RenewTicket", |
| 3460 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3461 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3462 | Bugs: ProtocolBugs{ |
| 3463 | RenewTicketOnResume: true, |
| 3464 | }, |
| 3465 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3466 | flags: []string{"-expect-ticket-renewal"}, |
| 3467 | resumeSession: true, |
| 3468 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3469 | }) |
| 3470 | tests = append(tests, testCase{ |
| 3471 | name: "Basic-Client-NoTicket", |
| 3472 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3473 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3474 | SessionTicketsDisabled: true, |
| 3475 | }, |
| 3476 | resumeSession: true, |
| 3477 | }) |
| 3478 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3479 | name: "Basic-Client-Implicit", |
| 3480 | config: Config{ |
| 3481 | MaxVersion: VersionTLS12, |
| 3482 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3483 | flags: []string{"-implicit-handshake"}, |
| 3484 | resumeSession: true, |
| 3485 | }) |
| 3486 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3487 | testType: serverTest, |
| 3488 | name: "Basic-Server", |
| 3489 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3490 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3491 | Bugs: ProtocolBugs{ |
| 3492 | RequireSessionTickets: true, |
| 3493 | }, |
| 3494 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3495 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3496 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3497 | }) |
| 3498 | tests = append(tests, testCase{ |
| 3499 | testType: serverTest, |
| 3500 | name: "Basic-Server-NoTickets", |
| 3501 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3502 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3503 | SessionTicketsDisabled: true, |
| 3504 | }, |
| 3505 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3506 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3507 | }) |
| 3508 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3509 | testType: serverTest, |
| 3510 | name: "Basic-Server-Implicit", |
| 3511 | config: Config{ |
| 3512 | MaxVersion: VersionTLS12, |
| 3513 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3514 | flags: []string{"-implicit-handshake"}, |
| 3515 | resumeSession: true, |
| 3516 | }) |
| 3517 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3518 | testType: serverTest, |
| 3519 | name: "Basic-Server-EarlyCallback", |
| 3520 | config: Config{ |
| 3521 | MaxVersion: VersionTLS12, |
| 3522 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3523 | flags: []string{"-use-early-callback"}, |
| 3524 | resumeSession: true, |
| 3525 | }) |
| 3526 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3527 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3528 | if config.protocol == tls { |
| 3529 | tests = append(tests, testCase{ |
| 3530 | name: "TLS13-1RTT-Client", |
| 3531 | config: Config{ |
| 3532 | MaxVersion: VersionTLS13, |
| 3533 | MinVersion: VersionTLS13, |
| 3534 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3535 | resumeSession: true, |
| 3536 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3537 | }) |
| 3538 | |
| 3539 | tests = append(tests, testCase{ |
| 3540 | testType: serverTest, |
| 3541 | name: "TLS13-1RTT-Server", |
| 3542 | config: Config{ |
| 3543 | MaxVersion: VersionTLS13, |
| 3544 | MinVersion: VersionTLS13, |
| 3545 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3546 | resumeSession: true, |
| 3547 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3548 | // TLS 1.3 uses tickets, so the session should not be |
| 3549 | // cached statefully. |
| 3550 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3551 | }) |
| 3552 | |
| 3553 | tests = append(tests, testCase{ |
| 3554 | name: "TLS13-HelloRetryRequest-Client", |
| 3555 | config: Config{ |
| 3556 | MaxVersion: VersionTLS13, |
| 3557 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3558 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3559 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3560 | CurvePreferences: []CurveID{CurveP384}, |
| 3561 | Bugs: ProtocolBugs{ |
| 3562 | ExpectMissingKeyShare: true, |
| 3563 | }, |
| 3564 | }, |
| 3565 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3566 | resumeSession: true, |
| 3567 | }) |
| 3568 | |
| 3569 | tests = append(tests, testCase{ |
| 3570 | testType: serverTest, |
| 3571 | name: "TLS13-HelloRetryRequest-Server", |
| 3572 | config: Config{ |
| 3573 | MaxVersion: VersionTLS13, |
| 3574 | MinVersion: VersionTLS13, |
| 3575 | // Require a HelloRetryRequest for every curve. |
| 3576 | DefaultCurves: []CurveID{}, |
| 3577 | }, |
| 3578 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3579 | resumeSession: true, |
| 3580 | }) |
| 3581 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3582 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3583 | // TLS client auth. |
| 3584 | tests = append(tests, testCase{ |
| 3585 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3586 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3587 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3588 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3589 | ClientAuth: RequestClientCert, |
| 3590 | }, |
| 3591 | }) |
| 3592 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3593 | testType: serverTest, |
| 3594 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3595 | config: Config{ |
| 3596 | MaxVersion: VersionTLS12, |
| 3597 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3598 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3599 | flags: []string{"-verify-peer"}, |
| 3600 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3601 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3602 | tests = append(tests, testCase{ |
| 3603 | testType: clientTest, |
| 3604 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3605 | config: Config{ |
| 3606 | MaxVersion: VersionSSL30, |
| 3607 | ClientAuth: RequestClientCert, |
| 3608 | }, |
| 3609 | }) |
| 3610 | tests = append(tests, testCase{ |
| 3611 | testType: serverTest, |
| 3612 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3613 | config: Config{ |
| 3614 | MaxVersion: VersionSSL30, |
| 3615 | }, |
| 3616 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3617 | flags: []string{"-verify-peer"}, |
| 3618 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3619 | tests = append(tests, testCase{ |
| 3620 | testType: clientTest, |
| 3621 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3622 | config: Config{ |
| 3623 | MaxVersion: VersionTLS13, |
| 3624 | ClientAuth: RequestClientCert, |
| 3625 | }, |
| 3626 | }) |
| 3627 | tests = append(tests, testCase{ |
| 3628 | testType: serverTest, |
| 3629 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3630 | config: Config{ |
| 3631 | MaxVersion: VersionTLS13, |
| 3632 | }, |
| 3633 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3634 | flags: []string{"-verify-peer"}, |
| 3635 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3636 | } |
| 3637 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3638 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3639 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3640 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3641 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3642 | ClientAuth: RequireAnyClientCert, |
| 3643 | }, |
| 3644 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3645 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3646 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3647 | }, |
| 3648 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3649 | tests = append(tests, testCase{ |
| 3650 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3651 | name: "ClientAuth-RSA-Client-TLS13", |
| 3652 | config: Config{ |
| 3653 | MaxVersion: VersionTLS13, |
| 3654 | ClientAuth: RequireAnyClientCert, |
| 3655 | }, |
| 3656 | flags: []string{ |
| 3657 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3658 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3659 | }, |
| 3660 | }) |
| 3661 | tests = append(tests, testCase{ |
| 3662 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3663 | name: "ClientAuth-ECDSA-Client", |
| 3664 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3665 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3666 | ClientAuth: RequireAnyClientCert, |
| 3667 | }, |
| 3668 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3669 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3670 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3671 | }, |
| 3672 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3673 | tests = append(tests, testCase{ |
| 3674 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3675 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3676 | config: Config{ |
| 3677 | MaxVersion: VersionTLS13, |
| 3678 | ClientAuth: RequireAnyClientCert, |
| 3679 | }, |
| 3680 | flags: []string{ |
| 3681 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3682 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3683 | }, |
| 3684 | }) |
| 3685 | tests = append(tests, testCase{ |
| 3686 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3687 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3688 | config: Config{ |
| 3689 | MaxVersion: VersionTLS12, |
| 3690 | ClientAuth: RequestClientCert, |
| 3691 | }, |
| 3692 | flags: []string{"-use-old-client-cert-callback"}, |
| 3693 | }) |
| 3694 | tests = append(tests, testCase{ |
| 3695 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3696 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3697 | config: Config{ |
| 3698 | MaxVersion: VersionTLS13, |
| 3699 | ClientAuth: RequestClientCert, |
| 3700 | }, |
| 3701 | flags: []string{"-use-old-client-cert-callback"}, |
| 3702 | }) |
| 3703 | tests = append(tests, testCase{ |
| 3704 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3705 | name: "ClientAuth-OldCallback", |
| 3706 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3707 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3708 | ClientAuth: RequireAnyClientCert, |
| 3709 | }, |
| 3710 | flags: []string{ |
| 3711 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3712 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3713 | "-use-old-client-cert-callback", |
| 3714 | }, |
| 3715 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3716 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3717 | testType: clientTest, |
| 3718 | name: "ClientAuth-OldCallback-TLS13", |
| 3719 | config: Config{ |
| 3720 | MaxVersion: VersionTLS13, |
| 3721 | ClientAuth: RequireAnyClientCert, |
| 3722 | }, |
| 3723 | flags: []string{ |
| 3724 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3725 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3726 | "-use-old-client-cert-callback", |
| 3727 | }, |
| 3728 | }) |
| 3729 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3730 | testType: serverTest, |
| 3731 | name: "ClientAuth-Server", |
| 3732 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3733 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3734 | Certificates: []Certificate{rsaCertificate}, |
| 3735 | }, |
| 3736 | flags: []string{"-require-any-client-certificate"}, |
| 3737 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3738 | tests = append(tests, testCase{ |
| 3739 | testType: serverTest, |
| 3740 | name: "ClientAuth-Server-TLS13", |
| 3741 | config: Config{ |
| 3742 | MaxVersion: VersionTLS13, |
| 3743 | Certificates: []Certificate{rsaCertificate}, |
| 3744 | }, |
| 3745 | flags: []string{"-require-any-client-certificate"}, |
| 3746 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3747 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3748 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3749 | tests = append(tests, testCase{ |
| 3750 | testType: serverTest, |
| 3751 | name: "Basic-Server-RSA", |
| 3752 | config: Config{ |
| 3753 | MaxVersion: VersionTLS12, |
| 3754 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3755 | }, |
| 3756 | flags: []string{ |
| 3757 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3758 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3759 | }, |
| 3760 | }) |
| 3761 | tests = append(tests, testCase{ |
| 3762 | testType: serverTest, |
| 3763 | name: "Basic-Server-ECDHE-RSA", |
| 3764 | config: Config{ |
| 3765 | MaxVersion: VersionTLS12, |
| 3766 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3767 | }, |
| 3768 | flags: []string{ |
| 3769 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3770 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3771 | }, |
| 3772 | }) |
| 3773 | tests = append(tests, testCase{ |
| 3774 | testType: serverTest, |
| 3775 | name: "Basic-Server-ECDHE-ECDSA", |
| 3776 | config: Config{ |
| 3777 | MaxVersion: VersionTLS12, |
| 3778 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3779 | }, |
| 3780 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3781 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3782 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3783 | }, |
| 3784 | }) |
| 3785 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3786 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3787 | tests = append(tests, testCase{ |
| 3788 | name: "SessionTicketsDisabled-Client", |
| 3789 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3790 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3791 | SessionTicketsDisabled: true, |
| 3792 | }, |
| 3793 | }) |
| 3794 | tests = append(tests, testCase{ |
| 3795 | testType: serverTest, |
| 3796 | name: "SessionTicketsDisabled-Server", |
| 3797 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3798 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3799 | SessionTicketsDisabled: true, |
| 3800 | }, |
| 3801 | }) |
| 3802 | |
| 3803 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3804 | // identity hint. |
| 3805 | tests = append(tests, testCase{ |
| 3806 | name: "EmptyPSKHint-Client", |
| 3807 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3808 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3809 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3810 | PreSharedKey: []byte("secret"), |
| 3811 | }, |
| 3812 | flags: []string{"-psk", "secret"}, |
| 3813 | }) |
| 3814 | tests = append(tests, testCase{ |
| 3815 | testType: serverTest, |
| 3816 | name: "EmptyPSKHint-Server", |
| 3817 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3818 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3819 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3820 | PreSharedKey: []byte("secret"), |
| 3821 | }, |
| 3822 | flags: []string{"-psk", "secret"}, |
| 3823 | }) |
| 3824 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3825 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3826 | tests = append(tests, testCase{ |
| 3827 | testType: clientTest, |
| 3828 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3829 | config: Config{ |
| 3830 | MaxVersion: VersionTLS12, |
| 3831 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3832 | flags: []string{ |
| 3833 | "-enable-ocsp-stapling", |
| 3834 | "-expect-ocsp-response", |
| 3835 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3836 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3837 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3838 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3839 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3840 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3841 | testType: serverTest, |
| 3842 | name: "OCSPStapling-Server", |
| 3843 | config: Config{ |
| 3844 | MaxVersion: VersionTLS12, |
| 3845 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3846 | expectedOCSPResponse: testOCSPResponse, |
| 3847 | flags: []string{ |
| 3848 | "-ocsp-response", |
| 3849 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3850 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3851 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3852 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3853 | tests = append(tests, testCase{ |
| 3854 | testType: clientTest, |
| 3855 | name: "OCSPStapling-Client-TLS13", |
| 3856 | config: Config{ |
| 3857 | MaxVersion: VersionTLS13, |
| 3858 | }, |
| 3859 | flags: []string{ |
| 3860 | "-enable-ocsp-stapling", |
| 3861 | "-expect-ocsp-response", |
| 3862 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3863 | "-verify-peer", |
| 3864 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3865 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3866 | }) |
| 3867 | tests = append(tests, testCase{ |
| 3868 | testType: serverTest, |
| 3869 | name: "OCSPStapling-Server-TLS13", |
| 3870 | config: Config{ |
| 3871 | MaxVersion: VersionTLS13, |
| 3872 | }, |
| 3873 | expectedOCSPResponse: testOCSPResponse, |
| 3874 | flags: []string{ |
| 3875 | "-ocsp-response", |
| 3876 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3877 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3878 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3879 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3880 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3881 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3882 | for _, vers := range tlsVersions { |
| 3883 | if config.protocol == dtls && !vers.hasDTLS { |
| 3884 | continue |
| 3885 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3886 | for _, testType := range []testType{clientTest, serverTest} { |
| 3887 | suffix := "-Client" |
| 3888 | if testType == serverTest { |
| 3889 | suffix = "-Server" |
| 3890 | } |
| 3891 | suffix += "-" + vers.name |
| 3892 | |
| 3893 | flag := "-verify-peer" |
| 3894 | if testType == serverTest { |
| 3895 | flag = "-require-any-client-certificate" |
| 3896 | } |
| 3897 | |
| 3898 | tests = append(tests, testCase{ |
| 3899 | testType: testType, |
| 3900 | name: "CertificateVerificationSucceed" + suffix, |
| 3901 | config: Config{ |
| 3902 | MaxVersion: vers.version, |
| 3903 | Certificates: []Certificate{rsaCertificate}, |
| 3904 | }, |
| 3905 | flags: []string{ |
| 3906 | flag, |
| 3907 | "-expect-verify-result", |
| 3908 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3909 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3910 | }) |
| 3911 | tests = append(tests, testCase{ |
| 3912 | testType: testType, |
| 3913 | name: "CertificateVerificationFail" + suffix, |
| 3914 | config: Config{ |
| 3915 | MaxVersion: vers.version, |
| 3916 | Certificates: []Certificate{rsaCertificate}, |
| 3917 | }, |
| 3918 | flags: []string{ |
| 3919 | flag, |
| 3920 | "-verify-fail", |
| 3921 | }, |
| 3922 | shouldFail: true, |
| 3923 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3924 | }) |
| 3925 | } |
| 3926 | |
| 3927 | // By default, the client is in a soft fail mode where the peer |
| 3928 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3929 | tests = append(tests, testCase{ |
| 3930 | testType: clientTest, |
| 3931 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3932 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3933 | MaxVersion: vers.version, |
| 3934 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3935 | }, |
| 3936 | flags: []string{ |
| 3937 | "-verify-fail", |
| 3938 | "-expect-verify-result", |
| 3939 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3940 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3941 | }) |
| 3942 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3943 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3944 | tests = append(tests, testCase{ |
| 3945 | name: "ShimSendAlert", |
| 3946 | flags: []string{"-send-alert"}, |
| 3947 | shimWritesFirst: true, |
| 3948 | shouldFail: true, |
| 3949 | expectedLocalError: "remote error: decompression failure", |
| 3950 | }) |
| 3951 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3952 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3953 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3954 | name: "Renegotiate-Client", |
| 3955 | config: Config{ |
| 3956 | MaxVersion: VersionTLS12, |
| 3957 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3958 | renegotiate: 1, |
| 3959 | flags: []string{ |
| 3960 | "-renegotiate-freely", |
| 3961 | "-expect-total-renegotiations", "1", |
| 3962 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3963 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3964 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3965 | tests = append(tests, testCase{ |
| 3966 | name: "SendHalfHelloRequest", |
| 3967 | config: Config{ |
| 3968 | MaxVersion: VersionTLS12, |
| 3969 | Bugs: ProtocolBugs{ |
| 3970 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3971 | }, |
| 3972 | }, |
| 3973 | sendHalfHelloRequest: true, |
| 3974 | flags: []string{"-renegotiate-ignore"}, |
| 3975 | shouldFail: true, |
| 3976 | expectedError: ":UNEXPECTED_RECORD:", |
| 3977 | }) |
| 3978 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3979 | // NPN on client and server; results in post-handshake message. |
| 3980 | tests = append(tests, testCase{ |
| 3981 | name: "NPN-Client", |
| 3982 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3983 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3984 | NextProtos: []string{"foo"}, |
| 3985 | }, |
| 3986 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3987 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3988 | expectedNextProto: "foo", |
| 3989 | expectedNextProtoType: npn, |
| 3990 | }) |
| 3991 | tests = append(tests, testCase{ |
| 3992 | testType: serverTest, |
| 3993 | name: "NPN-Server", |
| 3994 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3995 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3996 | NextProtos: []string{"bar"}, |
| 3997 | }, |
| 3998 | flags: []string{ |
| 3999 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4000 | "-expect-next-proto", "bar", |
| 4001 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4002 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4003 | expectedNextProto: "bar", |
| 4004 | expectedNextProtoType: npn, |
| 4005 | }) |
| 4006 | |
| 4007 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4008 | |
| 4009 | // Client does False Start and negotiates NPN. |
| 4010 | tests = append(tests, testCase{ |
| 4011 | name: "FalseStart", |
| 4012 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4013 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4014 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4015 | NextProtos: []string{"foo"}, |
| 4016 | Bugs: ProtocolBugs{ |
| 4017 | ExpectFalseStart: true, |
| 4018 | }, |
| 4019 | }, |
| 4020 | flags: []string{ |
| 4021 | "-false-start", |
| 4022 | "-select-next-proto", "foo", |
| 4023 | }, |
| 4024 | shimWritesFirst: true, |
| 4025 | resumeSession: true, |
| 4026 | }) |
| 4027 | |
| 4028 | // Client does False Start and negotiates ALPN. |
| 4029 | tests = append(tests, testCase{ |
| 4030 | name: "FalseStart-ALPN", |
| 4031 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4032 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4033 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4034 | NextProtos: []string{"foo"}, |
| 4035 | Bugs: ProtocolBugs{ |
| 4036 | ExpectFalseStart: true, |
| 4037 | }, |
| 4038 | }, |
| 4039 | flags: []string{ |
| 4040 | "-false-start", |
| 4041 | "-advertise-alpn", "\x03foo", |
| 4042 | }, |
| 4043 | shimWritesFirst: true, |
| 4044 | resumeSession: true, |
| 4045 | }) |
| 4046 | |
| 4047 | // Client does False Start but doesn't explicitly call |
| 4048 | // SSL_connect. |
| 4049 | tests = append(tests, testCase{ |
| 4050 | name: "FalseStart-Implicit", |
| 4051 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4052 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4053 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4054 | NextProtos: []string{"foo"}, |
| 4055 | }, |
| 4056 | flags: []string{ |
| 4057 | "-implicit-handshake", |
| 4058 | "-false-start", |
| 4059 | "-advertise-alpn", "\x03foo", |
| 4060 | }, |
| 4061 | }) |
| 4062 | |
| 4063 | // False Start without session tickets. |
| 4064 | tests = append(tests, testCase{ |
| 4065 | name: "FalseStart-SessionTicketsDisabled", |
| 4066 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4067 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4068 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4069 | NextProtos: []string{"foo"}, |
| 4070 | SessionTicketsDisabled: true, |
| 4071 | Bugs: ProtocolBugs{ |
| 4072 | ExpectFalseStart: true, |
| 4073 | }, |
| 4074 | }, |
| 4075 | flags: []string{ |
| 4076 | "-false-start", |
| 4077 | "-select-next-proto", "foo", |
| 4078 | }, |
| 4079 | shimWritesFirst: true, |
| 4080 | }) |
| 4081 | |
| 4082 | // Server parses a V2ClientHello. |
| 4083 | tests = append(tests, testCase{ |
| 4084 | testType: serverTest, |
| 4085 | name: "SendV2ClientHello", |
| 4086 | config: Config{ |
| 4087 | // Choose a cipher suite that does not involve |
| 4088 | // elliptic curves, so no extensions are |
| 4089 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4090 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4091 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4092 | Bugs: ProtocolBugs{ |
| 4093 | SendV2ClientHello: true, |
| 4094 | }, |
| 4095 | }, |
| 4096 | }) |
| 4097 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4098 | // Test Channel ID |
| 4099 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4100 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4101 | continue |
| 4102 | } |
| 4103 | // Client sends a Channel ID. |
| 4104 | tests = append(tests, testCase{ |
| 4105 | name: "ChannelID-Client-" + ver.name, |
| 4106 | config: Config{ |
| 4107 | MaxVersion: ver.version, |
| 4108 | RequestChannelID: true, |
| 4109 | }, |
| 4110 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4111 | resumeSession: true, |
| 4112 | expectChannelID: true, |
| 4113 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4114 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4115 | // Server accepts a Channel ID. |
| 4116 | tests = append(tests, testCase{ |
| 4117 | testType: serverTest, |
| 4118 | name: "ChannelID-Server-" + ver.name, |
| 4119 | config: Config{ |
| 4120 | MaxVersion: ver.version, |
| 4121 | ChannelID: channelIDKey, |
| 4122 | }, |
| 4123 | flags: []string{ |
| 4124 | "-expect-channel-id", |
| 4125 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4126 | }, |
| 4127 | resumeSession: true, |
| 4128 | expectChannelID: true, |
| 4129 | }) |
| 4130 | |
| 4131 | tests = append(tests, testCase{ |
| 4132 | testType: serverTest, |
| 4133 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4134 | config: Config{ |
| 4135 | MaxVersion: ver.version, |
| 4136 | ChannelID: channelIDKey, |
| 4137 | Bugs: ProtocolBugs{ |
| 4138 | InvalidChannelIDSignature: true, |
| 4139 | }, |
| 4140 | }, |
| 4141 | flags: []string{"-enable-channel-id"}, |
| 4142 | shouldFail: true, |
| 4143 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4144 | }) |
| 4145 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4146 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4147 | // Channel ID and NPN at the same time, to ensure their relative |
| 4148 | // ordering is correct. |
| 4149 | tests = append(tests, testCase{ |
| 4150 | name: "ChannelID-NPN-Client", |
| 4151 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4152 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4153 | RequestChannelID: true, |
| 4154 | NextProtos: []string{"foo"}, |
| 4155 | }, |
| 4156 | flags: []string{ |
| 4157 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4158 | "-select-next-proto", "foo", |
| 4159 | }, |
| 4160 | resumeSession: true, |
| 4161 | expectChannelID: true, |
| 4162 | expectedNextProto: "foo", |
| 4163 | expectedNextProtoType: npn, |
| 4164 | }) |
| 4165 | tests = append(tests, testCase{ |
| 4166 | testType: serverTest, |
| 4167 | name: "ChannelID-NPN-Server", |
| 4168 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4169 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4170 | ChannelID: channelIDKey, |
| 4171 | NextProtos: []string{"bar"}, |
| 4172 | }, |
| 4173 | flags: []string{ |
| 4174 | "-expect-channel-id", |
| 4175 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4176 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4177 | "-expect-next-proto", "bar", |
| 4178 | }, |
| 4179 | resumeSession: true, |
| 4180 | expectChannelID: true, |
| 4181 | expectedNextProto: "bar", |
| 4182 | expectedNextProtoType: npn, |
| 4183 | }) |
| 4184 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4185 | // Bidirectional shutdown with the runner initiating. |
| 4186 | tests = append(tests, testCase{ |
| 4187 | name: "Shutdown-Runner", |
| 4188 | config: Config{ |
| 4189 | Bugs: ProtocolBugs{ |
| 4190 | ExpectCloseNotify: true, |
| 4191 | }, |
| 4192 | }, |
| 4193 | flags: []string{"-check-close-notify"}, |
| 4194 | }) |
| 4195 | |
| 4196 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4197 | // in the meantime, sends garbage before the close_notify which |
| 4198 | // the shim must ignore. |
| 4199 | tests = append(tests, testCase{ |
| 4200 | name: "Shutdown-Shim", |
| 4201 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4202 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4203 | Bugs: ProtocolBugs{ |
| 4204 | ExpectCloseNotify: true, |
| 4205 | }, |
| 4206 | }, |
| 4207 | shimShutsDown: true, |
| 4208 | sendEmptyRecords: 1, |
| 4209 | sendWarningAlerts: 1, |
| 4210 | flags: []string{"-check-close-notify"}, |
| 4211 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4212 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4213 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4214 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4215 | tests = append(tests, testCase{ |
| 4216 | name: "SkipHelloVerifyRequest", |
| 4217 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4218 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4219 | Bugs: ProtocolBugs{ |
| 4220 | SkipHelloVerifyRequest: true, |
| 4221 | }, |
| 4222 | }, |
| 4223 | }) |
| 4224 | } |
| 4225 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4226 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4227 | test.protocol = config.protocol |
| 4228 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4229 | test.name += "-DTLS" |
| 4230 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4231 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4232 | test.name += "-Async" |
| 4233 | test.flags = append(test.flags, "-async") |
| 4234 | } else { |
| 4235 | test.name += "-Sync" |
| 4236 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4237 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4238 | test.name += "-SplitHandshakeRecords" |
| 4239 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4240 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4241 | test.config.Bugs.MaxPacketLength = 256 |
| 4242 | test.flags = append(test.flags, "-mtu", "256") |
| 4243 | } |
| 4244 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4245 | if config.packHandshakeFlight { |
| 4246 | test.name += "-PackHandshakeFlight" |
| 4247 | test.config.Bugs.PackHandshakeFlight = true |
| 4248 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4249 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4250 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4251 | } |
| 4252 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4253 | func addDDoSCallbackTests() { |
| 4254 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4255 | for _, resume := range []bool{false, true} { |
| 4256 | suffix := "Resume" |
| 4257 | if resume { |
| 4258 | suffix = "No" + suffix |
| 4259 | } |
| 4260 | |
| 4261 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4262 | testType: serverTest, |
| 4263 | name: "Server-DDoS-OK-" + suffix, |
| 4264 | config: Config{ |
| 4265 | MaxVersion: VersionTLS12, |
| 4266 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4267 | flags: []string{"-install-ddos-callback"}, |
| 4268 | resumeSession: resume, |
| 4269 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4270 | testCases = append(testCases, testCase{ |
| 4271 | testType: serverTest, |
| 4272 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4273 | config: Config{ |
| 4274 | MaxVersion: VersionTLS13, |
| 4275 | }, |
| 4276 | flags: []string{"-install-ddos-callback"}, |
| 4277 | resumeSession: resume, |
| 4278 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4279 | |
| 4280 | failFlag := "-fail-ddos-callback" |
| 4281 | if resume { |
| 4282 | failFlag = "-fail-second-ddos-callback" |
| 4283 | } |
| 4284 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4285 | testType: serverTest, |
| 4286 | name: "Server-DDoS-Reject-" + suffix, |
| 4287 | config: Config{ |
| 4288 | MaxVersion: VersionTLS12, |
| 4289 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4290 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4291 | resumeSession: resume, |
| 4292 | shouldFail: true, |
| 4293 | expectedError: ":CONNECTION_REJECTED:", |
| 4294 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4295 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4296 | testCases = append(testCases, testCase{ |
| 4297 | testType: serverTest, |
| 4298 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4299 | config: Config{ |
| 4300 | MaxVersion: VersionTLS13, |
| 4301 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4302 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4303 | resumeSession: resume, |
| 4304 | shouldFail: true, |
| 4305 | expectedError: ":CONNECTION_REJECTED:", |
| 4306 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4307 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4308 | } |
| 4309 | } |
| 4310 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4311 | func addVersionNegotiationTests() { |
| 4312 | for i, shimVers := range tlsVersions { |
| 4313 | // Assemble flags to disable all newer versions on the shim. |
| 4314 | var flags []string |
| 4315 | for _, vers := range tlsVersions[i+1:] { |
| 4316 | flags = append(flags, vers.flag) |
| 4317 | } |
| 4318 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4319 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4320 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4321 | protocols := []protocol{tls} |
| 4322 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4323 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4324 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4325 | for _, protocol := range protocols { |
| 4326 | expectedVersion := shimVers.version |
| 4327 | if runnerVers.version < shimVers.version { |
| 4328 | expectedVersion = runnerVers.version |
| 4329 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4330 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4331 | suffix := shimVers.name + "-" + runnerVers.name |
| 4332 | if protocol == dtls { |
| 4333 | suffix += "-DTLS" |
| 4334 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4335 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4336 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4337 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4338 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4339 | clientVers := shimVers.version |
| 4340 | if clientVers > VersionTLS10 { |
| 4341 | clientVers = VersionTLS10 |
| 4342 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4343 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4344 | serverVers := expectedVersion |
| 4345 | if expectedVersion >= VersionTLS13 { |
| 4346 | serverVers = VersionTLS10 |
| 4347 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4348 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4349 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4350 | testCases = append(testCases, testCase{ |
| 4351 | protocol: protocol, |
| 4352 | testType: clientTest, |
| 4353 | name: "VersionNegotiation-Client-" + suffix, |
| 4354 | config: Config{ |
| 4355 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4356 | Bugs: ProtocolBugs{ |
| 4357 | ExpectInitialRecordVersion: clientVers, |
| 4358 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4359 | }, |
| 4360 | flags: flags, |
| 4361 | expectedVersion: expectedVersion, |
| 4362 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4363 | testCases = append(testCases, testCase{ |
| 4364 | protocol: protocol, |
| 4365 | testType: clientTest, |
| 4366 | name: "VersionNegotiation-Client2-" + suffix, |
| 4367 | config: Config{ |
| 4368 | MaxVersion: runnerVers.version, |
| 4369 | Bugs: ProtocolBugs{ |
| 4370 | ExpectInitialRecordVersion: clientVers, |
| 4371 | }, |
| 4372 | }, |
| 4373 | flags: []string{"-max-version", shimVersFlag}, |
| 4374 | expectedVersion: expectedVersion, |
| 4375 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4376 | |
| 4377 | testCases = append(testCases, testCase{ |
| 4378 | protocol: protocol, |
| 4379 | testType: serverTest, |
| 4380 | name: "VersionNegotiation-Server-" + suffix, |
| 4381 | config: Config{ |
| 4382 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4383 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4384 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4385 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4386 | }, |
| 4387 | flags: flags, |
| 4388 | expectedVersion: expectedVersion, |
| 4389 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4390 | testCases = append(testCases, testCase{ |
| 4391 | protocol: protocol, |
| 4392 | testType: serverTest, |
| 4393 | name: "VersionNegotiation-Server2-" + suffix, |
| 4394 | config: Config{ |
| 4395 | MaxVersion: runnerVers.version, |
| 4396 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4397 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4398 | }, |
| 4399 | }, |
| 4400 | flags: []string{"-max-version", shimVersFlag}, |
| 4401 | expectedVersion: expectedVersion, |
| 4402 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4403 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4404 | } |
| 4405 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4406 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4407 | // Test the version extension at all versions. |
| 4408 | for _, vers := range tlsVersions { |
| 4409 | protocols := []protocol{tls} |
| 4410 | if vers.hasDTLS { |
| 4411 | protocols = append(protocols, dtls) |
| 4412 | } |
| 4413 | for _, protocol := range protocols { |
| 4414 | suffix := vers.name |
| 4415 | if protocol == dtls { |
| 4416 | suffix += "-DTLS" |
| 4417 | } |
| 4418 | |
| 4419 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4420 | testCases = append(testCases, testCase{ |
| 4421 | protocol: protocol, |
| 4422 | testType: serverTest, |
| 4423 | name: "VersionNegotiationExtension-" + suffix, |
| 4424 | config: Config{ |
| 4425 | Bugs: ProtocolBugs{ |
| 4426 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4427 | }, |
| 4428 | }, |
| 4429 | expectedVersion: vers.version, |
| 4430 | }) |
| 4431 | } |
| 4432 | |
| 4433 | } |
| 4434 | |
| 4435 | // If all versions are unknown, negotiation fails. |
| 4436 | testCases = append(testCases, testCase{ |
| 4437 | testType: serverTest, |
| 4438 | name: "NoSupportedVersions", |
| 4439 | config: Config{ |
| 4440 | Bugs: ProtocolBugs{ |
| 4441 | SendSupportedVersions: []uint16{0x1111}, |
| 4442 | }, |
| 4443 | }, |
| 4444 | shouldFail: true, |
| 4445 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4446 | }) |
| 4447 | testCases = append(testCases, testCase{ |
| 4448 | protocol: dtls, |
| 4449 | testType: serverTest, |
| 4450 | name: "NoSupportedVersions-DTLS", |
| 4451 | config: Config{ |
| 4452 | Bugs: ProtocolBugs{ |
| 4453 | SendSupportedVersions: []uint16{0x1111}, |
| 4454 | }, |
| 4455 | }, |
| 4456 | shouldFail: true, |
| 4457 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4458 | }) |
| 4459 | |
| 4460 | testCases = append(testCases, testCase{ |
| 4461 | testType: serverTest, |
| 4462 | name: "ClientHelloVersionTooHigh", |
| 4463 | config: Config{ |
| 4464 | MaxVersion: VersionTLS13, |
| 4465 | Bugs: ProtocolBugs{ |
| 4466 | SendClientVersion: 0x0304, |
| 4467 | OmitSupportedVersions: true, |
| 4468 | }, |
| 4469 | }, |
| 4470 | expectedVersion: VersionTLS12, |
| 4471 | }) |
| 4472 | |
| 4473 | testCases = append(testCases, testCase{ |
| 4474 | testType: serverTest, |
| 4475 | name: "ConflictingVersionNegotiation", |
| 4476 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4477 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4478 | SendClientVersion: VersionTLS12, |
| 4479 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4480 | }, |
| 4481 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4482 | // The extension takes precedence over the ClientHello version. |
| 4483 | expectedVersion: VersionTLS11, |
| 4484 | }) |
| 4485 | |
| 4486 | testCases = append(testCases, testCase{ |
| 4487 | testType: serverTest, |
| 4488 | name: "ConflictingVersionNegotiation-2", |
| 4489 | config: Config{ |
| 4490 | Bugs: ProtocolBugs{ |
| 4491 | SendClientVersion: VersionTLS11, |
| 4492 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4493 | }, |
| 4494 | }, |
| 4495 | // The extension takes precedence over the ClientHello version. |
| 4496 | expectedVersion: VersionTLS12, |
| 4497 | }) |
| 4498 | |
| 4499 | testCases = append(testCases, testCase{ |
| 4500 | testType: serverTest, |
| 4501 | name: "RejectFinalTLS13", |
| 4502 | config: Config{ |
| 4503 | Bugs: ProtocolBugs{ |
| 4504 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4505 | }, |
| 4506 | }, |
| 4507 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4508 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4509 | expectedVersion: VersionTLS12, |
| 4510 | }) |
| 4511 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4512 | // Test that the maximum version is selected regardless of the |
| 4513 | // client-sent order. |
| 4514 | testCases = append(testCases, testCase{ |
| 4515 | testType: serverTest, |
| 4516 | name: "IgnoreClientVersionOrder", |
| 4517 | config: Config{ |
| 4518 | Bugs: ProtocolBugs{ |
| 4519 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4520 | }, |
| 4521 | }, |
| 4522 | expectedVersion: VersionTLS13, |
| 4523 | }) |
| 4524 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4525 | // Test for version tolerance. |
| 4526 | testCases = append(testCases, testCase{ |
| 4527 | testType: serverTest, |
| 4528 | name: "MinorVersionTolerance", |
| 4529 | config: Config{ |
| 4530 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4531 | SendClientVersion: 0x03ff, |
| 4532 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4533 | }, |
| 4534 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4535 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4536 | }) |
| 4537 | testCases = append(testCases, testCase{ |
| 4538 | testType: serverTest, |
| 4539 | name: "MajorVersionTolerance", |
| 4540 | config: Config{ |
| 4541 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4542 | SendClientVersion: 0x0400, |
| 4543 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4544 | }, |
| 4545 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4546 | // TLS 1.3 must be negotiated with the supported_versions |
| 4547 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4548 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4549 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4550 | testCases = append(testCases, testCase{ |
| 4551 | testType: serverTest, |
| 4552 | name: "VersionTolerance-TLS13", |
| 4553 | config: Config{ |
| 4554 | Bugs: ProtocolBugs{ |
| 4555 | // Although TLS 1.3 does not use |
| 4556 | // ClientHello.version, it still tolerates high |
| 4557 | // values there. |
| 4558 | SendClientVersion: 0x0400, |
| 4559 | }, |
| 4560 | }, |
| 4561 | expectedVersion: VersionTLS13, |
| 4562 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4563 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4564 | testCases = append(testCases, testCase{ |
| 4565 | protocol: dtls, |
| 4566 | testType: serverTest, |
| 4567 | name: "MinorVersionTolerance-DTLS", |
| 4568 | config: Config{ |
| 4569 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4570 | SendClientVersion: 0xfe00, |
| 4571 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4572 | }, |
| 4573 | }, |
| 4574 | expectedVersion: VersionTLS12, |
| 4575 | }) |
| 4576 | testCases = append(testCases, testCase{ |
| 4577 | protocol: dtls, |
| 4578 | testType: serverTest, |
| 4579 | name: "MajorVersionTolerance-DTLS", |
| 4580 | config: Config{ |
| 4581 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4582 | SendClientVersion: 0xfdff, |
| 4583 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4584 | }, |
| 4585 | }, |
| 4586 | expectedVersion: VersionTLS12, |
| 4587 | }) |
| 4588 | |
| 4589 | // Test that versions below 3.0 are rejected. |
| 4590 | testCases = append(testCases, testCase{ |
| 4591 | testType: serverTest, |
| 4592 | name: "VersionTooLow", |
| 4593 | config: Config{ |
| 4594 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4595 | SendClientVersion: 0x0200, |
| 4596 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4597 | }, |
| 4598 | }, |
| 4599 | shouldFail: true, |
| 4600 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4601 | }) |
| 4602 | testCases = append(testCases, testCase{ |
| 4603 | protocol: dtls, |
| 4604 | testType: serverTest, |
| 4605 | name: "VersionTooLow-DTLS", |
| 4606 | config: Config{ |
| 4607 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4608 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4609 | }, |
| 4610 | }, |
| 4611 | shouldFail: true, |
| 4612 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4613 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4614 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4615 | testCases = append(testCases, testCase{ |
| 4616 | name: "ServerBogusVersion", |
| 4617 | config: Config{ |
| 4618 | Bugs: ProtocolBugs{ |
| 4619 | SendServerHelloVersion: 0x1234, |
| 4620 | }, |
| 4621 | }, |
| 4622 | shouldFail: true, |
| 4623 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4624 | }) |
| 4625 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4626 | // Test TLS 1.3's downgrade signal. |
| 4627 | testCases = append(testCases, testCase{ |
| 4628 | name: "Downgrade-TLS12-Client", |
| 4629 | config: Config{ |
| 4630 | Bugs: ProtocolBugs{ |
| 4631 | NegotiateVersion: VersionTLS12, |
| 4632 | }, |
| 4633 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4634 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4635 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4636 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4637 | }) |
| 4638 | testCases = append(testCases, testCase{ |
| 4639 | testType: serverTest, |
| 4640 | name: "Downgrade-TLS12-Server", |
| 4641 | config: Config{ |
| 4642 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4643 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4644 | }, |
| 4645 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4646 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4647 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4648 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4649 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4650 | } |
| 4651 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4652 | func addMinimumVersionTests() { |
| 4653 | for i, shimVers := range tlsVersions { |
| 4654 | // Assemble flags to disable all older versions on the shim. |
| 4655 | var flags []string |
| 4656 | for _, vers := range tlsVersions[:i] { |
| 4657 | flags = append(flags, vers.flag) |
| 4658 | } |
| 4659 | |
| 4660 | for _, runnerVers := range tlsVersions { |
| 4661 | protocols := []protocol{tls} |
| 4662 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4663 | protocols = append(protocols, dtls) |
| 4664 | } |
| 4665 | for _, protocol := range protocols { |
| 4666 | suffix := shimVers.name + "-" + runnerVers.name |
| 4667 | if protocol == dtls { |
| 4668 | suffix += "-DTLS" |
| 4669 | } |
| 4670 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4671 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4672 | var expectedVersion uint16 |
| 4673 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4674 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4675 | if runnerVers.version >= shimVers.version { |
| 4676 | expectedVersion = runnerVers.version |
| 4677 | } else { |
| 4678 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4679 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4680 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4681 | } |
| 4682 | |
| 4683 | testCases = append(testCases, testCase{ |
| 4684 | protocol: protocol, |
| 4685 | testType: clientTest, |
| 4686 | name: "MinimumVersion-Client-" + suffix, |
| 4687 | config: Config{ |
| 4688 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4689 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4690 | // Ensure the server does not decline to |
| 4691 | // select a version (versions extension) or |
| 4692 | // cipher (some ciphers depend on versions). |
| 4693 | NegotiateVersion: runnerVers.version, |
| 4694 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4695 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4696 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4697 | flags: flags, |
| 4698 | expectedVersion: expectedVersion, |
| 4699 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4700 | expectedError: expectedError, |
| 4701 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4702 | }) |
| 4703 | testCases = append(testCases, testCase{ |
| 4704 | protocol: protocol, |
| 4705 | testType: clientTest, |
| 4706 | name: "MinimumVersion-Client2-" + suffix, |
| 4707 | config: Config{ |
| 4708 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4709 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4710 | // Ensure the server does not decline to |
| 4711 | // select a version (versions extension) or |
| 4712 | // cipher (some ciphers depend on versions). |
| 4713 | NegotiateVersion: runnerVers.version, |
| 4714 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4715 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4716 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4717 | flags: []string{"-min-version", shimVersFlag}, |
| 4718 | expectedVersion: expectedVersion, |
| 4719 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4720 | expectedError: expectedError, |
| 4721 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4722 | }) |
| 4723 | |
| 4724 | testCases = append(testCases, testCase{ |
| 4725 | protocol: protocol, |
| 4726 | testType: serverTest, |
| 4727 | name: "MinimumVersion-Server-" + suffix, |
| 4728 | config: Config{ |
| 4729 | MaxVersion: runnerVers.version, |
| 4730 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4731 | flags: flags, |
| 4732 | expectedVersion: expectedVersion, |
| 4733 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4734 | expectedError: expectedError, |
| 4735 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4736 | }) |
| 4737 | testCases = append(testCases, testCase{ |
| 4738 | protocol: protocol, |
| 4739 | testType: serverTest, |
| 4740 | name: "MinimumVersion-Server2-" + suffix, |
| 4741 | config: Config{ |
| 4742 | MaxVersion: runnerVers.version, |
| 4743 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4744 | flags: []string{"-min-version", shimVersFlag}, |
| 4745 | expectedVersion: expectedVersion, |
| 4746 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4747 | expectedError: expectedError, |
| 4748 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4749 | }) |
| 4750 | } |
| 4751 | } |
| 4752 | } |
| 4753 | } |
| 4754 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4755 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4756 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4757 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4758 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4759 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4760 | // Repeat extensions tests all versions except SSL 3.0. |
| 4761 | for _, ver := range tlsVersions { |
| 4762 | if ver.version == VersionSSL30 { |
| 4763 | continue |
| 4764 | } |
| 4765 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4766 | // Test that duplicate extensions are rejected. |
| 4767 | testCases = append(testCases, testCase{ |
| 4768 | testType: clientTest, |
| 4769 | name: "DuplicateExtensionClient-" + ver.name, |
| 4770 | config: Config{ |
| 4771 | MaxVersion: ver.version, |
| 4772 | Bugs: ProtocolBugs{ |
| 4773 | DuplicateExtension: true, |
| 4774 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4775 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4776 | shouldFail: true, |
| 4777 | expectedLocalError: "remote error: error decoding message", |
| 4778 | }) |
| 4779 | testCases = append(testCases, testCase{ |
| 4780 | testType: serverTest, |
| 4781 | name: "DuplicateExtensionServer-" + ver.name, |
| 4782 | config: Config{ |
| 4783 | MaxVersion: ver.version, |
| 4784 | Bugs: ProtocolBugs{ |
| 4785 | DuplicateExtension: true, |
| 4786 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4787 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4788 | shouldFail: true, |
| 4789 | expectedLocalError: "remote error: error decoding message", |
| 4790 | }) |
| 4791 | |
| 4792 | // Test SNI. |
| 4793 | testCases = append(testCases, testCase{ |
| 4794 | testType: clientTest, |
| 4795 | name: "ServerNameExtensionClient-" + ver.name, |
| 4796 | config: Config{ |
| 4797 | MaxVersion: ver.version, |
| 4798 | Bugs: ProtocolBugs{ |
| 4799 | ExpectServerName: "example.com", |
| 4800 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4801 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4802 | flags: []string{"-host-name", "example.com"}, |
| 4803 | }) |
| 4804 | testCases = append(testCases, testCase{ |
| 4805 | testType: clientTest, |
| 4806 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4807 | config: Config{ |
| 4808 | MaxVersion: ver.version, |
| 4809 | Bugs: ProtocolBugs{ |
| 4810 | ExpectServerName: "mismatch.com", |
| 4811 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4812 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4813 | flags: []string{"-host-name", "example.com"}, |
| 4814 | shouldFail: true, |
| 4815 | expectedLocalError: "tls: unexpected server name", |
| 4816 | }) |
| 4817 | testCases = append(testCases, testCase{ |
| 4818 | testType: clientTest, |
| 4819 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4820 | config: Config{ |
| 4821 | MaxVersion: ver.version, |
| 4822 | Bugs: ProtocolBugs{ |
| 4823 | ExpectServerName: "missing.com", |
| 4824 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4825 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4826 | shouldFail: true, |
| 4827 | expectedLocalError: "tls: unexpected server name", |
| 4828 | }) |
| 4829 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 4830 | testType: clientTest, |
| 4831 | name: "TolerateServerNameAck-" + ver.name, |
| 4832 | config: Config{ |
| 4833 | MaxVersion: ver.version, |
| 4834 | Bugs: ProtocolBugs{ |
| 4835 | SendServerNameAck: true, |
| 4836 | }, |
| 4837 | }, |
| 4838 | flags: []string{"-host-name", "example.com"}, |
| 4839 | resumeSession: true, |
| 4840 | }) |
| 4841 | testCases = append(testCases, testCase{ |
| 4842 | testType: clientTest, |
| 4843 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 4844 | config: Config{ |
| 4845 | MaxVersion: ver.version, |
| 4846 | Bugs: ProtocolBugs{ |
| 4847 | SendServerNameAck: true, |
| 4848 | }, |
| 4849 | }, |
| 4850 | shouldFail: true, |
| 4851 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 4852 | expectedLocalError: "remote error: unsupported extension", |
| 4853 | }) |
| 4854 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4855 | testType: serverTest, |
| 4856 | name: "ServerNameExtensionServer-" + ver.name, |
| 4857 | config: Config{ |
| 4858 | MaxVersion: ver.version, |
| 4859 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4860 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4861 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4862 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4863 | }) |
| 4864 | |
| 4865 | // Test ALPN. |
| 4866 | testCases = append(testCases, testCase{ |
| 4867 | testType: clientTest, |
| 4868 | name: "ALPNClient-" + ver.name, |
| 4869 | config: Config{ |
| 4870 | MaxVersion: ver.version, |
| 4871 | NextProtos: []string{"foo"}, |
| 4872 | }, |
| 4873 | flags: []string{ |
| 4874 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4875 | "-expect-alpn", "foo", |
| 4876 | }, |
| 4877 | expectedNextProto: "foo", |
| 4878 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4879 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4880 | }) |
| 4881 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4882 | testType: clientTest, |
| 4883 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4884 | config: Config{ |
| 4885 | MaxVersion: ver.version, |
| 4886 | Bugs: ProtocolBugs{ |
| 4887 | SendALPN: "baz", |
| 4888 | }, |
| 4889 | }, |
| 4890 | flags: []string{ |
| 4891 | "-advertise-alpn", "\x03foo\x03bar", |
| 4892 | }, |
| 4893 | shouldFail: true, |
| 4894 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4895 | expectedLocalError: "remote error: illegal parameter", |
| 4896 | }) |
| 4897 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4898 | testType: serverTest, |
| 4899 | name: "ALPNServer-" + ver.name, |
| 4900 | config: Config{ |
| 4901 | MaxVersion: ver.version, |
| 4902 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4903 | }, |
| 4904 | flags: []string{ |
| 4905 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4906 | "-select-alpn", "foo", |
| 4907 | }, |
| 4908 | expectedNextProto: "foo", |
| 4909 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4910 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4911 | }) |
| 4912 | testCases = append(testCases, testCase{ |
| 4913 | testType: serverTest, |
| 4914 | name: "ALPNServer-Decline-" + ver.name, |
| 4915 | config: Config{ |
| 4916 | MaxVersion: ver.version, |
| 4917 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4918 | }, |
| 4919 | flags: []string{"-decline-alpn"}, |
| 4920 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4921 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4922 | }) |
| 4923 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4924 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4925 | // called once. |
| 4926 | testCases = append(testCases, testCase{ |
| 4927 | testType: serverTest, |
| 4928 | name: "ALPNServer-Async-" + ver.name, |
| 4929 | config: Config{ |
| 4930 | MaxVersion: ver.version, |
| 4931 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 4932 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 4933 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4934 | }, |
| 4935 | flags: []string{ |
| 4936 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4937 | "-select-alpn", "foo", |
| 4938 | "-async", |
| 4939 | }, |
| 4940 | expectedNextProto: "foo", |
| 4941 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4942 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4943 | }) |
| 4944 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4945 | var emptyString string |
| 4946 | testCases = append(testCases, testCase{ |
| 4947 | testType: clientTest, |
| 4948 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4949 | config: Config{ |
| 4950 | MaxVersion: ver.version, |
| 4951 | NextProtos: []string{""}, |
| 4952 | Bugs: ProtocolBugs{ |
| 4953 | // A server returning an empty ALPN protocol |
| 4954 | // should be rejected. |
| 4955 | ALPNProtocol: &emptyString, |
| 4956 | }, |
| 4957 | }, |
| 4958 | flags: []string{ |
| 4959 | "-advertise-alpn", "\x03foo", |
| 4960 | }, |
| 4961 | shouldFail: true, |
| 4962 | expectedError: ":PARSE_TLSEXT:", |
| 4963 | }) |
| 4964 | testCases = append(testCases, testCase{ |
| 4965 | testType: serverTest, |
| 4966 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4967 | config: Config{ |
| 4968 | MaxVersion: ver.version, |
| 4969 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4970 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4971 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4972 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4973 | flags: []string{ |
| 4974 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4975 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4976 | shouldFail: true, |
| 4977 | expectedError: ":PARSE_TLSEXT:", |
| 4978 | }) |
| 4979 | |
| 4980 | // Test NPN and the interaction with ALPN. |
| 4981 | if ver.version < VersionTLS13 { |
| 4982 | // Test that the server prefers ALPN over NPN. |
| 4983 | testCases = append(testCases, testCase{ |
| 4984 | testType: serverTest, |
| 4985 | name: "ALPNServer-Preferred-" + ver.name, |
| 4986 | config: Config{ |
| 4987 | MaxVersion: ver.version, |
| 4988 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4989 | }, |
| 4990 | flags: []string{ |
| 4991 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4992 | "-select-alpn", "foo", |
| 4993 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4994 | }, |
| 4995 | expectedNextProto: "foo", |
| 4996 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4997 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4998 | }) |
| 4999 | testCases = append(testCases, testCase{ |
| 5000 | testType: serverTest, |
| 5001 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5002 | config: Config{ |
| 5003 | MaxVersion: ver.version, |
| 5004 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5005 | Bugs: ProtocolBugs{ |
| 5006 | SwapNPNAndALPN: true, |
| 5007 | }, |
| 5008 | }, |
| 5009 | flags: []string{ |
| 5010 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5011 | "-select-alpn", "foo", |
| 5012 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5013 | }, |
| 5014 | expectedNextProto: "foo", |
| 5015 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5016 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5017 | }) |
| 5018 | |
| 5019 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5020 | testCases = append(testCases, testCase{ |
| 5021 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5022 | config: Config{ |
| 5023 | MaxVersion: ver.version, |
| 5024 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5025 | Bugs: ProtocolBugs{ |
| 5026 | NegotiateALPNAndNPN: true, |
| 5027 | }, |
| 5028 | }, |
| 5029 | flags: []string{ |
| 5030 | "-advertise-alpn", "\x03foo", |
| 5031 | "-select-next-proto", "foo", |
| 5032 | }, |
| 5033 | shouldFail: true, |
| 5034 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5035 | }) |
| 5036 | testCases = append(testCases, testCase{ |
| 5037 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5038 | config: Config{ |
| 5039 | MaxVersion: ver.version, |
| 5040 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5041 | Bugs: ProtocolBugs{ |
| 5042 | NegotiateALPNAndNPN: true, |
| 5043 | SwapNPNAndALPN: true, |
| 5044 | }, |
| 5045 | }, |
| 5046 | flags: []string{ |
| 5047 | "-advertise-alpn", "\x03foo", |
| 5048 | "-select-next-proto", "foo", |
| 5049 | }, |
| 5050 | shouldFail: true, |
| 5051 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5052 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5053 | } |
| 5054 | |
| 5055 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5056 | |
| 5057 | // Resume with a corrupt ticket. |
| 5058 | testCases = append(testCases, testCase{ |
| 5059 | testType: serverTest, |
| 5060 | name: "CorruptTicket-" + ver.name, |
| 5061 | config: Config{ |
| 5062 | MaxVersion: ver.version, |
| 5063 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5064 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5065 | in[len(in)-1] ^= 1 |
| 5066 | return in, nil |
| 5067 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5068 | }, |
| 5069 | }, |
| 5070 | resumeSession: true, |
| 5071 | expectResumeRejected: true, |
| 5072 | }) |
| 5073 | // Test the ticket callback, with and without renewal. |
| 5074 | testCases = append(testCases, testCase{ |
| 5075 | testType: serverTest, |
| 5076 | name: "TicketCallback-" + ver.name, |
| 5077 | config: Config{ |
| 5078 | MaxVersion: ver.version, |
| 5079 | }, |
| 5080 | resumeSession: true, |
| 5081 | flags: []string{"-use-ticket-callback"}, |
| 5082 | }) |
| 5083 | testCases = append(testCases, testCase{ |
| 5084 | testType: serverTest, |
| 5085 | name: "TicketCallback-Renew-" + ver.name, |
| 5086 | config: Config{ |
| 5087 | MaxVersion: ver.version, |
| 5088 | Bugs: ProtocolBugs{ |
| 5089 | ExpectNewTicket: true, |
| 5090 | }, |
| 5091 | }, |
| 5092 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5093 | resumeSession: true, |
| 5094 | }) |
| 5095 | |
| 5096 | // Test that the ticket callback is only called once when everything before |
| 5097 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5098 | // certificate selection callbacks run. |
| 5099 | testCases = append(testCases, testCase{ |
| 5100 | testType: serverTest, |
| 5101 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5102 | config: Config{ |
| 5103 | MaxVersion: ver.version, |
| 5104 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5105 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5106 | in[len(in)-1] ^= 1 |
| 5107 | return in, nil |
| 5108 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5109 | }, |
| 5110 | }, |
| 5111 | resumeSession: true, |
| 5112 | expectResumeRejected: true, |
| 5113 | flags: []string{ |
| 5114 | "-use-ticket-callback", |
| 5115 | "-async", |
| 5116 | }, |
| 5117 | }) |
| 5118 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5119 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5120 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5121 | testCases = append(testCases, testCase{ |
| 5122 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5123 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5124 | config: Config{ |
| 5125 | MaxVersion: ver.version, |
| 5126 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5127 | EmptyTicketSessionID: true, |
| 5128 | }, |
| 5129 | }, |
| 5130 | resumeSession: true, |
| 5131 | }) |
| 5132 | testCases = append(testCases, testCase{ |
| 5133 | testType: serverTest, |
| 5134 | name: "TicketSessionIDLength-16-" + ver.name, |
| 5135 | config: Config{ |
| 5136 | MaxVersion: ver.version, |
| 5137 | Bugs: ProtocolBugs{ |
| 5138 | TicketSessionIDLength: 16, |
| 5139 | }, |
| 5140 | }, |
| 5141 | resumeSession: true, |
| 5142 | }) |
| 5143 | testCases = append(testCases, testCase{ |
| 5144 | testType: serverTest, |
| 5145 | name: "TicketSessionIDLength-32-" + ver.name, |
| 5146 | config: Config{ |
| 5147 | MaxVersion: ver.version, |
| 5148 | Bugs: ProtocolBugs{ |
| 5149 | TicketSessionIDLength: 32, |
| 5150 | }, |
| 5151 | }, |
| 5152 | resumeSession: true, |
| 5153 | }) |
| 5154 | testCases = append(testCases, testCase{ |
| 5155 | testType: serverTest, |
| 5156 | name: "TicketSessionIDLength-33-" + ver.name, |
| 5157 | config: Config{ |
| 5158 | MaxVersion: ver.version, |
| 5159 | Bugs: ProtocolBugs{ |
| 5160 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5161 | }, |
| 5162 | }, |
| 5163 | resumeSession: true, |
| 5164 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5165 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5166 | expectedError: ":DECODE_ERROR:", |
| 5167 | }) |
| 5168 | } |
| 5169 | |
| 5170 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5171 | // are ignored. |
| 5172 | if ver.hasDTLS { |
| 5173 | testCases = append(testCases, testCase{ |
| 5174 | protocol: dtls, |
| 5175 | name: "SRTP-Client-" + ver.name, |
| 5176 | config: Config{ |
| 5177 | MaxVersion: ver.version, |
| 5178 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5179 | }, |
| 5180 | flags: []string{ |
| 5181 | "-srtp-profiles", |
| 5182 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5183 | }, |
| 5184 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5185 | }) |
| 5186 | testCases = append(testCases, testCase{ |
| 5187 | protocol: dtls, |
| 5188 | testType: serverTest, |
| 5189 | name: "SRTP-Server-" + ver.name, |
| 5190 | config: Config{ |
| 5191 | MaxVersion: ver.version, |
| 5192 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5193 | }, |
| 5194 | flags: []string{ |
| 5195 | "-srtp-profiles", |
| 5196 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5197 | }, |
| 5198 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5199 | }) |
| 5200 | // Test that the MKI is ignored. |
| 5201 | testCases = append(testCases, testCase{ |
| 5202 | protocol: dtls, |
| 5203 | testType: serverTest, |
| 5204 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5205 | config: Config{ |
| 5206 | MaxVersion: ver.version, |
| 5207 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5208 | Bugs: ProtocolBugs{ |
| 5209 | SRTPMasterKeyIdentifer: "bogus", |
| 5210 | }, |
| 5211 | }, |
| 5212 | flags: []string{ |
| 5213 | "-srtp-profiles", |
| 5214 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5215 | }, |
| 5216 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5217 | }) |
| 5218 | // Test that SRTP isn't negotiated on the server if there were |
| 5219 | // no matching profiles. |
| 5220 | testCases = append(testCases, testCase{ |
| 5221 | protocol: dtls, |
| 5222 | testType: serverTest, |
| 5223 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5224 | config: Config{ |
| 5225 | MaxVersion: ver.version, |
| 5226 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5227 | }, |
| 5228 | flags: []string{ |
| 5229 | "-srtp-profiles", |
| 5230 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5231 | }, |
| 5232 | expectedSRTPProtectionProfile: 0, |
| 5233 | }) |
| 5234 | // Test that the server returning an invalid SRTP profile is |
| 5235 | // flagged as an error by the client. |
| 5236 | testCases = append(testCases, testCase{ |
| 5237 | protocol: dtls, |
| 5238 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5239 | config: Config{ |
| 5240 | MaxVersion: ver.version, |
| 5241 | Bugs: ProtocolBugs{ |
| 5242 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5243 | }, |
| 5244 | }, |
| 5245 | flags: []string{ |
| 5246 | "-srtp-profiles", |
| 5247 | "SRTP_AES128_CM_SHA1_80", |
| 5248 | }, |
| 5249 | shouldFail: true, |
| 5250 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5251 | }) |
| 5252 | } |
| 5253 | |
| 5254 | // Test SCT list. |
| 5255 | testCases = append(testCases, testCase{ |
| 5256 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5257 | testType: clientTest, |
| 5258 | config: Config{ |
| 5259 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5260 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5261 | flags: []string{ |
| 5262 | "-enable-signed-cert-timestamps", |
| 5263 | "-expect-signed-cert-timestamps", |
| 5264 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5265 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5266 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5267 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5268 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5269 | var differentSCTList []byte |
| 5270 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5271 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5272 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5273 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5274 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5275 | testCases = append(testCases, testCase{ |
| 5276 | name: "SendSCTListOnResume-" + ver.name, |
| 5277 | config: Config{ |
| 5278 | MaxVersion: ver.version, |
| 5279 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5280 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5281 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5282 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5283 | flags: []string{ |
| 5284 | "-enable-signed-cert-timestamps", |
| 5285 | "-expect-signed-cert-timestamps", |
| 5286 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5287 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5288 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5289 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5290 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5291 | testCases = append(testCases, testCase{ |
| 5292 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5293 | testType: serverTest, |
| 5294 | config: Config{ |
| 5295 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5296 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5297 | flags: []string{ |
| 5298 | "-signed-cert-timestamps", |
| 5299 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5300 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5301 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5302 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5303 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5304 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5305 | emptySCTListCert := *testCerts[0].cert |
| 5306 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5307 | |
| 5308 | // Test empty SCT list. |
| 5309 | testCases = append(testCases, testCase{ |
| 5310 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5311 | testType: clientTest, |
| 5312 | config: Config{ |
| 5313 | MaxVersion: ver.version, |
| 5314 | Certificates: []Certificate{emptySCTListCert}, |
| 5315 | }, |
| 5316 | flags: []string{ |
| 5317 | "-enable-signed-cert-timestamps", |
| 5318 | }, |
| 5319 | shouldFail: true, |
| 5320 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5321 | }) |
| 5322 | |
| 5323 | emptySCTCert := *testCerts[0].cert |
| 5324 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5325 | |
| 5326 | // Test empty SCT in non-empty list. |
| 5327 | testCases = append(testCases, testCase{ |
| 5328 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5329 | testType: clientTest, |
| 5330 | config: Config{ |
| 5331 | MaxVersion: ver.version, |
| 5332 | Certificates: []Certificate{emptySCTCert}, |
| 5333 | }, |
| 5334 | flags: []string{ |
| 5335 | "-enable-signed-cert-timestamps", |
| 5336 | }, |
| 5337 | shouldFail: true, |
| 5338 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5339 | }) |
| 5340 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5341 | // Test that certificate-related extensions are not sent unsolicited. |
| 5342 | testCases = append(testCases, testCase{ |
| 5343 | testType: serverTest, |
| 5344 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5345 | config: Config{ |
| 5346 | MaxVersion: ver.version, |
| 5347 | Bugs: ProtocolBugs{ |
| 5348 | NoOCSPStapling: true, |
| 5349 | NoSignedCertificateTimestamps: true, |
| 5350 | }, |
| 5351 | }, |
| 5352 | flags: []string{ |
| 5353 | "-ocsp-response", |
| 5354 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5355 | "-signed-cert-timestamps", |
| 5356 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5357 | }, |
| 5358 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5359 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5360 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5361 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5362 | testType: clientTest, |
| 5363 | name: "ClientHelloPadding", |
| 5364 | config: Config{ |
| 5365 | Bugs: ProtocolBugs{ |
| 5366 | RequireClientHelloSize: 512, |
| 5367 | }, |
| 5368 | }, |
| 5369 | // This hostname just needs to be long enough to push the |
| 5370 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5371 | // long. |
| 5372 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5373 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5374 | |
| 5375 | // Extensions should not function in SSL 3.0. |
| 5376 | testCases = append(testCases, testCase{ |
| 5377 | testType: serverTest, |
| 5378 | name: "SSLv3Extensions-NoALPN", |
| 5379 | config: Config{ |
| 5380 | MaxVersion: VersionSSL30, |
| 5381 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5382 | }, |
| 5383 | flags: []string{ |
| 5384 | "-select-alpn", "foo", |
| 5385 | }, |
| 5386 | expectNoNextProto: true, |
| 5387 | }) |
| 5388 | |
| 5389 | // Test session tickets separately as they follow a different codepath. |
| 5390 | testCases = append(testCases, testCase{ |
| 5391 | testType: serverTest, |
| 5392 | name: "SSLv3Extensions-NoTickets", |
| 5393 | config: Config{ |
| 5394 | MaxVersion: VersionSSL30, |
| 5395 | Bugs: ProtocolBugs{ |
| 5396 | // Historically, session tickets in SSL 3.0 |
| 5397 | // failed in different ways depending on whether |
| 5398 | // the client supported renegotiation_info. |
| 5399 | NoRenegotiationInfo: true, |
| 5400 | }, |
| 5401 | }, |
| 5402 | resumeSession: true, |
| 5403 | }) |
| 5404 | testCases = append(testCases, testCase{ |
| 5405 | testType: serverTest, |
| 5406 | name: "SSLv3Extensions-NoTickets2", |
| 5407 | config: Config{ |
| 5408 | MaxVersion: VersionSSL30, |
| 5409 | }, |
| 5410 | resumeSession: true, |
| 5411 | }) |
| 5412 | |
| 5413 | // But SSL 3.0 does send and process renegotiation_info. |
| 5414 | testCases = append(testCases, testCase{ |
| 5415 | testType: serverTest, |
| 5416 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5417 | config: Config{ |
| 5418 | MaxVersion: VersionSSL30, |
| 5419 | Bugs: ProtocolBugs{ |
| 5420 | RequireRenegotiationInfo: true, |
| 5421 | }, |
| 5422 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 5423 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5424 | }) |
| 5425 | testCases = append(testCases, testCase{ |
| 5426 | testType: serverTest, |
| 5427 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5428 | config: Config{ |
| 5429 | MaxVersion: VersionSSL30, |
| 5430 | Bugs: ProtocolBugs{ |
| 5431 | NoRenegotiationInfo: true, |
| 5432 | SendRenegotiationSCSV: true, |
| 5433 | RequireRenegotiationInfo: true, |
| 5434 | }, |
| 5435 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 5436 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5437 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5438 | |
| 5439 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5440 | // in ServerHello. |
| 5441 | testCases = append(testCases, testCase{ |
| 5442 | name: "NPN-Forbidden-TLS13", |
| 5443 | config: Config{ |
| 5444 | MaxVersion: VersionTLS13, |
| 5445 | NextProtos: []string{"foo"}, |
| 5446 | Bugs: ProtocolBugs{ |
| 5447 | NegotiateNPNAtAllVersions: true, |
| 5448 | }, |
| 5449 | }, |
| 5450 | flags: []string{"-select-next-proto", "foo"}, |
| 5451 | shouldFail: true, |
| 5452 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5453 | }) |
| 5454 | testCases = append(testCases, testCase{ |
| 5455 | name: "EMS-Forbidden-TLS13", |
| 5456 | config: Config{ |
| 5457 | MaxVersion: VersionTLS13, |
| 5458 | Bugs: ProtocolBugs{ |
| 5459 | NegotiateEMSAtAllVersions: true, |
| 5460 | }, |
| 5461 | }, |
| 5462 | shouldFail: true, |
| 5463 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5464 | }) |
| 5465 | testCases = append(testCases, testCase{ |
| 5466 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5467 | config: Config{ |
| 5468 | MaxVersion: VersionTLS13, |
| 5469 | Bugs: ProtocolBugs{ |
| 5470 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5471 | }, |
| 5472 | }, |
| 5473 | shouldFail: true, |
| 5474 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5475 | }) |
| 5476 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5477 | name: "Ticket-Forbidden-TLS13", |
| 5478 | config: Config{ |
| 5479 | MaxVersion: VersionTLS12, |
| 5480 | }, |
| 5481 | resumeConfig: &Config{ |
| 5482 | MaxVersion: VersionTLS13, |
| 5483 | Bugs: ProtocolBugs{ |
| 5484 | AdvertiseTicketExtension: true, |
| 5485 | }, |
| 5486 | }, |
| 5487 | resumeSession: true, |
| 5488 | shouldFail: true, |
| 5489 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5490 | }) |
| 5491 | |
| 5492 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5493 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5494 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5495 | // implicit in every test.) |
| 5496 | testCases = append(testCases, testCase{ |
| 5497 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5498 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5499 | config: Config{ |
| 5500 | MaxVersion: VersionTLS13, |
| 5501 | NextProtos: []string{"bar"}, |
| 5502 | }, |
| 5503 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5504 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5505 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5506 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5507 | // tolerated. |
| 5508 | testCases = append(testCases, testCase{ |
| 5509 | name: "SendOCSPResponseOnResume-TLS12", |
| 5510 | config: Config{ |
| 5511 | MaxVersion: VersionTLS12, |
| 5512 | Bugs: ProtocolBugs{ |
| 5513 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5514 | }, |
| 5515 | }, |
| 5516 | flags: []string{ |
| 5517 | "-enable-ocsp-stapling", |
| 5518 | "-expect-ocsp-response", |
| 5519 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5520 | }, |
| 5521 | resumeSession: true, |
| 5522 | }) |
| 5523 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5524 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5525 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5526 | config: Config{ |
| 5527 | MaxVersion: VersionTLS13, |
| 5528 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5529 | SendExtensionOnCertificate: testOCSPExtension, |
| 5530 | }, |
| 5531 | }, |
| 5532 | shouldFail: true, |
| 5533 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5534 | }) |
| 5535 | |
| 5536 | testCases = append(testCases, testCase{ |
| 5537 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5538 | config: Config{ |
| 5539 | MaxVersion: VersionTLS13, |
| 5540 | Bugs: ProtocolBugs{ |
| 5541 | SendExtensionOnCertificate: testSCTExtension, |
| 5542 | }, |
| 5543 | }, |
| 5544 | shouldFail: true, |
| 5545 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5546 | }) |
| 5547 | |
| 5548 | // Test that extensions on client certificates are never accepted. |
| 5549 | testCases = append(testCases, testCase{ |
| 5550 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5551 | testType: serverTest, |
| 5552 | config: Config{ |
| 5553 | MaxVersion: VersionTLS13, |
| 5554 | Certificates: []Certificate{rsaCertificate}, |
| 5555 | Bugs: ProtocolBugs{ |
| 5556 | SendExtensionOnCertificate: testOCSPExtension, |
| 5557 | }, |
| 5558 | }, |
| 5559 | flags: []string{ |
| 5560 | "-enable-ocsp-stapling", |
| 5561 | "-require-any-client-certificate", |
| 5562 | }, |
| 5563 | shouldFail: true, |
| 5564 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5565 | }) |
| 5566 | |
| 5567 | testCases = append(testCases, testCase{ |
| 5568 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5569 | config: Config{ |
| 5570 | MaxVersion: VersionTLS13, |
| 5571 | Bugs: ProtocolBugs{ |
| 5572 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5573 | }, |
| 5574 | }, |
| 5575 | shouldFail: true, |
| 5576 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5577 | }) |
| 5578 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5579 | var differentSCTList []byte |
| 5580 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5581 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5582 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5583 | // Test that extensions on intermediates are allowed but ignored. |
| 5584 | testCases = append(testCases, testCase{ |
| 5585 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5586 | config: Config{ |
| 5587 | MaxVersion: VersionTLS13, |
| 5588 | Certificates: []Certificate{rsaChainCertificate}, |
| 5589 | Bugs: ProtocolBugs{ |
| 5590 | // Send different values on the intermediate. This tests |
| 5591 | // the intermediate's extensions do not override the |
| 5592 | // leaf's. |
| 5593 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5594 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5595 | }, |
| 5596 | }, |
| 5597 | flags: []string{ |
| 5598 | "-enable-ocsp-stapling", |
| 5599 | "-expect-ocsp-response", |
| 5600 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5601 | "-enable-signed-cert-timestamps", |
| 5602 | "-expect-signed-cert-timestamps", |
| 5603 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5604 | }, |
| 5605 | resumeSession: true, |
| 5606 | }) |
| 5607 | |
| 5608 | // Test that extensions are not sent on intermediates when configured |
| 5609 | // only for a leaf. |
| 5610 | testCases = append(testCases, testCase{ |
| 5611 | testType: serverTest, |
| 5612 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5613 | config: Config{ |
| 5614 | MaxVersion: VersionTLS13, |
| 5615 | Bugs: ProtocolBugs{ |
| 5616 | ExpectNoExtensionsOnIntermediate: true, |
| 5617 | }, |
| 5618 | }, |
| 5619 | flags: []string{ |
| 5620 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5621 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5622 | "-ocsp-response", |
| 5623 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5624 | "-signed-cert-timestamps", |
| 5625 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5626 | }, |
| 5627 | }) |
| 5628 | |
| 5629 | // Test that extensions are not sent on client certificates. |
| 5630 | testCases = append(testCases, testCase{ |
| 5631 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5632 | config: Config{ |
| 5633 | MaxVersion: VersionTLS13, |
| 5634 | ClientAuth: RequireAnyClientCert, |
| 5635 | }, |
| 5636 | flags: []string{ |
| 5637 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5638 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5639 | "-ocsp-response", |
| 5640 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5641 | "-signed-cert-timestamps", |
| 5642 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5643 | }, |
| 5644 | }) |
| 5645 | |
| 5646 | testCases = append(testCases, testCase{ |
| 5647 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5648 | config: Config{ |
| 5649 | MaxVersion: VersionTLS13, |
| 5650 | Bugs: ProtocolBugs{ |
| 5651 | SendDuplicateCertExtensions: true, |
| 5652 | }, |
| 5653 | }, |
| 5654 | flags: []string{ |
| 5655 | "-enable-ocsp-stapling", |
| 5656 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5657 | }, |
| 5658 | resumeSession: true, |
| 5659 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5660 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5661 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5662 | |
| 5663 | testCases = append(testCases, testCase{ |
| 5664 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5665 | testType: serverTest, |
| 5666 | flags: []string{ |
| 5667 | "-signed-cert-timestamps", |
| 5668 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5669 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5670 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5671 | expectedError: ":INVALID_SCT_LIST:", |
| 5672 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5673 | } |
| 5674 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5675 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5676 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5677 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5678 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5679 | // have session IDs, so skip their cross-resumption |
| 5680 | // tests. |
| 5681 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5682 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5683 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5684 | } |
| 5685 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5686 | protocols := []protocol{tls} |
| 5687 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5688 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5689 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5690 | for _, protocol := range protocols { |
| 5691 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5692 | if protocol == dtls { |
| 5693 | suffix += "-DTLS" |
| 5694 | } |
| 5695 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5696 | if sessionVers.version == resumeVers.version { |
| 5697 | testCases = append(testCases, testCase{ |
| 5698 | protocol: protocol, |
| 5699 | name: "Resume-Client" + suffix, |
| 5700 | resumeSession: true, |
| 5701 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5702 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5703 | Bugs: ProtocolBugs{ |
| 5704 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5705 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5706 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5707 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5708 | expectedVersion: sessionVers.version, |
| 5709 | expectedResumeVersion: resumeVers.version, |
| 5710 | }) |
| 5711 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5712 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5713 | |
| 5714 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5715 | // there is no way to convince a non-lookahead client the |
| 5716 | // session was resumed. It will appear to the client that a |
| 5717 | // stray ChangeCipherSpec was sent. |
| 5718 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5719 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5720 | } |
| 5721 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5722 | testCases = append(testCases, testCase{ |
| 5723 | protocol: protocol, |
| 5724 | name: "Resume-Client-Mismatch" + suffix, |
| 5725 | resumeSession: true, |
| 5726 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5727 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5728 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5729 | expectedVersion: sessionVers.version, |
| 5730 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5731 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5732 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5733 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5734 | }, |
| 5735 | }, |
| 5736 | expectedResumeVersion: resumeVers.version, |
| 5737 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5738 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5739 | }) |
| 5740 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5741 | |
| 5742 | testCases = append(testCases, testCase{ |
| 5743 | protocol: protocol, |
| 5744 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5745 | resumeSession: true, |
| 5746 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5747 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5748 | }, |
| 5749 | expectedVersion: sessionVers.version, |
| 5750 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5751 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5752 | }, |
| 5753 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5754 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5755 | expectedResumeVersion: resumeVers.version, |
| 5756 | }) |
| 5757 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5758 | testCases = append(testCases, testCase{ |
| 5759 | protocol: protocol, |
| 5760 | testType: serverTest, |
| 5761 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5762 | resumeSession: true, |
| 5763 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5764 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5765 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5766 | expectedVersion: sessionVers.version, |
| 5767 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5768 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5769 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5770 | Bugs: ProtocolBugs{ |
| 5771 | SendBothTickets: true, |
| 5772 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5773 | }, |
| 5774 | expectedResumeVersion: resumeVers.version, |
| 5775 | }) |
| 5776 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5777 | } |
| 5778 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5779 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5780 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5781 | testCases = append(testCases, testCase{ |
| 5782 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5783 | name: "ShimTicketRewritable", |
| 5784 | resumeSession: true, |
| 5785 | config: Config{ |
| 5786 | MaxVersion: VersionTLS12, |
| 5787 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5788 | Bugs: ProtocolBugs{ |
| 5789 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5790 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5791 | if err != nil { |
| 5792 | return nil, err |
| 5793 | } |
| 5794 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5795 | }, |
| 5796 | }, |
| 5797 | }, |
| 5798 | flags: []string{ |
| 5799 | "-ticket-key", |
| 5800 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5801 | }, |
| 5802 | }) |
| 5803 | |
| 5804 | // Resumptions are declined if the version does not match. |
| 5805 | testCases = append(testCases, testCase{ |
| 5806 | testType: serverTest, |
| 5807 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5808 | resumeSession: true, |
| 5809 | config: Config{ |
| 5810 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5811 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5812 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5813 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5814 | return SetShimTicketVersion(in, VersionTLS13) |
| 5815 | }, |
| 5816 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5817 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5818 | flags: []string{ |
| 5819 | "-ticket-key", |
| 5820 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5821 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5822 | expectResumeRejected: true, |
| 5823 | }) |
| 5824 | |
| 5825 | testCases = append(testCases, testCase{ |
| 5826 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5827 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5828 | resumeSession: true, |
| 5829 | config: Config{ |
| 5830 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5831 | Bugs: ProtocolBugs{ |
| 5832 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5833 | return SetShimTicketVersion(in, VersionTLS12) |
| 5834 | }, |
| 5835 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5836 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5837 | flags: []string{ |
| 5838 | "-ticket-key", |
| 5839 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5840 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5841 | expectResumeRejected: true, |
| 5842 | }) |
| 5843 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5844 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5845 | testCases = append(testCases, testCase{ |
| 5846 | testType: serverTest, |
| 5847 | name: "Resume-Server-DeclineBadCipher", |
| 5848 | resumeSession: true, |
| 5849 | config: Config{ |
| 5850 | MaxVersion: VersionTLS12, |
| 5851 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5852 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5853 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5854 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5855 | }, |
| 5856 | }, |
| 5857 | }, |
| 5858 | flags: []string{ |
| 5859 | "-ticket-key", |
| 5860 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5861 | }, |
| 5862 | expectResumeRejected: true, |
| 5863 | }) |
| 5864 | |
| 5865 | testCases = append(testCases, testCase{ |
| 5866 | testType: serverTest, |
| 5867 | name: "Resume-Server-DeclineBadCipher-2", |
| 5868 | resumeSession: true, |
| 5869 | config: Config{ |
| 5870 | MaxVersion: VersionTLS12, |
| 5871 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5872 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5873 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5874 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5875 | }, |
| 5876 | }, |
| 5877 | }, |
| 5878 | flags: []string{ |
| 5879 | "-cipher", "AES128", |
| 5880 | "-ticket-key", |
| 5881 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5882 | }, |
| 5883 | expectResumeRejected: true, |
| 5884 | }) |
| 5885 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5886 | // Sessions are not resumed if they do not use the preferred cipher. |
| 5887 | testCases = append(testCases, testCase{ |
| 5888 | testType: serverTest, |
| 5889 | name: "Resume-Server-CipherNotPreferred", |
| 5890 | resumeSession: true, |
| 5891 | config: Config{ |
| 5892 | MaxVersion: VersionTLS12, |
| 5893 | Bugs: ProtocolBugs{ |
| 5894 | ExpectNewTicket: true, |
| 5895 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5896 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 5897 | }, |
| 5898 | }, |
| 5899 | }, |
| 5900 | flags: []string{ |
| 5901 | "-ticket-key", |
| 5902 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5903 | }, |
| 5904 | shouldFail: false, |
| 5905 | expectResumeRejected: true, |
| 5906 | }) |
| 5907 | |
| 5908 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 5909 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 5910 | testCases = append(testCases, testCase{ |
| 5911 | testType: serverTest, |
| 5912 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 5913 | resumeSession: true, |
| 5914 | config: Config{ |
| 5915 | MaxVersion: VersionTLS13, |
| 5916 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 5917 | Bugs: ProtocolBugs{ |
| 5918 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5919 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 5920 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 5921 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5922 | }, |
| 5923 | }, |
| 5924 | }, |
| 5925 | flags: []string{ |
| 5926 | "-ticket-key", |
| 5927 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5928 | }, |
| 5929 | shouldFail: false, |
| 5930 | expectResumeRejected: true, |
| 5931 | }) |
| 5932 | |
| 5933 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5934 | testCases = append(testCases, testCase{ |
| 5935 | testType: serverTest, |
| 5936 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5937 | resumeSession: true, |
| 5938 | config: Config{ |
| 5939 | MaxVersion: VersionTLS13, |
| 5940 | Bugs: ProtocolBugs{ |
| 5941 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5942 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5943 | }, |
| 5944 | }, |
| 5945 | }, |
| 5946 | flags: []string{ |
| 5947 | "-ticket-key", |
| 5948 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5949 | }, |
| 5950 | expectResumeRejected: true, |
| 5951 | }) |
| 5952 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5953 | // If the client does not offer the cipher from the session, decline to |
| 5954 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 5955 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5956 | testCases = append(testCases, testCase{ |
| 5957 | testType: serverTest, |
| 5958 | name: "Resume-Server-UnofferedCipher", |
| 5959 | resumeSession: true, |
| 5960 | config: Config{ |
| 5961 | MaxVersion: VersionTLS12, |
| 5962 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5963 | }, |
| 5964 | resumeConfig: &Config{ |
| 5965 | MaxVersion: VersionTLS12, |
| 5966 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5967 | Bugs: ProtocolBugs{ |
| 5968 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5969 | }, |
| 5970 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5971 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5972 | }) |
| 5973 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5974 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 5975 | // include the selected cipher. Test that we tolerate this. Servers may |
| 5976 | // resume at another cipher if the PRF matches, but BoringSSL will |
| 5977 | // always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5978 | testCases = append(testCases, testCase{ |
| 5979 | testType: serverTest, |
| 5980 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5981 | resumeSession: true, |
| 5982 | config: Config{ |
| 5983 | MaxVersion: VersionTLS13, |
| 5984 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5985 | }, |
| 5986 | resumeConfig: &Config{ |
| 5987 | MaxVersion: VersionTLS13, |
| 5988 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5989 | Bugs: ProtocolBugs{ |
| 5990 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5991 | }, |
| 5992 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5993 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5994 | }) |
| 5995 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5996 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5997 | testCases = append(testCases, testCase{ |
| 5998 | name: "Resume-Client-CipherMismatch", |
| 5999 | resumeSession: true, |
| 6000 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6001 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6002 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6003 | }, |
| 6004 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6005 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6006 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6007 | Bugs: ProtocolBugs{ |
| 6008 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6009 | }, |
| 6010 | }, |
| 6011 | shouldFail: true, |
| 6012 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6013 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6014 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6015 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6016 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6017 | testCases = append(testCases, testCase{ |
| 6018 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6019 | resumeSession: true, |
| 6020 | config: Config{ |
| 6021 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6022 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6023 | }, |
| 6024 | resumeConfig: &Config{ |
| 6025 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6026 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6027 | }, |
| 6028 | }) |
| 6029 | |
| 6030 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6031 | testCases = append(testCases, testCase{ |
| 6032 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6033 | resumeSession: true, |
| 6034 | config: Config{ |
| 6035 | MaxVersion: VersionTLS13, |
| 6036 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6037 | }, |
| 6038 | resumeConfig: &Config{ |
| 6039 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6040 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6041 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6042 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6043 | }, |
| 6044 | }, |
| 6045 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6046 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6047 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6048 | |
| 6049 | testCases = append(testCases, testCase{ |
| 6050 | testType: serverTest, |
| 6051 | name: "Resume-Server-BinderWrongLength", |
| 6052 | resumeSession: true, |
| 6053 | config: Config{ |
| 6054 | MaxVersion: VersionTLS13, |
| 6055 | Bugs: ProtocolBugs{ |
| 6056 | SendShortPSKBinder: true, |
| 6057 | }, |
| 6058 | }, |
| 6059 | shouldFail: true, |
| 6060 | expectedLocalError: "remote error: error decrypting message", |
| 6061 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6062 | }) |
| 6063 | |
| 6064 | testCases = append(testCases, testCase{ |
| 6065 | testType: serverTest, |
| 6066 | name: "Resume-Server-NoPSKBinder", |
| 6067 | resumeSession: true, |
| 6068 | config: Config{ |
| 6069 | MaxVersion: VersionTLS13, |
| 6070 | Bugs: ProtocolBugs{ |
| 6071 | SendNoPSKBinder: true, |
| 6072 | }, |
| 6073 | }, |
| 6074 | shouldFail: true, |
| 6075 | expectedLocalError: "remote error: error decoding message", |
| 6076 | expectedError: ":DECODE_ERROR:", |
| 6077 | }) |
| 6078 | |
| 6079 | testCases = append(testCases, testCase{ |
| 6080 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6081 | name: "Resume-Server-ExtraPSKBinder", |
| 6082 | resumeSession: true, |
| 6083 | config: Config{ |
| 6084 | MaxVersion: VersionTLS13, |
| 6085 | Bugs: ProtocolBugs{ |
| 6086 | SendExtraPSKBinder: true, |
| 6087 | }, |
| 6088 | }, |
| 6089 | shouldFail: true, |
| 6090 | expectedLocalError: "remote error: illegal parameter", |
| 6091 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6092 | }) |
| 6093 | |
| 6094 | testCases = append(testCases, testCase{ |
| 6095 | testType: serverTest, |
| 6096 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6097 | resumeSession: true, |
| 6098 | config: Config{ |
| 6099 | MaxVersion: VersionTLS13, |
| 6100 | Bugs: ProtocolBugs{ |
| 6101 | ExtraPSKIdentity: true, |
| 6102 | }, |
| 6103 | }, |
| 6104 | shouldFail: true, |
| 6105 | expectedLocalError: "remote error: illegal parameter", |
| 6106 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6107 | }) |
| 6108 | |
| 6109 | testCases = append(testCases, testCase{ |
| 6110 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6111 | name: "Resume-Server-InvalidPSKBinder", |
| 6112 | resumeSession: true, |
| 6113 | config: Config{ |
| 6114 | MaxVersion: VersionTLS13, |
| 6115 | Bugs: ProtocolBugs{ |
| 6116 | SendInvalidPSKBinder: true, |
| 6117 | }, |
| 6118 | }, |
| 6119 | shouldFail: true, |
| 6120 | expectedLocalError: "remote error: error decrypting message", |
| 6121 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6122 | }) |
| 6123 | |
| 6124 | testCases = append(testCases, testCase{ |
| 6125 | testType: serverTest, |
| 6126 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6127 | resumeSession: true, |
| 6128 | config: Config{ |
| 6129 | MaxVersion: VersionTLS13, |
| 6130 | Bugs: ProtocolBugs{ |
| 6131 | PSKBinderFirst: true, |
| 6132 | }, |
| 6133 | }, |
| 6134 | shouldFail: true, |
| 6135 | expectedLocalError: "remote error: illegal parameter", |
| 6136 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6137 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6138 | } |
| 6139 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6140 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6141 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6142 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6143 | testType: serverTest, |
| 6144 | name: "Renegotiate-Server-Forbidden", |
| 6145 | config: Config{ |
| 6146 | MaxVersion: VersionTLS12, |
| 6147 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6148 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6149 | shouldFail: true, |
| 6150 | expectedError: ":NO_RENEGOTIATION:", |
| 6151 | expectedLocalError: "remote error: no renegotiation", |
| 6152 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6153 | // The server shouldn't echo the renegotiation extension unless |
| 6154 | // requested by the client. |
| 6155 | testCases = append(testCases, testCase{ |
| 6156 | testType: serverTest, |
| 6157 | name: "Renegotiate-Server-NoExt", |
| 6158 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6159 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6160 | Bugs: ProtocolBugs{ |
| 6161 | NoRenegotiationInfo: true, |
| 6162 | RequireRenegotiationInfo: true, |
| 6163 | }, |
| 6164 | }, |
| 6165 | shouldFail: true, |
| 6166 | expectedLocalError: "renegotiation extension missing", |
| 6167 | }) |
| 6168 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6169 | // the extension. |
| 6170 | testCases = append(testCases, testCase{ |
| 6171 | testType: serverTest, |
| 6172 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6173 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6174 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6175 | Bugs: ProtocolBugs{ |
| 6176 | NoRenegotiationInfo: true, |
| 6177 | SendRenegotiationSCSV: true, |
| 6178 | RequireRenegotiationInfo: true, |
| 6179 | }, |
| 6180 | }, |
| 6181 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6182 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6183 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6184 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6185 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6186 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6187 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6188 | }, |
| 6189 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6190 | renegotiate: 1, |
| 6191 | flags: []string{ |
| 6192 | "-renegotiate-freely", |
| 6193 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6194 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6195 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6196 | }) |
| 6197 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6198 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6199 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6200 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6201 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6202 | Bugs: ProtocolBugs{ |
| 6203 | EmptyRenegotiationInfo: true, |
| 6204 | }, |
| 6205 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6206 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6207 | shouldFail: true, |
| 6208 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6209 | }) |
| 6210 | testCases = append(testCases, testCase{ |
| 6211 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6212 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6213 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6214 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6215 | Bugs: ProtocolBugs{ |
| 6216 | BadRenegotiationInfo: true, |
| 6217 | }, |
| 6218 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6219 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6220 | shouldFail: true, |
| 6221 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6222 | }) |
| 6223 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6224 | name: "Renegotiate-Client-Downgrade", |
| 6225 | renegotiate: 1, |
| 6226 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6227 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6228 | Bugs: ProtocolBugs{ |
| 6229 | NoRenegotiationInfoAfterInitial: true, |
| 6230 | }, |
| 6231 | }, |
| 6232 | flags: []string{"-renegotiate-freely"}, |
| 6233 | shouldFail: true, |
| 6234 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6235 | }) |
| 6236 | testCases = append(testCases, testCase{ |
| 6237 | name: "Renegotiate-Client-Upgrade", |
| 6238 | renegotiate: 1, |
| 6239 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6240 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6241 | Bugs: ProtocolBugs{ |
| 6242 | NoRenegotiationInfoInInitial: true, |
| 6243 | }, |
| 6244 | }, |
| 6245 | flags: []string{"-renegotiate-freely"}, |
| 6246 | shouldFail: true, |
| 6247 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6248 | }) |
| 6249 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6250 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6251 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6252 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6253 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6254 | Bugs: ProtocolBugs{ |
| 6255 | NoRenegotiationInfo: true, |
| 6256 | }, |
| 6257 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6258 | flags: []string{ |
| 6259 | "-renegotiate-freely", |
| 6260 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6261 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6262 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6263 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6264 | |
| 6265 | // Test that the server may switch ciphers on renegotiation without |
| 6266 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6267 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6268 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6269 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6270 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6271 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6272 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6273 | }, |
| 6274 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6275 | flags: []string{ |
| 6276 | "-renegotiate-freely", |
| 6277 | "-expect-total-renegotiations", "1", |
| 6278 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6279 | }) |
| 6280 | testCases = append(testCases, testCase{ |
| 6281 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6282 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6283 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6284 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6285 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6286 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6287 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6288 | flags: []string{ |
| 6289 | "-renegotiate-freely", |
| 6290 | "-expect-total-renegotiations", "1", |
| 6291 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6292 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6293 | |
| 6294 | // Test that the server may not switch versions on renegotiation. |
| 6295 | testCases = append(testCases, testCase{ |
| 6296 | name: "Renegotiate-Client-SwitchVersion", |
| 6297 | config: Config{ |
| 6298 | MaxVersion: VersionTLS12, |
| 6299 | // Pick a cipher which exists at both versions. |
| 6300 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6301 | Bugs: ProtocolBugs{ |
| 6302 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6303 | // Avoid failing early at the record layer. |
| 6304 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6305 | }, |
| 6306 | }, |
| 6307 | renegotiate: 1, |
| 6308 | flags: []string{ |
| 6309 | "-renegotiate-freely", |
| 6310 | "-expect-total-renegotiations", "1", |
| 6311 | }, |
| 6312 | shouldFail: true, |
| 6313 | expectedError: ":WRONG_SSL_VERSION:", |
| 6314 | }) |
| 6315 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6316 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6317 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6318 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6319 | config: Config{ |
| 6320 | MaxVersion: VersionTLS10, |
| 6321 | Bugs: ProtocolBugs{ |
| 6322 | RequireSameRenegoClientVersion: true, |
| 6323 | }, |
| 6324 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6325 | flags: []string{ |
| 6326 | "-renegotiate-freely", |
| 6327 | "-expect-total-renegotiations", "1", |
| 6328 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6329 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6330 | testCases = append(testCases, testCase{ |
| 6331 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6332 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6333 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6334 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6335 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6336 | NextProtos: []string{"foo"}, |
| 6337 | }, |
| 6338 | flags: []string{ |
| 6339 | "-false-start", |
| 6340 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6341 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6342 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6343 | }, |
| 6344 | shimWritesFirst: true, |
| 6345 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6346 | |
| 6347 | // Client-side renegotiation controls. |
| 6348 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6349 | name: "Renegotiate-Client-Forbidden-1", |
| 6350 | config: Config{ |
| 6351 | MaxVersion: VersionTLS12, |
| 6352 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6353 | renegotiate: 1, |
| 6354 | shouldFail: true, |
| 6355 | expectedError: ":NO_RENEGOTIATION:", |
| 6356 | expectedLocalError: "remote error: no renegotiation", |
| 6357 | }) |
| 6358 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6359 | name: "Renegotiate-Client-Once-1", |
| 6360 | config: Config{ |
| 6361 | MaxVersion: VersionTLS12, |
| 6362 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6363 | renegotiate: 1, |
| 6364 | flags: []string{ |
| 6365 | "-renegotiate-once", |
| 6366 | "-expect-total-renegotiations", "1", |
| 6367 | }, |
| 6368 | }) |
| 6369 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6370 | name: "Renegotiate-Client-Freely-1", |
| 6371 | config: Config{ |
| 6372 | MaxVersion: VersionTLS12, |
| 6373 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6374 | renegotiate: 1, |
| 6375 | flags: []string{ |
| 6376 | "-renegotiate-freely", |
| 6377 | "-expect-total-renegotiations", "1", |
| 6378 | }, |
| 6379 | }) |
| 6380 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6381 | name: "Renegotiate-Client-Once-2", |
| 6382 | config: Config{ |
| 6383 | MaxVersion: VersionTLS12, |
| 6384 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6385 | renegotiate: 2, |
| 6386 | flags: []string{"-renegotiate-once"}, |
| 6387 | shouldFail: true, |
| 6388 | expectedError: ":NO_RENEGOTIATION:", |
| 6389 | expectedLocalError: "remote error: no renegotiation", |
| 6390 | }) |
| 6391 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6392 | name: "Renegotiate-Client-Freely-2", |
| 6393 | config: Config{ |
| 6394 | MaxVersion: VersionTLS12, |
| 6395 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6396 | renegotiate: 2, |
| 6397 | flags: []string{ |
| 6398 | "-renegotiate-freely", |
| 6399 | "-expect-total-renegotiations", "2", |
| 6400 | }, |
| 6401 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6402 | testCases = append(testCases, testCase{ |
| 6403 | name: "Renegotiate-Client-NoIgnore", |
| 6404 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6405 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6406 | Bugs: ProtocolBugs{ |
| 6407 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6408 | }, |
| 6409 | }, |
| 6410 | shouldFail: true, |
| 6411 | expectedError: ":NO_RENEGOTIATION:", |
| 6412 | }) |
| 6413 | testCases = append(testCases, testCase{ |
| 6414 | name: "Renegotiate-Client-Ignore", |
| 6415 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6416 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6417 | Bugs: ProtocolBugs{ |
| 6418 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6419 | }, |
| 6420 | }, |
| 6421 | flags: []string{ |
| 6422 | "-renegotiate-ignore", |
| 6423 | "-expect-total-renegotiations", "0", |
| 6424 | }, |
| 6425 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6426 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6427 | // Renegotiation is not allowed at SSL 3.0. |
| 6428 | testCases = append(testCases, testCase{ |
| 6429 | name: "Renegotiate-Client-SSL3", |
| 6430 | config: Config{ |
| 6431 | MaxVersion: VersionSSL30, |
| 6432 | }, |
| 6433 | renegotiate: 1, |
| 6434 | flags: []string{ |
| 6435 | "-renegotiate-freely", |
| 6436 | "-expect-total-renegotiations", "1", |
| 6437 | }, |
| 6438 | shouldFail: true, |
| 6439 | expectedError: ":NO_RENEGOTIATION:", |
| 6440 | expectedLocalError: "remote error: no renegotiation", |
| 6441 | }) |
| 6442 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 6443 | // Renegotiation is not allowed when there is an unfinished write. |
| 6444 | testCases = append(testCases, testCase{ |
| 6445 | name: "Renegotiate-Client-UnfinishedWrite", |
| 6446 | config: Config{ |
| 6447 | MaxVersion: VersionTLS12, |
| 6448 | }, |
| 6449 | renegotiate: 1, |
| 6450 | flags: []string{ |
| 6451 | "-async", |
| 6452 | "-renegotiate-freely", |
| 6453 | "-read-with-unfinished-write", |
| 6454 | }, |
| 6455 | shouldFail: true, |
| 6456 | expectedError: ":NO_RENEGOTIATION:", |
| 6457 | // We do not successfully send the no_renegotiation alert in |
| 6458 | // this case. https://crbug.com/boringssl/130 |
| 6459 | }) |
| 6460 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6461 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6462 | testCases = append(testCases, testCase{ |
| 6463 | name: "StrayHelloRequest", |
| 6464 | config: Config{ |
| 6465 | MaxVersion: VersionTLS12, |
| 6466 | Bugs: ProtocolBugs{ |
| 6467 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6468 | }, |
| 6469 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6470 | shouldFail: true, |
| 6471 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6472 | }) |
| 6473 | testCases = append(testCases, testCase{ |
| 6474 | name: "StrayHelloRequest-Packed", |
| 6475 | config: Config{ |
| 6476 | MaxVersion: VersionTLS12, |
| 6477 | Bugs: ProtocolBugs{ |
| 6478 | PackHandshakeFlight: true, |
| 6479 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6480 | }, |
| 6481 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6482 | shouldFail: true, |
| 6483 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6484 | }) |
| 6485 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6486 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6487 | // the same record. |
| 6488 | testCases = append(testCases, testCase{ |
| 6489 | name: "Renegotiate-Client-Packed", |
| 6490 | config: Config{ |
| 6491 | MaxVersion: VersionTLS12, |
| 6492 | Bugs: ProtocolBugs{ |
| 6493 | PackHandshakeFlight: true, |
| 6494 | PackHelloRequestWithFinished: true, |
| 6495 | }, |
| 6496 | }, |
| 6497 | renegotiate: 1, |
| 6498 | flags: []string{ |
| 6499 | "-renegotiate-freely", |
| 6500 | "-expect-total-renegotiations", "1", |
| 6501 | }, |
| 6502 | }) |
| 6503 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6504 | // Renegotiation is forbidden in TLS 1.3. |
| 6505 | testCases = append(testCases, testCase{ |
| 6506 | name: "Renegotiate-Client-TLS13", |
| 6507 | config: Config{ |
| 6508 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6509 | Bugs: ProtocolBugs{ |
| 6510 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6511 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6512 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6513 | flags: []string{ |
| 6514 | "-renegotiate-freely", |
| 6515 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6516 | shouldFail: true, |
| 6517 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6518 | }) |
| 6519 | |
| 6520 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6521 | testCases = append(testCases, testCase{ |
| 6522 | name: "StrayHelloRequest-TLS13", |
| 6523 | config: Config{ |
| 6524 | MaxVersion: VersionTLS13, |
| 6525 | Bugs: ProtocolBugs{ |
| 6526 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6527 | }, |
| 6528 | }, |
| 6529 | shouldFail: true, |
| 6530 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6531 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6532 | |
| 6533 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 6534 | // always reads as supporting it, regardless of whether it was |
| 6535 | // negotiated. |
| 6536 | testCases = append(testCases, testCase{ |
| 6537 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 6538 | config: Config{ |
| 6539 | MaxVersion: VersionTLS13, |
| 6540 | Bugs: ProtocolBugs{ |
| 6541 | NoRenegotiationInfo: true, |
| 6542 | }, |
| 6543 | }, |
| 6544 | flags: []string{ |
| 6545 | "-expect-secure-renegotiation", |
| 6546 | }, |
| 6547 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6548 | } |
| 6549 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6550 | func addDTLSReplayTests() { |
| 6551 | // Test that sequence number replays are detected. |
| 6552 | testCases = append(testCases, testCase{ |
| 6553 | protocol: dtls, |
| 6554 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6555 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6556 | replayWrites: true, |
| 6557 | }) |
| 6558 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6559 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6560 | // than the retransmit window. |
| 6561 | testCases = append(testCases, testCase{ |
| 6562 | protocol: dtls, |
| 6563 | name: "DTLS-Replay-LargeGaps", |
| 6564 | config: Config{ |
| 6565 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6566 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6567 | return in * 127 |
| 6568 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6569 | }, |
| 6570 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6571 | messageCount: 200, |
| 6572 | replayWrites: true, |
| 6573 | }) |
| 6574 | |
| 6575 | // Test the incoming sequence number changing non-monotonically. |
| 6576 | testCases = append(testCases, testCase{ |
| 6577 | protocol: dtls, |
| 6578 | name: "DTLS-Replay-NonMonotonic", |
| 6579 | config: Config{ |
| 6580 | Bugs: ProtocolBugs{ |
| 6581 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6582 | return in ^ 31 |
| 6583 | }, |
| 6584 | }, |
| 6585 | }, |
| 6586 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6587 | replayWrites: true, |
| 6588 | }) |
| 6589 | } |
| 6590 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6591 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6592 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6593 | id signatureAlgorithm |
| 6594 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6595 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6596 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6597 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6598 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6599 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6600 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6601 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6602 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6603 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6604 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6605 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6606 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6607 | // Tests for key types prior to TLS 1.2. |
| 6608 | {"RSA", 0, testCertRSA}, |
| 6609 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6610 | } |
| 6611 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6612 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6613 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6614 | |
| 6615 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6616 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6617 | // versions a signing cipher. |
| 6618 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6619 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6620 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6621 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6622 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6623 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6624 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6625 | } |
| 6626 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6627 | var allAlgorithms []signatureAlgorithm |
| 6628 | for _, alg := range testSignatureAlgorithms { |
| 6629 | if alg.id != 0 { |
| 6630 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6631 | } |
| 6632 | } |
| 6633 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6634 | // Make sure each signature algorithm works. Include some fake values in |
| 6635 | // the list and ensure they're ignored. |
| 6636 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6637 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6638 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6639 | continue |
| 6640 | } |
| 6641 | |
| 6642 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6643 | // or remove it in C. |
| 6644 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6645 | continue |
| 6646 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6647 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6648 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6649 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6650 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6651 | shouldSignFail = true |
| 6652 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6653 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6654 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6655 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6656 | shouldSignFail = true |
| 6657 | shouldVerifyFail = true |
| 6658 | } |
| 6659 | |
| 6660 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6661 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6662 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6663 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6664 | |
| 6665 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6666 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6667 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6668 | } |
| 6669 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6670 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6671 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6672 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6673 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6674 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6675 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6676 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6677 | config: Config{ |
| 6678 | MaxVersion: ver.version, |
| 6679 | ClientAuth: RequireAnyClientCert, |
| 6680 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6681 | fakeSigAlg1, |
| 6682 | alg.id, |
| 6683 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6684 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6685 | }, |
| 6686 | flags: []string{ |
| 6687 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6688 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6689 | "-enable-all-curves", |
| 6690 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6691 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6692 | expectedError: signError, |
| 6693 | expectedPeerSignatureAlgorithm: alg.id, |
| 6694 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6695 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6696 | testCases = append(testCases, testCase{ |
| 6697 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6698 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6699 | config: Config{ |
| 6700 | MaxVersion: ver.version, |
| 6701 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6702 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6703 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6704 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6705 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6706 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6707 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6708 | // Some signature algorithms may not be advertised. |
| 6709 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6710 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6711 | }, |
| 6712 | flags: []string{ |
| 6713 | "-require-any-client-certificate", |
| 6714 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6715 | "-enable-all-curves", |
| 6716 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6717 | // Resume the session to assert the peer signature |
| 6718 | // algorithm is reported on both handshakes. |
| 6719 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6720 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6721 | expectedError: verifyError, |
| 6722 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6723 | |
| 6724 | testCases = append(testCases, testCase{ |
| 6725 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6726 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6727 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6728 | MaxVersion: ver.version, |
| 6729 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6730 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6731 | fakeSigAlg1, |
| 6732 | alg.id, |
| 6733 | fakeSigAlg2, |
| 6734 | }, |
| 6735 | }, |
| 6736 | flags: []string{ |
| 6737 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6738 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6739 | "-enable-all-curves", |
| 6740 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6741 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6742 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6743 | expectedPeerSignatureAlgorithm: alg.id, |
| 6744 | }) |
| 6745 | |
| 6746 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6747 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6748 | config: Config{ |
| 6749 | MaxVersion: ver.version, |
| 6750 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6751 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6752 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6753 | alg.id, |
| 6754 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6755 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6756 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6757 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6758 | // Some signature algorithms may not be advertised. |
| 6759 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6760 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6761 | }, |
| 6762 | flags: []string{ |
| 6763 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6764 | "-enable-all-curves", |
| 6765 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6766 | // Resume the session to assert the peer signature |
| 6767 | // algorithm is reported on both handshakes. |
| 6768 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6769 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6770 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6771 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6772 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6773 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6774 | testCases = append(testCases, testCase{ |
| 6775 | testType: serverTest, |
| 6776 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6777 | config: Config{ |
| 6778 | MaxVersion: ver.version, |
| 6779 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6780 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6781 | alg.id, |
| 6782 | }, |
| 6783 | Bugs: ProtocolBugs{ |
| 6784 | InvalidSignature: true, |
| 6785 | }, |
| 6786 | }, |
| 6787 | flags: []string{ |
| 6788 | "-require-any-client-certificate", |
| 6789 | "-enable-all-curves", |
| 6790 | }, |
| 6791 | shouldFail: true, |
| 6792 | expectedError: ":BAD_SIGNATURE:", |
| 6793 | }) |
| 6794 | |
| 6795 | testCases = append(testCases, testCase{ |
| 6796 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6797 | config: Config{ |
| 6798 | MaxVersion: ver.version, |
| 6799 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6800 | CipherSuites: signingCiphers, |
| 6801 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6802 | alg.id, |
| 6803 | }, |
| 6804 | Bugs: ProtocolBugs{ |
| 6805 | InvalidSignature: true, |
| 6806 | }, |
| 6807 | }, |
| 6808 | flags: []string{"-enable-all-curves"}, |
| 6809 | shouldFail: true, |
| 6810 | expectedError: ":BAD_SIGNATURE:", |
| 6811 | }) |
| 6812 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6813 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6814 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6815 | testCases = append(testCases, testCase{ |
| 6816 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6817 | config: Config{ |
| 6818 | MaxVersion: ver.version, |
| 6819 | ClientAuth: RequireAnyClientCert, |
| 6820 | VerifySignatureAlgorithms: allAlgorithms, |
| 6821 | }, |
| 6822 | flags: []string{ |
| 6823 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6824 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6825 | "-enable-all-curves", |
| 6826 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6827 | }, |
| 6828 | expectedPeerSignatureAlgorithm: alg.id, |
| 6829 | }) |
| 6830 | |
| 6831 | testCases = append(testCases, testCase{ |
| 6832 | testType: serverTest, |
| 6833 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6834 | config: Config{ |
| 6835 | MaxVersion: ver.version, |
| 6836 | CipherSuites: signingCiphers, |
| 6837 | VerifySignatureAlgorithms: allAlgorithms, |
| 6838 | }, |
| 6839 | flags: []string{ |
| 6840 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6841 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6842 | "-enable-all-curves", |
| 6843 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6844 | }, |
| 6845 | expectedPeerSignatureAlgorithm: alg.id, |
| 6846 | }) |
| 6847 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6848 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6849 | } |
| 6850 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6851 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6852 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6853 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6854 | config: Config{ |
| 6855 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6856 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6857 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6858 | signatureECDSAWithP521AndSHA512, |
| 6859 | signatureRSAPKCS1WithSHA384, |
| 6860 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6861 | }, |
| 6862 | }, |
| 6863 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6864 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6865 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6866 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6867 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6868 | }) |
| 6869 | |
| 6870 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6871 | name: "ClientAuth-SignatureType-TLS13", |
| 6872 | config: Config{ |
| 6873 | ClientAuth: RequireAnyClientCert, |
| 6874 | MaxVersion: VersionTLS13, |
| 6875 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6876 | signatureECDSAWithP521AndSHA512, |
| 6877 | signatureRSAPKCS1WithSHA384, |
| 6878 | signatureRSAPSSWithSHA384, |
| 6879 | signatureECDSAWithSHA1, |
| 6880 | }, |
| 6881 | }, |
| 6882 | flags: []string{ |
| 6883 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6884 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6885 | }, |
| 6886 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6887 | }) |
| 6888 | |
| 6889 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6890 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6891 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6892 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6893 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6894 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6895 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6896 | signatureECDSAWithP521AndSHA512, |
| 6897 | signatureRSAPKCS1WithSHA384, |
| 6898 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6899 | }, |
| 6900 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6901 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6902 | }) |
| 6903 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6904 | testCases = append(testCases, testCase{ |
| 6905 | testType: serverTest, |
| 6906 | name: "ServerAuth-SignatureType-TLS13", |
| 6907 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6908 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6909 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6910 | signatureECDSAWithP521AndSHA512, |
| 6911 | signatureRSAPKCS1WithSHA384, |
| 6912 | signatureRSAPSSWithSHA384, |
| 6913 | signatureECDSAWithSHA1, |
| 6914 | }, |
| 6915 | }, |
| 6916 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6917 | }) |
| 6918 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6919 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6920 | testCases = append(testCases, testCase{ |
| 6921 | testType: serverTest, |
| 6922 | name: "Verify-ClientAuth-SignatureType", |
| 6923 | config: Config{ |
| 6924 | MaxVersion: VersionTLS12, |
| 6925 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6926 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6927 | signatureRSAPKCS1WithSHA256, |
| 6928 | }, |
| 6929 | Bugs: ProtocolBugs{ |
| 6930 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6931 | }, |
| 6932 | }, |
| 6933 | flags: []string{ |
| 6934 | "-require-any-client-certificate", |
| 6935 | }, |
| 6936 | shouldFail: true, |
| 6937 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6938 | }) |
| 6939 | |
| 6940 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6941 | testType: serverTest, |
| 6942 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6943 | config: Config{ |
| 6944 | MaxVersion: VersionTLS13, |
| 6945 | Certificates: []Certificate{rsaCertificate}, |
| 6946 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6947 | signatureRSAPSSWithSHA256, |
| 6948 | }, |
| 6949 | Bugs: ProtocolBugs{ |
| 6950 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6951 | }, |
| 6952 | }, |
| 6953 | flags: []string{ |
| 6954 | "-require-any-client-certificate", |
| 6955 | }, |
| 6956 | shouldFail: true, |
| 6957 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6958 | }) |
| 6959 | |
| 6960 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6961 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6962 | config: Config{ |
| 6963 | MaxVersion: VersionTLS12, |
| 6964 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6965 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6966 | signatureRSAPKCS1WithSHA256, |
| 6967 | }, |
| 6968 | Bugs: ProtocolBugs{ |
| 6969 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6970 | }, |
| 6971 | }, |
| 6972 | shouldFail: true, |
| 6973 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6974 | }) |
| 6975 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6976 | testCases = append(testCases, testCase{ |
| 6977 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6978 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6979 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6980 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6981 | signatureRSAPSSWithSHA256, |
| 6982 | }, |
| 6983 | Bugs: ProtocolBugs{ |
| 6984 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6985 | }, |
| 6986 | }, |
| 6987 | shouldFail: true, |
| 6988 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6989 | }) |
| 6990 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6991 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6992 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6993 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6994 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6995 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6996 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6997 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6998 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6999 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7000 | }, |
| 7001 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7002 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7003 | }, |
| 7004 | }, |
| 7005 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7006 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7007 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7008 | }, |
| 7009 | }) |
| 7010 | |
| 7011 | testCases = append(testCases, testCase{ |
| 7012 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7013 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7014 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7015 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7016 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7017 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7018 | }, |
| 7019 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7020 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7021 | }, |
| 7022 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7023 | flags: []string{ |
| 7024 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7025 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7026 | }, |
| 7027 | }) |
| 7028 | |
| 7029 | testCases = append(testCases, testCase{ |
| 7030 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 7031 | config: Config{ |
| 7032 | MaxVersion: VersionTLS12, |
| 7033 | ClientAuth: RequireAnyClientCert, |
| 7034 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7035 | signatureECDSAWithSHA1, |
| 7036 | }, |
| 7037 | Bugs: ProtocolBugs{ |
| 7038 | NoSignatureAlgorithms: true, |
| 7039 | }, |
| 7040 | }, |
| 7041 | flags: []string{ |
| 7042 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7043 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7044 | }, |
| 7045 | }) |
| 7046 | |
| 7047 | testCases = append(testCases, testCase{ |
| 7048 | testType: serverTest, |
| 7049 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 7050 | config: Config{ |
| 7051 | MaxVersion: VersionTLS12, |
| 7052 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7053 | signatureECDSAWithSHA1, |
| 7054 | }, |
| 7055 | Bugs: ProtocolBugs{ |
| 7056 | NoSignatureAlgorithms: true, |
| 7057 | }, |
| 7058 | }, |
| 7059 | flags: []string{ |
| 7060 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7061 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7062 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7063 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7064 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7065 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7066 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7067 | config: Config{ |
| 7068 | MaxVersion: VersionTLS13, |
| 7069 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7070 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7071 | signatureRSAPKCS1WithSHA1, |
| 7072 | }, |
| 7073 | Bugs: ProtocolBugs{ |
| 7074 | NoSignatureAlgorithms: true, |
| 7075 | }, |
| 7076 | }, |
| 7077 | flags: []string{ |
| 7078 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7079 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7080 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 7081 | shouldFail: true, |
| 7082 | // An empty CertificateRequest signature algorithm list is a |
| 7083 | // syntax error in TLS 1.3. |
| 7084 | expectedError: ":DECODE_ERROR:", |
| 7085 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7086 | }) |
| 7087 | |
| 7088 | testCases = append(testCases, testCase{ |
| 7089 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7090 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7091 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7092 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7093 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7094 | signatureRSAPKCS1WithSHA1, |
| 7095 | }, |
| 7096 | Bugs: ProtocolBugs{ |
| 7097 | NoSignatureAlgorithms: true, |
| 7098 | }, |
| 7099 | }, |
| 7100 | shouldFail: true, |
| 7101 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7102 | }) |
| 7103 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7104 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 7105 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7106 | testCases = append(testCases, testCase{ |
| 7107 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7108 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7109 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7110 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7111 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7112 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7113 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7114 | }, |
| 7115 | Bugs: ProtocolBugs{ |
| 7116 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7117 | }, |
| 7118 | }, |
| 7119 | flags: []string{"-require-any-client-certificate"}, |
| 7120 | shouldFail: true, |
| 7121 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7122 | }) |
| 7123 | |
| 7124 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7125 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7126 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7127 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7128 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7129 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7130 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7131 | }, |
| 7132 | Bugs: ProtocolBugs{ |
| 7133 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7134 | }, |
| 7135 | }, |
| 7136 | shouldFail: true, |
| 7137 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7138 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7139 | testCases = append(testCases, testCase{ |
| 7140 | testType: serverTest, |
| 7141 | name: "ClientAuth-Enforced-TLS13", |
| 7142 | config: Config{ |
| 7143 | MaxVersion: VersionTLS13, |
| 7144 | Certificates: []Certificate{rsaCertificate}, |
| 7145 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7146 | signatureRSAPKCS1WithMD5, |
| 7147 | }, |
| 7148 | Bugs: ProtocolBugs{ |
| 7149 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7150 | IgnoreSignatureVersionChecks: true, |
| 7151 | }, |
| 7152 | }, |
| 7153 | flags: []string{"-require-any-client-certificate"}, |
| 7154 | shouldFail: true, |
| 7155 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7156 | }) |
| 7157 | |
| 7158 | testCases = append(testCases, testCase{ |
| 7159 | name: "ServerAuth-Enforced-TLS13", |
| 7160 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7161 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7162 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7163 | signatureRSAPKCS1WithMD5, |
| 7164 | }, |
| 7165 | Bugs: ProtocolBugs{ |
| 7166 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7167 | IgnoreSignatureVersionChecks: true, |
| 7168 | }, |
| 7169 | }, |
| 7170 | shouldFail: true, |
| 7171 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7172 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7173 | |
| 7174 | // Test that the agreed upon digest respects the client preferences and |
| 7175 | // the server digests. |
| 7176 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7177 | name: "NoCommonAlgorithms-Digests", |
| 7178 | config: Config{ |
| 7179 | MaxVersion: VersionTLS12, |
| 7180 | ClientAuth: RequireAnyClientCert, |
| 7181 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7182 | signatureRSAPKCS1WithSHA512, |
| 7183 | signatureRSAPKCS1WithSHA1, |
| 7184 | }, |
| 7185 | }, |
| 7186 | flags: []string{ |
| 7187 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7188 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7189 | "-digest-prefs", "SHA256", |
| 7190 | }, |
| 7191 | shouldFail: true, |
| 7192 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7193 | }) |
| 7194 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7195 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7196 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7197 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7198 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7199 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7200 | signatureRSAPKCS1WithSHA512, |
| 7201 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7202 | }, |
| 7203 | }, |
| 7204 | flags: []string{ |
| 7205 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7206 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7207 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7208 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7209 | shouldFail: true, |
| 7210 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7211 | }) |
| 7212 | testCases = append(testCases, testCase{ |
| 7213 | name: "NoCommonAlgorithms-TLS13", |
| 7214 | config: Config{ |
| 7215 | MaxVersion: VersionTLS13, |
| 7216 | ClientAuth: RequireAnyClientCert, |
| 7217 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7218 | signatureRSAPSSWithSHA512, |
| 7219 | signatureRSAPSSWithSHA384, |
| 7220 | }, |
| 7221 | }, |
| 7222 | flags: []string{ |
| 7223 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7224 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7225 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7226 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7227 | shouldFail: true, |
| 7228 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7229 | }) |
| 7230 | testCases = append(testCases, testCase{ |
| 7231 | name: "Agree-Digest-SHA256", |
| 7232 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7233 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7234 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7235 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7236 | signatureRSAPKCS1WithSHA1, |
| 7237 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7238 | }, |
| 7239 | }, |
| 7240 | flags: []string{ |
| 7241 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7242 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7243 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7244 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7245 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7246 | }) |
| 7247 | testCases = append(testCases, testCase{ |
| 7248 | name: "Agree-Digest-SHA1", |
| 7249 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7250 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7251 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7252 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7253 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7254 | }, |
| 7255 | }, |
| 7256 | flags: []string{ |
| 7257 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7258 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7259 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7260 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7261 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7262 | }) |
| 7263 | testCases = append(testCases, testCase{ |
| 7264 | name: "Agree-Digest-Default", |
| 7265 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7266 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7267 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7268 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7269 | signatureRSAPKCS1WithSHA256, |
| 7270 | signatureECDSAWithP256AndSHA256, |
| 7271 | signatureRSAPKCS1WithSHA1, |
| 7272 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7273 | }, |
| 7274 | }, |
| 7275 | flags: []string{ |
| 7276 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7277 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7278 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7279 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7280 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7281 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7282 | // Test that the signing preference list may include extra algorithms |
| 7283 | // without negotiation problems. |
| 7284 | testCases = append(testCases, testCase{ |
| 7285 | testType: serverTest, |
| 7286 | name: "FilterExtraAlgorithms", |
| 7287 | config: Config{ |
| 7288 | MaxVersion: VersionTLS12, |
| 7289 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7290 | signatureRSAPKCS1WithSHA256, |
| 7291 | }, |
| 7292 | }, |
| 7293 | flags: []string{ |
| 7294 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7295 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7296 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7297 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7298 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7299 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7300 | }, |
| 7301 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7302 | }) |
| 7303 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7304 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7305 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7306 | testCases = append(testCases, testCase{ |
| 7307 | name: "CheckLeafCurve", |
| 7308 | config: Config{ |
| 7309 | MaxVersion: VersionTLS12, |
| 7310 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7311 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7312 | }, |
| 7313 | flags: []string{"-p384-only"}, |
| 7314 | shouldFail: true, |
| 7315 | expectedError: ":BAD_ECC_CERT:", |
| 7316 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7317 | |
| 7318 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7319 | testCases = append(testCases, testCase{ |
| 7320 | name: "CheckLeafCurve-TLS13", |
| 7321 | config: Config{ |
| 7322 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7323 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7324 | }, |
| 7325 | flags: []string{"-p384-only"}, |
| 7326 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7327 | |
| 7328 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7329 | testCases = append(testCases, testCase{ |
| 7330 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7331 | config: Config{ |
| 7332 | MaxVersion: VersionTLS12, |
| 7333 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7334 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7335 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7336 | signatureECDSAWithP384AndSHA384, |
| 7337 | }, |
| 7338 | }, |
| 7339 | }) |
| 7340 | |
| 7341 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7342 | testCases = append(testCases, testCase{ |
| 7343 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7344 | config: Config{ |
| 7345 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7346 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7347 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7348 | signatureECDSAWithP384AndSHA384, |
| 7349 | }, |
| 7350 | Bugs: ProtocolBugs{ |
| 7351 | SkipECDSACurveCheck: true, |
| 7352 | }, |
| 7353 | }, |
| 7354 | shouldFail: true, |
| 7355 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7356 | }) |
| 7357 | |
| 7358 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7359 | // account. |
| 7360 | testCases = append(testCases, testCase{ |
| 7361 | testType: serverTest, |
| 7362 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7363 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7364 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7365 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7366 | signatureECDSAWithP384AndSHA384, |
| 7367 | signatureECDSAWithP256AndSHA256, |
| 7368 | }, |
| 7369 | }, |
| 7370 | flags: []string{ |
| 7371 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7372 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7373 | }, |
| 7374 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7375 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7376 | |
| 7377 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7378 | // server does not attempt to sign in that case. |
| 7379 | testCases = append(testCases, testCase{ |
| 7380 | testType: serverTest, |
| 7381 | name: "RSA-PSS-Large", |
| 7382 | config: Config{ |
| 7383 | MaxVersion: VersionTLS13, |
| 7384 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7385 | signatureRSAPSSWithSHA512, |
| 7386 | }, |
| 7387 | }, |
| 7388 | flags: []string{ |
| 7389 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7390 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7391 | }, |
| 7392 | shouldFail: true, |
| 7393 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7394 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7395 | |
| 7396 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7397 | testCases = append(testCases, testCase{ |
| 7398 | testType: clientTest, |
| 7399 | name: "RSA-PSS-Default-Verify", |
| 7400 | config: Config{ |
| 7401 | MaxVersion: VersionTLS12, |
| 7402 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7403 | signatureRSAPSSWithSHA256, |
| 7404 | }, |
| 7405 | }, |
| 7406 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7407 | }) |
| 7408 | |
| 7409 | testCases = append(testCases, testCase{ |
| 7410 | testType: serverTest, |
| 7411 | name: "RSA-PSS-Default-Sign", |
| 7412 | config: Config{ |
| 7413 | MaxVersion: VersionTLS12, |
| 7414 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7415 | signatureRSAPSSWithSHA256, |
| 7416 | }, |
| 7417 | }, |
| 7418 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7419 | }) |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 7420 | |
| 7421 | // A server certificate with a P-224 key will only work up to TLS 1.2 |
| 7422 | // and we only test it with BoringSSL acting as a server because that's |
| 7423 | // all Alphabet requires with it. |
| 7424 | testCases = append(testCases, testCase{ |
| 7425 | testType: serverTest, |
| 7426 | name: "P224-Server", |
| 7427 | config: Config{ |
| 7428 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7429 | // TLS 1.2 does not require that the curve |
| 7430 | // match the hash, thus P-256 with SHA-256 is |
| 7431 | // the same signature algorithm value as P-224 |
| 7432 | // with SHA-256. |
| 7433 | signatureECDSAWithP256AndSHA256, |
| 7434 | }, |
| 7435 | // P-256 must be offered as well because ECDHE requires |
| 7436 | // it. |
| 7437 | CurvePreferences: []CurveID{CurveP224, CurveP256}, |
| 7438 | }, |
| 7439 | flags: []string{ |
| 7440 | "-max-version", strconv.Itoa(VersionTLS12), |
| 7441 | "-cert-file", path.Join(*resourceDir, ecdsaP224CertificateFile), |
| 7442 | "-key-file", path.Join(*resourceDir, ecdsaP224KeyFile), |
| 7443 | }, |
| 7444 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7445 | } |
| 7446 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7447 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7448 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7449 | var timeouts = []time.Duration{ |
| 7450 | 1 * time.Second, |
| 7451 | 2 * time.Second, |
| 7452 | 4 * time.Second, |
| 7453 | 8 * time.Second, |
| 7454 | 16 * time.Second, |
| 7455 | 32 * time.Second, |
| 7456 | 60 * time.Second, |
| 7457 | 60 * time.Second, |
| 7458 | 60 * time.Second, |
| 7459 | 60 * time.Second, |
| 7460 | 60 * time.Second, |
| 7461 | 60 * time.Second, |
| 7462 | 60 * time.Second, |
| 7463 | } |
| 7464 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7465 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7466 | // initial timeout duration was set to 250ms. |
| 7467 | var shortTimeouts = []time.Duration{ |
| 7468 | 250 * time.Millisecond, |
| 7469 | 500 * time.Millisecond, |
| 7470 | 1 * time.Second, |
| 7471 | 2 * time.Second, |
| 7472 | 4 * time.Second, |
| 7473 | 8 * time.Second, |
| 7474 | 16 * time.Second, |
| 7475 | 32 * time.Second, |
| 7476 | 60 * time.Second, |
| 7477 | 60 * time.Second, |
| 7478 | 60 * time.Second, |
| 7479 | 60 * time.Second, |
| 7480 | 60 * time.Second, |
| 7481 | } |
| 7482 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7483 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7484 | // These tests work by coordinating some behavior on both the shim and |
| 7485 | // the runner. |
| 7486 | // |
| 7487 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7488 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7489 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7490 | // timeout in the shim and acts as a synchronization point to help the |
| 7491 | // runner bracket each handshake flight. |
| 7492 | // |
| 7493 | // We assume the shim does not read from the channel eagerly. It must |
| 7494 | // first wait until it has sent flight N and is ready to receive |
| 7495 | // handshake flight N+1. At this point, it will process the timeout |
| 7496 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7497 | // as if the shim was idle for the specified amount of time. |
| 7498 | // |
| 7499 | // The runner then drops all packets received before the ACK and |
| 7500 | // continues waiting for flight N. This ordering results in one attempt |
| 7501 | // at sending flight N to be dropped. For the test to complete, the |
| 7502 | // shim must send flight N again, testing that the shim implements DTLS |
| 7503 | // retransmit on a timeout. |
| 7504 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7505 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7506 | // likely be more epochs to cross and the final message's retransmit may |
| 7507 | // be more complex. |
| 7508 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7509 | // Test that this is indeed the timeout schedule. Stress all |
| 7510 | // four patterns of handshake. |
| 7511 | for i := 1; i < len(timeouts); i++ { |
| 7512 | number := strconv.Itoa(i) |
| 7513 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7514 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7515 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7516 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7517 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7518 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7519 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7520 | }, |
| 7521 | }, |
| 7522 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7523 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7524 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7525 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7526 | protocol: dtls, |
| 7527 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7528 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7529 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7530 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7531 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7532 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7533 | }, |
| 7534 | }, |
| 7535 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7536 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7537 | }) |
| 7538 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame^] | 7539 | |
| 7540 | // Test that exceeding the timeout schedule hits a read |
| 7541 | // timeout. |
| 7542 | testCases = append(testCases, testCase{ |
| 7543 | protocol: dtls, |
| 7544 | name: "DTLS-Retransmit-Timeout", |
| 7545 | config: Config{ |
| 7546 | MaxVersion: VersionTLS12, |
| 7547 | Bugs: ProtocolBugs{ |
| 7548 | TimeoutSchedule: timeouts, |
| 7549 | }, |
| 7550 | }, |
| 7551 | resumeSession: true, |
| 7552 | flags: []string{"-async"}, |
| 7553 | shouldFail: true, |
| 7554 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 7555 | }) |
| 7556 | |
| 7557 | // Test that timeout handling has a fudge factor, due to API |
| 7558 | // problems. |
| 7559 | testCases = append(testCases, testCase{ |
| 7560 | protocol: dtls, |
| 7561 | name: "DTLS-Retransmit-Fudge", |
| 7562 | config: Config{ |
| 7563 | MaxVersion: VersionTLS12, |
| 7564 | Bugs: ProtocolBugs{ |
| 7565 | TimeoutSchedule: []time.Duration{ |
| 7566 | timeouts[0] - 10*time.Millisecond, |
| 7567 | }, |
| 7568 | }, |
| 7569 | }, |
| 7570 | resumeSession: true, |
| 7571 | flags: []string{"-async"}, |
| 7572 | }) |
| 7573 | |
| 7574 | // Test that the final Finished retransmitting isn't |
| 7575 | // duplicated if the peer badly fragments everything. |
| 7576 | testCases = append(testCases, testCase{ |
| 7577 | testType: serverTest, |
| 7578 | protocol: dtls, |
| 7579 | name: "DTLS-Retransmit-Fragmented", |
| 7580 | config: Config{ |
| 7581 | MaxVersion: VersionTLS12, |
| 7582 | Bugs: ProtocolBugs{ |
| 7583 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7584 | MaxHandshakeRecordLength: 2, |
| 7585 | }, |
| 7586 | }, |
| 7587 | flags: []string{"-async"}, |
| 7588 | }) |
| 7589 | |
| 7590 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7591 | testCases = append(testCases, testCase{ |
| 7592 | protocol: dtls, |
| 7593 | name: "DTLS-Retransmit-Short-Client", |
| 7594 | config: Config{ |
| 7595 | MaxVersion: VersionTLS12, |
| 7596 | Bugs: ProtocolBugs{ |
| 7597 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7598 | }, |
| 7599 | }, |
| 7600 | resumeSession: true, |
| 7601 | flags: []string{ |
| 7602 | "-async", |
| 7603 | "-initial-timeout-duration-ms", "250", |
| 7604 | }, |
| 7605 | }) |
| 7606 | testCases = append(testCases, testCase{ |
| 7607 | protocol: dtls, |
| 7608 | testType: serverTest, |
| 7609 | name: "DTLS-Retransmit-Short-Server", |
| 7610 | config: Config{ |
| 7611 | MaxVersion: VersionTLS12, |
| 7612 | Bugs: ProtocolBugs{ |
| 7613 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7614 | }, |
| 7615 | }, |
| 7616 | resumeSession: true, |
| 7617 | flags: []string{ |
| 7618 | "-async", |
| 7619 | "-initial-timeout-duration-ms", "250", |
| 7620 | }, |
| 7621 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7622 | } |
| 7623 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7624 | func addExportKeyingMaterialTests() { |
| 7625 | for _, vers := range tlsVersions { |
| 7626 | if vers.version == VersionSSL30 { |
| 7627 | continue |
| 7628 | } |
| 7629 | testCases = append(testCases, testCase{ |
| 7630 | name: "ExportKeyingMaterial-" + vers.name, |
| 7631 | config: Config{ |
| 7632 | MaxVersion: vers.version, |
| 7633 | }, |
| 7634 | exportKeyingMaterial: 1024, |
| 7635 | exportLabel: "label", |
| 7636 | exportContext: "context", |
| 7637 | useExportContext: true, |
| 7638 | }) |
| 7639 | testCases = append(testCases, testCase{ |
| 7640 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7641 | config: Config{ |
| 7642 | MaxVersion: vers.version, |
| 7643 | }, |
| 7644 | exportKeyingMaterial: 1024, |
| 7645 | }) |
| 7646 | testCases = append(testCases, testCase{ |
| 7647 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7648 | config: Config{ |
| 7649 | MaxVersion: vers.version, |
| 7650 | }, |
| 7651 | exportKeyingMaterial: 1024, |
| 7652 | useExportContext: true, |
| 7653 | }) |
| 7654 | testCases = append(testCases, testCase{ |
| 7655 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7656 | config: Config{ |
| 7657 | MaxVersion: vers.version, |
| 7658 | }, |
| 7659 | exportKeyingMaterial: 1, |
| 7660 | exportLabel: "label", |
| 7661 | exportContext: "context", |
| 7662 | useExportContext: true, |
| 7663 | }) |
| 7664 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7665 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7666 | testCases = append(testCases, testCase{ |
| 7667 | name: "ExportKeyingMaterial-SSL3", |
| 7668 | config: Config{ |
| 7669 | MaxVersion: VersionSSL30, |
| 7670 | }, |
| 7671 | exportKeyingMaterial: 1024, |
| 7672 | exportLabel: "label", |
| 7673 | exportContext: "context", |
| 7674 | useExportContext: true, |
| 7675 | shouldFail: true, |
| 7676 | expectedError: "failed to export keying material", |
| 7677 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7678 | |
| 7679 | // Exporters work during a False Start. |
| 7680 | testCases = append(testCases, testCase{ |
| 7681 | name: "ExportKeyingMaterial-FalseStart", |
| 7682 | config: Config{ |
| 7683 | MaxVersion: VersionTLS12, |
| 7684 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7685 | NextProtos: []string{"foo"}, |
| 7686 | Bugs: ProtocolBugs{ |
| 7687 | ExpectFalseStart: true, |
| 7688 | }, |
| 7689 | }, |
| 7690 | flags: []string{ |
| 7691 | "-false-start", |
| 7692 | "-advertise-alpn", "\x03foo", |
| 7693 | }, |
| 7694 | shimWritesFirst: true, |
| 7695 | exportKeyingMaterial: 1024, |
| 7696 | exportLabel: "label", |
| 7697 | exportContext: "context", |
| 7698 | useExportContext: true, |
| 7699 | }) |
| 7700 | |
| 7701 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7702 | // triggering the exporter after every SSL_read call and configuring the |
| 7703 | // shim to run asynchronously. |
| 7704 | testCases = append(testCases, testCase{ |
| 7705 | name: "ExportKeyingMaterial-Renegotiate", |
| 7706 | config: Config{ |
| 7707 | MaxVersion: VersionTLS12, |
| 7708 | }, |
| 7709 | renegotiate: 1, |
| 7710 | flags: []string{ |
| 7711 | "-async", |
| 7712 | "-use-exporter-between-reads", |
| 7713 | "-renegotiate-freely", |
| 7714 | "-expect-total-renegotiations", "1", |
| 7715 | }, |
| 7716 | shouldFail: true, |
| 7717 | expectedError: "failed to export keying material", |
| 7718 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7719 | } |
| 7720 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7721 | func addTLSUniqueTests() { |
| 7722 | for _, isClient := range []bool{false, true} { |
| 7723 | for _, isResumption := range []bool{false, true} { |
| 7724 | for _, hasEMS := range []bool{false, true} { |
| 7725 | var suffix string |
| 7726 | if isResumption { |
| 7727 | suffix = "Resume-" |
| 7728 | } else { |
| 7729 | suffix = "Full-" |
| 7730 | } |
| 7731 | |
| 7732 | if hasEMS { |
| 7733 | suffix += "EMS-" |
| 7734 | } else { |
| 7735 | suffix += "NoEMS-" |
| 7736 | } |
| 7737 | |
| 7738 | if isClient { |
| 7739 | suffix += "Client" |
| 7740 | } else { |
| 7741 | suffix += "Server" |
| 7742 | } |
| 7743 | |
| 7744 | test := testCase{ |
| 7745 | name: "TLSUnique-" + suffix, |
| 7746 | testTLSUnique: true, |
| 7747 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7748 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7749 | Bugs: ProtocolBugs{ |
| 7750 | NoExtendedMasterSecret: !hasEMS, |
| 7751 | }, |
| 7752 | }, |
| 7753 | } |
| 7754 | |
| 7755 | if isResumption { |
| 7756 | test.resumeSession = true |
| 7757 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7758 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7759 | Bugs: ProtocolBugs{ |
| 7760 | NoExtendedMasterSecret: !hasEMS, |
| 7761 | }, |
| 7762 | } |
| 7763 | } |
| 7764 | |
| 7765 | if isResumption && !hasEMS { |
| 7766 | test.shouldFail = true |
| 7767 | test.expectedError = "failed to get tls-unique" |
| 7768 | } |
| 7769 | |
| 7770 | testCases = append(testCases, test) |
| 7771 | } |
| 7772 | } |
| 7773 | } |
| 7774 | } |
| 7775 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7776 | func addCustomExtensionTests() { |
| 7777 | expectedContents := "custom extension" |
| 7778 | emptyString := "" |
| 7779 | |
| 7780 | for _, isClient := range []bool{false, true} { |
| 7781 | suffix := "Server" |
| 7782 | flag := "-enable-server-custom-extension" |
| 7783 | testType := serverTest |
| 7784 | if isClient { |
| 7785 | suffix = "Client" |
| 7786 | flag = "-enable-client-custom-extension" |
| 7787 | testType = clientTest |
| 7788 | } |
| 7789 | |
| 7790 | testCases = append(testCases, testCase{ |
| 7791 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7792 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7793 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7794 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7795 | Bugs: ProtocolBugs{ |
| 7796 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7797 | ExpectedCustomExtension: &expectedContents, |
| 7798 | }, |
| 7799 | }, |
| 7800 | flags: []string{flag}, |
| 7801 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7802 | testCases = append(testCases, testCase{ |
| 7803 | testType: testType, |
| 7804 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7805 | config: Config{ |
| 7806 | MaxVersion: VersionTLS13, |
| 7807 | Bugs: ProtocolBugs{ |
| 7808 | CustomExtension: expectedContents, |
| 7809 | ExpectedCustomExtension: &expectedContents, |
| 7810 | }, |
| 7811 | }, |
| 7812 | flags: []string{flag}, |
| 7813 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7814 | |
| 7815 | // If the parse callback fails, the handshake should also fail. |
| 7816 | testCases = append(testCases, testCase{ |
| 7817 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7818 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7819 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7820 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7821 | Bugs: ProtocolBugs{ |
| 7822 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7823 | ExpectedCustomExtension: &expectedContents, |
| 7824 | }, |
| 7825 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7826 | flags: []string{flag}, |
| 7827 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7828 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7829 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7830 | testCases = append(testCases, testCase{ |
| 7831 | testType: testType, |
| 7832 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7833 | config: Config{ |
| 7834 | MaxVersion: VersionTLS13, |
| 7835 | Bugs: ProtocolBugs{ |
| 7836 | CustomExtension: expectedContents + "foo", |
| 7837 | ExpectedCustomExtension: &expectedContents, |
| 7838 | }, |
| 7839 | }, |
| 7840 | flags: []string{flag}, |
| 7841 | shouldFail: true, |
| 7842 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7843 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7844 | |
| 7845 | // If the add callback fails, the handshake should also fail. |
| 7846 | testCases = append(testCases, testCase{ |
| 7847 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7848 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7849 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7850 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7851 | Bugs: ProtocolBugs{ |
| 7852 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7853 | ExpectedCustomExtension: &expectedContents, |
| 7854 | }, |
| 7855 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7856 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7857 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7858 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7859 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7860 | testCases = append(testCases, testCase{ |
| 7861 | testType: testType, |
| 7862 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7863 | config: Config{ |
| 7864 | MaxVersion: VersionTLS13, |
| 7865 | Bugs: ProtocolBugs{ |
| 7866 | CustomExtension: expectedContents, |
| 7867 | ExpectedCustomExtension: &expectedContents, |
| 7868 | }, |
| 7869 | }, |
| 7870 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7871 | shouldFail: true, |
| 7872 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7873 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7874 | |
| 7875 | // If the add callback returns zero, no extension should be |
| 7876 | // added. |
| 7877 | skipCustomExtension := expectedContents |
| 7878 | if isClient { |
| 7879 | // For the case where the client skips sending the |
| 7880 | // custom extension, the server must not “echo” it. |
| 7881 | skipCustomExtension = "" |
| 7882 | } |
| 7883 | testCases = append(testCases, testCase{ |
| 7884 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7885 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7886 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7887 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7888 | Bugs: ProtocolBugs{ |
| 7889 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7890 | ExpectedCustomExtension: &emptyString, |
| 7891 | }, |
| 7892 | }, |
| 7893 | flags: []string{flag, "-custom-extension-skip"}, |
| 7894 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7895 | testCases = append(testCases, testCase{ |
| 7896 | testType: testType, |
| 7897 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7898 | config: Config{ |
| 7899 | MaxVersion: VersionTLS13, |
| 7900 | Bugs: ProtocolBugs{ |
| 7901 | CustomExtension: skipCustomExtension, |
| 7902 | ExpectedCustomExtension: &emptyString, |
| 7903 | }, |
| 7904 | }, |
| 7905 | flags: []string{flag, "-custom-extension-skip"}, |
| 7906 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7907 | } |
| 7908 | |
| 7909 | // The custom extension add callback should not be called if the client |
| 7910 | // doesn't send the extension. |
| 7911 | testCases = append(testCases, testCase{ |
| 7912 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7913 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7914 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7915 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7916 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7917 | ExpectedCustomExtension: &emptyString, |
| 7918 | }, |
| 7919 | }, |
| 7920 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7921 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7922 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7923 | testCases = append(testCases, testCase{ |
| 7924 | testType: serverTest, |
| 7925 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7926 | config: Config{ |
| 7927 | MaxVersion: VersionTLS13, |
| 7928 | Bugs: ProtocolBugs{ |
| 7929 | ExpectedCustomExtension: &emptyString, |
| 7930 | }, |
| 7931 | }, |
| 7932 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7933 | }) |
| 7934 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7935 | // Test an unknown extension from the server. |
| 7936 | testCases = append(testCases, testCase{ |
| 7937 | testType: clientTest, |
| 7938 | name: "UnknownExtension-Client", |
| 7939 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7940 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7941 | Bugs: ProtocolBugs{ |
| 7942 | CustomExtension: expectedContents, |
| 7943 | }, |
| 7944 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7945 | shouldFail: true, |
| 7946 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7947 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7948 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7949 | testCases = append(testCases, testCase{ |
| 7950 | testType: clientTest, |
| 7951 | name: "UnknownExtension-Client-TLS13", |
| 7952 | config: Config{ |
| 7953 | MaxVersion: VersionTLS13, |
| 7954 | Bugs: ProtocolBugs{ |
| 7955 | CustomExtension: expectedContents, |
| 7956 | }, |
| 7957 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7958 | shouldFail: true, |
| 7959 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7960 | expectedLocalError: "remote error: unsupported extension", |
| 7961 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7962 | testCases = append(testCases, testCase{ |
| 7963 | testType: clientTest, |
| 7964 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7965 | config: Config{ |
| 7966 | MaxVersion: VersionTLS13, |
| 7967 | Bugs: ProtocolBugs{ |
| 7968 | CustomUnencryptedExtension: expectedContents, |
| 7969 | }, |
| 7970 | }, |
| 7971 | shouldFail: true, |
| 7972 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7973 | // The shim must send an alert, but alerts at this point do not |
| 7974 | // get successfully decrypted by the runner. |
| 7975 | expectedLocalError: "local error: bad record MAC", |
| 7976 | }) |
| 7977 | testCases = append(testCases, testCase{ |
| 7978 | testType: clientTest, |
| 7979 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7980 | config: Config{ |
| 7981 | MaxVersion: VersionTLS13, |
| 7982 | Bugs: ProtocolBugs{ |
| 7983 | SendUnencryptedALPN: "foo", |
| 7984 | }, |
| 7985 | }, |
| 7986 | flags: []string{ |
| 7987 | "-advertise-alpn", "\x03foo\x03bar", |
| 7988 | }, |
| 7989 | shouldFail: true, |
| 7990 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7991 | // The shim must send an alert, but alerts at this point do not |
| 7992 | // get successfully decrypted by the runner. |
| 7993 | expectedLocalError: "local error: bad record MAC", |
| 7994 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7995 | |
| 7996 | // Test a known but unoffered extension from the server. |
| 7997 | testCases = append(testCases, testCase{ |
| 7998 | testType: clientTest, |
| 7999 | name: "UnofferedExtension-Client", |
| 8000 | config: Config{ |
| 8001 | MaxVersion: VersionTLS12, |
| 8002 | Bugs: ProtocolBugs{ |
| 8003 | SendALPN: "alpn", |
| 8004 | }, |
| 8005 | }, |
| 8006 | shouldFail: true, |
| 8007 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8008 | expectedLocalError: "remote error: unsupported extension", |
| 8009 | }) |
| 8010 | testCases = append(testCases, testCase{ |
| 8011 | testType: clientTest, |
| 8012 | name: "UnofferedExtension-Client-TLS13", |
| 8013 | config: Config{ |
| 8014 | MaxVersion: VersionTLS13, |
| 8015 | Bugs: ProtocolBugs{ |
| 8016 | SendALPN: "alpn", |
| 8017 | }, |
| 8018 | }, |
| 8019 | shouldFail: true, |
| 8020 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8021 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8022 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8023 | } |
| 8024 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8025 | func addRSAClientKeyExchangeTests() { |
| 8026 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 8027 | testCases = append(testCases, testCase{ |
| 8028 | testType: serverTest, |
| 8029 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 8030 | config: Config{ |
| 8031 | // Ensure the ClientHello version and final |
| 8032 | // version are different, to detect if the |
| 8033 | // server uses the wrong one. |
| 8034 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 8035 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8036 | Bugs: ProtocolBugs{ |
| 8037 | BadRSAClientKeyExchange: bad, |
| 8038 | }, |
| 8039 | }, |
| 8040 | shouldFail: true, |
| 8041 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8042 | }) |
| 8043 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 8044 | |
| 8045 | // The server must compare whatever was in ClientHello.version for the |
| 8046 | // RSA premaster. |
| 8047 | testCases = append(testCases, testCase{ |
| 8048 | testType: serverTest, |
| 8049 | name: "SendClientVersion-RSA", |
| 8050 | config: Config{ |
| 8051 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 8052 | Bugs: ProtocolBugs{ |
| 8053 | SendClientVersion: 0x1234, |
| 8054 | }, |
| 8055 | }, |
| 8056 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8057 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8058 | } |
| 8059 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8060 | var testCurves = []struct { |
| 8061 | name string |
| 8062 | id CurveID |
| 8063 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8064 | {"P-256", CurveP256}, |
| 8065 | {"P-384", CurveP384}, |
| 8066 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 8067 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8068 | } |
| 8069 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8070 | const bogusCurve = 0x1234 |
| 8071 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8072 | func addCurveTests() { |
| 8073 | for _, curve := range testCurves { |
| 8074 | testCases = append(testCases, testCase{ |
| 8075 | name: "CurveTest-Client-" + curve.name, |
| 8076 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8077 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8078 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8079 | CurvePreferences: []CurveID{curve.id}, |
| 8080 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8081 | flags: []string{ |
| 8082 | "-enable-all-curves", |
| 8083 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8084 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8085 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8086 | }) |
| 8087 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8088 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 8089 | config: Config{ |
| 8090 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8091 | CurvePreferences: []CurveID{curve.id}, |
| 8092 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8093 | flags: []string{ |
| 8094 | "-enable-all-curves", |
| 8095 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8096 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8097 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8098 | }) |
| 8099 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8100 | testType: serverTest, |
| 8101 | name: "CurveTest-Server-" + curve.name, |
| 8102 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8103 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8104 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8105 | CurvePreferences: []CurveID{curve.id}, |
| 8106 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8107 | flags: []string{ |
| 8108 | "-enable-all-curves", |
| 8109 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8110 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8111 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8112 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8113 | testCases = append(testCases, testCase{ |
| 8114 | testType: serverTest, |
| 8115 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 8116 | config: Config{ |
| 8117 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8118 | CurvePreferences: []CurveID{curve.id}, |
| 8119 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8120 | flags: []string{ |
| 8121 | "-enable-all-curves", |
| 8122 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8123 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8124 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8125 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8126 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8127 | |
| 8128 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8129 | testCases = append(testCases, testCase{ |
| 8130 | testType: serverTest, |
| 8131 | name: "UnknownCurve", |
| 8132 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8133 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8134 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8135 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 8136 | }, |
| 8137 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8138 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8139 | // The server must be tolerant to bogus curves. |
| 8140 | testCases = append(testCases, testCase{ |
| 8141 | testType: serverTest, |
| 8142 | name: "UnknownCurve-TLS13", |
| 8143 | config: Config{ |
| 8144 | MaxVersion: VersionTLS13, |
| 8145 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 8146 | }, |
| 8147 | }) |
| 8148 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8149 | // The server must not consider ECDHE ciphers when there are no |
| 8150 | // supported curves. |
| 8151 | testCases = append(testCases, testCase{ |
| 8152 | testType: serverTest, |
| 8153 | name: "NoSupportedCurves", |
| 8154 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8155 | MaxVersion: VersionTLS12, |
| 8156 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8157 | Bugs: ProtocolBugs{ |
| 8158 | NoSupportedCurves: true, |
| 8159 | }, |
| 8160 | }, |
| 8161 | shouldFail: true, |
| 8162 | expectedError: ":NO_SHARED_CIPHER:", |
| 8163 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8164 | testCases = append(testCases, testCase{ |
| 8165 | testType: serverTest, |
| 8166 | name: "NoSupportedCurves-TLS13", |
| 8167 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8168 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8169 | Bugs: ProtocolBugs{ |
| 8170 | NoSupportedCurves: true, |
| 8171 | }, |
| 8172 | }, |
| 8173 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8174 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8175 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8176 | |
| 8177 | // The server must fall back to another cipher when there are no |
| 8178 | // supported curves. |
| 8179 | testCases = append(testCases, testCase{ |
| 8180 | testType: serverTest, |
| 8181 | name: "NoCommonCurves", |
| 8182 | config: Config{ |
| 8183 | MaxVersion: VersionTLS12, |
| 8184 | CipherSuites: []uint16{ |
| 8185 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8186 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8187 | }, |
| 8188 | CurvePreferences: []CurveID{CurveP224}, |
| 8189 | }, |
| 8190 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8191 | }) |
| 8192 | |
| 8193 | // The client must reject bogus curves and disabled curves. |
| 8194 | testCases = append(testCases, testCase{ |
| 8195 | name: "BadECDHECurve", |
| 8196 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8197 | MaxVersion: VersionTLS12, |
| 8198 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8199 | Bugs: ProtocolBugs{ |
| 8200 | SendCurve: bogusCurve, |
| 8201 | }, |
| 8202 | }, |
| 8203 | shouldFail: true, |
| 8204 | expectedError: ":WRONG_CURVE:", |
| 8205 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8206 | testCases = append(testCases, testCase{ |
| 8207 | name: "BadECDHECurve-TLS13", |
| 8208 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8209 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8210 | Bugs: ProtocolBugs{ |
| 8211 | SendCurve: bogusCurve, |
| 8212 | }, |
| 8213 | }, |
| 8214 | shouldFail: true, |
| 8215 | expectedError: ":WRONG_CURVE:", |
| 8216 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8217 | |
| 8218 | testCases = append(testCases, testCase{ |
| 8219 | name: "UnsupportedCurve", |
| 8220 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8221 | MaxVersion: VersionTLS12, |
| 8222 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8223 | CurvePreferences: []CurveID{CurveP256}, |
| 8224 | Bugs: ProtocolBugs{ |
| 8225 | IgnorePeerCurvePreferences: true, |
| 8226 | }, |
| 8227 | }, |
| 8228 | flags: []string{"-p384-only"}, |
| 8229 | shouldFail: true, |
| 8230 | expectedError: ":WRONG_CURVE:", |
| 8231 | }) |
| 8232 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8233 | testCases = append(testCases, testCase{ |
| 8234 | // TODO(davidben): Add a TLS 1.3 version where |
| 8235 | // HelloRetryRequest requests an unsupported curve. |
| 8236 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8237 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8238 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8239 | CurvePreferences: []CurveID{CurveP384}, |
| 8240 | Bugs: ProtocolBugs{ |
| 8241 | SendCurve: CurveP256, |
| 8242 | }, |
| 8243 | }, |
| 8244 | flags: []string{"-p384-only"}, |
| 8245 | shouldFail: true, |
| 8246 | expectedError: ":WRONG_CURVE:", |
| 8247 | }) |
| 8248 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8249 | // Test invalid curve points. |
| 8250 | testCases = append(testCases, testCase{ |
| 8251 | name: "InvalidECDHPoint-Client", |
| 8252 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8253 | MaxVersion: VersionTLS12, |
| 8254 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8255 | CurvePreferences: []CurveID{CurveP256}, |
| 8256 | Bugs: ProtocolBugs{ |
| 8257 | InvalidECDHPoint: true, |
| 8258 | }, |
| 8259 | }, |
| 8260 | shouldFail: true, |
| 8261 | expectedError: ":INVALID_ENCODING:", |
| 8262 | }) |
| 8263 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8264 | name: "InvalidECDHPoint-Client-TLS13", |
| 8265 | config: Config{ |
| 8266 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8267 | CurvePreferences: []CurveID{CurveP256}, |
| 8268 | Bugs: ProtocolBugs{ |
| 8269 | InvalidECDHPoint: true, |
| 8270 | }, |
| 8271 | }, |
| 8272 | shouldFail: true, |
| 8273 | expectedError: ":INVALID_ENCODING:", |
| 8274 | }) |
| 8275 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8276 | testType: serverTest, |
| 8277 | name: "InvalidECDHPoint-Server", |
| 8278 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8279 | MaxVersion: VersionTLS12, |
| 8280 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8281 | CurvePreferences: []CurveID{CurveP256}, |
| 8282 | Bugs: ProtocolBugs{ |
| 8283 | InvalidECDHPoint: true, |
| 8284 | }, |
| 8285 | }, |
| 8286 | shouldFail: true, |
| 8287 | expectedError: ":INVALID_ENCODING:", |
| 8288 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8289 | testCases = append(testCases, testCase{ |
| 8290 | testType: serverTest, |
| 8291 | name: "InvalidECDHPoint-Server-TLS13", |
| 8292 | config: Config{ |
| 8293 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8294 | CurvePreferences: []CurveID{CurveP256}, |
| 8295 | Bugs: ProtocolBugs{ |
| 8296 | InvalidECDHPoint: true, |
| 8297 | }, |
| 8298 | }, |
| 8299 | shouldFail: true, |
| 8300 | expectedError: ":INVALID_ENCODING:", |
| 8301 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8302 | |
| 8303 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 8304 | testCases = append(testCases, testCase{ |
| 8305 | name: "CurveID-Resume-Client", |
| 8306 | config: Config{ |
| 8307 | MaxVersion: VersionTLS12, |
| 8308 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8309 | CurvePreferences: []CurveID{CurveX25519}, |
| 8310 | }, |
| 8311 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8312 | resumeSession: true, |
| 8313 | }) |
| 8314 | testCases = append(testCases, testCase{ |
| 8315 | testType: serverTest, |
| 8316 | name: "CurveID-Resume-Server", |
| 8317 | config: Config{ |
| 8318 | MaxVersion: VersionTLS12, |
| 8319 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8320 | CurvePreferences: []CurveID{CurveX25519}, |
| 8321 | }, |
| 8322 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8323 | resumeSession: true, |
| 8324 | }) |
| 8325 | |
| 8326 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 8327 | // one should be reported. |
| 8328 | testCases = append(testCases, testCase{ |
| 8329 | name: "CurveID-Resume-Client-TLS13", |
| 8330 | config: Config{ |
| 8331 | MaxVersion: VersionTLS13, |
| 8332 | CurvePreferences: []CurveID{CurveX25519}, |
| 8333 | }, |
| 8334 | resumeConfig: &Config{ |
| 8335 | MaxVersion: VersionTLS13, |
| 8336 | CurvePreferences: []CurveID{CurveP256}, |
| 8337 | }, |
| 8338 | flags: []string{ |
| 8339 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8340 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8341 | }, |
| 8342 | resumeSession: true, |
| 8343 | }) |
| 8344 | testCases = append(testCases, testCase{ |
| 8345 | testType: serverTest, |
| 8346 | name: "CurveID-Resume-Server-TLS13", |
| 8347 | config: Config{ |
| 8348 | MaxVersion: VersionTLS13, |
| 8349 | CurvePreferences: []CurveID{CurveX25519}, |
| 8350 | }, |
| 8351 | resumeConfig: &Config{ |
| 8352 | MaxVersion: VersionTLS13, |
| 8353 | CurvePreferences: []CurveID{CurveP256}, |
| 8354 | }, |
| 8355 | flags: []string{ |
| 8356 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8357 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8358 | }, |
| 8359 | resumeSession: true, |
| 8360 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 8361 | |
| 8362 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 8363 | testCases = append(testCases, testCase{ |
| 8364 | name: "PointFormat-ServerHello-TLS12", |
| 8365 | config: Config{ |
| 8366 | MaxVersion: VersionTLS12, |
| 8367 | Bugs: ProtocolBugs{ |
| 8368 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8369 | }, |
| 8370 | }, |
| 8371 | }) |
| 8372 | testCases = append(testCases, testCase{ |
| 8373 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 8374 | config: Config{ |
| 8375 | MaxVersion: VersionTLS13, |
| 8376 | Bugs: ProtocolBugs{ |
| 8377 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8378 | }, |
| 8379 | }, |
| 8380 | shouldFail: true, |
| 8381 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8382 | }) |
| 8383 | |
| 8384 | // Test that we tolerate unknown point formats, as long as |
| 8385 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 8386 | // check they are still functional. |
| 8387 | testCases = append(testCases, testCase{ |
| 8388 | name: "PointFormat-Client-Tolerance", |
| 8389 | config: Config{ |
| 8390 | MaxVersion: VersionTLS12, |
| 8391 | Bugs: ProtocolBugs{ |
| 8392 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8393 | }, |
| 8394 | }, |
| 8395 | }) |
| 8396 | testCases = append(testCases, testCase{ |
| 8397 | testType: serverTest, |
| 8398 | name: "PointFormat-Server-Tolerance", |
| 8399 | config: Config{ |
| 8400 | MaxVersion: VersionTLS12, |
| 8401 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8402 | Bugs: ProtocolBugs{ |
| 8403 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8404 | }, |
| 8405 | }, |
| 8406 | }) |
| 8407 | |
| 8408 | // Test TLS 1.2 does not require the point format extension to be |
| 8409 | // present. |
| 8410 | testCases = append(testCases, testCase{ |
| 8411 | name: "PointFormat-Client-Missing", |
| 8412 | config: Config{ |
| 8413 | MaxVersion: VersionTLS12, |
| 8414 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8415 | Bugs: ProtocolBugs{ |
| 8416 | SendSupportedPointFormats: []byte{}, |
| 8417 | }, |
| 8418 | }, |
| 8419 | }) |
| 8420 | testCases = append(testCases, testCase{ |
| 8421 | testType: serverTest, |
| 8422 | name: "PointFormat-Server-Missing", |
| 8423 | config: Config{ |
| 8424 | MaxVersion: VersionTLS12, |
| 8425 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8426 | Bugs: ProtocolBugs{ |
| 8427 | SendSupportedPointFormats: []byte{}, |
| 8428 | }, |
| 8429 | }, |
| 8430 | }) |
| 8431 | |
| 8432 | // If the point format extension is present, uncompressed points must be |
| 8433 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 8434 | testCases = append(testCases, testCase{ |
| 8435 | name: "PointFormat-Client-MissingUncompressed", |
| 8436 | config: Config{ |
| 8437 | MaxVersion: VersionTLS12, |
| 8438 | Bugs: ProtocolBugs{ |
| 8439 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8440 | }, |
| 8441 | }, |
| 8442 | shouldFail: true, |
| 8443 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8444 | }) |
| 8445 | testCases = append(testCases, testCase{ |
| 8446 | testType: serverTest, |
| 8447 | name: "PointFormat-Server-MissingUncompressed", |
| 8448 | config: Config{ |
| 8449 | MaxVersion: VersionTLS12, |
| 8450 | Bugs: ProtocolBugs{ |
| 8451 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8452 | }, |
| 8453 | }, |
| 8454 | shouldFail: true, |
| 8455 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8456 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8457 | } |
| 8458 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8459 | func addTLS13RecordTests() { |
| 8460 | testCases = append(testCases, testCase{ |
| 8461 | name: "TLS13-RecordPadding", |
| 8462 | config: Config{ |
| 8463 | MaxVersion: VersionTLS13, |
| 8464 | MinVersion: VersionTLS13, |
| 8465 | Bugs: ProtocolBugs{ |
| 8466 | RecordPadding: 10, |
| 8467 | }, |
| 8468 | }, |
| 8469 | }) |
| 8470 | |
| 8471 | testCases = append(testCases, testCase{ |
| 8472 | name: "TLS13-EmptyRecords", |
| 8473 | config: Config{ |
| 8474 | MaxVersion: VersionTLS13, |
| 8475 | MinVersion: VersionTLS13, |
| 8476 | Bugs: ProtocolBugs{ |
| 8477 | OmitRecordContents: true, |
| 8478 | }, |
| 8479 | }, |
| 8480 | shouldFail: true, |
| 8481 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8482 | }) |
| 8483 | |
| 8484 | testCases = append(testCases, testCase{ |
| 8485 | name: "TLS13-OnlyPadding", |
| 8486 | config: Config{ |
| 8487 | MaxVersion: VersionTLS13, |
| 8488 | MinVersion: VersionTLS13, |
| 8489 | Bugs: ProtocolBugs{ |
| 8490 | OmitRecordContents: true, |
| 8491 | RecordPadding: 10, |
| 8492 | }, |
| 8493 | }, |
| 8494 | shouldFail: true, |
| 8495 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8496 | }) |
| 8497 | |
| 8498 | testCases = append(testCases, testCase{ |
| 8499 | name: "TLS13-WrongOuterRecord", |
| 8500 | config: Config{ |
| 8501 | MaxVersion: VersionTLS13, |
| 8502 | MinVersion: VersionTLS13, |
| 8503 | Bugs: ProtocolBugs{ |
| 8504 | OuterRecordType: recordTypeHandshake, |
| 8505 | }, |
| 8506 | }, |
| 8507 | shouldFail: true, |
| 8508 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8509 | }) |
| 8510 | } |
| 8511 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8512 | func addSessionTicketTests() { |
| 8513 | testCases = append(testCases, testCase{ |
| 8514 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8515 | // mean the server changed its mind on sending a ticket. |
| 8516 | name: "SendEmptySessionTicket", |
| 8517 | config: Config{ |
| 8518 | MaxVersion: VersionTLS12, |
| 8519 | Bugs: ProtocolBugs{ |
| 8520 | SendEmptySessionTicket: true, |
| 8521 | }, |
| 8522 | }, |
| 8523 | flags: []string{"-expect-no-session"}, |
| 8524 | }) |
| 8525 | |
| 8526 | // Test that the server ignores unknown PSK modes. |
| 8527 | testCases = append(testCases, testCase{ |
| 8528 | testType: serverTest, |
| 8529 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8530 | config: Config{ |
| 8531 | MaxVersion: VersionTLS13, |
| 8532 | Bugs: ProtocolBugs{ |
| 8533 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8534 | }, |
| 8535 | }, |
| 8536 | resumeSession: true, |
| 8537 | expectedResumeVersion: VersionTLS13, |
| 8538 | }) |
| 8539 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8540 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8541 | testCases = append(testCases, testCase{ |
| 8542 | testType: serverTest, |
| 8543 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8544 | config: Config{ |
| 8545 | MaxVersion: VersionTLS13, |
| 8546 | Bugs: ProtocolBugs{ |
| 8547 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8548 | ExpectNoNewSessionTicket: true, |
| 8549 | }, |
| 8550 | }, |
| 8551 | }) |
| 8552 | |
| 8553 | // 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] | 8554 | testCases = append(testCases, testCase{ |
| 8555 | testType: serverTest, |
| 8556 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8557 | config: Config{ |
| 8558 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8559 | }, |
| 8560 | resumeConfig: &Config{ |
| 8561 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8562 | Bugs: ProtocolBugs{ |
| 8563 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8564 | }, |
| 8565 | }, |
| 8566 | resumeSession: true, |
| 8567 | expectResumeRejected: true, |
| 8568 | }) |
| 8569 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8570 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8571 | testCases = append(testCases, testCase{ |
| 8572 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8573 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8574 | config: Config{ |
| 8575 | MaxVersion: VersionTLS13, |
| 8576 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8577 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8578 | }, |
| 8579 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8580 | resumeSession: true, |
| 8581 | flags: []string{ |
| 8582 | "-resumption-delay", "10", |
| 8583 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8584 | }) |
| 8585 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8586 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8587 | testCases = append(testCases, testCase{ |
| 8588 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8589 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8590 | config: Config{ |
| 8591 | MaxVersion: VersionTLS13, |
| 8592 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8593 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8594 | }, |
| 8595 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8596 | resumeSession: true, |
| 8597 | shouldFail: true, |
| 8598 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8599 | }) |
| 8600 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8601 | testCases = append(testCases, testCase{ |
| 8602 | testType: clientTest, |
| 8603 | name: "TLS13-SendTicketEarlyDataInfo", |
| 8604 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 8605 | MaxVersion: VersionTLS13, |
| 8606 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8607 | }, |
| 8608 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 8609 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8610 | "-expect-early-data-info", |
| 8611 | }, |
| 8612 | }) |
| 8613 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 8614 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 8615 | testCases = append(testCases, testCase{ |
| 8616 | testType: clientTest, |
| 8617 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 8618 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 8619 | MaxVersion: VersionTLS13, |
| 8620 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 8621 | }, |
| 8622 | }) |
| 8623 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8624 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 8625 | testType: clientTest, |
| 8626 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 8627 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 8628 | MaxVersion: VersionTLS13, |
| 8629 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 8630 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 8631 | DuplicateTicketEarlyDataInfo: true, |
| 8632 | }, |
| 8633 | }, |
| 8634 | shouldFail: true, |
| 8635 | expectedError: ":DUPLICATE_EXTENSION:", |
| 8636 | expectedLocalError: "remote error: illegal parameter", |
| 8637 | }) |
| 8638 | |
| 8639 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8640 | testType: serverTest, |
| 8641 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 8642 | config: Config{ |
| 8643 | MaxVersion: VersionTLS13, |
| 8644 | Bugs: ProtocolBugs{ |
| 8645 | ExpectTicketEarlyDataInfo: true, |
| 8646 | }, |
| 8647 | }, |
| 8648 | flags: []string{ |
| 8649 | "-enable-early-data", |
| 8650 | }, |
| 8651 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 8652 | |
| 8653 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 8654 | // is honored. |
| 8655 | testCases = append(testCases, testCase{ |
| 8656 | testType: clientTest, |
| 8657 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 8658 | config: Config{ |
| 8659 | MaxVersion: VersionTLS13, |
| 8660 | Bugs: ProtocolBugs{ |
| 8661 | SendTicketLifetime: 20 * time.Second, |
| 8662 | }, |
| 8663 | }, |
| 8664 | flags: []string{ |
| 8665 | "-resumption-delay", "19", |
| 8666 | }, |
| 8667 | resumeSession: true, |
| 8668 | }) |
| 8669 | testCases = append(testCases, testCase{ |
| 8670 | testType: clientTest, |
| 8671 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 8672 | config: Config{ |
| 8673 | MaxVersion: VersionTLS13, |
| 8674 | Bugs: ProtocolBugs{ |
| 8675 | SendTicketLifetime: 20 * time.Second, |
| 8676 | // The client should not offer the expired session. |
| 8677 | ExpectNoTLS13PSK: true, |
| 8678 | }, |
| 8679 | }, |
| 8680 | flags: []string{ |
| 8681 | "-resumption-delay", "21", |
| 8682 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 8683 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 8684 | expectResumeRejected: true, |
| 8685 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8686 | } |
| 8687 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8688 | func addChangeCipherSpecTests() { |
| 8689 | // Test missing ChangeCipherSpecs. |
| 8690 | testCases = append(testCases, testCase{ |
| 8691 | name: "SkipChangeCipherSpec-Client", |
| 8692 | config: Config{ |
| 8693 | MaxVersion: VersionTLS12, |
| 8694 | Bugs: ProtocolBugs{ |
| 8695 | SkipChangeCipherSpec: true, |
| 8696 | }, |
| 8697 | }, |
| 8698 | shouldFail: true, |
| 8699 | expectedError: ":UNEXPECTED_RECORD:", |
| 8700 | }) |
| 8701 | testCases = append(testCases, testCase{ |
| 8702 | testType: serverTest, |
| 8703 | name: "SkipChangeCipherSpec-Server", |
| 8704 | config: Config{ |
| 8705 | MaxVersion: VersionTLS12, |
| 8706 | Bugs: ProtocolBugs{ |
| 8707 | SkipChangeCipherSpec: true, |
| 8708 | }, |
| 8709 | }, |
| 8710 | shouldFail: true, |
| 8711 | expectedError: ":UNEXPECTED_RECORD:", |
| 8712 | }) |
| 8713 | testCases = append(testCases, testCase{ |
| 8714 | testType: serverTest, |
| 8715 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8716 | config: Config{ |
| 8717 | MaxVersion: VersionTLS12, |
| 8718 | NextProtos: []string{"bar"}, |
| 8719 | Bugs: ProtocolBugs{ |
| 8720 | SkipChangeCipherSpec: true, |
| 8721 | }, |
| 8722 | }, |
| 8723 | flags: []string{ |
| 8724 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8725 | }, |
| 8726 | shouldFail: true, |
| 8727 | expectedError: ":UNEXPECTED_RECORD:", |
| 8728 | }) |
| 8729 | |
| 8730 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8731 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8732 | // rejected. Test both with and without handshake packing to handle both |
| 8733 | // when the partial post-CCS message is in its own record and when it is |
| 8734 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8735 | for _, packed := range []bool{false, true} { |
| 8736 | var suffix string |
| 8737 | if packed { |
| 8738 | suffix = "-Packed" |
| 8739 | } |
| 8740 | |
| 8741 | testCases = append(testCases, testCase{ |
| 8742 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8743 | config: Config{ |
| 8744 | MaxVersion: VersionTLS12, |
| 8745 | Bugs: ProtocolBugs{ |
| 8746 | FragmentAcrossChangeCipherSpec: true, |
| 8747 | PackHandshakeFlight: packed, |
| 8748 | }, |
| 8749 | }, |
| 8750 | shouldFail: true, |
| 8751 | expectedError: ":UNEXPECTED_RECORD:", |
| 8752 | }) |
| 8753 | testCases = append(testCases, testCase{ |
| 8754 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8755 | config: Config{ |
| 8756 | MaxVersion: VersionTLS12, |
| 8757 | }, |
| 8758 | resumeSession: true, |
| 8759 | resumeConfig: &Config{ |
| 8760 | MaxVersion: VersionTLS12, |
| 8761 | Bugs: ProtocolBugs{ |
| 8762 | FragmentAcrossChangeCipherSpec: true, |
| 8763 | PackHandshakeFlight: packed, |
| 8764 | }, |
| 8765 | }, |
| 8766 | shouldFail: true, |
| 8767 | expectedError: ":UNEXPECTED_RECORD:", |
| 8768 | }) |
| 8769 | testCases = append(testCases, testCase{ |
| 8770 | testType: serverTest, |
| 8771 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8772 | config: Config{ |
| 8773 | MaxVersion: VersionTLS12, |
| 8774 | Bugs: ProtocolBugs{ |
| 8775 | FragmentAcrossChangeCipherSpec: true, |
| 8776 | PackHandshakeFlight: packed, |
| 8777 | }, |
| 8778 | }, |
| 8779 | shouldFail: true, |
| 8780 | expectedError: ":UNEXPECTED_RECORD:", |
| 8781 | }) |
| 8782 | testCases = append(testCases, testCase{ |
| 8783 | testType: serverTest, |
| 8784 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8785 | config: Config{ |
| 8786 | MaxVersion: VersionTLS12, |
| 8787 | }, |
| 8788 | resumeSession: true, |
| 8789 | resumeConfig: &Config{ |
| 8790 | MaxVersion: VersionTLS12, |
| 8791 | Bugs: ProtocolBugs{ |
| 8792 | FragmentAcrossChangeCipherSpec: true, |
| 8793 | PackHandshakeFlight: packed, |
| 8794 | }, |
| 8795 | }, |
| 8796 | shouldFail: true, |
| 8797 | expectedError: ":UNEXPECTED_RECORD:", |
| 8798 | }) |
| 8799 | testCases = append(testCases, testCase{ |
| 8800 | testType: serverTest, |
| 8801 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8802 | config: Config{ |
| 8803 | MaxVersion: VersionTLS12, |
| 8804 | NextProtos: []string{"bar"}, |
| 8805 | Bugs: ProtocolBugs{ |
| 8806 | FragmentAcrossChangeCipherSpec: true, |
| 8807 | PackHandshakeFlight: packed, |
| 8808 | }, |
| 8809 | }, |
| 8810 | flags: []string{ |
| 8811 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8812 | }, |
| 8813 | shouldFail: true, |
| 8814 | expectedError: ":UNEXPECTED_RECORD:", |
| 8815 | }) |
| 8816 | } |
| 8817 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8818 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8819 | // messages in the handshake queue. Do this by testing the server |
| 8820 | // reading the client Finished, reversing the flight so Finished comes |
| 8821 | // first. |
| 8822 | testCases = append(testCases, testCase{ |
| 8823 | protocol: dtls, |
| 8824 | testType: serverTest, |
| 8825 | name: "SendUnencryptedFinished-DTLS", |
| 8826 | config: Config{ |
| 8827 | MaxVersion: VersionTLS12, |
| 8828 | Bugs: ProtocolBugs{ |
| 8829 | SendUnencryptedFinished: true, |
| 8830 | ReverseHandshakeFragments: true, |
| 8831 | }, |
| 8832 | }, |
| 8833 | shouldFail: true, |
| 8834 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8835 | }) |
| 8836 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8837 | // Test synchronization between encryption changes and the handshake in |
| 8838 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8839 | testCases = append(testCases, testCase{ |
| 8840 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8841 | config: Config{ |
| 8842 | MaxVersion: VersionTLS13, |
| 8843 | Bugs: ProtocolBugs{ |
| 8844 | PartialEncryptedExtensionsWithServerHello: true, |
| 8845 | }, |
| 8846 | }, |
| 8847 | shouldFail: true, |
| 8848 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8849 | }) |
| 8850 | testCases = append(testCases, testCase{ |
| 8851 | testType: serverTest, |
| 8852 | name: "PartialClientFinishedWithClientHello", |
| 8853 | config: Config{ |
| 8854 | MaxVersion: VersionTLS13, |
| 8855 | Bugs: ProtocolBugs{ |
| 8856 | PartialClientFinishedWithClientHello: true, |
| 8857 | }, |
| 8858 | }, |
| 8859 | shouldFail: true, |
| 8860 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8861 | }) |
| 8862 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8863 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8864 | testCases = append(testCases, testCase{ |
| 8865 | testType: serverTest, |
| 8866 | name: "EarlyChangeCipherSpec-server-1", |
| 8867 | config: Config{ |
| 8868 | MaxVersion: VersionTLS12, |
| 8869 | Bugs: ProtocolBugs{ |
| 8870 | EarlyChangeCipherSpec: 1, |
| 8871 | }, |
| 8872 | }, |
| 8873 | shouldFail: true, |
| 8874 | expectedError: ":UNEXPECTED_RECORD:", |
| 8875 | }) |
| 8876 | testCases = append(testCases, testCase{ |
| 8877 | testType: serverTest, |
| 8878 | name: "EarlyChangeCipherSpec-server-2", |
| 8879 | config: Config{ |
| 8880 | MaxVersion: VersionTLS12, |
| 8881 | Bugs: ProtocolBugs{ |
| 8882 | EarlyChangeCipherSpec: 2, |
| 8883 | }, |
| 8884 | }, |
| 8885 | shouldFail: true, |
| 8886 | expectedError: ":UNEXPECTED_RECORD:", |
| 8887 | }) |
| 8888 | testCases = append(testCases, testCase{ |
| 8889 | protocol: dtls, |
| 8890 | name: "StrayChangeCipherSpec", |
| 8891 | config: Config{ |
| 8892 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8893 | // that stray ChangeCipherSpec messages are |
| 8894 | // rejected. |
| 8895 | MaxVersion: VersionTLS12, |
| 8896 | Bugs: ProtocolBugs{ |
| 8897 | StrayChangeCipherSpec: true, |
| 8898 | }, |
| 8899 | }, |
| 8900 | }) |
| 8901 | |
| 8902 | // Test that the contents of ChangeCipherSpec are checked. |
| 8903 | testCases = append(testCases, testCase{ |
| 8904 | name: "BadChangeCipherSpec-1", |
| 8905 | config: Config{ |
| 8906 | MaxVersion: VersionTLS12, |
| 8907 | Bugs: ProtocolBugs{ |
| 8908 | BadChangeCipherSpec: []byte{2}, |
| 8909 | }, |
| 8910 | }, |
| 8911 | shouldFail: true, |
| 8912 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8913 | }) |
| 8914 | testCases = append(testCases, testCase{ |
| 8915 | name: "BadChangeCipherSpec-2", |
| 8916 | config: Config{ |
| 8917 | MaxVersion: VersionTLS12, |
| 8918 | Bugs: ProtocolBugs{ |
| 8919 | BadChangeCipherSpec: []byte{1, 1}, |
| 8920 | }, |
| 8921 | }, |
| 8922 | shouldFail: true, |
| 8923 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8924 | }) |
| 8925 | testCases = append(testCases, testCase{ |
| 8926 | protocol: dtls, |
| 8927 | name: "BadChangeCipherSpec-DTLS-1", |
| 8928 | config: Config{ |
| 8929 | MaxVersion: VersionTLS12, |
| 8930 | Bugs: ProtocolBugs{ |
| 8931 | BadChangeCipherSpec: []byte{2}, |
| 8932 | }, |
| 8933 | }, |
| 8934 | shouldFail: true, |
| 8935 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8936 | }) |
| 8937 | testCases = append(testCases, testCase{ |
| 8938 | protocol: dtls, |
| 8939 | name: "BadChangeCipherSpec-DTLS-2", |
| 8940 | config: Config{ |
| 8941 | MaxVersion: VersionTLS12, |
| 8942 | Bugs: ProtocolBugs{ |
| 8943 | BadChangeCipherSpec: []byte{1, 1}, |
| 8944 | }, |
| 8945 | }, |
| 8946 | shouldFail: true, |
| 8947 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8948 | }) |
| 8949 | } |
| 8950 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8951 | type perMessageTest struct { |
| 8952 | messageType uint8 |
| 8953 | test testCase |
| 8954 | } |
| 8955 | |
| 8956 | // makePerMessageTests returns a series of test templates which cover each |
| 8957 | // message in the TLS handshake. These may be used with bugs like |
| 8958 | // WrongMessageType to fully test a per-message bug. |
| 8959 | func makePerMessageTests() []perMessageTest { |
| 8960 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8961 | for _, protocol := range []protocol{tls, dtls} { |
| 8962 | var suffix string |
| 8963 | if protocol == dtls { |
| 8964 | suffix = "-DTLS" |
| 8965 | } |
| 8966 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8967 | ret = append(ret, perMessageTest{ |
| 8968 | messageType: typeClientHello, |
| 8969 | test: testCase{ |
| 8970 | protocol: protocol, |
| 8971 | testType: serverTest, |
| 8972 | name: "ClientHello" + suffix, |
| 8973 | config: Config{ |
| 8974 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8975 | }, |
| 8976 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8977 | }) |
| 8978 | |
| 8979 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8980 | ret = append(ret, perMessageTest{ |
| 8981 | messageType: typeHelloVerifyRequest, |
| 8982 | test: testCase{ |
| 8983 | protocol: protocol, |
| 8984 | name: "HelloVerifyRequest" + suffix, |
| 8985 | config: Config{ |
| 8986 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8987 | }, |
| 8988 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8989 | }) |
| 8990 | } |
| 8991 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8992 | ret = append(ret, perMessageTest{ |
| 8993 | messageType: typeServerHello, |
| 8994 | test: testCase{ |
| 8995 | protocol: protocol, |
| 8996 | name: "ServerHello" + suffix, |
| 8997 | config: Config{ |
| 8998 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8999 | }, |
| 9000 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9001 | }) |
| 9002 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9003 | ret = append(ret, perMessageTest{ |
| 9004 | messageType: typeCertificate, |
| 9005 | test: testCase{ |
| 9006 | protocol: protocol, |
| 9007 | name: "ServerCertificate" + suffix, |
| 9008 | config: Config{ |
| 9009 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9010 | }, |
| 9011 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9012 | }) |
| 9013 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9014 | ret = append(ret, perMessageTest{ |
| 9015 | messageType: typeCertificateStatus, |
| 9016 | test: testCase{ |
| 9017 | protocol: protocol, |
| 9018 | name: "CertificateStatus" + suffix, |
| 9019 | config: Config{ |
| 9020 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9021 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9022 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9023 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9024 | }) |
| 9025 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9026 | ret = append(ret, perMessageTest{ |
| 9027 | messageType: typeServerKeyExchange, |
| 9028 | test: testCase{ |
| 9029 | protocol: protocol, |
| 9030 | name: "ServerKeyExchange" + suffix, |
| 9031 | config: Config{ |
| 9032 | MaxVersion: VersionTLS12, |
| 9033 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9034 | }, |
| 9035 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9036 | }) |
| 9037 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9038 | ret = append(ret, perMessageTest{ |
| 9039 | messageType: typeCertificateRequest, |
| 9040 | test: testCase{ |
| 9041 | protocol: protocol, |
| 9042 | name: "CertificateRequest" + suffix, |
| 9043 | config: Config{ |
| 9044 | MaxVersion: VersionTLS12, |
| 9045 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9046 | }, |
| 9047 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9048 | }) |
| 9049 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9050 | ret = append(ret, perMessageTest{ |
| 9051 | messageType: typeServerHelloDone, |
| 9052 | test: testCase{ |
| 9053 | protocol: protocol, |
| 9054 | name: "ServerHelloDone" + suffix, |
| 9055 | config: Config{ |
| 9056 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9057 | }, |
| 9058 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9059 | }) |
| 9060 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9061 | ret = append(ret, perMessageTest{ |
| 9062 | messageType: typeCertificate, |
| 9063 | test: testCase{ |
| 9064 | testType: serverTest, |
| 9065 | protocol: protocol, |
| 9066 | name: "ClientCertificate" + suffix, |
| 9067 | config: Config{ |
| 9068 | Certificates: []Certificate{rsaCertificate}, |
| 9069 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9070 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9071 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9072 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9073 | }) |
| 9074 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9075 | ret = append(ret, perMessageTest{ |
| 9076 | messageType: typeCertificateVerify, |
| 9077 | test: testCase{ |
| 9078 | testType: serverTest, |
| 9079 | protocol: protocol, |
| 9080 | name: "CertificateVerify" + suffix, |
| 9081 | config: Config{ |
| 9082 | Certificates: []Certificate{rsaCertificate}, |
| 9083 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9084 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9085 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9086 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9087 | }) |
| 9088 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9089 | ret = append(ret, perMessageTest{ |
| 9090 | messageType: typeClientKeyExchange, |
| 9091 | test: testCase{ |
| 9092 | testType: serverTest, |
| 9093 | protocol: protocol, |
| 9094 | name: "ClientKeyExchange" + suffix, |
| 9095 | config: Config{ |
| 9096 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9097 | }, |
| 9098 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9099 | }) |
| 9100 | |
| 9101 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9102 | ret = append(ret, perMessageTest{ |
| 9103 | messageType: typeNextProtocol, |
| 9104 | test: testCase{ |
| 9105 | testType: serverTest, |
| 9106 | protocol: protocol, |
| 9107 | name: "NextProtocol" + suffix, |
| 9108 | config: Config{ |
| 9109 | MaxVersion: VersionTLS12, |
| 9110 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9111 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9112 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9113 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9114 | }) |
| 9115 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9116 | ret = append(ret, perMessageTest{ |
| 9117 | messageType: typeChannelID, |
| 9118 | test: testCase{ |
| 9119 | testType: serverTest, |
| 9120 | protocol: protocol, |
| 9121 | name: "ChannelID" + suffix, |
| 9122 | config: Config{ |
| 9123 | MaxVersion: VersionTLS12, |
| 9124 | ChannelID: channelIDKey, |
| 9125 | }, |
| 9126 | flags: []string{ |
| 9127 | "-expect-channel-id", |
| 9128 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9129 | }, |
| 9130 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9131 | }) |
| 9132 | } |
| 9133 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9134 | ret = append(ret, perMessageTest{ |
| 9135 | messageType: typeFinished, |
| 9136 | test: testCase{ |
| 9137 | testType: serverTest, |
| 9138 | protocol: protocol, |
| 9139 | name: "ClientFinished" + suffix, |
| 9140 | config: Config{ |
| 9141 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9142 | }, |
| 9143 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9144 | }) |
| 9145 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9146 | ret = append(ret, perMessageTest{ |
| 9147 | messageType: typeNewSessionTicket, |
| 9148 | test: testCase{ |
| 9149 | protocol: protocol, |
| 9150 | name: "NewSessionTicket" + suffix, |
| 9151 | config: Config{ |
| 9152 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9153 | }, |
| 9154 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9155 | }) |
| 9156 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9157 | ret = append(ret, perMessageTest{ |
| 9158 | messageType: typeFinished, |
| 9159 | test: testCase{ |
| 9160 | protocol: protocol, |
| 9161 | name: "ServerFinished" + suffix, |
| 9162 | config: Config{ |
| 9163 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9164 | }, |
| 9165 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9166 | }) |
| 9167 | |
| 9168 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9169 | |
| 9170 | ret = append(ret, perMessageTest{ |
| 9171 | messageType: typeClientHello, |
| 9172 | test: testCase{ |
| 9173 | testType: serverTest, |
| 9174 | name: "TLS13-ClientHello", |
| 9175 | config: Config{ |
| 9176 | MaxVersion: VersionTLS13, |
| 9177 | }, |
| 9178 | }, |
| 9179 | }) |
| 9180 | |
| 9181 | ret = append(ret, perMessageTest{ |
| 9182 | messageType: typeServerHello, |
| 9183 | test: testCase{ |
| 9184 | name: "TLS13-ServerHello", |
| 9185 | config: Config{ |
| 9186 | MaxVersion: VersionTLS13, |
| 9187 | }, |
| 9188 | }, |
| 9189 | }) |
| 9190 | |
| 9191 | ret = append(ret, perMessageTest{ |
| 9192 | messageType: typeEncryptedExtensions, |
| 9193 | test: testCase{ |
| 9194 | name: "TLS13-EncryptedExtensions", |
| 9195 | config: Config{ |
| 9196 | MaxVersion: VersionTLS13, |
| 9197 | }, |
| 9198 | }, |
| 9199 | }) |
| 9200 | |
| 9201 | ret = append(ret, perMessageTest{ |
| 9202 | messageType: typeCertificateRequest, |
| 9203 | test: testCase{ |
| 9204 | name: "TLS13-CertificateRequest", |
| 9205 | config: Config{ |
| 9206 | MaxVersion: VersionTLS13, |
| 9207 | ClientAuth: RequireAnyClientCert, |
| 9208 | }, |
| 9209 | }, |
| 9210 | }) |
| 9211 | |
| 9212 | ret = append(ret, perMessageTest{ |
| 9213 | messageType: typeCertificate, |
| 9214 | test: testCase{ |
| 9215 | name: "TLS13-ServerCertificate", |
| 9216 | config: Config{ |
| 9217 | MaxVersion: VersionTLS13, |
| 9218 | }, |
| 9219 | }, |
| 9220 | }) |
| 9221 | |
| 9222 | ret = append(ret, perMessageTest{ |
| 9223 | messageType: typeCertificateVerify, |
| 9224 | test: testCase{ |
| 9225 | name: "TLS13-ServerCertificateVerify", |
| 9226 | config: Config{ |
| 9227 | MaxVersion: VersionTLS13, |
| 9228 | }, |
| 9229 | }, |
| 9230 | }) |
| 9231 | |
| 9232 | ret = append(ret, perMessageTest{ |
| 9233 | messageType: typeFinished, |
| 9234 | test: testCase{ |
| 9235 | name: "TLS13-ServerFinished", |
| 9236 | config: Config{ |
| 9237 | MaxVersion: VersionTLS13, |
| 9238 | }, |
| 9239 | }, |
| 9240 | }) |
| 9241 | |
| 9242 | ret = append(ret, perMessageTest{ |
| 9243 | messageType: typeCertificate, |
| 9244 | test: testCase{ |
| 9245 | testType: serverTest, |
| 9246 | name: "TLS13-ClientCertificate", |
| 9247 | config: Config{ |
| 9248 | Certificates: []Certificate{rsaCertificate}, |
| 9249 | MaxVersion: VersionTLS13, |
| 9250 | }, |
| 9251 | flags: []string{"-require-any-client-certificate"}, |
| 9252 | }, |
| 9253 | }) |
| 9254 | |
| 9255 | ret = append(ret, perMessageTest{ |
| 9256 | messageType: typeCertificateVerify, |
| 9257 | test: testCase{ |
| 9258 | testType: serverTest, |
| 9259 | name: "TLS13-ClientCertificateVerify", |
| 9260 | config: Config{ |
| 9261 | Certificates: []Certificate{rsaCertificate}, |
| 9262 | MaxVersion: VersionTLS13, |
| 9263 | }, |
| 9264 | flags: []string{"-require-any-client-certificate"}, |
| 9265 | }, |
| 9266 | }) |
| 9267 | |
| 9268 | ret = append(ret, perMessageTest{ |
| 9269 | messageType: typeFinished, |
| 9270 | test: testCase{ |
| 9271 | testType: serverTest, |
| 9272 | name: "TLS13-ClientFinished", |
| 9273 | config: Config{ |
| 9274 | MaxVersion: VersionTLS13, |
| 9275 | }, |
| 9276 | }, |
| 9277 | }) |
| 9278 | |
| 9279 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9280 | } |
| 9281 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9282 | func addWrongMessageTypeTests() { |
| 9283 | for _, t := range makePerMessageTests() { |
| 9284 | t.test.name = "WrongMessageType-" + t.test.name |
| 9285 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 9286 | t.test.shouldFail = true |
| 9287 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 9288 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9289 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9290 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9291 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9292 | // an unencrypted alert while the server expects |
| 9293 | // encryption, so the alert is not readable by runner. |
| 9294 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9295 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9296 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9297 | testCases = append(testCases, t.test) |
| 9298 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9299 | } |
| 9300 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9301 | func addTrailingMessageDataTests() { |
| 9302 | for _, t := range makePerMessageTests() { |
| 9303 | t.test.name = "TrailingMessageData-" + t.test.name |
| 9304 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 9305 | t.test.shouldFail = true |
| 9306 | t.test.expectedError = ":DECODE_ERROR:" |
| 9307 | t.test.expectedLocalError = "remote error: error decoding message" |
| 9308 | |
| 9309 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9310 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9311 | // an unencrypted alert while the server expects |
| 9312 | // encryption, so the alert is not readable by runner. |
| 9313 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9314 | } |
| 9315 | |
| 9316 | if t.messageType == typeFinished { |
| 9317 | // Bad Finished messages read as the verify data having |
| 9318 | // the wrong length. |
| 9319 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 9320 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 9321 | } |
| 9322 | |
| 9323 | testCases = append(testCases, t.test) |
| 9324 | } |
| 9325 | } |
| 9326 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9327 | func addTLS13HandshakeTests() { |
| 9328 | testCases = append(testCases, testCase{ |
| 9329 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9330 | name: "NegotiatePSKResumption-TLS13", |
| 9331 | config: Config{ |
| 9332 | MaxVersion: VersionTLS13, |
| 9333 | Bugs: ProtocolBugs{ |
| 9334 | NegotiatePSKResumption: true, |
| 9335 | }, |
| 9336 | }, |
| 9337 | resumeSession: true, |
| 9338 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9339 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9340 | }) |
| 9341 | |
| 9342 | testCases = append(testCases, testCase{ |
| 9343 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9344 | name: "MissingKeyShare-Client", |
| 9345 | config: Config{ |
| 9346 | MaxVersion: VersionTLS13, |
| 9347 | Bugs: ProtocolBugs{ |
| 9348 | MissingKeyShare: true, |
| 9349 | }, |
| 9350 | }, |
| 9351 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9352 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9353 | }) |
| 9354 | |
| 9355 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9356 | testType: serverTest, |
| 9357 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9358 | config: Config{ |
| 9359 | MaxVersion: VersionTLS13, |
| 9360 | Bugs: ProtocolBugs{ |
| 9361 | MissingKeyShare: true, |
| 9362 | }, |
| 9363 | }, |
| 9364 | shouldFail: true, |
| 9365 | expectedError: ":MISSING_KEY_SHARE:", |
| 9366 | }) |
| 9367 | |
| 9368 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9369 | testType: serverTest, |
| 9370 | name: "DuplicateKeyShares", |
| 9371 | config: Config{ |
| 9372 | MaxVersion: VersionTLS13, |
| 9373 | Bugs: ProtocolBugs{ |
| 9374 | DuplicateKeyShares: true, |
| 9375 | }, |
| 9376 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9377 | shouldFail: true, |
| 9378 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9379 | }) |
| 9380 | |
| 9381 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9382 | testType: serverTest, |
| 9383 | name: "SkipEarlyData", |
| 9384 | config: Config{ |
| 9385 | MaxVersion: VersionTLS13, |
| 9386 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9387 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9388 | }, |
| 9389 | }, |
| 9390 | }) |
| 9391 | |
| 9392 | testCases = append(testCases, testCase{ |
| 9393 | testType: serverTest, |
| 9394 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9395 | config: Config{ |
| 9396 | MaxVersion: VersionTLS13, |
| 9397 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9398 | SendFakeEarlyDataLength: 4, |
| 9399 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9400 | }, |
| 9401 | }, |
| 9402 | shouldFail: true, |
| 9403 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9404 | }) |
| 9405 | |
| 9406 | testCases = append(testCases, testCase{ |
| 9407 | testType: serverTest, |
| 9408 | name: "SkipEarlyData-TooMuchData", |
| 9409 | config: Config{ |
| 9410 | MaxVersion: VersionTLS13, |
| 9411 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9412 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9413 | }, |
| 9414 | }, |
| 9415 | shouldFail: true, |
| 9416 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9417 | }) |
| 9418 | |
| 9419 | testCases = append(testCases, testCase{ |
| 9420 | testType: serverTest, |
| 9421 | name: "SkipEarlyData-Interleaved", |
| 9422 | config: Config{ |
| 9423 | MaxVersion: VersionTLS13, |
| 9424 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9425 | SendFakeEarlyDataLength: 4, |
| 9426 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9427 | }, |
| 9428 | }, |
| 9429 | shouldFail: true, |
| 9430 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9431 | }) |
| 9432 | |
| 9433 | testCases = append(testCases, testCase{ |
| 9434 | testType: serverTest, |
| 9435 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 9436 | config: Config{ |
| 9437 | MaxVersion: VersionTLS13, |
| 9438 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9439 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9440 | }, |
| 9441 | }, |
| 9442 | shouldFail: true, |
| 9443 | expectedError: ":UNEXPECTED_RECORD:", |
| 9444 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9445 | }) |
| 9446 | |
| 9447 | testCases = append(testCases, testCase{ |
| 9448 | testType: serverTest, |
| 9449 | name: "SkipEarlyData-HRR", |
| 9450 | config: Config{ |
| 9451 | MaxVersion: VersionTLS13, |
| 9452 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9453 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9454 | }, |
| 9455 | DefaultCurves: []CurveID{}, |
| 9456 | }, |
| 9457 | }) |
| 9458 | |
| 9459 | testCases = append(testCases, testCase{ |
| 9460 | testType: serverTest, |
| 9461 | name: "SkipEarlyData-HRR-Interleaved", |
| 9462 | config: Config{ |
| 9463 | MaxVersion: VersionTLS13, |
| 9464 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9465 | SendFakeEarlyDataLength: 4, |
| 9466 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9467 | }, |
| 9468 | DefaultCurves: []CurveID{}, |
| 9469 | }, |
| 9470 | shouldFail: true, |
| 9471 | expectedError: ":UNEXPECTED_RECORD:", |
| 9472 | }) |
| 9473 | |
| 9474 | testCases = append(testCases, testCase{ |
| 9475 | testType: serverTest, |
| 9476 | name: "SkipEarlyData-HRR-TooMuchData", |
| 9477 | config: Config{ |
| 9478 | MaxVersion: VersionTLS13, |
| 9479 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9480 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9481 | }, |
| 9482 | DefaultCurves: []CurveID{}, |
| 9483 | }, |
| 9484 | shouldFail: true, |
| 9485 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9486 | }) |
| 9487 | |
| 9488 | // Test that skipping early data looking for cleartext correctly |
| 9489 | // processes an alert record. |
| 9490 | testCases = append(testCases, testCase{ |
| 9491 | testType: serverTest, |
| 9492 | name: "SkipEarlyData-HRR-FatalAlert", |
| 9493 | config: Config{ |
| 9494 | MaxVersion: VersionTLS13, |
| 9495 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9496 | SendEarlyAlert: true, |
| 9497 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9498 | }, |
| 9499 | DefaultCurves: []CurveID{}, |
| 9500 | }, |
| 9501 | shouldFail: true, |
| 9502 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 9503 | }) |
| 9504 | |
| 9505 | testCases = append(testCases, testCase{ |
| 9506 | testType: serverTest, |
| 9507 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 9508 | config: Config{ |
| 9509 | MaxVersion: VersionTLS13, |
| 9510 | Bugs: ProtocolBugs{ |
| 9511 | SendEarlyDataOnSecondClientHello: true, |
| 9512 | }, |
| 9513 | DefaultCurves: []CurveID{}, |
| 9514 | }, |
| 9515 | shouldFail: true, |
| 9516 | expectedLocalError: "remote error: bad record MAC", |
| 9517 | }) |
| 9518 | |
| 9519 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9520 | testType: clientTest, |
| 9521 | name: "EmptyEncryptedExtensions", |
| 9522 | config: Config{ |
| 9523 | MaxVersion: VersionTLS13, |
| 9524 | Bugs: ProtocolBugs{ |
| 9525 | EmptyEncryptedExtensions: true, |
| 9526 | }, |
| 9527 | }, |
| 9528 | shouldFail: true, |
| 9529 | expectedLocalError: "remote error: error decoding message", |
| 9530 | }) |
| 9531 | |
| 9532 | testCases = append(testCases, testCase{ |
| 9533 | testType: clientTest, |
| 9534 | name: "EncryptedExtensionsWithKeyShare", |
| 9535 | config: Config{ |
| 9536 | MaxVersion: VersionTLS13, |
| 9537 | Bugs: ProtocolBugs{ |
| 9538 | EncryptedExtensionsWithKeyShare: true, |
| 9539 | }, |
| 9540 | }, |
| 9541 | shouldFail: true, |
| 9542 | expectedLocalError: "remote error: unsupported extension", |
| 9543 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9544 | |
| 9545 | testCases = append(testCases, testCase{ |
| 9546 | testType: serverTest, |
| 9547 | name: "SendHelloRetryRequest", |
| 9548 | config: Config{ |
| 9549 | MaxVersion: VersionTLS13, |
| 9550 | // Require a HelloRetryRequest for every curve. |
| 9551 | DefaultCurves: []CurveID{}, |
| 9552 | }, |
| 9553 | expectedCurveID: CurveX25519, |
| 9554 | }) |
| 9555 | |
| 9556 | testCases = append(testCases, testCase{ |
| 9557 | testType: serverTest, |
| 9558 | name: "SendHelloRetryRequest-2", |
| 9559 | config: Config{ |
| 9560 | MaxVersion: VersionTLS13, |
| 9561 | DefaultCurves: []CurveID{CurveP384}, |
| 9562 | }, |
| 9563 | // Although the ClientHello did not predict our preferred curve, |
| 9564 | // we always select it whether it is predicted or not. |
| 9565 | expectedCurveID: CurveX25519, |
| 9566 | }) |
| 9567 | |
| 9568 | testCases = append(testCases, testCase{ |
| 9569 | name: "UnknownCurve-HelloRetryRequest", |
| 9570 | config: Config{ |
| 9571 | MaxVersion: VersionTLS13, |
| 9572 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9573 | CurvePreferences: []CurveID{CurveP384}, |
| 9574 | Bugs: ProtocolBugs{ |
| 9575 | SendHelloRetryRequestCurve: bogusCurve, |
| 9576 | }, |
| 9577 | }, |
| 9578 | shouldFail: true, |
| 9579 | expectedError: ":WRONG_CURVE:", |
| 9580 | }) |
| 9581 | |
| 9582 | testCases = append(testCases, testCase{ |
| 9583 | name: "DisabledCurve-HelloRetryRequest", |
| 9584 | config: Config{ |
| 9585 | MaxVersion: VersionTLS13, |
| 9586 | CurvePreferences: []CurveID{CurveP256}, |
| 9587 | Bugs: ProtocolBugs{ |
| 9588 | IgnorePeerCurvePreferences: true, |
| 9589 | }, |
| 9590 | }, |
| 9591 | flags: []string{"-p384-only"}, |
| 9592 | shouldFail: true, |
| 9593 | expectedError: ":WRONG_CURVE:", |
| 9594 | }) |
| 9595 | |
| 9596 | testCases = append(testCases, testCase{ |
| 9597 | name: "UnnecessaryHelloRetryRequest", |
| 9598 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9599 | MaxVersion: VersionTLS13, |
| 9600 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9601 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9602 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9603 | }, |
| 9604 | }, |
| 9605 | shouldFail: true, |
| 9606 | expectedError: ":WRONG_CURVE:", |
| 9607 | }) |
| 9608 | |
| 9609 | testCases = append(testCases, testCase{ |
| 9610 | name: "SecondHelloRetryRequest", |
| 9611 | config: Config{ |
| 9612 | MaxVersion: VersionTLS13, |
| 9613 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9614 | CurvePreferences: []CurveID{CurveP384}, |
| 9615 | Bugs: ProtocolBugs{ |
| 9616 | SecondHelloRetryRequest: true, |
| 9617 | }, |
| 9618 | }, |
| 9619 | shouldFail: true, |
| 9620 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9621 | }) |
| 9622 | |
| 9623 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9624 | name: "HelloRetryRequest-Empty", |
| 9625 | config: Config{ |
| 9626 | MaxVersion: VersionTLS13, |
| 9627 | Bugs: ProtocolBugs{ |
| 9628 | AlwaysSendHelloRetryRequest: true, |
| 9629 | }, |
| 9630 | }, |
| 9631 | shouldFail: true, |
| 9632 | expectedError: ":DECODE_ERROR:", |
| 9633 | }) |
| 9634 | |
| 9635 | testCases = append(testCases, testCase{ |
| 9636 | name: "HelloRetryRequest-DuplicateCurve", |
| 9637 | config: Config{ |
| 9638 | MaxVersion: VersionTLS13, |
| 9639 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9640 | // configuration. Assert this ExpectMissingKeyShare. |
| 9641 | CurvePreferences: []CurveID{CurveP384}, |
| 9642 | Bugs: ProtocolBugs{ |
| 9643 | ExpectMissingKeyShare: true, |
| 9644 | DuplicateHelloRetryRequestExtensions: true, |
| 9645 | }, |
| 9646 | }, |
| 9647 | shouldFail: true, |
| 9648 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9649 | expectedLocalError: "remote error: illegal parameter", |
| 9650 | }) |
| 9651 | |
| 9652 | testCases = append(testCases, testCase{ |
| 9653 | name: "HelloRetryRequest-Cookie", |
| 9654 | config: Config{ |
| 9655 | MaxVersion: VersionTLS13, |
| 9656 | Bugs: ProtocolBugs{ |
| 9657 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9658 | }, |
| 9659 | }, |
| 9660 | }) |
| 9661 | |
| 9662 | testCases = append(testCases, testCase{ |
| 9663 | name: "HelloRetryRequest-DuplicateCookie", |
| 9664 | config: Config{ |
| 9665 | MaxVersion: VersionTLS13, |
| 9666 | Bugs: ProtocolBugs{ |
| 9667 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9668 | DuplicateHelloRetryRequestExtensions: true, |
| 9669 | }, |
| 9670 | }, |
| 9671 | shouldFail: true, |
| 9672 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9673 | expectedLocalError: "remote error: illegal parameter", |
| 9674 | }) |
| 9675 | |
| 9676 | testCases = append(testCases, testCase{ |
| 9677 | name: "HelloRetryRequest-EmptyCookie", |
| 9678 | config: Config{ |
| 9679 | MaxVersion: VersionTLS13, |
| 9680 | Bugs: ProtocolBugs{ |
| 9681 | SendHelloRetryRequestCookie: []byte{}, |
| 9682 | }, |
| 9683 | }, |
| 9684 | shouldFail: true, |
| 9685 | expectedError: ":DECODE_ERROR:", |
| 9686 | }) |
| 9687 | |
| 9688 | testCases = append(testCases, testCase{ |
| 9689 | name: "HelloRetryRequest-Cookie-Curve", |
| 9690 | config: Config{ |
| 9691 | MaxVersion: VersionTLS13, |
| 9692 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9693 | CurvePreferences: []CurveID{CurveP384}, |
| 9694 | Bugs: ProtocolBugs{ |
| 9695 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9696 | ExpectMissingKeyShare: true, |
| 9697 | }, |
| 9698 | }, |
| 9699 | }) |
| 9700 | |
| 9701 | testCases = append(testCases, testCase{ |
| 9702 | name: "HelloRetryRequest-Unknown", |
| 9703 | config: Config{ |
| 9704 | MaxVersion: VersionTLS13, |
| 9705 | Bugs: ProtocolBugs{ |
| 9706 | CustomHelloRetryRequestExtension: "extension", |
| 9707 | }, |
| 9708 | }, |
| 9709 | shouldFail: true, |
| 9710 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9711 | expectedLocalError: "remote error: unsupported extension", |
| 9712 | }) |
| 9713 | |
| 9714 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9715 | testType: serverTest, |
| 9716 | name: "SecondClientHelloMissingKeyShare", |
| 9717 | config: Config{ |
| 9718 | MaxVersion: VersionTLS13, |
| 9719 | DefaultCurves: []CurveID{}, |
| 9720 | Bugs: ProtocolBugs{ |
| 9721 | SecondClientHelloMissingKeyShare: true, |
| 9722 | }, |
| 9723 | }, |
| 9724 | shouldFail: true, |
| 9725 | expectedError: ":MISSING_KEY_SHARE:", |
| 9726 | }) |
| 9727 | |
| 9728 | testCases = append(testCases, testCase{ |
| 9729 | testType: serverTest, |
| 9730 | name: "SecondClientHelloWrongCurve", |
| 9731 | config: Config{ |
| 9732 | MaxVersion: VersionTLS13, |
| 9733 | DefaultCurves: []CurveID{}, |
| 9734 | Bugs: ProtocolBugs{ |
| 9735 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9736 | }, |
| 9737 | }, |
| 9738 | shouldFail: true, |
| 9739 | expectedError: ":WRONG_CURVE:", |
| 9740 | }) |
| 9741 | |
| 9742 | testCases = append(testCases, testCase{ |
| 9743 | name: "HelloRetryRequestVersionMismatch", |
| 9744 | config: Config{ |
| 9745 | MaxVersion: VersionTLS13, |
| 9746 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9747 | CurvePreferences: []CurveID{CurveP384}, |
| 9748 | Bugs: ProtocolBugs{ |
| 9749 | SendServerHelloVersion: 0x0305, |
| 9750 | }, |
| 9751 | }, |
| 9752 | shouldFail: true, |
| 9753 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9754 | }) |
| 9755 | |
| 9756 | testCases = append(testCases, testCase{ |
| 9757 | name: "HelloRetryRequestCurveMismatch", |
| 9758 | config: Config{ |
| 9759 | MaxVersion: VersionTLS13, |
| 9760 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9761 | CurvePreferences: []CurveID{CurveP384}, |
| 9762 | Bugs: ProtocolBugs{ |
| 9763 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9764 | SendHelloRetryRequestCurve: CurveP384, |
| 9765 | // But send P-256 in the ServerHello. |
| 9766 | SendCurve: CurveP256, |
| 9767 | }, |
| 9768 | }, |
| 9769 | shouldFail: true, |
| 9770 | expectedError: ":WRONG_CURVE:", |
| 9771 | }) |
| 9772 | |
| 9773 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9774 | // without sending it. |
| 9775 | testCases = append(testCases, testCase{ |
| 9776 | name: "SkipHelloRetryRequest", |
| 9777 | config: Config{ |
| 9778 | MaxVersion: VersionTLS13, |
| 9779 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9780 | CurvePreferences: []CurveID{CurveP384}, |
| 9781 | Bugs: ProtocolBugs{ |
| 9782 | SkipHelloRetryRequest: true, |
| 9783 | }, |
| 9784 | }, |
| 9785 | shouldFail: true, |
| 9786 | expectedError: ":WRONG_CURVE:", |
| 9787 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9788 | |
| 9789 | testCases = append(testCases, testCase{ |
| 9790 | name: "TLS13-RequestContextInHandshake", |
| 9791 | config: Config{ |
| 9792 | MaxVersion: VersionTLS13, |
| 9793 | MinVersion: VersionTLS13, |
| 9794 | ClientAuth: RequireAnyClientCert, |
| 9795 | Bugs: ProtocolBugs{ |
| 9796 | SendRequestContext: []byte("request context"), |
| 9797 | }, |
| 9798 | }, |
| 9799 | flags: []string{ |
| 9800 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9801 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9802 | }, |
| 9803 | shouldFail: true, |
| 9804 | expectedError: ":DECODE_ERROR:", |
| 9805 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9806 | |
| 9807 | testCases = append(testCases, testCase{ |
| 9808 | testType: serverTest, |
| 9809 | name: "TLS13-TrailingKeyShareData", |
| 9810 | config: Config{ |
| 9811 | MaxVersion: VersionTLS13, |
| 9812 | Bugs: ProtocolBugs{ |
| 9813 | TrailingKeyShareData: true, |
| 9814 | }, |
| 9815 | }, |
| 9816 | shouldFail: true, |
| 9817 | expectedError: ":DECODE_ERROR:", |
| 9818 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9819 | |
| 9820 | testCases = append(testCases, testCase{ |
| 9821 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9822 | config: Config{ |
| 9823 | MaxVersion: VersionTLS13, |
| 9824 | Bugs: ProtocolBugs{ |
| 9825 | AlwaysSelectPSKIdentity: true, |
| 9826 | }, |
| 9827 | }, |
| 9828 | shouldFail: true, |
| 9829 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9830 | }) |
| 9831 | |
| 9832 | testCases = append(testCases, testCase{ |
| 9833 | name: "TLS13-InvalidPSKIdentity", |
| 9834 | config: Config{ |
| 9835 | MaxVersion: VersionTLS13, |
| 9836 | Bugs: ProtocolBugs{ |
| 9837 | SelectPSKIdentityOnResume: 1, |
| 9838 | }, |
| 9839 | }, |
| 9840 | resumeSession: true, |
| 9841 | shouldFail: true, |
| 9842 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9843 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9844 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9845 | testCases = append(testCases, testCase{ |
| 9846 | testType: serverTest, |
| 9847 | name: "TLS13-ExtraPSKIdentity", |
| 9848 | config: Config{ |
| 9849 | MaxVersion: VersionTLS13, |
| 9850 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 9851 | ExtraPSKIdentity: true, |
| 9852 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9853 | }, |
| 9854 | }, |
| 9855 | resumeSession: true, |
| 9856 | }) |
| 9857 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9858 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9859 | testCases = append(testCases, testCase{ |
| 9860 | name: "TLS13-CustomTicketExtension", |
| 9861 | config: Config{ |
| 9862 | MaxVersion: VersionTLS13, |
| 9863 | Bugs: ProtocolBugs{ |
| 9864 | CustomTicketExtension: "1234", |
| 9865 | }, |
| 9866 | }, |
| 9867 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9868 | } |
| 9869 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9870 | func addTLS13CipherPreferenceTests() { |
| 9871 | // Test that client preference is honored if the shim has AES hardware |
| 9872 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9873 | testCases = append(testCases, testCase{ |
| 9874 | testType: serverTest, |
| 9875 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9876 | config: Config{ |
| 9877 | MaxVersion: VersionTLS13, |
| 9878 | CipherSuites: []uint16{ |
| 9879 | TLS_CHACHA20_POLY1305_SHA256, |
| 9880 | TLS_AES_128_GCM_SHA256, |
| 9881 | }, |
| 9882 | }, |
| 9883 | flags: []string{ |
| 9884 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9885 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9886 | }, |
| 9887 | }) |
| 9888 | |
| 9889 | testCases = append(testCases, testCase{ |
| 9890 | testType: serverTest, |
| 9891 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9892 | config: Config{ |
| 9893 | MaxVersion: VersionTLS13, |
| 9894 | CipherSuites: []uint16{ |
| 9895 | TLS_AES_128_GCM_SHA256, |
| 9896 | TLS_CHACHA20_POLY1305_SHA256, |
| 9897 | }, |
| 9898 | }, |
| 9899 | flags: []string{ |
| 9900 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9901 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9902 | }, |
| 9903 | }) |
| 9904 | |
| 9905 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9906 | // whether it has AES hardware. |
| 9907 | testCases = append(testCases, testCase{ |
| 9908 | name: "TLS13-CipherPreference-Client", |
| 9909 | config: Config{ |
| 9910 | MaxVersion: VersionTLS13, |
| 9911 | // Use the client cipher order. (This is the default but |
| 9912 | // is listed to be explicit.) |
| 9913 | PreferServerCipherSuites: false, |
| 9914 | }, |
| 9915 | flags: []string{ |
| 9916 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9917 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9918 | }, |
| 9919 | }) |
| 9920 | } |
| 9921 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9922 | func addPeekTests() { |
| 9923 | // Test SSL_peek works, including on empty records. |
| 9924 | testCases = append(testCases, testCase{ |
| 9925 | name: "Peek-Basic", |
| 9926 | sendEmptyRecords: 1, |
| 9927 | flags: []string{"-peek-then-read"}, |
| 9928 | }) |
| 9929 | |
| 9930 | // Test SSL_peek can drive the initial handshake. |
| 9931 | testCases = append(testCases, testCase{ |
| 9932 | name: "Peek-ImplicitHandshake", |
| 9933 | flags: []string{ |
| 9934 | "-peek-then-read", |
| 9935 | "-implicit-handshake", |
| 9936 | }, |
| 9937 | }) |
| 9938 | |
| 9939 | // Test SSL_peek can discover and drive a renegotiation. |
| 9940 | testCases = append(testCases, testCase{ |
| 9941 | name: "Peek-Renegotiate", |
| 9942 | config: Config{ |
| 9943 | MaxVersion: VersionTLS12, |
| 9944 | }, |
| 9945 | renegotiate: 1, |
| 9946 | flags: []string{ |
| 9947 | "-peek-then-read", |
| 9948 | "-renegotiate-freely", |
| 9949 | "-expect-total-renegotiations", "1", |
| 9950 | }, |
| 9951 | }) |
| 9952 | |
| 9953 | // Test SSL_peek can discover a close_notify. |
| 9954 | testCases = append(testCases, testCase{ |
| 9955 | name: "Peek-Shutdown", |
| 9956 | config: Config{ |
| 9957 | Bugs: ProtocolBugs{ |
| 9958 | ExpectCloseNotify: true, |
| 9959 | }, |
| 9960 | }, |
| 9961 | flags: []string{ |
| 9962 | "-peek-then-read", |
| 9963 | "-check-close-notify", |
| 9964 | }, |
| 9965 | }) |
| 9966 | |
| 9967 | // Test SSL_peek can discover an alert. |
| 9968 | testCases = append(testCases, testCase{ |
| 9969 | name: "Peek-Alert", |
| 9970 | config: Config{ |
| 9971 | Bugs: ProtocolBugs{ |
| 9972 | SendSpuriousAlert: alertRecordOverflow, |
| 9973 | }, |
| 9974 | }, |
| 9975 | flags: []string{"-peek-then-read"}, |
| 9976 | shouldFail: true, |
| 9977 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9978 | }) |
| 9979 | |
| 9980 | // Test SSL_peek can handle KeyUpdate. |
| 9981 | testCases = append(testCases, testCase{ |
| 9982 | name: "Peek-KeyUpdate", |
| 9983 | config: Config{ |
| 9984 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9985 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9986 | sendKeyUpdates: 1, |
| 9987 | keyUpdateRequest: keyUpdateNotRequested, |
| 9988 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9989 | }) |
| 9990 | } |
| 9991 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9992 | func addRecordVersionTests() { |
| 9993 | for _, ver := range tlsVersions { |
| 9994 | // Test that the record version is enforced. |
| 9995 | testCases = append(testCases, testCase{ |
| 9996 | name: "CheckRecordVersion-" + ver.name, |
| 9997 | config: Config{ |
| 9998 | MinVersion: ver.version, |
| 9999 | MaxVersion: ver.version, |
| 10000 | Bugs: ProtocolBugs{ |
| 10001 | SendRecordVersion: 0x03ff, |
| 10002 | }, |
| 10003 | }, |
| 10004 | shouldFail: true, |
| 10005 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10006 | }) |
| 10007 | |
| 10008 | // Test that the ClientHello may use any record version, for |
| 10009 | // compatibility reasons. |
| 10010 | testCases = append(testCases, testCase{ |
| 10011 | testType: serverTest, |
| 10012 | name: "LooseInitialRecordVersion-" + ver.name, |
| 10013 | config: Config{ |
| 10014 | MinVersion: ver.version, |
| 10015 | MaxVersion: ver.version, |
| 10016 | Bugs: ProtocolBugs{ |
| 10017 | SendInitialRecordVersion: 0x03ff, |
| 10018 | }, |
| 10019 | }, |
| 10020 | }) |
| 10021 | |
| 10022 | // Test that garbage ClientHello record versions are rejected. |
| 10023 | testCases = append(testCases, testCase{ |
| 10024 | testType: serverTest, |
| 10025 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 10026 | config: Config{ |
| 10027 | MinVersion: ver.version, |
| 10028 | MaxVersion: ver.version, |
| 10029 | Bugs: ProtocolBugs{ |
| 10030 | SendInitialRecordVersion: 0xffff, |
| 10031 | }, |
| 10032 | }, |
| 10033 | shouldFail: true, |
| 10034 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10035 | }) |
| 10036 | } |
| 10037 | } |
| 10038 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10039 | func addCertificateTests() { |
| 10040 | // Test that a certificate chain with intermediate may be sent and |
| 10041 | // received as both client and server. |
| 10042 | for _, ver := range tlsVersions { |
| 10043 | testCases = append(testCases, testCase{ |
| 10044 | testType: clientTest, |
| 10045 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 10046 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 10047 | MinVersion: ver.version, |
| 10048 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10049 | Certificates: []Certificate{rsaChainCertificate}, |
| 10050 | ClientAuth: RequireAnyClientCert, |
| 10051 | }, |
| 10052 | expectPeerCertificate: &rsaChainCertificate, |
| 10053 | flags: []string{ |
| 10054 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10055 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 10056 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10057 | }, |
| 10058 | }) |
| 10059 | |
| 10060 | testCases = append(testCases, testCase{ |
| 10061 | testType: serverTest, |
| 10062 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 10063 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 10064 | MinVersion: ver.version, |
| 10065 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10066 | Certificates: []Certificate{rsaChainCertificate}, |
| 10067 | }, |
| 10068 | expectPeerCertificate: &rsaChainCertificate, |
| 10069 | flags: []string{ |
| 10070 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10071 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 10072 | "-require-any-client-certificate", |
| 10073 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10074 | }, |
| 10075 | }) |
| 10076 | } |
| 10077 | } |
| 10078 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 10079 | func addRetainOnlySHA256ClientCertTests() { |
| 10080 | for _, ver := range tlsVersions { |
| 10081 | // Test that enabling |
| 10082 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 10083 | // actually requesting a client certificate is a no-op. |
| 10084 | testCases = append(testCases, testCase{ |
| 10085 | testType: serverTest, |
| 10086 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 10087 | config: Config{ |
| 10088 | MinVersion: ver.version, |
| 10089 | MaxVersion: ver.version, |
| 10090 | }, |
| 10091 | flags: []string{ |
| 10092 | "-retain-only-sha256-client-cert-initial", |
| 10093 | "-retain-only-sha256-client-cert-resume", |
| 10094 | }, |
| 10095 | resumeSession: true, |
| 10096 | }) |
| 10097 | |
| 10098 | // Test that when retaining only a SHA-256 certificate is |
| 10099 | // enabled, the hash appears as expected. |
| 10100 | testCases = append(testCases, testCase{ |
| 10101 | testType: serverTest, |
| 10102 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 10103 | config: Config{ |
| 10104 | MinVersion: ver.version, |
| 10105 | MaxVersion: ver.version, |
| 10106 | Certificates: []Certificate{rsaCertificate}, |
| 10107 | }, |
| 10108 | flags: []string{ |
| 10109 | "-verify-peer", |
| 10110 | "-retain-only-sha256-client-cert-initial", |
| 10111 | "-retain-only-sha256-client-cert-resume", |
| 10112 | "-expect-sha256-client-cert-initial", |
| 10113 | "-expect-sha256-client-cert-resume", |
| 10114 | }, |
| 10115 | resumeSession: true, |
| 10116 | }) |
| 10117 | |
| 10118 | // Test that when the config changes from on to off, a |
| 10119 | // resumption is rejected because the server now wants the full |
| 10120 | // certificate chain. |
| 10121 | testCases = append(testCases, testCase{ |
| 10122 | testType: serverTest, |
| 10123 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 10124 | config: Config{ |
| 10125 | MinVersion: ver.version, |
| 10126 | MaxVersion: ver.version, |
| 10127 | Certificates: []Certificate{rsaCertificate}, |
| 10128 | }, |
| 10129 | flags: []string{ |
| 10130 | "-verify-peer", |
| 10131 | "-retain-only-sha256-client-cert-initial", |
| 10132 | "-expect-sha256-client-cert-initial", |
| 10133 | }, |
| 10134 | resumeSession: true, |
| 10135 | expectResumeRejected: true, |
| 10136 | }) |
| 10137 | |
| 10138 | // Test that when the config changes from off to on, a |
| 10139 | // resumption is rejected because the server now wants just the |
| 10140 | // hash. |
| 10141 | testCases = append(testCases, testCase{ |
| 10142 | testType: serverTest, |
| 10143 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 10144 | config: Config{ |
| 10145 | MinVersion: ver.version, |
| 10146 | MaxVersion: ver.version, |
| 10147 | Certificates: []Certificate{rsaCertificate}, |
| 10148 | }, |
| 10149 | flags: []string{ |
| 10150 | "-verify-peer", |
| 10151 | "-retain-only-sha256-client-cert-resume", |
| 10152 | "-expect-sha256-client-cert-resume", |
| 10153 | }, |
| 10154 | resumeSession: true, |
| 10155 | expectResumeRejected: true, |
| 10156 | }) |
| 10157 | } |
| 10158 | } |
| 10159 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 10160 | func addECDSAKeyUsageTests() { |
| 10161 | p256 := elliptic.P256() |
| 10162 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 10163 | if err != nil { |
| 10164 | panic(err) |
| 10165 | } |
| 10166 | |
| 10167 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 10168 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 10169 | if err != nil { |
| 10170 | panic(err) |
| 10171 | } |
| 10172 | |
| 10173 | template := x509.Certificate{ |
| 10174 | SerialNumber: serialNumber, |
| 10175 | Subject: pkix.Name{ |
| 10176 | Organization: []string{"Acme Co"}, |
| 10177 | }, |
| 10178 | NotBefore: time.Now(), |
| 10179 | NotAfter: time.Now(), |
| 10180 | |
| 10181 | // An ECC certificate with only the keyAgreement key usgae may |
| 10182 | // be used with ECDH, but not ECDSA. |
| 10183 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 10184 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 10185 | BasicConstraintsValid: true, |
| 10186 | } |
| 10187 | |
| 10188 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 10189 | if err != nil { |
| 10190 | panic(err) |
| 10191 | } |
| 10192 | |
| 10193 | cert := Certificate{ |
| 10194 | Certificate: [][]byte{derBytes}, |
| 10195 | PrivateKey: priv, |
| 10196 | } |
| 10197 | |
| 10198 | for _, ver := range tlsVersions { |
| 10199 | if ver.version < VersionTLS12 { |
| 10200 | continue |
| 10201 | } |
| 10202 | |
| 10203 | testCases = append(testCases, testCase{ |
| 10204 | testType: clientTest, |
| 10205 | name: "ECDSAKeyUsage-" + ver.name, |
| 10206 | config: Config{ |
| 10207 | MinVersion: ver.version, |
| 10208 | MaxVersion: ver.version, |
| 10209 | Certificates: []Certificate{cert}, |
| 10210 | }, |
| 10211 | shouldFail: true, |
| 10212 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 10213 | }) |
| 10214 | } |
| 10215 | } |
| 10216 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 10217 | func addShortHeaderTests() { |
| 10218 | // The short header extension may be negotiated as either client or |
| 10219 | // server. |
| 10220 | testCases = append(testCases, testCase{ |
| 10221 | name: "ShortHeader-Client", |
| 10222 | config: Config{ |
| 10223 | MaxVersion: VersionTLS13, |
| 10224 | Bugs: ProtocolBugs{ |
| 10225 | EnableShortHeader: true, |
| 10226 | }, |
| 10227 | }, |
| 10228 | flags: []string{"-enable-short-header"}, |
| 10229 | expectShortHeader: true, |
| 10230 | }) |
| 10231 | testCases = append(testCases, testCase{ |
| 10232 | testType: serverTest, |
| 10233 | name: "ShortHeader-Server", |
| 10234 | config: Config{ |
| 10235 | MaxVersion: VersionTLS13, |
| 10236 | Bugs: ProtocolBugs{ |
| 10237 | EnableShortHeader: true, |
| 10238 | }, |
| 10239 | }, |
| 10240 | flags: []string{"-enable-short-header"}, |
| 10241 | expectShortHeader: true, |
| 10242 | }) |
| 10243 | |
| 10244 | // If the peer doesn't support it, it will not be negotiated. |
| 10245 | testCases = append(testCases, testCase{ |
| 10246 | name: "ShortHeader-No-Yes-Client", |
| 10247 | config: Config{ |
| 10248 | MaxVersion: VersionTLS13, |
| 10249 | }, |
| 10250 | flags: []string{"-enable-short-header"}, |
| 10251 | }) |
| 10252 | testCases = append(testCases, testCase{ |
| 10253 | testType: serverTest, |
| 10254 | name: "ShortHeader-No-Yes-Server", |
| 10255 | config: Config{ |
| 10256 | MaxVersion: VersionTLS13, |
| 10257 | }, |
| 10258 | flags: []string{"-enable-short-header"}, |
| 10259 | }) |
| 10260 | |
| 10261 | // If we don't support it, it will not be negotiated. |
| 10262 | testCases = append(testCases, testCase{ |
| 10263 | name: "ShortHeader-Yes-No-Client", |
| 10264 | config: Config{ |
| 10265 | MaxVersion: VersionTLS13, |
| 10266 | Bugs: ProtocolBugs{ |
| 10267 | EnableShortHeader: true, |
| 10268 | }, |
| 10269 | }, |
| 10270 | }) |
| 10271 | testCases = append(testCases, testCase{ |
| 10272 | testType: serverTest, |
| 10273 | name: "ShortHeader-Yes-No-Server", |
| 10274 | config: Config{ |
| 10275 | MaxVersion: VersionTLS13, |
| 10276 | Bugs: ProtocolBugs{ |
| 10277 | EnableShortHeader: true, |
| 10278 | }, |
| 10279 | }, |
| 10280 | }) |
| 10281 | |
| 10282 | // It will not be negotiated at TLS 1.2. |
| 10283 | testCases = append(testCases, testCase{ |
| 10284 | name: "ShortHeader-TLS12-Client", |
| 10285 | config: Config{ |
| 10286 | MaxVersion: VersionTLS12, |
| 10287 | Bugs: ProtocolBugs{ |
| 10288 | EnableShortHeader: true, |
| 10289 | }, |
| 10290 | }, |
| 10291 | flags: []string{"-enable-short-header"}, |
| 10292 | }) |
| 10293 | testCases = append(testCases, testCase{ |
| 10294 | testType: serverTest, |
| 10295 | name: "ShortHeader-TLS12-Server", |
| 10296 | config: Config{ |
| 10297 | MaxVersion: VersionTLS12, |
| 10298 | Bugs: ProtocolBugs{ |
| 10299 | EnableShortHeader: true, |
| 10300 | }, |
| 10301 | }, |
| 10302 | flags: []string{"-enable-short-header"}, |
| 10303 | }) |
| 10304 | |
| 10305 | // Servers reject early data and short header sent together. |
| 10306 | testCases = append(testCases, testCase{ |
| 10307 | testType: serverTest, |
| 10308 | name: "ShortHeader-EarlyData", |
| 10309 | config: Config{ |
| 10310 | MaxVersion: VersionTLS13, |
| 10311 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10312 | EnableShortHeader: true, |
| 10313 | SendFakeEarlyDataLength: 1, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 10314 | }, |
| 10315 | }, |
| 10316 | flags: []string{"-enable-short-header"}, |
| 10317 | shouldFail: true, |
| 10318 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10319 | }) |
| 10320 | |
| 10321 | // Clients reject unsolicited short header extensions. |
| 10322 | testCases = append(testCases, testCase{ |
| 10323 | name: "ShortHeader-Unsolicited", |
| 10324 | config: Config{ |
| 10325 | MaxVersion: VersionTLS13, |
| 10326 | Bugs: ProtocolBugs{ |
| 10327 | AlwaysNegotiateShortHeader: true, |
| 10328 | }, |
| 10329 | }, |
| 10330 | shouldFail: true, |
| 10331 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10332 | }) |
| 10333 | testCases = append(testCases, testCase{ |
| 10334 | name: "ShortHeader-Unsolicited-TLS12", |
| 10335 | config: Config{ |
| 10336 | MaxVersion: VersionTLS12, |
| 10337 | Bugs: ProtocolBugs{ |
| 10338 | AlwaysNegotiateShortHeader: true, |
| 10339 | }, |
| 10340 | }, |
| 10341 | shouldFail: true, |
| 10342 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10343 | }) |
| 10344 | |
| 10345 | // The high bit must be checked in short headers. |
| 10346 | testCases = append(testCases, testCase{ |
| 10347 | name: "ShortHeader-ClearShortHeaderBit", |
| 10348 | config: Config{ |
| 10349 | Bugs: ProtocolBugs{ |
| 10350 | EnableShortHeader: true, |
| 10351 | ClearShortHeaderBit: true, |
| 10352 | }, |
| 10353 | }, |
| 10354 | flags: []string{"-enable-short-header"}, |
| 10355 | shouldFail: true, |
| 10356 | expectedError: ":DECODE_ERROR:", |
| 10357 | expectedLocalError: "remote error: error decoding message", |
| 10358 | }) |
| 10359 | } |
| 10360 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10361 | 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] | 10362 | defer wg.Done() |
| 10363 | |
| 10364 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10365 | var err error |
| 10366 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10367 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10368 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 10369 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10370 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10371 | if err != nil { |
| 10372 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 10373 | } |
| 10374 | break |
| 10375 | } |
| 10376 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10377 | } else if *repeatUntilFailure { |
| 10378 | for err == nil { |
| 10379 | statusChan <- statusMsg{test: test, started: true} |
| 10380 | err = runTest(test, shimPath, -1) |
| 10381 | } |
| 10382 | } else { |
| 10383 | statusChan <- statusMsg{test: test, started: true} |
| 10384 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10385 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10386 | statusChan <- statusMsg{test: test, err: err} |
| 10387 | } |
| 10388 | } |
| 10389 | |
| 10390 | type statusMsg struct { |
| 10391 | test *testCase |
| 10392 | started bool |
| 10393 | err error |
| 10394 | } |
| 10395 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10396 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10397 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10398 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10399 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10400 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10401 | if !*pipe { |
| 10402 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 10403 | var erase string |
| 10404 | for i := 0; i < lineLen; i++ { |
| 10405 | erase += "\b \b" |
| 10406 | } |
| 10407 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10408 | } |
| 10409 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10410 | if msg.started { |
| 10411 | started++ |
| 10412 | } else { |
| 10413 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10414 | |
| 10415 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10416 | if msg.err == errUnimplemented { |
| 10417 | if *pipe { |
| 10418 | // Print each test instead of a status line. |
| 10419 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 10420 | } |
| 10421 | unimplemented++ |
| 10422 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 10423 | } else { |
| 10424 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 10425 | failed++ |
| 10426 | testOutput.addResult(msg.test.name, "FAIL") |
| 10427 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10428 | } else { |
| 10429 | if *pipe { |
| 10430 | // Print each test instead of a status line. |
| 10431 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 10432 | } |
| 10433 | testOutput.addResult(msg.test.name, "PASS") |
| 10434 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10435 | } |
| 10436 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10437 | if !*pipe { |
| 10438 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10439 | 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] | 10440 | lineLen = len(line) |
| 10441 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10442 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10443 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10444 | |
| 10445 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10446 | } |
| 10447 | |
| 10448 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10449 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10450 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 10451 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10452 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10453 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10454 | addCipherSuiteTests() |
| 10455 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10456 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 10457 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 10458 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 10459 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 10460 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 10461 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 10462 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 10463 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 10464 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 10465 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 10466 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 10467 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 10468 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 10469 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 10470 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 10471 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 10472 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 10473 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 10474 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 10475 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 10476 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10477 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10478 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10479 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10480 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 10481 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10482 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 10483 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10484 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 10485 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 10486 | addECDSAKeyUsageTests() |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 10487 | addShortHeaderTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10488 | |
| 10489 | var wg sync.WaitGroup |
| 10490 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10491 | statusChan := make(chan statusMsg, *numWorkers) |
| 10492 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10493 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10494 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10495 | if len(*shimConfigFile) != 0 { |
| 10496 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 10497 | if err != nil { |
| 10498 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 10499 | os.Exit(1) |
| 10500 | } |
| 10501 | |
| 10502 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 10503 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 10504 | os.Exit(1) |
| 10505 | } |
| 10506 | } |
| 10507 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10508 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10509 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10510 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10511 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10512 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10513 | } |
| 10514 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10515 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10516 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10517 | matched := true |
| 10518 | if len(*testToRun) != 0 { |
| 10519 | var err error |
| 10520 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 10521 | if err != nil { |
| 10522 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 10523 | os.Exit(1) |
| 10524 | } |
| 10525 | } |
| 10526 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10527 | if !*includeDisabled { |
| 10528 | for pattern := range shimConfig.DisabledTests { |
| 10529 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 10530 | if err != nil { |
| 10531 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 10532 | os.Exit(1) |
| 10533 | } |
| 10534 | |
| 10535 | if isDisabled { |
| 10536 | matched = false |
| 10537 | break |
| 10538 | } |
| 10539 | } |
| 10540 | } |
| 10541 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10542 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10543 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10544 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10545 | |
| 10546 | // Only run one test if repeating until failure. |
| 10547 | if *repeatUntilFailure { |
| 10548 | break |
| 10549 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10550 | } |
| 10551 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10552 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10553 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10554 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10555 | os.Exit(1) |
| 10556 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10557 | |
| 10558 | close(testChan) |
| 10559 | wg.Wait() |
| 10560 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10561 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10562 | |
| 10563 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10564 | |
| 10565 | if *jsonOutput != "" { |
| 10566 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 10567 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 10568 | } |
| 10569 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10570 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10571 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 10572 | os.Exit(1) |
| 10573 | } |
| 10574 | |
| 10575 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10576 | os.Exit(1) |
| 10577 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10578 | } |