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" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 21 | "crypto/x509" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 22 | "encoding/base64" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 23 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 24 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 25 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 26 | "flag" |
| 27 | "fmt" |
| 28 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 29 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 30 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 31 | "net" |
| 32 | "os" |
| 33 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 34 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 35 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 36 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 37 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 38 | "strings" |
| 39 | "sync" |
| 40 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 41 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 42 | ) |
| 43 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 44 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 45 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 46 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 47 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 48 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 49 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 50 | 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.") |
| 51 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 52 | 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] | 53 | 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] | 54 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 55 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 56 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 57 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 58 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 59 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 60 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 61 | 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] | 62 | 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] | 63 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 64 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 65 | 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] | 66 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 67 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 68 | // ShimConfigurations is used with the “json” package and represents a shim |
| 69 | // config file. |
| 70 | type ShimConfiguration struct { |
| 71 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 72 | // The glob pattern is used to exclude tests from being run and the |
| 73 | // freeform string is unparsed but expected to explain why the test is |
| 74 | // disabled. |
| 75 | DisabledTests map[string]string |
| 76 | |
| 77 | // ErrorMap maps from expected error strings to the correct error |
| 78 | // string for the shim in question. For example, it might map |
| 79 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 80 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 81 | ErrorMap map[string]string |
| 82 | } |
| 83 | |
| 84 | var shimConfig ShimConfiguration |
| 85 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 86 | type testCert int |
| 87 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 88 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 89 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 90 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 91 | testCertRSAChain |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 92 | testCertECDSAP256 |
| 93 | testCertECDSAP384 |
| 94 | testCertECDSAP521 |
| 95 | ) |
| 96 | |
| 97 | const ( |
| 98 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 99 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 100 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 101 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 102 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 103 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 104 | ) |
| 105 | |
| 106 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 107 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 108 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 109 | rsaChainKeyFile = "rsa_chain_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 110 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 111 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 112 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 113 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 114 | ) |
| 115 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 116 | var ( |
| 117 | rsaCertificate Certificate |
| 118 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 119 | rsaChainCertificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 120 | ecdsaP256Certificate Certificate |
| 121 | ecdsaP384Certificate Certificate |
| 122 | ecdsaP521Certificate Certificate |
| 123 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 124 | |
| 125 | var testCerts = []struct { |
| 126 | id testCert |
| 127 | certFile, keyFile string |
| 128 | cert *Certificate |
| 129 | }{ |
| 130 | { |
| 131 | id: testCertRSA, |
| 132 | certFile: rsaCertificateFile, |
| 133 | keyFile: rsaKeyFile, |
| 134 | cert: &rsaCertificate, |
| 135 | }, |
| 136 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 137 | id: testCertRSA1024, |
| 138 | certFile: rsa1024CertificateFile, |
| 139 | keyFile: rsa1024KeyFile, |
| 140 | cert: &rsa1024Certificate, |
| 141 | }, |
| 142 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 143 | id: testCertRSAChain, |
| 144 | certFile: rsaChainCertificateFile, |
| 145 | keyFile: rsaChainKeyFile, |
| 146 | cert: &rsaChainCertificate, |
| 147 | }, |
| 148 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 149 | id: testCertECDSAP256, |
| 150 | certFile: ecdsaP256CertificateFile, |
| 151 | keyFile: ecdsaP256KeyFile, |
| 152 | cert: &ecdsaP256Certificate, |
| 153 | }, |
| 154 | { |
| 155 | id: testCertECDSAP384, |
| 156 | certFile: ecdsaP384CertificateFile, |
| 157 | keyFile: ecdsaP384KeyFile, |
| 158 | cert: &ecdsaP384Certificate, |
| 159 | }, |
| 160 | { |
| 161 | id: testCertECDSAP521, |
| 162 | certFile: ecdsaP521CertificateFile, |
| 163 | keyFile: ecdsaP521KeyFile, |
| 164 | cert: &ecdsaP521Certificate, |
| 165 | }, |
| 166 | } |
| 167 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 168 | var channelIDKey *ecdsa.PrivateKey |
| 169 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 170 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 171 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 172 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 173 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 174 | 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] | 175 | 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] | 176 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 177 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 178 | for i := range testCerts { |
| 179 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 180 | if err != nil { |
| 181 | panic(err) |
| 182 | } |
| 183 | cert.OCSPStaple = testOCSPResponse |
| 184 | cert.SignedCertificateTimestampList = testSCTList |
| 185 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 186 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 187 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 188 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 189 | if err != nil { |
| 190 | panic(err) |
| 191 | } |
| 192 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 193 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 194 | panic("bad key type") |
| 195 | } |
| 196 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 197 | if err != nil { |
| 198 | panic(err) |
| 199 | } |
| 200 | if channelIDKey.Curve != elliptic.P256() { |
| 201 | panic("bad curve") |
| 202 | } |
| 203 | |
| 204 | channelIDBytes = make([]byte, 64) |
| 205 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 206 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | } |
| 208 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 209 | func getRunnerCertificate(t testCert) Certificate { |
| 210 | for _, cert := range testCerts { |
| 211 | if cert.id == t { |
| 212 | return *cert.cert |
| 213 | } |
| 214 | } |
| 215 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | } |
| 217 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 218 | func getShimCertificate(t testCert) string { |
| 219 | for _, cert := range testCerts { |
| 220 | if cert.id == t { |
| 221 | return cert.certFile |
| 222 | } |
| 223 | } |
| 224 | panic("Unknown test certificate") |
| 225 | } |
| 226 | |
| 227 | func getShimKey(t testCert) string { |
| 228 | for _, cert := range testCerts { |
| 229 | if cert.id == t { |
| 230 | return cert.keyFile |
| 231 | } |
| 232 | } |
| 233 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 234 | } |
| 235 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 236 | type testType int |
| 237 | |
| 238 | const ( |
| 239 | clientTest testType = iota |
| 240 | serverTest |
| 241 | ) |
| 242 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 243 | type protocol int |
| 244 | |
| 245 | const ( |
| 246 | tls protocol = iota |
| 247 | dtls |
| 248 | ) |
| 249 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 250 | const ( |
| 251 | alpn = 1 |
| 252 | npn = 2 |
| 253 | ) |
| 254 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 255 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 256 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 257 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 258 | name string |
| 259 | config Config |
| 260 | shouldFail bool |
| 261 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 262 | // expectedLocalError, if not empty, contains a substring that must be |
| 263 | // found in the local error. |
| 264 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 265 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 266 | // negotiated. |
| 267 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 268 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 269 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 270 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 271 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 272 | // should be negotiated. |
| 273 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 274 | // expectChannelID controls whether the connection should have |
| 275 | // negotiated a Channel ID with channelIDKey. |
| 276 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 277 | // expectedNextProto controls whether the connection should |
| 278 | // negotiate a next protocol via NPN or ALPN. |
| 279 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 280 | // expectNoNextProto, if true, means that no next protocol should be |
| 281 | // negotiated. |
| 282 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 283 | // expectedNextProtoType, if non-zero, is the expected next |
| 284 | // protocol negotiation mechanism. |
| 285 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 286 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 287 | // should be negotiated. If zero, none should be negotiated. |
| 288 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 289 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 290 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 291 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 292 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 293 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 294 | // algorithm that the peer should have used in the handshake. |
| 295 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 296 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 297 | // have used. |
| 298 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 299 | // messageLen is the length, in bytes, of the test message that will be |
| 300 | // sent. |
| 301 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 302 | // messageCount is the number of test messages that will be sent. |
| 303 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 304 | // certFile is the path to the certificate to use for the server. |
| 305 | certFile string |
| 306 | // keyFile is the path to the private key to use for the server. |
| 307 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 308 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 309 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 310 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 311 | // resumeRenewedSession controls whether a third connection should be |
| 312 | // tested which attempts to resume the second connection's session. |
| 313 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 314 | // expectResumeRejected, if true, specifies that the attempted |
| 315 | // resumption must be rejected by the client. This is only valid for a |
| 316 | // serverTest. |
| 317 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 318 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 319 | // resumption. Unless newSessionsOnResume is set, |
| 320 | // SessionTicketKey, ServerSessionCache, and |
| 321 | // ClientSessionCache are copied from the initial connection's |
| 322 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 323 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 324 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 325 | // use a different session resumption context. |
| 326 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 327 | // noSessionCache, if true, will cause the server to run without a |
| 328 | // session cache. |
| 329 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 330 | // sendPrefix sends a prefix on the socket before actually performing a |
| 331 | // handshake. |
| 332 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 333 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 334 | // message before doing a roundtrip with the runner. |
| 335 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 336 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 337 | // connection immediately after the handshake rather than echoing |
| 338 | // messages from the runner. |
| 339 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 340 | // renegotiate indicates the number of times the connection should be |
| 341 | // renegotiated during the exchange. |
| 342 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 343 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 344 | // HelloRequest when the handshake completes. |
| 345 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 346 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 347 | // switched in just before renegotiation. |
| 348 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 349 | // replayWrites, if true, configures the underlying transport |
| 350 | // to replay every write it makes in DTLS tests. |
| 351 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 352 | // damageFirstWrite, if true, configures the underlying transport to |
| 353 | // damage the final byte of the first application data write. |
| 354 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 355 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 356 | // keying material and verify they match. |
| 357 | exportKeyingMaterial int |
| 358 | exportLabel string |
| 359 | exportContext string |
| 360 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 361 | // flags, if not empty, contains a list of command-line flags that will |
| 362 | // be passed to the shim program. |
| 363 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 364 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 365 | // which will be compared against the expected value. |
| 366 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 367 | // sendEmptyRecords is the number of consecutive empty records to send |
| 368 | // before and after the test message. |
| 369 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 370 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 371 | // before and after the test message. |
| 372 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 373 | // sendKeyUpdates is the number of consecutive key updates to send |
| 374 | // before and after the test message. |
| 375 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 376 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 377 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 378 | // expectMessageDropped, if true, means the test message is expected to |
| 379 | // be dropped by the client rather than echoed back. |
| 380 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 381 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 382 | // is expected to send. |
| 383 | expectPeerCertificate *Certificate |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 386 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 387 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 388 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 389 | if len(data) == 0 { |
| 390 | return |
| 391 | } |
| 392 | |
| 393 | protocol := "tls" |
| 394 | if test.protocol == dtls { |
| 395 | protocol = "dtls" |
| 396 | } |
| 397 | |
| 398 | side := "client" |
| 399 | if test.testType == serverTest { |
| 400 | side = "server" |
| 401 | } |
| 402 | |
| 403 | dir := path.Join(*transcriptDir, protocol, side) |
| 404 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 405 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 406 | return |
| 407 | } |
| 408 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 409 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 410 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 411 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 412 | } |
| 413 | } |
| 414 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 415 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 416 | type timeoutConn struct { |
| 417 | net.Conn |
| 418 | timeout time.Duration |
| 419 | } |
| 420 | |
| 421 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 422 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 423 | return 0, err |
| 424 | } |
| 425 | return t.Conn.Read(b) |
| 426 | } |
| 427 | |
| 428 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 429 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 430 | return 0, err |
| 431 | } |
| 432 | return t.Conn.Write(b) |
| 433 | } |
| 434 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 435 | 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] | 436 | if !test.noSessionCache { |
| 437 | if config.ClientSessionCache == nil { |
| 438 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 439 | } |
| 440 | if config.ServerSessionCache == nil { |
| 441 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 442 | } |
| 443 | } |
| 444 | if test.testType == clientTest { |
| 445 | if len(config.Certificates) == 0 { |
| 446 | config.Certificates = []Certificate{rsaCertificate} |
| 447 | } |
| 448 | } else { |
| 449 | // Supply a ServerName to ensure a constant session cache key, |
| 450 | // rather than falling back to net.Conn.RemoteAddr. |
| 451 | if len(config.ServerName) == 0 { |
| 452 | config.ServerName = "test" |
| 453 | } |
| 454 | } |
| 455 | if *fuzzer { |
| 456 | config.Bugs.NullAllCiphers = true |
| 457 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 458 | if *deterministic { |
| 459 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 460 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 461 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 462 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 463 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 464 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 465 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 466 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 467 | } |
| 468 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 469 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 470 | local, peer := "client", "server" |
| 471 | if test.testType == clientTest { |
| 472 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 473 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 474 | connDebug := &recordingConn{ |
| 475 | Conn: conn, |
| 476 | isDatagram: test.protocol == dtls, |
| 477 | local: local, |
| 478 | peer: peer, |
| 479 | } |
| 480 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | if *flagDebug { |
| 482 | defer connDebug.WriteTo(os.Stdout) |
| 483 | } |
| 484 | if len(*transcriptDir) != 0 { |
| 485 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 486 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 487 | }() |
| 488 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 489 | |
| 490 | if config.Bugs.PacketAdaptor != nil { |
| 491 | config.Bugs.PacketAdaptor.debug = connDebug |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | if test.replayWrites { |
| 496 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 497 | } |
| 498 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 499 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 500 | if test.damageFirstWrite { |
| 501 | connDamage = newDamageAdaptor(conn) |
| 502 | conn = connDamage |
| 503 | } |
| 504 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 505 | if test.sendPrefix != "" { |
| 506 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 507 | return err |
| 508 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 509 | } |
| 510 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 511 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 512 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 513 | if test.protocol == dtls { |
| 514 | tlsConn = DTLSServer(conn, config) |
| 515 | } else { |
| 516 | tlsConn = Server(conn, config) |
| 517 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 518 | } else { |
| 519 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 520 | if test.protocol == dtls { |
| 521 | tlsConn = DTLSClient(conn, config) |
| 522 | } else { |
| 523 | tlsConn = Client(conn, config) |
| 524 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 525 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 526 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 527 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 528 | if err := tlsConn.Handshake(); err != nil { |
| 529 | return err |
| 530 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 531 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 532 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 533 | // expectations struct that can be specified separately for the two |
| 534 | // legs. |
| 535 | expectedVersion := test.expectedVersion |
| 536 | if isResume && test.expectedResumeVersion != 0 { |
| 537 | expectedVersion = test.expectedResumeVersion |
| 538 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 539 | connState := tlsConn.ConnectionState() |
| 540 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 541 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 542 | } |
| 543 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 544 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 545 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 546 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 547 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 548 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 549 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 550 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 551 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 552 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 553 | if channelID == nil { |
| 554 | return fmt.Errorf("no channel ID negotiated") |
| 555 | } |
| 556 | if channelID.Curve != channelIDKey.Curve || |
| 557 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 558 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 559 | return fmt.Errorf("incorrect channel ID") |
| 560 | } |
| 561 | } |
| 562 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 563 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 564 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 565 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 566 | } |
| 567 | } |
| 568 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 569 | if test.expectNoNextProto { |
| 570 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 571 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 572 | } |
| 573 | } |
| 574 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 575 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 576 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 577 | return fmt.Errorf("next proto type mismatch") |
| 578 | } |
| 579 | } |
| 580 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 581 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 582 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 583 | } |
| 584 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 585 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 586 | 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] | 587 | } |
| 588 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 589 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 590 | return fmt.Errorf("SCT list mismatch") |
| 591 | } |
| 592 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 593 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 594 | 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] | 595 | } |
| 596 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 597 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 598 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 599 | } |
| 600 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 601 | if test.expectPeerCertificate != nil { |
| 602 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 603 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 604 | } |
| 605 | for i, cert := range connState.PeerCertificates { |
| 606 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 607 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 612 | if test.exportKeyingMaterial > 0 { |
| 613 | actual := make([]byte, test.exportKeyingMaterial) |
| 614 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 615 | return err |
| 616 | } |
| 617 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 618 | if err != nil { |
| 619 | return err |
| 620 | } |
| 621 | if !bytes.Equal(actual, expected) { |
| 622 | return fmt.Errorf("keying material mismatch") |
| 623 | } |
| 624 | } |
| 625 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 626 | if test.testTLSUnique { |
| 627 | var peersValue [12]byte |
| 628 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 629 | return err |
| 630 | } |
| 631 | expected := tlsConn.ConnectionState().TLSUnique |
| 632 | if !bytes.Equal(peersValue[:], expected) { |
| 633 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 634 | } |
| 635 | } |
| 636 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 637 | if test.shimWritesFirst { |
| 638 | var buf [5]byte |
| 639 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 640 | if err != nil { |
| 641 | return err |
| 642 | } |
| 643 | if string(buf[:]) != "hello" { |
| 644 | return fmt.Errorf("bad initial message") |
| 645 | } |
| 646 | } |
| 647 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 648 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 649 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 650 | return err |
| 651 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 652 | } |
| 653 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 654 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 655 | tlsConn.Write(nil) |
| 656 | } |
| 657 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 658 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 659 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 660 | } |
| 661 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 662 | if test.sendHalfHelloRequest { |
| 663 | tlsConn.SendHalfHelloRequest() |
| 664 | } |
| 665 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 666 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 667 | if test.renegotiateCiphers != nil { |
| 668 | config.CipherSuites = test.renegotiateCiphers |
| 669 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 670 | for i := 0; i < test.renegotiate; i++ { |
| 671 | if err := tlsConn.Renegotiate(); err != nil { |
| 672 | return err |
| 673 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 674 | } |
| 675 | } else if test.renegotiateCiphers != nil { |
| 676 | panic("renegotiateCiphers without renegotiate") |
| 677 | } |
| 678 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 679 | if test.damageFirstWrite { |
| 680 | connDamage.setDamage(true) |
| 681 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 682 | connDamage.setDamage(false) |
| 683 | } |
| 684 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 685 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 686 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 687 | if test.protocol == dtls { |
| 688 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 689 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 690 | // Read until EOF. |
| 691 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 692 | return err |
| 693 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 694 | if messageLen == 0 { |
| 695 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 696 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 697 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 698 | messageCount := test.messageCount |
| 699 | if messageCount == 0 { |
| 700 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 701 | } |
| 702 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 703 | for j := 0; j < messageCount; j++ { |
| 704 | testMessage := make([]byte, messageLen) |
| 705 | for i := range testMessage { |
| 706 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 707 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 708 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 709 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 710 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 711 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 712 | } |
| 713 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 714 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 715 | tlsConn.Write(nil) |
| 716 | } |
| 717 | |
| 718 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 719 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 720 | } |
| 721 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 722 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 723 | // The shim will not respond. |
| 724 | continue |
| 725 | } |
| 726 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 727 | buf := make([]byte, len(testMessage)) |
| 728 | if test.protocol == dtls { |
| 729 | bufTmp := make([]byte, len(buf)+1) |
| 730 | n, err := tlsConn.Read(bufTmp) |
| 731 | if err != nil { |
| 732 | return err |
| 733 | } |
| 734 | if n != len(buf) { |
| 735 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 736 | } |
| 737 | copy(buf, bufTmp) |
| 738 | } else { |
| 739 | _, err := io.ReadFull(tlsConn, buf) |
| 740 | if err != nil { |
| 741 | return err |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | for i, v := range buf { |
| 746 | if v != testMessage[i]^0xff { |
| 747 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 748 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 749 | } |
| 750 | } |
| 751 | |
| 752 | return nil |
| 753 | } |
| 754 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 755 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 756 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 757 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 758 | 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] | 759 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 760 | valgrindArgs = append(valgrindArgs, path) |
| 761 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 762 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 763 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 764 | } |
| 765 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 766 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 767 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 768 | xtermArgs = append(xtermArgs, path) |
| 769 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 770 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 771 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 772 | } |
| 773 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 774 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 775 | xtermArgs := []string{"-e", "lldb", "--"} |
| 776 | xtermArgs = append(xtermArgs, path) |
| 777 | xtermArgs = append(xtermArgs, args...) |
| 778 | |
| 779 | return exec.Command("xterm", xtermArgs...) |
| 780 | } |
| 781 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 782 | var ( |
| 783 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 784 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 785 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 786 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 787 | // accept accepts a connection from listener, unless waitChan signals a process |
| 788 | // exit first. |
| 789 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 790 | type connOrError struct { |
| 791 | conn net.Conn |
| 792 | err error |
| 793 | } |
| 794 | connChan := make(chan connOrError, 1) |
| 795 | go func() { |
| 796 | conn, err := listener.Accept() |
| 797 | connChan <- connOrError{conn, err} |
| 798 | close(connChan) |
| 799 | }() |
| 800 | select { |
| 801 | case result := <-connChan: |
| 802 | return result.conn, result.err |
| 803 | case childErr := <-waitChan: |
| 804 | waitChan <- childErr |
| 805 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 806 | } |
| 807 | } |
| 808 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 809 | func translateExpectedError(errorStr string) string { |
| 810 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 811 | return translated |
| 812 | } |
| 813 | |
| 814 | if *looseErrors { |
| 815 | return "" |
| 816 | } |
| 817 | |
| 818 | return errorStr |
| 819 | } |
| 820 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 821 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 822 | // Help debugging panics on the Go side. |
| 823 | defer func() { |
| 824 | if r := recover(); r != nil { |
| 825 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 826 | panic(r) |
| 827 | } |
| 828 | }() |
| 829 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 830 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 831 | panic("Error expected without shouldFail in " + test.name) |
| 832 | } |
| 833 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 834 | if test.expectResumeRejected && !test.resumeSession { |
| 835 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 836 | } |
| 837 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 838 | for _, ver := range tlsVersions { |
| 839 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 840 | continue |
| 841 | } |
| 842 | |
| 843 | if test.config.MaxVersion != 0 || test.config.MinVersion != 0 || test.expectedVersion != 0 { |
| 844 | continue |
| 845 | } |
| 846 | |
| 847 | 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)) |
| 848 | } |
| 849 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 850 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 851 | if err != nil { |
| 852 | panic(err) |
| 853 | } |
| 854 | defer func() { |
| 855 | if listener != nil { |
| 856 | listener.Close() |
| 857 | } |
| 858 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 859 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 860 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 861 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 862 | flags = append(flags, "-server") |
| 863 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 864 | flags = append(flags, "-key-file") |
| 865 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 866 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 867 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 868 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | flags = append(flags, "-cert-file") |
| 872 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 873 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 874 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 875 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 876 | } |
| 877 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 878 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 879 | if test.protocol == dtls { |
| 880 | flags = append(flags, "-dtls") |
| 881 | } |
| 882 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 883 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 884 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 885 | resumeCount++ |
| 886 | if test.resumeRenewedSession { |
| 887 | resumeCount++ |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | if resumeCount > 0 { |
| 892 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 893 | } |
| 894 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 895 | if test.shimWritesFirst { |
| 896 | flags = append(flags, "-shim-writes-first") |
| 897 | } |
| 898 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 899 | if test.shimShutsDown { |
| 900 | flags = append(flags, "-shim-shuts-down") |
| 901 | } |
| 902 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 903 | if test.exportKeyingMaterial > 0 { |
| 904 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 905 | flags = append(flags, "-export-label", test.exportLabel) |
| 906 | flags = append(flags, "-export-context", test.exportContext) |
| 907 | if test.useExportContext { |
| 908 | flags = append(flags, "-use-export-context") |
| 909 | } |
| 910 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 911 | if test.expectResumeRejected { |
| 912 | flags = append(flags, "-expect-session-miss") |
| 913 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 914 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 915 | if test.testTLSUnique { |
| 916 | flags = append(flags, "-tls-unique") |
| 917 | } |
| 918 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 919 | flags = append(flags, test.flags...) |
| 920 | |
| 921 | var shim *exec.Cmd |
| 922 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 923 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 924 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 925 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 926 | } else if *useLLDB { |
| 927 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 928 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 929 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 930 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 931 | shim.Stdin = os.Stdin |
| 932 | var stdoutBuf, stderrBuf bytes.Buffer |
| 933 | shim.Stdout = &stdoutBuf |
| 934 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 935 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 936 | shim.Env = os.Environ() |
| 937 | 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] | 938 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 939 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 940 | } |
| 941 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 942 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 943 | |
| 944 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 945 | panic(err) |
| 946 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 947 | waitChan := make(chan error, 1) |
| 948 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 949 | |
| 950 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 951 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 952 | if *deterministic { |
| 953 | config.Rand = &deterministicRand{} |
| 954 | } |
| 955 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 956 | conn, err := acceptOrWait(listener, waitChan) |
| 957 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 958 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 959 | conn.Close() |
| 960 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 961 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 962 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 963 | var resumeConfig Config |
| 964 | if test.resumeConfig != nil { |
| 965 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 966 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 967 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 968 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 969 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 970 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 971 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 972 | } else { |
| 973 | resumeConfig = config |
| 974 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 975 | var connResume net.Conn |
| 976 | connResume, err = acceptOrWait(listener, waitChan) |
| 977 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 978 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 979 | connResume.Close() |
| 980 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 981 | } |
| 982 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 983 | // Close the listener now. This is to avoid hangs should the shim try to |
| 984 | // open more connections than expected. |
| 985 | listener.Close() |
| 986 | listener = nil |
| 987 | |
| 988 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 989 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 990 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 991 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 992 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 993 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 994 | case 89: |
| 995 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 996 | case 99: |
| 997 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 998 | } |
| 999 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1000 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1001 | // Account for Windows line endings. |
| 1002 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1003 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1004 | |
| 1005 | // Separate the errors from the shim and those from tools like |
| 1006 | // AddressSanitizer. |
| 1007 | var extraStderr string |
| 1008 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1009 | stderr = stderrParts[0] |
| 1010 | extraStderr = stderrParts[1] |
| 1011 | } |
| 1012 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1013 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1014 | expectedError := translateExpectedError(test.expectedError) |
| 1015 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1016 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1017 | localError := "none" |
| 1018 | if err != nil { |
| 1019 | localError = err.Error() |
| 1020 | } |
| 1021 | if len(test.expectedLocalError) != 0 { |
| 1022 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1023 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1024 | |
| 1025 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1026 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1027 | if childErr != nil { |
| 1028 | childError = childErr.Error() |
| 1029 | } |
| 1030 | |
| 1031 | var msg string |
| 1032 | switch { |
| 1033 | case failed && !test.shouldFail: |
| 1034 | msg = "unexpected failure" |
| 1035 | case !failed && test.shouldFail: |
| 1036 | msg = "unexpected success" |
| 1037 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1038 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1039 | default: |
| 1040 | panic("internal error") |
| 1041 | } |
| 1042 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1043 | 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] | 1044 | } |
| 1045 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1046 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1047 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1048 | } |
| 1049 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1050 | if *useValgrind && isValgrindError { |
| 1051 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1052 | } |
| 1053 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1054 | return nil |
| 1055 | } |
| 1056 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame^] | 1057 | type tlsVersion struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1058 | name string |
| 1059 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1060 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1061 | hasDTLS bool |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame^] | 1062 | } |
| 1063 | |
| 1064 | var tlsVersions = []tlsVersion{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1065 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1066 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1067 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1068 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1069 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame^] | 1072 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1073 | name string |
| 1074 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame^] | 1075 | } |
| 1076 | |
| 1077 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1078 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1079 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1080 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1081 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1082 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1083 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1084 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1085 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1086 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1087 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1088 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1089 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1090 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1091 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1092 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1093 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1094 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1095 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1096 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1097 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1098 | {"ECDHE-ECDSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1099 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1100 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1101 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1102 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1103 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1104 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1105 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1106 | {"ECDHE-RSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1107 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1108 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1109 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1110 | {"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] | 1111 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1112 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1113 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1114 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1115 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1118 | func hasComponent(suiteName, component string) bool { |
| 1119 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1120 | } |
| 1121 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1122 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1123 | return hasComponent(suiteName, "GCM") || |
| 1124 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1125 | hasComponent(suiteName, "SHA384") || |
| 1126 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1127 | } |
| 1128 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1129 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1130 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1131 | } |
| 1132 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1133 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1134 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1135 | } |
| 1136 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1137 | func bigFromHex(hex string) *big.Int { |
| 1138 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1139 | if !ok { |
| 1140 | panic("failed to parse hex number 0x" + hex) |
| 1141 | } |
| 1142 | return ret |
| 1143 | } |
| 1144 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1145 | func addBasicTests() { |
| 1146 | basicTests := []testCase{ |
| 1147 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1148 | name: "NoFallbackSCSV", |
| 1149 | config: Config{ |
| 1150 | Bugs: ProtocolBugs{ |
| 1151 | FailIfNotFallbackSCSV: true, |
| 1152 | }, |
| 1153 | }, |
| 1154 | shouldFail: true, |
| 1155 | expectedLocalError: "no fallback SCSV found", |
| 1156 | }, |
| 1157 | { |
| 1158 | name: "SendFallbackSCSV", |
| 1159 | config: Config{ |
| 1160 | Bugs: ProtocolBugs{ |
| 1161 | FailIfNotFallbackSCSV: true, |
| 1162 | }, |
| 1163 | }, |
| 1164 | flags: []string{"-fallback-scsv"}, |
| 1165 | }, |
| 1166 | { |
| 1167 | name: "ClientCertificateTypes", |
| 1168 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1169 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1170 | ClientAuth: RequestClientCert, |
| 1171 | ClientCertificateTypes: []byte{ |
| 1172 | CertTypeDSSSign, |
| 1173 | CertTypeRSASign, |
| 1174 | CertTypeECDSASign, |
| 1175 | }, |
| 1176 | }, |
| 1177 | flags: []string{ |
| 1178 | "-expect-certificate-types", |
| 1179 | base64.StdEncoding.EncodeToString([]byte{ |
| 1180 | CertTypeDSSSign, |
| 1181 | CertTypeRSASign, |
| 1182 | CertTypeECDSASign, |
| 1183 | }), |
| 1184 | }, |
| 1185 | }, |
| 1186 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1187 | name: "UnauthenticatedECDH", |
| 1188 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1189 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1190 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1191 | Bugs: ProtocolBugs{ |
| 1192 | UnauthenticatedECDH: true, |
| 1193 | }, |
| 1194 | }, |
| 1195 | shouldFail: true, |
| 1196 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1197 | }, |
| 1198 | { |
| 1199 | name: "SkipCertificateStatus", |
| 1200 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1201 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1202 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1203 | Bugs: ProtocolBugs{ |
| 1204 | SkipCertificateStatus: true, |
| 1205 | }, |
| 1206 | }, |
| 1207 | flags: []string{ |
| 1208 | "-enable-ocsp-stapling", |
| 1209 | }, |
| 1210 | }, |
| 1211 | { |
| 1212 | name: "SkipServerKeyExchange", |
| 1213 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1214 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1215 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1216 | Bugs: ProtocolBugs{ |
| 1217 | SkipServerKeyExchange: true, |
| 1218 | }, |
| 1219 | }, |
| 1220 | shouldFail: true, |
| 1221 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1222 | }, |
| 1223 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1224 | testType: serverTest, |
| 1225 | name: "Alert", |
| 1226 | config: Config{ |
| 1227 | Bugs: ProtocolBugs{ |
| 1228 | SendSpuriousAlert: alertRecordOverflow, |
| 1229 | }, |
| 1230 | }, |
| 1231 | shouldFail: true, |
| 1232 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1233 | }, |
| 1234 | { |
| 1235 | protocol: dtls, |
| 1236 | testType: serverTest, |
| 1237 | name: "Alert-DTLS", |
| 1238 | config: Config{ |
| 1239 | Bugs: ProtocolBugs{ |
| 1240 | SendSpuriousAlert: alertRecordOverflow, |
| 1241 | }, |
| 1242 | }, |
| 1243 | shouldFail: true, |
| 1244 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1245 | }, |
| 1246 | { |
| 1247 | testType: serverTest, |
| 1248 | name: "FragmentAlert", |
| 1249 | config: Config{ |
| 1250 | Bugs: ProtocolBugs{ |
| 1251 | FragmentAlert: true, |
| 1252 | SendSpuriousAlert: alertRecordOverflow, |
| 1253 | }, |
| 1254 | }, |
| 1255 | shouldFail: true, |
| 1256 | expectedError: ":BAD_ALERT:", |
| 1257 | }, |
| 1258 | { |
| 1259 | protocol: dtls, |
| 1260 | testType: serverTest, |
| 1261 | name: "FragmentAlert-DTLS", |
| 1262 | config: Config{ |
| 1263 | Bugs: ProtocolBugs{ |
| 1264 | FragmentAlert: true, |
| 1265 | SendSpuriousAlert: alertRecordOverflow, |
| 1266 | }, |
| 1267 | }, |
| 1268 | shouldFail: true, |
| 1269 | expectedError: ":BAD_ALERT:", |
| 1270 | }, |
| 1271 | { |
| 1272 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1273 | name: "DoubleAlert", |
| 1274 | config: Config{ |
| 1275 | Bugs: ProtocolBugs{ |
| 1276 | DoubleAlert: true, |
| 1277 | SendSpuriousAlert: alertRecordOverflow, |
| 1278 | }, |
| 1279 | }, |
| 1280 | shouldFail: true, |
| 1281 | expectedError: ":BAD_ALERT:", |
| 1282 | }, |
| 1283 | { |
| 1284 | protocol: dtls, |
| 1285 | testType: serverTest, |
| 1286 | name: "DoubleAlert-DTLS", |
| 1287 | config: Config{ |
| 1288 | Bugs: ProtocolBugs{ |
| 1289 | DoubleAlert: true, |
| 1290 | SendSpuriousAlert: alertRecordOverflow, |
| 1291 | }, |
| 1292 | }, |
| 1293 | shouldFail: true, |
| 1294 | expectedError: ":BAD_ALERT:", |
| 1295 | }, |
| 1296 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1297 | name: "SkipNewSessionTicket", |
| 1298 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1299 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1300 | Bugs: ProtocolBugs{ |
| 1301 | SkipNewSessionTicket: true, |
| 1302 | }, |
| 1303 | }, |
| 1304 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1305 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1306 | }, |
| 1307 | { |
| 1308 | testType: serverTest, |
| 1309 | name: "FallbackSCSV", |
| 1310 | config: Config{ |
| 1311 | MaxVersion: VersionTLS11, |
| 1312 | Bugs: ProtocolBugs{ |
| 1313 | SendFallbackSCSV: true, |
| 1314 | }, |
| 1315 | }, |
| 1316 | shouldFail: true, |
| 1317 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1318 | }, |
| 1319 | { |
| 1320 | testType: serverTest, |
| 1321 | name: "FallbackSCSV-VersionMatch", |
| 1322 | config: Config{ |
| 1323 | Bugs: ProtocolBugs{ |
| 1324 | SendFallbackSCSV: true, |
| 1325 | }, |
| 1326 | }, |
| 1327 | }, |
| 1328 | { |
| 1329 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1330 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1331 | config: Config{ |
| 1332 | MaxVersion: VersionTLS12, |
| 1333 | Bugs: ProtocolBugs{ |
| 1334 | SendFallbackSCSV: true, |
| 1335 | }, |
| 1336 | }, |
| 1337 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1338 | }, |
| 1339 | { |
| 1340 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1341 | name: "FragmentedClientVersion", |
| 1342 | config: Config{ |
| 1343 | Bugs: ProtocolBugs{ |
| 1344 | MaxHandshakeRecordLength: 1, |
| 1345 | FragmentClientVersion: true, |
| 1346 | }, |
| 1347 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1348 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1349 | }, |
| 1350 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1351 | testType: serverTest, |
| 1352 | name: "HttpGET", |
| 1353 | sendPrefix: "GET / HTTP/1.0\n", |
| 1354 | shouldFail: true, |
| 1355 | expectedError: ":HTTP_REQUEST:", |
| 1356 | }, |
| 1357 | { |
| 1358 | testType: serverTest, |
| 1359 | name: "HttpPOST", |
| 1360 | sendPrefix: "POST / HTTP/1.0\n", |
| 1361 | shouldFail: true, |
| 1362 | expectedError: ":HTTP_REQUEST:", |
| 1363 | }, |
| 1364 | { |
| 1365 | testType: serverTest, |
| 1366 | name: "HttpHEAD", |
| 1367 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1368 | shouldFail: true, |
| 1369 | expectedError: ":HTTP_REQUEST:", |
| 1370 | }, |
| 1371 | { |
| 1372 | testType: serverTest, |
| 1373 | name: "HttpPUT", |
| 1374 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1375 | shouldFail: true, |
| 1376 | expectedError: ":HTTP_REQUEST:", |
| 1377 | }, |
| 1378 | { |
| 1379 | testType: serverTest, |
| 1380 | name: "HttpCONNECT", |
| 1381 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1382 | shouldFail: true, |
| 1383 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1384 | }, |
| 1385 | { |
| 1386 | testType: serverTest, |
| 1387 | name: "Garbage", |
| 1388 | sendPrefix: "blah", |
| 1389 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1390 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1391 | }, |
| 1392 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1393 | name: "RSAEphemeralKey", |
| 1394 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1395 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1396 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1397 | Bugs: ProtocolBugs{ |
| 1398 | RSAEphemeralKey: true, |
| 1399 | }, |
| 1400 | }, |
| 1401 | shouldFail: true, |
| 1402 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1403 | }, |
| 1404 | { |
| 1405 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1406 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1407 | shouldFail: true, |
| 1408 | expectedError: ":WRONG_SSL_VERSION:", |
| 1409 | }, |
| 1410 | { |
| 1411 | protocol: dtls, |
| 1412 | name: "DisableEverything-DTLS", |
| 1413 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1414 | shouldFail: true, |
| 1415 | expectedError: ":WRONG_SSL_VERSION:", |
| 1416 | }, |
| 1417 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1418 | protocol: dtls, |
| 1419 | testType: serverTest, |
| 1420 | name: "MTU", |
| 1421 | config: Config{ |
| 1422 | Bugs: ProtocolBugs{ |
| 1423 | MaxPacketLength: 256, |
| 1424 | }, |
| 1425 | }, |
| 1426 | flags: []string{"-mtu", "256"}, |
| 1427 | }, |
| 1428 | { |
| 1429 | protocol: dtls, |
| 1430 | testType: serverTest, |
| 1431 | name: "MTUExceeded", |
| 1432 | config: Config{ |
| 1433 | Bugs: ProtocolBugs{ |
| 1434 | MaxPacketLength: 255, |
| 1435 | }, |
| 1436 | }, |
| 1437 | flags: []string{"-mtu", "256"}, |
| 1438 | shouldFail: true, |
| 1439 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1440 | }, |
| 1441 | { |
| 1442 | name: "CertMismatchRSA", |
| 1443 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1444 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1445 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1446 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1447 | Bugs: ProtocolBugs{ |
| 1448 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1449 | }, |
| 1450 | }, |
| 1451 | shouldFail: true, |
| 1452 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1453 | }, |
| 1454 | { |
| 1455 | name: "CertMismatchECDSA", |
| 1456 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1457 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1458 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1459 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1460 | Bugs: ProtocolBugs{ |
| 1461 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1462 | }, |
| 1463 | }, |
| 1464 | shouldFail: true, |
| 1465 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1466 | }, |
| 1467 | { |
| 1468 | name: "EmptyCertificateList", |
| 1469 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1470 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1471 | Bugs: ProtocolBugs{ |
| 1472 | EmptyCertificateList: true, |
| 1473 | }, |
| 1474 | }, |
| 1475 | shouldFail: true, |
| 1476 | expectedError: ":DECODE_ERROR:", |
| 1477 | }, |
| 1478 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1479 | name: "EmptyCertificateList-TLS13", |
| 1480 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1481 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1482 | Bugs: ProtocolBugs{ |
| 1483 | EmptyCertificateList: true, |
| 1484 | }, |
| 1485 | }, |
| 1486 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1487 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1488 | }, |
| 1489 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1490 | name: "TLSFatalBadPackets", |
| 1491 | damageFirstWrite: true, |
| 1492 | shouldFail: true, |
| 1493 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1494 | }, |
| 1495 | { |
| 1496 | protocol: dtls, |
| 1497 | name: "DTLSIgnoreBadPackets", |
| 1498 | damageFirstWrite: true, |
| 1499 | }, |
| 1500 | { |
| 1501 | protocol: dtls, |
| 1502 | name: "DTLSIgnoreBadPackets-Async", |
| 1503 | damageFirstWrite: true, |
| 1504 | flags: []string{"-async"}, |
| 1505 | }, |
| 1506 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1507 | name: "AppDataBeforeHandshake", |
| 1508 | config: Config{ |
| 1509 | Bugs: ProtocolBugs{ |
| 1510 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1511 | }, |
| 1512 | }, |
| 1513 | shouldFail: true, |
| 1514 | expectedError: ":UNEXPECTED_RECORD:", |
| 1515 | }, |
| 1516 | { |
| 1517 | name: "AppDataBeforeHandshake-Empty", |
| 1518 | config: Config{ |
| 1519 | Bugs: ProtocolBugs{ |
| 1520 | AppDataBeforeHandshake: []byte{}, |
| 1521 | }, |
| 1522 | }, |
| 1523 | shouldFail: true, |
| 1524 | expectedError: ":UNEXPECTED_RECORD:", |
| 1525 | }, |
| 1526 | { |
| 1527 | protocol: dtls, |
| 1528 | name: "AppDataBeforeHandshake-DTLS", |
| 1529 | config: Config{ |
| 1530 | Bugs: ProtocolBugs{ |
| 1531 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1532 | }, |
| 1533 | }, |
| 1534 | shouldFail: true, |
| 1535 | expectedError: ":UNEXPECTED_RECORD:", |
| 1536 | }, |
| 1537 | { |
| 1538 | protocol: dtls, |
| 1539 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1540 | config: Config{ |
| 1541 | Bugs: ProtocolBugs{ |
| 1542 | AppDataBeforeHandshake: []byte{}, |
| 1543 | }, |
| 1544 | }, |
| 1545 | shouldFail: true, |
| 1546 | expectedError: ":UNEXPECTED_RECORD:", |
| 1547 | }, |
| 1548 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1549 | name: "AppDataAfterChangeCipherSpec", |
| 1550 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1551 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1552 | Bugs: ProtocolBugs{ |
| 1553 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1554 | }, |
| 1555 | }, |
| 1556 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1557 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1558 | }, |
| 1559 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1560 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1561 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1562 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1563 | Bugs: ProtocolBugs{ |
| 1564 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1565 | }, |
| 1566 | }, |
| 1567 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1568 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1569 | }, |
| 1570 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1571 | protocol: dtls, |
| 1572 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1573 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1574 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1575 | Bugs: ProtocolBugs{ |
| 1576 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1577 | }, |
| 1578 | }, |
| 1579 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1580 | // application data. |
| 1581 | }, |
| 1582 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1583 | protocol: dtls, |
| 1584 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1585 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1586 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1587 | Bugs: ProtocolBugs{ |
| 1588 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1589 | }, |
| 1590 | }, |
| 1591 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1592 | // application data. |
| 1593 | }, |
| 1594 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1595 | name: "AlertAfterChangeCipherSpec", |
| 1596 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1597 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1598 | Bugs: ProtocolBugs{ |
| 1599 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1600 | }, |
| 1601 | }, |
| 1602 | shouldFail: true, |
| 1603 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1604 | }, |
| 1605 | { |
| 1606 | protocol: dtls, |
| 1607 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1608 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1609 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1610 | Bugs: ProtocolBugs{ |
| 1611 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1612 | }, |
| 1613 | }, |
| 1614 | shouldFail: true, |
| 1615 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1616 | }, |
| 1617 | { |
| 1618 | protocol: dtls, |
| 1619 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1620 | config: Config{ |
| 1621 | Bugs: ProtocolBugs{ |
| 1622 | ReorderHandshakeFragments: true, |
| 1623 | // Small enough that every handshake message is |
| 1624 | // fragmented. |
| 1625 | MaxHandshakeRecordLength: 2, |
| 1626 | }, |
| 1627 | }, |
| 1628 | }, |
| 1629 | { |
| 1630 | protocol: dtls, |
| 1631 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1632 | config: Config{ |
| 1633 | Bugs: ProtocolBugs{ |
| 1634 | ReorderHandshakeFragments: true, |
| 1635 | // Large enough that no handshake message is |
| 1636 | // fragmented. |
| 1637 | MaxHandshakeRecordLength: 2048, |
| 1638 | }, |
| 1639 | }, |
| 1640 | }, |
| 1641 | { |
| 1642 | protocol: dtls, |
| 1643 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1644 | config: Config{ |
| 1645 | Bugs: ProtocolBugs{ |
| 1646 | ReorderHandshakeFragments: true, |
| 1647 | MixCompleteMessageWithFragments: true, |
| 1648 | MaxHandshakeRecordLength: 2, |
| 1649 | }, |
| 1650 | }, |
| 1651 | }, |
| 1652 | { |
| 1653 | name: "SendInvalidRecordType", |
| 1654 | config: Config{ |
| 1655 | Bugs: ProtocolBugs{ |
| 1656 | SendInvalidRecordType: true, |
| 1657 | }, |
| 1658 | }, |
| 1659 | shouldFail: true, |
| 1660 | expectedError: ":UNEXPECTED_RECORD:", |
| 1661 | }, |
| 1662 | { |
| 1663 | protocol: dtls, |
| 1664 | name: "SendInvalidRecordType-DTLS", |
| 1665 | config: Config{ |
| 1666 | Bugs: ProtocolBugs{ |
| 1667 | SendInvalidRecordType: true, |
| 1668 | }, |
| 1669 | }, |
| 1670 | shouldFail: true, |
| 1671 | expectedError: ":UNEXPECTED_RECORD:", |
| 1672 | }, |
| 1673 | { |
| 1674 | name: "FalseStart-SkipServerSecondLeg", |
| 1675 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1676 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1677 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1678 | NextProtos: []string{"foo"}, |
| 1679 | Bugs: ProtocolBugs{ |
| 1680 | SkipNewSessionTicket: true, |
| 1681 | SkipChangeCipherSpec: true, |
| 1682 | SkipFinished: true, |
| 1683 | ExpectFalseStart: true, |
| 1684 | }, |
| 1685 | }, |
| 1686 | flags: []string{ |
| 1687 | "-false-start", |
| 1688 | "-handshake-never-done", |
| 1689 | "-advertise-alpn", "\x03foo", |
| 1690 | }, |
| 1691 | shimWritesFirst: true, |
| 1692 | shouldFail: true, |
| 1693 | expectedError: ":UNEXPECTED_RECORD:", |
| 1694 | }, |
| 1695 | { |
| 1696 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1697 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1698 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1699 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1700 | NextProtos: []string{"foo"}, |
| 1701 | Bugs: ProtocolBugs{ |
| 1702 | SkipNewSessionTicket: true, |
| 1703 | SkipChangeCipherSpec: true, |
| 1704 | SkipFinished: true, |
| 1705 | }, |
| 1706 | }, |
| 1707 | flags: []string{ |
| 1708 | "-implicit-handshake", |
| 1709 | "-false-start", |
| 1710 | "-handshake-never-done", |
| 1711 | "-advertise-alpn", "\x03foo", |
| 1712 | }, |
| 1713 | shouldFail: true, |
| 1714 | expectedError: ":UNEXPECTED_RECORD:", |
| 1715 | }, |
| 1716 | { |
| 1717 | testType: serverTest, |
| 1718 | name: "FailEarlyCallback", |
| 1719 | flags: []string{"-fail-early-callback"}, |
| 1720 | shouldFail: true, |
| 1721 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1722 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1723 | }, |
| 1724 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1725 | name: "FailCertCallback-Client-TLS12", |
| 1726 | config: Config{ |
| 1727 | MaxVersion: VersionTLS12, |
| 1728 | ClientAuth: RequestClientCert, |
| 1729 | }, |
| 1730 | flags: []string{"-fail-cert-callback"}, |
| 1731 | shouldFail: true, |
| 1732 | expectedError: ":CERT_CB_ERROR:", |
| 1733 | expectedLocalError: "remote error: internal error", |
| 1734 | }, |
| 1735 | { |
| 1736 | testType: serverTest, |
| 1737 | name: "FailCertCallback-Server-TLS12", |
| 1738 | config: Config{ |
| 1739 | MaxVersion: VersionTLS12, |
| 1740 | }, |
| 1741 | flags: []string{"-fail-cert-callback"}, |
| 1742 | shouldFail: true, |
| 1743 | expectedError: ":CERT_CB_ERROR:", |
| 1744 | expectedLocalError: "remote error: internal error", |
| 1745 | }, |
| 1746 | { |
| 1747 | name: "FailCertCallback-Client-TLS13", |
| 1748 | config: Config{ |
| 1749 | MaxVersion: VersionTLS13, |
| 1750 | ClientAuth: RequestClientCert, |
| 1751 | }, |
| 1752 | flags: []string{"-fail-cert-callback"}, |
| 1753 | shouldFail: true, |
| 1754 | expectedError: ":CERT_CB_ERROR:", |
| 1755 | expectedLocalError: "remote error: internal error", |
| 1756 | }, |
| 1757 | { |
| 1758 | testType: serverTest, |
| 1759 | name: "FailCertCallback-Server-TLS13", |
| 1760 | config: Config{ |
| 1761 | MaxVersion: VersionTLS13, |
| 1762 | }, |
| 1763 | flags: []string{"-fail-cert-callback"}, |
| 1764 | shouldFail: true, |
| 1765 | expectedError: ":CERT_CB_ERROR:", |
| 1766 | expectedLocalError: "remote error: internal error", |
| 1767 | }, |
| 1768 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1769 | protocol: dtls, |
| 1770 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1771 | config: Config{ |
| 1772 | Bugs: ProtocolBugs{ |
| 1773 | MaxHandshakeRecordLength: 2, |
| 1774 | FragmentMessageTypeMismatch: true, |
| 1775 | }, |
| 1776 | }, |
| 1777 | shouldFail: true, |
| 1778 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1779 | }, |
| 1780 | { |
| 1781 | protocol: dtls, |
| 1782 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1783 | config: Config{ |
| 1784 | Bugs: ProtocolBugs{ |
| 1785 | MaxHandshakeRecordLength: 2, |
| 1786 | FragmentMessageLengthMismatch: true, |
| 1787 | }, |
| 1788 | }, |
| 1789 | shouldFail: true, |
| 1790 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1791 | }, |
| 1792 | { |
| 1793 | protocol: dtls, |
| 1794 | name: "SplitFragments-Header-DTLS", |
| 1795 | config: Config{ |
| 1796 | Bugs: ProtocolBugs{ |
| 1797 | SplitFragments: 2, |
| 1798 | }, |
| 1799 | }, |
| 1800 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1801 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1802 | }, |
| 1803 | { |
| 1804 | protocol: dtls, |
| 1805 | name: "SplitFragments-Boundary-DTLS", |
| 1806 | config: Config{ |
| 1807 | Bugs: ProtocolBugs{ |
| 1808 | SplitFragments: dtlsRecordHeaderLen, |
| 1809 | }, |
| 1810 | }, |
| 1811 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1812 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1813 | }, |
| 1814 | { |
| 1815 | protocol: dtls, |
| 1816 | name: "SplitFragments-Body-DTLS", |
| 1817 | config: Config{ |
| 1818 | Bugs: ProtocolBugs{ |
| 1819 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1820 | }, |
| 1821 | }, |
| 1822 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1823 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1824 | }, |
| 1825 | { |
| 1826 | protocol: dtls, |
| 1827 | name: "SendEmptyFragments-DTLS", |
| 1828 | config: Config{ |
| 1829 | Bugs: ProtocolBugs{ |
| 1830 | SendEmptyFragments: true, |
| 1831 | }, |
| 1832 | }, |
| 1833 | }, |
| 1834 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1835 | name: "BadFinished-Client", |
| 1836 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1837 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1838 | Bugs: ProtocolBugs{ |
| 1839 | BadFinished: true, |
| 1840 | }, |
| 1841 | }, |
| 1842 | shouldFail: true, |
| 1843 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1844 | }, |
| 1845 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1846 | name: "BadFinished-Client-TLS13", |
| 1847 | config: Config{ |
| 1848 | MaxVersion: VersionTLS13, |
| 1849 | Bugs: ProtocolBugs{ |
| 1850 | BadFinished: true, |
| 1851 | }, |
| 1852 | }, |
| 1853 | shouldFail: true, |
| 1854 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1855 | }, |
| 1856 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1857 | testType: serverTest, |
| 1858 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1859 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1860 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1861 | Bugs: ProtocolBugs{ |
| 1862 | BadFinished: true, |
| 1863 | }, |
| 1864 | }, |
| 1865 | shouldFail: true, |
| 1866 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1867 | }, |
| 1868 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1869 | testType: serverTest, |
| 1870 | name: "BadFinished-Server-TLS13", |
| 1871 | config: Config{ |
| 1872 | MaxVersion: VersionTLS13, |
| 1873 | Bugs: ProtocolBugs{ |
| 1874 | BadFinished: true, |
| 1875 | }, |
| 1876 | }, |
| 1877 | shouldFail: true, |
| 1878 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1879 | }, |
| 1880 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1881 | name: "FalseStart-BadFinished", |
| 1882 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1883 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1884 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1885 | NextProtos: []string{"foo"}, |
| 1886 | Bugs: ProtocolBugs{ |
| 1887 | BadFinished: true, |
| 1888 | ExpectFalseStart: true, |
| 1889 | }, |
| 1890 | }, |
| 1891 | flags: []string{ |
| 1892 | "-false-start", |
| 1893 | "-handshake-never-done", |
| 1894 | "-advertise-alpn", "\x03foo", |
| 1895 | }, |
| 1896 | shimWritesFirst: true, |
| 1897 | shouldFail: true, |
| 1898 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1899 | }, |
| 1900 | { |
| 1901 | name: "NoFalseStart-NoALPN", |
| 1902 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1903 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1904 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1905 | Bugs: ProtocolBugs{ |
| 1906 | ExpectFalseStart: true, |
| 1907 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1908 | }, |
| 1909 | }, |
| 1910 | flags: []string{ |
| 1911 | "-false-start", |
| 1912 | }, |
| 1913 | shimWritesFirst: true, |
| 1914 | shouldFail: true, |
| 1915 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1916 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1917 | }, |
| 1918 | { |
| 1919 | name: "NoFalseStart-NoAEAD", |
| 1920 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1921 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1922 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1923 | NextProtos: []string{"foo"}, |
| 1924 | Bugs: ProtocolBugs{ |
| 1925 | ExpectFalseStart: true, |
| 1926 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1927 | }, |
| 1928 | }, |
| 1929 | flags: []string{ |
| 1930 | "-false-start", |
| 1931 | "-advertise-alpn", "\x03foo", |
| 1932 | }, |
| 1933 | shimWritesFirst: true, |
| 1934 | shouldFail: true, |
| 1935 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1936 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1937 | }, |
| 1938 | { |
| 1939 | name: "NoFalseStart-RSA", |
| 1940 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1941 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1942 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1943 | NextProtos: []string{"foo"}, |
| 1944 | Bugs: ProtocolBugs{ |
| 1945 | ExpectFalseStart: true, |
| 1946 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1947 | }, |
| 1948 | }, |
| 1949 | flags: []string{ |
| 1950 | "-false-start", |
| 1951 | "-advertise-alpn", "\x03foo", |
| 1952 | }, |
| 1953 | shimWritesFirst: true, |
| 1954 | shouldFail: true, |
| 1955 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1956 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1957 | }, |
| 1958 | { |
| 1959 | name: "NoFalseStart-DHE_RSA", |
| 1960 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1961 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1962 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1963 | NextProtos: []string{"foo"}, |
| 1964 | Bugs: ProtocolBugs{ |
| 1965 | ExpectFalseStart: true, |
| 1966 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1967 | }, |
| 1968 | }, |
| 1969 | flags: []string{ |
| 1970 | "-false-start", |
| 1971 | "-advertise-alpn", "\x03foo", |
| 1972 | }, |
| 1973 | shimWritesFirst: true, |
| 1974 | shouldFail: true, |
| 1975 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1976 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1977 | }, |
| 1978 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1979 | protocol: dtls, |
| 1980 | name: "SendSplitAlert-Sync", |
| 1981 | config: Config{ |
| 1982 | Bugs: ProtocolBugs{ |
| 1983 | SendSplitAlert: true, |
| 1984 | }, |
| 1985 | }, |
| 1986 | }, |
| 1987 | { |
| 1988 | protocol: dtls, |
| 1989 | name: "SendSplitAlert-Async", |
| 1990 | config: Config{ |
| 1991 | Bugs: ProtocolBugs{ |
| 1992 | SendSplitAlert: true, |
| 1993 | }, |
| 1994 | }, |
| 1995 | flags: []string{"-async"}, |
| 1996 | }, |
| 1997 | { |
| 1998 | protocol: dtls, |
| 1999 | name: "PackDTLSHandshake", |
| 2000 | config: Config{ |
| 2001 | Bugs: ProtocolBugs{ |
| 2002 | MaxHandshakeRecordLength: 2, |
| 2003 | PackHandshakeFragments: 20, |
| 2004 | PackHandshakeRecords: 200, |
| 2005 | }, |
| 2006 | }, |
| 2007 | }, |
| 2008 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2009 | name: "SendEmptyRecords-Pass", |
| 2010 | sendEmptyRecords: 32, |
| 2011 | }, |
| 2012 | { |
| 2013 | name: "SendEmptyRecords", |
| 2014 | sendEmptyRecords: 33, |
| 2015 | shouldFail: true, |
| 2016 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2017 | }, |
| 2018 | { |
| 2019 | name: "SendEmptyRecords-Async", |
| 2020 | sendEmptyRecords: 33, |
| 2021 | flags: []string{"-async"}, |
| 2022 | shouldFail: true, |
| 2023 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2024 | }, |
| 2025 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2026 | name: "SendWarningAlerts-Pass", |
| 2027 | config: Config{ |
| 2028 | MaxVersion: VersionTLS12, |
| 2029 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2030 | sendWarningAlerts: 4, |
| 2031 | }, |
| 2032 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2033 | protocol: dtls, |
| 2034 | name: "SendWarningAlerts-DTLS-Pass", |
| 2035 | config: Config{ |
| 2036 | MaxVersion: VersionTLS12, |
| 2037 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2038 | sendWarningAlerts: 4, |
| 2039 | }, |
| 2040 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2041 | name: "SendWarningAlerts-TLS13", |
| 2042 | config: Config{ |
| 2043 | MaxVersion: VersionTLS13, |
| 2044 | }, |
| 2045 | sendWarningAlerts: 4, |
| 2046 | shouldFail: true, |
| 2047 | expectedError: ":BAD_ALERT:", |
| 2048 | expectedLocalError: "remote error: error decoding message", |
| 2049 | }, |
| 2050 | { |
| 2051 | name: "SendWarningAlerts", |
| 2052 | config: Config{ |
| 2053 | MaxVersion: VersionTLS12, |
| 2054 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2055 | sendWarningAlerts: 5, |
| 2056 | shouldFail: true, |
| 2057 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2058 | }, |
| 2059 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2060 | name: "SendWarningAlerts-Async", |
| 2061 | config: Config{ |
| 2062 | MaxVersion: VersionTLS12, |
| 2063 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2064 | sendWarningAlerts: 5, |
| 2065 | flags: []string{"-async"}, |
| 2066 | shouldFail: true, |
| 2067 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2068 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2069 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2070 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2071 | config: Config{ |
| 2072 | MaxVersion: VersionTLS13, |
| 2073 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2074 | sendKeyUpdates: 33, |
| 2075 | keyUpdateRequest: keyUpdateNotRequested, |
| 2076 | shouldFail: true, |
| 2077 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2078 | }, |
| 2079 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2080 | name: "EmptySessionID", |
| 2081 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2082 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2083 | SessionTicketsDisabled: true, |
| 2084 | }, |
| 2085 | noSessionCache: true, |
| 2086 | flags: []string{"-expect-no-session"}, |
| 2087 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2088 | { |
| 2089 | name: "Unclean-Shutdown", |
| 2090 | config: Config{ |
| 2091 | Bugs: ProtocolBugs{ |
| 2092 | NoCloseNotify: true, |
| 2093 | ExpectCloseNotify: true, |
| 2094 | }, |
| 2095 | }, |
| 2096 | shimShutsDown: true, |
| 2097 | flags: []string{"-check-close-notify"}, |
| 2098 | shouldFail: true, |
| 2099 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2100 | }, |
| 2101 | { |
| 2102 | name: "Unclean-Shutdown-Ignored", |
| 2103 | config: Config{ |
| 2104 | Bugs: ProtocolBugs{ |
| 2105 | NoCloseNotify: true, |
| 2106 | }, |
| 2107 | }, |
| 2108 | shimShutsDown: true, |
| 2109 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2110 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2111 | name: "Unclean-Shutdown-Alert", |
| 2112 | config: Config{ |
| 2113 | Bugs: ProtocolBugs{ |
| 2114 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2115 | ExpectCloseNotify: true, |
| 2116 | }, |
| 2117 | }, |
| 2118 | shimShutsDown: true, |
| 2119 | flags: []string{"-check-close-notify"}, |
| 2120 | shouldFail: true, |
| 2121 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2122 | }, |
| 2123 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2124 | name: "LargePlaintext", |
| 2125 | config: Config{ |
| 2126 | Bugs: ProtocolBugs{ |
| 2127 | SendLargeRecords: true, |
| 2128 | }, |
| 2129 | }, |
| 2130 | messageLen: maxPlaintext + 1, |
| 2131 | shouldFail: true, |
| 2132 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2133 | }, |
| 2134 | { |
| 2135 | protocol: dtls, |
| 2136 | name: "LargePlaintext-DTLS", |
| 2137 | config: Config{ |
| 2138 | Bugs: ProtocolBugs{ |
| 2139 | SendLargeRecords: true, |
| 2140 | }, |
| 2141 | }, |
| 2142 | messageLen: maxPlaintext + 1, |
| 2143 | shouldFail: true, |
| 2144 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2145 | }, |
| 2146 | { |
| 2147 | name: "LargeCiphertext", |
| 2148 | config: Config{ |
| 2149 | Bugs: ProtocolBugs{ |
| 2150 | SendLargeRecords: true, |
| 2151 | }, |
| 2152 | }, |
| 2153 | messageLen: maxPlaintext * 2, |
| 2154 | shouldFail: true, |
| 2155 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2156 | }, |
| 2157 | { |
| 2158 | protocol: dtls, |
| 2159 | name: "LargeCiphertext-DTLS", |
| 2160 | config: Config{ |
| 2161 | Bugs: ProtocolBugs{ |
| 2162 | SendLargeRecords: true, |
| 2163 | }, |
| 2164 | }, |
| 2165 | messageLen: maxPlaintext * 2, |
| 2166 | // Unlike the other four cases, DTLS drops records which |
| 2167 | // are invalid before authentication, so the connection |
| 2168 | // does not fail. |
| 2169 | expectMessageDropped: true, |
| 2170 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2171 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2172 | name: "BadHelloRequest-1", |
| 2173 | renegotiate: 1, |
| 2174 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2175 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2176 | Bugs: ProtocolBugs{ |
| 2177 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2178 | }, |
| 2179 | }, |
| 2180 | flags: []string{ |
| 2181 | "-renegotiate-freely", |
| 2182 | "-expect-total-renegotiations", "1", |
| 2183 | }, |
| 2184 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2185 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2186 | }, |
| 2187 | { |
| 2188 | name: "BadHelloRequest-2", |
| 2189 | renegotiate: 1, |
| 2190 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2191 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2192 | Bugs: ProtocolBugs{ |
| 2193 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2194 | }, |
| 2195 | }, |
| 2196 | flags: []string{ |
| 2197 | "-renegotiate-freely", |
| 2198 | "-expect-total-renegotiations", "1", |
| 2199 | }, |
| 2200 | shouldFail: true, |
| 2201 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2202 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2203 | { |
| 2204 | testType: serverTest, |
| 2205 | name: "SupportTicketsWithSessionID", |
| 2206 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2207 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2208 | SessionTicketsDisabled: true, |
| 2209 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2210 | resumeConfig: &Config{ |
| 2211 | MaxVersion: VersionTLS12, |
| 2212 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2213 | resumeSession: true, |
| 2214 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2215 | { |
| 2216 | protocol: dtls, |
| 2217 | name: "DTLS-SendExtraFinished", |
| 2218 | config: Config{ |
| 2219 | Bugs: ProtocolBugs{ |
| 2220 | SendExtraFinished: true, |
| 2221 | }, |
| 2222 | }, |
| 2223 | shouldFail: true, |
| 2224 | expectedError: ":UNEXPECTED_RECORD:", |
| 2225 | }, |
| 2226 | { |
| 2227 | protocol: dtls, |
| 2228 | name: "DTLS-SendExtraFinished-Reordered", |
| 2229 | config: Config{ |
| 2230 | Bugs: ProtocolBugs{ |
| 2231 | MaxHandshakeRecordLength: 2, |
| 2232 | ReorderHandshakeFragments: true, |
| 2233 | SendExtraFinished: true, |
| 2234 | }, |
| 2235 | }, |
| 2236 | shouldFail: true, |
| 2237 | expectedError: ":UNEXPECTED_RECORD:", |
| 2238 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2239 | { |
| 2240 | testType: serverTest, |
| 2241 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2242 | config: Config{ |
| 2243 | // Choose a cipher suite that does not involve |
| 2244 | // elliptic curves, so no extensions are |
| 2245 | // involved. |
| 2246 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2247 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2248 | Bugs: ProtocolBugs{ |
| 2249 | SendV2ClientHello: true, |
| 2250 | }, |
| 2251 | }, |
| 2252 | sendPrefix: string([]byte{ |
| 2253 | byte(recordTypeHandshake), |
| 2254 | 3, 1, // version |
| 2255 | 0, 0, // length |
| 2256 | }), |
| 2257 | // A no-op empty record may not be sent before V2ClientHello. |
| 2258 | shouldFail: true, |
| 2259 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2260 | }, |
| 2261 | { |
| 2262 | testType: serverTest, |
| 2263 | name: "V2ClientHello-WarningAlertPrefix", |
| 2264 | config: Config{ |
| 2265 | // Choose a cipher suite that does not involve |
| 2266 | // elliptic curves, so no extensions are |
| 2267 | // involved. |
| 2268 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2269 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2270 | Bugs: ProtocolBugs{ |
| 2271 | SendV2ClientHello: true, |
| 2272 | }, |
| 2273 | }, |
| 2274 | sendPrefix: string([]byte{ |
| 2275 | byte(recordTypeAlert), |
| 2276 | 3, 1, // version |
| 2277 | 0, 2, // length |
| 2278 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2279 | }), |
| 2280 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2281 | shouldFail: true, |
| 2282 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2283 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2284 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2285 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2286 | config: Config{ |
| 2287 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2288 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2289 | sendKeyUpdates: 1, |
| 2290 | keyUpdateRequest: keyUpdateNotRequested, |
| 2291 | }, |
| 2292 | { |
| 2293 | name: "KeyUpdate-InvalidRequestMode", |
| 2294 | config: Config{ |
| 2295 | MaxVersion: VersionTLS13, |
| 2296 | }, |
| 2297 | sendKeyUpdates: 1, |
| 2298 | keyUpdateRequest: 42, |
| 2299 | shouldFail: true, |
| 2300 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2301 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2302 | { |
| 2303 | name: "SendSNIWarningAlert", |
| 2304 | config: Config{ |
| 2305 | MaxVersion: VersionTLS12, |
| 2306 | Bugs: ProtocolBugs{ |
| 2307 | SendSNIWarningAlert: true, |
| 2308 | }, |
| 2309 | }, |
| 2310 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2311 | { |
| 2312 | testType: serverTest, |
| 2313 | name: "ExtraCompressionMethods-TLS12", |
| 2314 | config: Config{ |
| 2315 | MaxVersion: VersionTLS12, |
| 2316 | Bugs: ProtocolBugs{ |
| 2317 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2318 | }, |
| 2319 | }, |
| 2320 | }, |
| 2321 | { |
| 2322 | testType: serverTest, |
| 2323 | name: "ExtraCompressionMethods-TLS13", |
| 2324 | config: Config{ |
| 2325 | MaxVersion: VersionTLS13, |
| 2326 | Bugs: ProtocolBugs{ |
| 2327 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2328 | }, |
| 2329 | }, |
| 2330 | shouldFail: true, |
| 2331 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2332 | expectedLocalError: "remote error: illegal parameter", |
| 2333 | }, |
| 2334 | { |
| 2335 | testType: serverTest, |
| 2336 | name: "NoNullCompression-TLS12", |
| 2337 | config: Config{ |
| 2338 | MaxVersion: VersionTLS12, |
| 2339 | Bugs: ProtocolBugs{ |
| 2340 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2341 | }, |
| 2342 | }, |
| 2343 | shouldFail: true, |
| 2344 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2345 | expectedLocalError: "remote error: illegal parameter", |
| 2346 | }, |
| 2347 | { |
| 2348 | testType: serverTest, |
| 2349 | name: "NoNullCompression-TLS13", |
| 2350 | config: Config{ |
| 2351 | MaxVersion: VersionTLS13, |
| 2352 | Bugs: ProtocolBugs{ |
| 2353 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2354 | }, |
| 2355 | }, |
| 2356 | shouldFail: true, |
| 2357 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2358 | expectedLocalError: "remote error: illegal parameter", |
| 2359 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2360 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2361 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2362 | config: Config{ |
| 2363 | MaxVersion: VersionTLS12, |
| 2364 | Bugs: ProtocolBugs{ |
| 2365 | ExpectGREASE: true, |
| 2366 | }, |
| 2367 | }, |
| 2368 | flags: []string{"-enable-grease"}, |
| 2369 | }, |
| 2370 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2371 | name: "GREASE-Client-TLS13", |
| 2372 | config: Config{ |
| 2373 | MaxVersion: VersionTLS13, |
| 2374 | Bugs: ProtocolBugs{ |
| 2375 | ExpectGREASE: true, |
| 2376 | }, |
| 2377 | }, |
| 2378 | flags: []string{"-enable-grease"}, |
| 2379 | }, |
| 2380 | { |
| 2381 | testType: serverTest, |
| 2382 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2383 | config: Config{ |
| 2384 | MaxVersion: VersionTLS13, |
| 2385 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2386 | // TLS 1.3 servers are expected to |
| 2387 | // always enable GREASE. TLS 1.3 is new, |
| 2388 | // so there is no existing ecosystem to |
| 2389 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2390 | ExpectGREASE: true, |
| 2391 | }, |
| 2392 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2393 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2394 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2395 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2396 | |
| 2397 | // Test that very large messages can be received. |
| 2398 | cert := rsaCertificate |
| 2399 | for i := 0; i < 50; i++ { |
| 2400 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2401 | } |
| 2402 | testCases = append(testCases, testCase{ |
| 2403 | name: "LargeMessage", |
| 2404 | config: Config{ |
| 2405 | Certificates: []Certificate{cert}, |
| 2406 | }, |
| 2407 | }) |
| 2408 | testCases = append(testCases, testCase{ |
| 2409 | protocol: dtls, |
| 2410 | name: "LargeMessage-DTLS", |
| 2411 | config: Config{ |
| 2412 | Certificates: []Certificate{cert}, |
| 2413 | }, |
| 2414 | }) |
| 2415 | |
| 2416 | // They are rejected if the maximum certificate chain length is capped. |
| 2417 | testCases = append(testCases, testCase{ |
| 2418 | name: "LargeMessage-Reject", |
| 2419 | config: Config{ |
| 2420 | Certificates: []Certificate{cert}, |
| 2421 | }, |
| 2422 | flags: []string{"-max-cert-list", "16384"}, |
| 2423 | shouldFail: true, |
| 2424 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2425 | }) |
| 2426 | testCases = append(testCases, testCase{ |
| 2427 | protocol: dtls, |
| 2428 | name: "LargeMessage-Reject-DTLS", |
| 2429 | config: Config{ |
| 2430 | Certificates: []Certificate{cert}, |
| 2431 | }, |
| 2432 | flags: []string{"-max-cert-list", "16384"}, |
| 2433 | shouldFail: true, |
| 2434 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2435 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2436 | } |
| 2437 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame^] | 2438 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2439 | const psk = "12345" |
| 2440 | const pskIdentity = "luggage combo" |
| 2441 | |
| 2442 | var prefix string |
| 2443 | if protocol == dtls { |
| 2444 | if !ver.hasDTLS { |
| 2445 | return |
| 2446 | } |
| 2447 | prefix = "D" |
| 2448 | } |
| 2449 | |
| 2450 | var cert Certificate |
| 2451 | var certFile string |
| 2452 | var keyFile string |
| 2453 | if hasComponent(suite.name, "ECDSA") { |
| 2454 | cert = ecdsaP256Certificate |
| 2455 | certFile = ecdsaP256CertificateFile |
| 2456 | keyFile = ecdsaP256KeyFile |
| 2457 | } else { |
| 2458 | cert = rsaCertificate |
| 2459 | certFile = rsaCertificateFile |
| 2460 | keyFile = rsaKeyFile |
| 2461 | } |
| 2462 | |
| 2463 | var flags []string |
| 2464 | if hasComponent(suite.name, "PSK") { |
| 2465 | flags = append(flags, |
| 2466 | "-psk", psk, |
| 2467 | "-psk-identity", pskIdentity) |
| 2468 | } |
| 2469 | if hasComponent(suite.name, "NULL") { |
| 2470 | // NULL ciphers must be explicitly enabled. |
| 2471 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2472 | } |
| 2473 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2474 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2475 | // for now. |
| 2476 | flags = append(flags, "-cipher", suite.name) |
| 2477 | } |
| 2478 | |
| 2479 | var shouldServerFail, shouldClientFail bool |
| 2480 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2481 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2482 | // a BoringSSL server will never select it |
| 2483 | // because the extension is missing. |
| 2484 | shouldServerFail = true |
| 2485 | } |
| 2486 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2487 | shouldClientFail = true |
| 2488 | shouldServerFail = true |
| 2489 | } |
| 2490 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2491 | shouldClientFail = true |
| 2492 | shouldServerFail = true |
| 2493 | } |
| 2494 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2495 | shouldClientFail = true |
| 2496 | shouldServerFail = true |
| 2497 | } |
| 2498 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2499 | shouldClientFail = true |
| 2500 | shouldServerFail = true |
| 2501 | } |
| 2502 | |
| 2503 | var sendCipherSuite uint16 |
| 2504 | var expectedServerError, expectedClientError string |
| 2505 | serverCipherSuites := []uint16{suite.id} |
| 2506 | if shouldServerFail { |
| 2507 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2508 | } |
| 2509 | if shouldClientFail { |
| 2510 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2511 | // Configure the server to select ciphers as normal but |
| 2512 | // select an incompatible cipher in ServerHello. |
| 2513 | serverCipherSuites = nil |
| 2514 | sendCipherSuite = suite.id |
| 2515 | } |
| 2516 | |
| 2517 | testCases = append(testCases, testCase{ |
| 2518 | testType: serverTest, |
| 2519 | protocol: protocol, |
| 2520 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2521 | config: Config{ |
| 2522 | MinVersion: ver.version, |
| 2523 | MaxVersion: ver.version, |
| 2524 | CipherSuites: []uint16{suite.id}, |
| 2525 | Certificates: []Certificate{cert}, |
| 2526 | PreSharedKey: []byte(psk), |
| 2527 | PreSharedKeyIdentity: pskIdentity, |
| 2528 | Bugs: ProtocolBugs{ |
| 2529 | AdvertiseAllConfiguredCiphers: true, |
| 2530 | }, |
| 2531 | }, |
| 2532 | certFile: certFile, |
| 2533 | keyFile: keyFile, |
| 2534 | flags: flags, |
| 2535 | resumeSession: true, |
| 2536 | shouldFail: shouldServerFail, |
| 2537 | expectedError: expectedServerError, |
| 2538 | }) |
| 2539 | |
| 2540 | testCases = append(testCases, testCase{ |
| 2541 | testType: clientTest, |
| 2542 | protocol: protocol, |
| 2543 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2544 | config: Config{ |
| 2545 | MinVersion: ver.version, |
| 2546 | MaxVersion: ver.version, |
| 2547 | CipherSuites: serverCipherSuites, |
| 2548 | Certificates: []Certificate{cert}, |
| 2549 | PreSharedKey: []byte(psk), |
| 2550 | PreSharedKeyIdentity: pskIdentity, |
| 2551 | Bugs: ProtocolBugs{ |
| 2552 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2553 | SendCipherSuite: sendCipherSuite, |
| 2554 | }, |
| 2555 | }, |
| 2556 | flags: flags, |
| 2557 | resumeSession: true, |
| 2558 | shouldFail: shouldClientFail, |
| 2559 | expectedError: expectedClientError, |
| 2560 | }) |
| 2561 | |
| 2562 | if !shouldClientFail { |
| 2563 | // Ensure the maximum record size is accepted. |
| 2564 | testCases = append(testCases, testCase{ |
| 2565 | protocol: protocol, |
| 2566 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2567 | config: Config{ |
| 2568 | MinVersion: ver.version, |
| 2569 | MaxVersion: ver.version, |
| 2570 | CipherSuites: []uint16{suite.id}, |
| 2571 | Certificates: []Certificate{cert}, |
| 2572 | PreSharedKey: []byte(psk), |
| 2573 | PreSharedKeyIdentity: pskIdentity, |
| 2574 | }, |
| 2575 | flags: flags, |
| 2576 | messageLen: maxPlaintext, |
| 2577 | }) |
| 2578 | |
| 2579 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2580 | // and ignored in DTLS. |
| 2581 | var shouldFail bool |
| 2582 | var expectedError string |
| 2583 | if protocol == tls { |
| 2584 | shouldFail = true |
| 2585 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2586 | } |
| 2587 | |
| 2588 | testCases = append(testCases, testCase{ |
| 2589 | protocol: protocol, |
| 2590 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2591 | config: Config{ |
| 2592 | MinVersion: ver.version, |
| 2593 | MaxVersion: ver.version, |
| 2594 | CipherSuites: []uint16{suite.id}, |
| 2595 | Certificates: []Certificate{cert}, |
| 2596 | PreSharedKey: []byte(psk), |
| 2597 | PreSharedKeyIdentity: pskIdentity, |
| 2598 | }, |
| 2599 | flags: flags, |
| 2600 | damageFirstWrite: true, |
| 2601 | messageLen: maxPlaintext, |
| 2602 | shouldFail: shouldFail, |
| 2603 | expectedError: expectedError, |
| 2604 | }) |
| 2605 | } |
| 2606 | } |
| 2607 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2608 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2609 | const bogusCipher = 0xfe00 |
| 2610 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2611 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2612 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2613 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame^] | 2614 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2615 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2616 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2617 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2618 | |
| 2619 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2620 | name: "NoSharedCipher", |
| 2621 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2622 | MaxVersion: VersionTLS12, |
| 2623 | CipherSuites: []uint16{}, |
| 2624 | }, |
| 2625 | shouldFail: true, |
| 2626 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2627 | }) |
| 2628 | |
| 2629 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2630 | name: "NoSharedCipher-TLS13", |
| 2631 | config: Config{ |
| 2632 | MaxVersion: VersionTLS13, |
| 2633 | CipherSuites: []uint16{}, |
| 2634 | }, |
| 2635 | shouldFail: true, |
| 2636 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2637 | }) |
| 2638 | |
| 2639 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2640 | name: "UnsupportedCipherSuite", |
| 2641 | config: Config{ |
| 2642 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2643 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2644 | Bugs: ProtocolBugs{ |
| 2645 | IgnorePeerCipherPreferences: true, |
| 2646 | }, |
| 2647 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2648 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2649 | shouldFail: true, |
| 2650 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2651 | }) |
| 2652 | |
| 2653 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2654 | name: "ServerHelloBogusCipher", |
| 2655 | config: Config{ |
| 2656 | MaxVersion: VersionTLS12, |
| 2657 | Bugs: ProtocolBugs{ |
| 2658 | SendCipherSuite: bogusCipher, |
| 2659 | }, |
| 2660 | }, |
| 2661 | shouldFail: true, |
| 2662 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2663 | }) |
| 2664 | testCases = append(testCases, testCase{ |
| 2665 | name: "ServerHelloBogusCipher-TLS13", |
| 2666 | config: Config{ |
| 2667 | MaxVersion: VersionTLS13, |
| 2668 | Bugs: ProtocolBugs{ |
| 2669 | SendCipherSuite: bogusCipher, |
| 2670 | }, |
| 2671 | }, |
| 2672 | shouldFail: true, |
| 2673 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2674 | }) |
| 2675 | |
| 2676 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2677 | name: "WeakDH", |
| 2678 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2679 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2680 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2681 | Bugs: ProtocolBugs{ |
| 2682 | // This is a 1023-bit prime number, generated |
| 2683 | // with: |
| 2684 | // openssl gendh 1023 | openssl asn1parse -i |
| 2685 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2686 | }, |
| 2687 | }, |
| 2688 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2689 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2690 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2691 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2692 | testCases = append(testCases, testCase{ |
| 2693 | name: "SillyDH", |
| 2694 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2695 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2696 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2697 | Bugs: ProtocolBugs{ |
| 2698 | // This is a 4097-bit prime number, generated |
| 2699 | // with: |
| 2700 | // openssl gendh 4097 | openssl asn1parse -i |
| 2701 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2702 | }, |
| 2703 | }, |
| 2704 | shouldFail: true, |
| 2705 | expectedError: ":DH_P_TOO_LONG:", |
| 2706 | }) |
| 2707 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2708 | // This test ensures that Diffie-Hellman public values are padded with |
| 2709 | // zeros so that they're the same length as the prime. This is to avoid |
| 2710 | // hitting a bug in yaSSL. |
| 2711 | testCases = append(testCases, testCase{ |
| 2712 | testType: serverTest, |
| 2713 | name: "DHPublicValuePadded", |
| 2714 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2715 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2716 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2717 | Bugs: ProtocolBugs{ |
| 2718 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2719 | }, |
| 2720 | }, |
| 2721 | flags: []string{"-use-sparse-dh-prime"}, |
| 2722 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2723 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2724 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2725 | testCases = append(testCases, testCase{ |
| 2726 | testType: serverTest, |
| 2727 | name: "UnknownCipher", |
| 2728 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2729 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2730 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2731 | Bugs: ProtocolBugs{ |
| 2732 | AdvertiseAllConfiguredCiphers: true, |
| 2733 | }, |
| 2734 | }, |
| 2735 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2736 | |
| 2737 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2738 | testCases = append(testCases, testCase{ |
| 2739 | testType: serverTest, |
| 2740 | name: "UnknownCipher-TLS13", |
| 2741 | config: Config{ |
| 2742 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2743 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2744 | Bugs: ProtocolBugs{ |
| 2745 | AdvertiseAllConfiguredCiphers: true, |
| 2746 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2747 | }, |
| 2748 | }) |
| 2749 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2750 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2751 | testCases = append(testCases, testCase{ |
| 2752 | name: "EmptyECDHEPSKHint", |
| 2753 | config: Config{ |
| 2754 | MaxVersion: VersionTLS12, |
| 2755 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2756 | PreSharedKey: []byte("secret"), |
| 2757 | }, |
| 2758 | flags: []string{"-psk", "secret"}, |
| 2759 | }) |
| 2760 | |
| 2761 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2762 | // ServerKeyExchange is sent. |
| 2763 | testCases = append(testCases, testCase{ |
| 2764 | name: "ExplicitEmptyPSKHint", |
| 2765 | config: Config{ |
| 2766 | MaxVersion: VersionTLS12, |
| 2767 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2768 | PreSharedKey: []byte("secret"), |
| 2769 | Bugs: ProtocolBugs{ |
| 2770 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2771 | }, |
| 2772 | }, |
| 2773 | flags: []string{"-psk", "secret"}, |
| 2774 | }) |
| 2775 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2776 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2777 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2778 | // cipher lists and then a connection is made for each member of |
| 2779 | // expectations. The cipher suite that the server selects must match |
| 2780 | // the specified one. |
| 2781 | var versionSpecificCiphersTest = []struct { |
| 2782 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2783 | // expectations is a map from TLS version to cipher suite id. |
| 2784 | expectations map[uint16]uint16 |
| 2785 | }{ |
| 2786 | { |
| 2787 | // Test that the null case (where no version-specific ciphers are set) |
| 2788 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2789 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2790 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2791 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2792 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2793 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2794 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2795 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2796 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2797 | }, |
| 2798 | }, |
| 2799 | { |
| 2800 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2801 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2802 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2803 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2804 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2805 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2806 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2807 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2808 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2809 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2810 | }, |
| 2811 | }, |
| 2812 | { |
| 2813 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2814 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2815 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2816 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2817 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2818 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2819 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2820 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2821 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2822 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2823 | }, |
| 2824 | }, |
| 2825 | { |
| 2826 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2827 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2828 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2829 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2830 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2831 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2832 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2833 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2834 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2835 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2836 | }, |
| 2837 | }, |
| 2838 | } |
| 2839 | |
| 2840 | for i, test := range versionSpecificCiphersTest { |
| 2841 | for version, expectedCipherSuite := range test.expectations { |
| 2842 | flags := []string{"-cipher", test.ciphersDefault} |
| 2843 | if len(test.ciphersTLS10) > 0 { |
| 2844 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2845 | } |
| 2846 | if len(test.ciphersTLS11) > 0 { |
| 2847 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2848 | } |
| 2849 | |
| 2850 | testCases = append(testCases, testCase{ |
| 2851 | testType: serverTest, |
| 2852 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2853 | config: Config{ |
| 2854 | MaxVersion: version, |
| 2855 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2856 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA}, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2857 | }, |
| 2858 | flags: flags, |
| 2859 | expectedCipher: expectedCipherSuite, |
| 2860 | }) |
| 2861 | } |
| 2862 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2863 | } |
| 2864 | |
| 2865 | func addBadECDSASignatureTests() { |
| 2866 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2867 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2868 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2869 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2870 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2871 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2872 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2873 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2874 | Bugs: ProtocolBugs{ |
| 2875 | BadECDSAR: badR, |
| 2876 | BadECDSAS: badS, |
| 2877 | }, |
| 2878 | }, |
| 2879 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2880 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2881 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2882 | testCases = append(testCases, testCase{ |
| 2883 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2884 | config: Config{ |
| 2885 | MaxVersion: VersionTLS13, |
| 2886 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2887 | Bugs: ProtocolBugs{ |
| 2888 | BadECDSAR: badR, |
| 2889 | BadECDSAS: badS, |
| 2890 | }, |
| 2891 | }, |
| 2892 | shouldFail: true, |
| 2893 | expectedError: ":BAD_SIGNATURE:", |
| 2894 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2895 | } |
| 2896 | } |
| 2897 | } |
| 2898 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2899 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2900 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2901 | name: "MaxCBCPadding", |
| 2902 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2903 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2904 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2905 | Bugs: ProtocolBugs{ |
| 2906 | MaxPadding: true, |
| 2907 | }, |
| 2908 | }, |
| 2909 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2910 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2911 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2912 | name: "BadCBCPadding", |
| 2913 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2914 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2915 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2916 | Bugs: ProtocolBugs{ |
| 2917 | PaddingFirstByteBad: true, |
| 2918 | }, |
| 2919 | }, |
| 2920 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2921 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2922 | }) |
| 2923 | // OpenSSL previously had an issue where the first byte of padding in |
| 2924 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2925 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2926 | name: "BadCBCPadding255", |
| 2927 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2928 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2929 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2930 | Bugs: ProtocolBugs{ |
| 2931 | MaxPadding: true, |
| 2932 | PaddingFirstByteBadIf255: true, |
| 2933 | }, |
| 2934 | }, |
| 2935 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 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 | } |
| 2940 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2941 | func addCBCSplittingTests() { |
| 2942 | testCases = append(testCases, testCase{ |
| 2943 | name: "CBCRecordSplitting", |
| 2944 | config: Config{ |
| 2945 | MaxVersion: VersionTLS10, |
| 2946 | MinVersion: VersionTLS10, |
| 2947 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2948 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2949 | messageLen: -1, // read until EOF |
| 2950 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2951 | flags: []string{ |
| 2952 | "-async", |
| 2953 | "-write-different-record-sizes", |
| 2954 | "-cbc-record-splitting", |
| 2955 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2956 | }) |
| 2957 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2958 | name: "CBCRecordSplittingPartialWrite", |
| 2959 | config: Config{ |
| 2960 | MaxVersion: VersionTLS10, |
| 2961 | MinVersion: VersionTLS10, |
| 2962 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2963 | }, |
| 2964 | messageLen: -1, // read until EOF |
| 2965 | flags: []string{ |
| 2966 | "-async", |
| 2967 | "-write-different-record-sizes", |
| 2968 | "-cbc-record-splitting", |
| 2969 | "-partial-write", |
| 2970 | }, |
| 2971 | }) |
| 2972 | } |
| 2973 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2974 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2975 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2976 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2977 | certPool := x509.NewCertPool() |
| 2978 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2979 | if err != nil { |
| 2980 | panic(err) |
| 2981 | } |
| 2982 | certPool.AddCert(cert) |
| 2983 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2984 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2985 | testCases = append(testCases, testCase{ |
| 2986 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2987 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2988 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2989 | MinVersion: ver.version, |
| 2990 | MaxVersion: ver.version, |
| 2991 | ClientAuth: RequireAnyClientCert, |
| 2992 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2993 | }, |
| 2994 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2995 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2996 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2997 | }, |
| 2998 | }) |
| 2999 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3000 | testType: serverTest, |
| 3001 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3002 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3003 | MinVersion: ver.version, |
| 3004 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3005 | Certificates: []Certificate{rsaCertificate}, |
| 3006 | }, |
| 3007 | flags: []string{"-require-any-client-certificate"}, |
| 3008 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3009 | if ver.version != VersionSSL30 { |
| 3010 | testCases = append(testCases, testCase{ |
| 3011 | testType: serverTest, |
| 3012 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3013 | config: Config{ |
| 3014 | MinVersion: ver.version, |
| 3015 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3016 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3017 | }, |
| 3018 | flags: []string{"-require-any-client-certificate"}, |
| 3019 | }) |
| 3020 | testCases = append(testCases, testCase{ |
| 3021 | testType: clientTest, |
| 3022 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3023 | config: Config{ |
| 3024 | MinVersion: ver.version, |
| 3025 | MaxVersion: ver.version, |
| 3026 | ClientAuth: RequireAnyClientCert, |
| 3027 | ClientCAs: certPool, |
| 3028 | }, |
| 3029 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3030 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3031 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3032 | }, |
| 3033 | }) |
| 3034 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3035 | |
| 3036 | testCases = append(testCases, testCase{ |
| 3037 | name: "NoClientCertificate-" + ver.name, |
| 3038 | config: Config{ |
| 3039 | MinVersion: ver.version, |
| 3040 | MaxVersion: ver.version, |
| 3041 | ClientAuth: RequireAnyClientCert, |
| 3042 | }, |
| 3043 | shouldFail: true, |
| 3044 | expectedLocalError: "client didn't provide a certificate", |
| 3045 | }) |
| 3046 | |
| 3047 | testCases = append(testCases, testCase{ |
| 3048 | // Even if not configured to expect a certificate, OpenSSL will |
| 3049 | // return X509_V_OK as the verify_result. |
| 3050 | testType: serverTest, |
| 3051 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3052 | config: Config{ |
| 3053 | MinVersion: ver.version, |
| 3054 | MaxVersion: ver.version, |
| 3055 | }, |
| 3056 | flags: []string{ |
| 3057 | "-expect-verify-result", |
| 3058 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3059 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3060 | }) |
| 3061 | |
| 3062 | testCases = append(testCases, testCase{ |
| 3063 | // If a client certificate is not provided, OpenSSL will still |
| 3064 | // return X509_V_OK as the verify_result. |
| 3065 | testType: serverTest, |
| 3066 | name: "NoClientCertificate-Server-" + ver.name, |
| 3067 | config: Config{ |
| 3068 | MinVersion: ver.version, |
| 3069 | MaxVersion: ver.version, |
| 3070 | }, |
| 3071 | flags: []string{ |
| 3072 | "-expect-verify-result", |
| 3073 | "-verify-peer", |
| 3074 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3075 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3076 | }) |
| 3077 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3078 | certificateRequired := "remote error: certificate required" |
| 3079 | if ver.version < VersionTLS13 { |
| 3080 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3081 | // was used. |
| 3082 | certificateRequired = "remote error: handshake failure" |
| 3083 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3084 | testCases = append(testCases, testCase{ |
| 3085 | testType: serverTest, |
| 3086 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3087 | config: Config{ |
| 3088 | MinVersion: ver.version, |
| 3089 | MaxVersion: ver.version, |
| 3090 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3091 | flags: []string{"-require-any-client-certificate"}, |
| 3092 | shouldFail: true, |
| 3093 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3094 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3095 | }) |
| 3096 | |
| 3097 | if ver.version != VersionSSL30 { |
| 3098 | testCases = append(testCases, testCase{ |
| 3099 | testType: serverTest, |
| 3100 | name: "SkipClientCertificate-" + ver.name, |
| 3101 | config: Config{ |
| 3102 | MinVersion: ver.version, |
| 3103 | MaxVersion: ver.version, |
| 3104 | Bugs: ProtocolBugs{ |
| 3105 | SkipClientCertificate: true, |
| 3106 | }, |
| 3107 | }, |
| 3108 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3109 | flags: []string{"-verify-peer"}, |
| 3110 | shouldFail: true, |
| 3111 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3112 | }) |
| 3113 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3114 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3115 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3116 | // Client auth is only legal in certificate-based ciphers. |
| 3117 | testCases = append(testCases, testCase{ |
| 3118 | testType: clientTest, |
| 3119 | name: "ClientAuth-PSK", |
| 3120 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3121 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3122 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3123 | PreSharedKey: []byte("secret"), |
| 3124 | ClientAuth: RequireAnyClientCert, |
| 3125 | }, |
| 3126 | flags: []string{ |
| 3127 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3128 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3129 | "-psk", "secret", |
| 3130 | }, |
| 3131 | shouldFail: true, |
| 3132 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3133 | }) |
| 3134 | testCases = append(testCases, testCase{ |
| 3135 | testType: clientTest, |
| 3136 | name: "ClientAuth-ECDHE_PSK", |
| 3137 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3138 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3139 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3140 | PreSharedKey: []byte("secret"), |
| 3141 | ClientAuth: RequireAnyClientCert, |
| 3142 | }, |
| 3143 | flags: []string{ |
| 3144 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3145 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3146 | "-psk", "secret", |
| 3147 | }, |
| 3148 | shouldFail: true, |
| 3149 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3150 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3151 | |
| 3152 | // Regression test for a bug where the client CA list, if explicitly |
| 3153 | // set to NULL, was mis-encoded. |
| 3154 | testCases = append(testCases, testCase{ |
| 3155 | testType: serverTest, |
| 3156 | name: "Null-Client-CA-List", |
| 3157 | config: Config{ |
| 3158 | MaxVersion: VersionTLS12, |
| 3159 | Certificates: []Certificate{rsaCertificate}, |
| 3160 | }, |
| 3161 | flags: []string{ |
| 3162 | "-require-any-client-certificate", |
| 3163 | "-use-null-client-ca-list", |
| 3164 | }, |
| 3165 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3166 | } |
| 3167 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3168 | func addExtendedMasterSecretTests() { |
| 3169 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3170 | |
| 3171 | for _, with := range []bool{false, true} { |
| 3172 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3173 | if with { |
| 3174 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3175 | } |
| 3176 | |
| 3177 | for _, isClient := range []bool{false, true} { |
| 3178 | suffix := "-Server" |
| 3179 | testType := serverTest |
| 3180 | if isClient { |
| 3181 | suffix = "-Client" |
| 3182 | testType = clientTest |
| 3183 | } |
| 3184 | |
| 3185 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3186 | // In TLS 1.3, the extension is irrelevant and |
| 3187 | // always reports as enabled. |
| 3188 | var flags []string |
| 3189 | if with || ver.version >= VersionTLS13 { |
| 3190 | flags = []string{expectEMSFlag} |
| 3191 | } |
| 3192 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3193 | test := testCase{ |
| 3194 | testType: testType, |
| 3195 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3196 | config: Config{ |
| 3197 | MinVersion: ver.version, |
| 3198 | MaxVersion: ver.version, |
| 3199 | Bugs: ProtocolBugs{ |
| 3200 | NoExtendedMasterSecret: !with, |
| 3201 | RequireExtendedMasterSecret: with, |
| 3202 | }, |
| 3203 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3204 | flags: flags, |
| 3205 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3206 | } |
| 3207 | if test.shouldFail { |
| 3208 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3209 | } |
| 3210 | testCases = append(testCases, test) |
| 3211 | } |
| 3212 | } |
| 3213 | } |
| 3214 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3215 | for _, isClient := range []bool{false, true} { |
| 3216 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3217 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3218 | boolToWord := func(b bool) string { |
| 3219 | if b { |
| 3220 | return "Yes" |
| 3221 | } |
| 3222 | return "No" |
| 3223 | } |
| 3224 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3225 | if isClient { |
| 3226 | suffix += "Client" |
| 3227 | } else { |
| 3228 | suffix += "Server" |
| 3229 | } |
| 3230 | |
| 3231 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3232 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3233 | Bugs: ProtocolBugs{ |
| 3234 | RequireExtendedMasterSecret: true, |
| 3235 | }, |
| 3236 | } |
| 3237 | |
| 3238 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3239 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3240 | Bugs: ProtocolBugs{ |
| 3241 | NoExtendedMasterSecret: true, |
| 3242 | }, |
| 3243 | } |
| 3244 | |
| 3245 | test := testCase{ |
| 3246 | name: "ExtendedMasterSecret-" + suffix, |
| 3247 | resumeSession: true, |
| 3248 | } |
| 3249 | |
| 3250 | if !isClient { |
| 3251 | test.testType = serverTest |
| 3252 | } |
| 3253 | |
| 3254 | if supportedInFirstConnection { |
| 3255 | test.config = supportedConfig |
| 3256 | } else { |
| 3257 | test.config = noSupportConfig |
| 3258 | } |
| 3259 | |
| 3260 | if supportedInResumeConnection { |
| 3261 | test.resumeConfig = &supportedConfig |
| 3262 | } else { |
| 3263 | test.resumeConfig = &noSupportConfig |
| 3264 | } |
| 3265 | |
| 3266 | switch suffix { |
| 3267 | case "YesToYes-Client", "YesToYes-Server": |
| 3268 | // When a session is resumed, it should |
| 3269 | // still be aware that its master |
| 3270 | // secret was generated via EMS and |
| 3271 | // thus it's safe to use tls-unique. |
| 3272 | test.flags = []string{expectEMSFlag} |
| 3273 | case "NoToYes-Server": |
| 3274 | // If an original connection did not |
| 3275 | // contain EMS, but a resumption |
| 3276 | // handshake does, then a server should |
| 3277 | // not resume the session. |
| 3278 | test.expectResumeRejected = true |
| 3279 | case "YesToNo-Server": |
| 3280 | // Resuming an EMS session without the |
| 3281 | // EMS extension should cause the |
| 3282 | // server to abort the connection. |
| 3283 | test.shouldFail = true |
| 3284 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3285 | case "NoToYes-Client": |
| 3286 | // A client should abort a connection |
| 3287 | // where the server resumed a non-EMS |
| 3288 | // session but echoed the EMS |
| 3289 | // extension. |
| 3290 | test.shouldFail = true |
| 3291 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3292 | case "YesToNo-Client": |
| 3293 | // A client should abort a connection |
| 3294 | // where the server didn't echo EMS |
| 3295 | // when the session used it. |
| 3296 | test.shouldFail = true |
| 3297 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3298 | } |
| 3299 | |
| 3300 | testCases = append(testCases, test) |
| 3301 | } |
| 3302 | } |
| 3303 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3304 | |
| 3305 | // Switching EMS on renegotiation is forbidden. |
| 3306 | testCases = append(testCases, testCase{ |
| 3307 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3308 | config: Config{ |
| 3309 | MaxVersion: VersionTLS12, |
| 3310 | Bugs: ProtocolBugs{ |
| 3311 | NoExtendedMasterSecret: true, |
| 3312 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3313 | }, |
| 3314 | }, |
| 3315 | renegotiate: 1, |
| 3316 | flags: []string{ |
| 3317 | "-renegotiate-freely", |
| 3318 | "-expect-total-renegotiations", "1", |
| 3319 | }, |
| 3320 | }) |
| 3321 | |
| 3322 | testCases = append(testCases, testCase{ |
| 3323 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3324 | config: Config{ |
| 3325 | MaxVersion: VersionTLS12, |
| 3326 | Bugs: ProtocolBugs{ |
| 3327 | NoExtendedMasterSecret: true, |
| 3328 | }, |
| 3329 | }, |
| 3330 | renegotiate: 1, |
| 3331 | flags: []string{ |
| 3332 | "-renegotiate-freely", |
| 3333 | "-expect-total-renegotiations", "1", |
| 3334 | }, |
| 3335 | shouldFail: true, |
| 3336 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3337 | }) |
| 3338 | |
| 3339 | testCases = append(testCases, testCase{ |
| 3340 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3341 | config: Config{ |
| 3342 | MaxVersion: VersionTLS12, |
| 3343 | Bugs: ProtocolBugs{ |
| 3344 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3345 | }, |
| 3346 | }, |
| 3347 | renegotiate: 1, |
| 3348 | flags: []string{ |
| 3349 | "-renegotiate-freely", |
| 3350 | "-expect-total-renegotiations", "1", |
| 3351 | }, |
| 3352 | shouldFail: true, |
| 3353 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3354 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3355 | } |
| 3356 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3357 | type stateMachineTestConfig struct { |
| 3358 | protocol protocol |
| 3359 | async bool |
| 3360 | splitHandshake, packHandshakeFlight bool |
| 3361 | } |
| 3362 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3363 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3364 | // various conditions. Some of these are redundant with other tests, but they |
| 3365 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3366 | func addAllStateMachineCoverageTests() { |
| 3367 | for _, async := range []bool{false, true} { |
| 3368 | for _, protocol := range []protocol{tls, dtls} { |
| 3369 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3370 | protocol: protocol, |
| 3371 | async: async, |
| 3372 | }) |
| 3373 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3374 | protocol: protocol, |
| 3375 | async: async, |
| 3376 | splitHandshake: true, |
| 3377 | }) |
| 3378 | if protocol == tls { |
| 3379 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3380 | protocol: protocol, |
| 3381 | async: async, |
| 3382 | packHandshakeFlight: true, |
| 3383 | }) |
| 3384 | } |
| 3385 | } |
| 3386 | } |
| 3387 | } |
| 3388 | |
| 3389 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3390 | var tests []testCase |
| 3391 | |
| 3392 | // Basic handshake, with resumption. Client and server, |
| 3393 | // session ID and session ticket. |
| 3394 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3395 | name: "Basic-Client", |
| 3396 | config: Config{ |
| 3397 | MaxVersion: VersionTLS12, |
| 3398 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3399 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3400 | // Ensure session tickets are used, not session IDs. |
| 3401 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3402 | }) |
| 3403 | tests = append(tests, testCase{ |
| 3404 | name: "Basic-Client-RenewTicket", |
| 3405 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3406 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3407 | Bugs: ProtocolBugs{ |
| 3408 | RenewTicketOnResume: true, |
| 3409 | }, |
| 3410 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3411 | flags: []string{"-expect-ticket-renewal"}, |
| 3412 | resumeSession: true, |
| 3413 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3414 | }) |
| 3415 | tests = append(tests, testCase{ |
| 3416 | name: "Basic-Client-NoTicket", |
| 3417 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3418 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3419 | SessionTicketsDisabled: true, |
| 3420 | }, |
| 3421 | resumeSession: true, |
| 3422 | }) |
| 3423 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3424 | name: "Basic-Client-Implicit", |
| 3425 | config: Config{ |
| 3426 | MaxVersion: VersionTLS12, |
| 3427 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3428 | flags: []string{"-implicit-handshake"}, |
| 3429 | resumeSession: true, |
| 3430 | }) |
| 3431 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3432 | testType: serverTest, |
| 3433 | name: "Basic-Server", |
| 3434 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3435 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3436 | Bugs: ProtocolBugs{ |
| 3437 | RequireSessionTickets: true, |
| 3438 | }, |
| 3439 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3440 | resumeSession: true, |
| 3441 | }) |
| 3442 | tests = append(tests, testCase{ |
| 3443 | testType: serverTest, |
| 3444 | name: "Basic-Server-NoTickets", |
| 3445 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3446 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3447 | SessionTicketsDisabled: true, |
| 3448 | }, |
| 3449 | resumeSession: true, |
| 3450 | }) |
| 3451 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3452 | testType: serverTest, |
| 3453 | name: "Basic-Server-Implicit", |
| 3454 | config: Config{ |
| 3455 | MaxVersion: VersionTLS12, |
| 3456 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3457 | flags: []string{"-implicit-handshake"}, |
| 3458 | resumeSession: true, |
| 3459 | }) |
| 3460 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3461 | testType: serverTest, |
| 3462 | name: "Basic-Server-EarlyCallback", |
| 3463 | config: Config{ |
| 3464 | MaxVersion: VersionTLS12, |
| 3465 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3466 | flags: []string{"-use-early-callback"}, |
| 3467 | resumeSession: true, |
| 3468 | }) |
| 3469 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3470 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3471 | if config.protocol == tls { |
| 3472 | tests = append(tests, testCase{ |
| 3473 | name: "TLS13-1RTT-Client", |
| 3474 | config: Config{ |
| 3475 | MaxVersion: VersionTLS13, |
| 3476 | MinVersion: VersionTLS13, |
| 3477 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3478 | resumeSession: true, |
| 3479 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3480 | }) |
| 3481 | |
| 3482 | tests = append(tests, testCase{ |
| 3483 | testType: serverTest, |
| 3484 | name: "TLS13-1RTT-Server", |
| 3485 | config: Config{ |
| 3486 | MaxVersion: VersionTLS13, |
| 3487 | MinVersion: VersionTLS13, |
| 3488 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3489 | resumeSession: true, |
| 3490 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3491 | }) |
| 3492 | |
| 3493 | tests = append(tests, testCase{ |
| 3494 | name: "TLS13-HelloRetryRequest-Client", |
| 3495 | config: Config{ |
| 3496 | MaxVersion: VersionTLS13, |
| 3497 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3498 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3499 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3500 | CurvePreferences: []CurveID{CurveP384}, |
| 3501 | Bugs: ProtocolBugs{ |
| 3502 | ExpectMissingKeyShare: true, |
| 3503 | }, |
| 3504 | }, |
| 3505 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3506 | resumeSession: true, |
| 3507 | }) |
| 3508 | |
| 3509 | tests = append(tests, testCase{ |
| 3510 | testType: serverTest, |
| 3511 | name: "TLS13-HelloRetryRequest-Server", |
| 3512 | config: Config{ |
| 3513 | MaxVersion: VersionTLS13, |
| 3514 | MinVersion: VersionTLS13, |
| 3515 | // Require a HelloRetryRequest for every curve. |
| 3516 | DefaultCurves: []CurveID{}, |
| 3517 | }, |
| 3518 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3519 | resumeSession: true, |
| 3520 | }) |
| 3521 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3522 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3523 | // TLS client auth. |
| 3524 | tests = append(tests, testCase{ |
| 3525 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3526 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3527 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3528 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3529 | ClientAuth: RequestClientCert, |
| 3530 | }, |
| 3531 | }) |
| 3532 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3533 | testType: serverTest, |
| 3534 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3535 | config: Config{ |
| 3536 | MaxVersion: VersionTLS12, |
| 3537 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3538 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3539 | flags: []string{"-verify-peer"}, |
| 3540 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3541 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3542 | tests = append(tests, testCase{ |
| 3543 | testType: clientTest, |
| 3544 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3545 | config: Config{ |
| 3546 | MaxVersion: VersionSSL30, |
| 3547 | ClientAuth: RequestClientCert, |
| 3548 | }, |
| 3549 | }) |
| 3550 | tests = append(tests, testCase{ |
| 3551 | testType: serverTest, |
| 3552 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3553 | config: Config{ |
| 3554 | MaxVersion: VersionSSL30, |
| 3555 | }, |
| 3556 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3557 | flags: []string{"-verify-peer"}, |
| 3558 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3559 | tests = append(tests, testCase{ |
| 3560 | testType: clientTest, |
| 3561 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3562 | config: Config{ |
| 3563 | MaxVersion: VersionTLS13, |
| 3564 | ClientAuth: RequestClientCert, |
| 3565 | }, |
| 3566 | }) |
| 3567 | tests = append(tests, testCase{ |
| 3568 | testType: serverTest, |
| 3569 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3570 | config: Config{ |
| 3571 | MaxVersion: VersionTLS13, |
| 3572 | }, |
| 3573 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3574 | flags: []string{"-verify-peer"}, |
| 3575 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3576 | } |
| 3577 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3578 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3579 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3580 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3581 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3582 | ClientAuth: RequireAnyClientCert, |
| 3583 | }, |
| 3584 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3585 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3586 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3587 | }, |
| 3588 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3589 | tests = append(tests, testCase{ |
| 3590 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3591 | name: "ClientAuth-RSA-Client-TLS13", |
| 3592 | config: Config{ |
| 3593 | MaxVersion: VersionTLS13, |
| 3594 | ClientAuth: RequireAnyClientCert, |
| 3595 | }, |
| 3596 | flags: []string{ |
| 3597 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3598 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3599 | }, |
| 3600 | }) |
| 3601 | tests = append(tests, testCase{ |
| 3602 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3603 | name: "ClientAuth-ECDSA-Client", |
| 3604 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3605 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3606 | ClientAuth: RequireAnyClientCert, |
| 3607 | }, |
| 3608 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3609 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3610 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3611 | }, |
| 3612 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3613 | tests = append(tests, testCase{ |
| 3614 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3615 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3616 | config: Config{ |
| 3617 | MaxVersion: VersionTLS13, |
| 3618 | ClientAuth: RequireAnyClientCert, |
| 3619 | }, |
| 3620 | flags: []string{ |
| 3621 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3622 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3623 | }, |
| 3624 | }) |
| 3625 | tests = append(tests, testCase{ |
| 3626 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3627 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3628 | config: Config{ |
| 3629 | MaxVersion: VersionTLS12, |
| 3630 | ClientAuth: RequestClientCert, |
| 3631 | }, |
| 3632 | flags: []string{"-use-old-client-cert-callback"}, |
| 3633 | }) |
| 3634 | tests = append(tests, testCase{ |
| 3635 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3636 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3637 | config: Config{ |
| 3638 | MaxVersion: VersionTLS13, |
| 3639 | ClientAuth: RequestClientCert, |
| 3640 | }, |
| 3641 | flags: []string{"-use-old-client-cert-callback"}, |
| 3642 | }) |
| 3643 | tests = append(tests, testCase{ |
| 3644 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3645 | name: "ClientAuth-OldCallback", |
| 3646 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3647 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3648 | ClientAuth: RequireAnyClientCert, |
| 3649 | }, |
| 3650 | flags: []string{ |
| 3651 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3652 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3653 | "-use-old-client-cert-callback", |
| 3654 | }, |
| 3655 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3656 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3657 | testType: clientTest, |
| 3658 | name: "ClientAuth-OldCallback-TLS13", |
| 3659 | config: Config{ |
| 3660 | MaxVersion: VersionTLS13, |
| 3661 | ClientAuth: RequireAnyClientCert, |
| 3662 | }, |
| 3663 | flags: []string{ |
| 3664 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3665 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3666 | "-use-old-client-cert-callback", |
| 3667 | }, |
| 3668 | }) |
| 3669 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3670 | testType: serverTest, |
| 3671 | name: "ClientAuth-Server", |
| 3672 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3673 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3674 | Certificates: []Certificate{rsaCertificate}, |
| 3675 | }, |
| 3676 | flags: []string{"-require-any-client-certificate"}, |
| 3677 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3678 | tests = append(tests, testCase{ |
| 3679 | testType: serverTest, |
| 3680 | name: "ClientAuth-Server-TLS13", |
| 3681 | config: Config{ |
| 3682 | MaxVersion: VersionTLS13, |
| 3683 | Certificates: []Certificate{rsaCertificate}, |
| 3684 | }, |
| 3685 | flags: []string{"-require-any-client-certificate"}, |
| 3686 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3687 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3688 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3689 | tests = append(tests, testCase{ |
| 3690 | testType: serverTest, |
| 3691 | name: "Basic-Server-RSA", |
| 3692 | config: Config{ |
| 3693 | MaxVersion: VersionTLS12, |
| 3694 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3695 | }, |
| 3696 | flags: []string{ |
| 3697 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3698 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3699 | }, |
| 3700 | }) |
| 3701 | tests = append(tests, testCase{ |
| 3702 | testType: serverTest, |
| 3703 | name: "Basic-Server-ECDHE-RSA", |
| 3704 | config: Config{ |
| 3705 | MaxVersion: VersionTLS12, |
| 3706 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3707 | }, |
| 3708 | flags: []string{ |
| 3709 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3710 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3711 | }, |
| 3712 | }) |
| 3713 | tests = append(tests, testCase{ |
| 3714 | testType: serverTest, |
| 3715 | name: "Basic-Server-ECDHE-ECDSA", |
| 3716 | config: Config{ |
| 3717 | MaxVersion: VersionTLS12, |
| 3718 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3719 | }, |
| 3720 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3721 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3722 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3723 | }, |
| 3724 | }) |
| 3725 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3726 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3727 | tests = append(tests, testCase{ |
| 3728 | name: "SessionTicketsDisabled-Client", |
| 3729 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3730 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3731 | SessionTicketsDisabled: true, |
| 3732 | }, |
| 3733 | }) |
| 3734 | tests = append(tests, testCase{ |
| 3735 | testType: serverTest, |
| 3736 | name: "SessionTicketsDisabled-Server", |
| 3737 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3738 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3739 | SessionTicketsDisabled: true, |
| 3740 | }, |
| 3741 | }) |
| 3742 | |
| 3743 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3744 | // identity hint. |
| 3745 | tests = append(tests, testCase{ |
| 3746 | name: "EmptyPSKHint-Client", |
| 3747 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3748 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3749 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3750 | PreSharedKey: []byte("secret"), |
| 3751 | }, |
| 3752 | flags: []string{"-psk", "secret"}, |
| 3753 | }) |
| 3754 | tests = append(tests, testCase{ |
| 3755 | testType: serverTest, |
| 3756 | name: "EmptyPSKHint-Server", |
| 3757 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3758 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3759 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3760 | PreSharedKey: []byte("secret"), |
| 3761 | }, |
| 3762 | flags: []string{"-psk", "secret"}, |
| 3763 | }) |
| 3764 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3765 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3766 | tests = append(tests, testCase{ |
| 3767 | testType: clientTest, |
| 3768 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3769 | config: Config{ |
| 3770 | MaxVersion: VersionTLS12, |
| 3771 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3772 | flags: []string{ |
| 3773 | "-enable-ocsp-stapling", |
| 3774 | "-expect-ocsp-response", |
| 3775 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3776 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3777 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3778 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3779 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3780 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3781 | testType: serverTest, |
| 3782 | name: "OCSPStapling-Server", |
| 3783 | config: Config{ |
| 3784 | MaxVersion: VersionTLS12, |
| 3785 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3786 | expectedOCSPResponse: testOCSPResponse, |
| 3787 | flags: []string{ |
| 3788 | "-ocsp-response", |
| 3789 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3790 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3791 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3792 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3793 | tests = append(tests, testCase{ |
| 3794 | testType: clientTest, |
| 3795 | name: "OCSPStapling-Client-TLS13", |
| 3796 | config: Config{ |
| 3797 | MaxVersion: VersionTLS13, |
| 3798 | }, |
| 3799 | flags: []string{ |
| 3800 | "-enable-ocsp-stapling", |
| 3801 | "-expect-ocsp-response", |
| 3802 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3803 | "-verify-peer", |
| 3804 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3805 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3806 | }) |
| 3807 | tests = append(tests, testCase{ |
| 3808 | testType: serverTest, |
| 3809 | name: "OCSPStapling-Server-TLS13", |
| 3810 | config: Config{ |
| 3811 | MaxVersion: VersionTLS13, |
| 3812 | }, |
| 3813 | expectedOCSPResponse: testOCSPResponse, |
| 3814 | flags: []string{ |
| 3815 | "-ocsp-response", |
| 3816 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3817 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3818 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3819 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3820 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3821 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3822 | for _, vers := range tlsVersions { |
| 3823 | if config.protocol == dtls && !vers.hasDTLS { |
| 3824 | continue |
| 3825 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3826 | for _, testType := range []testType{clientTest, serverTest} { |
| 3827 | suffix := "-Client" |
| 3828 | if testType == serverTest { |
| 3829 | suffix = "-Server" |
| 3830 | } |
| 3831 | suffix += "-" + vers.name |
| 3832 | |
| 3833 | flag := "-verify-peer" |
| 3834 | if testType == serverTest { |
| 3835 | flag = "-require-any-client-certificate" |
| 3836 | } |
| 3837 | |
| 3838 | tests = append(tests, testCase{ |
| 3839 | testType: testType, |
| 3840 | name: "CertificateVerificationSucceed" + suffix, |
| 3841 | config: Config{ |
| 3842 | MaxVersion: vers.version, |
| 3843 | Certificates: []Certificate{rsaCertificate}, |
| 3844 | }, |
| 3845 | flags: []string{ |
| 3846 | flag, |
| 3847 | "-expect-verify-result", |
| 3848 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3849 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3850 | }) |
| 3851 | tests = append(tests, testCase{ |
| 3852 | testType: testType, |
| 3853 | name: "CertificateVerificationFail" + suffix, |
| 3854 | config: Config{ |
| 3855 | MaxVersion: vers.version, |
| 3856 | Certificates: []Certificate{rsaCertificate}, |
| 3857 | }, |
| 3858 | flags: []string{ |
| 3859 | flag, |
| 3860 | "-verify-fail", |
| 3861 | }, |
| 3862 | shouldFail: true, |
| 3863 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3864 | }) |
| 3865 | } |
| 3866 | |
| 3867 | // By default, the client is in a soft fail mode where the peer |
| 3868 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3869 | tests = append(tests, testCase{ |
| 3870 | testType: clientTest, |
| 3871 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3872 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3873 | MaxVersion: vers.version, |
| 3874 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3875 | }, |
| 3876 | flags: []string{ |
| 3877 | "-verify-fail", |
| 3878 | "-expect-verify-result", |
| 3879 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3880 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3881 | }) |
| 3882 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3883 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3884 | tests = append(tests, testCase{ |
| 3885 | name: "ShimSendAlert", |
| 3886 | flags: []string{"-send-alert"}, |
| 3887 | shimWritesFirst: true, |
| 3888 | shouldFail: true, |
| 3889 | expectedLocalError: "remote error: decompression failure", |
| 3890 | }) |
| 3891 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3892 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3893 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3894 | name: "Renegotiate-Client", |
| 3895 | config: Config{ |
| 3896 | MaxVersion: VersionTLS12, |
| 3897 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3898 | renegotiate: 1, |
| 3899 | flags: []string{ |
| 3900 | "-renegotiate-freely", |
| 3901 | "-expect-total-renegotiations", "1", |
| 3902 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3903 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3904 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3905 | tests = append(tests, testCase{ |
| 3906 | name: "SendHalfHelloRequest", |
| 3907 | config: Config{ |
| 3908 | MaxVersion: VersionTLS12, |
| 3909 | Bugs: ProtocolBugs{ |
| 3910 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3911 | }, |
| 3912 | }, |
| 3913 | sendHalfHelloRequest: true, |
| 3914 | flags: []string{"-renegotiate-ignore"}, |
| 3915 | shouldFail: true, |
| 3916 | expectedError: ":UNEXPECTED_RECORD:", |
| 3917 | }) |
| 3918 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3919 | // NPN on client and server; results in post-handshake message. |
| 3920 | tests = append(tests, testCase{ |
| 3921 | name: "NPN-Client", |
| 3922 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3923 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3924 | NextProtos: []string{"foo"}, |
| 3925 | }, |
| 3926 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3927 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3928 | expectedNextProto: "foo", |
| 3929 | expectedNextProtoType: npn, |
| 3930 | }) |
| 3931 | tests = append(tests, testCase{ |
| 3932 | testType: serverTest, |
| 3933 | name: "NPN-Server", |
| 3934 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3935 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3936 | NextProtos: []string{"bar"}, |
| 3937 | }, |
| 3938 | flags: []string{ |
| 3939 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3940 | "-expect-next-proto", "bar", |
| 3941 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3942 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3943 | expectedNextProto: "bar", |
| 3944 | expectedNextProtoType: npn, |
| 3945 | }) |
| 3946 | |
| 3947 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3948 | |
| 3949 | // Client does False Start and negotiates NPN. |
| 3950 | tests = append(tests, testCase{ |
| 3951 | name: "FalseStart", |
| 3952 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3953 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3954 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3955 | NextProtos: []string{"foo"}, |
| 3956 | Bugs: ProtocolBugs{ |
| 3957 | ExpectFalseStart: true, |
| 3958 | }, |
| 3959 | }, |
| 3960 | flags: []string{ |
| 3961 | "-false-start", |
| 3962 | "-select-next-proto", "foo", |
| 3963 | }, |
| 3964 | shimWritesFirst: true, |
| 3965 | resumeSession: true, |
| 3966 | }) |
| 3967 | |
| 3968 | // Client does False Start and negotiates ALPN. |
| 3969 | tests = append(tests, testCase{ |
| 3970 | name: "FalseStart-ALPN", |
| 3971 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3972 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3973 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3974 | NextProtos: []string{"foo"}, |
| 3975 | Bugs: ProtocolBugs{ |
| 3976 | ExpectFalseStart: true, |
| 3977 | }, |
| 3978 | }, |
| 3979 | flags: []string{ |
| 3980 | "-false-start", |
| 3981 | "-advertise-alpn", "\x03foo", |
| 3982 | }, |
| 3983 | shimWritesFirst: true, |
| 3984 | resumeSession: true, |
| 3985 | }) |
| 3986 | |
| 3987 | // Client does False Start but doesn't explicitly call |
| 3988 | // SSL_connect. |
| 3989 | tests = append(tests, testCase{ |
| 3990 | name: "FalseStart-Implicit", |
| 3991 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3992 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3993 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3994 | NextProtos: []string{"foo"}, |
| 3995 | }, |
| 3996 | flags: []string{ |
| 3997 | "-implicit-handshake", |
| 3998 | "-false-start", |
| 3999 | "-advertise-alpn", "\x03foo", |
| 4000 | }, |
| 4001 | }) |
| 4002 | |
| 4003 | // False Start without session tickets. |
| 4004 | tests = append(tests, testCase{ |
| 4005 | name: "FalseStart-SessionTicketsDisabled", |
| 4006 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4007 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4008 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4009 | NextProtos: []string{"foo"}, |
| 4010 | SessionTicketsDisabled: true, |
| 4011 | Bugs: ProtocolBugs{ |
| 4012 | ExpectFalseStart: true, |
| 4013 | }, |
| 4014 | }, |
| 4015 | flags: []string{ |
| 4016 | "-false-start", |
| 4017 | "-select-next-proto", "foo", |
| 4018 | }, |
| 4019 | shimWritesFirst: true, |
| 4020 | }) |
| 4021 | |
| 4022 | // Server parses a V2ClientHello. |
| 4023 | tests = append(tests, testCase{ |
| 4024 | testType: serverTest, |
| 4025 | name: "SendV2ClientHello", |
| 4026 | config: Config{ |
| 4027 | // Choose a cipher suite that does not involve |
| 4028 | // elliptic curves, so no extensions are |
| 4029 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4030 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4031 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4032 | Bugs: ProtocolBugs{ |
| 4033 | SendV2ClientHello: true, |
| 4034 | }, |
| 4035 | }, |
| 4036 | }) |
| 4037 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4038 | // Test Channel ID |
| 4039 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4040 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4041 | continue |
| 4042 | } |
| 4043 | // Client sends a Channel ID. |
| 4044 | tests = append(tests, testCase{ |
| 4045 | name: "ChannelID-Client-" + ver.name, |
| 4046 | config: Config{ |
| 4047 | MaxVersion: ver.version, |
| 4048 | RequestChannelID: true, |
| 4049 | }, |
| 4050 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4051 | resumeSession: true, |
| 4052 | expectChannelID: true, |
| 4053 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4054 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4055 | // Server accepts a Channel ID. |
| 4056 | tests = append(tests, testCase{ |
| 4057 | testType: serverTest, |
| 4058 | name: "ChannelID-Server-" + ver.name, |
| 4059 | config: Config{ |
| 4060 | MaxVersion: ver.version, |
| 4061 | ChannelID: channelIDKey, |
| 4062 | }, |
| 4063 | flags: []string{ |
| 4064 | "-expect-channel-id", |
| 4065 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4066 | }, |
| 4067 | resumeSession: true, |
| 4068 | expectChannelID: true, |
| 4069 | }) |
| 4070 | |
| 4071 | tests = append(tests, testCase{ |
| 4072 | testType: serverTest, |
| 4073 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4074 | config: Config{ |
| 4075 | MaxVersion: ver.version, |
| 4076 | ChannelID: channelIDKey, |
| 4077 | Bugs: ProtocolBugs{ |
| 4078 | InvalidChannelIDSignature: true, |
| 4079 | }, |
| 4080 | }, |
| 4081 | flags: []string{"-enable-channel-id"}, |
| 4082 | shouldFail: true, |
| 4083 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4084 | }) |
| 4085 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4086 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4087 | // Channel ID and NPN at the same time, to ensure their relative |
| 4088 | // ordering is correct. |
| 4089 | tests = append(tests, testCase{ |
| 4090 | name: "ChannelID-NPN-Client", |
| 4091 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4092 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4093 | RequestChannelID: true, |
| 4094 | NextProtos: []string{"foo"}, |
| 4095 | }, |
| 4096 | flags: []string{ |
| 4097 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4098 | "-select-next-proto", "foo", |
| 4099 | }, |
| 4100 | resumeSession: true, |
| 4101 | expectChannelID: true, |
| 4102 | expectedNextProto: "foo", |
| 4103 | expectedNextProtoType: npn, |
| 4104 | }) |
| 4105 | tests = append(tests, testCase{ |
| 4106 | testType: serverTest, |
| 4107 | name: "ChannelID-NPN-Server", |
| 4108 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4109 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4110 | ChannelID: channelIDKey, |
| 4111 | NextProtos: []string{"bar"}, |
| 4112 | }, |
| 4113 | flags: []string{ |
| 4114 | "-expect-channel-id", |
| 4115 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4116 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4117 | "-expect-next-proto", "bar", |
| 4118 | }, |
| 4119 | resumeSession: true, |
| 4120 | expectChannelID: true, |
| 4121 | expectedNextProto: "bar", |
| 4122 | expectedNextProtoType: npn, |
| 4123 | }) |
| 4124 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4125 | // Bidirectional shutdown with the runner initiating. |
| 4126 | tests = append(tests, testCase{ |
| 4127 | name: "Shutdown-Runner", |
| 4128 | config: Config{ |
| 4129 | Bugs: ProtocolBugs{ |
| 4130 | ExpectCloseNotify: true, |
| 4131 | }, |
| 4132 | }, |
| 4133 | flags: []string{"-check-close-notify"}, |
| 4134 | }) |
| 4135 | |
| 4136 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4137 | // in the meantime, sends garbage before the close_notify which |
| 4138 | // the shim must ignore. |
| 4139 | tests = append(tests, testCase{ |
| 4140 | name: "Shutdown-Shim", |
| 4141 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4142 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4143 | Bugs: ProtocolBugs{ |
| 4144 | ExpectCloseNotify: true, |
| 4145 | }, |
| 4146 | }, |
| 4147 | shimShutsDown: true, |
| 4148 | sendEmptyRecords: 1, |
| 4149 | sendWarningAlerts: 1, |
| 4150 | flags: []string{"-check-close-notify"}, |
| 4151 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4152 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4153 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4154 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4155 | tests = append(tests, testCase{ |
| 4156 | name: "SkipHelloVerifyRequest", |
| 4157 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4158 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4159 | Bugs: ProtocolBugs{ |
| 4160 | SkipHelloVerifyRequest: true, |
| 4161 | }, |
| 4162 | }, |
| 4163 | }) |
| 4164 | } |
| 4165 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4166 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4167 | test.protocol = config.protocol |
| 4168 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4169 | test.name += "-DTLS" |
| 4170 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4171 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4172 | test.name += "-Async" |
| 4173 | test.flags = append(test.flags, "-async") |
| 4174 | } else { |
| 4175 | test.name += "-Sync" |
| 4176 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4177 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4178 | test.name += "-SplitHandshakeRecords" |
| 4179 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4180 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4181 | test.config.Bugs.MaxPacketLength = 256 |
| 4182 | test.flags = append(test.flags, "-mtu", "256") |
| 4183 | } |
| 4184 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4185 | if config.packHandshakeFlight { |
| 4186 | test.name += "-PackHandshakeFlight" |
| 4187 | test.config.Bugs.PackHandshakeFlight = true |
| 4188 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4189 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4190 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4191 | } |
| 4192 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4193 | func addDDoSCallbackTests() { |
| 4194 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4195 | for _, resume := range []bool{false, true} { |
| 4196 | suffix := "Resume" |
| 4197 | if resume { |
| 4198 | suffix = "No" + suffix |
| 4199 | } |
| 4200 | |
| 4201 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4202 | testType: serverTest, |
| 4203 | name: "Server-DDoS-OK-" + suffix, |
| 4204 | config: Config{ |
| 4205 | MaxVersion: VersionTLS12, |
| 4206 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4207 | flags: []string{"-install-ddos-callback"}, |
| 4208 | resumeSession: resume, |
| 4209 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4210 | testCases = append(testCases, testCase{ |
| 4211 | testType: serverTest, |
| 4212 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4213 | config: Config{ |
| 4214 | MaxVersion: VersionTLS13, |
| 4215 | }, |
| 4216 | flags: []string{"-install-ddos-callback"}, |
| 4217 | resumeSession: resume, |
| 4218 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4219 | |
| 4220 | failFlag := "-fail-ddos-callback" |
| 4221 | if resume { |
| 4222 | failFlag = "-fail-second-ddos-callback" |
| 4223 | } |
| 4224 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4225 | testType: serverTest, |
| 4226 | name: "Server-DDoS-Reject-" + suffix, |
| 4227 | config: Config{ |
| 4228 | MaxVersion: VersionTLS12, |
| 4229 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4230 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4231 | resumeSession: resume, |
| 4232 | shouldFail: true, |
| 4233 | expectedError: ":CONNECTION_REJECTED:", |
| 4234 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4235 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4236 | testCases = append(testCases, testCase{ |
| 4237 | testType: serverTest, |
| 4238 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4239 | config: Config{ |
| 4240 | MaxVersion: VersionTLS13, |
| 4241 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4242 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4243 | resumeSession: resume, |
| 4244 | shouldFail: true, |
| 4245 | expectedError: ":CONNECTION_REJECTED:", |
| 4246 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4247 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4248 | } |
| 4249 | } |
| 4250 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4251 | func addVersionNegotiationTests() { |
| 4252 | for i, shimVers := range tlsVersions { |
| 4253 | // Assemble flags to disable all newer versions on the shim. |
| 4254 | var flags []string |
| 4255 | for _, vers := range tlsVersions[i+1:] { |
| 4256 | flags = append(flags, vers.flag) |
| 4257 | } |
| 4258 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4259 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4260 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4261 | protocols := []protocol{tls} |
| 4262 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4263 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4264 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4265 | for _, protocol := range protocols { |
| 4266 | expectedVersion := shimVers.version |
| 4267 | if runnerVers.version < shimVers.version { |
| 4268 | expectedVersion = runnerVers.version |
| 4269 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4270 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4271 | suffix := shimVers.name + "-" + runnerVers.name |
| 4272 | if protocol == dtls { |
| 4273 | suffix += "-DTLS" |
| 4274 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4275 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4276 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4277 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4278 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4279 | clientVers := shimVers.version |
| 4280 | if clientVers > VersionTLS10 { |
| 4281 | clientVers = VersionTLS10 |
| 4282 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4283 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4284 | serverVers := expectedVersion |
| 4285 | if expectedVersion >= VersionTLS13 { |
| 4286 | serverVers = VersionTLS10 |
| 4287 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4288 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4289 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4290 | testCases = append(testCases, testCase{ |
| 4291 | protocol: protocol, |
| 4292 | testType: clientTest, |
| 4293 | name: "VersionNegotiation-Client-" + suffix, |
| 4294 | config: Config{ |
| 4295 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4296 | Bugs: ProtocolBugs{ |
| 4297 | ExpectInitialRecordVersion: clientVers, |
| 4298 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4299 | }, |
| 4300 | flags: flags, |
| 4301 | expectedVersion: expectedVersion, |
| 4302 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4303 | testCases = append(testCases, testCase{ |
| 4304 | protocol: protocol, |
| 4305 | testType: clientTest, |
| 4306 | name: "VersionNegotiation-Client2-" + suffix, |
| 4307 | config: Config{ |
| 4308 | MaxVersion: runnerVers.version, |
| 4309 | Bugs: ProtocolBugs{ |
| 4310 | ExpectInitialRecordVersion: clientVers, |
| 4311 | }, |
| 4312 | }, |
| 4313 | flags: []string{"-max-version", shimVersFlag}, |
| 4314 | expectedVersion: expectedVersion, |
| 4315 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4316 | |
| 4317 | testCases = append(testCases, testCase{ |
| 4318 | protocol: protocol, |
| 4319 | testType: serverTest, |
| 4320 | name: "VersionNegotiation-Server-" + suffix, |
| 4321 | config: Config{ |
| 4322 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4323 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4324 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4325 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4326 | }, |
| 4327 | flags: flags, |
| 4328 | expectedVersion: expectedVersion, |
| 4329 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4330 | testCases = append(testCases, testCase{ |
| 4331 | protocol: protocol, |
| 4332 | testType: serverTest, |
| 4333 | name: "VersionNegotiation-Server2-" + suffix, |
| 4334 | config: Config{ |
| 4335 | MaxVersion: runnerVers.version, |
| 4336 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4337 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4338 | }, |
| 4339 | }, |
| 4340 | flags: []string{"-max-version", shimVersFlag}, |
| 4341 | expectedVersion: expectedVersion, |
| 4342 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4343 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4344 | } |
| 4345 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4346 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4347 | // Test the version extension at all versions. |
| 4348 | for _, vers := range tlsVersions { |
| 4349 | protocols := []protocol{tls} |
| 4350 | if vers.hasDTLS { |
| 4351 | protocols = append(protocols, dtls) |
| 4352 | } |
| 4353 | for _, protocol := range protocols { |
| 4354 | suffix := vers.name |
| 4355 | if protocol == dtls { |
| 4356 | suffix += "-DTLS" |
| 4357 | } |
| 4358 | |
| 4359 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4360 | testCases = append(testCases, testCase{ |
| 4361 | protocol: protocol, |
| 4362 | testType: serverTest, |
| 4363 | name: "VersionNegotiationExtension-" + suffix, |
| 4364 | config: Config{ |
| 4365 | Bugs: ProtocolBugs{ |
| 4366 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4367 | }, |
| 4368 | }, |
| 4369 | expectedVersion: vers.version, |
| 4370 | }) |
| 4371 | } |
| 4372 | |
| 4373 | } |
| 4374 | |
| 4375 | // If all versions are unknown, negotiation fails. |
| 4376 | testCases = append(testCases, testCase{ |
| 4377 | testType: serverTest, |
| 4378 | name: "NoSupportedVersions", |
| 4379 | config: Config{ |
| 4380 | Bugs: ProtocolBugs{ |
| 4381 | SendSupportedVersions: []uint16{0x1111}, |
| 4382 | }, |
| 4383 | }, |
| 4384 | shouldFail: true, |
| 4385 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4386 | }) |
| 4387 | testCases = append(testCases, testCase{ |
| 4388 | protocol: dtls, |
| 4389 | testType: serverTest, |
| 4390 | name: "NoSupportedVersions-DTLS", |
| 4391 | config: Config{ |
| 4392 | Bugs: ProtocolBugs{ |
| 4393 | SendSupportedVersions: []uint16{0x1111}, |
| 4394 | }, |
| 4395 | }, |
| 4396 | shouldFail: true, |
| 4397 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4398 | }) |
| 4399 | |
| 4400 | testCases = append(testCases, testCase{ |
| 4401 | testType: serverTest, |
| 4402 | name: "ClientHelloVersionTooHigh", |
| 4403 | config: Config{ |
| 4404 | MaxVersion: VersionTLS13, |
| 4405 | Bugs: ProtocolBugs{ |
| 4406 | SendClientVersion: 0x0304, |
| 4407 | OmitSupportedVersions: true, |
| 4408 | }, |
| 4409 | }, |
| 4410 | expectedVersion: VersionTLS12, |
| 4411 | }) |
| 4412 | |
| 4413 | testCases = append(testCases, testCase{ |
| 4414 | testType: serverTest, |
| 4415 | name: "ConflictingVersionNegotiation", |
| 4416 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4417 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4418 | SendClientVersion: VersionTLS12, |
| 4419 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4420 | }, |
| 4421 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4422 | // The extension takes precedence over the ClientHello version. |
| 4423 | expectedVersion: VersionTLS11, |
| 4424 | }) |
| 4425 | |
| 4426 | testCases = append(testCases, testCase{ |
| 4427 | testType: serverTest, |
| 4428 | name: "ConflictingVersionNegotiation-2", |
| 4429 | config: Config{ |
| 4430 | Bugs: ProtocolBugs{ |
| 4431 | SendClientVersion: VersionTLS11, |
| 4432 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4433 | }, |
| 4434 | }, |
| 4435 | // The extension takes precedence over the ClientHello version. |
| 4436 | expectedVersion: VersionTLS12, |
| 4437 | }) |
| 4438 | |
| 4439 | testCases = append(testCases, testCase{ |
| 4440 | testType: serverTest, |
| 4441 | name: "RejectFinalTLS13", |
| 4442 | config: Config{ |
| 4443 | Bugs: ProtocolBugs{ |
| 4444 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4445 | }, |
| 4446 | }, |
| 4447 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4448 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4449 | expectedVersion: VersionTLS12, |
| 4450 | }) |
| 4451 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4452 | // Test that the maximum version is selected regardless of the |
| 4453 | // client-sent order. |
| 4454 | testCases = append(testCases, testCase{ |
| 4455 | testType: serverTest, |
| 4456 | name: "IgnoreClientVersionOrder", |
| 4457 | config: Config{ |
| 4458 | Bugs: ProtocolBugs{ |
| 4459 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4460 | }, |
| 4461 | }, |
| 4462 | expectedVersion: VersionTLS13, |
| 4463 | }) |
| 4464 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4465 | // Test for version tolerance. |
| 4466 | testCases = append(testCases, testCase{ |
| 4467 | testType: serverTest, |
| 4468 | name: "MinorVersionTolerance", |
| 4469 | config: Config{ |
| 4470 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4471 | SendClientVersion: 0x03ff, |
| 4472 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4473 | }, |
| 4474 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4475 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4476 | }) |
| 4477 | testCases = append(testCases, testCase{ |
| 4478 | testType: serverTest, |
| 4479 | name: "MajorVersionTolerance", |
| 4480 | config: Config{ |
| 4481 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4482 | SendClientVersion: 0x0400, |
| 4483 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4484 | }, |
| 4485 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4486 | // TLS 1.3 must be negotiated with the supported_versions |
| 4487 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4488 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4489 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4490 | testCases = append(testCases, testCase{ |
| 4491 | testType: serverTest, |
| 4492 | name: "VersionTolerance-TLS13", |
| 4493 | config: Config{ |
| 4494 | Bugs: ProtocolBugs{ |
| 4495 | // Although TLS 1.3 does not use |
| 4496 | // ClientHello.version, it still tolerates high |
| 4497 | // values there. |
| 4498 | SendClientVersion: 0x0400, |
| 4499 | }, |
| 4500 | }, |
| 4501 | expectedVersion: VersionTLS13, |
| 4502 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4503 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4504 | testCases = append(testCases, testCase{ |
| 4505 | protocol: dtls, |
| 4506 | testType: serverTest, |
| 4507 | name: "MinorVersionTolerance-DTLS", |
| 4508 | config: Config{ |
| 4509 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4510 | SendClientVersion: 0xfe00, |
| 4511 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4512 | }, |
| 4513 | }, |
| 4514 | expectedVersion: VersionTLS12, |
| 4515 | }) |
| 4516 | testCases = append(testCases, testCase{ |
| 4517 | protocol: dtls, |
| 4518 | testType: serverTest, |
| 4519 | name: "MajorVersionTolerance-DTLS", |
| 4520 | config: Config{ |
| 4521 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4522 | SendClientVersion: 0xfdff, |
| 4523 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4524 | }, |
| 4525 | }, |
| 4526 | expectedVersion: VersionTLS12, |
| 4527 | }) |
| 4528 | |
| 4529 | // Test that versions below 3.0 are rejected. |
| 4530 | testCases = append(testCases, testCase{ |
| 4531 | testType: serverTest, |
| 4532 | name: "VersionTooLow", |
| 4533 | config: Config{ |
| 4534 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4535 | SendClientVersion: 0x0200, |
| 4536 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4537 | }, |
| 4538 | }, |
| 4539 | shouldFail: true, |
| 4540 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4541 | }) |
| 4542 | testCases = append(testCases, testCase{ |
| 4543 | protocol: dtls, |
| 4544 | testType: serverTest, |
| 4545 | name: "VersionTooLow-DTLS", |
| 4546 | config: Config{ |
| 4547 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4548 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4549 | }, |
| 4550 | }, |
| 4551 | shouldFail: true, |
| 4552 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4553 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4554 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4555 | testCases = append(testCases, testCase{ |
| 4556 | name: "ServerBogusVersion", |
| 4557 | config: Config{ |
| 4558 | Bugs: ProtocolBugs{ |
| 4559 | SendServerHelloVersion: 0x1234, |
| 4560 | }, |
| 4561 | }, |
| 4562 | shouldFail: true, |
| 4563 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4564 | }) |
| 4565 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4566 | // Test TLS 1.3's downgrade signal. |
| 4567 | testCases = append(testCases, testCase{ |
| 4568 | name: "Downgrade-TLS12-Client", |
| 4569 | config: Config{ |
| 4570 | Bugs: ProtocolBugs{ |
| 4571 | NegotiateVersion: VersionTLS12, |
| 4572 | }, |
| 4573 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4574 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4575 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4576 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4577 | }) |
| 4578 | testCases = append(testCases, testCase{ |
| 4579 | testType: serverTest, |
| 4580 | name: "Downgrade-TLS12-Server", |
| 4581 | config: Config{ |
| 4582 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4583 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4584 | }, |
| 4585 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4586 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4587 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4588 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4589 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4590 | } |
| 4591 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4592 | func addMinimumVersionTests() { |
| 4593 | for i, shimVers := range tlsVersions { |
| 4594 | // Assemble flags to disable all older versions on the shim. |
| 4595 | var flags []string |
| 4596 | for _, vers := range tlsVersions[:i] { |
| 4597 | flags = append(flags, vers.flag) |
| 4598 | } |
| 4599 | |
| 4600 | for _, runnerVers := range tlsVersions { |
| 4601 | protocols := []protocol{tls} |
| 4602 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4603 | protocols = append(protocols, dtls) |
| 4604 | } |
| 4605 | for _, protocol := range protocols { |
| 4606 | suffix := shimVers.name + "-" + runnerVers.name |
| 4607 | if protocol == dtls { |
| 4608 | suffix += "-DTLS" |
| 4609 | } |
| 4610 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4611 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4612 | var expectedVersion uint16 |
| 4613 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4614 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4615 | if runnerVers.version >= shimVers.version { |
| 4616 | expectedVersion = runnerVers.version |
| 4617 | } else { |
| 4618 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4619 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4620 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4621 | } |
| 4622 | |
| 4623 | testCases = append(testCases, testCase{ |
| 4624 | protocol: protocol, |
| 4625 | testType: clientTest, |
| 4626 | name: "MinimumVersion-Client-" + suffix, |
| 4627 | config: Config{ |
| 4628 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4629 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4630 | // Ensure the server does not decline to |
| 4631 | // select a version (versions extension) or |
| 4632 | // cipher (some ciphers depend on versions). |
| 4633 | NegotiateVersion: runnerVers.version, |
| 4634 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4635 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4636 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4637 | flags: flags, |
| 4638 | expectedVersion: expectedVersion, |
| 4639 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4640 | expectedError: expectedError, |
| 4641 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4642 | }) |
| 4643 | testCases = append(testCases, testCase{ |
| 4644 | protocol: protocol, |
| 4645 | testType: clientTest, |
| 4646 | name: "MinimumVersion-Client2-" + suffix, |
| 4647 | config: Config{ |
| 4648 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4649 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4650 | // Ensure the server does not decline to |
| 4651 | // select a version (versions extension) or |
| 4652 | // cipher (some ciphers depend on versions). |
| 4653 | NegotiateVersion: runnerVers.version, |
| 4654 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4655 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4656 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4657 | flags: []string{"-min-version", shimVersFlag}, |
| 4658 | expectedVersion: expectedVersion, |
| 4659 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4660 | expectedError: expectedError, |
| 4661 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4662 | }) |
| 4663 | |
| 4664 | testCases = append(testCases, testCase{ |
| 4665 | protocol: protocol, |
| 4666 | testType: serverTest, |
| 4667 | name: "MinimumVersion-Server-" + suffix, |
| 4668 | config: Config{ |
| 4669 | MaxVersion: runnerVers.version, |
| 4670 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4671 | flags: flags, |
| 4672 | expectedVersion: expectedVersion, |
| 4673 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4674 | expectedError: expectedError, |
| 4675 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4676 | }) |
| 4677 | testCases = append(testCases, testCase{ |
| 4678 | protocol: protocol, |
| 4679 | testType: serverTest, |
| 4680 | name: "MinimumVersion-Server2-" + suffix, |
| 4681 | config: Config{ |
| 4682 | MaxVersion: runnerVers.version, |
| 4683 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4684 | flags: []string{"-min-version", shimVersFlag}, |
| 4685 | expectedVersion: expectedVersion, |
| 4686 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4687 | expectedError: expectedError, |
| 4688 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4689 | }) |
| 4690 | } |
| 4691 | } |
| 4692 | } |
| 4693 | } |
| 4694 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4695 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4696 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4697 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4698 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4699 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4700 | // Repeat extensions tests all versions except SSL 3.0. |
| 4701 | for _, ver := range tlsVersions { |
| 4702 | if ver.version == VersionSSL30 { |
| 4703 | continue |
| 4704 | } |
| 4705 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4706 | // Test that duplicate extensions are rejected. |
| 4707 | testCases = append(testCases, testCase{ |
| 4708 | testType: clientTest, |
| 4709 | name: "DuplicateExtensionClient-" + ver.name, |
| 4710 | config: Config{ |
| 4711 | MaxVersion: ver.version, |
| 4712 | Bugs: ProtocolBugs{ |
| 4713 | DuplicateExtension: true, |
| 4714 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4715 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4716 | shouldFail: true, |
| 4717 | expectedLocalError: "remote error: error decoding message", |
| 4718 | }) |
| 4719 | testCases = append(testCases, testCase{ |
| 4720 | testType: serverTest, |
| 4721 | name: "DuplicateExtensionServer-" + ver.name, |
| 4722 | config: Config{ |
| 4723 | MaxVersion: ver.version, |
| 4724 | Bugs: ProtocolBugs{ |
| 4725 | DuplicateExtension: true, |
| 4726 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4727 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4728 | shouldFail: true, |
| 4729 | expectedLocalError: "remote error: error decoding message", |
| 4730 | }) |
| 4731 | |
| 4732 | // Test SNI. |
| 4733 | testCases = append(testCases, testCase{ |
| 4734 | testType: clientTest, |
| 4735 | name: "ServerNameExtensionClient-" + ver.name, |
| 4736 | config: Config{ |
| 4737 | MaxVersion: ver.version, |
| 4738 | Bugs: ProtocolBugs{ |
| 4739 | ExpectServerName: "example.com", |
| 4740 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4741 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4742 | flags: []string{"-host-name", "example.com"}, |
| 4743 | }) |
| 4744 | testCases = append(testCases, testCase{ |
| 4745 | testType: clientTest, |
| 4746 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4747 | config: Config{ |
| 4748 | MaxVersion: ver.version, |
| 4749 | Bugs: ProtocolBugs{ |
| 4750 | ExpectServerName: "mismatch.com", |
| 4751 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4752 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4753 | flags: []string{"-host-name", "example.com"}, |
| 4754 | shouldFail: true, |
| 4755 | expectedLocalError: "tls: unexpected server name", |
| 4756 | }) |
| 4757 | testCases = append(testCases, testCase{ |
| 4758 | testType: clientTest, |
| 4759 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4760 | config: Config{ |
| 4761 | MaxVersion: ver.version, |
| 4762 | Bugs: ProtocolBugs{ |
| 4763 | ExpectServerName: "missing.com", |
| 4764 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4765 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4766 | shouldFail: true, |
| 4767 | expectedLocalError: "tls: unexpected server name", |
| 4768 | }) |
| 4769 | testCases = append(testCases, testCase{ |
| 4770 | testType: serverTest, |
| 4771 | name: "ServerNameExtensionServer-" + ver.name, |
| 4772 | config: Config{ |
| 4773 | MaxVersion: ver.version, |
| 4774 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4775 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4776 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4777 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4778 | }) |
| 4779 | |
| 4780 | // Test ALPN. |
| 4781 | testCases = append(testCases, testCase{ |
| 4782 | testType: clientTest, |
| 4783 | name: "ALPNClient-" + ver.name, |
| 4784 | config: Config{ |
| 4785 | MaxVersion: ver.version, |
| 4786 | NextProtos: []string{"foo"}, |
| 4787 | }, |
| 4788 | flags: []string{ |
| 4789 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4790 | "-expect-alpn", "foo", |
| 4791 | }, |
| 4792 | expectedNextProto: "foo", |
| 4793 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4794 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4795 | }) |
| 4796 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4797 | testType: clientTest, |
| 4798 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4799 | config: Config{ |
| 4800 | MaxVersion: ver.version, |
| 4801 | Bugs: ProtocolBugs{ |
| 4802 | SendALPN: "baz", |
| 4803 | }, |
| 4804 | }, |
| 4805 | flags: []string{ |
| 4806 | "-advertise-alpn", "\x03foo\x03bar", |
| 4807 | }, |
| 4808 | shouldFail: true, |
| 4809 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4810 | expectedLocalError: "remote error: illegal parameter", |
| 4811 | }) |
| 4812 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4813 | testType: serverTest, |
| 4814 | name: "ALPNServer-" + ver.name, |
| 4815 | config: Config{ |
| 4816 | MaxVersion: ver.version, |
| 4817 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4818 | }, |
| 4819 | flags: []string{ |
| 4820 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4821 | "-select-alpn", "foo", |
| 4822 | }, |
| 4823 | expectedNextProto: "foo", |
| 4824 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4825 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4826 | }) |
| 4827 | testCases = append(testCases, testCase{ |
| 4828 | testType: serverTest, |
| 4829 | name: "ALPNServer-Decline-" + ver.name, |
| 4830 | config: Config{ |
| 4831 | MaxVersion: ver.version, |
| 4832 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4833 | }, |
| 4834 | flags: []string{"-decline-alpn"}, |
| 4835 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4836 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4837 | }) |
| 4838 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4839 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4840 | // called once. |
| 4841 | testCases = append(testCases, testCase{ |
| 4842 | testType: serverTest, |
| 4843 | name: "ALPNServer-Async-" + ver.name, |
| 4844 | config: Config{ |
| 4845 | MaxVersion: ver.version, |
| 4846 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 4847 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 4848 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4849 | }, |
| 4850 | flags: []string{ |
| 4851 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4852 | "-select-alpn", "foo", |
| 4853 | "-async", |
| 4854 | }, |
| 4855 | expectedNextProto: "foo", |
| 4856 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4857 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4858 | }) |
| 4859 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4860 | var emptyString string |
| 4861 | testCases = append(testCases, testCase{ |
| 4862 | testType: clientTest, |
| 4863 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4864 | config: Config{ |
| 4865 | MaxVersion: ver.version, |
| 4866 | NextProtos: []string{""}, |
| 4867 | Bugs: ProtocolBugs{ |
| 4868 | // A server returning an empty ALPN protocol |
| 4869 | // should be rejected. |
| 4870 | ALPNProtocol: &emptyString, |
| 4871 | }, |
| 4872 | }, |
| 4873 | flags: []string{ |
| 4874 | "-advertise-alpn", "\x03foo", |
| 4875 | }, |
| 4876 | shouldFail: true, |
| 4877 | expectedError: ":PARSE_TLSEXT:", |
| 4878 | }) |
| 4879 | testCases = append(testCases, testCase{ |
| 4880 | testType: serverTest, |
| 4881 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4882 | config: Config{ |
| 4883 | MaxVersion: ver.version, |
| 4884 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4885 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4886 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4887 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4888 | flags: []string{ |
| 4889 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4890 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4891 | shouldFail: true, |
| 4892 | expectedError: ":PARSE_TLSEXT:", |
| 4893 | }) |
| 4894 | |
| 4895 | // Test NPN and the interaction with ALPN. |
| 4896 | if ver.version < VersionTLS13 { |
| 4897 | // Test that the server prefers ALPN over NPN. |
| 4898 | testCases = append(testCases, testCase{ |
| 4899 | testType: serverTest, |
| 4900 | name: "ALPNServer-Preferred-" + ver.name, |
| 4901 | config: Config{ |
| 4902 | MaxVersion: ver.version, |
| 4903 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4904 | }, |
| 4905 | flags: []string{ |
| 4906 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4907 | "-select-alpn", "foo", |
| 4908 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4909 | }, |
| 4910 | expectedNextProto: "foo", |
| 4911 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4912 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4913 | }) |
| 4914 | testCases = append(testCases, testCase{ |
| 4915 | testType: serverTest, |
| 4916 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4917 | config: Config{ |
| 4918 | MaxVersion: ver.version, |
| 4919 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4920 | Bugs: ProtocolBugs{ |
| 4921 | SwapNPNAndALPN: true, |
| 4922 | }, |
| 4923 | }, |
| 4924 | flags: []string{ |
| 4925 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4926 | "-select-alpn", "foo", |
| 4927 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4928 | }, |
| 4929 | expectedNextProto: "foo", |
| 4930 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4931 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4932 | }) |
| 4933 | |
| 4934 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4935 | testCases = append(testCases, testCase{ |
| 4936 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4937 | config: Config{ |
| 4938 | MaxVersion: ver.version, |
| 4939 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4940 | Bugs: ProtocolBugs{ |
| 4941 | NegotiateALPNAndNPN: true, |
| 4942 | }, |
| 4943 | }, |
| 4944 | flags: []string{ |
| 4945 | "-advertise-alpn", "\x03foo", |
| 4946 | "-select-next-proto", "foo", |
| 4947 | }, |
| 4948 | shouldFail: true, |
| 4949 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4950 | }) |
| 4951 | testCases = append(testCases, testCase{ |
| 4952 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4953 | config: Config{ |
| 4954 | MaxVersion: ver.version, |
| 4955 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4956 | Bugs: ProtocolBugs{ |
| 4957 | NegotiateALPNAndNPN: true, |
| 4958 | SwapNPNAndALPN: true, |
| 4959 | }, |
| 4960 | }, |
| 4961 | flags: []string{ |
| 4962 | "-advertise-alpn", "\x03foo", |
| 4963 | "-select-next-proto", "foo", |
| 4964 | }, |
| 4965 | shouldFail: true, |
| 4966 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4967 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4968 | } |
| 4969 | |
| 4970 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4971 | |
| 4972 | // Resume with a corrupt ticket. |
| 4973 | testCases = append(testCases, testCase{ |
| 4974 | testType: serverTest, |
| 4975 | name: "CorruptTicket-" + ver.name, |
| 4976 | config: Config{ |
| 4977 | MaxVersion: ver.version, |
| 4978 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 4979 | FilterTicket: func(in []byte) ([]byte, error) { |
| 4980 | in[len(in)-1] ^= 1 |
| 4981 | return in, nil |
| 4982 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4983 | }, |
| 4984 | }, |
| 4985 | resumeSession: true, |
| 4986 | expectResumeRejected: true, |
| 4987 | }) |
| 4988 | // Test the ticket callback, with and without renewal. |
| 4989 | testCases = append(testCases, testCase{ |
| 4990 | testType: serverTest, |
| 4991 | name: "TicketCallback-" + ver.name, |
| 4992 | config: Config{ |
| 4993 | MaxVersion: ver.version, |
| 4994 | }, |
| 4995 | resumeSession: true, |
| 4996 | flags: []string{"-use-ticket-callback"}, |
| 4997 | }) |
| 4998 | testCases = append(testCases, testCase{ |
| 4999 | testType: serverTest, |
| 5000 | name: "TicketCallback-Renew-" + ver.name, |
| 5001 | config: Config{ |
| 5002 | MaxVersion: ver.version, |
| 5003 | Bugs: ProtocolBugs{ |
| 5004 | ExpectNewTicket: true, |
| 5005 | }, |
| 5006 | }, |
| 5007 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5008 | resumeSession: true, |
| 5009 | }) |
| 5010 | |
| 5011 | // Test that the ticket callback is only called once when everything before |
| 5012 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5013 | // certificate selection callbacks run. |
| 5014 | testCases = append(testCases, testCase{ |
| 5015 | testType: serverTest, |
| 5016 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5017 | config: Config{ |
| 5018 | MaxVersion: ver.version, |
| 5019 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5020 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5021 | in[len(in)-1] ^= 1 |
| 5022 | return in, nil |
| 5023 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5024 | }, |
| 5025 | }, |
| 5026 | resumeSession: true, |
| 5027 | expectResumeRejected: true, |
| 5028 | flags: []string{ |
| 5029 | "-use-ticket-callback", |
| 5030 | "-async", |
| 5031 | }, |
| 5032 | }) |
| 5033 | |
| 5034 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5035 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5036 | testCases = append(testCases, testCase{ |
| 5037 | testType: serverTest, |
| 5038 | name: "OversizedSessionId-" + ver.name, |
| 5039 | config: Config{ |
| 5040 | MaxVersion: ver.version, |
| 5041 | Bugs: ProtocolBugs{ |
| 5042 | OversizedSessionId: true, |
| 5043 | }, |
| 5044 | }, |
| 5045 | resumeSession: true, |
| 5046 | shouldFail: true, |
| 5047 | expectedError: ":DECODE_ERROR:", |
| 5048 | }) |
| 5049 | } |
| 5050 | |
| 5051 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5052 | // are ignored. |
| 5053 | if ver.hasDTLS { |
| 5054 | testCases = append(testCases, testCase{ |
| 5055 | protocol: dtls, |
| 5056 | name: "SRTP-Client-" + ver.name, |
| 5057 | config: Config{ |
| 5058 | MaxVersion: ver.version, |
| 5059 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5060 | }, |
| 5061 | flags: []string{ |
| 5062 | "-srtp-profiles", |
| 5063 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5064 | }, |
| 5065 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5066 | }) |
| 5067 | testCases = append(testCases, testCase{ |
| 5068 | protocol: dtls, |
| 5069 | testType: serverTest, |
| 5070 | name: "SRTP-Server-" + ver.name, |
| 5071 | config: Config{ |
| 5072 | MaxVersion: ver.version, |
| 5073 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5074 | }, |
| 5075 | flags: []string{ |
| 5076 | "-srtp-profiles", |
| 5077 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5078 | }, |
| 5079 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5080 | }) |
| 5081 | // Test that the MKI is ignored. |
| 5082 | testCases = append(testCases, testCase{ |
| 5083 | protocol: dtls, |
| 5084 | testType: serverTest, |
| 5085 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5086 | config: Config{ |
| 5087 | MaxVersion: ver.version, |
| 5088 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5089 | Bugs: ProtocolBugs{ |
| 5090 | SRTPMasterKeyIdentifer: "bogus", |
| 5091 | }, |
| 5092 | }, |
| 5093 | flags: []string{ |
| 5094 | "-srtp-profiles", |
| 5095 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5096 | }, |
| 5097 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5098 | }) |
| 5099 | // Test that SRTP isn't negotiated on the server if there were |
| 5100 | // no matching profiles. |
| 5101 | testCases = append(testCases, testCase{ |
| 5102 | protocol: dtls, |
| 5103 | testType: serverTest, |
| 5104 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5105 | config: Config{ |
| 5106 | MaxVersion: ver.version, |
| 5107 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5108 | }, |
| 5109 | flags: []string{ |
| 5110 | "-srtp-profiles", |
| 5111 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5112 | }, |
| 5113 | expectedSRTPProtectionProfile: 0, |
| 5114 | }) |
| 5115 | // Test that the server returning an invalid SRTP profile is |
| 5116 | // flagged as an error by the client. |
| 5117 | testCases = append(testCases, testCase{ |
| 5118 | protocol: dtls, |
| 5119 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5120 | config: Config{ |
| 5121 | MaxVersion: ver.version, |
| 5122 | Bugs: ProtocolBugs{ |
| 5123 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5124 | }, |
| 5125 | }, |
| 5126 | flags: []string{ |
| 5127 | "-srtp-profiles", |
| 5128 | "SRTP_AES128_CM_SHA1_80", |
| 5129 | }, |
| 5130 | shouldFail: true, |
| 5131 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5132 | }) |
| 5133 | } |
| 5134 | |
| 5135 | // Test SCT list. |
| 5136 | testCases = append(testCases, testCase{ |
| 5137 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5138 | testType: clientTest, |
| 5139 | config: Config{ |
| 5140 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5141 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5142 | flags: []string{ |
| 5143 | "-enable-signed-cert-timestamps", |
| 5144 | "-expect-signed-cert-timestamps", |
| 5145 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5146 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5147 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5148 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5149 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5150 | var differentSCTList []byte |
| 5151 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5152 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5153 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5154 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5155 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5156 | testCases = append(testCases, testCase{ |
| 5157 | name: "SendSCTListOnResume-" + ver.name, |
| 5158 | config: Config{ |
| 5159 | MaxVersion: ver.version, |
| 5160 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5161 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5162 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5163 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5164 | flags: []string{ |
| 5165 | "-enable-signed-cert-timestamps", |
| 5166 | "-expect-signed-cert-timestamps", |
| 5167 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5168 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5169 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5170 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5171 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5172 | testCases = append(testCases, testCase{ |
| 5173 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5174 | testType: serverTest, |
| 5175 | config: Config{ |
| 5176 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5177 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5178 | flags: []string{ |
| 5179 | "-signed-cert-timestamps", |
| 5180 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5181 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5182 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5183 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5184 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5185 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5186 | emptySCTListCert := *testCerts[0].cert |
| 5187 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5188 | |
| 5189 | // Test empty SCT list. |
| 5190 | testCases = append(testCases, testCase{ |
| 5191 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5192 | testType: clientTest, |
| 5193 | config: Config{ |
| 5194 | MaxVersion: ver.version, |
| 5195 | Certificates: []Certificate{emptySCTListCert}, |
| 5196 | }, |
| 5197 | flags: []string{ |
| 5198 | "-enable-signed-cert-timestamps", |
| 5199 | }, |
| 5200 | shouldFail: true, |
| 5201 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5202 | }) |
| 5203 | |
| 5204 | emptySCTCert := *testCerts[0].cert |
| 5205 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5206 | |
| 5207 | // Test empty SCT in non-empty list. |
| 5208 | testCases = append(testCases, testCase{ |
| 5209 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5210 | testType: clientTest, |
| 5211 | config: Config{ |
| 5212 | MaxVersion: ver.version, |
| 5213 | Certificates: []Certificate{emptySCTCert}, |
| 5214 | }, |
| 5215 | flags: []string{ |
| 5216 | "-enable-signed-cert-timestamps", |
| 5217 | }, |
| 5218 | shouldFail: true, |
| 5219 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5220 | }) |
| 5221 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5222 | // Test that certificate-related extensions are not sent unsolicited. |
| 5223 | testCases = append(testCases, testCase{ |
| 5224 | testType: serverTest, |
| 5225 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5226 | config: Config{ |
| 5227 | MaxVersion: ver.version, |
| 5228 | Bugs: ProtocolBugs{ |
| 5229 | NoOCSPStapling: true, |
| 5230 | NoSignedCertificateTimestamps: true, |
| 5231 | }, |
| 5232 | }, |
| 5233 | flags: []string{ |
| 5234 | "-ocsp-response", |
| 5235 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5236 | "-signed-cert-timestamps", |
| 5237 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5238 | }, |
| 5239 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5240 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5241 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5242 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5243 | testType: clientTest, |
| 5244 | name: "ClientHelloPadding", |
| 5245 | config: Config{ |
| 5246 | Bugs: ProtocolBugs{ |
| 5247 | RequireClientHelloSize: 512, |
| 5248 | }, |
| 5249 | }, |
| 5250 | // This hostname just needs to be long enough to push the |
| 5251 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5252 | // long. |
| 5253 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5254 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5255 | |
| 5256 | // Extensions should not function in SSL 3.0. |
| 5257 | testCases = append(testCases, testCase{ |
| 5258 | testType: serverTest, |
| 5259 | name: "SSLv3Extensions-NoALPN", |
| 5260 | config: Config{ |
| 5261 | MaxVersion: VersionSSL30, |
| 5262 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5263 | }, |
| 5264 | flags: []string{ |
| 5265 | "-select-alpn", "foo", |
| 5266 | }, |
| 5267 | expectNoNextProto: true, |
| 5268 | }) |
| 5269 | |
| 5270 | // Test session tickets separately as they follow a different codepath. |
| 5271 | testCases = append(testCases, testCase{ |
| 5272 | testType: serverTest, |
| 5273 | name: "SSLv3Extensions-NoTickets", |
| 5274 | config: Config{ |
| 5275 | MaxVersion: VersionSSL30, |
| 5276 | Bugs: ProtocolBugs{ |
| 5277 | // Historically, session tickets in SSL 3.0 |
| 5278 | // failed in different ways depending on whether |
| 5279 | // the client supported renegotiation_info. |
| 5280 | NoRenegotiationInfo: true, |
| 5281 | }, |
| 5282 | }, |
| 5283 | resumeSession: true, |
| 5284 | }) |
| 5285 | testCases = append(testCases, testCase{ |
| 5286 | testType: serverTest, |
| 5287 | name: "SSLv3Extensions-NoTickets2", |
| 5288 | config: Config{ |
| 5289 | MaxVersion: VersionSSL30, |
| 5290 | }, |
| 5291 | resumeSession: true, |
| 5292 | }) |
| 5293 | |
| 5294 | // But SSL 3.0 does send and process renegotiation_info. |
| 5295 | testCases = append(testCases, testCase{ |
| 5296 | testType: serverTest, |
| 5297 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5298 | config: Config{ |
| 5299 | MaxVersion: VersionSSL30, |
| 5300 | Bugs: ProtocolBugs{ |
| 5301 | RequireRenegotiationInfo: true, |
| 5302 | }, |
| 5303 | }, |
| 5304 | }) |
| 5305 | testCases = append(testCases, testCase{ |
| 5306 | testType: serverTest, |
| 5307 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5308 | config: Config{ |
| 5309 | MaxVersion: VersionSSL30, |
| 5310 | Bugs: ProtocolBugs{ |
| 5311 | NoRenegotiationInfo: true, |
| 5312 | SendRenegotiationSCSV: true, |
| 5313 | RequireRenegotiationInfo: true, |
| 5314 | }, |
| 5315 | }, |
| 5316 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5317 | |
| 5318 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5319 | // in ServerHello. |
| 5320 | testCases = append(testCases, testCase{ |
| 5321 | name: "NPN-Forbidden-TLS13", |
| 5322 | config: Config{ |
| 5323 | MaxVersion: VersionTLS13, |
| 5324 | NextProtos: []string{"foo"}, |
| 5325 | Bugs: ProtocolBugs{ |
| 5326 | NegotiateNPNAtAllVersions: true, |
| 5327 | }, |
| 5328 | }, |
| 5329 | flags: []string{"-select-next-proto", "foo"}, |
| 5330 | shouldFail: true, |
| 5331 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5332 | }) |
| 5333 | testCases = append(testCases, testCase{ |
| 5334 | name: "EMS-Forbidden-TLS13", |
| 5335 | config: Config{ |
| 5336 | MaxVersion: VersionTLS13, |
| 5337 | Bugs: ProtocolBugs{ |
| 5338 | NegotiateEMSAtAllVersions: true, |
| 5339 | }, |
| 5340 | }, |
| 5341 | shouldFail: true, |
| 5342 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5343 | }) |
| 5344 | testCases = append(testCases, testCase{ |
| 5345 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5346 | config: Config{ |
| 5347 | MaxVersion: VersionTLS13, |
| 5348 | Bugs: ProtocolBugs{ |
| 5349 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5350 | }, |
| 5351 | }, |
| 5352 | shouldFail: true, |
| 5353 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5354 | }) |
| 5355 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5356 | name: "Ticket-Forbidden-TLS13", |
| 5357 | config: Config{ |
| 5358 | MaxVersion: VersionTLS12, |
| 5359 | }, |
| 5360 | resumeConfig: &Config{ |
| 5361 | MaxVersion: VersionTLS13, |
| 5362 | Bugs: ProtocolBugs{ |
| 5363 | AdvertiseTicketExtension: true, |
| 5364 | }, |
| 5365 | }, |
| 5366 | resumeSession: true, |
| 5367 | shouldFail: true, |
| 5368 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5369 | }) |
| 5370 | |
| 5371 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5372 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5373 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5374 | // implicit in every test.) |
| 5375 | testCases = append(testCases, testCase{ |
| 5376 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5377 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5378 | config: Config{ |
| 5379 | MaxVersion: VersionTLS13, |
| 5380 | NextProtos: []string{"bar"}, |
| 5381 | }, |
| 5382 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5383 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5384 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5385 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5386 | // tolerated. |
| 5387 | testCases = append(testCases, testCase{ |
| 5388 | name: "SendOCSPResponseOnResume-TLS12", |
| 5389 | config: Config{ |
| 5390 | MaxVersion: VersionTLS12, |
| 5391 | Bugs: ProtocolBugs{ |
| 5392 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5393 | }, |
| 5394 | }, |
| 5395 | flags: []string{ |
| 5396 | "-enable-ocsp-stapling", |
| 5397 | "-expect-ocsp-response", |
| 5398 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5399 | }, |
| 5400 | resumeSession: true, |
| 5401 | }) |
| 5402 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5403 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5404 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5405 | config: Config{ |
| 5406 | MaxVersion: VersionTLS13, |
| 5407 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5408 | SendExtensionOnCertificate: testOCSPExtension, |
| 5409 | }, |
| 5410 | }, |
| 5411 | shouldFail: true, |
| 5412 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5413 | }) |
| 5414 | |
| 5415 | testCases = append(testCases, testCase{ |
| 5416 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5417 | config: Config{ |
| 5418 | MaxVersion: VersionTLS13, |
| 5419 | Bugs: ProtocolBugs{ |
| 5420 | SendExtensionOnCertificate: testSCTExtension, |
| 5421 | }, |
| 5422 | }, |
| 5423 | shouldFail: true, |
| 5424 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5425 | }) |
| 5426 | |
| 5427 | // Test that extensions on client certificates are never accepted. |
| 5428 | testCases = append(testCases, testCase{ |
| 5429 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5430 | testType: serverTest, |
| 5431 | config: Config{ |
| 5432 | MaxVersion: VersionTLS13, |
| 5433 | Certificates: []Certificate{rsaCertificate}, |
| 5434 | Bugs: ProtocolBugs{ |
| 5435 | SendExtensionOnCertificate: testOCSPExtension, |
| 5436 | }, |
| 5437 | }, |
| 5438 | flags: []string{ |
| 5439 | "-enable-ocsp-stapling", |
| 5440 | "-require-any-client-certificate", |
| 5441 | }, |
| 5442 | shouldFail: true, |
| 5443 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5444 | }) |
| 5445 | |
| 5446 | testCases = append(testCases, testCase{ |
| 5447 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5448 | config: Config{ |
| 5449 | MaxVersion: VersionTLS13, |
| 5450 | Bugs: ProtocolBugs{ |
| 5451 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5452 | }, |
| 5453 | }, |
| 5454 | shouldFail: true, |
| 5455 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5456 | }) |
| 5457 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5458 | var differentSCTList []byte |
| 5459 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5460 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5461 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5462 | // Test that extensions on intermediates are allowed but ignored. |
| 5463 | testCases = append(testCases, testCase{ |
| 5464 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5465 | config: Config{ |
| 5466 | MaxVersion: VersionTLS13, |
| 5467 | Certificates: []Certificate{rsaChainCertificate}, |
| 5468 | Bugs: ProtocolBugs{ |
| 5469 | // Send different values on the intermediate. This tests |
| 5470 | // the intermediate's extensions do not override the |
| 5471 | // leaf's. |
| 5472 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5473 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5474 | }, |
| 5475 | }, |
| 5476 | flags: []string{ |
| 5477 | "-enable-ocsp-stapling", |
| 5478 | "-expect-ocsp-response", |
| 5479 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5480 | "-enable-signed-cert-timestamps", |
| 5481 | "-expect-signed-cert-timestamps", |
| 5482 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5483 | }, |
| 5484 | resumeSession: true, |
| 5485 | }) |
| 5486 | |
| 5487 | // Test that extensions are not sent on intermediates when configured |
| 5488 | // only for a leaf. |
| 5489 | testCases = append(testCases, testCase{ |
| 5490 | testType: serverTest, |
| 5491 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5492 | config: Config{ |
| 5493 | MaxVersion: VersionTLS13, |
| 5494 | Bugs: ProtocolBugs{ |
| 5495 | ExpectNoExtensionsOnIntermediate: true, |
| 5496 | }, |
| 5497 | }, |
| 5498 | flags: []string{ |
| 5499 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5500 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5501 | "-ocsp-response", |
| 5502 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5503 | "-signed-cert-timestamps", |
| 5504 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5505 | }, |
| 5506 | }) |
| 5507 | |
| 5508 | // Test that extensions are not sent on client certificates. |
| 5509 | testCases = append(testCases, testCase{ |
| 5510 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5511 | config: Config{ |
| 5512 | MaxVersion: VersionTLS13, |
| 5513 | ClientAuth: RequireAnyClientCert, |
| 5514 | }, |
| 5515 | flags: []string{ |
| 5516 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5517 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5518 | "-ocsp-response", |
| 5519 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5520 | "-signed-cert-timestamps", |
| 5521 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5522 | }, |
| 5523 | }) |
| 5524 | |
| 5525 | testCases = append(testCases, testCase{ |
| 5526 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5527 | config: Config{ |
| 5528 | MaxVersion: VersionTLS13, |
| 5529 | Bugs: ProtocolBugs{ |
| 5530 | SendDuplicateCertExtensions: true, |
| 5531 | }, |
| 5532 | }, |
| 5533 | flags: []string{ |
| 5534 | "-enable-ocsp-stapling", |
| 5535 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5536 | }, |
| 5537 | resumeSession: true, |
| 5538 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5539 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5540 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5541 | |
| 5542 | testCases = append(testCases, testCase{ |
| 5543 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5544 | testType: serverTest, |
| 5545 | flags: []string{ |
| 5546 | "-signed-cert-timestamps", |
| 5547 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5548 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5549 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5550 | expectedError: ":INVALID_SCT_LIST:", |
| 5551 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5552 | } |
| 5553 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5554 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5555 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5556 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5557 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5558 | // have session IDs, so skip their cross-resumption |
| 5559 | // tests. |
| 5560 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5561 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5562 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5563 | } |
| 5564 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5565 | protocols := []protocol{tls} |
| 5566 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5567 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5568 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5569 | for _, protocol := range protocols { |
| 5570 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5571 | if protocol == dtls { |
| 5572 | suffix += "-DTLS" |
| 5573 | } |
| 5574 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5575 | if sessionVers.version == resumeVers.version { |
| 5576 | testCases = append(testCases, testCase{ |
| 5577 | protocol: protocol, |
| 5578 | name: "Resume-Client" + suffix, |
| 5579 | resumeSession: true, |
| 5580 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5581 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5582 | Bugs: ProtocolBugs{ |
| 5583 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5584 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5585 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5586 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5587 | expectedVersion: sessionVers.version, |
| 5588 | expectedResumeVersion: resumeVers.version, |
| 5589 | }) |
| 5590 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5591 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5592 | |
| 5593 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5594 | // there is no way to convince a non-lookahead client the |
| 5595 | // session was resumed. It will appear to the client that a |
| 5596 | // stray ChangeCipherSpec was sent. |
| 5597 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5598 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5599 | } |
| 5600 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5601 | testCases = append(testCases, testCase{ |
| 5602 | protocol: protocol, |
| 5603 | name: "Resume-Client-Mismatch" + suffix, |
| 5604 | resumeSession: true, |
| 5605 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5606 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5607 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5608 | expectedVersion: sessionVers.version, |
| 5609 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5610 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5611 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5612 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5613 | }, |
| 5614 | }, |
| 5615 | expectedResumeVersion: resumeVers.version, |
| 5616 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5617 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5618 | }) |
| 5619 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5620 | |
| 5621 | testCases = append(testCases, testCase{ |
| 5622 | protocol: protocol, |
| 5623 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5624 | resumeSession: true, |
| 5625 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5626 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5627 | }, |
| 5628 | expectedVersion: sessionVers.version, |
| 5629 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5630 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5631 | }, |
| 5632 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5633 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5634 | expectedResumeVersion: resumeVers.version, |
| 5635 | }) |
| 5636 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5637 | testCases = append(testCases, testCase{ |
| 5638 | protocol: protocol, |
| 5639 | testType: serverTest, |
| 5640 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5641 | resumeSession: true, |
| 5642 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5643 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5644 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5645 | expectedVersion: sessionVers.version, |
| 5646 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5647 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5648 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5649 | Bugs: ProtocolBugs{ |
| 5650 | SendBothTickets: true, |
| 5651 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5652 | }, |
| 5653 | expectedResumeVersion: resumeVers.version, |
| 5654 | }) |
| 5655 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5656 | } |
| 5657 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5658 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5659 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5660 | testCases = append(testCases, testCase{ |
| 5661 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5662 | name: "ShimTicketRewritable", |
| 5663 | resumeSession: true, |
| 5664 | config: Config{ |
| 5665 | MaxVersion: VersionTLS12, |
| 5666 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5667 | Bugs: ProtocolBugs{ |
| 5668 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5669 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5670 | if err != nil { |
| 5671 | return nil, err |
| 5672 | } |
| 5673 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5674 | }, |
| 5675 | }, |
| 5676 | }, |
| 5677 | flags: []string{ |
| 5678 | "-ticket-key", |
| 5679 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5680 | }, |
| 5681 | }) |
| 5682 | |
| 5683 | // Resumptions are declined if the version does not match. |
| 5684 | testCases = append(testCases, testCase{ |
| 5685 | testType: serverTest, |
| 5686 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5687 | resumeSession: true, |
| 5688 | config: Config{ |
| 5689 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5690 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5691 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5692 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5693 | return SetShimTicketVersion(in, VersionTLS13) |
| 5694 | }, |
| 5695 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5696 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5697 | flags: []string{ |
| 5698 | "-ticket-key", |
| 5699 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5700 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5701 | expectResumeRejected: true, |
| 5702 | }) |
| 5703 | |
| 5704 | testCases = append(testCases, testCase{ |
| 5705 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5706 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5707 | resumeSession: true, |
| 5708 | config: Config{ |
| 5709 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5710 | Bugs: ProtocolBugs{ |
| 5711 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5712 | return SetShimTicketVersion(in, VersionTLS12) |
| 5713 | }, |
| 5714 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5715 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5716 | flags: []string{ |
| 5717 | "-ticket-key", |
| 5718 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5719 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5720 | expectResumeRejected: true, |
| 5721 | }) |
| 5722 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5723 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5724 | testCases = append(testCases, testCase{ |
| 5725 | testType: serverTest, |
| 5726 | name: "Resume-Server-DeclineBadCipher", |
| 5727 | resumeSession: true, |
| 5728 | config: Config{ |
| 5729 | MaxVersion: VersionTLS12, |
| 5730 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5731 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5732 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5733 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5734 | }, |
| 5735 | }, |
| 5736 | }, |
| 5737 | flags: []string{ |
| 5738 | "-ticket-key", |
| 5739 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5740 | }, |
| 5741 | expectResumeRejected: true, |
| 5742 | }) |
| 5743 | |
| 5744 | testCases = append(testCases, testCase{ |
| 5745 | testType: serverTest, |
| 5746 | name: "Resume-Server-DeclineBadCipher-2", |
| 5747 | resumeSession: true, |
| 5748 | config: Config{ |
| 5749 | MaxVersion: VersionTLS12, |
| 5750 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5751 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5752 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5753 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5754 | }, |
| 5755 | }, |
| 5756 | }, |
| 5757 | flags: []string{ |
| 5758 | "-cipher", "AES128", |
| 5759 | "-ticket-key", |
| 5760 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5761 | }, |
| 5762 | expectResumeRejected: true, |
| 5763 | }) |
| 5764 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5765 | // Sessions are not resumed if they do not use the preferred cipher. |
| 5766 | testCases = append(testCases, testCase{ |
| 5767 | testType: serverTest, |
| 5768 | name: "Resume-Server-CipherNotPreferred", |
| 5769 | resumeSession: true, |
| 5770 | config: Config{ |
| 5771 | MaxVersion: VersionTLS12, |
| 5772 | Bugs: ProtocolBugs{ |
| 5773 | ExpectNewTicket: true, |
| 5774 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5775 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 5776 | }, |
| 5777 | }, |
| 5778 | }, |
| 5779 | flags: []string{ |
| 5780 | "-ticket-key", |
| 5781 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5782 | }, |
| 5783 | shouldFail: false, |
| 5784 | expectResumeRejected: true, |
| 5785 | }) |
| 5786 | |
| 5787 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 5788 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 5789 | testCases = append(testCases, testCase{ |
| 5790 | testType: serverTest, |
| 5791 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 5792 | resumeSession: true, |
| 5793 | config: Config{ |
| 5794 | MaxVersion: VersionTLS13, |
| 5795 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 5796 | Bugs: ProtocolBugs{ |
| 5797 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5798 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 5799 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 5800 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5801 | }, |
| 5802 | }, |
| 5803 | }, |
| 5804 | flags: []string{ |
| 5805 | "-ticket-key", |
| 5806 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5807 | }, |
| 5808 | shouldFail: false, |
| 5809 | expectResumeRejected: true, |
| 5810 | }) |
| 5811 | |
| 5812 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5813 | testCases = append(testCases, testCase{ |
| 5814 | testType: serverTest, |
| 5815 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5816 | resumeSession: true, |
| 5817 | config: Config{ |
| 5818 | MaxVersion: VersionTLS13, |
| 5819 | Bugs: ProtocolBugs{ |
| 5820 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5821 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5822 | }, |
| 5823 | }, |
| 5824 | }, |
| 5825 | flags: []string{ |
| 5826 | "-ticket-key", |
| 5827 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5828 | }, |
| 5829 | expectResumeRejected: true, |
| 5830 | }) |
| 5831 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5832 | // If the client does not offer the cipher from the session, decline to |
| 5833 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 5834 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5835 | testCases = append(testCases, testCase{ |
| 5836 | testType: serverTest, |
| 5837 | name: "Resume-Server-UnofferedCipher", |
| 5838 | resumeSession: true, |
| 5839 | config: Config{ |
| 5840 | MaxVersion: VersionTLS12, |
| 5841 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5842 | }, |
| 5843 | resumeConfig: &Config{ |
| 5844 | MaxVersion: VersionTLS12, |
| 5845 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5846 | Bugs: ProtocolBugs{ |
| 5847 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5848 | }, |
| 5849 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5850 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5851 | }) |
| 5852 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5853 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 5854 | // include the selected cipher. Test that we tolerate this. Servers may |
| 5855 | // resume at another cipher if the PRF matches, but BoringSSL will |
| 5856 | // always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5857 | testCases = append(testCases, testCase{ |
| 5858 | testType: serverTest, |
| 5859 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5860 | resumeSession: true, |
| 5861 | config: Config{ |
| 5862 | MaxVersion: VersionTLS13, |
| 5863 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5864 | }, |
| 5865 | resumeConfig: &Config{ |
| 5866 | MaxVersion: VersionTLS13, |
| 5867 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5868 | Bugs: ProtocolBugs{ |
| 5869 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5870 | }, |
| 5871 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5872 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5873 | }) |
| 5874 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5875 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5876 | testCases = append(testCases, testCase{ |
| 5877 | name: "Resume-Client-CipherMismatch", |
| 5878 | resumeSession: true, |
| 5879 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5880 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5881 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5882 | }, |
| 5883 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5884 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5885 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5886 | Bugs: ProtocolBugs{ |
| 5887 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5888 | }, |
| 5889 | }, |
| 5890 | shouldFail: true, |
| 5891 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5892 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5893 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5894 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 5895 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5896 | testCases = append(testCases, testCase{ |
| 5897 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5898 | resumeSession: true, |
| 5899 | config: Config{ |
| 5900 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5901 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5902 | }, |
| 5903 | resumeConfig: &Config{ |
| 5904 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5905 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5906 | }, |
| 5907 | }) |
| 5908 | |
| 5909 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 5910 | testCases = append(testCases, testCase{ |
| 5911 | name: "Resume-Client-PRFMismatch-TLS13", |
| 5912 | resumeSession: true, |
| 5913 | config: Config{ |
| 5914 | MaxVersion: VersionTLS13, |
| 5915 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5916 | }, |
| 5917 | resumeConfig: &Config{ |
| 5918 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5919 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5920 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5921 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5922 | }, |
| 5923 | }, |
| 5924 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5925 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5926 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5927 | |
| 5928 | testCases = append(testCases, testCase{ |
| 5929 | testType: serverTest, |
| 5930 | name: "Resume-Server-BinderWrongLength", |
| 5931 | resumeSession: true, |
| 5932 | config: Config{ |
| 5933 | MaxVersion: VersionTLS13, |
| 5934 | Bugs: ProtocolBugs{ |
| 5935 | SendShortPSKBinder: true, |
| 5936 | }, |
| 5937 | }, |
| 5938 | shouldFail: true, |
| 5939 | expectedLocalError: "remote error: error decrypting message", |
| 5940 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5941 | }) |
| 5942 | |
| 5943 | testCases = append(testCases, testCase{ |
| 5944 | testType: serverTest, |
| 5945 | name: "Resume-Server-NoPSKBinder", |
| 5946 | resumeSession: true, |
| 5947 | config: Config{ |
| 5948 | MaxVersion: VersionTLS13, |
| 5949 | Bugs: ProtocolBugs{ |
| 5950 | SendNoPSKBinder: true, |
| 5951 | }, |
| 5952 | }, |
| 5953 | shouldFail: true, |
| 5954 | expectedLocalError: "remote error: error decoding message", |
| 5955 | expectedError: ":DECODE_ERROR:", |
| 5956 | }) |
| 5957 | |
| 5958 | testCases = append(testCases, testCase{ |
| 5959 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 5960 | name: "Resume-Server-ExtraPSKBinder", |
| 5961 | resumeSession: true, |
| 5962 | config: Config{ |
| 5963 | MaxVersion: VersionTLS13, |
| 5964 | Bugs: ProtocolBugs{ |
| 5965 | SendExtraPSKBinder: true, |
| 5966 | }, |
| 5967 | }, |
| 5968 | shouldFail: true, |
| 5969 | expectedLocalError: "remote error: illegal parameter", |
| 5970 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 5971 | }) |
| 5972 | |
| 5973 | testCases = append(testCases, testCase{ |
| 5974 | testType: serverTest, |
| 5975 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 5976 | resumeSession: true, |
| 5977 | config: Config{ |
| 5978 | MaxVersion: VersionTLS13, |
| 5979 | Bugs: ProtocolBugs{ |
| 5980 | ExtraPSKIdentity: true, |
| 5981 | }, |
| 5982 | }, |
| 5983 | shouldFail: true, |
| 5984 | expectedLocalError: "remote error: illegal parameter", |
| 5985 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 5986 | }) |
| 5987 | |
| 5988 | testCases = append(testCases, testCase{ |
| 5989 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5990 | name: "Resume-Server-InvalidPSKBinder", |
| 5991 | resumeSession: true, |
| 5992 | config: Config{ |
| 5993 | MaxVersion: VersionTLS13, |
| 5994 | Bugs: ProtocolBugs{ |
| 5995 | SendInvalidPSKBinder: true, |
| 5996 | }, |
| 5997 | }, |
| 5998 | shouldFail: true, |
| 5999 | expectedLocalError: "remote error: error decrypting message", |
| 6000 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6001 | }) |
| 6002 | |
| 6003 | testCases = append(testCases, testCase{ |
| 6004 | testType: serverTest, |
| 6005 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6006 | resumeSession: true, |
| 6007 | config: Config{ |
| 6008 | MaxVersion: VersionTLS13, |
| 6009 | Bugs: ProtocolBugs{ |
| 6010 | PSKBinderFirst: true, |
| 6011 | }, |
| 6012 | }, |
| 6013 | shouldFail: true, |
| 6014 | expectedLocalError: "remote error: illegal parameter", |
| 6015 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6016 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6017 | } |
| 6018 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6019 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6020 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6021 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6022 | testType: serverTest, |
| 6023 | name: "Renegotiate-Server-Forbidden", |
| 6024 | config: Config{ |
| 6025 | MaxVersion: VersionTLS12, |
| 6026 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6027 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6028 | shouldFail: true, |
| 6029 | expectedError: ":NO_RENEGOTIATION:", |
| 6030 | expectedLocalError: "remote error: no renegotiation", |
| 6031 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6032 | // The server shouldn't echo the renegotiation extension unless |
| 6033 | // requested by the client. |
| 6034 | testCases = append(testCases, testCase{ |
| 6035 | testType: serverTest, |
| 6036 | name: "Renegotiate-Server-NoExt", |
| 6037 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6038 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6039 | Bugs: ProtocolBugs{ |
| 6040 | NoRenegotiationInfo: true, |
| 6041 | RequireRenegotiationInfo: true, |
| 6042 | }, |
| 6043 | }, |
| 6044 | shouldFail: true, |
| 6045 | expectedLocalError: "renegotiation extension missing", |
| 6046 | }) |
| 6047 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6048 | // the extension. |
| 6049 | testCases = append(testCases, testCase{ |
| 6050 | testType: serverTest, |
| 6051 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6052 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6053 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6054 | Bugs: ProtocolBugs{ |
| 6055 | NoRenegotiationInfo: true, |
| 6056 | SendRenegotiationSCSV: true, |
| 6057 | RequireRenegotiationInfo: true, |
| 6058 | }, |
| 6059 | }, |
| 6060 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6061 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6062 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6063 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6064 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6065 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6066 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6067 | }, |
| 6068 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6069 | renegotiate: 1, |
| 6070 | flags: []string{ |
| 6071 | "-renegotiate-freely", |
| 6072 | "-expect-total-renegotiations", "1", |
| 6073 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6074 | }) |
| 6075 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6076 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6077 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6078 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6079 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6080 | Bugs: ProtocolBugs{ |
| 6081 | EmptyRenegotiationInfo: true, |
| 6082 | }, |
| 6083 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6084 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6085 | shouldFail: true, |
| 6086 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6087 | }) |
| 6088 | testCases = append(testCases, testCase{ |
| 6089 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6090 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6091 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6092 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6093 | Bugs: ProtocolBugs{ |
| 6094 | BadRenegotiationInfo: true, |
| 6095 | }, |
| 6096 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6097 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6098 | shouldFail: true, |
| 6099 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6100 | }) |
| 6101 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6102 | name: "Renegotiate-Client-Downgrade", |
| 6103 | renegotiate: 1, |
| 6104 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6105 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6106 | Bugs: ProtocolBugs{ |
| 6107 | NoRenegotiationInfoAfterInitial: true, |
| 6108 | }, |
| 6109 | }, |
| 6110 | flags: []string{"-renegotiate-freely"}, |
| 6111 | shouldFail: true, |
| 6112 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6113 | }) |
| 6114 | testCases = append(testCases, testCase{ |
| 6115 | name: "Renegotiate-Client-Upgrade", |
| 6116 | renegotiate: 1, |
| 6117 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6118 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6119 | Bugs: ProtocolBugs{ |
| 6120 | NoRenegotiationInfoInInitial: true, |
| 6121 | }, |
| 6122 | }, |
| 6123 | flags: []string{"-renegotiate-freely"}, |
| 6124 | shouldFail: true, |
| 6125 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6126 | }) |
| 6127 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6128 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6129 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6130 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6131 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6132 | Bugs: ProtocolBugs{ |
| 6133 | NoRenegotiationInfo: true, |
| 6134 | }, |
| 6135 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6136 | flags: []string{ |
| 6137 | "-renegotiate-freely", |
| 6138 | "-expect-total-renegotiations", "1", |
| 6139 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6140 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6141 | |
| 6142 | // Test that the server may switch ciphers on renegotiation without |
| 6143 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6144 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6145 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6146 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6147 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6148 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6149 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6150 | }, |
| 6151 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6152 | flags: []string{ |
| 6153 | "-renegotiate-freely", |
| 6154 | "-expect-total-renegotiations", "1", |
| 6155 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6156 | }) |
| 6157 | testCases = append(testCases, testCase{ |
| 6158 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6159 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6160 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6161 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6162 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6163 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6164 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6165 | flags: []string{ |
| 6166 | "-renegotiate-freely", |
| 6167 | "-expect-total-renegotiations", "1", |
| 6168 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6169 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6170 | |
| 6171 | // Test that the server may not switch versions on renegotiation. |
| 6172 | testCases = append(testCases, testCase{ |
| 6173 | name: "Renegotiate-Client-SwitchVersion", |
| 6174 | config: Config{ |
| 6175 | MaxVersion: VersionTLS12, |
| 6176 | // Pick a cipher which exists at both versions. |
| 6177 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6178 | Bugs: ProtocolBugs{ |
| 6179 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6180 | // Avoid failing early at the record layer. |
| 6181 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6182 | }, |
| 6183 | }, |
| 6184 | renegotiate: 1, |
| 6185 | flags: []string{ |
| 6186 | "-renegotiate-freely", |
| 6187 | "-expect-total-renegotiations", "1", |
| 6188 | }, |
| 6189 | shouldFail: true, |
| 6190 | expectedError: ":WRONG_SSL_VERSION:", |
| 6191 | }) |
| 6192 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6193 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6194 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6195 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6196 | config: Config{ |
| 6197 | MaxVersion: VersionTLS10, |
| 6198 | Bugs: ProtocolBugs{ |
| 6199 | RequireSameRenegoClientVersion: true, |
| 6200 | }, |
| 6201 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6202 | flags: []string{ |
| 6203 | "-renegotiate-freely", |
| 6204 | "-expect-total-renegotiations", "1", |
| 6205 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6206 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6207 | testCases = append(testCases, testCase{ |
| 6208 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6209 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6210 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6211 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6212 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6213 | NextProtos: []string{"foo"}, |
| 6214 | }, |
| 6215 | flags: []string{ |
| 6216 | "-false-start", |
| 6217 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6218 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6219 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6220 | }, |
| 6221 | shimWritesFirst: true, |
| 6222 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6223 | |
| 6224 | // Client-side renegotiation controls. |
| 6225 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6226 | name: "Renegotiate-Client-Forbidden-1", |
| 6227 | config: Config{ |
| 6228 | MaxVersion: VersionTLS12, |
| 6229 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6230 | renegotiate: 1, |
| 6231 | shouldFail: true, |
| 6232 | expectedError: ":NO_RENEGOTIATION:", |
| 6233 | expectedLocalError: "remote error: no renegotiation", |
| 6234 | }) |
| 6235 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6236 | name: "Renegotiate-Client-Once-1", |
| 6237 | config: Config{ |
| 6238 | MaxVersion: VersionTLS12, |
| 6239 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6240 | renegotiate: 1, |
| 6241 | flags: []string{ |
| 6242 | "-renegotiate-once", |
| 6243 | "-expect-total-renegotiations", "1", |
| 6244 | }, |
| 6245 | }) |
| 6246 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6247 | name: "Renegotiate-Client-Freely-1", |
| 6248 | config: Config{ |
| 6249 | MaxVersion: VersionTLS12, |
| 6250 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6251 | renegotiate: 1, |
| 6252 | flags: []string{ |
| 6253 | "-renegotiate-freely", |
| 6254 | "-expect-total-renegotiations", "1", |
| 6255 | }, |
| 6256 | }) |
| 6257 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6258 | name: "Renegotiate-Client-Once-2", |
| 6259 | config: Config{ |
| 6260 | MaxVersion: VersionTLS12, |
| 6261 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6262 | renegotiate: 2, |
| 6263 | flags: []string{"-renegotiate-once"}, |
| 6264 | shouldFail: true, |
| 6265 | expectedError: ":NO_RENEGOTIATION:", |
| 6266 | expectedLocalError: "remote error: no renegotiation", |
| 6267 | }) |
| 6268 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6269 | name: "Renegotiate-Client-Freely-2", |
| 6270 | config: Config{ |
| 6271 | MaxVersion: VersionTLS12, |
| 6272 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6273 | renegotiate: 2, |
| 6274 | flags: []string{ |
| 6275 | "-renegotiate-freely", |
| 6276 | "-expect-total-renegotiations", "2", |
| 6277 | }, |
| 6278 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6279 | testCases = append(testCases, testCase{ |
| 6280 | name: "Renegotiate-Client-NoIgnore", |
| 6281 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6282 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6283 | Bugs: ProtocolBugs{ |
| 6284 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6285 | }, |
| 6286 | }, |
| 6287 | shouldFail: true, |
| 6288 | expectedError: ":NO_RENEGOTIATION:", |
| 6289 | }) |
| 6290 | testCases = append(testCases, testCase{ |
| 6291 | name: "Renegotiate-Client-Ignore", |
| 6292 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6293 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6294 | Bugs: ProtocolBugs{ |
| 6295 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6296 | }, |
| 6297 | }, |
| 6298 | flags: []string{ |
| 6299 | "-renegotiate-ignore", |
| 6300 | "-expect-total-renegotiations", "0", |
| 6301 | }, |
| 6302 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6303 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6304 | // Renegotiation is not allowed at SSL 3.0. |
| 6305 | testCases = append(testCases, testCase{ |
| 6306 | name: "Renegotiate-Client-SSL3", |
| 6307 | config: Config{ |
| 6308 | MaxVersion: VersionSSL30, |
| 6309 | }, |
| 6310 | renegotiate: 1, |
| 6311 | flags: []string{ |
| 6312 | "-renegotiate-freely", |
| 6313 | "-expect-total-renegotiations", "1", |
| 6314 | }, |
| 6315 | shouldFail: true, |
| 6316 | expectedError: ":NO_RENEGOTIATION:", |
| 6317 | expectedLocalError: "remote error: no renegotiation", |
| 6318 | }) |
| 6319 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6320 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6321 | testCases = append(testCases, testCase{ |
| 6322 | name: "StrayHelloRequest", |
| 6323 | config: Config{ |
| 6324 | MaxVersion: VersionTLS12, |
| 6325 | Bugs: ProtocolBugs{ |
| 6326 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6327 | }, |
| 6328 | }, |
| 6329 | }) |
| 6330 | testCases = append(testCases, testCase{ |
| 6331 | name: "StrayHelloRequest-Packed", |
| 6332 | config: Config{ |
| 6333 | MaxVersion: VersionTLS12, |
| 6334 | Bugs: ProtocolBugs{ |
| 6335 | PackHandshakeFlight: true, |
| 6336 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6337 | }, |
| 6338 | }, |
| 6339 | }) |
| 6340 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6341 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6342 | // the same record. |
| 6343 | testCases = append(testCases, testCase{ |
| 6344 | name: "Renegotiate-Client-Packed", |
| 6345 | config: Config{ |
| 6346 | MaxVersion: VersionTLS12, |
| 6347 | Bugs: ProtocolBugs{ |
| 6348 | PackHandshakeFlight: true, |
| 6349 | PackHelloRequestWithFinished: true, |
| 6350 | }, |
| 6351 | }, |
| 6352 | renegotiate: 1, |
| 6353 | flags: []string{ |
| 6354 | "-renegotiate-freely", |
| 6355 | "-expect-total-renegotiations", "1", |
| 6356 | }, |
| 6357 | }) |
| 6358 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6359 | // Renegotiation is forbidden in TLS 1.3. |
| 6360 | testCases = append(testCases, testCase{ |
| 6361 | name: "Renegotiate-Client-TLS13", |
| 6362 | config: Config{ |
| 6363 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6364 | Bugs: ProtocolBugs{ |
| 6365 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6366 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6367 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6368 | flags: []string{ |
| 6369 | "-renegotiate-freely", |
| 6370 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6371 | shouldFail: true, |
| 6372 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6373 | }) |
| 6374 | |
| 6375 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6376 | testCases = append(testCases, testCase{ |
| 6377 | name: "StrayHelloRequest-TLS13", |
| 6378 | config: Config{ |
| 6379 | MaxVersion: VersionTLS13, |
| 6380 | Bugs: ProtocolBugs{ |
| 6381 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6382 | }, |
| 6383 | }, |
| 6384 | shouldFail: true, |
| 6385 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6386 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6387 | } |
| 6388 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6389 | func addDTLSReplayTests() { |
| 6390 | // Test that sequence number replays are detected. |
| 6391 | testCases = append(testCases, testCase{ |
| 6392 | protocol: dtls, |
| 6393 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6394 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6395 | replayWrites: true, |
| 6396 | }) |
| 6397 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6398 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6399 | // than the retransmit window. |
| 6400 | testCases = append(testCases, testCase{ |
| 6401 | protocol: dtls, |
| 6402 | name: "DTLS-Replay-LargeGaps", |
| 6403 | config: Config{ |
| 6404 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6405 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6406 | return in * 127 |
| 6407 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6408 | }, |
| 6409 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6410 | messageCount: 200, |
| 6411 | replayWrites: true, |
| 6412 | }) |
| 6413 | |
| 6414 | // Test the incoming sequence number changing non-monotonically. |
| 6415 | testCases = append(testCases, testCase{ |
| 6416 | protocol: dtls, |
| 6417 | name: "DTLS-Replay-NonMonotonic", |
| 6418 | config: Config{ |
| 6419 | Bugs: ProtocolBugs{ |
| 6420 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6421 | return in ^ 31 |
| 6422 | }, |
| 6423 | }, |
| 6424 | }, |
| 6425 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6426 | replayWrites: true, |
| 6427 | }) |
| 6428 | } |
| 6429 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6430 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6431 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6432 | id signatureAlgorithm |
| 6433 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6434 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6435 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6436 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6437 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6438 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6439 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6440 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6441 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6442 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6443 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6444 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6445 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6446 | // Tests for key types prior to TLS 1.2. |
| 6447 | {"RSA", 0, testCertRSA}, |
| 6448 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6449 | } |
| 6450 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6451 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6452 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6453 | |
| 6454 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6455 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6456 | // versions a signing cipher. |
| 6457 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6458 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6459 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6460 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6461 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6462 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6463 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6464 | } |
| 6465 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6466 | var allAlgorithms []signatureAlgorithm |
| 6467 | for _, alg := range testSignatureAlgorithms { |
| 6468 | if alg.id != 0 { |
| 6469 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6470 | } |
| 6471 | } |
| 6472 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6473 | // Make sure each signature algorithm works. Include some fake values in |
| 6474 | // the list and ensure they're ignored. |
| 6475 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6476 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6477 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6478 | continue |
| 6479 | } |
| 6480 | |
| 6481 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6482 | // or remove it in C. |
| 6483 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6484 | continue |
| 6485 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6486 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6487 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6488 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6489 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6490 | shouldSignFail = true |
| 6491 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6492 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6493 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6494 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6495 | shouldSignFail = true |
| 6496 | shouldVerifyFail = true |
| 6497 | } |
| 6498 | |
| 6499 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6500 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6501 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6502 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6503 | |
| 6504 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6505 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6506 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6507 | } |
| 6508 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6509 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6510 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6511 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6512 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6513 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6514 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6515 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6516 | config: Config{ |
| 6517 | MaxVersion: ver.version, |
| 6518 | ClientAuth: RequireAnyClientCert, |
| 6519 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6520 | fakeSigAlg1, |
| 6521 | alg.id, |
| 6522 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6523 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6524 | }, |
| 6525 | flags: []string{ |
| 6526 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6527 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6528 | "-enable-all-curves", |
| 6529 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6530 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6531 | expectedError: signError, |
| 6532 | expectedPeerSignatureAlgorithm: alg.id, |
| 6533 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6534 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6535 | testCases = append(testCases, testCase{ |
| 6536 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6537 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6538 | config: Config{ |
| 6539 | MaxVersion: ver.version, |
| 6540 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6541 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6542 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6543 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6544 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6545 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6546 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6547 | // Some signature algorithms may not be advertised. |
| 6548 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6549 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6550 | }, |
| 6551 | flags: []string{ |
| 6552 | "-require-any-client-certificate", |
| 6553 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6554 | "-enable-all-curves", |
| 6555 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6556 | // Resume the session to assert the peer signature |
| 6557 | // algorithm is reported on both handshakes. |
| 6558 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6559 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6560 | expectedError: verifyError, |
| 6561 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6562 | |
| 6563 | testCases = append(testCases, testCase{ |
| 6564 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6565 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6566 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6567 | MaxVersion: ver.version, |
| 6568 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6569 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6570 | fakeSigAlg1, |
| 6571 | alg.id, |
| 6572 | fakeSigAlg2, |
| 6573 | }, |
| 6574 | }, |
| 6575 | flags: []string{ |
| 6576 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6577 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6578 | "-enable-all-curves", |
| 6579 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6580 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6581 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6582 | expectedPeerSignatureAlgorithm: alg.id, |
| 6583 | }) |
| 6584 | |
| 6585 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6586 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6587 | config: Config{ |
| 6588 | MaxVersion: ver.version, |
| 6589 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6590 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6591 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6592 | alg.id, |
| 6593 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6594 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6595 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6596 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6597 | // Some signature algorithms may not be advertised. |
| 6598 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6599 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6600 | }, |
| 6601 | flags: []string{ |
| 6602 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6603 | "-enable-all-curves", |
| 6604 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6605 | // Resume the session to assert the peer signature |
| 6606 | // algorithm is reported on both handshakes. |
| 6607 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6608 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6609 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6610 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6611 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6612 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6613 | testCases = append(testCases, testCase{ |
| 6614 | testType: serverTest, |
| 6615 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6616 | config: Config{ |
| 6617 | MaxVersion: ver.version, |
| 6618 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6619 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6620 | alg.id, |
| 6621 | }, |
| 6622 | Bugs: ProtocolBugs{ |
| 6623 | InvalidSignature: true, |
| 6624 | }, |
| 6625 | }, |
| 6626 | flags: []string{ |
| 6627 | "-require-any-client-certificate", |
| 6628 | "-enable-all-curves", |
| 6629 | }, |
| 6630 | shouldFail: true, |
| 6631 | expectedError: ":BAD_SIGNATURE:", |
| 6632 | }) |
| 6633 | |
| 6634 | testCases = append(testCases, testCase{ |
| 6635 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6636 | config: Config{ |
| 6637 | MaxVersion: ver.version, |
| 6638 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6639 | CipherSuites: signingCiphers, |
| 6640 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6641 | alg.id, |
| 6642 | }, |
| 6643 | Bugs: ProtocolBugs{ |
| 6644 | InvalidSignature: true, |
| 6645 | }, |
| 6646 | }, |
| 6647 | flags: []string{"-enable-all-curves"}, |
| 6648 | shouldFail: true, |
| 6649 | expectedError: ":BAD_SIGNATURE:", |
| 6650 | }) |
| 6651 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6652 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6653 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6654 | testCases = append(testCases, testCase{ |
| 6655 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6656 | config: Config{ |
| 6657 | MaxVersion: ver.version, |
| 6658 | ClientAuth: RequireAnyClientCert, |
| 6659 | VerifySignatureAlgorithms: allAlgorithms, |
| 6660 | }, |
| 6661 | flags: []string{ |
| 6662 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6663 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6664 | "-enable-all-curves", |
| 6665 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6666 | }, |
| 6667 | expectedPeerSignatureAlgorithm: alg.id, |
| 6668 | }) |
| 6669 | |
| 6670 | testCases = append(testCases, testCase{ |
| 6671 | testType: serverTest, |
| 6672 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6673 | config: Config{ |
| 6674 | MaxVersion: ver.version, |
| 6675 | CipherSuites: signingCiphers, |
| 6676 | VerifySignatureAlgorithms: allAlgorithms, |
| 6677 | }, |
| 6678 | flags: []string{ |
| 6679 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6680 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6681 | "-enable-all-curves", |
| 6682 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6683 | }, |
| 6684 | expectedPeerSignatureAlgorithm: alg.id, |
| 6685 | }) |
| 6686 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6687 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6688 | } |
| 6689 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6690 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6691 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6692 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6693 | config: Config{ |
| 6694 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6695 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6696 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6697 | signatureECDSAWithP521AndSHA512, |
| 6698 | signatureRSAPKCS1WithSHA384, |
| 6699 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6700 | }, |
| 6701 | }, |
| 6702 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6703 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6704 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6705 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6706 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6707 | }) |
| 6708 | |
| 6709 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6710 | name: "ClientAuth-SignatureType-TLS13", |
| 6711 | config: Config{ |
| 6712 | ClientAuth: RequireAnyClientCert, |
| 6713 | MaxVersion: VersionTLS13, |
| 6714 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6715 | signatureECDSAWithP521AndSHA512, |
| 6716 | signatureRSAPKCS1WithSHA384, |
| 6717 | signatureRSAPSSWithSHA384, |
| 6718 | signatureECDSAWithSHA1, |
| 6719 | }, |
| 6720 | }, |
| 6721 | flags: []string{ |
| 6722 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6723 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6724 | }, |
| 6725 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6726 | }) |
| 6727 | |
| 6728 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6729 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6730 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6731 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6732 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6733 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6734 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6735 | signatureECDSAWithP521AndSHA512, |
| 6736 | signatureRSAPKCS1WithSHA384, |
| 6737 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6738 | }, |
| 6739 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6740 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6741 | }) |
| 6742 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6743 | testCases = append(testCases, testCase{ |
| 6744 | testType: serverTest, |
| 6745 | name: "ServerAuth-SignatureType-TLS13", |
| 6746 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6747 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6748 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6749 | signatureECDSAWithP521AndSHA512, |
| 6750 | signatureRSAPKCS1WithSHA384, |
| 6751 | signatureRSAPSSWithSHA384, |
| 6752 | signatureECDSAWithSHA1, |
| 6753 | }, |
| 6754 | }, |
| 6755 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6756 | }) |
| 6757 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6758 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6759 | testCases = append(testCases, testCase{ |
| 6760 | testType: serverTest, |
| 6761 | name: "Verify-ClientAuth-SignatureType", |
| 6762 | config: Config{ |
| 6763 | MaxVersion: VersionTLS12, |
| 6764 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6765 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6766 | signatureRSAPKCS1WithSHA256, |
| 6767 | }, |
| 6768 | Bugs: ProtocolBugs{ |
| 6769 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6770 | }, |
| 6771 | }, |
| 6772 | flags: []string{ |
| 6773 | "-require-any-client-certificate", |
| 6774 | }, |
| 6775 | shouldFail: true, |
| 6776 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6777 | }) |
| 6778 | |
| 6779 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6780 | testType: serverTest, |
| 6781 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6782 | config: Config{ |
| 6783 | MaxVersion: VersionTLS13, |
| 6784 | Certificates: []Certificate{rsaCertificate}, |
| 6785 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6786 | signatureRSAPSSWithSHA256, |
| 6787 | }, |
| 6788 | Bugs: ProtocolBugs{ |
| 6789 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6790 | }, |
| 6791 | }, |
| 6792 | flags: []string{ |
| 6793 | "-require-any-client-certificate", |
| 6794 | }, |
| 6795 | shouldFail: true, |
| 6796 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6797 | }) |
| 6798 | |
| 6799 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6800 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6801 | config: Config{ |
| 6802 | MaxVersion: VersionTLS12, |
| 6803 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6804 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6805 | signatureRSAPKCS1WithSHA256, |
| 6806 | }, |
| 6807 | Bugs: ProtocolBugs{ |
| 6808 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6809 | }, |
| 6810 | }, |
| 6811 | shouldFail: true, |
| 6812 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6813 | }) |
| 6814 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6815 | testCases = append(testCases, testCase{ |
| 6816 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6817 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6818 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6819 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6820 | signatureRSAPSSWithSHA256, |
| 6821 | }, |
| 6822 | Bugs: ProtocolBugs{ |
| 6823 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6824 | }, |
| 6825 | }, |
| 6826 | shouldFail: true, |
| 6827 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6828 | }) |
| 6829 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6830 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6831 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6832 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6833 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6834 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6835 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6836 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6837 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6838 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6839 | }, |
| 6840 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6841 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6842 | }, |
| 6843 | }, |
| 6844 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6845 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6846 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6847 | }, |
| 6848 | }) |
| 6849 | |
| 6850 | testCases = append(testCases, testCase{ |
| 6851 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6852 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6853 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6854 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6855 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6856 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6857 | }, |
| 6858 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6859 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6860 | }, |
| 6861 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6862 | flags: []string{ |
| 6863 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6864 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6865 | }, |
| 6866 | }) |
| 6867 | |
| 6868 | testCases = append(testCases, testCase{ |
| 6869 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6870 | config: Config{ |
| 6871 | MaxVersion: VersionTLS12, |
| 6872 | ClientAuth: RequireAnyClientCert, |
| 6873 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6874 | signatureECDSAWithSHA1, |
| 6875 | }, |
| 6876 | Bugs: ProtocolBugs{ |
| 6877 | NoSignatureAlgorithms: true, |
| 6878 | }, |
| 6879 | }, |
| 6880 | flags: []string{ |
| 6881 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6882 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6883 | }, |
| 6884 | }) |
| 6885 | |
| 6886 | testCases = append(testCases, testCase{ |
| 6887 | testType: serverTest, |
| 6888 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6889 | config: Config{ |
| 6890 | MaxVersion: VersionTLS12, |
| 6891 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6892 | signatureECDSAWithSHA1, |
| 6893 | }, |
| 6894 | Bugs: ProtocolBugs{ |
| 6895 | NoSignatureAlgorithms: true, |
| 6896 | }, |
| 6897 | }, |
| 6898 | flags: []string{ |
| 6899 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6900 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6901 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6902 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6903 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6904 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6905 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6906 | config: Config{ |
| 6907 | MaxVersion: VersionTLS13, |
| 6908 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6909 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6910 | signatureRSAPKCS1WithSHA1, |
| 6911 | }, |
| 6912 | Bugs: ProtocolBugs{ |
| 6913 | NoSignatureAlgorithms: true, |
| 6914 | }, |
| 6915 | }, |
| 6916 | flags: []string{ |
| 6917 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6918 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6919 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6920 | shouldFail: true, |
| 6921 | // An empty CertificateRequest signature algorithm list is a |
| 6922 | // syntax error in TLS 1.3. |
| 6923 | expectedError: ":DECODE_ERROR:", |
| 6924 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6925 | }) |
| 6926 | |
| 6927 | testCases = append(testCases, testCase{ |
| 6928 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6929 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6930 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6931 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6932 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6933 | signatureRSAPKCS1WithSHA1, |
| 6934 | }, |
| 6935 | Bugs: ProtocolBugs{ |
| 6936 | NoSignatureAlgorithms: true, |
| 6937 | }, |
| 6938 | }, |
| 6939 | shouldFail: true, |
| 6940 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6941 | }) |
| 6942 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6943 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6944 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6945 | testCases = append(testCases, testCase{ |
| 6946 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6947 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6948 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6949 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6950 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6951 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6952 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6953 | }, |
| 6954 | Bugs: ProtocolBugs{ |
| 6955 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6956 | }, |
| 6957 | }, |
| 6958 | flags: []string{"-require-any-client-certificate"}, |
| 6959 | shouldFail: true, |
| 6960 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6961 | }) |
| 6962 | |
| 6963 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6964 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6965 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6966 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6967 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6968 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6969 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6970 | }, |
| 6971 | Bugs: ProtocolBugs{ |
| 6972 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6973 | }, |
| 6974 | }, |
| 6975 | shouldFail: true, |
| 6976 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6977 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6978 | testCases = append(testCases, testCase{ |
| 6979 | testType: serverTest, |
| 6980 | name: "ClientAuth-Enforced-TLS13", |
| 6981 | config: Config{ |
| 6982 | MaxVersion: VersionTLS13, |
| 6983 | Certificates: []Certificate{rsaCertificate}, |
| 6984 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6985 | signatureRSAPKCS1WithMD5, |
| 6986 | }, |
| 6987 | Bugs: ProtocolBugs{ |
| 6988 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6989 | IgnoreSignatureVersionChecks: true, |
| 6990 | }, |
| 6991 | }, |
| 6992 | flags: []string{"-require-any-client-certificate"}, |
| 6993 | shouldFail: true, |
| 6994 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6995 | }) |
| 6996 | |
| 6997 | testCases = append(testCases, testCase{ |
| 6998 | name: "ServerAuth-Enforced-TLS13", |
| 6999 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7000 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7001 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7002 | signatureRSAPKCS1WithMD5, |
| 7003 | }, |
| 7004 | Bugs: ProtocolBugs{ |
| 7005 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7006 | IgnoreSignatureVersionChecks: true, |
| 7007 | }, |
| 7008 | }, |
| 7009 | shouldFail: true, |
| 7010 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7011 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7012 | |
| 7013 | // Test that the agreed upon digest respects the client preferences and |
| 7014 | // the server digests. |
| 7015 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7016 | name: "NoCommonAlgorithms-Digests", |
| 7017 | config: Config{ |
| 7018 | MaxVersion: VersionTLS12, |
| 7019 | ClientAuth: RequireAnyClientCert, |
| 7020 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7021 | signatureRSAPKCS1WithSHA512, |
| 7022 | signatureRSAPKCS1WithSHA1, |
| 7023 | }, |
| 7024 | }, |
| 7025 | flags: []string{ |
| 7026 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7027 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7028 | "-digest-prefs", "SHA256", |
| 7029 | }, |
| 7030 | shouldFail: true, |
| 7031 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7032 | }) |
| 7033 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7034 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7035 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7036 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7037 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7038 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7039 | signatureRSAPKCS1WithSHA512, |
| 7040 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7041 | }, |
| 7042 | }, |
| 7043 | flags: []string{ |
| 7044 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7045 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7046 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7047 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7048 | shouldFail: true, |
| 7049 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7050 | }) |
| 7051 | testCases = append(testCases, testCase{ |
| 7052 | name: "NoCommonAlgorithms-TLS13", |
| 7053 | config: Config{ |
| 7054 | MaxVersion: VersionTLS13, |
| 7055 | ClientAuth: RequireAnyClientCert, |
| 7056 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7057 | signatureRSAPSSWithSHA512, |
| 7058 | signatureRSAPSSWithSHA384, |
| 7059 | }, |
| 7060 | }, |
| 7061 | flags: []string{ |
| 7062 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7063 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7064 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7065 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7066 | shouldFail: true, |
| 7067 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7068 | }) |
| 7069 | testCases = append(testCases, testCase{ |
| 7070 | name: "Agree-Digest-SHA256", |
| 7071 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7072 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7073 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7074 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7075 | signatureRSAPKCS1WithSHA1, |
| 7076 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7077 | }, |
| 7078 | }, |
| 7079 | flags: []string{ |
| 7080 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7081 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7082 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7083 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7084 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7085 | }) |
| 7086 | testCases = append(testCases, testCase{ |
| 7087 | name: "Agree-Digest-SHA1", |
| 7088 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7089 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7090 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7091 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7092 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7093 | }, |
| 7094 | }, |
| 7095 | flags: []string{ |
| 7096 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7097 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7098 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7099 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7100 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7101 | }) |
| 7102 | testCases = append(testCases, testCase{ |
| 7103 | name: "Agree-Digest-Default", |
| 7104 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7105 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7106 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7107 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7108 | signatureRSAPKCS1WithSHA256, |
| 7109 | signatureECDSAWithP256AndSHA256, |
| 7110 | signatureRSAPKCS1WithSHA1, |
| 7111 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7112 | }, |
| 7113 | }, |
| 7114 | flags: []string{ |
| 7115 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7116 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7117 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7118 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7119 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7120 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7121 | // Test that the signing preference list may include extra algorithms |
| 7122 | // without negotiation problems. |
| 7123 | testCases = append(testCases, testCase{ |
| 7124 | testType: serverTest, |
| 7125 | name: "FilterExtraAlgorithms", |
| 7126 | config: Config{ |
| 7127 | MaxVersion: VersionTLS12, |
| 7128 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7129 | signatureRSAPKCS1WithSHA256, |
| 7130 | }, |
| 7131 | }, |
| 7132 | flags: []string{ |
| 7133 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7134 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7135 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7136 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7137 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7138 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7139 | }, |
| 7140 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7141 | }) |
| 7142 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7143 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7144 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7145 | testCases = append(testCases, testCase{ |
| 7146 | name: "CheckLeafCurve", |
| 7147 | config: Config{ |
| 7148 | MaxVersion: VersionTLS12, |
| 7149 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7150 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7151 | }, |
| 7152 | flags: []string{"-p384-only"}, |
| 7153 | shouldFail: true, |
| 7154 | expectedError: ":BAD_ECC_CERT:", |
| 7155 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7156 | |
| 7157 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7158 | testCases = append(testCases, testCase{ |
| 7159 | name: "CheckLeafCurve-TLS13", |
| 7160 | config: Config{ |
| 7161 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7162 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7163 | }, |
| 7164 | flags: []string{"-p384-only"}, |
| 7165 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7166 | |
| 7167 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7168 | testCases = append(testCases, testCase{ |
| 7169 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7170 | config: Config{ |
| 7171 | MaxVersion: VersionTLS12, |
| 7172 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7173 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7174 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7175 | signatureECDSAWithP384AndSHA384, |
| 7176 | }, |
| 7177 | }, |
| 7178 | }) |
| 7179 | |
| 7180 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7181 | testCases = append(testCases, testCase{ |
| 7182 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7183 | config: Config{ |
| 7184 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7185 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7186 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7187 | signatureECDSAWithP384AndSHA384, |
| 7188 | }, |
| 7189 | Bugs: ProtocolBugs{ |
| 7190 | SkipECDSACurveCheck: true, |
| 7191 | }, |
| 7192 | }, |
| 7193 | shouldFail: true, |
| 7194 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7195 | }) |
| 7196 | |
| 7197 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7198 | // account. |
| 7199 | testCases = append(testCases, testCase{ |
| 7200 | testType: serverTest, |
| 7201 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7202 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7203 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7204 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7205 | signatureECDSAWithP384AndSHA384, |
| 7206 | signatureECDSAWithP256AndSHA256, |
| 7207 | }, |
| 7208 | }, |
| 7209 | flags: []string{ |
| 7210 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7211 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7212 | }, |
| 7213 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7214 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7215 | |
| 7216 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7217 | // server does not attempt to sign in that case. |
| 7218 | testCases = append(testCases, testCase{ |
| 7219 | testType: serverTest, |
| 7220 | name: "RSA-PSS-Large", |
| 7221 | config: Config{ |
| 7222 | MaxVersion: VersionTLS13, |
| 7223 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7224 | signatureRSAPSSWithSHA512, |
| 7225 | }, |
| 7226 | }, |
| 7227 | flags: []string{ |
| 7228 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7229 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7230 | }, |
| 7231 | shouldFail: true, |
| 7232 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7233 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7234 | |
| 7235 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7236 | testCases = append(testCases, testCase{ |
| 7237 | testType: clientTest, |
| 7238 | name: "RSA-PSS-Default-Verify", |
| 7239 | config: Config{ |
| 7240 | MaxVersion: VersionTLS12, |
| 7241 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7242 | signatureRSAPSSWithSHA256, |
| 7243 | }, |
| 7244 | }, |
| 7245 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7246 | }) |
| 7247 | |
| 7248 | testCases = append(testCases, testCase{ |
| 7249 | testType: serverTest, |
| 7250 | name: "RSA-PSS-Default-Sign", |
| 7251 | config: Config{ |
| 7252 | MaxVersion: VersionTLS12, |
| 7253 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7254 | signatureRSAPSSWithSHA256, |
| 7255 | }, |
| 7256 | }, |
| 7257 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7258 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7259 | } |
| 7260 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7261 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7262 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7263 | var timeouts = []time.Duration{ |
| 7264 | 1 * time.Second, |
| 7265 | 2 * time.Second, |
| 7266 | 4 * time.Second, |
| 7267 | 8 * time.Second, |
| 7268 | 16 * time.Second, |
| 7269 | 32 * time.Second, |
| 7270 | 60 * time.Second, |
| 7271 | 60 * time.Second, |
| 7272 | 60 * time.Second, |
| 7273 | 60 * time.Second, |
| 7274 | 60 * time.Second, |
| 7275 | 60 * time.Second, |
| 7276 | 60 * time.Second, |
| 7277 | } |
| 7278 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7279 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7280 | // initial timeout duration was set to 250ms. |
| 7281 | var shortTimeouts = []time.Duration{ |
| 7282 | 250 * time.Millisecond, |
| 7283 | 500 * time.Millisecond, |
| 7284 | 1 * time.Second, |
| 7285 | 2 * time.Second, |
| 7286 | 4 * time.Second, |
| 7287 | 8 * time.Second, |
| 7288 | 16 * time.Second, |
| 7289 | 32 * time.Second, |
| 7290 | 60 * time.Second, |
| 7291 | 60 * time.Second, |
| 7292 | 60 * time.Second, |
| 7293 | 60 * time.Second, |
| 7294 | 60 * time.Second, |
| 7295 | } |
| 7296 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7297 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7298 | // These tests work by coordinating some behavior on both the shim and |
| 7299 | // the runner. |
| 7300 | // |
| 7301 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7302 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7303 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7304 | // timeout in the shim and acts as a synchronization point to help the |
| 7305 | // runner bracket each handshake flight. |
| 7306 | // |
| 7307 | // We assume the shim does not read from the channel eagerly. It must |
| 7308 | // first wait until it has sent flight N and is ready to receive |
| 7309 | // handshake flight N+1. At this point, it will process the timeout |
| 7310 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7311 | // as if the shim was idle for the specified amount of time. |
| 7312 | // |
| 7313 | // The runner then drops all packets received before the ACK and |
| 7314 | // continues waiting for flight N. This ordering results in one attempt |
| 7315 | // at sending flight N to be dropped. For the test to complete, the |
| 7316 | // shim must send flight N again, testing that the shim implements DTLS |
| 7317 | // retransmit on a timeout. |
| 7318 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7319 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7320 | // likely be more epochs to cross and the final message's retransmit may |
| 7321 | // be more complex. |
| 7322 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7323 | for _, async := range []bool{true, false} { |
| 7324 | var tests []testCase |
| 7325 | |
| 7326 | // Test that this is indeed the timeout schedule. Stress all |
| 7327 | // four patterns of handshake. |
| 7328 | for i := 1; i < len(timeouts); i++ { |
| 7329 | number := strconv.Itoa(i) |
| 7330 | tests = append(tests, testCase{ |
| 7331 | protocol: dtls, |
| 7332 | name: "DTLS-Retransmit-Client-" + number, |
| 7333 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7334 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7335 | Bugs: ProtocolBugs{ |
| 7336 | TimeoutSchedule: timeouts[:i], |
| 7337 | }, |
| 7338 | }, |
| 7339 | resumeSession: true, |
| 7340 | }) |
| 7341 | tests = append(tests, testCase{ |
| 7342 | protocol: dtls, |
| 7343 | testType: serverTest, |
| 7344 | name: "DTLS-Retransmit-Server-" + number, |
| 7345 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7346 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7347 | Bugs: ProtocolBugs{ |
| 7348 | TimeoutSchedule: timeouts[:i], |
| 7349 | }, |
| 7350 | }, |
| 7351 | resumeSession: true, |
| 7352 | }) |
| 7353 | } |
| 7354 | |
| 7355 | // Test that exceeding the timeout schedule hits a read |
| 7356 | // timeout. |
| 7357 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7358 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7359 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7360 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7361 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7362 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7363 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7364 | }, |
| 7365 | }, |
| 7366 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7367 | shouldFail: true, |
| 7368 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7369 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7370 | |
| 7371 | if async { |
| 7372 | // Test that timeout handling has a fudge factor, due to API |
| 7373 | // problems. |
| 7374 | tests = append(tests, testCase{ |
| 7375 | protocol: dtls, |
| 7376 | name: "DTLS-Retransmit-Fudge", |
| 7377 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7378 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7379 | Bugs: ProtocolBugs{ |
| 7380 | TimeoutSchedule: []time.Duration{ |
| 7381 | timeouts[0] - 10*time.Millisecond, |
| 7382 | }, |
| 7383 | }, |
| 7384 | }, |
| 7385 | resumeSession: true, |
| 7386 | }) |
| 7387 | } |
| 7388 | |
| 7389 | // Test that the final Finished retransmitting isn't |
| 7390 | // duplicated if the peer badly fragments everything. |
| 7391 | tests = append(tests, testCase{ |
| 7392 | testType: serverTest, |
| 7393 | protocol: dtls, |
| 7394 | name: "DTLS-Retransmit-Fragmented", |
| 7395 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7396 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7397 | Bugs: ProtocolBugs{ |
| 7398 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7399 | MaxHandshakeRecordLength: 2, |
| 7400 | }, |
| 7401 | }, |
| 7402 | }) |
| 7403 | |
| 7404 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7405 | tests = append(tests, testCase{ |
| 7406 | protocol: dtls, |
| 7407 | name: "DTLS-Retransmit-Short-Client", |
| 7408 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7409 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7410 | Bugs: ProtocolBugs{ |
| 7411 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7412 | }, |
| 7413 | }, |
| 7414 | resumeSession: true, |
| 7415 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 7416 | }) |
| 7417 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7418 | protocol: dtls, |
| 7419 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7420 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7421 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7422 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7423 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7424 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7425 | }, |
| 7426 | }, |
| 7427 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7428 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7429 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7430 | |
| 7431 | for _, test := range tests { |
| 7432 | if async { |
| 7433 | test.name += "-Async" |
| 7434 | test.flags = append(test.flags, "-async") |
| 7435 | } |
| 7436 | |
| 7437 | testCases = append(testCases, test) |
| 7438 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7439 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7440 | } |
| 7441 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7442 | func addExportKeyingMaterialTests() { |
| 7443 | for _, vers := range tlsVersions { |
| 7444 | if vers.version == VersionSSL30 { |
| 7445 | continue |
| 7446 | } |
| 7447 | testCases = append(testCases, testCase{ |
| 7448 | name: "ExportKeyingMaterial-" + vers.name, |
| 7449 | config: Config{ |
| 7450 | MaxVersion: vers.version, |
| 7451 | }, |
| 7452 | exportKeyingMaterial: 1024, |
| 7453 | exportLabel: "label", |
| 7454 | exportContext: "context", |
| 7455 | useExportContext: true, |
| 7456 | }) |
| 7457 | testCases = append(testCases, testCase{ |
| 7458 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7459 | config: Config{ |
| 7460 | MaxVersion: vers.version, |
| 7461 | }, |
| 7462 | exportKeyingMaterial: 1024, |
| 7463 | }) |
| 7464 | testCases = append(testCases, testCase{ |
| 7465 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7466 | config: Config{ |
| 7467 | MaxVersion: vers.version, |
| 7468 | }, |
| 7469 | exportKeyingMaterial: 1024, |
| 7470 | useExportContext: true, |
| 7471 | }) |
| 7472 | testCases = append(testCases, testCase{ |
| 7473 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7474 | config: Config{ |
| 7475 | MaxVersion: vers.version, |
| 7476 | }, |
| 7477 | exportKeyingMaterial: 1, |
| 7478 | exportLabel: "label", |
| 7479 | exportContext: "context", |
| 7480 | useExportContext: true, |
| 7481 | }) |
| 7482 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7483 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7484 | testCases = append(testCases, testCase{ |
| 7485 | name: "ExportKeyingMaterial-SSL3", |
| 7486 | config: Config{ |
| 7487 | MaxVersion: VersionSSL30, |
| 7488 | }, |
| 7489 | exportKeyingMaterial: 1024, |
| 7490 | exportLabel: "label", |
| 7491 | exportContext: "context", |
| 7492 | useExportContext: true, |
| 7493 | shouldFail: true, |
| 7494 | expectedError: "failed to export keying material", |
| 7495 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7496 | |
| 7497 | // Exporters work during a False Start. |
| 7498 | testCases = append(testCases, testCase{ |
| 7499 | name: "ExportKeyingMaterial-FalseStart", |
| 7500 | config: Config{ |
| 7501 | MaxVersion: VersionTLS12, |
| 7502 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7503 | NextProtos: []string{"foo"}, |
| 7504 | Bugs: ProtocolBugs{ |
| 7505 | ExpectFalseStart: true, |
| 7506 | }, |
| 7507 | }, |
| 7508 | flags: []string{ |
| 7509 | "-false-start", |
| 7510 | "-advertise-alpn", "\x03foo", |
| 7511 | }, |
| 7512 | shimWritesFirst: true, |
| 7513 | exportKeyingMaterial: 1024, |
| 7514 | exportLabel: "label", |
| 7515 | exportContext: "context", |
| 7516 | useExportContext: true, |
| 7517 | }) |
| 7518 | |
| 7519 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7520 | // triggering the exporter after every SSL_read call and configuring the |
| 7521 | // shim to run asynchronously. |
| 7522 | testCases = append(testCases, testCase{ |
| 7523 | name: "ExportKeyingMaterial-Renegotiate", |
| 7524 | config: Config{ |
| 7525 | MaxVersion: VersionTLS12, |
| 7526 | }, |
| 7527 | renegotiate: 1, |
| 7528 | flags: []string{ |
| 7529 | "-async", |
| 7530 | "-use-exporter-between-reads", |
| 7531 | "-renegotiate-freely", |
| 7532 | "-expect-total-renegotiations", "1", |
| 7533 | }, |
| 7534 | shouldFail: true, |
| 7535 | expectedError: "failed to export keying material", |
| 7536 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7537 | } |
| 7538 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7539 | func addTLSUniqueTests() { |
| 7540 | for _, isClient := range []bool{false, true} { |
| 7541 | for _, isResumption := range []bool{false, true} { |
| 7542 | for _, hasEMS := range []bool{false, true} { |
| 7543 | var suffix string |
| 7544 | if isResumption { |
| 7545 | suffix = "Resume-" |
| 7546 | } else { |
| 7547 | suffix = "Full-" |
| 7548 | } |
| 7549 | |
| 7550 | if hasEMS { |
| 7551 | suffix += "EMS-" |
| 7552 | } else { |
| 7553 | suffix += "NoEMS-" |
| 7554 | } |
| 7555 | |
| 7556 | if isClient { |
| 7557 | suffix += "Client" |
| 7558 | } else { |
| 7559 | suffix += "Server" |
| 7560 | } |
| 7561 | |
| 7562 | test := testCase{ |
| 7563 | name: "TLSUnique-" + suffix, |
| 7564 | testTLSUnique: true, |
| 7565 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7566 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7567 | Bugs: ProtocolBugs{ |
| 7568 | NoExtendedMasterSecret: !hasEMS, |
| 7569 | }, |
| 7570 | }, |
| 7571 | } |
| 7572 | |
| 7573 | if isResumption { |
| 7574 | test.resumeSession = true |
| 7575 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7576 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7577 | Bugs: ProtocolBugs{ |
| 7578 | NoExtendedMasterSecret: !hasEMS, |
| 7579 | }, |
| 7580 | } |
| 7581 | } |
| 7582 | |
| 7583 | if isResumption && !hasEMS { |
| 7584 | test.shouldFail = true |
| 7585 | test.expectedError = "failed to get tls-unique" |
| 7586 | } |
| 7587 | |
| 7588 | testCases = append(testCases, test) |
| 7589 | } |
| 7590 | } |
| 7591 | } |
| 7592 | } |
| 7593 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7594 | func addCustomExtensionTests() { |
| 7595 | expectedContents := "custom extension" |
| 7596 | emptyString := "" |
| 7597 | |
| 7598 | for _, isClient := range []bool{false, true} { |
| 7599 | suffix := "Server" |
| 7600 | flag := "-enable-server-custom-extension" |
| 7601 | testType := serverTest |
| 7602 | if isClient { |
| 7603 | suffix = "Client" |
| 7604 | flag = "-enable-client-custom-extension" |
| 7605 | testType = clientTest |
| 7606 | } |
| 7607 | |
| 7608 | testCases = append(testCases, testCase{ |
| 7609 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7610 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7611 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7612 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7613 | Bugs: ProtocolBugs{ |
| 7614 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7615 | ExpectedCustomExtension: &expectedContents, |
| 7616 | }, |
| 7617 | }, |
| 7618 | flags: []string{flag}, |
| 7619 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7620 | testCases = append(testCases, testCase{ |
| 7621 | testType: testType, |
| 7622 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7623 | config: Config{ |
| 7624 | MaxVersion: VersionTLS13, |
| 7625 | Bugs: ProtocolBugs{ |
| 7626 | CustomExtension: expectedContents, |
| 7627 | ExpectedCustomExtension: &expectedContents, |
| 7628 | }, |
| 7629 | }, |
| 7630 | flags: []string{flag}, |
| 7631 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7632 | |
| 7633 | // If the parse callback fails, the handshake should also fail. |
| 7634 | testCases = append(testCases, testCase{ |
| 7635 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7636 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7637 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7638 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7639 | Bugs: ProtocolBugs{ |
| 7640 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7641 | ExpectedCustomExtension: &expectedContents, |
| 7642 | }, |
| 7643 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7644 | flags: []string{flag}, |
| 7645 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7646 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7647 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7648 | testCases = append(testCases, testCase{ |
| 7649 | testType: testType, |
| 7650 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7651 | config: Config{ |
| 7652 | MaxVersion: VersionTLS13, |
| 7653 | Bugs: ProtocolBugs{ |
| 7654 | CustomExtension: expectedContents + "foo", |
| 7655 | ExpectedCustomExtension: &expectedContents, |
| 7656 | }, |
| 7657 | }, |
| 7658 | flags: []string{flag}, |
| 7659 | shouldFail: true, |
| 7660 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7661 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7662 | |
| 7663 | // If the add callback fails, the handshake should also fail. |
| 7664 | testCases = append(testCases, testCase{ |
| 7665 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7666 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7667 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7668 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7669 | Bugs: ProtocolBugs{ |
| 7670 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7671 | ExpectedCustomExtension: &expectedContents, |
| 7672 | }, |
| 7673 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7674 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7675 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7676 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7677 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7678 | testCases = append(testCases, testCase{ |
| 7679 | testType: testType, |
| 7680 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7681 | config: Config{ |
| 7682 | MaxVersion: VersionTLS13, |
| 7683 | Bugs: ProtocolBugs{ |
| 7684 | CustomExtension: expectedContents, |
| 7685 | ExpectedCustomExtension: &expectedContents, |
| 7686 | }, |
| 7687 | }, |
| 7688 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7689 | shouldFail: true, |
| 7690 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7691 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7692 | |
| 7693 | // If the add callback returns zero, no extension should be |
| 7694 | // added. |
| 7695 | skipCustomExtension := expectedContents |
| 7696 | if isClient { |
| 7697 | // For the case where the client skips sending the |
| 7698 | // custom extension, the server must not “echo” it. |
| 7699 | skipCustomExtension = "" |
| 7700 | } |
| 7701 | testCases = append(testCases, testCase{ |
| 7702 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7703 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7704 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7705 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7706 | Bugs: ProtocolBugs{ |
| 7707 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7708 | ExpectedCustomExtension: &emptyString, |
| 7709 | }, |
| 7710 | }, |
| 7711 | flags: []string{flag, "-custom-extension-skip"}, |
| 7712 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7713 | testCases = append(testCases, testCase{ |
| 7714 | testType: testType, |
| 7715 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7716 | config: Config{ |
| 7717 | MaxVersion: VersionTLS13, |
| 7718 | Bugs: ProtocolBugs{ |
| 7719 | CustomExtension: skipCustomExtension, |
| 7720 | ExpectedCustomExtension: &emptyString, |
| 7721 | }, |
| 7722 | }, |
| 7723 | flags: []string{flag, "-custom-extension-skip"}, |
| 7724 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7725 | } |
| 7726 | |
| 7727 | // The custom extension add callback should not be called if the client |
| 7728 | // doesn't send the extension. |
| 7729 | testCases = append(testCases, testCase{ |
| 7730 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7731 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7732 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7733 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7734 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7735 | ExpectedCustomExtension: &emptyString, |
| 7736 | }, |
| 7737 | }, |
| 7738 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7739 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7740 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7741 | testCases = append(testCases, testCase{ |
| 7742 | testType: serverTest, |
| 7743 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7744 | config: Config{ |
| 7745 | MaxVersion: VersionTLS13, |
| 7746 | Bugs: ProtocolBugs{ |
| 7747 | ExpectedCustomExtension: &emptyString, |
| 7748 | }, |
| 7749 | }, |
| 7750 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7751 | }) |
| 7752 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7753 | // Test an unknown extension from the server. |
| 7754 | testCases = append(testCases, testCase{ |
| 7755 | testType: clientTest, |
| 7756 | name: "UnknownExtension-Client", |
| 7757 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7758 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7759 | Bugs: ProtocolBugs{ |
| 7760 | CustomExtension: expectedContents, |
| 7761 | }, |
| 7762 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7763 | shouldFail: true, |
| 7764 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7765 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7766 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7767 | testCases = append(testCases, testCase{ |
| 7768 | testType: clientTest, |
| 7769 | name: "UnknownExtension-Client-TLS13", |
| 7770 | config: Config{ |
| 7771 | MaxVersion: VersionTLS13, |
| 7772 | Bugs: ProtocolBugs{ |
| 7773 | CustomExtension: expectedContents, |
| 7774 | }, |
| 7775 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7776 | shouldFail: true, |
| 7777 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7778 | expectedLocalError: "remote error: unsupported extension", |
| 7779 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7780 | testCases = append(testCases, testCase{ |
| 7781 | testType: clientTest, |
| 7782 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7783 | config: Config{ |
| 7784 | MaxVersion: VersionTLS13, |
| 7785 | Bugs: ProtocolBugs{ |
| 7786 | CustomUnencryptedExtension: expectedContents, |
| 7787 | }, |
| 7788 | }, |
| 7789 | shouldFail: true, |
| 7790 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7791 | // The shim must send an alert, but alerts at this point do not |
| 7792 | // get successfully decrypted by the runner. |
| 7793 | expectedLocalError: "local error: bad record MAC", |
| 7794 | }) |
| 7795 | testCases = append(testCases, testCase{ |
| 7796 | testType: clientTest, |
| 7797 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7798 | config: Config{ |
| 7799 | MaxVersion: VersionTLS13, |
| 7800 | Bugs: ProtocolBugs{ |
| 7801 | SendUnencryptedALPN: "foo", |
| 7802 | }, |
| 7803 | }, |
| 7804 | flags: []string{ |
| 7805 | "-advertise-alpn", "\x03foo\x03bar", |
| 7806 | }, |
| 7807 | shouldFail: true, |
| 7808 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7809 | // The shim must send an alert, but alerts at this point do not |
| 7810 | // get successfully decrypted by the runner. |
| 7811 | expectedLocalError: "local error: bad record MAC", |
| 7812 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7813 | |
| 7814 | // Test a known but unoffered extension from the server. |
| 7815 | testCases = append(testCases, testCase{ |
| 7816 | testType: clientTest, |
| 7817 | name: "UnofferedExtension-Client", |
| 7818 | config: Config{ |
| 7819 | MaxVersion: VersionTLS12, |
| 7820 | Bugs: ProtocolBugs{ |
| 7821 | SendALPN: "alpn", |
| 7822 | }, |
| 7823 | }, |
| 7824 | shouldFail: true, |
| 7825 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7826 | expectedLocalError: "remote error: unsupported extension", |
| 7827 | }) |
| 7828 | testCases = append(testCases, testCase{ |
| 7829 | testType: clientTest, |
| 7830 | name: "UnofferedExtension-Client-TLS13", |
| 7831 | config: Config{ |
| 7832 | MaxVersion: VersionTLS13, |
| 7833 | Bugs: ProtocolBugs{ |
| 7834 | SendALPN: "alpn", |
| 7835 | }, |
| 7836 | }, |
| 7837 | shouldFail: true, |
| 7838 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7839 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7840 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7841 | } |
| 7842 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7843 | func addRSAClientKeyExchangeTests() { |
| 7844 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7845 | testCases = append(testCases, testCase{ |
| 7846 | testType: serverTest, |
| 7847 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7848 | config: Config{ |
| 7849 | // Ensure the ClientHello version and final |
| 7850 | // version are different, to detect if the |
| 7851 | // server uses the wrong one. |
| 7852 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7853 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7854 | Bugs: ProtocolBugs{ |
| 7855 | BadRSAClientKeyExchange: bad, |
| 7856 | }, |
| 7857 | }, |
| 7858 | shouldFail: true, |
| 7859 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7860 | }) |
| 7861 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7862 | |
| 7863 | // The server must compare whatever was in ClientHello.version for the |
| 7864 | // RSA premaster. |
| 7865 | testCases = append(testCases, testCase{ |
| 7866 | testType: serverTest, |
| 7867 | name: "SendClientVersion-RSA", |
| 7868 | config: Config{ |
| 7869 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7870 | Bugs: ProtocolBugs{ |
| 7871 | SendClientVersion: 0x1234, |
| 7872 | }, |
| 7873 | }, |
| 7874 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7875 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7876 | } |
| 7877 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7878 | var testCurves = []struct { |
| 7879 | name string |
| 7880 | id CurveID |
| 7881 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7882 | {"P-256", CurveP256}, |
| 7883 | {"P-384", CurveP384}, |
| 7884 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7885 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7886 | } |
| 7887 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7888 | const bogusCurve = 0x1234 |
| 7889 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7890 | func addCurveTests() { |
| 7891 | for _, curve := range testCurves { |
| 7892 | testCases = append(testCases, testCase{ |
| 7893 | name: "CurveTest-Client-" + curve.name, |
| 7894 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7895 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7896 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7897 | CurvePreferences: []CurveID{curve.id}, |
| 7898 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7899 | flags: []string{ |
| 7900 | "-enable-all-curves", |
| 7901 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7902 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7903 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7904 | }) |
| 7905 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7906 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7907 | config: Config{ |
| 7908 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7909 | CurvePreferences: []CurveID{curve.id}, |
| 7910 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7911 | flags: []string{ |
| 7912 | "-enable-all-curves", |
| 7913 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7914 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7915 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7916 | }) |
| 7917 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7918 | testType: serverTest, |
| 7919 | name: "CurveTest-Server-" + curve.name, |
| 7920 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7921 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7922 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7923 | CurvePreferences: []CurveID{curve.id}, |
| 7924 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7925 | flags: []string{ |
| 7926 | "-enable-all-curves", |
| 7927 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7928 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7929 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7930 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7931 | testCases = append(testCases, testCase{ |
| 7932 | testType: serverTest, |
| 7933 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7934 | config: Config{ |
| 7935 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7936 | CurvePreferences: []CurveID{curve.id}, |
| 7937 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7938 | flags: []string{ |
| 7939 | "-enable-all-curves", |
| 7940 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7941 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7942 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7943 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7944 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7945 | |
| 7946 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7947 | testCases = append(testCases, testCase{ |
| 7948 | testType: serverTest, |
| 7949 | name: "UnknownCurve", |
| 7950 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7951 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7952 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7953 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7954 | }, |
| 7955 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7956 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7957 | // The server must be tolerant to bogus curves. |
| 7958 | testCases = append(testCases, testCase{ |
| 7959 | testType: serverTest, |
| 7960 | name: "UnknownCurve-TLS13", |
| 7961 | config: Config{ |
| 7962 | MaxVersion: VersionTLS13, |
| 7963 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7964 | }, |
| 7965 | }) |
| 7966 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7967 | // The server must not consider ECDHE ciphers when there are no |
| 7968 | // supported curves. |
| 7969 | testCases = append(testCases, testCase{ |
| 7970 | testType: serverTest, |
| 7971 | name: "NoSupportedCurves", |
| 7972 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7973 | MaxVersion: VersionTLS12, |
| 7974 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7975 | Bugs: ProtocolBugs{ |
| 7976 | NoSupportedCurves: true, |
| 7977 | }, |
| 7978 | }, |
| 7979 | shouldFail: true, |
| 7980 | expectedError: ":NO_SHARED_CIPHER:", |
| 7981 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7982 | testCases = append(testCases, testCase{ |
| 7983 | testType: serverTest, |
| 7984 | name: "NoSupportedCurves-TLS13", |
| 7985 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7986 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7987 | Bugs: ProtocolBugs{ |
| 7988 | NoSupportedCurves: true, |
| 7989 | }, |
| 7990 | }, |
| 7991 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7992 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7993 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7994 | |
| 7995 | // The server must fall back to another cipher when there are no |
| 7996 | // supported curves. |
| 7997 | testCases = append(testCases, testCase{ |
| 7998 | testType: serverTest, |
| 7999 | name: "NoCommonCurves", |
| 8000 | config: Config{ |
| 8001 | MaxVersion: VersionTLS12, |
| 8002 | CipherSuites: []uint16{ |
| 8003 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8004 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8005 | }, |
| 8006 | CurvePreferences: []CurveID{CurveP224}, |
| 8007 | }, |
| 8008 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8009 | }) |
| 8010 | |
| 8011 | // The client must reject bogus curves and disabled curves. |
| 8012 | testCases = append(testCases, testCase{ |
| 8013 | name: "BadECDHECurve", |
| 8014 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8015 | MaxVersion: VersionTLS12, |
| 8016 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8017 | Bugs: ProtocolBugs{ |
| 8018 | SendCurve: bogusCurve, |
| 8019 | }, |
| 8020 | }, |
| 8021 | shouldFail: true, |
| 8022 | expectedError: ":WRONG_CURVE:", |
| 8023 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8024 | testCases = append(testCases, testCase{ |
| 8025 | name: "BadECDHECurve-TLS13", |
| 8026 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8027 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8028 | Bugs: ProtocolBugs{ |
| 8029 | SendCurve: bogusCurve, |
| 8030 | }, |
| 8031 | }, |
| 8032 | shouldFail: true, |
| 8033 | expectedError: ":WRONG_CURVE:", |
| 8034 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8035 | |
| 8036 | testCases = append(testCases, testCase{ |
| 8037 | name: "UnsupportedCurve", |
| 8038 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8039 | MaxVersion: VersionTLS12, |
| 8040 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8041 | CurvePreferences: []CurveID{CurveP256}, |
| 8042 | Bugs: ProtocolBugs{ |
| 8043 | IgnorePeerCurvePreferences: true, |
| 8044 | }, |
| 8045 | }, |
| 8046 | flags: []string{"-p384-only"}, |
| 8047 | shouldFail: true, |
| 8048 | expectedError: ":WRONG_CURVE:", |
| 8049 | }) |
| 8050 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8051 | testCases = append(testCases, testCase{ |
| 8052 | // TODO(davidben): Add a TLS 1.3 version where |
| 8053 | // HelloRetryRequest requests an unsupported curve. |
| 8054 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8055 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8056 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8057 | CurvePreferences: []CurveID{CurveP384}, |
| 8058 | Bugs: ProtocolBugs{ |
| 8059 | SendCurve: CurveP256, |
| 8060 | }, |
| 8061 | }, |
| 8062 | flags: []string{"-p384-only"}, |
| 8063 | shouldFail: true, |
| 8064 | expectedError: ":WRONG_CURVE:", |
| 8065 | }) |
| 8066 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8067 | // Test invalid curve points. |
| 8068 | testCases = append(testCases, testCase{ |
| 8069 | name: "InvalidECDHPoint-Client", |
| 8070 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8071 | MaxVersion: VersionTLS12, |
| 8072 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8073 | CurvePreferences: []CurveID{CurveP256}, |
| 8074 | Bugs: ProtocolBugs{ |
| 8075 | InvalidECDHPoint: true, |
| 8076 | }, |
| 8077 | }, |
| 8078 | shouldFail: true, |
| 8079 | expectedError: ":INVALID_ENCODING:", |
| 8080 | }) |
| 8081 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8082 | name: "InvalidECDHPoint-Client-TLS13", |
| 8083 | config: Config{ |
| 8084 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8085 | CurvePreferences: []CurveID{CurveP256}, |
| 8086 | Bugs: ProtocolBugs{ |
| 8087 | InvalidECDHPoint: true, |
| 8088 | }, |
| 8089 | }, |
| 8090 | shouldFail: true, |
| 8091 | expectedError: ":INVALID_ENCODING:", |
| 8092 | }) |
| 8093 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8094 | testType: serverTest, |
| 8095 | name: "InvalidECDHPoint-Server", |
| 8096 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8097 | MaxVersion: VersionTLS12, |
| 8098 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8099 | CurvePreferences: []CurveID{CurveP256}, |
| 8100 | Bugs: ProtocolBugs{ |
| 8101 | InvalidECDHPoint: true, |
| 8102 | }, |
| 8103 | }, |
| 8104 | shouldFail: true, |
| 8105 | expectedError: ":INVALID_ENCODING:", |
| 8106 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8107 | testCases = append(testCases, testCase{ |
| 8108 | testType: serverTest, |
| 8109 | name: "InvalidECDHPoint-Server-TLS13", |
| 8110 | config: Config{ |
| 8111 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8112 | CurvePreferences: []CurveID{CurveP256}, |
| 8113 | Bugs: ProtocolBugs{ |
| 8114 | InvalidECDHPoint: true, |
| 8115 | }, |
| 8116 | }, |
| 8117 | shouldFail: true, |
| 8118 | expectedError: ":INVALID_ENCODING:", |
| 8119 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8120 | |
| 8121 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 8122 | testCases = append(testCases, testCase{ |
| 8123 | name: "CurveID-Resume-Client", |
| 8124 | config: Config{ |
| 8125 | MaxVersion: VersionTLS12, |
| 8126 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8127 | CurvePreferences: []CurveID{CurveX25519}, |
| 8128 | }, |
| 8129 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8130 | resumeSession: true, |
| 8131 | }) |
| 8132 | testCases = append(testCases, testCase{ |
| 8133 | testType: serverTest, |
| 8134 | name: "CurveID-Resume-Server", |
| 8135 | config: Config{ |
| 8136 | MaxVersion: VersionTLS12, |
| 8137 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8138 | CurvePreferences: []CurveID{CurveX25519}, |
| 8139 | }, |
| 8140 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8141 | resumeSession: true, |
| 8142 | }) |
| 8143 | |
| 8144 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 8145 | // one should be reported. |
| 8146 | testCases = append(testCases, testCase{ |
| 8147 | name: "CurveID-Resume-Client-TLS13", |
| 8148 | config: Config{ |
| 8149 | MaxVersion: VersionTLS13, |
| 8150 | CurvePreferences: []CurveID{CurveX25519}, |
| 8151 | }, |
| 8152 | resumeConfig: &Config{ |
| 8153 | MaxVersion: VersionTLS13, |
| 8154 | CurvePreferences: []CurveID{CurveP256}, |
| 8155 | }, |
| 8156 | flags: []string{ |
| 8157 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8158 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8159 | }, |
| 8160 | resumeSession: true, |
| 8161 | }) |
| 8162 | testCases = append(testCases, testCase{ |
| 8163 | testType: serverTest, |
| 8164 | name: "CurveID-Resume-Server-TLS13", |
| 8165 | config: Config{ |
| 8166 | MaxVersion: VersionTLS13, |
| 8167 | CurvePreferences: []CurveID{CurveX25519}, |
| 8168 | }, |
| 8169 | resumeConfig: &Config{ |
| 8170 | MaxVersion: VersionTLS13, |
| 8171 | CurvePreferences: []CurveID{CurveP256}, |
| 8172 | }, |
| 8173 | flags: []string{ |
| 8174 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8175 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8176 | }, |
| 8177 | resumeSession: true, |
| 8178 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8179 | } |
| 8180 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8181 | func addTLS13RecordTests() { |
| 8182 | testCases = append(testCases, testCase{ |
| 8183 | name: "TLS13-RecordPadding", |
| 8184 | config: Config{ |
| 8185 | MaxVersion: VersionTLS13, |
| 8186 | MinVersion: VersionTLS13, |
| 8187 | Bugs: ProtocolBugs{ |
| 8188 | RecordPadding: 10, |
| 8189 | }, |
| 8190 | }, |
| 8191 | }) |
| 8192 | |
| 8193 | testCases = append(testCases, testCase{ |
| 8194 | name: "TLS13-EmptyRecords", |
| 8195 | config: Config{ |
| 8196 | MaxVersion: VersionTLS13, |
| 8197 | MinVersion: VersionTLS13, |
| 8198 | Bugs: ProtocolBugs{ |
| 8199 | OmitRecordContents: true, |
| 8200 | }, |
| 8201 | }, |
| 8202 | shouldFail: true, |
| 8203 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8204 | }) |
| 8205 | |
| 8206 | testCases = append(testCases, testCase{ |
| 8207 | name: "TLS13-OnlyPadding", |
| 8208 | config: Config{ |
| 8209 | MaxVersion: VersionTLS13, |
| 8210 | MinVersion: VersionTLS13, |
| 8211 | Bugs: ProtocolBugs{ |
| 8212 | OmitRecordContents: true, |
| 8213 | RecordPadding: 10, |
| 8214 | }, |
| 8215 | }, |
| 8216 | shouldFail: true, |
| 8217 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8218 | }) |
| 8219 | |
| 8220 | testCases = append(testCases, testCase{ |
| 8221 | name: "TLS13-WrongOuterRecord", |
| 8222 | config: Config{ |
| 8223 | MaxVersion: VersionTLS13, |
| 8224 | MinVersion: VersionTLS13, |
| 8225 | Bugs: ProtocolBugs{ |
| 8226 | OuterRecordType: recordTypeHandshake, |
| 8227 | }, |
| 8228 | }, |
| 8229 | shouldFail: true, |
| 8230 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8231 | }) |
| 8232 | } |
| 8233 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8234 | func addSessionTicketTests() { |
| 8235 | testCases = append(testCases, testCase{ |
| 8236 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8237 | // mean the server changed its mind on sending a ticket. |
| 8238 | name: "SendEmptySessionTicket", |
| 8239 | config: Config{ |
| 8240 | MaxVersion: VersionTLS12, |
| 8241 | Bugs: ProtocolBugs{ |
| 8242 | SendEmptySessionTicket: true, |
| 8243 | }, |
| 8244 | }, |
| 8245 | flags: []string{"-expect-no-session"}, |
| 8246 | }) |
| 8247 | |
| 8248 | // Test that the server ignores unknown PSK modes. |
| 8249 | testCases = append(testCases, testCase{ |
| 8250 | testType: serverTest, |
| 8251 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8252 | config: Config{ |
| 8253 | MaxVersion: VersionTLS13, |
| 8254 | Bugs: ProtocolBugs{ |
| 8255 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8256 | }, |
| 8257 | }, |
| 8258 | resumeSession: true, |
| 8259 | expectedResumeVersion: VersionTLS13, |
| 8260 | }) |
| 8261 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8262 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8263 | testCases = append(testCases, testCase{ |
| 8264 | testType: serverTest, |
| 8265 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8266 | config: Config{ |
| 8267 | MaxVersion: VersionTLS13, |
| 8268 | Bugs: ProtocolBugs{ |
| 8269 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8270 | ExpectNoNewSessionTicket: true, |
| 8271 | }, |
| 8272 | }, |
| 8273 | }) |
| 8274 | |
| 8275 | // 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] | 8276 | testCases = append(testCases, testCase{ |
| 8277 | testType: serverTest, |
| 8278 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8279 | config: Config{ |
| 8280 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8281 | }, |
| 8282 | resumeConfig: &Config{ |
| 8283 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8284 | Bugs: ProtocolBugs{ |
| 8285 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8286 | }, |
| 8287 | }, |
| 8288 | resumeSession: true, |
| 8289 | expectResumeRejected: true, |
| 8290 | }) |
| 8291 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8292 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8293 | testCases = append(testCases, testCase{ |
| 8294 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8295 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8296 | config: Config{ |
| 8297 | MaxVersion: VersionTLS13, |
| 8298 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8299 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8300 | }, |
| 8301 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8302 | resumeSession: true, |
| 8303 | flags: []string{ |
| 8304 | "-resumption-delay", "10", |
| 8305 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8306 | }) |
| 8307 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8308 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8309 | testCases = append(testCases, testCase{ |
| 8310 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8311 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8312 | config: Config{ |
| 8313 | MaxVersion: VersionTLS13, |
| 8314 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8315 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8316 | }, |
| 8317 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8318 | resumeSession: true, |
| 8319 | shouldFail: true, |
| 8320 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8321 | }) |
| 8322 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8323 | } |
| 8324 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8325 | func addChangeCipherSpecTests() { |
| 8326 | // Test missing ChangeCipherSpecs. |
| 8327 | testCases = append(testCases, testCase{ |
| 8328 | name: "SkipChangeCipherSpec-Client", |
| 8329 | config: Config{ |
| 8330 | MaxVersion: VersionTLS12, |
| 8331 | Bugs: ProtocolBugs{ |
| 8332 | SkipChangeCipherSpec: true, |
| 8333 | }, |
| 8334 | }, |
| 8335 | shouldFail: true, |
| 8336 | expectedError: ":UNEXPECTED_RECORD:", |
| 8337 | }) |
| 8338 | testCases = append(testCases, testCase{ |
| 8339 | testType: serverTest, |
| 8340 | name: "SkipChangeCipherSpec-Server", |
| 8341 | config: Config{ |
| 8342 | MaxVersion: VersionTLS12, |
| 8343 | Bugs: ProtocolBugs{ |
| 8344 | SkipChangeCipherSpec: true, |
| 8345 | }, |
| 8346 | }, |
| 8347 | shouldFail: true, |
| 8348 | expectedError: ":UNEXPECTED_RECORD:", |
| 8349 | }) |
| 8350 | testCases = append(testCases, testCase{ |
| 8351 | testType: serverTest, |
| 8352 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8353 | config: Config{ |
| 8354 | MaxVersion: VersionTLS12, |
| 8355 | NextProtos: []string{"bar"}, |
| 8356 | Bugs: ProtocolBugs{ |
| 8357 | SkipChangeCipherSpec: true, |
| 8358 | }, |
| 8359 | }, |
| 8360 | flags: []string{ |
| 8361 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8362 | }, |
| 8363 | shouldFail: true, |
| 8364 | expectedError: ":UNEXPECTED_RECORD:", |
| 8365 | }) |
| 8366 | |
| 8367 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8368 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8369 | // rejected. Test both with and without handshake packing to handle both |
| 8370 | // when the partial post-CCS message is in its own record and when it is |
| 8371 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8372 | for _, packed := range []bool{false, true} { |
| 8373 | var suffix string |
| 8374 | if packed { |
| 8375 | suffix = "-Packed" |
| 8376 | } |
| 8377 | |
| 8378 | testCases = append(testCases, testCase{ |
| 8379 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8380 | config: Config{ |
| 8381 | MaxVersion: VersionTLS12, |
| 8382 | Bugs: ProtocolBugs{ |
| 8383 | FragmentAcrossChangeCipherSpec: true, |
| 8384 | PackHandshakeFlight: packed, |
| 8385 | }, |
| 8386 | }, |
| 8387 | shouldFail: true, |
| 8388 | expectedError: ":UNEXPECTED_RECORD:", |
| 8389 | }) |
| 8390 | testCases = append(testCases, testCase{ |
| 8391 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8392 | config: Config{ |
| 8393 | MaxVersion: VersionTLS12, |
| 8394 | }, |
| 8395 | resumeSession: true, |
| 8396 | resumeConfig: &Config{ |
| 8397 | MaxVersion: VersionTLS12, |
| 8398 | Bugs: ProtocolBugs{ |
| 8399 | FragmentAcrossChangeCipherSpec: true, |
| 8400 | PackHandshakeFlight: packed, |
| 8401 | }, |
| 8402 | }, |
| 8403 | shouldFail: true, |
| 8404 | expectedError: ":UNEXPECTED_RECORD:", |
| 8405 | }) |
| 8406 | testCases = append(testCases, testCase{ |
| 8407 | testType: serverTest, |
| 8408 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8409 | config: Config{ |
| 8410 | MaxVersion: VersionTLS12, |
| 8411 | Bugs: ProtocolBugs{ |
| 8412 | FragmentAcrossChangeCipherSpec: true, |
| 8413 | PackHandshakeFlight: packed, |
| 8414 | }, |
| 8415 | }, |
| 8416 | shouldFail: true, |
| 8417 | expectedError: ":UNEXPECTED_RECORD:", |
| 8418 | }) |
| 8419 | testCases = append(testCases, testCase{ |
| 8420 | testType: serverTest, |
| 8421 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8422 | config: Config{ |
| 8423 | MaxVersion: VersionTLS12, |
| 8424 | }, |
| 8425 | resumeSession: true, |
| 8426 | resumeConfig: &Config{ |
| 8427 | MaxVersion: VersionTLS12, |
| 8428 | Bugs: ProtocolBugs{ |
| 8429 | FragmentAcrossChangeCipherSpec: true, |
| 8430 | PackHandshakeFlight: packed, |
| 8431 | }, |
| 8432 | }, |
| 8433 | shouldFail: true, |
| 8434 | expectedError: ":UNEXPECTED_RECORD:", |
| 8435 | }) |
| 8436 | testCases = append(testCases, testCase{ |
| 8437 | testType: serverTest, |
| 8438 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8439 | config: Config{ |
| 8440 | MaxVersion: VersionTLS12, |
| 8441 | NextProtos: []string{"bar"}, |
| 8442 | Bugs: ProtocolBugs{ |
| 8443 | FragmentAcrossChangeCipherSpec: true, |
| 8444 | PackHandshakeFlight: packed, |
| 8445 | }, |
| 8446 | }, |
| 8447 | flags: []string{ |
| 8448 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8449 | }, |
| 8450 | shouldFail: true, |
| 8451 | expectedError: ":UNEXPECTED_RECORD:", |
| 8452 | }) |
| 8453 | } |
| 8454 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8455 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8456 | // messages in the handshake queue. Do this by testing the server |
| 8457 | // reading the client Finished, reversing the flight so Finished comes |
| 8458 | // first. |
| 8459 | testCases = append(testCases, testCase{ |
| 8460 | protocol: dtls, |
| 8461 | testType: serverTest, |
| 8462 | name: "SendUnencryptedFinished-DTLS", |
| 8463 | config: Config{ |
| 8464 | MaxVersion: VersionTLS12, |
| 8465 | Bugs: ProtocolBugs{ |
| 8466 | SendUnencryptedFinished: true, |
| 8467 | ReverseHandshakeFragments: true, |
| 8468 | }, |
| 8469 | }, |
| 8470 | shouldFail: true, |
| 8471 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8472 | }) |
| 8473 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8474 | // Test synchronization between encryption changes and the handshake in |
| 8475 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8476 | testCases = append(testCases, testCase{ |
| 8477 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8478 | config: Config{ |
| 8479 | MaxVersion: VersionTLS13, |
| 8480 | Bugs: ProtocolBugs{ |
| 8481 | PartialEncryptedExtensionsWithServerHello: true, |
| 8482 | }, |
| 8483 | }, |
| 8484 | shouldFail: true, |
| 8485 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8486 | }) |
| 8487 | testCases = append(testCases, testCase{ |
| 8488 | testType: serverTest, |
| 8489 | name: "PartialClientFinishedWithClientHello", |
| 8490 | config: Config{ |
| 8491 | MaxVersion: VersionTLS13, |
| 8492 | Bugs: ProtocolBugs{ |
| 8493 | PartialClientFinishedWithClientHello: true, |
| 8494 | }, |
| 8495 | }, |
| 8496 | shouldFail: true, |
| 8497 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8498 | }) |
| 8499 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8500 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8501 | testCases = append(testCases, testCase{ |
| 8502 | testType: serverTest, |
| 8503 | name: "EarlyChangeCipherSpec-server-1", |
| 8504 | config: Config{ |
| 8505 | MaxVersion: VersionTLS12, |
| 8506 | Bugs: ProtocolBugs{ |
| 8507 | EarlyChangeCipherSpec: 1, |
| 8508 | }, |
| 8509 | }, |
| 8510 | shouldFail: true, |
| 8511 | expectedError: ":UNEXPECTED_RECORD:", |
| 8512 | }) |
| 8513 | testCases = append(testCases, testCase{ |
| 8514 | testType: serverTest, |
| 8515 | name: "EarlyChangeCipherSpec-server-2", |
| 8516 | config: Config{ |
| 8517 | MaxVersion: VersionTLS12, |
| 8518 | Bugs: ProtocolBugs{ |
| 8519 | EarlyChangeCipherSpec: 2, |
| 8520 | }, |
| 8521 | }, |
| 8522 | shouldFail: true, |
| 8523 | expectedError: ":UNEXPECTED_RECORD:", |
| 8524 | }) |
| 8525 | testCases = append(testCases, testCase{ |
| 8526 | protocol: dtls, |
| 8527 | name: "StrayChangeCipherSpec", |
| 8528 | config: Config{ |
| 8529 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8530 | // that stray ChangeCipherSpec messages are |
| 8531 | // rejected. |
| 8532 | MaxVersion: VersionTLS12, |
| 8533 | Bugs: ProtocolBugs{ |
| 8534 | StrayChangeCipherSpec: true, |
| 8535 | }, |
| 8536 | }, |
| 8537 | }) |
| 8538 | |
| 8539 | // Test that the contents of ChangeCipherSpec are checked. |
| 8540 | testCases = append(testCases, testCase{ |
| 8541 | name: "BadChangeCipherSpec-1", |
| 8542 | config: Config{ |
| 8543 | MaxVersion: VersionTLS12, |
| 8544 | Bugs: ProtocolBugs{ |
| 8545 | BadChangeCipherSpec: []byte{2}, |
| 8546 | }, |
| 8547 | }, |
| 8548 | shouldFail: true, |
| 8549 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8550 | }) |
| 8551 | testCases = append(testCases, testCase{ |
| 8552 | name: "BadChangeCipherSpec-2", |
| 8553 | config: Config{ |
| 8554 | MaxVersion: VersionTLS12, |
| 8555 | Bugs: ProtocolBugs{ |
| 8556 | BadChangeCipherSpec: []byte{1, 1}, |
| 8557 | }, |
| 8558 | }, |
| 8559 | shouldFail: true, |
| 8560 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8561 | }) |
| 8562 | testCases = append(testCases, testCase{ |
| 8563 | protocol: dtls, |
| 8564 | name: "BadChangeCipherSpec-DTLS-1", |
| 8565 | config: Config{ |
| 8566 | MaxVersion: VersionTLS12, |
| 8567 | Bugs: ProtocolBugs{ |
| 8568 | BadChangeCipherSpec: []byte{2}, |
| 8569 | }, |
| 8570 | }, |
| 8571 | shouldFail: true, |
| 8572 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8573 | }) |
| 8574 | testCases = append(testCases, testCase{ |
| 8575 | protocol: dtls, |
| 8576 | name: "BadChangeCipherSpec-DTLS-2", |
| 8577 | config: Config{ |
| 8578 | MaxVersion: VersionTLS12, |
| 8579 | Bugs: ProtocolBugs{ |
| 8580 | BadChangeCipherSpec: []byte{1, 1}, |
| 8581 | }, |
| 8582 | }, |
| 8583 | shouldFail: true, |
| 8584 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8585 | }) |
| 8586 | } |
| 8587 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8588 | type perMessageTest struct { |
| 8589 | messageType uint8 |
| 8590 | test testCase |
| 8591 | } |
| 8592 | |
| 8593 | // makePerMessageTests returns a series of test templates which cover each |
| 8594 | // message in the TLS handshake. These may be used with bugs like |
| 8595 | // WrongMessageType to fully test a per-message bug. |
| 8596 | func makePerMessageTests() []perMessageTest { |
| 8597 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8598 | for _, protocol := range []protocol{tls, dtls} { |
| 8599 | var suffix string |
| 8600 | if protocol == dtls { |
| 8601 | suffix = "-DTLS" |
| 8602 | } |
| 8603 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8604 | ret = append(ret, perMessageTest{ |
| 8605 | messageType: typeClientHello, |
| 8606 | test: testCase{ |
| 8607 | protocol: protocol, |
| 8608 | testType: serverTest, |
| 8609 | name: "ClientHello" + suffix, |
| 8610 | config: Config{ |
| 8611 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8612 | }, |
| 8613 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8614 | }) |
| 8615 | |
| 8616 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8617 | ret = append(ret, perMessageTest{ |
| 8618 | messageType: typeHelloVerifyRequest, |
| 8619 | test: testCase{ |
| 8620 | protocol: protocol, |
| 8621 | name: "HelloVerifyRequest" + suffix, |
| 8622 | config: Config{ |
| 8623 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8624 | }, |
| 8625 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8626 | }) |
| 8627 | } |
| 8628 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8629 | ret = append(ret, perMessageTest{ |
| 8630 | messageType: typeServerHello, |
| 8631 | test: testCase{ |
| 8632 | protocol: protocol, |
| 8633 | name: "ServerHello" + suffix, |
| 8634 | config: Config{ |
| 8635 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8636 | }, |
| 8637 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8638 | }) |
| 8639 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8640 | ret = append(ret, perMessageTest{ |
| 8641 | messageType: typeCertificate, |
| 8642 | test: testCase{ |
| 8643 | protocol: protocol, |
| 8644 | name: "ServerCertificate" + suffix, |
| 8645 | config: Config{ |
| 8646 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8647 | }, |
| 8648 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8649 | }) |
| 8650 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8651 | ret = append(ret, perMessageTest{ |
| 8652 | messageType: typeCertificateStatus, |
| 8653 | test: testCase{ |
| 8654 | protocol: protocol, |
| 8655 | name: "CertificateStatus" + suffix, |
| 8656 | config: Config{ |
| 8657 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8658 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8659 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8660 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8661 | }) |
| 8662 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8663 | ret = append(ret, perMessageTest{ |
| 8664 | messageType: typeServerKeyExchange, |
| 8665 | test: testCase{ |
| 8666 | protocol: protocol, |
| 8667 | name: "ServerKeyExchange" + suffix, |
| 8668 | config: Config{ |
| 8669 | MaxVersion: VersionTLS12, |
| 8670 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8671 | }, |
| 8672 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8673 | }) |
| 8674 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8675 | ret = append(ret, perMessageTest{ |
| 8676 | messageType: typeCertificateRequest, |
| 8677 | test: testCase{ |
| 8678 | protocol: protocol, |
| 8679 | name: "CertificateRequest" + suffix, |
| 8680 | config: Config{ |
| 8681 | MaxVersion: VersionTLS12, |
| 8682 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8683 | }, |
| 8684 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8685 | }) |
| 8686 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8687 | ret = append(ret, perMessageTest{ |
| 8688 | messageType: typeServerHelloDone, |
| 8689 | test: testCase{ |
| 8690 | protocol: protocol, |
| 8691 | name: "ServerHelloDone" + suffix, |
| 8692 | config: Config{ |
| 8693 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8694 | }, |
| 8695 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8696 | }) |
| 8697 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8698 | ret = append(ret, perMessageTest{ |
| 8699 | messageType: typeCertificate, |
| 8700 | test: testCase{ |
| 8701 | testType: serverTest, |
| 8702 | protocol: protocol, |
| 8703 | name: "ClientCertificate" + suffix, |
| 8704 | config: Config{ |
| 8705 | Certificates: []Certificate{rsaCertificate}, |
| 8706 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8707 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8708 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8709 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8710 | }) |
| 8711 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8712 | ret = append(ret, perMessageTest{ |
| 8713 | messageType: typeCertificateVerify, |
| 8714 | test: testCase{ |
| 8715 | testType: serverTest, |
| 8716 | protocol: protocol, |
| 8717 | name: "CertificateVerify" + suffix, |
| 8718 | config: Config{ |
| 8719 | Certificates: []Certificate{rsaCertificate}, |
| 8720 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8721 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8722 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8723 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8724 | }) |
| 8725 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8726 | ret = append(ret, perMessageTest{ |
| 8727 | messageType: typeClientKeyExchange, |
| 8728 | test: testCase{ |
| 8729 | testType: serverTest, |
| 8730 | protocol: protocol, |
| 8731 | name: "ClientKeyExchange" + suffix, |
| 8732 | config: Config{ |
| 8733 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8734 | }, |
| 8735 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8736 | }) |
| 8737 | |
| 8738 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8739 | ret = append(ret, perMessageTest{ |
| 8740 | messageType: typeNextProtocol, |
| 8741 | test: testCase{ |
| 8742 | testType: serverTest, |
| 8743 | protocol: protocol, |
| 8744 | name: "NextProtocol" + suffix, |
| 8745 | config: Config{ |
| 8746 | MaxVersion: VersionTLS12, |
| 8747 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8748 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8749 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8750 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8751 | }) |
| 8752 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8753 | ret = append(ret, perMessageTest{ |
| 8754 | messageType: typeChannelID, |
| 8755 | test: testCase{ |
| 8756 | testType: serverTest, |
| 8757 | protocol: protocol, |
| 8758 | name: "ChannelID" + suffix, |
| 8759 | config: Config{ |
| 8760 | MaxVersion: VersionTLS12, |
| 8761 | ChannelID: channelIDKey, |
| 8762 | }, |
| 8763 | flags: []string{ |
| 8764 | "-expect-channel-id", |
| 8765 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8766 | }, |
| 8767 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8768 | }) |
| 8769 | } |
| 8770 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8771 | ret = append(ret, perMessageTest{ |
| 8772 | messageType: typeFinished, |
| 8773 | test: testCase{ |
| 8774 | testType: serverTest, |
| 8775 | protocol: protocol, |
| 8776 | name: "ClientFinished" + suffix, |
| 8777 | config: Config{ |
| 8778 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8779 | }, |
| 8780 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8781 | }) |
| 8782 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8783 | ret = append(ret, perMessageTest{ |
| 8784 | messageType: typeNewSessionTicket, |
| 8785 | test: testCase{ |
| 8786 | protocol: protocol, |
| 8787 | name: "NewSessionTicket" + suffix, |
| 8788 | config: Config{ |
| 8789 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8790 | }, |
| 8791 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8792 | }) |
| 8793 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8794 | ret = append(ret, perMessageTest{ |
| 8795 | messageType: typeFinished, |
| 8796 | test: testCase{ |
| 8797 | protocol: protocol, |
| 8798 | name: "ServerFinished" + suffix, |
| 8799 | config: Config{ |
| 8800 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8801 | }, |
| 8802 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8803 | }) |
| 8804 | |
| 8805 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8806 | |
| 8807 | ret = append(ret, perMessageTest{ |
| 8808 | messageType: typeClientHello, |
| 8809 | test: testCase{ |
| 8810 | testType: serverTest, |
| 8811 | name: "TLS13-ClientHello", |
| 8812 | config: Config{ |
| 8813 | MaxVersion: VersionTLS13, |
| 8814 | }, |
| 8815 | }, |
| 8816 | }) |
| 8817 | |
| 8818 | ret = append(ret, perMessageTest{ |
| 8819 | messageType: typeServerHello, |
| 8820 | test: testCase{ |
| 8821 | name: "TLS13-ServerHello", |
| 8822 | config: Config{ |
| 8823 | MaxVersion: VersionTLS13, |
| 8824 | }, |
| 8825 | }, |
| 8826 | }) |
| 8827 | |
| 8828 | ret = append(ret, perMessageTest{ |
| 8829 | messageType: typeEncryptedExtensions, |
| 8830 | test: testCase{ |
| 8831 | name: "TLS13-EncryptedExtensions", |
| 8832 | config: Config{ |
| 8833 | MaxVersion: VersionTLS13, |
| 8834 | }, |
| 8835 | }, |
| 8836 | }) |
| 8837 | |
| 8838 | ret = append(ret, perMessageTest{ |
| 8839 | messageType: typeCertificateRequest, |
| 8840 | test: testCase{ |
| 8841 | name: "TLS13-CertificateRequest", |
| 8842 | config: Config{ |
| 8843 | MaxVersion: VersionTLS13, |
| 8844 | ClientAuth: RequireAnyClientCert, |
| 8845 | }, |
| 8846 | }, |
| 8847 | }) |
| 8848 | |
| 8849 | ret = append(ret, perMessageTest{ |
| 8850 | messageType: typeCertificate, |
| 8851 | test: testCase{ |
| 8852 | name: "TLS13-ServerCertificate", |
| 8853 | config: Config{ |
| 8854 | MaxVersion: VersionTLS13, |
| 8855 | }, |
| 8856 | }, |
| 8857 | }) |
| 8858 | |
| 8859 | ret = append(ret, perMessageTest{ |
| 8860 | messageType: typeCertificateVerify, |
| 8861 | test: testCase{ |
| 8862 | name: "TLS13-ServerCertificateVerify", |
| 8863 | config: Config{ |
| 8864 | MaxVersion: VersionTLS13, |
| 8865 | }, |
| 8866 | }, |
| 8867 | }) |
| 8868 | |
| 8869 | ret = append(ret, perMessageTest{ |
| 8870 | messageType: typeFinished, |
| 8871 | test: testCase{ |
| 8872 | name: "TLS13-ServerFinished", |
| 8873 | config: Config{ |
| 8874 | MaxVersion: VersionTLS13, |
| 8875 | }, |
| 8876 | }, |
| 8877 | }) |
| 8878 | |
| 8879 | ret = append(ret, perMessageTest{ |
| 8880 | messageType: typeCertificate, |
| 8881 | test: testCase{ |
| 8882 | testType: serverTest, |
| 8883 | name: "TLS13-ClientCertificate", |
| 8884 | config: Config{ |
| 8885 | Certificates: []Certificate{rsaCertificate}, |
| 8886 | MaxVersion: VersionTLS13, |
| 8887 | }, |
| 8888 | flags: []string{"-require-any-client-certificate"}, |
| 8889 | }, |
| 8890 | }) |
| 8891 | |
| 8892 | ret = append(ret, perMessageTest{ |
| 8893 | messageType: typeCertificateVerify, |
| 8894 | test: testCase{ |
| 8895 | testType: serverTest, |
| 8896 | name: "TLS13-ClientCertificateVerify", |
| 8897 | config: Config{ |
| 8898 | Certificates: []Certificate{rsaCertificate}, |
| 8899 | MaxVersion: VersionTLS13, |
| 8900 | }, |
| 8901 | flags: []string{"-require-any-client-certificate"}, |
| 8902 | }, |
| 8903 | }) |
| 8904 | |
| 8905 | ret = append(ret, perMessageTest{ |
| 8906 | messageType: typeFinished, |
| 8907 | test: testCase{ |
| 8908 | testType: serverTest, |
| 8909 | name: "TLS13-ClientFinished", |
| 8910 | config: Config{ |
| 8911 | MaxVersion: VersionTLS13, |
| 8912 | }, |
| 8913 | }, |
| 8914 | }) |
| 8915 | |
| 8916 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8917 | } |
| 8918 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8919 | func addWrongMessageTypeTests() { |
| 8920 | for _, t := range makePerMessageTests() { |
| 8921 | t.test.name = "WrongMessageType-" + t.test.name |
| 8922 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 8923 | t.test.shouldFail = true |
| 8924 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 8925 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8926 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8927 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8928 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8929 | // an unencrypted alert while the server expects |
| 8930 | // encryption, so the alert is not readable by runner. |
| 8931 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8932 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8933 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8934 | testCases = append(testCases, t.test) |
| 8935 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8936 | } |
| 8937 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8938 | func addTrailingMessageDataTests() { |
| 8939 | for _, t := range makePerMessageTests() { |
| 8940 | t.test.name = "TrailingMessageData-" + t.test.name |
| 8941 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 8942 | t.test.shouldFail = true |
| 8943 | t.test.expectedError = ":DECODE_ERROR:" |
| 8944 | t.test.expectedLocalError = "remote error: error decoding message" |
| 8945 | |
| 8946 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8947 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8948 | // an unencrypted alert while the server expects |
| 8949 | // encryption, so the alert is not readable by runner. |
| 8950 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8951 | } |
| 8952 | |
| 8953 | if t.messageType == typeFinished { |
| 8954 | // Bad Finished messages read as the verify data having |
| 8955 | // the wrong length. |
| 8956 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 8957 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 8958 | } |
| 8959 | |
| 8960 | testCases = append(testCases, t.test) |
| 8961 | } |
| 8962 | } |
| 8963 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8964 | func addTLS13HandshakeTests() { |
| 8965 | testCases = append(testCases, testCase{ |
| 8966 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8967 | name: "NegotiatePSKResumption-TLS13", |
| 8968 | config: Config{ |
| 8969 | MaxVersion: VersionTLS13, |
| 8970 | Bugs: ProtocolBugs{ |
| 8971 | NegotiatePSKResumption: true, |
| 8972 | }, |
| 8973 | }, |
| 8974 | resumeSession: true, |
| 8975 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 8976 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8977 | }) |
| 8978 | |
| 8979 | testCases = append(testCases, testCase{ |
| 8980 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8981 | name: "MissingKeyShare-Client", |
| 8982 | config: Config{ |
| 8983 | MaxVersion: VersionTLS13, |
| 8984 | Bugs: ProtocolBugs{ |
| 8985 | MissingKeyShare: true, |
| 8986 | }, |
| 8987 | }, |
| 8988 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 8989 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8990 | }) |
| 8991 | |
| 8992 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8993 | testType: serverTest, |
| 8994 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8995 | config: Config{ |
| 8996 | MaxVersion: VersionTLS13, |
| 8997 | Bugs: ProtocolBugs{ |
| 8998 | MissingKeyShare: true, |
| 8999 | }, |
| 9000 | }, |
| 9001 | shouldFail: true, |
| 9002 | expectedError: ":MISSING_KEY_SHARE:", |
| 9003 | }) |
| 9004 | |
| 9005 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9006 | testType: serverTest, |
| 9007 | name: "DuplicateKeyShares", |
| 9008 | config: Config{ |
| 9009 | MaxVersion: VersionTLS13, |
| 9010 | Bugs: ProtocolBugs{ |
| 9011 | DuplicateKeyShares: true, |
| 9012 | }, |
| 9013 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9014 | shouldFail: true, |
| 9015 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9016 | }) |
| 9017 | |
| 9018 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9019 | testType: serverTest, |
| 9020 | name: "SkipEarlyData", |
| 9021 | config: Config{ |
| 9022 | MaxVersion: VersionTLS13, |
| 9023 | Bugs: ProtocolBugs{ |
| 9024 | SendEarlyDataLength: 4, |
| 9025 | }, |
| 9026 | }, |
| 9027 | }) |
| 9028 | |
| 9029 | testCases = append(testCases, testCase{ |
| 9030 | testType: serverTest, |
| 9031 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9032 | config: Config{ |
| 9033 | MaxVersion: VersionTLS13, |
| 9034 | Bugs: ProtocolBugs{ |
| 9035 | SendEarlyDataLength: 4, |
| 9036 | OmitEarlyDataExtension: true, |
| 9037 | }, |
| 9038 | }, |
| 9039 | shouldFail: true, |
| 9040 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9041 | }) |
| 9042 | |
| 9043 | testCases = append(testCases, testCase{ |
| 9044 | testType: serverTest, |
| 9045 | name: "SkipEarlyData-TooMuchData", |
| 9046 | config: Config{ |
| 9047 | MaxVersion: VersionTLS13, |
| 9048 | Bugs: ProtocolBugs{ |
| 9049 | SendEarlyDataLength: 16384 + 1, |
| 9050 | }, |
| 9051 | }, |
| 9052 | shouldFail: true, |
| 9053 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9054 | }) |
| 9055 | |
| 9056 | testCases = append(testCases, testCase{ |
| 9057 | testType: serverTest, |
| 9058 | name: "SkipEarlyData-Interleaved", |
| 9059 | config: Config{ |
| 9060 | MaxVersion: VersionTLS13, |
| 9061 | Bugs: ProtocolBugs{ |
| 9062 | SendEarlyDataLength: 4, |
| 9063 | InterleaveEarlyData: true, |
| 9064 | }, |
| 9065 | }, |
| 9066 | shouldFail: true, |
| 9067 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9068 | }) |
| 9069 | |
| 9070 | testCases = append(testCases, testCase{ |
| 9071 | testType: serverTest, |
| 9072 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 9073 | config: Config{ |
| 9074 | MaxVersion: VersionTLS13, |
| 9075 | Bugs: ProtocolBugs{ |
| 9076 | SendEarlyDataLength: 4, |
| 9077 | }, |
| 9078 | }, |
| 9079 | shouldFail: true, |
| 9080 | expectedError: ":UNEXPECTED_RECORD:", |
| 9081 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9082 | }) |
| 9083 | |
| 9084 | testCases = append(testCases, testCase{ |
| 9085 | testType: serverTest, |
| 9086 | name: "SkipEarlyData-HRR", |
| 9087 | config: Config{ |
| 9088 | MaxVersion: VersionTLS13, |
| 9089 | Bugs: ProtocolBugs{ |
| 9090 | SendEarlyDataLength: 4, |
| 9091 | }, |
| 9092 | DefaultCurves: []CurveID{}, |
| 9093 | }, |
| 9094 | }) |
| 9095 | |
| 9096 | testCases = append(testCases, testCase{ |
| 9097 | testType: serverTest, |
| 9098 | name: "SkipEarlyData-HRR-Interleaved", |
| 9099 | config: Config{ |
| 9100 | MaxVersion: VersionTLS13, |
| 9101 | Bugs: ProtocolBugs{ |
| 9102 | SendEarlyDataLength: 4, |
| 9103 | InterleaveEarlyData: true, |
| 9104 | }, |
| 9105 | DefaultCurves: []CurveID{}, |
| 9106 | }, |
| 9107 | shouldFail: true, |
| 9108 | expectedError: ":UNEXPECTED_RECORD:", |
| 9109 | }) |
| 9110 | |
| 9111 | testCases = append(testCases, testCase{ |
| 9112 | testType: serverTest, |
| 9113 | name: "SkipEarlyData-HRR-TooMuchData", |
| 9114 | config: Config{ |
| 9115 | MaxVersion: VersionTLS13, |
| 9116 | Bugs: ProtocolBugs{ |
| 9117 | SendEarlyDataLength: 16384 + 1, |
| 9118 | }, |
| 9119 | DefaultCurves: []CurveID{}, |
| 9120 | }, |
| 9121 | shouldFail: true, |
| 9122 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9123 | }) |
| 9124 | |
| 9125 | // Test that skipping early data looking for cleartext correctly |
| 9126 | // processes an alert record. |
| 9127 | testCases = append(testCases, testCase{ |
| 9128 | testType: serverTest, |
| 9129 | name: "SkipEarlyData-HRR-FatalAlert", |
| 9130 | config: Config{ |
| 9131 | MaxVersion: VersionTLS13, |
| 9132 | Bugs: ProtocolBugs{ |
| 9133 | SendEarlyAlert: true, |
| 9134 | SendEarlyDataLength: 4, |
| 9135 | }, |
| 9136 | DefaultCurves: []CurveID{}, |
| 9137 | }, |
| 9138 | shouldFail: true, |
| 9139 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 9140 | }) |
| 9141 | |
| 9142 | testCases = append(testCases, testCase{ |
| 9143 | testType: serverTest, |
| 9144 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 9145 | config: Config{ |
| 9146 | MaxVersion: VersionTLS13, |
| 9147 | Bugs: ProtocolBugs{ |
| 9148 | SendEarlyDataOnSecondClientHello: true, |
| 9149 | }, |
| 9150 | DefaultCurves: []CurveID{}, |
| 9151 | }, |
| 9152 | shouldFail: true, |
| 9153 | expectedLocalError: "remote error: bad record MAC", |
| 9154 | }) |
| 9155 | |
| 9156 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9157 | testType: clientTest, |
| 9158 | name: "EmptyEncryptedExtensions", |
| 9159 | config: Config{ |
| 9160 | MaxVersion: VersionTLS13, |
| 9161 | Bugs: ProtocolBugs{ |
| 9162 | EmptyEncryptedExtensions: true, |
| 9163 | }, |
| 9164 | }, |
| 9165 | shouldFail: true, |
| 9166 | expectedLocalError: "remote error: error decoding message", |
| 9167 | }) |
| 9168 | |
| 9169 | testCases = append(testCases, testCase{ |
| 9170 | testType: clientTest, |
| 9171 | name: "EncryptedExtensionsWithKeyShare", |
| 9172 | config: Config{ |
| 9173 | MaxVersion: VersionTLS13, |
| 9174 | Bugs: ProtocolBugs{ |
| 9175 | EncryptedExtensionsWithKeyShare: true, |
| 9176 | }, |
| 9177 | }, |
| 9178 | shouldFail: true, |
| 9179 | expectedLocalError: "remote error: unsupported extension", |
| 9180 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9181 | |
| 9182 | testCases = append(testCases, testCase{ |
| 9183 | testType: serverTest, |
| 9184 | name: "SendHelloRetryRequest", |
| 9185 | config: Config{ |
| 9186 | MaxVersion: VersionTLS13, |
| 9187 | // Require a HelloRetryRequest for every curve. |
| 9188 | DefaultCurves: []CurveID{}, |
| 9189 | }, |
| 9190 | expectedCurveID: CurveX25519, |
| 9191 | }) |
| 9192 | |
| 9193 | testCases = append(testCases, testCase{ |
| 9194 | testType: serverTest, |
| 9195 | name: "SendHelloRetryRequest-2", |
| 9196 | config: Config{ |
| 9197 | MaxVersion: VersionTLS13, |
| 9198 | DefaultCurves: []CurveID{CurveP384}, |
| 9199 | }, |
| 9200 | // Although the ClientHello did not predict our preferred curve, |
| 9201 | // we always select it whether it is predicted or not. |
| 9202 | expectedCurveID: CurveX25519, |
| 9203 | }) |
| 9204 | |
| 9205 | testCases = append(testCases, testCase{ |
| 9206 | name: "UnknownCurve-HelloRetryRequest", |
| 9207 | config: Config{ |
| 9208 | MaxVersion: VersionTLS13, |
| 9209 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9210 | CurvePreferences: []CurveID{CurveP384}, |
| 9211 | Bugs: ProtocolBugs{ |
| 9212 | SendHelloRetryRequestCurve: bogusCurve, |
| 9213 | }, |
| 9214 | }, |
| 9215 | shouldFail: true, |
| 9216 | expectedError: ":WRONG_CURVE:", |
| 9217 | }) |
| 9218 | |
| 9219 | testCases = append(testCases, testCase{ |
| 9220 | name: "DisabledCurve-HelloRetryRequest", |
| 9221 | config: Config{ |
| 9222 | MaxVersion: VersionTLS13, |
| 9223 | CurvePreferences: []CurveID{CurveP256}, |
| 9224 | Bugs: ProtocolBugs{ |
| 9225 | IgnorePeerCurvePreferences: true, |
| 9226 | }, |
| 9227 | }, |
| 9228 | flags: []string{"-p384-only"}, |
| 9229 | shouldFail: true, |
| 9230 | expectedError: ":WRONG_CURVE:", |
| 9231 | }) |
| 9232 | |
| 9233 | testCases = append(testCases, testCase{ |
| 9234 | name: "UnnecessaryHelloRetryRequest", |
| 9235 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9236 | MaxVersion: VersionTLS13, |
| 9237 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9238 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9239 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9240 | }, |
| 9241 | }, |
| 9242 | shouldFail: true, |
| 9243 | expectedError: ":WRONG_CURVE:", |
| 9244 | }) |
| 9245 | |
| 9246 | testCases = append(testCases, testCase{ |
| 9247 | name: "SecondHelloRetryRequest", |
| 9248 | config: Config{ |
| 9249 | MaxVersion: VersionTLS13, |
| 9250 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9251 | CurvePreferences: []CurveID{CurveP384}, |
| 9252 | Bugs: ProtocolBugs{ |
| 9253 | SecondHelloRetryRequest: true, |
| 9254 | }, |
| 9255 | }, |
| 9256 | shouldFail: true, |
| 9257 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9258 | }) |
| 9259 | |
| 9260 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9261 | name: "HelloRetryRequest-Empty", |
| 9262 | config: Config{ |
| 9263 | MaxVersion: VersionTLS13, |
| 9264 | Bugs: ProtocolBugs{ |
| 9265 | AlwaysSendHelloRetryRequest: true, |
| 9266 | }, |
| 9267 | }, |
| 9268 | shouldFail: true, |
| 9269 | expectedError: ":DECODE_ERROR:", |
| 9270 | }) |
| 9271 | |
| 9272 | testCases = append(testCases, testCase{ |
| 9273 | name: "HelloRetryRequest-DuplicateCurve", |
| 9274 | config: Config{ |
| 9275 | MaxVersion: VersionTLS13, |
| 9276 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9277 | // configuration. Assert this ExpectMissingKeyShare. |
| 9278 | CurvePreferences: []CurveID{CurveP384}, |
| 9279 | Bugs: ProtocolBugs{ |
| 9280 | ExpectMissingKeyShare: true, |
| 9281 | DuplicateHelloRetryRequestExtensions: true, |
| 9282 | }, |
| 9283 | }, |
| 9284 | shouldFail: true, |
| 9285 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9286 | expectedLocalError: "remote error: illegal parameter", |
| 9287 | }) |
| 9288 | |
| 9289 | testCases = append(testCases, testCase{ |
| 9290 | name: "HelloRetryRequest-Cookie", |
| 9291 | config: Config{ |
| 9292 | MaxVersion: VersionTLS13, |
| 9293 | Bugs: ProtocolBugs{ |
| 9294 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9295 | }, |
| 9296 | }, |
| 9297 | }) |
| 9298 | |
| 9299 | testCases = append(testCases, testCase{ |
| 9300 | name: "HelloRetryRequest-DuplicateCookie", |
| 9301 | config: Config{ |
| 9302 | MaxVersion: VersionTLS13, |
| 9303 | Bugs: ProtocolBugs{ |
| 9304 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9305 | DuplicateHelloRetryRequestExtensions: true, |
| 9306 | }, |
| 9307 | }, |
| 9308 | shouldFail: true, |
| 9309 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9310 | expectedLocalError: "remote error: illegal parameter", |
| 9311 | }) |
| 9312 | |
| 9313 | testCases = append(testCases, testCase{ |
| 9314 | name: "HelloRetryRequest-EmptyCookie", |
| 9315 | config: Config{ |
| 9316 | MaxVersion: VersionTLS13, |
| 9317 | Bugs: ProtocolBugs{ |
| 9318 | SendHelloRetryRequestCookie: []byte{}, |
| 9319 | }, |
| 9320 | }, |
| 9321 | shouldFail: true, |
| 9322 | expectedError: ":DECODE_ERROR:", |
| 9323 | }) |
| 9324 | |
| 9325 | testCases = append(testCases, testCase{ |
| 9326 | name: "HelloRetryRequest-Cookie-Curve", |
| 9327 | config: Config{ |
| 9328 | MaxVersion: VersionTLS13, |
| 9329 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9330 | CurvePreferences: []CurveID{CurveP384}, |
| 9331 | Bugs: ProtocolBugs{ |
| 9332 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9333 | ExpectMissingKeyShare: true, |
| 9334 | }, |
| 9335 | }, |
| 9336 | }) |
| 9337 | |
| 9338 | testCases = append(testCases, testCase{ |
| 9339 | name: "HelloRetryRequest-Unknown", |
| 9340 | config: Config{ |
| 9341 | MaxVersion: VersionTLS13, |
| 9342 | Bugs: ProtocolBugs{ |
| 9343 | CustomHelloRetryRequestExtension: "extension", |
| 9344 | }, |
| 9345 | }, |
| 9346 | shouldFail: true, |
| 9347 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9348 | expectedLocalError: "remote error: unsupported extension", |
| 9349 | }) |
| 9350 | |
| 9351 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9352 | testType: serverTest, |
| 9353 | name: "SecondClientHelloMissingKeyShare", |
| 9354 | config: Config{ |
| 9355 | MaxVersion: VersionTLS13, |
| 9356 | DefaultCurves: []CurveID{}, |
| 9357 | Bugs: ProtocolBugs{ |
| 9358 | SecondClientHelloMissingKeyShare: true, |
| 9359 | }, |
| 9360 | }, |
| 9361 | shouldFail: true, |
| 9362 | expectedError: ":MISSING_KEY_SHARE:", |
| 9363 | }) |
| 9364 | |
| 9365 | testCases = append(testCases, testCase{ |
| 9366 | testType: serverTest, |
| 9367 | name: "SecondClientHelloWrongCurve", |
| 9368 | config: Config{ |
| 9369 | MaxVersion: VersionTLS13, |
| 9370 | DefaultCurves: []CurveID{}, |
| 9371 | Bugs: ProtocolBugs{ |
| 9372 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9373 | }, |
| 9374 | }, |
| 9375 | shouldFail: true, |
| 9376 | expectedError: ":WRONG_CURVE:", |
| 9377 | }) |
| 9378 | |
| 9379 | testCases = append(testCases, testCase{ |
| 9380 | name: "HelloRetryRequestVersionMismatch", |
| 9381 | config: Config{ |
| 9382 | MaxVersion: VersionTLS13, |
| 9383 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9384 | CurvePreferences: []CurveID{CurveP384}, |
| 9385 | Bugs: ProtocolBugs{ |
| 9386 | SendServerHelloVersion: 0x0305, |
| 9387 | }, |
| 9388 | }, |
| 9389 | shouldFail: true, |
| 9390 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9391 | }) |
| 9392 | |
| 9393 | testCases = append(testCases, testCase{ |
| 9394 | name: "HelloRetryRequestCurveMismatch", |
| 9395 | config: Config{ |
| 9396 | MaxVersion: VersionTLS13, |
| 9397 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9398 | CurvePreferences: []CurveID{CurveP384}, |
| 9399 | Bugs: ProtocolBugs{ |
| 9400 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9401 | SendHelloRetryRequestCurve: CurveP384, |
| 9402 | // But send P-256 in the ServerHello. |
| 9403 | SendCurve: CurveP256, |
| 9404 | }, |
| 9405 | }, |
| 9406 | shouldFail: true, |
| 9407 | expectedError: ":WRONG_CURVE:", |
| 9408 | }) |
| 9409 | |
| 9410 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9411 | // without sending it. |
| 9412 | testCases = append(testCases, testCase{ |
| 9413 | name: "SkipHelloRetryRequest", |
| 9414 | config: Config{ |
| 9415 | MaxVersion: VersionTLS13, |
| 9416 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9417 | CurvePreferences: []CurveID{CurveP384}, |
| 9418 | Bugs: ProtocolBugs{ |
| 9419 | SkipHelloRetryRequest: true, |
| 9420 | }, |
| 9421 | }, |
| 9422 | shouldFail: true, |
| 9423 | expectedError: ":WRONG_CURVE:", |
| 9424 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9425 | |
| 9426 | testCases = append(testCases, testCase{ |
| 9427 | name: "TLS13-RequestContextInHandshake", |
| 9428 | config: Config{ |
| 9429 | MaxVersion: VersionTLS13, |
| 9430 | MinVersion: VersionTLS13, |
| 9431 | ClientAuth: RequireAnyClientCert, |
| 9432 | Bugs: ProtocolBugs{ |
| 9433 | SendRequestContext: []byte("request context"), |
| 9434 | }, |
| 9435 | }, |
| 9436 | flags: []string{ |
| 9437 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9438 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9439 | }, |
| 9440 | shouldFail: true, |
| 9441 | expectedError: ":DECODE_ERROR:", |
| 9442 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9443 | |
| 9444 | testCases = append(testCases, testCase{ |
| 9445 | testType: serverTest, |
| 9446 | name: "TLS13-TrailingKeyShareData", |
| 9447 | config: Config{ |
| 9448 | MaxVersion: VersionTLS13, |
| 9449 | Bugs: ProtocolBugs{ |
| 9450 | TrailingKeyShareData: true, |
| 9451 | }, |
| 9452 | }, |
| 9453 | shouldFail: true, |
| 9454 | expectedError: ":DECODE_ERROR:", |
| 9455 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9456 | |
| 9457 | testCases = append(testCases, testCase{ |
| 9458 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9459 | config: Config{ |
| 9460 | MaxVersion: VersionTLS13, |
| 9461 | Bugs: ProtocolBugs{ |
| 9462 | AlwaysSelectPSKIdentity: true, |
| 9463 | }, |
| 9464 | }, |
| 9465 | shouldFail: true, |
| 9466 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9467 | }) |
| 9468 | |
| 9469 | testCases = append(testCases, testCase{ |
| 9470 | name: "TLS13-InvalidPSKIdentity", |
| 9471 | config: Config{ |
| 9472 | MaxVersion: VersionTLS13, |
| 9473 | Bugs: ProtocolBugs{ |
| 9474 | SelectPSKIdentityOnResume: 1, |
| 9475 | }, |
| 9476 | }, |
| 9477 | resumeSession: true, |
| 9478 | shouldFail: true, |
| 9479 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9480 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9481 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9482 | testCases = append(testCases, testCase{ |
| 9483 | testType: serverTest, |
| 9484 | name: "TLS13-ExtraPSKIdentity", |
| 9485 | config: Config{ |
| 9486 | MaxVersion: VersionTLS13, |
| 9487 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 9488 | ExtraPSKIdentity: true, |
| 9489 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9490 | }, |
| 9491 | }, |
| 9492 | resumeSession: true, |
| 9493 | }) |
| 9494 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9495 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9496 | testCases = append(testCases, testCase{ |
| 9497 | name: "TLS13-CustomTicketExtension", |
| 9498 | config: Config{ |
| 9499 | MaxVersion: VersionTLS13, |
| 9500 | Bugs: ProtocolBugs{ |
| 9501 | CustomTicketExtension: "1234", |
| 9502 | }, |
| 9503 | }, |
| 9504 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9505 | } |
| 9506 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9507 | func addTLS13CipherPreferenceTests() { |
| 9508 | // Test that client preference is honored if the shim has AES hardware |
| 9509 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9510 | testCases = append(testCases, testCase{ |
| 9511 | testType: serverTest, |
| 9512 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9513 | config: Config{ |
| 9514 | MaxVersion: VersionTLS13, |
| 9515 | CipherSuites: []uint16{ |
| 9516 | TLS_CHACHA20_POLY1305_SHA256, |
| 9517 | TLS_AES_128_GCM_SHA256, |
| 9518 | }, |
| 9519 | }, |
| 9520 | flags: []string{ |
| 9521 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9522 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9523 | }, |
| 9524 | }) |
| 9525 | |
| 9526 | testCases = append(testCases, testCase{ |
| 9527 | testType: serverTest, |
| 9528 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9529 | config: Config{ |
| 9530 | MaxVersion: VersionTLS13, |
| 9531 | CipherSuites: []uint16{ |
| 9532 | TLS_AES_128_GCM_SHA256, |
| 9533 | TLS_CHACHA20_POLY1305_SHA256, |
| 9534 | }, |
| 9535 | }, |
| 9536 | flags: []string{ |
| 9537 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9538 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9539 | }, |
| 9540 | }) |
| 9541 | |
| 9542 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9543 | // whether it has AES hardware. |
| 9544 | testCases = append(testCases, testCase{ |
| 9545 | name: "TLS13-CipherPreference-Client", |
| 9546 | config: Config{ |
| 9547 | MaxVersion: VersionTLS13, |
| 9548 | // Use the client cipher order. (This is the default but |
| 9549 | // is listed to be explicit.) |
| 9550 | PreferServerCipherSuites: false, |
| 9551 | }, |
| 9552 | flags: []string{ |
| 9553 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9554 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9555 | }, |
| 9556 | }) |
| 9557 | } |
| 9558 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9559 | func addPeekTests() { |
| 9560 | // Test SSL_peek works, including on empty records. |
| 9561 | testCases = append(testCases, testCase{ |
| 9562 | name: "Peek-Basic", |
| 9563 | sendEmptyRecords: 1, |
| 9564 | flags: []string{"-peek-then-read"}, |
| 9565 | }) |
| 9566 | |
| 9567 | // Test SSL_peek can drive the initial handshake. |
| 9568 | testCases = append(testCases, testCase{ |
| 9569 | name: "Peek-ImplicitHandshake", |
| 9570 | flags: []string{ |
| 9571 | "-peek-then-read", |
| 9572 | "-implicit-handshake", |
| 9573 | }, |
| 9574 | }) |
| 9575 | |
| 9576 | // Test SSL_peek can discover and drive a renegotiation. |
| 9577 | testCases = append(testCases, testCase{ |
| 9578 | name: "Peek-Renegotiate", |
| 9579 | config: Config{ |
| 9580 | MaxVersion: VersionTLS12, |
| 9581 | }, |
| 9582 | renegotiate: 1, |
| 9583 | flags: []string{ |
| 9584 | "-peek-then-read", |
| 9585 | "-renegotiate-freely", |
| 9586 | "-expect-total-renegotiations", "1", |
| 9587 | }, |
| 9588 | }) |
| 9589 | |
| 9590 | // Test SSL_peek can discover a close_notify. |
| 9591 | testCases = append(testCases, testCase{ |
| 9592 | name: "Peek-Shutdown", |
| 9593 | config: Config{ |
| 9594 | Bugs: ProtocolBugs{ |
| 9595 | ExpectCloseNotify: true, |
| 9596 | }, |
| 9597 | }, |
| 9598 | flags: []string{ |
| 9599 | "-peek-then-read", |
| 9600 | "-check-close-notify", |
| 9601 | }, |
| 9602 | }) |
| 9603 | |
| 9604 | // Test SSL_peek can discover an alert. |
| 9605 | testCases = append(testCases, testCase{ |
| 9606 | name: "Peek-Alert", |
| 9607 | config: Config{ |
| 9608 | Bugs: ProtocolBugs{ |
| 9609 | SendSpuriousAlert: alertRecordOverflow, |
| 9610 | }, |
| 9611 | }, |
| 9612 | flags: []string{"-peek-then-read"}, |
| 9613 | shouldFail: true, |
| 9614 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9615 | }) |
| 9616 | |
| 9617 | // Test SSL_peek can handle KeyUpdate. |
| 9618 | testCases = append(testCases, testCase{ |
| 9619 | name: "Peek-KeyUpdate", |
| 9620 | config: Config{ |
| 9621 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9622 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9623 | sendKeyUpdates: 1, |
| 9624 | keyUpdateRequest: keyUpdateNotRequested, |
| 9625 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9626 | }) |
| 9627 | } |
| 9628 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9629 | func addRecordVersionTests() { |
| 9630 | for _, ver := range tlsVersions { |
| 9631 | // Test that the record version is enforced. |
| 9632 | testCases = append(testCases, testCase{ |
| 9633 | name: "CheckRecordVersion-" + ver.name, |
| 9634 | config: Config{ |
| 9635 | MinVersion: ver.version, |
| 9636 | MaxVersion: ver.version, |
| 9637 | Bugs: ProtocolBugs{ |
| 9638 | SendRecordVersion: 0x03ff, |
| 9639 | }, |
| 9640 | }, |
| 9641 | shouldFail: true, |
| 9642 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9643 | }) |
| 9644 | |
| 9645 | // Test that the ClientHello may use any record version, for |
| 9646 | // compatibility reasons. |
| 9647 | testCases = append(testCases, testCase{ |
| 9648 | testType: serverTest, |
| 9649 | name: "LooseInitialRecordVersion-" + ver.name, |
| 9650 | config: Config{ |
| 9651 | MinVersion: ver.version, |
| 9652 | MaxVersion: ver.version, |
| 9653 | Bugs: ProtocolBugs{ |
| 9654 | SendInitialRecordVersion: 0x03ff, |
| 9655 | }, |
| 9656 | }, |
| 9657 | }) |
| 9658 | |
| 9659 | // Test that garbage ClientHello record versions are rejected. |
| 9660 | testCases = append(testCases, testCase{ |
| 9661 | testType: serverTest, |
| 9662 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 9663 | config: Config{ |
| 9664 | MinVersion: ver.version, |
| 9665 | MaxVersion: ver.version, |
| 9666 | Bugs: ProtocolBugs{ |
| 9667 | SendInitialRecordVersion: 0xffff, |
| 9668 | }, |
| 9669 | }, |
| 9670 | shouldFail: true, |
| 9671 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9672 | }) |
| 9673 | } |
| 9674 | } |
| 9675 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9676 | func addCertificateTests() { |
| 9677 | // Test that a certificate chain with intermediate may be sent and |
| 9678 | // received as both client and server. |
| 9679 | for _, ver := range tlsVersions { |
| 9680 | testCases = append(testCases, testCase{ |
| 9681 | testType: clientTest, |
| 9682 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 9683 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9684 | MinVersion: ver.version, |
| 9685 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9686 | Certificates: []Certificate{rsaChainCertificate}, |
| 9687 | ClientAuth: RequireAnyClientCert, |
| 9688 | }, |
| 9689 | expectPeerCertificate: &rsaChainCertificate, |
| 9690 | flags: []string{ |
| 9691 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9692 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9693 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9694 | }, |
| 9695 | }) |
| 9696 | |
| 9697 | testCases = append(testCases, testCase{ |
| 9698 | testType: serverTest, |
| 9699 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 9700 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9701 | MinVersion: ver.version, |
| 9702 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9703 | Certificates: []Certificate{rsaChainCertificate}, |
| 9704 | }, |
| 9705 | expectPeerCertificate: &rsaChainCertificate, |
| 9706 | flags: []string{ |
| 9707 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9708 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9709 | "-require-any-client-certificate", |
| 9710 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9711 | }, |
| 9712 | }) |
| 9713 | } |
| 9714 | } |
| 9715 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9716 | func addRetainOnlySHA256ClientCertTests() { |
| 9717 | for _, ver := range tlsVersions { |
| 9718 | // Test that enabling |
| 9719 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 9720 | // actually requesting a client certificate is a no-op. |
| 9721 | testCases = append(testCases, testCase{ |
| 9722 | testType: serverTest, |
| 9723 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 9724 | config: Config{ |
| 9725 | MinVersion: ver.version, |
| 9726 | MaxVersion: ver.version, |
| 9727 | }, |
| 9728 | flags: []string{ |
| 9729 | "-retain-only-sha256-client-cert-initial", |
| 9730 | "-retain-only-sha256-client-cert-resume", |
| 9731 | }, |
| 9732 | resumeSession: true, |
| 9733 | }) |
| 9734 | |
| 9735 | // Test that when retaining only a SHA-256 certificate is |
| 9736 | // enabled, the hash appears as expected. |
| 9737 | testCases = append(testCases, testCase{ |
| 9738 | testType: serverTest, |
| 9739 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 9740 | config: Config{ |
| 9741 | MinVersion: ver.version, |
| 9742 | MaxVersion: ver.version, |
| 9743 | Certificates: []Certificate{rsaCertificate}, |
| 9744 | }, |
| 9745 | flags: []string{ |
| 9746 | "-verify-peer", |
| 9747 | "-retain-only-sha256-client-cert-initial", |
| 9748 | "-retain-only-sha256-client-cert-resume", |
| 9749 | "-expect-sha256-client-cert-initial", |
| 9750 | "-expect-sha256-client-cert-resume", |
| 9751 | }, |
| 9752 | resumeSession: true, |
| 9753 | }) |
| 9754 | |
| 9755 | // Test that when the config changes from on to off, a |
| 9756 | // resumption is rejected because the server now wants the full |
| 9757 | // certificate chain. |
| 9758 | testCases = append(testCases, testCase{ |
| 9759 | testType: serverTest, |
| 9760 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 9761 | config: Config{ |
| 9762 | MinVersion: ver.version, |
| 9763 | MaxVersion: ver.version, |
| 9764 | Certificates: []Certificate{rsaCertificate}, |
| 9765 | }, |
| 9766 | flags: []string{ |
| 9767 | "-verify-peer", |
| 9768 | "-retain-only-sha256-client-cert-initial", |
| 9769 | "-expect-sha256-client-cert-initial", |
| 9770 | }, |
| 9771 | resumeSession: true, |
| 9772 | expectResumeRejected: true, |
| 9773 | }) |
| 9774 | |
| 9775 | // Test that when the config changes from off to on, a |
| 9776 | // resumption is rejected because the server now wants just the |
| 9777 | // hash. |
| 9778 | testCases = append(testCases, testCase{ |
| 9779 | testType: serverTest, |
| 9780 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 9781 | config: Config{ |
| 9782 | MinVersion: ver.version, |
| 9783 | MaxVersion: ver.version, |
| 9784 | Certificates: []Certificate{rsaCertificate}, |
| 9785 | }, |
| 9786 | flags: []string{ |
| 9787 | "-verify-peer", |
| 9788 | "-retain-only-sha256-client-cert-resume", |
| 9789 | "-expect-sha256-client-cert-resume", |
| 9790 | }, |
| 9791 | resumeSession: true, |
| 9792 | expectResumeRejected: true, |
| 9793 | }) |
| 9794 | } |
| 9795 | } |
| 9796 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9797 | 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] | 9798 | defer wg.Done() |
| 9799 | |
| 9800 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9801 | var err error |
| 9802 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9803 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9804 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 9805 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9806 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9807 | if err != nil { |
| 9808 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 9809 | } |
| 9810 | break |
| 9811 | } |
| 9812 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9813 | } else if *repeatUntilFailure { |
| 9814 | for err == nil { |
| 9815 | statusChan <- statusMsg{test: test, started: true} |
| 9816 | err = runTest(test, shimPath, -1) |
| 9817 | } |
| 9818 | } else { |
| 9819 | statusChan <- statusMsg{test: test, started: true} |
| 9820 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9821 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9822 | statusChan <- statusMsg{test: test, err: err} |
| 9823 | } |
| 9824 | } |
| 9825 | |
| 9826 | type statusMsg struct { |
| 9827 | test *testCase |
| 9828 | started bool |
| 9829 | err error |
| 9830 | } |
| 9831 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9832 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9833 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9834 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9835 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9836 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9837 | if !*pipe { |
| 9838 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 9839 | var erase string |
| 9840 | for i := 0; i < lineLen; i++ { |
| 9841 | erase += "\b \b" |
| 9842 | } |
| 9843 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9844 | } |
| 9845 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9846 | if msg.started { |
| 9847 | started++ |
| 9848 | } else { |
| 9849 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9850 | |
| 9851 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9852 | if msg.err == errUnimplemented { |
| 9853 | if *pipe { |
| 9854 | // Print each test instead of a status line. |
| 9855 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 9856 | } |
| 9857 | unimplemented++ |
| 9858 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 9859 | } else { |
| 9860 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 9861 | failed++ |
| 9862 | testOutput.addResult(msg.test.name, "FAIL") |
| 9863 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9864 | } else { |
| 9865 | if *pipe { |
| 9866 | // Print each test instead of a status line. |
| 9867 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 9868 | } |
| 9869 | testOutput.addResult(msg.test.name, "PASS") |
| 9870 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9871 | } |
| 9872 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9873 | if !*pipe { |
| 9874 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9875 | 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] | 9876 | lineLen = len(line) |
| 9877 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9878 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9879 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9880 | |
| 9881 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9882 | } |
| 9883 | |
| 9884 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9885 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9886 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 9887 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9888 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9889 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9890 | addCipherSuiteTests() |
| 9891 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9892 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 9893 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 9894 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 9895 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 9896 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 9897 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 9898 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 9899 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 9900 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 9901 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 9902 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 9903 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 9904 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 9905 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 9906 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9907 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9908 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9909 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9910 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9911 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 9912 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9913 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9914 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9915 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9916 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9917 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9918 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9919 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9920 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9921 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9922 | |
| 9923 | var wg sync.WaitGroup |
| 9924 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9925 | statusChan := make(chan statusMsg, *numWorkers) |
| 9926 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9927 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9928 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9929 | if len(*shimConfigFile) != 0 { |
| 9930 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 9931 | if err != nil { |
| 9932 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 9933 | os.Exit(1) |
| 9934 | } |
| 9935 | |
| 9936 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 9937 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 9938 | os.Exit(1) |
| 9939 | } |
| 9940 | } |
| 9941 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9942 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9943 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9944 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9945 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9946 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9947 | } |
| 9948 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9949 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9950 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9951 | matched := true |
| 9952 | if len(*testToRun) != 0 { |
| 9953 | var err error |
| 9954 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 9955 | if err != nil { |
| 9956 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 9957 | os.Exit(1) |
| 9958 | } |
| 9959 | } |
| 9960 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9961 | if !*includeDisabled { |
| 9962 | for pattern := range shimConfig.DisabledTests { |
| 9963 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 9964 | if err != nil { |
| 9965 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 9966 | os.Exit(1) |
| 9967 | } |
| 9968 | |
| 9969 | if isDisabled { |
| 9970 | matched = false |
| 9971 | break |
| 9972 | } |
| 9973 | } |
| 9974 | } |
| 9975 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9976 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9977 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9978 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9979 | |
| 9980 | // Only run one test if repeating until failure. |
| 9981 | if *repeatUntilFailure { |
| 9982 | break |
| 9983 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9984 | } |
| 9985 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9986 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9987 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9988 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9989 | os.Exit(1) |
| 9990 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9991 | |
| 9992 | close(testChan) |
| 9993 | wg.Wait() |
| 9994 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9995 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9996 | |
| 9997 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9998 | |
| 9999 | if *jsonOutput != "" { |
| 10000 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 10001 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 10002 | } |
| 10003 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10004 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10005 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 10006 | os.Exit(1) |
| 10007 | } |
| 10008 | |
| 10009 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10010 | os.Exit(1) |
| 10011 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10012 | } |