Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2016, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 14 | |
Adam Langley | dc7e9c4 | 2015-09-29 15:21:04 -0700 | [diff] [blame] | 15 | package runner |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 19 | "crypto/ecdsa" |
| 20 | "crypto/elliptic" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 21 | "crypto/rand" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 22 | "crypto/x509" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 23 | "crypto/x509/pkix" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 24 | "encoding/base64" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 25 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 26 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 27 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 28 | "flag" |
| 29 | "fmt" |
| 30 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 31 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 32 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 33 | "net" |
| 34 | "os" |
| 35 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 36 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 37 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 38 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 39 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 40 | "strings" |
| 41 | "sync" |
| 42 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 43 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 44 | ) |
| 45 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 46 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 47 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 48 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 49 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 50 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 51 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 52 | 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.") |
| 53 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 54 | 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] | 55 | 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] | 56 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 57 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 58 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 59 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 60 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 61 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 62 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 63 | 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] | 64 | 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] | 65 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 66 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 67 | 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] | 68 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 69 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 70 | // ShimConfigurations is used with the “json” package and represents a shim |
| 71 | // config file. |
| 72 | type ShimConfiguration struct { |
| 73 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 74 | // The glob pattern is used to exclude tests from being run and the |
| 75 | // freeform string is unparsed but expected to explain why the test is |
| 76 | // disabled. |
| 77 | DisabledTests map[string]string |
| 78 | |
| 79 | // ErrorMap maps from expected error strings to the correct error |
| 80 | // string for the shim in question. For example, it might map |
| 81 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 82 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 83 | ErrorMap map[string]string |
| 84 | } |
| 85 | |
| 86 | var shimConfig ShimConfiguration |
| 87 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 88 | type testCert int |
| 89 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 90 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 91 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 92 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 93 | testCertRSAChain |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 94 | testCertECDSAP256 |
| 95 | testCertECDSAP384 |
| 96 | testCertECDSAP521 |
| 97 | ) |
| 98 | |
| 99 | const ( |
| 100 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 101 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 102 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 103 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 104 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 105 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 106 | ) |
| 107 | |
| 108 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 109 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 110 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 111 | rsaChainKeyFile = "rsa_chain_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 112 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 113 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 114 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 115 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 116 | ) |
| 117 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 118 | var ( |
| 119 | rsaCertificate Certificate |
| 120 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 121 | rsaChainCertificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 122 | ecdsaP256Certificate Certificate |
| 123 | ecdsaP384Certificate Certificate |
| 124 | ecdsaP521Certificate Certificate |
| 125 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 126 | |
| 127 | var testCerts = []struct { |
| 128 | id testCert |
| 129 | certFile, keyFile string |
| 130 | cert *Certificate |
| 131 | }{ |
| 132 | { |
| 133 | id: testCertRSA, |
| 134 | certFile: rsaCertificateFile, |
| 135 | keyFile: rsaKeyFile, |
| 136 | cert: &rsaCertificate, |
| 137 | }, |
| 138 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 139 | id: testCertRSA1024, |
| 140 | certFile: rsa1024CertificateFile, |
| 141 | keyFile: rsa1024KeyFile, |
| 142 | cert: &rsa1024Certificate, |
| 143 | }, |
| 144 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 145 | id: testCertRSAChain, |
| 146 | certFile: rsaChainCertificateFile, |
| 147 | keyFile: rsaChainKeyFile, |
| 148 | cert: &rsaChainCertificate, |
| 149 | }, |
| 150 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 151 | id: testCertECDSAP256, |
| 152 | certFile: ecdsaP256CertificateFile, |
| 153 | keyFile: ecdsaP256KeyFile, |
| 154 | cert: &ecdsaP256Certificate, |
| 155 | }, |
| 156 | { |
| 157 | id: testCertECDSAP384, |
| 158 | certFile: ecdsaP384CertificateFile, |
| 159 | keyFile: ecdsaP384KeyFile, |
| 160 | cert: &ecdsaP384Certificate, |
| 161 | }, |
| 162 | { |
| 163 | id: testCertECDSAP521, |
| 164 | certFile: ecdsaP521CertificateFile, |
| 165 | keyFile: ecdsaP521KeyFile, |
| 166 | cert: &ecdsaP521Certificate, |
| 167 | }, |
| 168 | } |
| 169 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 170 | var channelIDKey *ecdsa.PrivateKey |
| 171 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 172 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 173 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 174 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 175 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 176 | 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] | 177 | 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] | 178 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 179 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 180 | for i := range testCerts { |
| 181 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 182 | if err != nil { |
| 183 | panic(err) |
| 184 | } |
| 185 | cert.OCSPStaple = testOCSPResponse |
| 186 | cert.SignedCertificateTimestampList = testSCTList |
| 187 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 188 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 189 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 190 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 191 | if err != nil { |
| 192 | panic(err) |
| 193 | } |
| 194 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 195 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 196 | panic("bad key type") |
| 197 | } |
| 198 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 199 | if err != nil { |
| 200 | panic(err) |
| 201 | } |
| 202 | if channelIDKey.Curve != elliptic.P256() { |
| 203 | panic("bad curve") |
| 204 | } |
| 205 | |
| 206 | channelIDBytes = make([]byte, 64) |
| 207 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 208 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 209 | } |
| 210 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 211 | func getRunnerCertificate(t testCert) Certificate { |
| 212 | for _, cert := range testCerts { |
| 213 | if cert.id == t { |
| 214 | return *cert.cert |
| 215 | } |
| 216 | } |
| 217 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 218 | } |
| 219 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 220 | func getShimCertificate(t testCert) string { |
| 221 | for _, cert := range testCerts { |
| 222 | if cert.id == t { |
| 223 | return cert.certFile |
| 224 | } |
| 225 | } |
| 226 | panic("Unknown test certificate") |
| 227 | } |
| 228 | |
| 229 | func getShimKey(t testCert) string { |
| 230 | for _, cert := range testCerts { |
| 231 | if cert.id == t { |
| 232 | return cert.keyFile |
| 233 | } |
| 234 | } |
| 235 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 236 | } |
| 237 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 238 | type testType int |
| 239 | |
| 240 | const ( |
| 241 | clientTest testType = iota |
| 242 | serverTest |
| 243 | ) |
| 244 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 245 | type protocol int |
| 246 | |
| 247 | const ( |
| 248 | tls protocol = iota |
| 249 | dtls |
| 250 | ) |
| 251 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 252 | const ( |
| 253 | alpn = 1 |
| 254 | npn = 2 |
| 255 | ) |
| 256 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 257 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 258 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 259 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 260 | name string |
| 261 | config Config |
| 262 | shouldFail bool |
| 263 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 264 | // expectedLocalError, if not empty, contains a substring that must be |
| 265 | // found in the local error. |
| 266 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 267 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 268 | // negotiated. |
| 269 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 270 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 271 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 272 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 273 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 274 | // should be negotiated. |
| 275 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 276 | // expectChannelID controls whether the connection should have |
| 277 | // negotiated a Channel ID with channelIDKey. |
| 278 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 279 | // expectedNextProto controls whether the connection should |
| 280 | // negotiate a next protocol via NPN or ALPN. |
| 281 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 282 | // expectNoNextProto, if true, means that no next protocol should be |
| 283 | // negotiated. |
| 284 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 285 | // expectedNextProtoType, if non-zero, is the expected next |
| 286 | // protocol negotiation mechanism. |
| 287 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 288 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 289 | // should be negotiated. If zero, none should be negotiated. |
| 290 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 291 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 292 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 293 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 294 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 295 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 296 | // algorithm that the peer should have used in the handshake. |
| 297 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 298 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 299 | // have used. |
| 300 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 301 | // messageLen is the length, in bytes, of the test message that will be |
| 302 | // sent. |
| 303 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 304 | // messageCount is the number of test messages that will be sent. |
| 305 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 306 | // certFile is the path to the certificate to use for the server. |
| 307 | certFile string |
| 308 | // keyFile is the path to the private key to use for the server. |
| 309 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 310 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 311 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 312 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 313 | // resumeRenewedSession controls whether a third connection should be |
| 314 | // tested which attempts to resume the second connection's session. |
| 315 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 316 | // expectResumeRejected, if true, specifies that the attempted |
| 317 | // resumption must be rejected by the client. This is only valid for a |
| 318 | // serverTest. |
| 319 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 320 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 321 | // resumption. Unless newSessionsOnResume is set, |
| 322 | // SessionTicketKey, ServerSessionCache, and |
| 323 | // ClientSessionCache are copied from the initial connection's |
| 324 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 325 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 326 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 327 | // use a different session resumption context. |
| 328 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 329 | // noSessionCache, if true, will cause the server to run without a |
| 330 | // session cache. |
| 331 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 332 | // sendPrefix sends a prefix on the socket before actually performing a |
| 333 | // handshake. |
| 334 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 335 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 336 | // message before doing a roundtrip with the runner. |
| 337 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 338 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 339 | // connection immediately after the handshake rather than echoing |
| 340 | // messages from the runner. |
| 341 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 342 | // renegotiate indicates the number of times the connection should be |
| 343 | // renegotiated during the exchange. |
| 344 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 345 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 346 | // HelloRequest when the handshake completes. |
| 347 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 348 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 349 | // switched in just before renegotiation. |
| 350 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 351 | // replayWrites, if true, configures the underlying transport |
| 352 | // to replay every write it makes in DTLS tests. |
| 353 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 354 | // damageFirstWrite, if true, configures the underlying transport to |
| 355 | // damage the final byte of the first application data write. |
| 356 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 357 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 358 | // keying material and verify they match. |
| 359 | exportKeyingMaterial int |
| 360 | exportLabel string |
| 361 | exportContext string |
| 362 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 363 | // flags, if not empty, contains a list of command-line flags that will |
| 364 | // be passed to the shim program. |
| 365 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 366 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 367 | // which will be compared against the expected value. |
| 368 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 369 | // sendEmptyRecords is the number of consecutive empty records to send |
| 370 | // before and after the test message. |
| 371 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 372 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 373 | // before and after the test message. |
| 374 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 375 | // sendKeyUpdates is the number of consecutive key updates to send |
| 376 | // before and after the test message. |
| 377 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 378 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 379 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 380 | // expectMessageDropped, if true, means the test message is expected to |
| 381 | // be dropped by the client rather than echoed back. |
| 382 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 383 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 384 | // is expected to send. |
| 385 | expectPeerCertificate *Certificate |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 386 | // expectShortHeader is whether the short header extension should be negotiated. |
| 387 | expectShortHeader bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 390 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 391 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 392 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 393 | if len(data) == 0 { |
| 394 | return |
| 395 | } |
| 396 | |
| 397 | protocol := "tls" |
| 398 | if test.protocol == dtls { |
| 399 | protocol = "dtls" |
| 400 | } |
| 401 | |
| 402 | side := "client" |
| 403 | if test.testType == serverTest { |
| 404 | side = "server" |
| 405 | } |
| 406 | |
| 407 | dir := path.Join(*transcriptDir, protocol, side) |
| 408 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 409 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 410 | return |
| 411 | } |
| 412 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 413 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 414 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 415 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 416 | } |
| 417 | } |
| 418 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 419 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 420 | type timeoutConn struct { |
| 421 | net.Conn |
| 422 | timeout time.Duration |
| 423 | } |
| 424 | |
| 425 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 426 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 427 | return 0, err |
| 428 | } |
| 429 | return t.Conn.Read(b) |
| 430 | } |
| 431 | |
| 432 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 433 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 434 | return 0, err |
| 435 | } |
| 436 | return t.Conn.Write(b) |
| 437 | } |
| 438 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 439 | 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] | 440 | if !test.noSessionCache { |
| 441 | if config.ClientSessionCache == nil { |
| 442 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 443 | } |
| 444 | if config.ServerSessionCache == nil { |
| 445 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 446 | } |
| 447 | } |
| 448 | if test.testType == clientTest { |
| 449 | if len(config.Certificates) == 0 { |
| 450 | config.Certificates = []Certificate{rsaCertificate} |
| 451 | } |
| 452 | } else { |
| 453 | // Supply a ServerName to ensure a constant session cache key, |
| 454 | // rather than falling back to net.Conn.RemoteAddr. |
| 455 | if len(config.ServerName) == 0 { |
| 456 | config.ServerName = "test" |
| 457 | } |
| 458 | } |
| 459 | if *fuzzer { |
| 460 | config.Bugs.NullAllCiphers = true |
| 461 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 462 | if *deterministic { |
| 463 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 464 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 465 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 466 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 467 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 468 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 469 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 470 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 471 | } |
| 472 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 473 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 474 | local, peer := "client", "server" |
| 475 | if test.testType == clientTest { |
| 476 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 477 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 478 | connDebug := &recordingConn{ |
| 479 | Conn: conn, |
| 480 | isDatagram: test.protocol == dtls, |
| 481 | local: local, |
| 482 | peer: peer, |
| 483 | } |
| 484 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 485 | if *flagDebug { |
| 486 | defer connDebug.WriteTo(os.Stdout) |
| 487 | } |
| 488 | if len(*transcriptDir) != 0 { |
| 489 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 490 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 491 | }() |
| 492 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 493 | |
| 494 | if config.Bugs.PacketAdaptor != nil { |
| 495 | config.Bugs.PacketAdaptor.debug = connDebug |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | if test.replayWrites { |
| 500 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 501 | } |
| 502 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 503 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 504 | if test.damageFirstWrite { |
| 505 | connDamage = newDamageAdaptor(conn) |
| 506 | conn = connDamage |
| 507 | } |
| 508 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 509 | if test.sendPrefix != "" { |
| 510 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 511 | return err |
| 512 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 513 | } |
| 514 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 515 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 516 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 517 | if test.protocol == dtls { |
| 518 | tlsConn = DTLSServer(conn, config) |
| 519 | } else { |
| 520 | tlsConn = Server(conn, config) |
| 521 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 522 | } else { |
| 523 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 524 | if test.protocol == dtls { |
| 525 | tlsConn = DTLSClient(conn, config) |
| 526 | } else { |
| 527 | tlsConn = Client(conn, config) |
| 528 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 529 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 530 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 531 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 532 | if err := tlsConn.Handshake(); err != nil { |
| 533 | return err |
| 534 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 535 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 536 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 537 | // expectations struct that can be specified separately for the two |
| 538 | // legs. |
| 539 | expectedVersion := test.expectedVersion |
| 540 | if isResume && test.expectedResumeVersion != 0 { |
| 541 | expectedVersion = test.expectedResumeVersion |
| 542 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 543 | connState := tlsConn.ConnectionState() |
| 544 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 545 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 546 | } |
| 547 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 548 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 549 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 550 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 551 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 552 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 553 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 554 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 555 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 556 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 557 | if channelID == nil { |
| 558 | return fmt.Errorf("no channel ID negotiated") |
| 559 | } |
| 560 | if channelID.Curve != channelIDKey.Curve || |
| 561 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 562 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 563 | return fmt.Errorf("incorrect channel ID") |
| 564 | } |
| 565 | } |
| 566 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 567 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 568 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 569 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 570 | } |
| 571 | } |
| 572 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 573 | if test.expectNoNextProto { |
| 574 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 575 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 576 | } |
| 577 | } |
| 578 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 579 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 580 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 581 | return fmt.Errorf("next proto type mismatch") |
| 582 | } |
| 583 | } |
| 584 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 585 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 586 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 587 | } |
| 588 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 589 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 590 | 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] | 591 | } |
| 592 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 593 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 594 | return fmt.Errorf("SCT list mismatch") |
| 595 | } |
| 596 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 597 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 598 | 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] | 599 | } |
| 600 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 601 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 602 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 603 | } |
| 604 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 605 | if test.expectPeerCertificate != nil { |
| 606 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 607 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 608 | } |
| 609 | for i, cert := range connState.PeerCertificates { |
| 610 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 611 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 616 | if test.expectShortHeader != connState.ShortHeader { |
| 617 | return fmt.Errorf("ShortHeader is %t, but we expected the opposite", connState.ShortHeader) |
| 618 | } |
| 619 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 620 | if test.exportKeyingMaterial > 0 { |
| 621 | actual := make([]byte, test.exportKeyingMaterial) |
| 622 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 623 | return err |
| 624 | } |
| 625 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 626 | if err != nil { |
| 627 | return err |
| 628 | } |
| 629 | if !bytes.Equal(actual, expected) { |
| 630 | return fmt.Errorf("keying material mismatch") |
| 631 | } |
| 632 | } |
| 633 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 634 | if test.testTLSUnique { |
| 635 | var peersValue [12]byte |
| 636 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 637 | return err |
| 638 | } |
| 639 | expected := tlsConn.ConnectionState().TLSUnique |
| 640 | if !bytes.Equal(peersValue[:], expected) { |
| 641 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 642 | } |
| 643 | } |
| 644 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 645 | if test.shimWritesFirst { |
| 646 | var buf [5]byte |
| 647 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 648 | if err != nil { |
| 649 | return err |
| 650 | } |
| 651 | if string(buf[:]) != "hello" { |
| 652 | return fmt.Errorf("bad initial message") |
| 653 | } |
| 654 | } |
| 655 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 656 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 657 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 658 | return err |
| 659 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 660 | } |
| 661 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 662 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 663 | tlsConn.Write(nil) |
| 664 | } |
| 665 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 666 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 667 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 668 | } |
| 669 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 670 | if test.sendHalfHelloRequest { |
| 671 | tlsConn.SendHalfHelloRequest() |
| 672 | } |
| 673 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 674 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 675 | if test.renegotiateCiphers != nil { |
| 676 | config.CipherSuites = test.renegotiateCiphers |
| 677 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 678 | for i := 0; i < test.renegotiate; i++ { |
| 679 | if err := tlsConn.Renegotiate(); err != nil { |
| 680 | return err |
| 681 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 682 | } |
| 683 | } else if test.renegotiateCiphers != nil { |
| 684 | panic("renegotiateCiphers without renegotiate") |
| 685 | } |
| 686 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 687 | if test.damageFirstWrite { |
| 688 | connDamage.setDamage(true) |
| 689 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 690 | connDamage.setDamage(false) |
| 691 | } |
| 692 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 693 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 694 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 695 | if test.protocol == dtls { |
| 696 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 697 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 698 | // Read until EOF. |
| 699 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 700 | return err |
| 701 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 702 | if messageLen == 0 { |
| 703 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 704 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 705 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 706 | messageCount := test.messageCount |
| 707 | if messageCount == 0 { |
| 708 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 709 | } |
| 710 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 711 | for j := 0; j < messageCount; j++ { |
| 712 | testMessage := make([]byte, messageLen) |
| 713 | for i := range testMessage { |
| 714 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 715 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 716 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 717 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 718 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 719 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 720 | } |
| 721 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 722 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 723 | tlsConn.Write(nil) |
| 724 | } |
| 725 | |
| 726 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 727 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 728 | } |
| 729 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 730 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 731 | // The shim will not respond. |
| 732 | continue |
| 733 | } |
| 734 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 735 | buf := make([]byte, len(testMessage)) |
| 736 | if test.protocol == dtls { |
| 737 | bufTmp := make([]byte, len(buf)+1) |
| 738 | n, err := tlsConn.Read(bufTmp) |
| 739 | if err != nil { |
| 740 | return err |
| 741 | } |
| 742 | if n != len(buf) { |
| 743 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 744 | } |
| 745 | copy(buf, bufTmp) |
| 746 | } else { |
| 747 | _, err := io.ReadFull(tlsConn, buf) |
| 748 | if err != nil { |
| 749 | return err |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | for i, v := range buf { |
| 754 | if v != testMessage[i]^0xff { |
| 755 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 756 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 757 | } |
| 758 | } |
| 759 | |
| 760 | return nil |
| 761 | } |
| 762 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 763 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 764 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 765 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 766 | 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] | 767 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 768 | valgrindArgs = append(valgrindArgs, path) |
| 769 | valgrindArgs = append(valgrindArgs, 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("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 772 | } |
| 773 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 774 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 775 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 776 | xtermArgs = append(xtermArgs, path) |
| 777 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 778 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 779 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 780 | } |
| 781 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 782 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 783 | xtermArgs := []string{"-e", "lldb", "--"} |
| 784 | xtermArgs = append(xtermArgs, path) |
| 785 | xtermArgs = append(xtermArgs, args...) |
| 786 | |
| 787 | return exec.Command("xterm", xtermArgs...) |
| 788 | } |
| 789 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 790 | var ( |
| 791 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 792 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 793 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 794 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 795 | // accept accepts a connection from listener, unless waitChan signals a process |
| 796 | // exit first. |
| 797 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 798 | type connOrError struct { |
| 799 | conn net.Conn |
| 800 | err error |
| 801 | } |
| 802 | connChan := make(chan connOrError, 1) |
| 803 | go func() { |
| 804 | conn, err := listener.Accept() |
| 805 | connChan <- connOrError{conn, err} |
| 806 | close(connChan) |
| 807 | }() |
| 808 | select { |
| 809 | case result := <-connChan: |
| 810 | return result.conn, result.err |
| 811 | case childErr := <-waitChan: |
| 812 | waitChan <- childErr |
| 813 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 814 | } |
| 815 | } |
| 816 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 817 | func translateExpectedError(errorStr string) string { |
| 818 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 819 | return translated |
| 820 | } |
| 821 | |
| 822 | if *looseErrors { |
| 823 | return "" |
| 824 | } |
| 825 | |
| 826 | return errorStr |
| 827 | } |
| 828 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 829 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 830 | // Help debugging panics on the Go side. |
| 831 | defer func() { |
| 832 | if r := recover(); r != nil { |
| 833 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 834 | panic(r) |
| 835 | } |
| 836 | }() |
| 837 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 838 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 839 | panic("Error expected without shouldFail in " + test.name) |
| 840 | } |
| 841 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 842 | if test.expectResumeRejected && !test.resumeSession { |
| 843 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 844 | } |
| 845 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 846 | for _, ver := range tlsVersions { |
| 847 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 848 | continue |
| 849 | } |
| 850 | |
| 851 | if test.config.MaxVersion != 0 || test.config.MinVersion != 0 || test.expectedVersion != 0 { |
| 852 | continue |
| 853 | } |
| 854 | |
| 855 | 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)) |
| 856 | } |
| 857 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 858 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 859 | if err != nil { |
| 860 | panic(err) |
| 861 | } |
| 862 | defer func() { |
| 863 | if listener != nil { |
| 864 | listener.Close() |
| 865 | } |
| 866 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 867 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 868 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 869 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 870 | flags = append(flags, "-server") |
| 871 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 872 | flags = append(flags, "-key-file") |
| 873 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 874 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 875 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 876 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | flags = append(flags, "-cert-file") |
| 880 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 881 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 882 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 883 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 884 | } |
| 885 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 886 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 887 | if test.protocol == dtls { |
| 888 | flags = append(flags, "-dtls") |
| 889 | } |
| 890 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 891 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 892 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 893 | resumeCount++ |
| 894 | if test.resumeRenewedSession { |
| 895 | resumeCount++ |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | if resumeCount > 0 { |
| 900 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 901 | } |
| 902 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 903 | if test.shimWritesFirst { |
| 904 | flags = append(flags, "-shim-writes-first") |
| 905 | } |
| 906 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 907 | if test.shimShutsDown { |
| 908 | flags = append(flags, "-shim-shuts-down") |
| 909 | } |
| 910 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 911 | if test.exportKeyingMaterial > 0 { |
| 912 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 913 | flags = append(flags, "-export-label", test.exportLabel) |
| 914 | flags = append(flags, "-export-context", test.exportContext) |
| 915 | if test.useExportContext { |
| 916 | flags = append(flags, "-use-export-context") |
| 917 | } |
| 918 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 919 | if test.expectResumeRejected { |
| 920 | flags = append(flags, "-expect-session-miss") |
| 921 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 922 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 923 | if test.testTLSUnique { |
| 924 | flags = append(flags, "-tls-unique") |
| 925 | } |
| 926 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 927 | flags = append(flags, test.flags...) |
| 928 | |
| 929 | var shim *exec.Cmd |
| 930 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 931 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 932 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 933 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 934 | } else if *useLLDB { |
| 935 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 936 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 937 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 938 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 939 | shim.Stdin = os.Stdin |
| 940 | var stdoutBuf, stderrBuf bytes.Buffer |
| 941 | shim.Stdout = &stdoutBuf |
| 942 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 943 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 944 | shim.Env = os.Environ() |
| 945 | 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] | 946 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 947 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 948 | } |
| 949 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 950 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 951 | |
| 952 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 953 | panic(err) |
| 954 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 955 | waitChan := make(chan error, 1) |
| 956 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 957 | |
| 958 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 959 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 960 | if *deterministic { |
| 961 | config.Rand = &deterministicRand{} |
| 962 | } |
| 963 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 964 | conn, err := acceptOrWait(listener, waitChan) |
| 965 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 966 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 967 | conn.Close() |
| 968 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 969 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 970 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 971 | var resumeConfig Config |
| 972 | if test.resumeConfig != nil { |
| 973 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 974 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 975 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 976 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 977 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 978 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 979 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 980 | } else { |
| 981 | resumeConfig = config |
| 982 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 983 | var connResume net.Conn |
| 984 | connResume, err = acceptOrWait(listener, waitChan) |
| 985 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 986 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 987 | connResume.Close() |
| 988 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 989 | } |
| 990 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 991 | // Close the listener now. This is to avoid hangs should the shim try to |
| 992 | // open more connections than expected. |
| 993 | listener.Close() |
| 994 | listener = nil |
| 995 | |
| 996 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 997 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 998 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 999 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1000 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1001 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1002 | case 89: |
| 1003 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1004 | case 99: |
| 1005 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1006 | } |
| 1007 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1008 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1009 | // Account for Windows line endings. |
| 1010 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1011 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1012 | |
| 1013 | // Separate the errors from the shim and those from tools like |
| 1014 | // AddressSanitizer. |
| 1015 | var extraStderr string |
| 1016 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1017 | stderr = stderrParts[0] |
| 1018 | extraStderr = stderrParts[1] |
| 1019 | } |
| 1020 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1021 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1022 | expectedError := translateExpectedError(test.expectedError) |
| 1023 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1024 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1025 | localError := "none" |
| 1026 | if err != nil { |
| 1027 | localError = err.Error() |
| 1028 | } |
| 1029 | if len(test.expectedLocalError) != 0 { |
| 1030 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1031 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1032 | |
| 1033 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1034 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1035 | if childErr != nil { |
| 1036 | childError = childErr.Error() |
| 1037 | } |
| 1038 | |
| 1039 | var msg string |
| 1040 | switch { |
| 1041 | case failed && !test.shouldFail: |
| 1042 | msg = "unexpected failure" |
| 1043 | case !failed && test.shouldFail: |
| 1044 | msg = "unexpected success" |
| 1045 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1046 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1047 | default: |
| 1048 | panic("internal error") |
| 1049 | } |
| 1050 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1051 | 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] | 1052 | } |
| 1053 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1054 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1055 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1058 | if *useValgrind && isValgrindError { |
| 1059 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1060 | } |
| 1061 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1062 | return nil |
| 1063 | } |
| 1064 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1065 | type tlsVersion struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1066 | name string |
| 1067 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1068 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1069 | hasDTLS bool |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1070 | } |
| 1071 | |
| 1072 | var tlsVersions = []tlsVersion{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1073 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1074 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1075 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1076 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1077 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1078 | } |
| 1079 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1080 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1081 | name string |
| 1082 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1086 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1087 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1088 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1089 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1090 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1091 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1092 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1093 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1094 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1095 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1096 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1097 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1098 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1099 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1100 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1101 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1102 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1103 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1104 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1105 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1106 | {"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] | 1107 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1108 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1109 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1110 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1111 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1112 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1113 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1114 | {"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] | 1115 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1116 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1117 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1118 | {"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] | 1119 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1120 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1121 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1122 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1123 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1124 | } |
| 1125 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1126 | func hasComponent(suiteName, component string) bool { |
| 1127 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1128 | } |
| 1129 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1130 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1131 | return hasComponent(suiteName, "GCM") || |
| 1132 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1133 | hasComponent(suiteName, "SHA384") || |
| 1134 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1135 | } |
| 1136 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1137 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1138 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1139 | } |
| 1140 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1141 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1142 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1143 | } |
| 1144 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1145 | func bigFromHex(hex string) *big.Int { |
| 1146 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1147 | if !ok { |
| 1148 | panic("failed to parse hex number 0x" + hex) |
| 1149 | } |
| 1150 | return ret |
| 1151 | } |
| 1152 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1153 | func addBasicTests() { |
| 1154 | basicTests := []testCase{ |
| 1155 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1156 | name: "NoFallbackSCSV", |
| 1157 | config: Config{ |
| 1158 | Bugs: ProtocolBugs{ |
| 1159 | FailIfNotFallbackSCSV: true, |
| 1160 | }, |
| 1161 | }, |
| 1162 | shouldFail: true, |
| 1163 | expectedLocalError: "no fallback SCSV found", |
| 1164 | }, |
| 1165 | { |
| 1166 | name: "SendFallbackSCSV", |
| 1167 | config: Config{ |
| 1168 | Bugs: ProtocolBugs{ |
| 1169 | FailIfNotFallbackSCSV: true, |
| 1170 | }, |
| 1171 | }, |
| 1172 | flags: []string{"-fallback-scsv"}, |
| 1173 | }, |
| 1174 | { |
| 1175 | name: "ClientCertificateTypes", |
| 1176 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1177 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1178 | ClientAuth: RequestClientCert, |
| 1179 | ClientCertificateTypes: []byte{ |
| 1180 | CertTypeDSSSign, |
| 1181 | CertTypeRSASign, |
| 1182 | CertTypeECDSASign, |
| 1183 | }, |
| 1184 | }, |
| 1185 | flags: []string{ |
| 1186 | "-expect-certificate-types", |
| 1187 | base64.StdEncoding.EncodeToString([]byte{ |
| 1188 | CertTypeDSSSign, |
| 1189 | CertTypeRSASign, |
| 1190 | CertTypeECDSASign, |
| 1191 | }), |
| 1192 | }, |
| 1193 | }, |
| 1194 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1195 | name: "UnauthenticatedECDH", |
| 1196 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1197 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1198 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1199 | Bugs: ProtocolBugs{ |
| 1200 | UnauthenticatedECDH: true, |
| 1201 | }, |
| 1202 | }, |
| 1203 | shouldFail: true, |
| 1204 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1205 | }, |
| 1206 | { |
| 1207 | name: "SkipCertificateStatus", |
| 1208 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1209 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1210 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1211 | Bugs: ProtocolBugs{ |
| 1212 | SkipCertificateStatus: true, |
| 1213 | }, |
| 1214 | }, |
| 1215 | flags: []string{ |
| 1216 | "-enable-ocsp-stapling", |
| 1217 | }, |
| 1218 | }, |
| 1219 | { |
| 1220 | name: "SkipServerKeyExchange", |
| 1221 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1222 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1223 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1224 | Bugs: ProtocolBugs{ |
| 1225 | SkipServerKeyExchange: true, |
| 1226 | }, |
| 1227 | }, |
| 1228 | shouldFail: true, |
| 1229 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1230 | }, |
| 1231 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1232 | testType: serverTest, |
| 1233 | name: "Alert", |
| 1234 | config: Config{ |
| 1235 | Bugs: ProtocolBugs{ |
| 1236 | SendSpuriousAlert: alertRecordOverflow, |
| 1237 | }, |
| 1238 | }, |
| 1239 | shouldFail: true, |
| 1240 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1241 | }, |
| 1242 | { |
| 1243 | protocol: dtls, |
| 1244 | testType: serverTest, |
| 1245 | name: "Alert-DTLS", |
| 1246 | config: Config{ |
| 1247 | Bugs: ProtocolBugs{ |
| 1248 | SendSpuriousAlert: alertRecordOverflow, |
| 1249 | }, |
| 1250 | }, |
| 1251 | shouldFail: true, |
| 1252 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1253 | }, |
| 1254 | { |
| 1255 | testType: serverTest, |
| 1256 | name: "FragmentAlert", |
| 1257 | config: Config{ |
| 1258 | Bugs: ProtocolBugs{ |
| 1259 | FragmentAlert: true, |
| 1260 | SendSpuriousAlert: alertRecordOverflow, |
| 1261 | }, |
| 1262 | }, |
| 1263 | shouldFail: true, |
| 1264 | expectedError: ":BAD_ALERT:", |
| 1265 | }, |
| 1266 | { |
| 1267 | protocol: dtls, |
| 1268 | testType: serverTest, |
| 1269 | name: "FragmentAlert-DTLS", |
| 1270 | config: Config{ |
| 1271 | Bugs: ProtocolBugs{ |
| 1272 | FragmentAlert: true, |
| 1273 | SendSpuriousAlert: alertRecordOverflow, |
| 1274 | }, |
| 1275 | }, |
| 1276 | shouldFail: true, |
| 1277 | expectedError: ":BAD_ALERT:", |
| 1278 | }, |
| 1279 | { |
| 1280 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1281 | name: "DoubleAlert", |
| 1282 | config: Config{ |
| 1283 | Bugs: ProtocolBugs{ |
| 1284 | DoubleAlert: true, |
| 1285 | SendSpuriousAlert: alertRecordOverflow, |
| 1286 | }, |
| 1287 | }, |
| 1288 | shouldFail: true, |
| 1289 | expectedError: ":BAD_ALERT:", |
| 1290 | }, |
| 1291 | { |
| 1292 | protocol: dtls, |
| 1293 | testType: serverTest, |
| 1294 | name: "DoubleAlert-DTLS", |
| 1295 | config: Config{ |
| 1296 | Bugs: ProtocolBugs{ |
| 1297 | DoubleAlert: true, |
| 1298 | SendSpuriousAlert: alertRecordOverflow, |
| 1299 | }, |
| 1300 | }, |
| 1301 | shouldFail: true, |
| 1302 | expectedError: ":BAD_ALERT:", |
| 1303 | }, |
| 1304 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1305 | name: "SkipNewSessionTicket", |
| 1306 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1307 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1308 | Bugs: ProtocolBugs{ |
| 1309 | SkipNewSessionTicket: true, |
| 1310 | }, |
| 1311 | }, |
| 1312 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1313 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1314 | }, |
| 1315 | { |
| 1316 | testType: serverTest, |
| 1317 | name: "FallbackSCSV", |
| 1318 | config: Config{ |
| 1319 | MaxVersion: VersionTLS11, |
| 1320 | Bugs: ProtocolBugs{ |
| 1321 | SendFallbackSCSV: true, |
| 1322 | }, |
| 1323 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1324 | shouldFail: true, |
| 1325 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1326 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1327 | }, |
| 1328 | { |
| 1329 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1330 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1331 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1332 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1333 | Bugs: ProtocolBugs{ |
| 1334 | SendFallbackSCSV: true, |
| 1335 | }, |
| 1336 | }, |
| 1337 | }, |
| 1338 | { |
| 1339 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1340 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1341 | config: Config{ |
| 1342 | MaxVersion: VersionTLS12, |
| 1343 | Bugs: ProtocolBugs{ |
| 1344 | SendFallbackSCSV: true, |
| 1345 | }, |
| 1346 | }, |
| 1347 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1348 | }, |
| 1349 | { |
| 1350 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1351 | name: "FragmentedClientVersion", |
| 1352 | config: Config{ |
| 1353 | Bugs: ProtocolBugs{ |
| 1354 | MaxHandshakeRecordLength: 1, |
| 1355 | FragmentClientVersion: true, |
| 1356 | }, |
| 1357 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1358 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1359 | }, |
| 1360 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1361 | testType: serverTest, |
| 1362 | name: "HttpGET", |
| 1363 | sendPrefix: "GET / HTTP/1.0\n", |
| 1364 | shouldFail: true, |
| 1365 | expectedError: ":HTTP_REQUEST:", |
| 1366 | }, |
| 1367 | { |
| 1368 | testType: serverTest, |
| 1369 | name: "HttpPOST", |
| 1370 | sendPrefix: "POST / HTTP/1.0\n", |
| 1371 | shouldFail: true, |
| 1372 | expectedError: ":HTTP_REQUEST:", |
| 1373 | }, |
| 1374 | { |
| 1375 | testType: serverTest, |
| 1376 | name: "HttpHEAD", |
| 1377 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1378 | shouldFail: true, |
| 1379 | expectedError: ":HTTP_REQUEST:", |
| 1380 | }, |
| 1381 | { |
| 1382 | testType: serverTest, |
| 1383 | name: "HttpPUT", |
| 1384 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1385 | shouldFail: true, |
| 1386 | expectedError: ":HTTP_REQUEST:", |
| 1387 | }, |
| 1388 | { |
| 1389 | testType: serverTest, |
| 1390 | name: "HttpCONNECT", |
| 1391 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1392 | shouldFail: true, |
| 1393 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1394 | }, |
| 1395 | { |
| 1396 | testType: serverTest, |
| 1397 | name: "Garbage", |
| 1398 | sendPrefix: "blah", |
| 1399 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1400 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1401 | }, |
| 1402 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1403 | name: "RSAEphemeralKey", |
| 1404 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1405 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1406 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1407 | Bugs: ProtocolBugs{ |
| 1408 | RSAEphemeralKey: true, |
| 1409 | }, |
| 1410 | }, |
| 1411 | shouldFail: true, |
| 1412 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1413 | }, |
| 1414 | { |
| 1415 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1416 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1417 | shouldFail: true, |
| 1418 | expectedError: ":WRONG_SSL_VERSION:", |
| 1419 | }, |
| 1420 | { |
| 1421 | protocol: dtls, |
| 1422 | name: "DisableEverything-DTLS", |
| 1423 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1424 | shouldFail: true, |
| 1425 | expectedError: ":WRONG_SSL_VERSION:", |
| 1426 | }, |
| 1427 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1428 | protocol: dtls, |
| 1429 | testType: serverTest, |
| 1430 | name: "MTU", |
| 1431 | config: Config{ |
| 1432 | Bugs: ProtocolBugs{ |
| 1433 | MaxPacketLength: 256, |
| 1434 | }, |
| 1435 | }, |
| 1436 | flags: []string{"-mtu", "256"}, |
| 1437 | }, |
| 1438 | { |
| 1439 | protocol: dtls, |
| 1440 | testType: serverTest, |
| 1441 | name: "MTUExceeded", |
| 1442 | config: Config{ |
| 1443 | Bugs: ProtocolBugs{ |
| 1444 | MaxPacketLength: 255, |
| 1445 | }, |
| 1446 | }, |
| 1447 | flags: []string{"-mtu", "256"}, |
| 1448 | shouldFail: true, |
| 1449 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1450 | }, |
| 1451 | { |
| 1452 | name: "CertMismatchRSA", |
| 1453 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1454 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1455 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1456 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1457 | Bugs: ProtocolBugs{ |
| 1458 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1459 | }, |
| 1460 | }, |
| 1461 | shouldFail: true, |
| 1462 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1463 | }, |
| 1464 | { |
| 1465 | name: "CertMismatchECDSA", |
| 1466 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1467 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1468 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1469 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1470 | Bugs: ProtocolBugs{ |
| 1471 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1472 | }, |
| 1473 | }, |
| 1474 | shouldFail: true, |
| 1475 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1476 | }, |
| 1477 | { |
| 1478 | name: "EmptyCertificateList", |
| 1479 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1480 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1481 | Bugs: ProtocolBugs{ |
| 1482 | EmptyCertificateList: true, |
| 1483 | }, |
| 1484 | }, |
| 1485 | shouldFail: true, |
| 1486 | expectedError: ":DECODE_ERROR:", |
| 1487 | }, |
| 1488 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1489 | name: "EmptyCertificateList-TLS13", |
| 1490 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1491 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1492 | Bugs: ProtocolBugs{ |
| 1493 | EmptyCertificateList: true, |
| 1494 | }, |
| 1495 | }, |
| 1496 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1497 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1498 | }, |
| 1499 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1500 | name: "TLSFatalBadPackets", |
| 1501 | damageFirstWrite: true, |
| 1502 | shouldFail: true, |
| 1503 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1504 | }, |
| 1505 | { |
| 1506 | protocol: dtls, |
| 1507 | name: "DTLSIgnoreBadPackets", |
| 1508 | damageFirstWrite: true, |
| 1509 | }, |
| 1510 | { |
| 1511 | protocol: dtls, |
| 1512 | name: "DTLSIgnoreBadPackets-Async", |
| 1513 | damageFirstWrite: true, |
| 1514 | flags: []string{"-async"}, |
| 1515 | }, |
| 1516 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1517 | name: "AppDataBeforeHandshake", |
| 1518 | config: Config{ |
| 1519 | Bugs: ProtocolBugs{ |
| 1520 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1521 | }, |
| 1522 | }, |
| 1523 | shouldFail: true, |
| 1524 | expectedError: ":UNEXPECTED_RECORD:", |
| 1525 | }, |
| 1526 | { |
| 1527 | name: "AppDataBeforeHandshake-Empty", |
| 1528 | config: Config{ |
| 1529 | Bugs: ProtocolBugs{ |
| 1530 | AppDataBeforeHandshake: []byte{}, |
| 1531 | }, |
| 1532 | }, |
| 1533 | shouldFail: true, |
| 1534 | expectedError: ":UNEXPECTED_RECORD:", |
| 1535 | }, |
| 1536 | { |
| 1537 | protocol: dtls, |
| 1538 | name: "AppDataBeforeHandshake-DTLS", |
| 1539 | config: Config{ |
| 1540 | Bugs: ProtocolBugs{ |
| 1541 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1542 | }, |
| 1543 | }, |
| 1544 | shouldFail: true, |
| 1545 | expectedError: ":UNEXPECTED_RECORD:", |
| 1546 | }, |
| 1547 | { |
| 1548 | protocol: dtls, |
| 1549 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1550 | config: Config{ |
| 1551 | Bugs: ProtocolBugs{ |
| 1552 | AppDataBeforeHandshake: []byte{}, |
| 1553 | }, |
| 1554 | }, |
| 1555 | shouldFail: true, |
| 1556 | expectedError: ":UNEXPECTED_RECORD:", |
| 1557 | }, |
| 1558 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1559 | name: "AppDataAfterChangeCipherSpec", |
| 1560 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1561 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1562 | Bugs: ProtocolBugs{ |
| 1563 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1564 | }, |
| 1565 | }, |
| 1566 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1567 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1568 | }, |
| 1569 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1570 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1571 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1572 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1573 | Bugs: ProtocolBugs{ |
| 1574 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1575 | }, |
| 1576 | }, |
| 1577 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1578 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1579 | }, |
| 1580 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1581 | protocol: dtls, |
| 1582 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1583 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1584 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1585 | Bugs: ProtocolBugs{ |
| 1586 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1587 | }, |
| 1588 | }, |
| 1589 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1590 | // application data. |
| 1591 | }, |
| 1592 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1593 | protocol: dtls, |
| 1594 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1595 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1596 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1597 | Bugs: ProtocolBugs{ |
| 1598 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1599 | }, |
| 1600 | }, |
| 1601 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1602 | // application data. |
| 1603 | }, |
| 1604 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1605 | name: "AlertAfterChangeCipherSpec", |
| 1606 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1607 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1608 | Bugs: ProtocolBugs{ |
| 1609 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1610 | }, |
| 1611 | }, |
| 1612 | shouldFail: true, |
| 1613 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1614 | }, |
| 1615 | { |
| 1616 | protocol: dtls, |
| 1617 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1618 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1619 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1620 | Bugs: ProtocolBugs{ |
| 1621 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1622 | }, |
| 1623 | }, |
| 1624 | shouldFail: true, |
| 1625 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1626 | }, |
| 1627 | { |
| 1628 | protocol: dtls, |
| 1629 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1630 | config: Config{ |
| 1631 | Bugs: ProtocolBugs{ |
| 1632 | ReorderHandshakeFragments: true, |
| 1633 | // Small enough that every handshake message is |
| 1634 | // fragmented. |
| 1635 | MaxHandshakeRecordLength: 2, |
| 1636 | }, |
| 1637 | }, |
| 1638 | }, |
| 1639 | { |
| 1640 | protocol: dtls, |
| 1641 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1642 | config: Config{ |
| 1643 | Bugs: ProtocolBugs{ |
| 1644 | ReorderHandshakeFragments: true, |
| 1645 | // Large enough that no handshake message is |
| 1646 | // fragmented. |
| 1647 | MaxHandshakeRecordLength: 2048, |
| 1648 | }, |
| 1649 | }, |
| 1650 | }, |
| 1651 | { |
| 1652 | protocol: dtls, |
| 1653 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1654 | config: Config{ |
| 1655 | Bugs: ProtocolBugs{ |
| 1656 | ReorderHandshakeFragments: true, |
| 1657 | MixCompleteMessageWithFragments: true, |
| 1658 | MaxHandshakeRecordLength: 2, |
| 1659 | }, |
| 1660 | }, |
| 1661 | }, |
| 1662 | { |
| 1663 | name: "SendInvalidRecordType", |
| 1664 | config: Config{ |
| 1665 | Bugs: ProtocolBugs{ |
| 1666 | SendInvalidRecordType: true, |
| 1667 | }, |
| 1668 | }, |
| 1669 | shouldFail: true, |
| 1670 | expectedError: ":UNEXPECTED_RECORD:", |
| 1671 | }, |
| 1672 | { |
| 1673 | protocol: dtls, |
| 1674 | name: "SendInvalidRecordType-DTLS", |
| 1675 | config: Config{ |
| 1676 | Bugs: ProtocolBugs{ |
| 1677 | SendInvalidRecordType: true, |
| 1678 | }, |
| 1679 | }, |
| 1680 | shouldFail: true, |
| 1681 | expectedError: ":UNEXPECTED_RECORD:", |
| 1682 | }, |
| 1683 | { |
| 1684 | name: "FalseStart-SkipServerSecondLeg", |
| 1685 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1686 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1687 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1688 | NextProtos: []string{"foo"}, |
| 1689 | Bugs: ProtocolBugs{ |
| 1690 | SkipNewSessionTicket: true, |
| 1691 | SkipChangeCipherSpec: true, |
| 1692 | SkipFinished: true, |
| 1693 | ExpectFalseStart: true, |
| 1694 | }, |
| 1695 | }, |
| 1696 | flags: []string{ |
| 1697 | "-false-start", |
| 1698 | "-handshake-never-done", |
| 1699 | "-advertise-alpn", "\x03foo", |
| 1700 | }, |
| 1701 | shimWritesFirst: true, |
| 1702 | shouldFail: true, |
| 1703 | expectedError: ":UNEXPECTED_RECORD:", |
| 1704 | }, |
| 1705 | { |
| 1706 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1707 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1708 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1709 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1710 | NextProtos: []string{"foo"}, |
| 1711 | Bugs: ProtocolBugs{ |
| 1712 | SkipNewSessionTicket: true, |
| 1713 | SkipChangeCipherSpec: true, |
| 1714 | SkipFinished: true, |
| 1715 | }, |
| 1716 | }, |
| 1717 | flags: []string{ |
| 1718 | "-implicit-handshake", |
| 1719 | "-false-start", |
| 1720 | "-handshake-never-done", |
| 1721 | "-advertise-alpn", "\x03foo", |
| 1722 | }, |
| 1723 | shouldFail: true, |
| 1724 | expectedError: ":UNEXPECTED_RECORD:", |
| 1725 | }, |
| 1726 | { |
| 1727 | testType: serverTest, |
| 1728 | name: "FailEarlyCallback", |
| 1729 | flags: []string{"-fail-early-callback"}, |
| 1730 | shouldFail: true, |
| 1731 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1732 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1733 | }, |
| 1734 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1735 | name: "FailCertCallback-Client-TLS12", |
| 1736 | config: Config{ |
| 1737 | MaxVersion: VersionTLS12, |
| 1738 | ClientAuth: RequestClientCert, |
| 1739 | }, |
| 1740 | flags: []string{"-fail-cert-callback"}, |
| 1741 | shouldFail: true, |
| 1742 | expectedError: ":CERT_CB_ERROR:", |
| 1743 | expectedLocalError: "remote error: internal error", |
| 1744 | }, |
| 1745 | { |
| 1746 | testType: serverTest, |
| 1747 | name: "FailCertCallback-Server-TLS12", |
| 1748 | config: Config{ |
| 1749 | MaxVersion: VersionTLS12, |
| 1750 | }, |
| 1751 | flags: []string{"-fail-cert-callback"}, |
| 1752 | shouldFail: true, |
| 1753 | expectedError: ":CERT_CB_ERROR:", |
| 1754 | expectedLocalError: "remote error: internal error", |
| 1755 | }, |
| 1756 | { |
| 1757 | name: "FailCertCallback-Client-TLS13", |
| 1758 | config: Config{ |
| 1759 | MaxVersion: VersionTLS13, |
| 1760 | ClientAuth: RequestClientCert, |
| 1761 | }, |
| 1762 | flags: []string{"-fail-cert-callback"}, |
| 1763 | shouldFail: true, |
| 1764 | expectedError: ":CERT_CB_ERROR:", |
| 1765 | expectedLocalError: "remote error: internal error", |
| 1766 | }, |
| 1767 | { |
| 1768 | testType: serverTest, |
| 1769 | name: "FailCertCallback-Server-TLS13", |
| 1770 | config: Config{ |
| 1771 | MaxVersion: VersionTLS13, |
| 1772 | }, |
| 1773 | flags: []string{"-fail-cert-callback"}, |
| 1774 | shouldFail: true, |
| 1775 | expectedError: ":CERT_CB_ERROR:", |
| 1776 | expectedLocalError: "remote error: internal error", |
| 1777 | }, |
| 1778 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1779 | protocol: dtls, |
| 1780 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1781 | config: Config{ |
| 1782 | Bugs: ProtocolBugs{ |
| 1783 | MaxHandshakeRecordLength: 2, |
| 1784 | FragmentMessageTypeMismatch: true, |
| 1785 | }, |
| 1786 | }, |
| 1787 | shouldFail: true, |
| 1788 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1789 | }, |
| 1790 | { |
| 1791 | protocol: dtls, |
| 1792 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1793 | config: Config{ |
| 1794 | Bugs: ProtocolBugs{ |
| 1795 | MaxHandshakeRecordLength: 2, |
| 1796 | FragmentMessageLengthMismatch: true, |
| 1797 | }, |
| 1798 | }, |
| 1799 | shouldFail: true, |
| 1800 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1801 | }, |
| 1802 | { |
| 1803 | protocol: dtls, |
| 1804 | name: "SplitFragments-Header-DTLS", |
| 1805 | config: Config{ |
| 1806 | Bugs: ProtocolBugs{ |
| 1807 | SplitFragments: 2, |
| 1808 | }, |
| 1809 | }, |
| 1810 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1811 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1812 | }, |
| 1813 | { |
| 1814 | protocol: dtls, |
| 1815 | name: "SplitFragments-Boundary-DTLS", |
| 1816 | config: Config{ |
| 1817 | Bugs: ProtocolBugs{ |
| 1818 | SplitFragments: dtlsRecordHeaderLen, |
| 1819 | }, |
| 1820 | }, |
| 1821 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1822 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1823 | }, |
| 1824 | { |
| 1825 | protocol: dtls, |
| 1826 | name: "SplitFragments-Body-DTLS", |
| 1827 | config: Config{ |
| 1828 | Bugs: ProtocolBugs{ |
| 1829 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1830 | }, |
| 1831 | }, |
| 1832 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1833 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1834 | }, |
| 1835 | { |
| 1836 | protocol: dtls, |
| 1837 | name: "SendEmptyFragments-DTLS", |
| 1838 | config: Config{ |
| 1839 | Bugs: ProtocolBugs{ |
| 1840 | SendEmptyFragments: true, |
| 1841 | }, |
| 1842 | }, |
| 1843 | }, |
| 1844 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1845 | name: "BadFinished-Client", |
| 1846 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1847 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1848 | Bugs: ProtocolBugs{ |
| 1849 | BadFinished: true, |
| 1850 | }, |
| 1851 | }, |
| 1852 | shouldFail: true, |
| 1853 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1854 | }, |
| 1855 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1856 | name: "BadFinished-Client-TLS13", |
| 1857 | config: Config{ |
| 1858 | MaxVersion: VersionTLS13, |
| 1859 | Bugs: ProtocolBugs{ |
| 1860 | BadFinished: true, |
| 1861 | }, |
| 1862 | }, |
| 1863 | shouldFail: true, |
| 1864 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1865 | }, |
| 1866 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1867 | testType: serverTest, |
| 1868 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1869 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1870 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1871 | Bugs: ProtocolBugs{ |
| 1872 | BadFinished: true, |
| 1873 | }, |
| 1874 | }, |
| 1875 | shouldFail: true, |
| 1876 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1877 | }, |
| 1878 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1879 | testType: serverTest, |
| 1880 | name: "BadFinished-Server-TLS13", |
| 1881 | config: Config{ |
| 1882 | MaxVersion: VersionTLS13, |
| 1883 | Bugs: ProtocolBugs{ |
| 1884 | BadFinished: true, |
| 1885 | }, |
| 1886 | }, |
| 1887 | shouldFail: true, |
| 1888 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1889 | }, |
| 1890 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1891 | name: "FalseStart-BadFinished", |
| 1892 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1893 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1894 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1895 | NextProtos: []string{"foo"}, |
| 1896 | Bugs: ProtocolBugs{ |
| 1897 | BadFinished: true, |
| 1898 | ExpectFalseStart: true, |
| 1899 | }, |
| 1900 | }, |
| 1901 | flags: []string{ |
| 1902 | "-false-start", |
| 1903 | "-handshake-never-done", |
| 1904 | "-advertise-alpn", "\x03foo", |
| 1905 | }, |
| 1906 | shimWritesFirst: true, |
| 1907 | shouldFail: true, |
| 1908 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1909 | }, |
| 1910 | { |
| 1911 | name: "NoFalseStart-NoALPN", |
| 1912 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1913 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1914 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1915 | Bugs: ProtocolBugs{ |
| 1916 | ExpectFalseStart: true, |
| 1917 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1918 | }, |
| 1919 | }, |
| 1920 | flags: []string{ |
| 1921 | "-false-start", |
| 1922 | }, |
| 1923 | shimWritesFirst: true, |
| 1924 | shouldFail: true, |
| 1925 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1926 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1927 | }, |
| 1928 | { |
| 1929 | name: "NoFalseStart-NoAEAD", |
| 1930 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1931 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1932 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1933 | NextProtos: []string{"foo"}, |
| 1934 | Bugs: ProtocolBugs{ |
| 1935 | ExpectFalseStart: true, |
| 1936 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1937 | }, |
| 1938 | }, |
| 1939 | flags: []string{ |
| 1940 | "-false-start", |
| 1941 | "-advertise-alpn", "\x03foo", |
| 1942 | }, |
| 1943 | shimWritesFirst: true, |
| 1944 | shouldFail: true, |
| 1945 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1946 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1947 | }, |
| 1948 | { |
| 1949 | name: "NoFalseStart-RSA", |
| 1950 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1951 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1952 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1953 | NextProtos: []string{"foo"}, |
| 1954 | Bugs: ProtocolBugs{ |
| 1955 | ExpectFalseStart: true, |
| 1956 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1957 | }, |
| 1958 | }, |
| 1959 | flags: []string{ |
| 1960 | "-false-start", |
| 1961 | "-advertise-alpn", "\x03foo", |
| 1962 | }, |
| 1963 | shimWritesFirst: true, |
| 1964 | shouldFail: true, |
| 1965 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1966 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1967 | }, |
| 1968 | { |
| 1969 | name: "NoFalseStart-DHE_RSA", |
| 1970 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1971 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1972 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1973 | NextProtos: []string{"foo"}, |
| 1974 | Bugs: ProtocolBugs{ |
| 1975 | ExpectFalseStart: true, |
| 1976 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1977 | }, |
| 1978 | }, |
| 1979 | flags: []string{ |
| 1980 | "-false-start", |
| 1981 | "-advertise-alpn", "\x03foo", |
| 1982 | }, |
| 1983 | shimWritesFirst: true, |
| 1984 | shouldFail: true, |
| 1985 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1986 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1987 | }, |
| 1988 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1989 | protocol: dtls, |
| 1990 | name: "SendSplitAlert-Sync", |
| 1991 | config: Config{ |
| 1992 | Bugs: ProtocolBugs{ |
| 1993 | SendSplitAlert: true, |
| 1994 | }, |
| 1995 | }, |
| 1996 | }, |
| 1997 | { |
| 1998 | protocol: dtls, |
| 1999 | name: "SendSplitAlert-Async", |
| 2000 | config: Config{ |
| 2001 | Bugs: ProtocolBugs{ |
| 2002 | SendSplitAlert: true, |
| 2003 | }, |
| 2004 | }, |
| 2005 | flags: []string{"-async"}, |
| 2006 | }, |
| 2007 | { |
| 2008 | protocol: dtls, |
| 2009 | name: "PackDTLSHandshake", |
| 2010 | config: Config{ |
| 2011 | Bugs: ProtocolBugs{ |
| 2012 | MaxHandshakeRecordLength: 2, |
| 2013 | PackHandshakeFragments: 20, |
| 2014 | PackHandshakeRecords: 200, |
| 2015 | }, |
| 2016 | }, |
| 2017 | }, |
| 2018 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2019 | name: "SendEmptyRecords-Pass", |
| 2020 | sendEmptyRecords: 32, |
| 2021 | }, |
| 2022 | { |
| 2023 | name: "SendEmptyRecords", |
| 2024 | sendEmptyRecords: 33, |
| 2025 | shouldFail: true, |
| 2026 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2027 | }, |
| 2028 | { |
| 2029 | name: "SendEmptyRecords-Async", |
| 2030 | sendEmptyRecords: 33, |
| 2031 | flags: []string{"-async"}, |
| 2032 | shouldFail: true, |
| 2033 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2034 | }, |
| 2035 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2036 | name: "SendWarningAlerts-Pass", |
| 2037 | config: Config{ |
| 2038 | MaxVersion: VersionTLS12, |
| 2039 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2040 | sendWarningAlerts: 4, |
| 2041 | }, |
| 2042 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2043 | protocol: dtls, |
| 2044 | name: "SendWarningAlerts-DTLS-Pass", |
| 2045 | config: Config{ |
| 2046 | MaxVersion: VersionTLS12, |
| 2047 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2048 | sendWarningAlerts: 4, |
| 2049 | }, |
| 2050 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2051 | name: "SendWarningAlerts-TLS13", |
| 2052 | config: Config{ |
| 2053 | MaxVersion: VersionTLS13, |
| 2054 | }, |
| 2055 | sendWarningAlerts: 4, |
| 2056 | shouldFail: true, |
| 2057 | expectedError: ":BAD_ALERT:", |
| 2058 | expectedLocalError: "remote error: error decoding message", |
| 2059 | }, |
| 2060 | { |
| 2061 | name: "SendWarningAlerts", |
| 2062 | config: Config{ |
| 2063 | MaxVersion: VersionTLS12, |
| 2064 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2065 | sendWarningAlerts: 5, |
| 2066 | shouldFail: true, |
| 2067 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2068 | }, |
| 2069 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2070 | name: "SendWarningAlerts-Async", |
| 2071 | config: Config{ |
| 2072 | MaxVersion: VersionTLS12, |
| 2073 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2074 | sendWarningAlerts: 5, |
| 2075 | flags: []string{"-async"}, |
| 2076 | shouldFail: true, |
| 2077 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2078 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2079 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2080 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2081 | config: Config{ |
| 2082 | MaxVersion: VersionTLS13, |
| 2083 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2084 | sendKeyUpdates: 33, |
| 2085 | keyUpdateRequest: keyUpdateNotRequested, |
| 2086 | shouldFail: true, |
| 2087 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2088 | }, |
| 2089 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2090 | name: "EmptySessionID", |
| 2091 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2092 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2093 | SessionTicketsDisabled: true, |
| 2094 | }, |
| 2095 | noSessionCache: true, |
| 2096 | flags: []string{"-expect-no-session"}, |
| 2097 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2098 | { |
| 2099 | name: "Unclean-Shutdown", |
| 2100 | config: Config{ |
| 2101 | Bugs: ProtocolBugs{ |
| 2102 | NoCloseNotify: true, |
| 2103 | ExpectCloseNotify: true, |
| 2104 | }, |
| 2105 | }, |
| 2106 | shimShutsDown: true, |
| 2107 | flags: []string{"-check-close-notify"}, |
| 2108 | shouldFail: true, |
| 2109 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2110 | }, |
| 2111 | { |
| 2112 | name: "Unclean-Shutdown-Ignored", |
| 2113 | config: Config{ |
| 2114 | Bugs: ProtocolBugs{ |
| 2115 | NoCloseNotify: true, |
| 2116 | }, |
| 2117 | }, |
| 2118 | shimShutsDown: true, |
| 2119 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2120 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2121 | name: "Unclean-Shutdown-Alert", |
| 2122 | config: Config{ |
| 2123 | Bugs: ProtocolBugs{ |
| 2124 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2125 | ExpectCloseNotify: true, |
| 2126 | }, |
| 2127 | }, |
| 2128 | shimShutsDown: true, |
| 2129 | flags: []string{"-check-close-notify"}, |
| 2130 | shouldFail: true, |
| 2131 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2132 | }, |
| 2133 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2134 | name: "LargePlaintext", |
| 2135 | config: Config{ |
| 2136 | Bugs: ProtocolBugs{ |
| 2137 | SendLargeRecords: true, |
| 2138 | }, |
| 2139 | }, |
| 2140 | messageLen: maxPlaintext + 1, |
| 2141 | shouldFail: true, |
| 2142 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2143 | }, |
| 2144 | { |
| 2145 | protocol: dtls, |
| 2146 | name: "LargePlaintext-DTLS", |
| 2147 | config: Config{ |
| 2148 | Bugs: ProtocolBugs{ |
| 2149 | SendLargeRecords: true, |
| 2150 | }, |
| 2151 | }, |
| 2152 | messageLen: maxPlaintext + 1, |
| 2153 | shouldFail: true, |
| 2154 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2155 | }, |
| 2156 | { |
| 2157 | name: "LargeCiphertext", |
| 2158 | config: Config{ |
| 2159 | Bugs: ProtocolBugs{ |
| 2160 | SendLargeRecords: true, |
| 2161 | }, |
| 2162 | }, |
| 2163 | messageLen: maxPlaintext * 2, |
| 2164 | shouldFail: true, |
| 2165 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2166 | }, |
| 2167 | { |
| 2168 | protocol: dtls, |
| 2169 | name: "LargeCiphertext-DTLS", |
| 2170 | config: Config{ |
| 2171 | Bugs: ProtocolBugs{ |
| 2172 | SendLargeRecords: true, |
| 2173 | }, |
| 2174 | }, |
| 2175 | messageLen: maxPlaintext * 2, |
| 2176 | // Unlike the other four cases, DTLS drops records which |
| 2177 | // are invalid before authentication, so the connection |
| 2178 | // does not fail. |
| 2179 | expectMessageDropped: true, |
| 2180 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2181 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2182 | name: "BadHelloRequest-1", |
| 2183 | renegotiate: 1, |
| 2184 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2185 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2186 | Bugs: ProtocolBugs{ |
| 2187 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2188 | }, |
| 2189 | }, |
| 2190 | flags: []string{ |
| 2191 | "-renegotiate-freely", |
| 2192 | "-expect-total-renegotiations", "1", |
| 2193 | }, |
| 2194 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2195 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2196 | }, |
| 2197 | { |
| 2198 | name: "BadHelloRequest-2", |
| 2199 | renegotiate: 1, |
| 2200 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2201 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2202 | Bugs: ProtocolBugs{ |
| 2203 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2204 | }, |
| 2205 | }, |
| 2206 | flags: []string{ |
| 2207 | "-renegotiate-freely", |
| 2208 | "-expect-total-renegotiations", "1", |
| 2209 | }, |
| 2210 | shouldFail: true, |
| 2211 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2212 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2213 | { |
| 2214 | testType: serverTest, |
| 2215 | name: "SupportTicketsWithSessionID", |
| 2216 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2217 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2218 | SessionTicketsDisabled: true, |
| 2219 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2220 | resumeConfig: &Config{ |
| 2221 | MaxVersion: VersionTLS12, |
| 2222 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2223 | resumeSession: true, |
| 2224 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2225 | { |
| 2226 | protocol: dtls, |
| 2227 | name: "DTLS-SendExtraFinished", |
| 2228 | config: Config{ |
| 2229 | Bugs: ProtocolBugs{ |
| 2230 | SendExtraFinished: true, |
| 2231 | }, |
| 2232 | }, |
| 2233 | shouldFail: true, |
| 2234 | expectedError: ":UNEXPECTED_RECORD:", |
| 2235 | }, |
| 2236 | { |
| 2237 | protocol: dtls, |
| 2238 | name: "DTLS-SendExtraFinished-Reordered", |
| 2239 | config: Config{ |
| 2240 | Bugs: ProtocolBugs{ |
| 2241 | MaxHandshakeRecordLength: 2, |
| 2242 | ReorderHandshakeFragments: true, |
| 2243 | SendExtraFinished: true, |
| 2244 | }, |
| 2245 | }, |
| 2246 | shouldFail: true, |
| 2247 | expectedError: ":UNEXPECTED_RECORD:", |
| 2248 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2249 | { |
| 2250 | testType: serverTest, |
| 2251 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2252 | config: Config{ |
| 2253 | // Choose a cipher suite that does not involve |
| 2254 | // elliptic curves, so no extensions are |
| 2255 | // involved. |
| 2256 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2257 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2258 | Bugs: ProtocolBugs{ |
| 2259 | SendV2ClientHello: true, |
| 2260 | }, |
| 2261 | }, |
| 2262 | sendPrefix: string([]byte{ |
| 2263 | byte(recordTypeHandshake), |
| 2264 | 3, 1, // version |
| 2265 | 0, 0, // length |
| 2266 | }), |
| 2267 | // A no-op empty record may not be sent before V2ClientHello. |
| 2268 | shouldFail: true, |
| 2269 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2270 | }, |
| 2271 | { |
| 2272 | testType: serverTest, |
| 2273 | name: "V2ClientHello-WarningAlertPrefix", |
| 2274 | config: Config{ |
| 2275 | // Choose a cipher suite that does not involve |
| 2276 | // elliptic curves, so no extensions are |
| 2277 | // involved. |
| 2278 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2279 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2280 | Bugs: ProtocolBugs{ |
| 2281 | SendV2ClientHello: true, |
| 2282 | }, |
| 2283 | }, |
| 2284 | sendPrefix: string([]byte{ |
| 2285 | byte(recordTypeAlert), |
| 2286 | 3, 1, // version |
| 2287 | 0, 2, // length |
| 2288 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2289 | }), |
| 2290 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2291 | shouldFail: true, |
| 2292 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2293 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2294 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2295 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2296 | config: Config{ |
| 2297 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2298 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2299 | sendKeyUpdates: 1, |
| 2300 | keyUpdateRequest: keyUpdateNotRequested, |
| 2301 | }, |
| 2302 | { |
| 2303 | name: "KeyUpdate-InvalidRequestMode", |
| 2304 | config: Config{ |
| 2305 | MaxVersion: VersionTLS13, |
| 2306 | }, |
| 2307 | sendKeyUpdates: 1, |
| 2308 | keyUpdateRequest: 42, |
| 2309 | shouldFail: true, |
| 2310 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2311 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2312 | { |
| 2313 | name: "SendSNIWarningAlert", |
| 2314 | config: Config{ |
| 2315 | MaxVersion: VersionTLS12, |
| 2316 | Bugs: ProtocolBugs{ |
| 2317 | SendSNIWarningAlert: true, |
| 2318 | }, |
| 2319 | }, |
| 2320 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2321 | { |
| 2322 | testType: serverTest, |
| 2323 | name: "ExtraCompressionMethods-TLS12", |
| 2324 | config: Config{ |
| 2325 | MaxVersion: VersionTLS12, |
| 2326 | Bugs: ProtocolBugs{ |
| 2327 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2328 | }, |
| 2329 | }, |
| 2330 | }, |
| 2331 | { |
| 2332 | testType: serverTest, |
| 2333 | name: "ExtraCompressionMethods-TLS13", |
| 2334 | config: Config{ |
| 2335 | MaxVersion: VersionTLS13, |
| 2336 | Bugs: ProtocolBugs{ |
| 2337 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2338 | }, |
| 2339 | }, |
| 2340 | shouldFail: true, |
| 2341 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2342 | expectedLocalError: "remote error: illegal parameter", |
| 2343 | }, |
| 2344 | { |
| 2345 | testType: serverTest, |
| 2346 | name: "NoNullCompression-TLS12", |
| 2347 | config: Config{ |
| 2348 | MaxVersion: VersionTLS12, |
| 2349 | Bugs: ProtocolBugs{ |
| 2350 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2351 | }, |
| 2352 | }, |
| 2353 | shouldFail: true, |
| 2354 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2355 | expectedLocalError: "remote error: illegal parameter", |
| 2356 | }, |
| 2357 | { |
| 2358 | testType: serverTest, |
| 2359 | name: "NoNullCompression-TLS13", |
| 2360 | config: Config{ |
| 2361 | MaxVersion: VersionTLS13, |
| 2362 | Bugs: ProtocolBugs{ |
| 2363 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2364 | }, |
| 2365 | }, |
| 2366 | shouldFail: true, |
| 2367 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2368 | expectedLocalError: "remote error: illegal parameter", |
| 2369 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2370 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2371 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2372 | config: Config{ |
| 2373 | MaxVersion: VersionTLS12, |
| 2374 | Bugs: ProtocolBugs{ |
| 2375 | ExpectGREASE: true, |
| 2376 | }, |
| 2377 | }, |
| 2378 | flags: []string{"-enable-grease"}, |
| 2379 | }, |
| 2380 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2381 | name: "GREASE-Client-TLS13", |
| 2382 | config: Config{ |
| 2383 | MaxVersion: VersionTLS13, |
| 2384 | Bugs: ProtocolBugs{ |
| 2385 | ExpectGREASE: true, |
| 2386 | }, |
| 2387 | }, |
| 2388 | flags: []string{"-enable-grease"}, |
| 2389 | }, |
| 2390 | { |
| 2391 | testType: serverTest, |
| 2392 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2393 | config: Config{ |
| 2394 | MaxVersion: VersionTLS13, |
| 2395 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2396 | // TLS 1.3 servers are expected to |
| 2397 | // always enable GREASE. TLS 1.3 is new, |
| 2398 | // so there is no existing ecosystem to |
| 2399 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2400 | ExpectGREASE: true, |
| 2401 | }, |
| 2402 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2403 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2404 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2405 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2406 | |
| 2407 | // Test that very large messages can be received. |
| 2408 | cert := rsaCertificate |
| 2409 | for i := 0; i < 50; i++ { |
| 2410 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2411 | } |
| 2412 | testCases = append(testCases, testCase{ |
| 2413 | name: "LargeMessage", |
| 2414 | config: Config{ |
| 2415 | Certificates: []Certificate{cert}, |
| 2416 | }, |
| 2417 | }) |
| 2418 | testCases = append(testCases, testCase{ |
| 2419 | protocol: dtls, |
| 2420 | name: "LargeMessage-DTLS", |
| 2421 | config: Config{ |
| 2422 | Certificates: []Certificate{cert}, |
| 2423 | }, |
| 2424 | }) |
| 2425 | |
| 2426 | // They are rejected if the maximum certificate chain length is capped. |
| 2427 | testCases = append(testCases, testCase{ |
| 2428 | name: "LargeMessage-Reject", |
| 2429 | config: Config{ |
| 2430 | Certificates: []Certificate{cert}, |
| 2431 | }, |
| 2432 | flags: []string{"-max-cert-list", "16384"}, |
| 2433 | shouldFail: true, |
| 2434 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2435 | }) |
| 2436 | testCases = append(testCases, testCase{ |
| 2437 | protocol: dtls, |
| 2438 | name: "LargeMessage-Reject-DTLS", |
| 2439 | config: Config{ |
| 2440 | Certificates: []Certificate{cert}, |
| 2441 | }, |
| 2442 | flags: []string{"-max-cert-list", "16384"}, |
| 2443 | shouldFail: true, |
| 2444 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2445 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2446 | } |
| 2447 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2448 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2449 | const psk = "12345" |
| 2450 | const pskIdentity = "luggage combo" |
| 2451 | |
| 2452 | var prefix string |
| 2453 | if protocol == dtls { |
| 2454 | if !ver.hasDTLS { |
| 2455 | return |
| 2456 | } |
| 2457 | prefix = "D" |
| 2458 | } |
| 2459 | |
| 2460 | var cert Certificate |
| 2461 | var certFile string |
| 2462 | var keyFile string |
| 2463 | if hasComponent(suite.name, "ECDSA") { |
| 2464 | cert = ecdsaP256Certificate |
| 2465 | certFile = ecdsaP256CertificateFile |
| 2466 | keyFile = ecdsaP256KeyFile |
| 2467 | } else { |
| 2468 | cert = rsaCertificate |
| 2469 | certFile = rsaCertificateFile |
| 2470 | keyFile = rsaKeyFile |
| 2471 | } |
| 2472 | |
| 2473 | var flags []string |
| 2474 | if hasComponent(suite.name, "PSK") { |
| 2475 | flags = append(flags, |
| 2476 | "-psk", psk, |
| 2477 | "-psk-identity", pskIdentity) |
| 2478 | } |
| 2479 | if hasComponent(suite.name, "NULL") { |
| 2480 | // NULL ciphers must be explicitly enabled. |
| 2481 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2482 | } |
| 2483 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2484 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2485 | // for now. |
| 2486 | flags = append(flags, "-cipher", suite.name) |
| 2487 | } |
| 2488 | |
| 2489 | var shouldServerFail, shouldClientFail bool |
| 2490 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2491 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2492 | // a BoringSSL server will never select it |
| 2493 | // because the extension is missing. |
| 2494 | shouldServerFail = true |
| 2495 | } |
| 2496 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2497 | shouldClientFail = true |
| 2498 | shouldServerFail = true |
| 2499 | } |
| 2500 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2501 | shouldClientFail = true |
| 2502 | shouldServerFail = true |
| 2503 | } |
| 2504 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2505 | shouldClientFail = true |
| 2506 | shouldServerFail = true |
| 2507 | } |
| 2508 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2509 | shouldClientFail = true |
| 2510 | shouldServerFail = true |
| 2511 | } |
| 2512 | |
| 2513 | var sendCipherSuite uint16 |
| 2514 | var expectedServerError, expectedClientError string |
| 2515 | serverCipherSuites := []uint16{suite.id} |
| 2516 | if shouldServerFail { |
| 2517 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2518 | } |
| 2519 | if shouldClientFail { |
| 2520 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2521 | // Configure the server to select ciphers as normal but |
| 2522 | // select an incompatible cipher in ServerHello. |
| 2523 | serverCipherSuites = nil |
| 2524 | sendCipherSuite = suite.id |
| 2525 | } |
| 2526 | |
| 2527 | testCases = append(testCases, testCase{ |
| 2528 | testType: serverTest, |
| 2529 | protocol: protocol, |
| 2530 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2531 | config: Config{ |
| 2532 | MinVersion: ver.version, |
| 2533 | MaxVersion: ver.version, |
| 2534 | CipherSuites: []uint16{suite.id}, |
| 2535 | Certificates: []Certificate{cert}, |
| 2536 | PreSharedKey: []byte(psk), |
| 2537 | PreSharedKeyIdentity: pskIdentity, |
| 2538 | Bugs: ProtocolBugs{ |
| 2539 | AdvertiseAllConfiguredCiphers: true, |
| 2540 | }, |
| 2541 | }, |
| 2542 | certFile: certFile, |
| 2543 | keyFile: keyFile, |
| 2544 | flags: flags, |
| 2545 | resumeSession: true, |
| 2546 | shouldFail: shouldServerFail, |
| 2547 | expectedError: expectedServerError, |
| 2548 | }) |
| 2549 | |
| 2550 | testCases = append(testCases, testCase{ |
| 2551 | testType: clientTest, |
| 2552 | protocol: protocol, |
| 2553 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2554 | config: Config{ |
| 2555 | MinVersion: ver.version, |
| 2556 | MaxVersion: ver.version, |
| 2557 | CipherSuites: serverCipherSuites, |
| 2558 | Certificates: []Certificate{cert}, |
| 2559 | PreSharedKey: []byte(psk), |
| 2560 | PreSharedKeyIdentity: pskIdentity, |
| 2561 | Bugs: ProtocolBugs{ |
| 2562 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2563 | SendCipherSuite: sendCipherSuite, |
| 2564 | }, |
| 2565 | }, |
| 2566 | flags: flags, |
| 2567 | resumeSession: true, |
| 2568 | shouldFail: shouldClientFail, |
| 2569 | expectedError: expectedClientError, |
| 2570 | }) |
| 2571 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2572 | if shouldClientFail { |
| 2573 | return |
| 2574 | } |
| 2575 | |
| 2576 | // Ensure the maximum record size is accepted. |
| 2577 | testCases = append(testCases, testCase{ |
| 2578 | protocol: protocol, |
| 2579 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2580 | config: Config{ |
| 2581 | MinVersion: ver.version, |
| 2582 | MaxVersion: ver.version, |
| 2583 | CipherSuites: []uint16{suite.id}, |
| 2584 | Certificates: []Certificate{cert}, |
| 2585 | PreSharedKey: []byte(psk), |
| 2586 | PreSharedKeyIdentity: pskIdentity, |
| 2587 | }, |
| 2588 | flags: flags, |
| 2589 | messageLen: maxPlaintext, |
| 2590 | }) |
| 2591 | |
| 2592 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2593 | // and ignored in DTLS. |
| 2594 | var shouldFail bool |
| 2595 | var expectedError string |
| 2596 | if protocol == tls { |
| 2597 | shouldFail = true |
| 2598 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2599 | } |
| 2600 | |
| 2601 | testCases = append(testCases, testCase{ |
| 2602 | protocol: protocol, |
| 2603 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2604 | config: Config{ |
| 2605 | MinVersion: ver.version, |
| 2606 | MaxVersion: ver.version, |
| 2607 | CipherSuites: []uint16{suite.id}, |
| 2608 | Certificates: []Certificate{cert}, |
| 2609 | PreSharedKey: []byte(psk), |
| 2610 | PreSharedKeyIdentity: pskIdentity, |
| 2611 | }, |
| 2612 | flags: flags, |
| 2613 | damageFirstWrite: true, |
| 2614 | messageLen: maxPlaintext, |
| 2615 | shouldFail: shouldFail, |
| 2616 | expectedError: expectedError, |
| 2617 | }) |
| 2618 | |
| 2619 | if ver.version >= VersionTLS13 { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2620 | testCases = append(testCases, testCase{ |
| 2621 | protocol: protocol, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2622 | name: prefix + ver.name + "-" + suite.name + "-ShortHeader", |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2623 | config: Config{ |
| 2624 | MinVersion: ver.version, |
| 2625 | MaxVersion: ver.version, |
| 2626 | CipherSuites: []uint16{suite.id}, |
| 2627 | Certificates: []Certificate{cert}, |
| 2628 | PreSharedKey: []byte(psk), |
| 2629 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2630 | Bugs: ProtocolBugs{ |
| 2631 | EnableShortHeader: true, |
| 2632 | }, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2633 | }, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2634 | flags: append([]string{"-enable-short-header"}, flags...), |
| 2635 | resumeSession: true, |
| 2636 | expectShortHeader: true, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2637 | }) |
| 2638 | } |
| 2639 | } |
| 2640 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2641 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2642 | const bogusCipher = 0xfe00 |
| 2643 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2644 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2645 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2646 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2647 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2648 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2649 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2650 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2651 | |
| 2652 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2653 | name: "NoSharedCipher", |
| 2654 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2655 | MaxVersion: VersionTLS12, |
| 2656 | CipherSuites: []uint16{}, |
| 2657 | }, |
| 2658 | shouldFail: true, |
| 2659 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2660 | }) |
| 2661 | |
| 2662 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2663 | name: "NoSharedCipher-TLS13", |
| 2664 | config: Config{ |
| 2665 | MaxVersion: VersionTLS13, |
| 2666 | CipherSuites: []uint16{}, |
| 2667 | }, |
| 2668 | shouldFail: true, |
| 2669 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2670 | }) |
| 2671 | |
| 2672 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2673 | name: "UnsupportedCipherSuite", |
| 2674 | config: Config{ |
| 2675 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2676 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2677 | Bugs: ProtocolBugs{ |
| 2678 | IgnorePeerCipherPreferences: true, |
| 2679 | }, |
| 2680 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2681 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2682 | shouldFail: true, |
| 2683 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2684 | }) |
| 2685 | |
| 2686 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2687 | name: "ServerHelloBogusCipher", |
| 2688 | config: Config{ |
| 2689 | MaxVersion: VersionTLS12, |
| 2690 | Bugs: ProtocolBugs{ |
| 2691 | SendCipherSuite: bogusCipher, |
| 2692 | }, |
| 2693 | }, |
| 2694 | shouldFail: true, |
| 2695 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2696 | }) |
| 2697 | testCases = append(testCases, testCase{ |
| 2698 | name: "ServerHelloBogusCipher-TLS13", |
| 2699 | config: Config{ |
| 2700 | MaxVersion: VersionTLS13, |
| 2701 | Bugs: ProtocolBugs{ |
| 2702 | SendCipherSuite: bogusCipher, |
| 2703 | }, |
| 2704 | }, |
| 2705 | shouldFail: true, |
| 2706 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2707 | }) |
| 2708 | |
| 2709 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2710 | name: "WeakDH", |
| 2711 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2712 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2713 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2714 | Bugs: ProtocolBugs{ |
| 2715 | // This is a 1023-bit prime number, generated |
| 2716 | // with: |
| 2717 | // openssl gendh 1023 | openssl asn1parse -i |
| 2718 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2719 | }, |
| 2720 | }, |
| 2721 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2722 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2723 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2724 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2725 | testCases = append(testCases, testCase{ |
| 2726 | name: "SillyDH", |
| 2727 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2728 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2729 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2730 | Bugs: ProtocolBugs{ |
| 2731 | // This is a 4097-bit prime number, generated |
| 2732 | // with: |
| 2733 | // openssl gendh 4097 | openssl asn1parse -i |
| 2734 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2735 | }, |
| 2736 | }, |
| 2737 | shouldFail: true, |
| 2738 | expectedError: ":DH_P_TOO_LONG:", |
| 2739 | }) |
| 2740 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2741 | // This test ensures that Diffie-Hellman public values are padded with |
| 2742 | // zeros so that they're the same length as the prime. This is to avoid |
| 2743 | // hitting a bug in yaSSL. |
| 2744 | testCases = append(testCases, testCase{ |
| 2745 | testType: serverTest, |
| 2746 | name: "DHPublicValuePadded", |
| 2747 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2748 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2749 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2750 | Bugs: ProtocolBugs{ |
| 2751 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2752 | }, |
| 2753 | }, |
| 2754 | flags: []string{"-use-sparse-dh-prime"}, |
| 2755 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2756 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2757 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2758 | testCases = append(testCases, testCase{ |
| 2759 | testType: serverTest, |
| 2760 | name: "UnknownCipher", |
| 2761 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2762 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2763 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2764 | Bugs: ProtocolBugs{ |
| 2765 | AdvertiseAllConfiguredCiphers: true, |
| 2766 | }, |
| 2767 | }, |
| 2768 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2769 | |
| 2770 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2771 | testCases = append(testCases, testCase{ |
| 2772 | testType: serverTest, |
| 2773 | name: "UnknownCipher-TLS13", |
| 2774 | config: Config{ |
| 2775 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2776 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2777 | Bugs: ProtocolBugs{ |
| 2778 | AdvertiseAllConfiguredCiphers: true, |
| 2779 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2780 | }, |
| 2781 | }) |
| 2782 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2783 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2784 | testCases = append(testCases, testCase{ |
| 2785 | name: "EmptyECDHEPSKHint", |
| 2786 | config: Config{ |
| 2787 | MaxVersion: VersionTLS12, |
| 2788 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2789 | PreSharedKey: []byte("secret"), |
| 2790 | }, |
| 2791 | flags: []string{"-psk", "secret"}, |
| 2792 | }) |
| 2793 | |
| 2794 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2795 | // ServerKeyExchange is sent. |
| 2796 | testCases = append(testCases, testCase{ |
| 2797 | name: "ExplicitEmptyPSKHint", |
| 2798 | config: Config{ |
| 2799 | MaxVersion: VersionTLS12, |
| 2800 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2801 | PreSharedKey: []byte("secret"), |
| 2802 | Bugs: ProtocolBugs{ |
| 2803 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2804 | }, |
| 2805 | }, |
| 2806 | flags: []string{"-psk", "secret"}, |
| 2807 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2808 | } |
| 2809 | |
| 2810 | func addBadECDSASignatureTests() { |
| 2811 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2812 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2813 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2814 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2815 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2816 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2817 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2818 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2819 | Bugs: ProtocolBugs{ |
| 2820 | BadECDSAR: badR, |
| 2821 | BadECDSAS: badS, |
| 2822 | }, |
| 2823 | }, |
| 2824 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2825 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2826 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2827 | testCases = append(testCases, testCase{ |
| 2828 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2829 | config: Config{ |
| 2830 | MaxVersion: VersionTLS13, |
| 2831 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2832 | Bugs: ProtocolBugs{ |
| 2833 | BadECDSAR: badR, |
| 2834 | BadECDSAS: badS, |
| 2835 | }, |
| 2836 | }, |
| 2837 | shouldFail: true, |
| 2838 | expectedError: ":BAD_SIGNATURE:", |
| 2839 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2840 | } |
| 2841 | } |
| 2842 | } |
| 2843 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2844 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2845 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2846 | name: "MaxCBCPadding", |
| 2847 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2848 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2849 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2850 | Bugs: ProtocolBugs{ |
| 2851 | MaxPadding: true, |
| 2852 | }, |
| 2853 | }, |
| 2854 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2855 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2856 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2857 | name: "BadCBCPadding", |
| 2858 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2859 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2860 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2861 | Bugs: ProtocolBugs{ |
| 2862 | PaddingFirstByteBad: true, |
| 2863 | }, |
| 2864 | }, |
| 2865 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2866 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2867 | }) |
| 2868 | // OpenSSL previously had an issue where the first byte of padding in |
| 2869 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2870 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2871 | name: "BadCBCPadding255", |
| 2872 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2873 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2874 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2875 | Bugs: ProtocolBugs{ |
| 2876 | MaxPadding: true, |
| 2877 | PaddingFirstByteBadIf255: true, |
| 2878 | }, |
| 2879 | }, |
| 2880 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2881 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2882 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2883 | }) |
| 2884 | } |
| 2885 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2886 | func addCBCSplittingTests() { |
| 2887 | testCases = append(testCases, testCase{ |
| 2888 | name: "CBCRecordSplitting", |
| 2889 | config: Config{ |
| 2890 | MaxVersion: VersionTLS10, |
| 2891 | MinVersion: VersionTLS10, |
| 2892 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2893 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2894 | messageLen: -1, // read until EOF |
| 2895 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2896 | flags: []string{ |
| 2897 | "-async", |
| 2898 | "-write-different-record-sizes", |
| 2899 | "-cbc-record-splitting", |
| 2900 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2901 | }) |
| 2902 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2903 | name: "CBCRecordSplittingPartialWrite", |
| 2904 | config: Config{ |
| 2905 | MaxVersion: VersionTLS10, |
| 2906 | MinVersion: VersionTLS10, |
| 2907 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2908 | }, |
| 2909 | messageLen: -1, // read until EOF |
| 2910 | flags: []string{ |
| 2911 | "-async", |
| 2912 | "-write-different-record-sizes", |
| 2913 | "-cbc-record-splitting", |
| 2914 | "-partial-write", |
| 2915 | }, |
| 2916 | }) |
| 2917 | } |
| 2918 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2919 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2920 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2921 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2922 | certPool := x509.NewCertPool() |
| 2923 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2924 | if err != nil { |
| 2925 | panic(err) |
| 2926 | } |
| 2927 | certPool.AddCert(cert) |
| 2928 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2929 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2930 | testCases = append(testCases, testCase{ |
| 2931 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2932 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2933 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2934 | MinVersion: ver.version, |
| 2935 | MaxVersion: ver.version, |
| 2936 | ClientAuth: RequireAnyClientCert, |
| 2937 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2938 | }, |
| 2939 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2940 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2941 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2942 | }, |
| 2943 | }) |
| 2944 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2945 | testType: serverTest, |
| 2946 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2947 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2948 | MinVersion: ver.version, |
| 2949 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2950 | Certificates: []Certificate{rsaCertificate}, |
| 2951 | }, |
| 2952 | flags: []string{"-require-any-client-certificate"}, |
| 2953 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2954 | if ver.version != VersionSSL30 { |
| 2955 | testCases = append(testCases, testCase{ |
| 2956 | testType: serverTest, |
| 2957 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 2958 | config: Config{ |
| 2959 | MinVersion: ver.version, |
| 2960 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2961 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2962 | }, |
| 2963 | flags: []string{"-require-any-client-certificate"}, |
| 2964 | }) |
| 2965 | testCases = append(testCases, testCase{ |
| 2966 | testType: clientTest, |
| 2967 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 2968 | config: Config{ |
| 2969 | MinVersion: ver.version, |
| 2970 | MaxVersion: ver.version, |
| 2971 | ClientAuth: RequireAnyClientCert, |
| 2972 | ClientCAs: certPool, |
| 2973 | }, |
| 2974 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2975 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2976 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2977 | }, |
| 2978 | }) |
| 2979 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2980 | |
| 2981 | testCases = append(testCases, testCase{ |
| 2982 | name: "NoClientCertificate-" + ver.name, |
| 2983 | config: Config{ |
| 2984 | MinVersion: ver.version, |
| 2985 | MaxVersion: ver.version, |
| 2986 | ClientAuth: RequireAnyClientCert, |
| 2987 | }, |
| 2988 | shouldFail: true, |
| 2989 | expectedLocalError: "client didn't provide a certificate", |
| 2990 | }) |
| 2991 | |
| 2992 | testCases = append(testCases, testCase{ |
| 2993 | // Even if not configured to expect a certificate, OpenSSL will |
| 2994 | // return X509_V_OK as the verify_result. |
| 2995 | testType: serverTest, |
| 2996 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 2997 | config: Config{ |
| 2998 | MinVersion: ver.version, |
| 2999 | MaxVersion: ver.version, |
| 3000 | }, |
| 3001 | flags: []string{ |
| 3002 | "-expect-verify-result", |
| 3003 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3004 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3005 | }) |
| 3006 | |
| 3007 | testCases = append(testCases, testCase{ |
| 3008 | // If a client certificate is not provided, OpenSSL will still |
| 3009 | // return X509_V_OK as the verify_result. |
| 3010 | testType: serverTest, |
| 3011 | name: "NoClientCertificate-Server-" + ver.name, |
| 3012 | config: Config{ |
| 3013 | MinVersion: ver.version, |
| 3014 | MaxVersion: ver.version, |
| 3015 | }, |
| 3016 | flags: []string{ |
| 3017 | "-expect-verify-result", |
| 3018 | "-verify-peer", |
| 3019 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3020 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3021 | }) |
| 3022 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3023 | certificateRequired := "remote error: certificate required" |
| 3024 | if ver.version < VersionTLS13 { |
| 3025 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3026 | // was used. |
| 3027 | certificateRequired = "remote error: handshake failure" |
| 3028 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3029 | testCases = append(testCases, testCase{ |
| 3030 | testType: serverTest, |
| 3031 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3032 | config: Config{ |
| 3033 | MinVersion: ver.version, |
| 3034 | MaxVersion: ver.version, |
| 3035 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3036 | flags: []string{"-require-any-client-certificate"}, |
| 3037 | shouldFail: true, |
| 3038 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3039 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3040 | }) |
| 3041 | |
| 3042 | if ver.version != VersionSSL30 { |
| 3043 | testCases = append(testCases, testCase{ |
| 3044 | testType: serverTest, |
| 3045 | name: "SkipClientCertificate-" + ver.name, |
| 3046 | config: Config{ |
| 3047 | MinVersion: ver.version, |
| 3048 | MaxVersion: ver.version, |
| 3049 | Bugs: ProtocolBugs{ |
| 3050 | SkipClientCertificate: true, |
| 3051 | }, |
| 3052 | }, |
| 3053 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3054 | flags: []string{"-verify-peer"}, |
| 3055 | shouldFail: true, |
| 3056 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3057 | }) |
| 3058 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3059 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3060 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3061 | // Client auth is only legal in certificate-based ciphers. |
| 3062 | testCases = append(testCases, testCase{ |
| 3063 | testType: clientTest, |
| 3064 | name: "ClientAuth-PSK", |
| 3065 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3066 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3067 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3068 | PreSharedKey: []byte("secret"), |
| 3069 | ClientAuth: RequireAnyClientCert, |
| 3070 | }, |
| 3071 | flags: []string{ |
| 3072 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3073 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3074 | "-psk", "secret", |
| 3075 | }, |
| 3076 | shouldFail: true, |
| 3077 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3078 | }) |
| 3079 | testCases = append(testCases, testCase{ |
| 3080 | testType: clientTest, |
| 3081 | name: "ClientAuth-ECDHE_PSK", |
| 3082 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3083 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3084 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3085 | PreSharedKey: []byte("secret"), |
| 3086 | ClientAuth: RequireAnyClientCert, |
| 3087 | }, |
| 3088 | flags: []string{ |
| 3089 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3090 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3091 | "-psk", "secret", |
| 3092 | }, |
| 3093 | shouldFail: true, |
| 3094 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3095 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3096 | |
| 3097 | // Regression test for a bug where the client CA list, if explicitly |
| 3098 | // set to NULL, was mis-encoded. |
| 3099 | testCases = append(testCases, testCase{ |
| 3100 | testType: serverTest, |
| 3101 | name: "Null-Client-CA-List", |
| 3102 | config: Config{ |
| 3103 | MaxVersion: VersionTLS12, |
| 3104 | Certificates: []Certificate{rsaCertificate}, |
| 3105 | }, |
| 3106 | flags: []string{ |
| 3107 | "-require-any-client-certificate", |
| 3108 | "-use-null-client-ca-list", |
| 3109 | }, |
| 3110 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3111 | } |
| 3112 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3113 | func addExtendedMasterSecretTests() { |
| 3114 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3115 | |
| 3116 | for _, with := range []bool{false, true} { |
| 3117 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3118 | if with { |
| 3119 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3120 | } |
| 3121 | |
| 3122 | for _, isClient := range []bool{false, true} { |
| 3123 | suffix := "-Server" |
| 3124 | testType := serverTest |
| 3125 | if isClient { |
| 3126 | suffix = "-Client" |
| 3127 | testType = clientTest |
| 3128 | } |
| 3129 | |
| 3130 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3131 | // In TLS 1.3, the extension is irrelevant and |
| 3132 | // always reports as enabled. |
| 3133 | var flags []string |
| 3134 | if with || ver.version >= VersionTLS13 { |
| 3135 | flags = []string{expectEMSFlag} |
| 3136 | } |
| 3137 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3138 | test := testCase{ |
| 3139 | testType: testType, |
| 3140 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3141 | config: Config{ |
| 3142 | MinVersion: ver.version, |
| 3143 | MaxVersion: ver.version, |
| 3144 | Bugs: ProtocolBugs{ |
| 3145 | NoExtendedMasterSecret: !with, |
| 3146 | RequireExtendedMasterSecret: with, |
| 3147 | }, |
| 3148 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3149 | flags: flags, |
| 3150 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3151 | } |
| 3152 | if test.shouldFail { |
| 3153 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3154 | } |
| 3155 | testCases = append(testCases, test) |
| 3156 | } |
| 3157 | } |
| 3158 | } |
| 3159 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3160 | for _, isClient := range []bool{false, true} { |
| 3161 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3162 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3163 | boolToWord := func(b bool) string { |
| 3164 | if b { |
| 3165 | return "Yes" |
| 3166 | } |
| 3167 | return "No" |
| 3168 | } |
| 3169 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3170 | if isClient { |
| 3171 | suffix += "Client" |
| 3172 | } else { |
| 3173 | suffix += "Server" |
| 3174 | } |
| 3175 | |
| 3176 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3177 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3178 | Bugs: ProtocolBugs{ |
| 3179 | RequireExtendedMasterSecret: true, |
| 3180 | }, |
| 3181 | } |
| 3182 | |
| 3183 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3184 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3185 | Bugs: ProtocolBugs{ |
| 3186 | NoExtendedMasterSecret: true, |
| 3187 | }, |
| 3188 | } |
| 3189 | |
| 3190 | test := testCase{ |
| 3191 | name: "ExtendedMasterSecret-" + suffix, |
| 3192 | resumeSession: true, |
| 3193 | } |
| 3194 | |
| 3195 | if !isClient { |
| 3196 | test.testType = serverTest |
| 3197 | } |
| 3198 | |
| 3199 | if supportedInFirstConnection { |
| 3200 | test.config = supportedConfig |
| 3201 | } else { |
| 3202 | test.config = noSupportConfig |
| 3203 | } |
| 3204 | |
| 3205 | if supportedInResumeConnection { |
| 3206 | test.resumeConfig = &supportedConfig |
| 3207 | } else { |
| 3208 | test.resumeConfig = &noSupportConfig |
| 3209 | } |
| 3210 | |
| 3211 | switch suffix { |
| 3212 | case "YesToYes-Client", "YesToYes-Server": |
| 3213 | // When a session is resumed, it should |
| 3214 | // still be aware that its master |
| 3215 | // secret was generated via EMS and |
| 3216 | // thus it's safe to use tls-unique. |
| 3217 | test.flags = []string{expectEMSFlag} |
| 3218 | case "NoToYes-Server": |
| 3219 | // If an original connection did not |
| 3220 | // contain EMS, but a resumption |
| 3221 | // handshake does, then a server should |
| 3222 | // not resume the session. |
| 3223 | test.expectResumeRejected = true |
| 3224 | case "YesToNo-Server": |
| 3225 | // Resuming an EMS session without the |
| 3226 | // EMS extension should cause the |
| 3227 | // server to abort the connection. |
| 3228 | test.shouldFail = true |
| 3229 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3230 | case "NoToYes-Client": |
| 3231 | // A client should abort a connection |
| 3232 | // where the server resumed a non-EMS |
| 3233 | // session but echoed the EMS |
| 3234 | // extension. |
| 3235 | test.shouldFail = true |
| 3236 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3237 | case "YesToNo-Client": |
| 3238 | // A client should abort a connection |
| 3239 | // where the server didn't echo EMS |
| 3240 | // when the session used it. |
| 3241 | test.shouldFail = true |
| 3242 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3243 | } |
| 3244 | |
| 3245 | testCases = append(testCases, test) |
| 3246 | } |
| 3247 | } |
| 3248 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3249 | |
| 3250 | // Switching EMS on renegotiation is forbidden. |
| 3251 | testCases = append(testCases, testCase{ |
| 3252 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3253 | config: Config{ |
| 3254 | MaxVersion: VersionTLS12, |
| 3255 | Bugs: ProtocolBugs{ |
| 3256 | NoExtendedMasterSecret: true, |
| 3257 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3258 | }, |
| 3259 | }, |
| 3260 | renegotiate: 1, |
| 3261 | flags: []string{ |
| 3262 | "-renegotiate-freely", |
| 3263 | "-expect-total-renegotiations", "1", |
| 3264 | }, |
| 3265 | }) |
| 3266 | |
| 3267 | testCases = append(testCases, testCase{ |
| 3268 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3269 | config: Config{ |
| 3270 | MaxVersion: VersionTLS12, |
| 3271 | Bugs: ProtocolBugs{ |
| 3272 | NoExtendedMasterSecret: true, |
| 3273 | }, |
| 3274 | }, |
| 3275 | renegotiate: 1, |
| 3276 | flags: []string{ |
| 3277 | "-renegotiate-freely", |
| 3278 | "-expect-total-renegotiations", "1", |
| 3279 | }, |
| 3280 | shouldFail: true, |
| 3281 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3282 | }) |
| 3283 | |
| 3284 | testCases = append(testCases, testCase{ |
| 3285 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3286 | config: Config{ |
| 3287 | MaxVersion: VersionTLS12, |
| 3288 | Bugs: ProtocolBugs{ |
| 3289 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3290 | }, |
| 3291 | }, |
| 3292 | renegotiate: 1, |
| 3293 | flags: []string{ |
| 3294 | "-renegotiate-freely", |
| 3295 | "-expect-total-renegotiations", "1", |
| 3296 | }, |
| 3297 | shouldFail: true, |
| 3298 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3299 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3300 | } |
| 3301 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3302 | type stateMachineTestConfig struct { |
| 3303 | protocol protocol |
| 3304 | async bool |
| 3305 | splitHandshake, packHandshakeFlight bool |
| 3306 | } |
| 3307 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3308 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3309 | // various conditions. Some of these are redundant with other tests, but they |
| 3310 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3311 | func addAllStateMachineCoverageTests() { |
| 3312 | for _, async := range []bool{false, true} { |
| 3313 | for _, protocol := range []protocol{tls, dtls} { |
| 3314 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3315 | protocol: protocol, |
| 3316 | async: async, |
| 3317 | }) |
| 3318 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3319 | protocol: protocol, |
| 3320 | async: async, |
| 3321 | splitHandshake: true, |
| 3322 | }) |
| 3323 | if protocol == tls { |
| 3324 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3325 | protocol: protocol, |
| 3326 | async: async, |
| 3327 | packHandshakeFlight: true, |
| 3328 | }) |
| 3329 | } |
| 3330 | } |
| 3331 | } |
| 3332 | } |
| 3333 | |
| 3334 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3335 | var tests []testCase |
| 3336 | |
| 3337 | // Basic handshake, with resumption. Client and server, |
| 3338 | // session ID and session ticket. |
| 3339 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3340 | name: "Basic-Client", |
| 3341 | config: Config{ |
| 3342 | MaxVersion: VersionTLS12, |
| 3343 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3344 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3345 | // Ensure session tickets are used, not session IDs. |
| 3346 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3347 | }) |
| 3348 | tests = append(tests, testCase{ |
| 3349 | name: "Basic-Client-RenewTicket", |
| 3350 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3351 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3352 | Bugs: ProtocolBugs{ |
| 3353 | RenewTicketOnResume: true, |
| 3354 | }, |
| 3355 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3356 | flags: []string{"-expect-ticket-renewal"}, |
| 3357 | resumeSession: true, |
| 3358 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3359 | }) |
| 3360 | tests = append(tests, testCase{ |
| 3361 | name: "Basic-Client-NoTicket", |
| 3362 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3363 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3364 | SessionTicketsDisabled: true, |
| 3365 | }, |
| 3366 | resumeSession: true, |
| 3367 | }) |
| 3368 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3369 | name: "Basic-Client-Implicit", |
| 3370 | config: Config{ |
| 3371 | MaxVersion: VersionTLS12, |
| 3372 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3373 | flags: []string{"-implicit-handshake"}, |
| 3374 | resumeSession: true, |
| 3375 | }) |
| 3376 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3377 | testType: serverTest, |
| 3378 | name: "Basic-Server", |
| 3379 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3380 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3381 | Bugs: ProtocolBugs{ |
| 3382 | RequireSessionTickets: true, |
| 3383 | }, |
| 3384 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3385 | resumeSession: true, |
| 3386 | }) |
| 3387 | tests = append(tests, testCase{ |
| 3388 | testType: serverTest, |
| 3389 | name: "Basic-Server-NoTickets", |
| 3390 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3391 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3392 | SessionTicketsDisabled: true, |
| 3393 | }, |
| 3394 | resumeSession: true, |
| 3395 | }) |
| 3396 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3397 | testType: serverTest, |
| 3398 | name: "Basic-Server-Implicit", |
| 3399 | config: Config{ |
| 3400 | MaxVersion: VersionTLS12, |
| 3401 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3402 | flags: []string{"-implicit-handshake"}, |
| 3403 | resumeSession: true, |
| 3404 | }) |
| 3405 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3406 | testType: serverTest, |
| 3407 | name: "Basic-Server-EarlyCallback", |
| 3408 | config: Config{ |
| 3409 | MaxVersion: VersionTLS12, |
| 3410 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3411 | flags: []string{"-use-early-callback"}, |
| 3412 | resumeSession: true, |
| 3413 | }) |
| 3414 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3415 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3416 | if config.protocol == tls { |
| 3417 | tests = append(tests, testCase{ |
| 3418 | name: "TLS13-1RTT-Client", |
| 3419 | config: Config{ |
| 3420 | MaxVersion: VersionTLS13, |
| 3421 | MinVersion: VersionTLS13, |
| 3422 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3423 | resumeSession: true, |
| 3424 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3425 | }) |
| 3426 | |
| 3427 | tests = append(tests, testCase{ |
| 3428 | testType: serverTest, |
| 3429 | name: "TLS13-1RTT-Server", |
| 3430 | config: Config{ |
| 3431 | MaxVersion: VersionTLS13, |
| 3432 | MinVersion: VersionTLS13, |
| 3433 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3434 | resumeSession: true, |
| 3435 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3436 | }) |
| 3437 | |
| 3438 | tests = append(tests, testCase{ |
| 3439 | name: "TLS13-HelloRetryRequest-Client", |
| 3440 | config: Config{ |
| 3441 | MaxVersion: VersionTLS13, |
| 3442 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3443 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3444 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3445 | CurvePreferences: []CurveID{CurveP384}, |
| 3446 | Bugs: ProtocolBugs{ |
| 3447 | ExpectMissingKeyShare: true, |
| 3448 | }, |
| 3449 | }, |
| 3450 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3451 | resumeSession: true, |
| 3452 | }) |
| 3453 | |
| 3454 | tests = append(tests, testCase{ |
| 3455 | testType: serverTest, |
| 3456 | name: "TLS13-HelloRetryRequest-Server", |
| 3457 | config: Config{ |
| 3458 | MaxVersion: VersionTLS13, |
| 3459 | MinVersion: VersionTLS13, |
| 3460 | // Require a HelloRetryRequest for every curve. |
| 3461 | DefaultCurves: []CurveID{}, |
| 3462 | }, |
| 3463 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3464 | resumeSession: true, |
| 3465 | }) |
| 3466 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3467 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3468 | // TLS client auth. |
| 3469 | tests = append(tests, testCase{ |
| 3470 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3471 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3472 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3473 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3474 | ClientAuth: RequestClientCert, |
| 3475 | }, |
| 3476 | }) |
| 3477 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3478 | testType: serverTest, |
| 3479 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3480 | config: Config{ |
| 3481 | MaxVersion: VersionTLS12, |
| 3482 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3483 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3484 | flags: []string{"-verify-peer"}, |
| 3485 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3486 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3487 | tests = append(tests, testCase{ |
| 3488 | testType: clientTest, |
| 3489 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3490 | config: Config{ |
| 3491 | MaxVersion: VersionSSL30, |
| 3492 | ClientAuth: RequestClientCert, |
| 3493 | }, |
| 3494 | }) |
| 3495 | tests = append(tests, testCase{ |
| 3496 | testType: serverTest, |
| 3497 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3498 | config: Config{ |
| 3499 | MaxVersion: VersionSSL30, |
| 3500 | }, |
| 3501 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3502 | flags: []string{"-verify-peer"}, |
| 3503 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3504 | tests = append(tests, testCase{ |
| 3505 | testType: clientTest, |
| 3506 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3507 | config: Config{ |
| 3508 | MaxVersion: VersionTLS13, |
| 3509 | ClientAuth: RequestClientCert, |
| 3510 | }, |
| 3511 | }) |
| 3512 | tests = append(tests, testCase{ |
| 3513 | testType: serverTest, |
| 3514 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3515 | config: Config{ |
| 3516 | MaxVersion: VersionTLS13, |
| 3517 | }, |
| 3518 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3519 | flags: []string{"-verify-peer"}, |
| 3520 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3521 | } |
| 3522 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3523 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3524 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3525 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3526 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3527 | ClientAuth: RequireAnyClientCert, |
| 3528 | }, |
| 3529 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3530 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3531 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3532 | }, |
| 3533 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3534 | tests = append(tests, testCase{ |
| 3535 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3536 | name: "ClientAuth-RSA-Client-TLS13", |
| 3537 | config: Config{ |
| 3538 | MaxVersion: VersionTLS13, |
| 3539 | ClientAuth: RequireAnyClientCert, |
| 3540 | }, |
| 3541 | flags: []string{ |
| 3542 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3543 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3544 | }, |
| 3545 | }) |
| 3546 | tests = append(tests, testCase{ |
| 3547 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3548 | name: "ClientAuth-ECDSA-Client", |
| 3549 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3550 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3551 | ClientAuth: RequireAnyClientCert, |
| 3552 | }, |
| 3553 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3554 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3555 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3556 | }, |
| 3557 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3558 | tests = append(tests, testCase{ |
| 3559 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3560 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3561 | config: Config{ |
| 3562 | MaxVersion: VersionTLS13, |
| 3563 | ClientAuth: RequireAnyClientCert, |
| 3564 | }, |
| 3565 | flags: []string{ |
| 3566 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3567 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3568 | }, |
| 3569 | }) |
| 3570 | tests = append(tests, testCase{ |
| 3571 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3572 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3573 | config: Config{ |
| 3574 | MaxVersion: VersionTLS12, |
| 3575 | ClientAuth: RequestClientCert, |
| 3576 | }, |
| 3577 | flags: []string{"-use-old-client-cert-callback"}, |
| 3578 | }) |
| 3579 | tests = append(tests, testCase{ |
| 3580 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3581 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3582 | config: Config{ |
| 3583 | MaxVersion: VersionTLS13, |
| 3584 | ClientAuth: RequestClientCert, |
| 3585 | }, |
| 3586 | flags: []string{"-use-old-client-cert-callback"}, |
| 3587 | }) |
| 3588 | tests = append(tests, testCase{ |
| 3589 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3590 | name: "ClientAuth-OldCallback", |
| 3591 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3592 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3593 | ClientAuth: RequireAnyClientCert, |
| 3594 | }, |
| 3595 | flags: []string{ |
| 3596 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3597 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3598 | "-use-old-client-cert-callback", |
| 3599 | }, |
| 3600 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3601 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3602 | testType: clientTest, |
| 3603 | name: "ClientAuth-OldCallback-TLS13", |
| 3604 | config: Config{ |
| 3605 | MaxVersion: VersionTLS13, |
| 3606 | ClientAuth: RequireAnyClientCert, |
| 3607 | }, |
| 3608 | flags: []string{ |
| 3609 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3610 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3611 | "-use-old-client-cert-callback", |
| 3612 | }, |
| 3613 | }) |
| 3614 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3615 | testType: serverTest, |
| 3616 | name: "ClientAuth-Server", |
| 3617 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3618 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3619 | Certificates: []Certificate{rsaCertificate}, |
| 3620 | }, |
| 3621 | flags: []string{"-require-any-client-certificate"}, |
| 3622 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3623 | tests = append(tests, testCase{ |
| 3624 | testType: serverTest, |
| 3625 | name: "ClientAuth-Server-TLS13", |
| 3626 | config: Config{ |
| 3627 | MaxVersion: VersionTLS13, |
| 3628 | Certificates: []Certificate{rsaCertificate}, |
| 3629 | }, |
| 3630 | flags: []string{"-require-any-client-certificate"}, |
| 3631 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3632 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3633 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3634 | tests = append(tests, testCase{ |
| 3635 | testType: serverTest, |
| 3636 | name: "Basic-Server-RSA", |
| 3637 | config: Config{ |
| 3638 | MaxVersion: VersionTLS12, |
| 3639 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3640 | }, |
| 3641 | flags: []string{ |
| 3642 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3643 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3644 | }, |
| 3645 | }) |
| 3646 | tests = append(tests, testCase{ |
| 3647 | testType: serverTest, |
| 3648 | name: "Basic-Server-ECDHE-RSA", |
| 3649 | config: Config{ |
| 3650 | MaxVersion: VersionTLS12, |
| 3651 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3652 | }, |
| 3653 | flags: []string{ |
| 3654 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3655 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3656 | }, |
| 3657 | }) |
| 3658 | tests = append(tests, testCase{ |
| 3659 | testType: serverTest, |
| 3660 | name: "Basic-Server-ECDHE-ECDSA", |
| 3661 | config: Config{ |
| 3662 | MaxVersion: VersionTLS12, |
| 3663 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3664 | }, |
| 3665 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3666 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3667 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3668 | }, |
| 3669 | }) |
| 3670 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3671 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3672 | tests = append(tests, testCase{ |
| 3673 | name: "SessionTicketsDisabled-Client", |
| 3674 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3675 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3676 | SessionTicketsDisabled: true, |
| 3677 | }, |
| 3678 | }) |
| 3679 | tests = append(tests, testCase{ |
| 3680 | testType: serverTest, |
| 3681 | name: "SessionTicketsDisabled-Server", |
| 3682 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3683 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3684 | SessionTicketsDisabled: true, |
| 3685 | }, |
| 3686 | }) |
| 3687 | |
| 3688 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3689 | // identity hint. |
| 3690 | tests = append(tests, testCase{ |
| 3691 | name: "EmptyPSKHint-Client", |
| 3692 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3693 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3694 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3695 | PreSharedKey: []byte("secret"), |
| 3696 | }, |
| 3697 | flags: []string{"-psk", "secret"}, |
| 3698 | }) |
| 3699 | tests = append(tests, testCase{ |
| 3700 | testType: serverTest, |
| 3701 | name: "EmptyPSKHint-Server", |
| 3702 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3703 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3704 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3705 | PreSharedKey: []byte("secret"), |
| 3706 | }, |
| 3707 | flags: []string{"-psk", "secret"}, |
| 3708 | }) |
| 3709 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3710 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3711 | tests = append(tests, testCase{ |
| 3712 | testType: clientTest, |
| 3713 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3714 | config: Config{ |
| 3715 | MaxVersion: VersionTLS12, |
| 3716 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3717 | flags: []string{ |
| 3718 | "-enable-ocsp-stapling", |
| 3719 | "-expect-ocsp-response", |
| 3720 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3721 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3722 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3723 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3724 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3725 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3726 | testType: serverTest, |
| 3727 | name: "OCSPStapling-Server", |
| 3728 | config: Config{ |
| 3729 | MaxVersion: VersionTLS12, |
| 3730 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3731 | expectedOCSPResponse: testOCSPResponse, |
| 3732 | flags: []string{ |
| 3733 | "-ocsp-response", |
| 3734 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3735 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3736 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3737 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3738 | tests = append(tests, testCase{ |
| 3739 | testType: clientTest, |
| 3740 | name: "OCSPStapling-Client-TLS13", |
| 3741 | config: Config{ |
| 3742 | MaxVersion: VersionTLS13, |
| 3743 | }, |
| 3744 | flags: []string{ |
| 3745 | "-enable-ocsp-stapling", |
| 3746 | "-expect-ocsp-response", |
| 3747 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3748 | "-verify-peer", |
| 3749 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3750 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3751 | }) |
| 3752 | tests = append(tests, testCase{ |
| 3753 | testType: serverTest, |
| 3754 | name: "OCSPStapling-Server-TLS13", |
| 3755 | config: Config{ |
| 3756 | MaxVersion: VersionTLS13, |
| 3757 | }, |
| 3758 | expectedOCSPResponse: testOCSPResponse, |
| 3759 | flags: []string{ |
| 3760 | "-ocsp-response", |
| 3761 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3762 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3763 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3764 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3765 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3766 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3767 | for _, vers := range tlsVersions { |
| 3768 | if config.protocol == dtls && !vers.hasDTLS { |
| 3769 | continue |
| 3770 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3771 | for _, testType := range []testType{clientTest, serverTest} { |
| 3772 | suffix := "-Client" |
| 3773 | if testType == serverTest { |
| 3774 | suffix = "-Server" |
| 3775 | } |
| 3776 | suffix += "-" + vers.name |
| 3777 | |
| 3778 | flag := "-verify-peer" |
| 3779 | if testType == serverTest { |
| 3780 | flag = "-require-any-client-certificate" |
| 3781 | } |
| 3782 | |
| 3783 | tests = append(tests, testCase{ |
| 3784 | testType: testType, |
| 3785 | name: "CertificateVerificationSucceed" + suffix, |
| 3786 | config: Config{ |
| 3787 | MaxVersion: vers.version, |
| 3788 | Certificates: []Certificate{rsaCertificate}, |
| 3789 | }, |
| 3790 | flags: []string{ |
| 3791 | flag, |
| 3792 | "-expect-verify-result", |
| 3793 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3794 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3795 | }) |
| 3796 | tests = append(tests, testCase{ |
| 3797 | testType: testType, |
| 3798 | name: "CertificateVerificationFail" + suffix, |
| 3799 | config: Config{ |
| 3800 | MaxVersion: vers.version, |
| 3801 | Certificates: []Certificate{rsaCertificate}, |
| 3802 | }, |
| 3803 | flags: []string{ |
| 3804 | flag, |
| 3805 | "-verify-fail", |
| 3806 | }, |
| 3807 | shouldFail: true, |
| 3808 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3809 | }) |
| 3810 | } |
| 3811 | |
| 3812 | // By default, the client is in a soft fail mode where the peer |
| 3813 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3814 | tests = append(tests, testCase{ |
| 3815 | testType: clientTest, |
| 3816 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3817 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3818 | MaxVersion: vers.version, |
| 3819 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3820 | }, |
| 3821 | flags: []string{ |
| 3822 | "-verify-fail", |
| 3823 | "-expect-verify-result", |
| 3824 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3825 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3826 | }) |
| 3827 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3828 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3829 | tests = append(tests, testCase{ |
| 3830 | name: "ShimSendAlert", |
| 3831 | flags: []string{"-send-alert"}, |
| 3832 | shimWritesFirst: true, |
| 3833 | shouldFail: true, |
| 3834 | expectedLocalError: "remote error: decompression failure", |
| 3835 | }) |
| 3836 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3837 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3838 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3839 | name: "Renegotiate-Client", |
| 3840 | config: Config{ |
| 3841 | MaxVersion: VersionTLS12, |
| 3842 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3843 | renegotiate: 1, |
| 3844 | flags: []string{ |
| 3845 | "-renegotiate-freely", |
| 3846 | "-expect-total-renegotiations", "1", |
| 3847 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3848 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3849 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3850 | tests = append(tests, testCase{ |
| 3851 | name: "SendHalfHelloRequest", |
| 3852 | config: Config{ |
| 3853 | MaxVersion: VersionTLS12, |
| 3854 | Bugs: ProtocolBugs{ |
| 3855 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3856 | }, |
| 3857 | }, |
| 3858 | sendHalfHelloRequest: true, |
| 3859 | flags: []string{"-renegotiate-ignore"}, |
| 3860 | shouldFail: true, |
| 3861 | expectedError: ":UNEXPECTED_RECORD:", |
| 3862 | }) |
| 3863 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3864 | // NPN on client and server; results in post-handshake message. |
| 3865 | tests = append(tests, testCase{ |
| 3866 | name: "NPN-Client", |
| 3867 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3868 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3869 | NextProtos: []string{"foo"}, |
| 3870 | }, |
| 3871 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3872 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3873 | expectedNextProto: "foo", |
| 3874 | expectedNextProtoType: npn, |
| 3875 | }) |
| 3876 | tests = append(tests, testCase{ |
| 3877 | testType: serverTest, |
| 3878 | name: "NPN-Server", |
| 3879 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3880 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3881 | NextProtos: []string{"bar"}, |
| 3882 | }, |
| 3883 | flags: []string{ |
| 3884 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3885 | "-expect-next-proto", "bar", |
| 3886 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3887 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3888 | expectedNextProto: "bar", |
| 3889 | expectedNextProtoType: npn, |
| 3890 | }) |
| 3891 | |
| 3892 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3893 | |
| 3894 | // Client does False Start and negotiates NPN. |
| 3895 | tests = append(tests, testCase{ |
| 3896 | name: "FalseStart", |
| 3897 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3898 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3899 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3900 | NextProtos: []string{"foo"}, |
| 3901 | Bugs: ProtocolBugs{ |
| 3902 | ExpectFalseStart: true, |
| 3903 | }, |
| 3904 | }, |
| 3905 | flags: []string{ |
| 3906 | "-false-start", |
| 3907 | "-select-next-proto", "foo", |
| 3908 | }, |
| 3909 | shimWritesFirst: true, |
| 3910 | resumeSession: true, |
| 3911 | }) |
| 3912 | |
| 3913 | // Client does False Start and negotiates ALPN. |
| 3914 | tests = append(tests, testCase{ |
| 3915 | name: "FalseStart-ALPN", |
| 3916 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3917 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3918 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3919 | NextProtos: []string{"foo"}, |
| 3920 | Bugs: ProtocolBugs{ |
| 3921 | ExpectFalseStart: true, |
| 3922 | }, |
| 3923 | }, |
| 3924 | flags: []string{ |
| 3925 | "-false-start", |
| 3926 | "-advertise-alpn", "\x03foo", |
| 3927 | }, |
| 3928 | shimWritesFirst: true, |
| 3929 | resumeSession: true, |
| 3930 | }) |
| 3931 | |
| 3932 | // Client does False Start but doesn't explicitly call |
| 3933 | // SSL_connect. |
| 3934 | tests = append(tests, testCase{ |
| 3935 | name: "FalseStart-Implicit", |
| 3936 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3937 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3938 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3939 | NextProtos: []string{"foo"}, |
| 3940 | }, |
| 3941 | flags: []string{ |
| 3942 | "-implicit-handshake", |
| 3943 | "-false-start", |
| 3944 | "-advertise-alpn", "\x03foo", |
| 3945 | }, |
| 3946 | }) |
| 3947 | |
| 3948 | // False Start without session tickets. |
| 3949 | tests = append(tests, testCase{ |
| 3950 | name: "FalseStart-SessionTicketsDisabled", |
| 3951 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3952 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3953 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3954 | NextProtos: []string{"foo"}, |
| 3955 | SessionTicketsDisabled: true, |
| 3956 | Bugs: ProtocolBugs{ |
| 3957 | ExpectFalseStart: true, |
| 3958 | }, |
| 3959 | }, |
| 3960 | flags: []string{ |
| 3961 | "-false-start", |
| 3962 | "-select-next-proto", "foo", |
| 3963 | }, |
| 3964 | shimWritesFirst: true, |
| 3965 | }) |
| 3966 | |
| 3967 | // Server parses a V2ClientHello. |
| 3968 | tests = append(tests, testCase{ |
| 3969 | testType: serverTest, |
| 3970 | name: "SendV2ClientHello", |
| 3971 | config: Config{ |
| 3972 | // Choose a cipher suite that does not involve |
| 3973 | // elliptic curves, so no extensions are |
| 3974 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3975 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 3976 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3977 | Bugs: ProtocolBugs{ |
| 3978 | SendV2ClientHello: true, |
| 3979 | }, |
| 3980 | }, |
| 3981 | }) |
| 3982 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 3983 | // Test Channel ID |
| 3984 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 3985 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 3986 | continue |
| 3987 | } |
| 3988 | // Client sends a Channel ID. |
| 3989 | tests = append(tests, testCase{ |
| 3990 | name: "ChannelID-Client-" + ver.name, |
| 3991 | config: Config{ |
| 3992 | MaxVersion: ver.version, |
| 3993 | RequestChannelID: true, |
| 3994 | }, |
| 3995 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 3996 | resumeSession: true, |
| 3997 | expectChannelID: true, |
| 3998 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3999 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4000 | // Server accepts a Channel ID. |
| 4001 | tests = append(tests, testCase{ |
| 4002 | testType: serverTest, |
| 4003 | name: "ChannelID-Server-" + ver.name, |
| 4004 | config: Config{ |
| 4005 | MaxVersion: ver.version, |
| 4006 | ChannelID: channelIDKey, |
| 4007 | }, |
| 4008 | flags: []string{ |
| 4009 | "-expect-channel-id", |
| 4010 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4011 | }, |
| 4012 | resumeSession: true, |
| 4013 | expectChannelID: true, |
| 4014 | }) |
| 4015 | |
| 4016 | tests = append(tests, testCase{ |
| 4017 | testType: serverTest, |
| 4018 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4019 | config: Config{ |
| 4020 | MaxVersion: ver.version, |
| 4021 | ChannelID: channelIDKey, |
| 4022 | Bugs: ProtocolBugs{ |
| 4023 | InvalidChannelIDSignature: true, |
| 4024 | }, |
| 4025 | }, |
| 4026 | flags: []string{"-enable-channel-id"}, |
| 4027 | shouldFail: true, |
| 4028 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4029 | }) |
| 4030 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4031 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4032 | // Channel ID and NPN at the same time, to ensure their relative |
| 4033 | // ordering is correct. |
| 4034 | tests = append(tests, testCase{ |
| 4035 | name: "ChannelID-NPN-Client", |
| 4036 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4037 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4038 | RequestChannelID: true, |
| 4039 | NextProtos: []string{"foo"}, |
| 4040 | }, |
| 4041 | flags: []string{ |
| 4042 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4043 | "-select-next-proto", "foo", |
| 4044 | }, |
| 4045 | resumeSession: true, |
| 4046 | expectChannelID: true, |
| 4047 | expectedNextProto: "foo", |
| 4048 | expectedNextProtoType: npn, |
| 4049 | }) |
| 4050 | tests = append(tests, testCase{ |
| 4051 | testType: serverTest, |
| 4052 | name: "ChannelID-NPN-Server", |
| 4053 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4054 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4055 | ChannelID: channelIDKey, |
| 4056 | NextProtos: []string{"bar"}, |
| 4057 | }, |
| 4058 | flags: []string{ |
| 4059 | "-expect-channel-id", |
| 4060 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4061 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4062 | "-expect-next-proto", "bar", |
| 4063 | }, |
| 4064 | resumeSession: true, |
| 4065 | expectChannelID: true, |
| 4066 | expectedNextProto: "bar", |
| 4067 | expectedNextProtoType: npn, |
| 4068 | }) |
| 4069 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4070 | // Bidirectional shutdown with the runner initiating. |
| 4071 | tests = append(tests, testCase{ |
| 4072 | name: "Shutdown-Runner", |
| 4073 | config: Config{ |
| 4074 | Bugs: ProtocolBugs{ |
| 4075 | ExpectCloseNotify: true, |
| 4076 | }, |
| 4077 | }, |
| 4078 | flags: []string{"-check-close-notify"}, |
| 4079 | }) |
| 4080 | |
| 4081 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4082 | // in the meantime, sends garbage before the close_notify which |
| 4083 | // the shim must ignore. |
| 4084 | tests = append(tests, testCase{ |
| 4085 | name: "Shutdown-Shim", |
| 4086 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4087 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4088 | Bugs: ProtocolBugs{ |
| 4089 | ExpectCloseNotify: true, |
| 4090 | }, |
| 4091 | }, |
| 4092 | shimShutsDown: true, |
| 4093 | sendEmptyRecords: 1, |
| 4094 | sendWarningAlerts: 1, |
| 4095 | flags: []string{"-check-close-notify"}, |
| 4096 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4097 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4098 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4099 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4100 | tests = append(tests, testCase{ |
| 4101 | name: "SkipHelloVerifyRequest", |
| 4102 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4103 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4104 | Bugs: ProtocolBugs{ |
| 4105 | SkipHelloVerifyRequest: true, |
| 4106 | }, |
| 4107 | }, |
| 4108 | }) |
| 4109 | } |
| 4110 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4111 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4112 | test.protocol = config.protocol |
| 4113 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4114 | test.name += "-DTLS" |
| 4115 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4116 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4117 | test.name += "-Async" |
| 4118 | test.flags = append(test.flags, "-async") |
| 4119 | } else { |
| 4120 | test.name += "-Sync" |
| 4121 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4122 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4123 | test.name += "-SplitHandshakeRecords" |
| 4124 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4125 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4126 | test.config.Bugs.MaxPacketLength = 256 |
| 4127 | test.flags = append(test.flags, "-mtu", "256") |
| 4128 | } |
| 4129 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4130 | if config.packHandshakeFlight { |
| 4131 | test.name += "-PackHandshakeFlight" |
| 4132 | test.config.Bugs.PackHandshakeFlight = true |
| 4133 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4134 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4135 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4136 | } |
| 4137 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4138 | func addDDoSCallbackTests() { |
| 4139 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4140 | for _, resume := range []bool{false, true} { |
| 4141 | suffix := "Resume" |
| 4142 | if resume { |
| 4143 | suffix = "No" + suffix |
| 4144 | } |
| 4145 | |
| 4146 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4147 | testType: serverTest, |
| 4148 | name: "Server-DDoS-OK-" + suffix, |
| 4149 | config: Config{ |
| 4150 | MaxVersion: VersionTLS12, |
| 4151 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4152 | flags: []string{"-install-ddos-callback"}, |
| 4153 | resumeSession: resume, |
| 4154 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4155 | testCases = append(testCases, testCase{ |
| 4156 | testType: serverTest, |
| 4157 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4158 | config: Config{ |
| 4159 | MaxVersion: VersionTLS13, |
| 4160 | }, |
| 4161 | flags: []string{"-install-ddos-callback"}, |
| 4162 | resumeSession: resume, |
| 4163 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4164 | |
| 4165 | failFlag := "-fail-ddos-callback" |
| 4166 | if resume { |
| 4167 | failFlag = "-fail-second-ddos-callback" |
| 4168 | } |
| 4169 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4170 | testType: serverTest, |
| 4171 | name: "Server-DDoS-Reject-" + suffix, |
| 4172 | config: Config{ |
| 4173 | MaxVersion: VersionTLS12, |
| 4174 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4175 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4176 | resumeSession: resume, |
| 4177 | shouldFail: true, |
| 4178 | expectedError: ":CONNECTION_REJECTED:", |
| 4179 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4180 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4181 | testCases = append(testCases, testCase{ |
| 4182 | testType: serverTest, |
| 4183 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4184 | config: Config{ |
| 4185 | MaxVersion: VersionTLS13, |
| 4186 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4187 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4188 | resumeSession: resume, |
| 4189 | shouldFail: true, |
| 4190 | expectedError: ":CONNECTION_REJECTED:", |
| 4191 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4192 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4193 | } |
| 4194 | } |
| 4195 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4196 | func addVersionNegotiationTests() { |
| 4197 | for i, shimVers := range tlsVersions { |
| 4198 | // Assemble flags to disable all newer versions on the shim. |
| 4199 | var flags []string |
| 4200 | for _, vers := range tlsVersions[i+1:] { |
| 4201 | flags = append(flags, vers.flag) |
| 4202 | } |
| 4203 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4204 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4205 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4206 | protocols := []protocol{tls} |
| 4207 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4208 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4209 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4210 | for _, protocol := range protocols { |
| 4211 | expectedVersion := shimVers.version |
| 4212 | if runnerVers.version < shimVers.version { |
| 4213 | expectedVersion = runnerVers.version |
| 4214 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4215 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4216 | suffix := shimVers.name + "-" + runnerVers.name |
| 4217 | if protocol == dtls { |
| 4218 | suffix += "-DTLS" |
| 4219 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4220 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4221 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4222 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4223 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4224 | clientVers := shimVers.version |
| 4225 | if clientVers > VersionTLS10 { |
| 4226 | clientVers = VersionTLS10 |
| 4227 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4228 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4229 | serverVers := expectedVersion |
| 4230 | if expectedVersion >= VersionTLS13 { |
| 4231 | serverVers = VersionTLS10 |
| 4232 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4233 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4234 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4235 | testCases = append(testCases, testCase{ |
| 4236 | protocol: protocol, |
| 4237 | testType: clientTest, |
| 4238 | name: "VersionNegotiation-Client-" + suffix, |
| 4239 | config: Config{ |
| 4240 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4241 | Bugs: ProtocolBugs{ |
| 4242 | ExpectInitialRecordVersion: clientVers, |
| 4243 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4244 | }, |
| 4245 | flags: flags, |
| 4246 | expectedVersion: expectedVersion, |
| 4247 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4248 | testCases = append(testCases, testCase{ |
| 4249 | protocol: protocol, |
| 4250 | testType: clientTest, |
| 4251 | name: "VersionNegotiation-Client2-" + suffix, |
| 4252 | config: Config{ |
| 4253 | MaxVersion: runnerVers.version, |
| 4254 | Bugs: ProtocolBugs{ |
| 4255 | ExpectInitialRecordVersion: clientVers, |
| 4256 | }, |
| 4257 | }, |
| 4258 | flags: []string{"-max-version", shimVersFlag}, |
| 4259 | expectedVersion: expectedVersion, |
| 4260 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4261 | |
| 4262 | testCases = append(testCases, testCase{ |
| 4263 | protocol: protocol, |
| 4264 | testType: serverTest, |
| 4265 | name: "VersionNegotiation-Server-" + suffix, |
| 4266 | config: Config{ |
| 4267 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4268 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4269 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4270 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4271 | }, |
| 4272 | flags: flags, |
| 4273 | expectedVersion: expectedVersion, |
| 4274 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4275 | testCases = append(testCases, testCase{ |
| 4276 | protocol: protocol, |
| 4277 | testType: serverTest, |
| 4278 | name: "VersionNegotiation-Server2-" + suffix, |
| 4279 | config: Config{ |
| 4280 | MaxVersion: runnerVers.version, |
| 4281 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4282 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4283 | }, |
| 4284 | }, |
| 4285 | flags: []string{"-max-version", shimVersFlag}, |
| 4286 | expectedVersion: expectedVersion, |
| 4287 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4288 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4289 | } |
| 4290 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4291 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4292 | // Test the version extension at all versions. |
| 4293 | for _, vers := range tlsVersions { |
| 4294 | protocols := []protocol{tls} |
| 4295 | if vers.hasDTLS { |
| 4296 | protocols = append(protocols, dtls) |
| 4297 | } |
| 4298 | for _, protocol := range protocols { |
| 4299 | suffix := vers.name |
| 4300 | if protocol == dtls { |
| 4301 | suffix += "-DTLS" |
| 4302 | } |
| 4303 | |
| 4304 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4305 | testCases = append(testCases, testCase{ |
| 4306 | protocol: protocol, |
| 4307 | testType: serverTest, |
| 4308 | name: "VersionNegotiationExtension-" + suffix, |
| 4309 | config: Config{ |
| 4310 | Bugs: ProtocolBugs{ |
| 4311 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4312 | }, |
| 4313 | }, |
| 4314 | expectedVersion: vers.version, |
| 4315 | }) |
| 4316 | } |
| 4317 | |
| 4318 | } |
| 4319 | |
| 4320 | // If all versions are unknown, negotiation fails. |
| 4321 | testCases = append(testCases, testCase{ |
| 4322 | testType: serverTest, |
| 4323 | name: "NoSupportedVersions", |
| 4324 | config: Config{ |
| 4325 | Bugs: ProtocolBugs{ |
| 4326 | SendSupportedVersions: []uint16{0x1111}, |
| 4327 | }, |
| 4328 | }, |
| 4329 | shouldFail: true, |
| 4330 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4331 | }) |
| 4332 | testCases = append(testCases, testCase{ |
| 4333 | protocol: dtls, |
| 4334 | testType: serverTest, |
| 4335 | name: "NoSupportedVersions-DTLS", |
| 4336 | config: Config{ |
| 4337 | Bugs: ProtocolBugs{ |
| 4338 | SendSupportedVersions: []uint16{0x1111}, |
| 4339 | }, |
| 4340 | }, |
| 4341 | shouldFail: true, |
| 4342 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4343 | }) |
| 4344 | |
| 4345 | testCases = append(testCases, testCase{ |
| 4346 | testType: serverTest, |
| 4347 | name: "ClientHelloVersionTooHigh", |
| 4348 | config: Config{ |
| 4349 | MaxVersion: VersionTLS13, |
| 4350 | Bugs: ProtocolBugs{ |
| 4351 | SendClientVersion: 0x0304, |
| 4352 | OmitSupportedVersions: true, |
| 4353 | }, |
| 4354 | }, |
| 4355 | expectedVersion: VersionTLS12, |
| 4356 | }) |
| 4357 | |
| 4358 | testCases = append(testCases, testCase{ |
| 4359 | testType: serverTest, |
| 4360 | name: "ConflictingVersionNegotiation", |
| 4361 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4362 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4363 | SendClientVersion: VersionTLS12, |
| 4364 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4365 | }, |
| 4366 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4367 | // The extension takes precedence over the ClientHello version. |
| 4368 | expectedVersion: VersionTLS11, |
| 4369 | }) |
| 4370 | |
| 4371 | testCases = append(testCases, testCase{ |
| 4372 | testType: serverTest, |
| 4373 | name: "ConflictingVersionNegotiation-2", |
| 4374 | config: Config{ |
| 4375 | Bugs: ProtocolBugs{ |
| 4376 | SendClientVersion: VersionTLS11, |
| 4377 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4378 | }, |
| 4379 | }, |
| 4380 | // The extension takes precedence over the ClientHello version. |
| 4381 | expectedVersion: VersionTLS12, |
| 4382 | }) |
| 4383 | |
| 4384 | testCases = append(testCases, testCase{ |
| 4385 | testType: serverTest, |
| 4386 | name: "RejectFinalTLS13", |
| 4387 | config: Config{ |
| 4388 | Bugs: ProtocolBugs{ |
| 4389 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4390 | }, |
| 4391 | }, |
| 4392 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4393 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4394 | expectedVersion: VersionTLS12, |
| 4395 | }) |
| 4396 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4397 | // Test that the maximum version is selected regardless of the |
| 4398 | // client-sent order. |
| 4399 | testCases = append(testCases, testCase{ |
| 4400 | testType: serverTest, |
| 4401 | name: "IgnoreClientVersionOrder", |
| 4402 | config: Config{ |
| 4403 | Bugs: ProtocolBugs{ |
| 4404 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4405 | }, |
| 4406 | }, |
| 4407 | expectedVersion: VersionTLS13, |
| 4408 | }) |
| 4409 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4410 | // Test for version tolerance. |
| 4411 | testCases = append(testCases, testCase{ |
| 4412 | testType: serverTest, |
| 4413 | name: "MinorVersionTolerance", |
| 4414 | config: Config{ |
| 4415 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4416 | SendClientVersion: 0x03ff, |
| 4417 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4418 | }, |
| 4419 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4420 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4421 | }) |
| 4422 | testCases = append(testCases, testCase{ |
| 4423 | testType: serverTest, |
| 4424 | name: "MajorVersionTolerance", |
| 4425 | config: Config{ |
| 4426 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4427 | SendClientVersion: 0x0400, |
| 4428 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4429 | }, |
| 4430 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4431 | // TLS 1.3 must be negotiated with the supported_versions |
| 4432 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4433 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4434 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4435 | testCases = append(testCases, testCase{ |
| 4436 | testType: serverTest, |
| 4437 | name: "VersionTolerance-TLS13", |
| 4438 | config: Config{ |
| 4439 | Bugs: ProtocolBugs{ |
| 4440 | // Although TLS 1.3 does not use |
| 4441 | // ClientHello.version, it still tolerates high |
| 4442 | // values there. |
| 4443 | SendClientVersion: 0x0400, |
| 4444 | }, |
| 4445 | }, |
| 4446 | expectedVersion: VersionTLS13, |
| 4447 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4448 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4449 | testCases = append(testCases, testCase{ |
| 4450 | protocol: dtls, |
| 4451 | testType: serverTest, |
| 4452 | name: "MinorVersionTolerance-DTLS", |
| 4453 | config: Config{ |
| 4454 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4455 | SendClientVersion: 0xfe00, |
| 4456 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4457 | }, |
| 4458 | }, |
| 4459 | expectedVersion: VersionTLS12, |
| 4460 | }) |
| 4461 | testCases = append(testCases, testCase{ |
| 4462 | protocol: dtls, |
| 4463 | testType: serverTest, |
| 4464 | name: "MajorVersionTolerance-DTLS", |
| 4465 | config: Config{ |
| 4466 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4467 | SendClientVersion: 0xfdff, |
| 4468 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4469 | }, |
| 4470 | }, |
| 4471 | expectedVersion: VersionTLS12, |
| 4472 | }) |
| 4473 | |
| 4474 | // Test that versions below 3.0 are rejected. |
| 4475 | testCases = append(testCases, testCase{ |
| 4476 | testType: serverTest, |
| 4477 | name: "VersionTooLow", |
| 4478 | config: Config{ |
| 4479 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4480 | SendClientVersion: 0x0200, |
| 4481 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4482 | }, |
| 4483 | }, |
| 4484 | shouldFail: true, |
| 4485 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4486 | }) |
| 4487 | testCases = append(testCases, testCase{ |
| 4488 | protocol: dtls, |
| 4489 | testType: serverTest, |
| 4490 | name: "VersionTooLow-DTLS", |
| 4491 | config: Config{ |
| 4492 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4493 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4494 | }, |
| 4495 | }, |
| 4496 | shouldFail: true, |
| 4497 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4498 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4499 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4500 | testCases = append(testCases, testCase{ |
| 4501 | name: "ServerBogusVersion", |
| 4502 | config: Config{ |
| 4503 | Bugs: ProtocolBugs{ |
| 4504 | SendServerHelloVersion: 0x1234, |
| 4505 | }, |
| 4506 | }, |
| 4507 | shouldFail: true, |
| 4508 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4509 | }) |
| 4510 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4511 | // Test TLS 1.3's downgrade signal. |
| 4512 | testCases = append(testCases, testCase{ |
| 4513 | name: "Downgrade-TLS12-Client", |
| 4514 | config: Config{ |
| 4515 | Bugs: ProtocolBugs{ |
| 4516 | NegotiateVersion: VersionTLS12, |
| 4517 | }, |
| 4518 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4519 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4520 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4521 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4522 | }) |
| 4523 | testCases = append(testCases, testCase{ |
| 4524 | testType: serverTest, |
| 4525 | name: "Downgrade-TLS12-Server", |
| 4526 | config: Config{ |
| 4527 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4528 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4529 | }, |
| 4530 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4531 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4532 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4533 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4534 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4535 | } |
| 4536 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4537 | func addMinimumVersionTests() { |
| 4538 | for i, shimVers := range tlsVersions { |
| 4539 | // Assemble flags to disable all older versions on the shim. |
| 4540 | var flags []string |
| 4541 | for _, vers := range tlsVersions[:i] { |
| 4542 | flags = append(flags, vers.flag) |
| 4543 | } |
| 4544 | |
| 4545 | for _, runnerVers := range tlsVersions { |
| 4546 | protocols := []protocol{tls} |
| 4547 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4548 | protocols = append(protocols, dtls) |
| 4549 | } |
| 4550 | for _, protocol := range protocols { |
| 4551 | suffix := shimVers.name + "-" + runnerVers.name |
| 4552 | if protocol == dtls { |
| 4553 | suffix += "-DTLS" |
| 4554 | } |
| 4555 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4556 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4557 | var expectedVersion uint16 |
| 4558 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4559 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4560 | if runnerVers.version >= shimVers.version { |
| 4561 | expectedVersion = runnerVers.version |
| 4562 | } else { |
| 4563 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4564 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4565 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4566 | } |
| 4567 | |
| 4568 | testCases = append(testCases, testCase{ |
| 4569 | protocol: protocol, |
| 4570 | testType: clientTest, |
| 4571 | name: "MinimumVersion-Client-" + suffix, |
| 4572 | config: Config{ |
| 4573 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4574 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4575 | // Ensure the server does not decline to |
| 4576 | // select a version (versions extension) or |
| 4577 | // cipher (some ciphers depend on versions). |
| 4578 | NegotiateVersion: runnerVers.version, |
| 4579 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4580 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4581 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4582 | flags: flags, |
| 4583 | expectedVersion: expectedVersion, |
| 4584 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4585 | expectedError: expectedError, |
| 4586 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4587 | }) |
| 4588 | testCases = append(testCases, testCase{ |
| 4589 | protocol: protocol, |
| 4590 | testType: clientTest, |
| 4591 | name: "MinimumVersion-Client2-" + suffix, |
| 4592 | config: Config{ |
| 4593 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4594 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4595 | // Ensure the server does not decline to |
| 4596 | // select a version (versions extension) or |
| 4597 | // cipher (some ciphers depend on versions). |
| 4598 | NegotiateVersion: runnerVers.version, |
| 4599 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4600 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4601 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4602 | flags: []string{"-min-version", shimVersFlag}, |
| 4603 | expectedVersion: expectedVersion, |
| 4604 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4605 | expectedError: expectedError, |
| 4606 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4607 | }) |
| 4608 | |
| 4609 | testCases = append(testCases, testCase{ |
| 4610 | protocol: protocol, |
| 4611 | testType: serverTest, |
| 4612 | name: "MinimumVersion-Server-" + suffix, |
| 4613 | config: Config{ |
| 4614 | MaxVersion: runnerVers.version, |
| 4615 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4616 | flags: flags, |
| 4617 | expectedVersion: expectedVersion, |
| 4618 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4619 | expectedError: expectedError, |
| 4620 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4621 | }) |
| 4622 | testCases = append(testCases, testCase{ |
| 4623 | protocol: protocol, |
| 4624 | testType: serverTest, |
| 4625 | name: "MinimumVersion-Server2-" + suffix, |
| 4626 | config: Config{ |
| 4627 | MaxVersion: runnerVers.version, |
| 4628 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4629 | flags: []string{"-min-version", shimVersFlag}, |
| 4630 | expectedVersion: expectedVersion, |
| 4631 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4632 | expectedError: expectedError, |
| 4633 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4634 | }) |
| 4635 | } |
| 4636 | } |
| 4637 | } |
| 4638 | } |
| 4639 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4640 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4641 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4642 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4643 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4644 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4645 | // Repeat extensions tests all versions except SSL 3.0. |
| 4646 | for _, ver := range tlsVersions { |
| 4647 | if ver.version == VersionSSL30 { |
| 4648 | continue |
| 4649 | } |
| 4650 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4651 | // Test that duplicate extensions are rejected. |
| 4652 | testCases = append(testCases, testCase{ |
| 4653 | testType: clientTest, |
| 4654 | name: "DuplicateExtensionClient-" + ver.name, |
| 4655 | config: Config{ |
| 4656 | MaxVersion: ver.version, |
| 4657 | Bugs: ProtocolBugs{ |
| 4658 | DuplicateExtension: true, |
| 4659 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4660 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4661 | shouldFail: true, |
| 4662 | expectedLocalError: "remote error: error decoding message", |
| 4663 | }) |
| 4664 | testCases = append(testCases, testCase{ |
| 4665 | testType: serverTest, |
| 4666 | name: "DuplicateExtensionServer-" + ver.name, |
| 4667 | config: Config{ |
| 4668 | MaxVersion: ver.version, |
| 4669 | Bugs: ProtocolBugs{ |
| 4670 | DuplicateExtension: true, |
| 4671 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4672 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4673 | shouldFail: true, |
| 4674 | expectedLocalError: "remote error: error decoding message", |
| 4675 | }) |
| 4676 | |
| 4677 | // Test SNI. |
| 4678 | testCases = append(testCases, testCase{ |
| 4679 | testType: clientTest, |
| 4680 | name: "ServerNameExtensionClient-" + ver.name, |
| 4681 | config: Config{ |
| 4682 | MaxVersion: ver.version, |
| 4683 | Bugs: ProtocolBugs{ |
| 4684 | ExpectServerName: "example.com", |
| 4685 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4686 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4687 | flags: []string{"-host-name", "example.com"}, |
| 4688 | }) |
| 4689 | testCases = append(testCases, testCase{ |
| 4690 | testType: clientTest, |
| 4691 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4692 | config: Config{ |
| 4693 | MaxVersion: ver.version, |
| 4694 | Bugs: ProtocolBugs{ |
| 4695 | ExpectServerName: "mismatch.com", |
| 4696 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4697 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4698 | flags: []string{"-host-name", "example.com"}, |
| 4699 | shouldFail: true, |
| 4700 | expectedLocalError: "tls: unexpected server name", |
| 4701 | }) |
| 4702 | testCases = append(testCases, testCase{ |
| 4703 | testType: clientTest, |
| 4704 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4705 | config: Config{ |
| 4706 | MaxVersion: ver.version, |
| 4707 | Bugs: ProtocolBugs{ |
| 4708 | ExpectServerName: "missing.com", |
| 4709 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4710 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4711 | shouldFail: true, |
| 4712 | expectedLocalError: "tls: unexpected server name", |
| 4713 | }) |
| 4714 | testCases = append(testCases, testCase{ |
| 4715 | testType: serverTest, |
| 4716 | name: "ServerNameExtensionServer-" + ver.name, |
| 4717 | config: Config{ |
| 4718 | MaxVersion: ver.version, |
| 4719 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4720 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4721 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4722 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4723 | }) |
| 4724 | |
| 4725 | // Test ALPN. |
| 4726 | testCases = append(testCases, testCase{ |
| 4727 | testType: clientTest, |
| 4728 | name: "ALPNClient-" + ver.name, |
| 4729 | config: Config{ |
| 4730 | MaxVersion: ver.version, |
| 4731 | NextProtos: []string{"foo"}, |
| 4732 | }, |
| 4733 | flags: []string{ |
| 4734 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4735 | "-expect-alpn", "foo", |
| 4736 | }, |
| 4737 | expectedNextProto: "foo", |
| 4738 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4739 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4740 | }) |
| 4741 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4742 | testType: clientTest, |
| 4743 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4744 | config: Config{ |
| 4745 | MaxVersion: ver.version, |
| 4746 | Bugs: ProtocolBugs{ |
| 4747 | SendALPN: "baz", |
| 4748 | }, |
| 4749 | }, |
| 4750 | flags: []string{ |
| 4751 | "-advertise-alpn", "\x03foo\x03bar", |
| 4752 | }, |
| 4753 | shouldFail: true, |
| 4754 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4755 | expectedLocalError: "remote error: illegal parameter", |
| 4756 | }) |
| 4757 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4758 | testType: serverTest, |
| 4759 | name: "ALPNServer-" + ver.name, |
| 4760 | config: Config{ |
| 4761 | MaxVersion: ver.version, |
| 4762 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4763 | }, |
| 4764 | flags: []string{ |
| 4765 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4766 | "-select-alpn", "foo", |
| 4767 | }, |
| 4768 | expectedNextProto: "foo", |
| 4769 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4770 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4771 | }) |
| 4772 | testCases = append(testCases, testCase{ |
| 4773 | testType: serverTest, |
| 4774 | name: "ALPNServer-Decline-" + ver.name, |
| 4775 | config: Config{ |
| 4776 | MaxVersion: ver.version, |
| 4777 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4778 | }, |
| 4779 | flags: []string{"-decline-alpn"}, |
| 4780 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4781 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4782 | }) |
| 4783 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4784 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4785 | // called once. |
| 4786 | testCases = append(testCases, testCase{ |
| 4787 | testType: serverTest, |
| 4788 | name: "ALPNServer-Async-" + ver.name, |
| 4789 | config: Config{ |
| 4790 | MaxVersion: ver.version, |
| 4791 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 4792 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 4793 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4794 | }, |
| 4795 | flags: []string{ |
| 4796 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4797 | "-select-alpn", "foo", |
| 4798 | "-async", |
| 4799 | }, |
| 4800 | expectedNextProto: "foo", |
| 4801 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4802 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4803 | }) |
| 4804 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4805 | var emptyString string |
| 4806 | testCases = append(testCases, testCase{ |
| 4807 | testType: clientTest, |
| 4808 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4809 | config: Config{ |
| 4810 | MaxVersion: ver.version, |
| 4811 | NextProtos: []string{""}, |
| 4812 | Bugs: ProtocolBugs{ |
| 4813 | // A server returning an empty ALPN protocol |
| 4814 | // should be rejected. |
| 4815 | ALPNProtocol: &emptyString, |
| 4816 | }, |
| 4817 | }, |
| 4818 | flags: []string{ |
| 4819 | "-advertise-alpn", "\x03foo", |
| 4820 | }, |
| 4821 | shouldFail: true, |
| 4822 | expectedError: ":PARSE_TLSEXT:", |
| 4823 | }) |
| 4824 | testCases = append(testCases, testCase{ |
| 4825 | testType: serverTest, |
| 4826 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4827 | config: Config{ |
| 4828 | MaxVersion: ver.version, |
| 4829 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4830 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4831 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4832 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4833 | flags: []string{ |
| 4834 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4835 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4836 | shouldFail: true, |
| 4837 | expectedError: ":PARSE_TLSEXT:", |
| 4838 | }) |
| 4839 | |
| 4840 | // Test NPN and the interaction with ALPN. |
| 4841 | if ver.version < VersionTLS13 { |
| 4842 | // Test that the server prefers ALPN over NPN. |
| 4843 | testCases = append(testCases, testCase{ |
| 4844 | testType: serverTest, |
| 4845 | name: "ALPNServer-Preferred-" + ver.name, |
| 4846 | config: Config{ |
| 4847 | MaxVersion: ver.version, |
| 4848 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4849 | }, |
| 4850 | flags: []string{ |
| 4851 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4852 | "-select-alpn", "foo", |
| 4853 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4854 | }, |
| 4855 | expectedNextProto: "foo", |
| 4856 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4857 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4858 | }) |
| 4859 | testCases = append(testCases, testCase{ |
| 4860 | testType: serverTest, |
| 4861 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4862 | config: Config{ |
| 4863 | MaxVersion: ver.version, |
| 4864 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4865 | Bugs: ProtocolBugs{ |
| 4866 | SwapNPNAndALPN: true, |
| 4867 | }, |
| 4868 | }, |
| 4869 | flags: []string{ |
| 4870 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4871 | "-select-alpn", "foo", |
| 4872 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4873 | }, |
| 4874 | expectedNextProto: "foo", |
| 4875 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4876 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4877 | }) |
| 4878 | |
| 4879 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4880 | testCases = append(testCases, testCase{ |
| 4881 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4882 | config: Config{ |
| 4883 | MaxVersion: ver.version, |
| 4884 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4885 | Bugs: ProtocolBugs{ |
| 4886 | NegotiateALPNAndNPN: true, |
| 4887 | }, |
| 4888 | }, |
| 4889 | flags: []string{ |
| 4890 | "-advertise-alpn", "\x03foo", |
| 4891 | "-select-next-proto", "foo", |
| 4892 | }, |
| 4893 | shouldFail: true, |
| 4894 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4895 | }) |
| 4896 | testCases = append(testCases, testCase{ |
| 4897 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4898 | config: Config{ |
| 4899 | MaxVersion: ver.version, |
| 4900 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4901 | Bugs: ProtocolBugs{ |
| 4902 | NegotiateALPNAndNPN: true, |
| 4903 | SwapNPNAndALPN: true, |
| 4904 | }, |
| 4905 | }, |
| 4906 | flags: []string{ |
| 4907 | "-advertise-alpn", "\x03foo", |
| 4908 | "-select-next-proto", "foo", |
| 4909 | }, |
| 4910 | shouldFail: true, |
| 4911 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4912 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4913 | } |
| 4914 | |
| 4915 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4916 | |
| 4917 | // Resume with a corrupt ticket. |
| 4918 | testCases = append(testCases, testCase{ |
| 4919 | testType: serverTest, |
| 4920 | name: "CorruptTicket-" + ver.name, |
| 4921 | config: Config{ |
| 4922 | MaxVersion: ver.version, |
| 4923 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 4924 | FilterTicket: func(in []byte) ([]byte, error) { |
| 4925 | in[len(in)-1] ^= 1 |
| 4926 | return in, nil |
| 4927 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4928 | }, |
| 4929 | }, |
| 4930 | resumeSession: true, |
| 4931 | expectResumeRejected: true, |
| 4932 | }) |
| 4933 | // Test the ticket callback, with and without renewal. |
| 4934 | testCases = append(testCases, testCase{ |
| 4935 | testType: serverTest, |
| 4936 | name: "TicketCallback-" + ver.name, |
| 4937 | config: Config{ |
| 4938 | MaxVersion: ver.version, |
| 4939 | }, |
| 4940 | resumeSession: true, |
| 4941 | flags: []string{"-use-ticket-callback"}, |
| 4942 | }) |
| 4943 | testCases = append(testCases, testCase{ |
| 4944 | testType: serverTest, |
| 4945 | name: "TicketCallback-Renew-" + ver.name, |
| 4946 | config: Config{ |
| 4947 | MaxVersion: ver.version, |
| 4948 | Bugs: ProtocolBugs{ |
| 4949 | ExpectNewTicket: true, |
| 4950 | }, |
| 4951 | }, |
| 4952 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 4953 | resumeSession: true, |
| 4954 | }) |
| 4955 | |
| 4956 | // Test that the ticket callback is only called once when everything before |
| 4957 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 4958 | // certificate selection callbacks run. |
| 4959 | testCases = append(testCases, testCase{ |
| 4960 | testType: serverTest, |
| 4961 | name: "TicketCallback-SingleCall-" + ver.name, |
| 4962 | config: Config{ |
| 4963 | MaxVersion: ver.version, |
| 4964 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 4965 | FilterTicket: func(in []byte) ([]byte, error) { |
| 4966 | in[len(in)-1] ^= 1 |
| 4967 | return in, nil |
| 4968 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4969 | }, |
| 4970 | }, |
| 4971 | resumeSession: true, |
| 4972 | expectResumeRejected: true, |
| 4973 | flags: []string{ |
| 4974 | "-use-ticket-callback", |
| 4975 | "-async", |
| 4976 | }, |
| 4977 | }) |
| 4978 | |
| 4979 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4980 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4981 | testCases = append(testCases, testCase{ |
| 4982 | testType: serverTest, |
| 4983 | name: "OversizedSessionId-" + ver.name, |
| 4984 | config: Config{ |
| 4985 | MaxVersion: ver.version, |
| 4986 | Bugs: ProtocolBugs{ |
| 4987 | OversizedSessionId: true, |
| 4988 | }, |
| 4989 | }, |
| 4990 | resumeSession: true, |
| 4991 | shouldFail: true, |
| 4992 | expectedError: ":DECODE_ERROR:", |
| 4993 | }) |
| 4994 | } |
| 4995 | |
| 4996 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 4997 | // are ignored. |
| 4998 | if ver.hasDTLS { |
| 4999 | testCases = append(testCases, testCase{ |
| 5000 | protocol: dtls, |
| 5001 | name: "SRTP-Client-" + ver.name, |
| 5002 | config: Config{ |
| 5003 | MaxVersion: ver.version, |
| 5004 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5005 | }, |
| 5006 | flags: []string{ |
| 5007 | "-srtp-profiles", |
| 5008 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5009 | }, |
| 5010 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5011 | }) |
| 5012 | testCases = append(testCases, testCase{ |
| 5013 | protocol: dtls, |
| 5014 | testType: serverTest, |
| 5015 | name: "SRTP-Server-" + ver.name, |
| 5016 | config: Config{ |
| 5017 | MaxVersion: ver.version, |
| 5018 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5019 | }, |
| 5020 | flags: []string{ |
| 5021 | "-srtp-profiles", |
| 5022 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5023 | }, |
| 5024 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5025 | }) |
| 5026 | // Test that the MKI is ignored. |
| 5027 | testCases = append(testCases, testCase{ |
| 5028 | protocol: dtls, |
| 5029 | testType: serverTest, |
| 5030 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5031 | config: Config{ |
| 5032 | MaxVersion: ver.version, |
| 5033 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5034 | Bugs: ProtocolBugs{ |
| 5035 | SRTPMasterKeyIdentifer: "bogus", |
| 5036 | }, |
| 5037 | }, |
| 5038 | flags: []string{ |
| 5039 | "-srtp-profiles", |
| 5040 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5041 | }, |
| 5042 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5043 | }) |
| 5044 | // Test that SRTP isn't negotiated on the server if there were |
| 5045 | // no matching profiles. |
| 5046 | testCases = append(testCases, testCase{ |
| 5047 | protocol: dtls, |
| 5048 | testType: serverTest, |
| 5049 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5050 | config: Config{ |
| 5051 | MaxVersion: ver.version, |
| 5052 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5053 | }, |
| 5054 | flags: []string{ |
| 5055 | "-srtp-profiles", |
| 5056 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5057 | }, |
| 5058 | expectedSRTPProtectionProfile: 0, |
| 5059 | }) |
| 5060 | // Test that the server returning an invalid SRTP profile is |
| 5061 | // flagged as an error by the client. |
| 5062 | testCases = append(testCases, testCase{ |
| 5063 | protocol: dtls, |
| 5064 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5065 | config: Config{ |
| 5066 | MaxVersion: ver.version, |
| 5067 | Bugs: ProtocolBugs{ |
| 5068 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5069 | }, |
| 5070 | }, |
| 5071 | flags: []string{ |
| 5072 | "-srtp-profiles", |
| 5073 | "SRTP_AES128_CM_SHA1_80", |
| 5074 | }, |
| 5075 | shouldFail: true, |
| 5076 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5077 | }) |
| 5078 | } |
| 5079 | |
| 5080 | // Test SCT list. |
| 5081 | testCases = append(testCases, testCase{ |
| 5082 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5083 | testType: clientTest, |
| 5084 | config: Config{ |
| 5085 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5086 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5087 | flags: []string{ |
| 5088 | "-enable-signed-cert-timestamps", |
| 5089 | "-expect-signed-cert-timestamps", |
| 5090 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5091 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5092 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5093 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5094 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5095 | var differentSCTList []byte |
| 5096 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5097 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5098 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5099 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5100 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5101 | testCases = append(testCases, testCase{ |
| 5102 | name: "SendSCTListOnResume-" + ver.name, |
| 5103 | config: Config{ |
| 5104 | MaxVersion: ver.version, |
| 5105 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5106 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5107 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5108 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5109 | flags: []string{ |
| 5110 | "-enable-signed-cert-timestamps", |
| 5111 | "-expect-signed-cert-timestamps", |
| 5112 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5113 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5114 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5115 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5116 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5117 | testCases = append(testCases, testCase{ |
| 5118 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5119 | testType: serverTest, |
| 5120 | config: Config{ |
| 5121 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5122 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5123 | flags: []string{ |
| 5124 | "-signed-cert-timestamps", |
| 5125 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5126 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5127 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5128 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5129 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5130 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5131 | emptySCTListCert := *testCerts[0].cert |
| 5132 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5133 | |
| 5134 | // Test empty SCT list. |
| 5135 | testCases = append(testCases, testCase{ |
| 5136 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5137 | testType: clientTest, |
| 5138 | config: Config{ |
| 5139 | MaxVersion: ver.version, |
| 5140 | Certificates: []Certificate{emptySCTListCert}, |
| 5141 | }, |
| 5142 | flags: []string{ |
| 5143 | "-enable-signed-cert-timestamps", |
| 5144 | }, |
| 5145 | shouldFail: true, |
| 5146 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5147 | }) |
| 5148 | |
| 5149 | emptySCTCert := *testCerts[0].cert |
| 5150 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5151 | |
| 5152 | // Test empty SCT in non-empty list. |
| 5153 | testCases = append(testCases, testCase{ |
| 5154 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5155 | testType: clientTest, |
| 5156 | config: Config{ |
| 5157 | MaxVersion: ver.version, |
| 5158 | Certificates: []Certificate{emptySCTCert}, |
| 5159 | }, |
| 5160 | flags: []string{ |
| 5161 | "-enable-signed-cert-timestamps", |
| 5162 | }, |
| 5163 | shouldFail: true, |
| 5164 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5165 | }) |
| 5166 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5167 | // Test that certificate-related extensions are not sent unsolicited. |
| 5168 | testCases = append(testCases, testCase{ |
| 5169 | testType: serverTest, |
| 5170 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5171 | config: Config{ |
| 5172 | MaxVersion: ver.version, |
| 5173 | Bugs: ProtocolBugs{ |
| 5174 | NoOCSPStapling: true, |
| 5175 | NoSignedCertificateTimestamps: true, |
| 5176 | }, |
| 5177 | }, |
| 5178 | flags: []string{ |
| 5179 | "-ocsp-response", |
| 5180 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5181 | "-signed-cert-timestamps", |
| 5182 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5183 | }, |
| 5184 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5185 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5186 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5187 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5188 | testType: clientTest, |
| 5189 | name: "ClientHelloPadding", |
| 5190 | config: Config{ |
| 5191 | Bugs: ProtocolBugs{ |
| 5192 | RequireClientHelloSize: 512, |
| 5193 | }, |
| 5194 | }, |
| 5195 | // This hostname just needs to be long enough to push the |
| 5196 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5197 | // long. |
| 5198 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5199 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5200 | |
| 5201 | // Extensions should not function in SSL 3.0. |
| 5202 | testCases = append(testCases, testCase{ |
| 5203 | testType: serverTest, |
| 5204 | name: "SSLv3Extensions-NoALPN", |
| 5205 | config: Config{ |
| 5206 | MaxVersion: VersionSSL30, |
| 5207 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5208 | }, |
| 5209 | flags: []string{ |
| 5210 | "-select-alpn", "foo", |
| 5211 | }, |
| 5212 | expectNoNextProto: true, |
| 5213 | }) |
| 5214 | |
| 5215 | // Test session tickets separately as they follow a different codepath. |
| 5216 | testCases = append(testCases, testCase{ |
| 5217 | testType: serverTest, |
| 5218 | name: "SSLv3Extensions-NoTickets", |
| 5219 | config: Config{ |
| 5220 | MaxVersion: VersionSSL30, |
| 5221 | Bugs: ProtocolBugs{ |
| 5222 | // Historically, session tickets in SSL 3.0 |
| 5223 | // failed in different ways depending on whether |
| 5224 | // the client supported renegotiation_info. |
| 5225 | NoRenegotiationInfo: true, |
| 5226 | }, |
| 5227 | }, |
| 5228 | resumeSession: true, |
| 5229 | }) |
| 5230 | testCases = append(testCases, testCase{ |
| 5231 | testType: serverTest, |
| 5232 | name: "SSLv3Extensions-NoTickets2", |
| 5233 | config: Config{ |
| 5234 | MaxVersion: VersionSSL30, |
| 5235 | }, |
| 5236 | resumeSession: true, |
| 5237 | }) |
| 5238 | |
| 5239 | // But SSL 3.0 does send and process renegotiation_info. |
| 5240 | testCases = append(testCases, testCase{ |
| 5241 | testType: serverTest, |
| 5242 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5243 | config: Config{ |
| 5244 | MaxVersion: VersionSSL30, |
| 5245 | Bugs: ProtocolBugs{ |
| 5246 | RequireRenegotiationInfo: true, |
| 5247 | }, |
| 5248 | }, |
| 5249 | }) |
| 5250 | testCases = append(testCases, testCase{ |
| 5251 | testType: serverTest, |
| 5252 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5253 | config: Config{ |
| 5254 | MaxVersion: VersionSSL30, |
| 5255 | Bugs: ProtocolBugs{ |
| 5256 | NoRenegotiationInfo: true, |
| 5257 | SendRenegotiationSCSV: true, |
| 5258 | RequireRenegotiationInfo: true, |
| 5259 | }, |
| 5260 | }, |
| 5261 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5262 | |
| 5263 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5264 | // in ServerHello. |
| 5265 | testCases = append(testCases, testCase{ |
| 5266 | name: "NPN-Forbidden-TLS13", |
| 5267 | config: Config{ |
| 5268 | MaxVersion: VersionTLS13, |
| 5269 | NextProtos: []string{"foo"}, |
| 5270 | Bugs: ProtocolBugs{ |
| 5271 | NegotiateNPNAtAllVersions: true, |
| 5272 | }, |
| 5273 | }, |
| 5274 | flags: []string{"-select-next-proto", "foo"}, |
| 5275 | shouldFail: true, |
| 5276 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5277 | }) |
| 5278 | testCases = append(testCases, testCase{ |
| 5279 | name: "EMS-Forbidden-TLS13", |
| 5280 | config: Config{ |
| 5281 | MaxVersion: VersionTLS13, |
| 5282 | Bugs: ProtocolBugs{ |
| 5283 | NegotiateEMSAtAllVersions: true, |
| 5284 | }, |
| 5285 | }, |
| 5286 | shouldFail: true, |
| 5287 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5288 | }) |
| 5289 | testCases = append(testCases, testCase{ |
| 5290 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5291 | config: Config{ |
| 5292 | MaxVersion: VersionTLS13, |
| 5293 | Bugs: ProtocolBugs{ |
| 5294 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5295 | }, |
| 5296 | }, |
| 5297 | shouldFail: true, |
| 5298 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5299 | }) |
| 5300 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5301 | name: "Ticket-Forbidden-TLS13", |
| 5302 | config: Config{ |
| 5303 | MaxVersion: VersionTLS12, |
| 5304 | }, |
| 5305 | resumeConfig: &Config{ |
| 5306 | MaxVersion: VersionTLS13, |
| 5307 | Bugs: ProtocolBugs{ |
| 5308 | AdvertiseTicketExtension: true, |
| 5309 | }, |
| 5310 | }, |
| 5311 | resumeSession: true, |
| 5312 | shouldFail: true, |
| 5313 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5314 | }) |
| 5315 | |
| 5316 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5317 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5318 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5319 | // implicit in every test.) |
| 5320 | testCases = append(testCases, testCase{ |
| 5321 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5322 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5323 | config: Config{ |
| 5324 | MaxVersion: VersionTLS13, |
| 5325 | NextProtos: []string{"bar"}, |
| 5326 | }, |
| 5327 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5328 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5329 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5330 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5331 | // tolerated. |
| 5332 | testCases = append(testCases, testCase{ |
| 5333 | name: "SendOCSPResponseOnResume-TLS12", |
| 5334 | config: Config{ |
| 5335 | MaxVersion: VersionTLS12, |
| 5336 | Bugs: ProtocolBugs{ |
| 5337 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5338 | }, |
| 5339 | }, |
| 5340 | flags: []string{ |
| 5341 | "-enable-ocsp-stapling", |
| 5342 | "-expect-ocsp-response", |
| 5343 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5344 | }, |
| 5345 | resumeSession: true, |
| 5346 | }) |
| 5347 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5348 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5349 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5350 | config: Config{ |
| 5351 | MaxVersion: VersionTLS13, |
| 5352 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5353 | SendExtensionOnCertificate: testOCSPExtension, |
| 5354 | }, |
| 5355 | }, |
| 5356 | shouldFail: true, |
| 5357 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5358 | }) |
| 5359 | |
| 5360 | testCases = append(testCases, testCase{ |
| 5361 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5362 | config: Config{ |
| 5363 | MaxVersion: VersionTLS13, |
| 5364 | Bugs: ProtocolBugs{ |
| 5365 | SendExtensionOnCertificate: testSCTExtension, |
| 5366 | }, |
| 5367 | }, |
| 5368 | shouldFail: true, |
| 5369 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5370 | }) |
| 5371 | |
| 5372 | // Test that extensions on client certificates are never accepted. |
| 5373 | testCases = append(testCases, testCase{ |
| 5374 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5375 | testType: serverTest, |
| 5376 | config: Config{ |
| 5377 | MaxVersion: VersionTLS13, |
| 5378 | Certificates: []Certificate{rsaCertificate}, |
| 5379 | Bugs: ProtocolBugs{ |
| 5380 | SendExtensionOnCertificate: testOCSPExtension, |
| 5381 | }, |
| 5382 | }, |
| 5383 | flags: []string{ |
| 5384 | "-enable-ocsp-stapling", |
| 5385 | "-require-any-client-certificate", |
| 5386 | }, |
| 5387 | shouldFail: true, |
| 5388 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5389 | }) |
| 5390 | |
| 5391 | testCases = append(testCases, testCase{ |
| 5392 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5393 | config: Config{ |
| 5394 | MaxVersion: VersionTLS13, |
| 5395 | Bugs: ProtocolBugs{ |
| 5396 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5397 | }, |
| 5398 | }, |
| 5399 | shouldFail: true, |
| 5400 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5401 | }) |
| 5402 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5403 | var differentSCTList []byte |
| 5404 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5405 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5406 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5407 | // Test that extensions on intermediates are allowed but ignored. |
| 5408 | testCases = append(testCases, testCase{ |
| 5409 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5410 | config: Config{ |
| 5411 | MaxVersion: VersionTLS13, |
| 5412 | Certificates: []Certificate{rsaChainCertificate}, |
| 5413 | Bugs: ProtocolBugs{ |
| 5414 | // Send different values on the intermediate. This tests |
| 5415 | // the intermediate's extensions do not override the |
| 5416 | // leaf's. |
| 5417 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5418 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5419 | }, |
| 5420 | }, |
| 5421 | flags: []string{ |
| 5422 | "-enable-ocsp-stapling", |
| 5423 | "-expect-ocsp-response", |
| 5424 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5425 | "-enable-signed-cert-timestamps", |
| 5426 | "-expect-signed-cert-timestamps", |
| 5427 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5428 | }, |
| 5429 | resumeSession: true, |
| 5430 | }) |
| 5431 | |
| 5432 | // Test that extensions are not sent on intermediates when configured |
| 5433 | // only for a leaf. |
| 5434 | testCases = append(testCases, testCase{ |
| 5435 | testType: serverTest, |
| 5436 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5437 | config: Config{ |
| 5438 | MaxVersion: VersionTLS13, |
| 5439 | Bugs: ProtocolBugs{ |
| 5440 | ExpectNoExtensionsOnIntermediate: true, |
| 5441 | }, |
| 5442 | }, |
| 5443 | flags: []string{ |
| 5444 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5445 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5446 | "-ocsp-response", |
| 5447 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5448 | "-signed-cert-timestamps", |
| 5449 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5450 | }, |
| 5451 | }) |
| 5452 | |
| 5453 | // Test that extensions are not sent on client certificates. |
| 5454 | testCases = append(testCases, testCase{ |
| 5455 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5456 | config: Config{ |
| 5457 | MaxVersion: VersionTLS13, |
| 5458 | ClientAuth: RequireAnyClientCert, |
| 5459 | }, |
| 5460 | flags: []string{ |
| 5461 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5462 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5463 | "-ocsp-response", |
| 5464 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5465 | "-signed-cert-timestamps", |
| 5466 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5467 | }, |
| 5468 | }) |
| 5469 | |
| 5470 | testCases = append(testCases, testCase{ |
| 5471 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5472 | config: Config{ |
| 5473 | MaxVersion: VersionTLS13, |
| 5474 | Bugs: ProtocolBugs{ |
| 5475 | SendDuplicateCertExtensions: true, |
| 5476 | }, |
| 5477 | }, |
| 5478 | flags: []string{ |
| 5479 | "-enable-ocsp-stapling", |
| 5480 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5481 | }, |
| 5482 | resumeSession: true, |
| 5483 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5484 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5485 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5486 | |
| 5487 | testCases = append(testCases, testCase{ |
| 5488 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5489 | testType: serverTest, |
| 5490 | flags: []string{ |
| 5491 | "-signed-cert-timestamps", |
| 5492 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5493 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5494 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5495 | expectedError: ":INVALID_SCT_LIST:", |
| 5496 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5497 | } |
| 5498 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5499 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5500 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5501 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5502 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5503 | // have session IDs, so skip their cross-resumption |
| 5504 | // tests. |
| 5505 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5506 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5507 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5508 | } |
| 5509 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5510 | protocols := []protocol{tls} |
| 5511 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5512 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5513 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5514 | for _, protocol := range protocols { |
| 5515 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5516 | if protocol == dtls { |
| 5517 | suffix += "-DTLS" |
| 5518 | } |
| 5519 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5520 | if sessionVers.version == resumeVers.version { |
| 5521 | testCases = append(testCases, testCase{ |
| 5522 | protocol: protocol, |
| 5523 | name: "Resume-Client" + suffix, |
| 5524 | resumeSession: true, |
| 5525 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5526 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5527 | Bugs: ProtocolBugs{ |
| 5528 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5529 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5530 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5531 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5532 | expectedVersion: sessionVers.version, |
| 5533 | expectedResumeVersion: resumeVers.version, |
| 5534 | }) |
| 5535 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5536 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5537 | |
| 5538 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5539 | // there is no way to convince a non-lookahead client the |
| 5540 | // session was resumed. It will appear to the client that a |
| 5541 | // stray ChangeCipherSpec was sent. |
| 5542 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5543 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5544 | } |
| 5545 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5546 | testCases = append(testCases, testCase{ |
| 5547 | protocol: protocol, |
| 5548 | name: "Resume-Client-Mismatch" + suffix, |
| 5549 | resumeSession: true, |
| 5550 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5551 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5552 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5553 | expectedVersion: sessionVers.version, |
| 5554 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5555 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5556 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5557 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5558 | }, |
| 5559 | }, |
| 5560 | expectedResumeVersion: resumeVers.version, |
| 5561 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5562 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5563 | }) |
| 5564 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5565 | |
| 5566 | testCases = append(testCases, testCase{ |
| 5567 | protocol: protocol, |
| 5568 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5569 | resumeSession: true, |
| 5570 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5571 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5572 | }, |
| 5573 | expectedVersion: sessionVers.version, |
| 5574 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5575 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5576 | }, |
| 5577 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5578 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5579 | expectedResumeVersion: resumeVers.version, |
| 5580 | }) |
| 5581 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5582 | testCases = append(testCases, testCase{ |
| 5583 | protocol: protocol, |
| 5584 | testType: serverTest, |
| 5585 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5586 | resumeSession: true, |
| 5587 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5588 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5589 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5590 | expectedVersion: sessionVers.version, |
| 5591 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5592 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5593 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5594 | Bugs: ProtocolBugs{ |
| 5595 | SendBothTickets: true, |
| 5596 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5597 | }, |
| 5598 | expectedResumeVersion: resumeVers.version, |
| 5599 | }) |
| 5600 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5601 | } |
| 5602 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5603 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5604 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5605 | testCases = append(testCases, testCase{ |
| 5606 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5607 | name: "ShimTicketRewritable", |
| 5608 | resumeSession: true, |
| 5609 | config: Config{ |
| 5610 | MaxVersion: VersionTLS12, |
| 5611 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5612 | Bugs: ProtocolBugs{ |
| 5613 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5614 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5615 | if err != nil { |
| 5616 | return nil, err |
| 5617 | } |
| 5618 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5619 | }, |
| 5620 | }, |
| 5621 | }, |
| 5622 | flags: []string{ |
| 5623 | "-ticket-key", |
| 5624 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5625 | }, |
| 5626 | }) |
| 5627 | |
| 5628 | // Resumptions are declined if the version does not match. |
| 5629 | testCases = append(testCases, testCase{ |
| 5630 | testType: serverTest, |
| 5631 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5632 | resumeSession: true, |
| 5633 | config: Config{ |
| 5634 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5635 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5636 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5637 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5638 | return SetShimTicketVersion(in, VersionTLS13) |
| 5639 | }, |
| 5640 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5641 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5642 | flags: []string{ |
| 5643 | "-ticket-key", |
| 5644 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5645 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5646 | expectResumeRejected: true, |
| 5647 | }) |
| 5648 | |
| 5649 | testCases = append(testCases, testCase{ |
| 5650 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5651 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5652 | resumeSession: true, |
| 5653 | config: Config{ |
| 5654 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5655 | Bugs: ProtocolBugs{ |
| 5656 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5657 | return SetShimTicketVersion(in, VersionTLS12) |
| 5658 | }, |
| 5659 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5660 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5661 | flags: []string{ |
| 5662 | "-ticket-key", |
| 5663 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5664 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5665 | expectResumeRejected: true, |
| 5666 | }) |
| 5667 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5668 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5669 | testCases = append(testCases, testCase{ |
| 5670 | testType: serverTest, |
| 5671 | name: "Resume-Server-DeclineBadCipher", |
| 5672 | resumeSession: true, |
| 5673 | config: Config{ |
| 5674 | MaxVersion: VersionTLS12, |
| 5675 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5676 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5677 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5678 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5679 | }, |
| 5680 | }, |
| 5681 | }, |
| 5682 | flags: []string{ |
| 5683 | "-ticket-key", |
| 5684 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5685 | }, |
| 5686 | expectResumeRejected: true, |
| 5687 | }) |
| 5688 | |
| 5689 | testCases = append(testCases, testCase{ |
| 5690 | testType: serverTest, |
| 5691 | name: "Resume-Server-DeclineBadCipher-2", |
| 5692 | resumeSession: true, |
| 5693 | config: Config{ |
| 5694 | MaxVersion: VersionTLS12, |
| 5695 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5696 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5697 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5698 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5699 | }, |
| 5700 | }, |
| 5701 | }, |
| 5702 | flags: []string{ |
| 5703 | "-cipher", "AES128", |
| 5704 | "-ticket-key", |
| 5705 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5706 | }, |
| 5707 | expectResumeRejected: true, |
| 5708 | }) |
| 5709 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5710 | // Sessions are not resumed if they do not use the preferred cipher. |
| 5711 | testCases = append(testCases, testCase{ |
| 5712 | testType: serverTest, |
| 5713 | name: "Resume-Server-CipherNotPreferred", |
| 5714 | resumeSession: true, |
| 5715 | config: Config{ |
| 5716 | MaxVersion: VersionTLS12, |
| 5717 | Bugs: ProtocolBugs{ |
| 5718 | ExpectNewTicket: true, |
| 5719 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5720 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 5721 | }, |
| 5722 | }, |
| 5723 | }, |
| 5724 | flags: []string{ |
| 5725 | "-ticket-key", |
| 5726 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5727 | }, |
| 5728 | shouldFail: false, |
| 5729 | expectResumeRejected: true, |
| 5730 | }) |
| 5731 | |
| 5732 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 5733 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 5734 | testCases = append(testCases, testCase{ |
| 5735 | testType: serverTest, |
| 5736 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 5737 | resumeSession: true, |
| 5738 | config: Config{ |
| 5739 | MaxVersion: VersionTLS13, |
| 5740 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 5741 | Bugs: ProtocolBugs{ |
| 5742 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5743 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 5744 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 5745 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5746 | }, |
| 5747 | }, |
| 5748 | }, |
| 5749 | flags: []string{ |
| 5750 | "-ticket-key", |
| 5751 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5752 | }, |
| 5753 | shouldFail: false, |
| 5754 | expectResumeRejected: true, |
| 5755 | }) |
| 5756 | |
| 5757 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5758 | testCases = append(testCases, testCase{ |
| 5759 | testType: serverTest, |
| 5760 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5761 | resumeSession: true, |
| 5762 | config: Config{ |
| 5763 | MaxVersion: VersionTLS13, |
| 5764 | Bugs: ProtocolBugs{ |
| 5765 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5766 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5767 | }, |
| 5768 | }, |
| 5769 | }, |
| 5770 | flags: []string{ |
| 5771 | "-ticket-key", |
| 5772 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5773 | }, |
| 5774 | expectResumeRejected: true, |
| 5775 | }) |
| 5776 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5777 | // If the client does not offer the cipher from the session, decline to |
| 5778 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 5779 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5780 | testCases = append(testCases, testCase{ |
| 5781 | testType: serverTest, |
| 5782 | name: "Resume-Server-UnofferedCipher", |
| 5783 | resumeSession: true, |
| 5784 | config: Config{ |
| 5785 | MaxVersion: VersionTLS12, |
| 5786 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5787 | }, |
| 5788 | resumeConfig: &Config{ |
| 5789 | MaxVersion: VersionTLS12, |
| 5790 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5791 | Bugs: ProtocolBugs{ |
| 5792 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5793 | }, |
| 5794 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5795 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5796 | }) |
| 5797 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5798 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 5799 | // include the selected cipher. Test that we tolerate this. Servers may |
| 5800 | // resume at another cipher if the PRF matches, but BoringSSL will |
| 5801 | // always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5802 | testCases = append(testCases, testCase{ |
| 5803 | testType: serverTest, |
| 5804 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5805 | resumeSession: true, |
| 5806 | config: Config{ |
| 5807 | MaxVersion: VersionTLS13, |
| 5808 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5809 | }, |
| 5810 | resumeConfig: &Config{ |
| 5811 | MaxVersion: VersionTLS13, |
| 5812 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5813 | Bugs: ProtocolBugs{ |
| 5814 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5815 | }, |
| 5816 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5817 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5818 | }) |
| 5819 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5820 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5821 | testCases = append(testCases, testCase{ |
| 5822 | name: "Resume-Client-CipherMismatch", |
| 5823 | resumeSession: true, |
| 5824 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5825 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5826 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5827 | }, |
| 5828 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5829 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5830 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5831 | Bugs: ProtocolBugs{ |
| 5832 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5833 | }, |
| 5834 | }, |
| 5835 | shouldFail: true, |
| 5836 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5837 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5838 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5839 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 5840 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5841 | testCases = append(testCases, testCase{ |
| 5842 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5843 | resumeSession: true, |
| 5844 | config: Config{ |
| 5845 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5846 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5847 | }, |
| 5848 | resumeConfig: &Config{ |
| 5849 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5850 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5851 | }, |
| 5852 | }) |
| 5853 | |
| 5854 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 5855 | testCases = append(testCases, testCase{ |
| 5856 | name: "Resume-Client-PRFMismatch-TLS13", |
| 5857 | resumeSession: true, |
| 5858 | config: Config{ |
| 5859 | MaxVersion: VersionTLS13, |
| 5860 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5861 | }, |
| 5862 | resumeConfig: &Config{ |
| 5863 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5864 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5865 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5866 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5867 | }, |
| 5868 | }, |
| 5869 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5870 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5871 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5872 | |
| 5873 | testCases = append(testCases, testCase{ |
| 5874 | testType: serverTest, |
| 5875 | name: "Resume-Server-BinderWrongLength", |
| 5876 | resumeSession: true, |
| 5877 | config: Config{ |
| 5878 | MaxVersion: VersionTLS13, |
| 5879 | Bugs: ProtocolBugs{ |
| 5880 | SendShortPSKBinder: true, |
| 5881 | }, |
| 5882 | }, |
| 5883 | shouldFail: true, |
| 5884 | expectedLocalError: "remote error: error decrypting message", |
| 5885 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5886 | }) |
| 5887 | |
| 5888 | testCases = append(testCases, testCase{ |
| 5889 | testType: serverTest, |
| 5890 | name: "Resume-Server-NoPSKBinder", |
| 5891 | resumeSession: true, |
| 5892 | config: Config{ |
| 5893 | MaxVersion: VersionTLS13, |
| 5894 | Bugs: ProtocolBugs{ |
| 5895 | SendNoPSKBinder: true, |
| 5896 | }, |
| 5897 | }, |
| 5898 | shouldFail: true, |
| 5899 | expectedLocalError: "remote error: error decoding message", |
| 5900 | expectedError: ":DECODE_ERROR:", |
| 5901 | }) |
| 5902 | |
| 5903 | testCases = append(testCases, testCase{ |
| 5904 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 5905 | name: "Resume-Server-ExtraPSKBinder", |
| 5906 | resumeSession: true, |
| 5907 | config: Config{ |
| 5908 | MaxVersion: VersionTLS13, |
| 5909 | Bugs: ProtocolBugs{ |
| 5910 | SendExtraPSKBinder: true, |
| 5911 | }, |
| 5912 | }, |
| 5913 | shouldFail: true, |
| 5914 | expectedLocalError: "remote error: illegal parameter", |
| 5915 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 5916 | }) |
| 5917 | |
| 5918 | testCases = append(testCases, testCase{ |
| 5919 | testType: serverTest, |
| 5920 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 5921 | resumeSession: true, |
| 5922 | config: Config{ |
| 5923 | MaxVersion: VersionTLS13, |
| 5924 | Bugs: ProtocolBugs{ |
| 5925 | ExtraPSKIdentity: true, |
| 5926 | }, |
| 5927 | }, |
| 5928 | shouldFail: true, |
| 5929 | expectedLocalError: "remote error: illegal parameter", |
| 5930 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 5931 | }) |
| 5932 | |
| 5933 | testCases = append(testCases, testCase{ |
| 5934 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5935 | name: "Resume-Server-InvalidPSKBinder", |
| 5936 | resumeSession: true, |
| 5937 | config: Config{ |
| 5938 | MaxVersion: VersionTLS13, |
| 5939 | Bugs: ProtocolBugs{ |
| 5940 | SendInvalidPSKBinder: true, |
| 5941 | }, |
| 5942 | }, |
| 5943 | shouldFail: true, |
| 5944 | expectedLocalError: "remote error: error decrypting message", |
| 5945 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5946 | }) |
| 5947 | |
| 5948 | testCases = append(testCases, testCase{ |
| 5949 | testType: serverTest, |
| 5950 | name: "Resume-Server-PSKBinderFirstExtension", |
| 5951 | resumeSession: true, |
| 5952 | config: Config{ |
| 5953 | MaxVersion: VersionTLS13, |
| 5954 | Bugs: ProtocolBugs{ |
| 5955 | PSKBinderFirst: true, |
| 5956 | }, |
| 5957 | }, |
| 5958 | shouldFail: true, |
| 5959 | expectedLocalError: "remote error: illegal parameter", |
| 5960 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 5961 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5962 | } |
| 5963 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5964 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 5965 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5966 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5967 | testType: serverTest, |
| 5968 | name: "Renegotiate-Server-Forbidden", |
| 5969 | config: Config{ |
| 5970 | MaxVersion: VersionTLS12, |
| 5971 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5972 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5973 | shouldFail: true, |
| 5974 | expectedError: ":NO_RENEGOTIATION:", |
| 5975 | expectedLocalError: "remote error: no renegotiation", |
| 5976 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5977 | // The server shouldn't echo the renegotiation extension unless |
| 5978 | // requested by the client. |
| 5979 | testCases = append(testCases, testCase{ |
| 5980 | testType: serverTest, |
| 5981 | name: "Renegotiate-Server-NoExt", |
| 5982 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5983 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5984 | Bugs: ProtocolBugs{ |
| 5985 | NoRenegotiationInfo: true, |
| 5986 | RequireRenegotiationInfo: true, |
| 5987 | }, |
| 5988 | }, |
| 5989 | shouldFail: true, |
| 5990 | expectedLocalError: "renegotiation extension missing", |
| 5991 | }) |
| 5992 | // The renegotiation SCSV should be sufficient for the server to echo |
| 5993 | // the extension. |
| 5994 | testCases = append(testCases, testCase{ |
| 5995 | testType: serverTest, |
| 5996 | name: "Renegotiate-Server-NoExt-SCSV", |
| 5997 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5998 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5999 | Bugs: ProtocolBugs{ |
| 6000 | NoRenegotiationInfo: true, |
| 6001 | SendRenegotiationSCSV: true, |
| 6002 | RequireRenegotiationInfo: true, |
| 6003 | }, |
| 6004 | }, |
| 6005 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6006 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6007 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6008 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6009 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6010 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6011 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6012 | }, |
| 6013 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6014 | renegotiate: 1, |
| 6015 | flags: []string{ |
| 6016 | "-renegotiate-freely", |
| 6017 | "-expect-total-renegotiations", "1", |
| 6018 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6019 | }) |
| 6020 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6021 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6022 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6023 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6024 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6025 | Bugs: ProtocolBugs{ |
| 6026 | EmptyRenegotiationInfo: true, |
| 6027 | }, |
| 6028 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6029 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6030 | shouldFail: true, |
| 6031 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6032 | }) |
| 6033 | testCases = append(testCases, testCase{ |
| 6034 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6035 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6036 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6037 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6038 | Bugs: ProtocolBugs{ |
| 6039 | BadRenegotiationInfo: true, |
| 6040 | }, |
| 6041 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6042 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6043 | shouldFail: true, |
| 6044 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6045 | }) |
| 6046 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6047 | name: "Renegotiate-Client-Downgrade", |
| 6048 | renegotiate: 1, |
| 6049 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6050 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6051 | Bugs: ProtocolBugs{ |
| 6052 | NoRenegotiationInfoAfterInitial: true, |
| 6053 | }, |
| 6054 | }, |
| 6055 | flags: []string{"-renegotiate-freely"}, |
| 6056 | shouldFail: true, |
| 6057 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6058 | }) |
| 6059 | testCases = append(testCases, testCase{ |
| 6060 | name: "Renegotiate-Client-Upgrade", |
| 6061 | renegotiate: 1, |
| 6062 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6063 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6064 | Bugs: ProtocolBugs{ |
| 6065 | NoRenegotiationInfoInInitial: true, |
| 6066 | }, |
| 6067 | }, |
| 6068 | flags: []string{"-renegotiate-freely"}, |
| 6069 | shouldFail: true, |
| 6070 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6071 | }) |
| 6072 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6073 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6074 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6075 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6076 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6077 | Bugs: ProtocolBugs{ |
| 6078 | NoRenegotiationInfo: true, |
| 6079 | }, |
| 6080 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6081 | flags: []string{ |
| 6082 | "-renegotiate-freely", |
| 6083 | "-expect-total-renegotiations", "1", |
| 6084 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6085 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6086 | |
| 6087 | // Test that the server may switch ciphers on renegotiation without |
| 6088 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6089 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6090 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6091 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6092 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6093 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6094 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6095 | }, |
| 6096 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6097 | flags: []string{ |
| 6098 | "-renegotiate-freely", |
| 6099 | "-expect-total-renegotiations", "1", |
| 6100 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6101 | }) |
| 6102 | testCases = append(testCases, testCase{ |
| 6103 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6104 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6105 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6106 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6107 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6108 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6109 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6110 | flags: []string{ |
| 6111 | "-renegotiate-freely", |
| 6112 | "-expect-total-renegotiations", "1", |
| 6113 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6114 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6115 | |
| 6116 | // Test that the server may not switch versions on renegotiation. |
| 6117 | testCases = append(testCases, testCase{ |
| 6118 | name: "Renegotiate-Client-SwitchVersion", |
| 6119 | config: Config{ |
| 6120 | MaxVersion: VersionTLS12, |
| 6121 | // Pick a cipher which exists at both versions. |
| 6122 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6123 | Bugs: ProtocolBugs{ |
| 6124 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6125 | // Avoid failing early at the record layer. |
| 6126 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6127 | }, |
| 6128 | }, |
| 6129 | renegotiate: 1, |
| 6130 | flags: []string{ |
| 6131 | "-renegotiate-freely", |
| 6132 | "-expect-total-renegotiations", "1", |
| 6133 | }, |
| 6134 | shouldFail: true, |
| 6135 | expectedError: ":WRONG_SSL_VERSION:", |
| 6136 | }) |
| 6137 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6138 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6139 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6140 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6141 | config: Config{ |
| 6142 | MaxVersion: VersionTLS10, |
| 6143 | Bugs: ProtocolBugs{ |
| 6144 | RequireSameRenegoClientVersion: true, |
| 6145 | }, |
| 6146 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6147 | flags: []string{ |
| 6148 | "-renegotiate-freely", |
| 6149 | "-expect-total-renegotiations", "1", |
| 6150 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6151 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6152 | testCases = append(testCases, testCase{ |
| 6153 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6154 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6155 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6156 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6157 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6158 | NextProtos: []string{"foo"}, |
| 6159 | }, |
| 6160 | flags: []string{ |
| 6161 | "-false-start", |
| 6162 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6163 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6164 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6165 | }, |
| 6166 | shimWritesFirst: true, |
| 6167 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6168 | |
| 6169 | // Client-side renegotiation controls. |
| 6170 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6171 | name: "Renegotiate-Client-Forbidden-1", |
| 6172 | config: Config{ |
| 6173 | MaxVersion: VersionTLS12, |
| 6174 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6175 | renegotiate: 1, |
| 6176 | shouldFail: true, |
| 6177 | expectedError: ":NO_RENEGOTIATION:", |
| 6178 | expectedLocalError: "remote error: no renegotiation", |
| 6179 | }) |
| 6180 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6181 | name: "Renegotiate-Client-Once-1", |
| 6182 | config: Config{ |
| 6183 | MaxVersion: VersionTLS12, |
| 6184 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6185 | renegotiate: 1, |
| 6186 | flags: []string{ |
| 6187 | "-renegotiate-once", |
| 6188 | "-expect-total-renegotiations", "1", |
| 6189 | }, |
| 6190 | }) |
| 6191 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6192 | name: "Renegotiate-Client-Freely-1", |
| 6193 | config: Config{ |
| 6194 | MaxVersion: VersionTLS12, |
| 6195 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6196 | renegotiate: 1, |
| 6197 | flags: []string{ |
| 6198 | "-renegotiate-freely", |
| 6199 | "-expect-total-renegotiations", "1", |
| 6200 | }, |
| 6201 | }) |
| 6202 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6203 | name: "Renegotiate-Client-Once-2", |
| 6204 | config: Config{ |
| 6205 | MaxVersion: VersionTLS12, |
| 6206 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6207 | renegotiate: 2, |
| 6208 | flags: []string{"-renegotiate-once"}, |
| 6209 | shouldFail: true, |
| 6210 | expectedError: ":NO_RENEGOTIATION:", |
| 6211 | expectedLocalError: "remote error: no renegotiation", |
| 6212 | }) |
| 6213 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6214 | name: "Renegotiate-Client-Freely-2", |
| 6215 | config: Config{ |
| 6216 | MaxVersion: VersionTLS12, |
| 6217 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6218 | renegotiate: 2, |
| 6219 | flags: []string{ |
| 6220 | "-renegotiate-freely", |
| 6221 | "-expect-total-renegotiations", "2", |
| 6222 | }, |
| 6223 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6224 | testCases = append(testCases, testCase{ |
| 6225 | name: "Renegotiate-Client-NoIgnore", |
| 6226 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6227 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6228 | Bugs: ProtocolBugs{ |
| 6229 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6230 | }, |
| 6231 | }, |
| 6232 | shouldFail: true, |
| 6233 | expectedError: ":NO_RENEGOTIATION:", |
| 6234 | }) |
| 6235 | testCases = append(testCases, testCase{ |
| 6236 | name: "Renegotiate-Client-Ignore", |
| 6237 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6238 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6239 | Bugs: ProtocolBugs{ |
| 6240 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6241 | }, |
| 6242 | }, |
| 6243 | flags: []string{ |
| 6244 | "-renegotiate-ignore", |
| 6245 | "-expect-total-renegotiations", "0", |
| 6246 | }, |
| 6247 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6248 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6249 | // Renegotiation is not allowed at SSL 3.0. |
| 6250 | testCases = append(testCases, testCase{ |
| 6251 | name: "Renegotiate-Client-SSL3", |
| 6252 | config: Config{ |
| 6253 | MaxVersion: VersionSSL30, |
| 6254 | }, |
| 6255 | renegotiate: 1, |
| 6256 | flags: []string{ |
| 6257 | "-renegotiate-freely", |
| 6258 | "-expect-total-renegotiations", "1", |
| 6259 | }, |
| 6260 | shouldFail: true, |
| 6261 | expectedError: ":NO_RENEGOTIATION:", |
| 6262 | expectedLocalError: "remote error: no renegotiation", |
| 6263 | }) |
| 6264 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 6265 | // Renegotiation is not allowed when there is an unfinished write. |
| 6266 | testCases = append(testCases, testCase{ |
| 6267 | name: "Renegotiate-Client-UnfinishedWrite", |
| 6268 | config: Config{ |
| 6269 | MaxVersion: VersionTLS12, |
| 6270 | }, |
| 6271 | renegotiate: 1, |
| 6272 | flags: []string{ |
| 6273 | "-async", |
| 6274 | "-renegotiate-freely", |
| 6275 | "-read-with-unfinished-write", |
| 6276 | }, |
| 6277 | shouldFail: true, |
| 6278 | expectedError: ":NO_RENEGOTIATION:", |
| 6279 | // We do not successfully send the no_renegotiation alert in |
| 6280 | // this case. https://crbug.com/boringssl/130 |
| 6281 | }) |
| 6282 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6283 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6284 | testCases = append(testCases, testCase{ |
| 6285 | name: "StrayHelloRequest", |
| 6286 | config: Config{ |
| 6287 | MaxVersion: VersionTLS12, |
| 6288 | Bugs: ProtocolBugs{ |
| 6289 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6290 | }, |
| 6291 | }, |
| 6292 | }) |
| 6293 | testCases = append(testCases, testCase{ |
| 6294 | name: "StrayHelloRequest-Packed", |
| 6295 | config: Config{ |
| 6296 | MaxVersion: VersionTLS12, |
| 6297 | Bugs: ProtocolBugs{ |
| 6298 | PackHandshakeFlight: true, |
| 6299 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6300 | }, |
| 6301 | }, |
| 6302 | }) |
| 6303 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6304 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6305 | // the same record. |
| 6306 | testCases = append(testCases, testCase{ |
| 6307 | name: "Renegotiate-Client-Packed", |
| 6308 | config: Config{ |
| 6309 | MaxVersion: VersionTLS12, |
| 6310 | Bugs: ProtocolBugs{ |
| 6311 | PackHandshakeFlight: true, |
| 6312 | PackHelloRequestWithFinished: true, |
| 6313 | }, |
| 6314 | }, |
| 6315 | renegotiate: 1, |
| 6316 | flags: []string{ |
| 6317 | "-renegotiate-freely", |
| 6318 | "-expect-total-renegotiations", "1", |
| 6319 | }, |
| 6320 | }) |
| 6321 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6322 | // Renegotiation is forbidden in TLS 1.3. |
| 6323 | testCases = append(testCases, testCase{ |
| 6324 | name: "Renegotiate-Client-TLS13", |
| 6325 | config: Config{ |
| 6326 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6327 | Bugs: ProtocolBugs{ |
| 6328 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6329 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6330 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6331 | flags: []string{ |
| 6332 | "-renegotiate-freely", |
| 6333 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6334 | shouldFail: true, |
| 6335 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6336 | }) |
| 6337 | |
| 6338 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6339 | testCases = append(testCases, testCase{ |
| 6340 | name: "StrayHelloRequest-TLS13", |
| 6341 | config: Config{ |
| 6342 | MaxVersion: VersionTLS13, |
| 6343 | Bugs: ProtocolBugs{ |
| 6344 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6345 | }, |
| 6346 | }, |
| 6347 | shouldFail: true, |
| 6348 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6349 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6350 | } |
| 6351 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6352 | func addDTLSReplayTests() { |
| 6353 | // Test that sequence number replays are detected. |
| 6354 | testCases = append(testCases, testCase{ |
| 6355 | protocol: dtls, |
| 6356 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6357 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6358 | replayWrites: true, |
| 6359 | }) |
| 6360 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6361 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6362 | // than the retransmit window. |
| 6363 | testCases = append(testCases, testCase{ |
| 6364 | protocol: dtls, |
| 6365 | name: "DTLS-Replay-LargeGaps", |
| 6366 | config: Config{ |
| 6367 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6368 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6369 | return in * 127 |
| 6370 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6371 | }, |
| 6372 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6373 | messageCount: 200, |
| 6374 | replayWrites: true, |
| 6375 | }) |
| 6376 | |
| 6377 | // Test the incoming sequence number changing non-monotonically. |
| 6378 | testCases = append(testCases, testCase{ |
| 6379 | protocol: dtls, |
| 6380 | name: "DTLS-Replay-NonMonotonic", |
| 6381 | config: Config{ |
| 6382 | Bugs: ProtocolBugs{ |
| 6383 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6384 | return in ^ 31 |
| 6385 | }, |
| 6386 | }, |
| 6387 | }, |
| 6388 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6389 | replayWrites: true, |
| 6390 | }) |
| 6391 | } |
| 6392 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6393 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6394 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6395 | id signatureAlgorithm |
| 6396 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6397 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6398 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6399 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6400 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6401 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6402 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6403 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6404 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6405 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6406 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6407 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6408 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6409 | // Tests for key types prior to TLS 1.2. |
| 6410 | {"RSA", 0, testCertRSA}, |
| 6411 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6412 | } |
| 6413 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6414 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6415 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6416 | |
| 6417 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6418 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6419 | // versions a signing cipher. |
| 6420 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6421 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6422 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6423 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6424 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6425 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6426 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6427 | } |
| 6428 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6429 | var allAlgorithms []signatureAlgorithm |
| 6430 | for _, alg := range testSignatureAlgorithms { |
| 6431 | if alg.id != 0 { |
| 6432 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6433 | } |
| 6434 | } |
| 6435 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6436 | // Make sure each signature algorithm works. Include some fake values in |
| 6437 | // the list and ensure they're ignored. |
| 6438 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6439 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6440 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6441 | continue |
| 6442 | } |
| 6443 | |
| 6444 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6445 | // or remove it in C. |
| 6446 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6447 | continue |
| 6448 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6449 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6450 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6451 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6452 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6453 | shouldSignFail = true |
| 6454 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6455 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6456 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6457 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6458 | shouldSignFail = true |
| 6459 | shouldVerifyFail = true |
| 6460 | } |
| 6461 | |
| 6462 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6463 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6464 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6465 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6466 | |
| 6467 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6468 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6469 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6470 | } |
| 6471 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6472 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6473 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6474 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6475 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6476 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6477 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6478 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6479 | config: Config{ |
| 6480 | MaxVersion: ver.version, |
| 6481 | ClientAuth: RequireAnyClientCert, |
| 6482 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6483 | fakeSigAlg1, |
| 6484 | alg.id, |
| 6485 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6486 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6487 | }, |
| 6488 | flags: []string{ |
| 6489 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6490 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6491 | "-enable-all-curves", |
| 6492 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6493 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6494 | expectedError: signError, |
| 6495 | expectedPeerSignatureAlgorithm: alg.id, |
| 6496 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6497 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6498 | testCases = append(testCases, testCase{ |
| 6499 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6500 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6501 | config: Config{ |
| 6502 | MaxVersion: ver.version, |
| 6503 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6504 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6505 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6506 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6507 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6508 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6509 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6510 | // Some signature algorithms may not be advertised. |
| 6511 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6512 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6513 | }, |
| 6514 | flags: []string{ |
| 6515 | "-require-any-client-certificate", |
| 6516 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6517 | "-enable-all-curves", |
| 6518 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6519 | // Resume the session to assert the peer signature |
| 6520 | // algorithm is reported on both handshakes. |
| 6521 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6522 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6523 | expectedError: verifyError, |
| 6524 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6525 | |
| 6526 | testCases = append(testCases, testCase{ |
| 6527 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6528 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6529 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6530 | MaxVersion: ver.version, |
| 6531 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6532 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6533 | fakeSigAlg1, |
| 6534 | alg.id, |
| 6535 | fakeSigAlg2, |
| 6536 | }, |
| 6537 | }, |
| 6538 | flags: []string{ |
| 6539 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6540 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6541 | "-enable-all-curves", |
| 6542 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6543 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6544 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6545 | expectedPeerSignatureAlgorithm: alg.id, |
| 6546 | }) |
| 6547 | |
| 6548 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6549 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6550 | config: Config{ |
| 6551 | MaxVersion: ver.version, |
| 6552 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6553 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6554 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6555 | alg.id, |
| 6556 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6557 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6558 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6559 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6560 | // Some signature algorithms may not be advertised. |
| 6561 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6562 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6563 | }, |
| 6564 | flags: []string{ |
| 6565 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6566 | "-enable-all-curves", |
| 6567 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6568 | // Resume the session to assert the peer signature |
| 6569 | // algorithm is reported on both handshakes. |
| 6570 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6571 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6572 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6573 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6574 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6575 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6576 | testCases = append(testCases, testCase{ |
| 6577 | testType: serverTest, |
| 6578 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6579 | config: Config{ |
| 6580 | MaxVersion: ver.version, |
| 6581 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6582 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6583 | alg.id, |
| 6584 | }, |
| 6585 | Bugs: ProtocolBugs{ |
| 6586 | InvalidSignature: true, |
| 6587 | }, |
| 6588 | }, |
| 6589 | flags: []string{ |
| 6590 | "-require-any-client-certificate", |
| 6591 | "-enable-all-curves", |
| 6592 | }, |
| 6593 | shouldFail: true, |
| 6594 | expectedError: ":BAD_SIGNATURE:", |
| 6595 | }) |
| 6596 | |
| 6597 | testCases = append(testCases, testCase{ |
| 6598 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6599 | config: Config{ |
| 6600 | MaxVersion: ver.version, |
| 6601 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6602 | CipherSuites: signingCiphers, |
| 6603 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6604 | alg.id, |
| 6605 | }, |
| 6606 | Bugs: ProtocolBugs{ |
| 6607 | InvalidSignature: true, |
| 6608 | }, |
| 6609 | }, |
| 6610 | flags: []string{"-enable-all-curves"}, |
| 6611 | shouldFail: true, |
| 6612 | expectedError: ":BAD_SIGNATURE:", |
| 6613 | }) |
| 6614 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6615 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6616 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6617 | testCases = append(testCases, testCase{ |
| 6618 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6619 | config: Config{ |
| 6620 | MaxVersion: ver.version, |
| 6621 | ClientAuth: RequireAnyClientCert, |
| 6622 | VerifySignatureAlgorithms: allAlgorithms, |
| 6623 | }, |
| 6624 | flags: []string{ |
| 6625 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6626 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6627 | "-enable-all-curves", |
| 6628 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6629 | }, |
| 6630 | expectedPeerSignatureAlgorithm: alg.id, |
| 6631 | }) |
| 6632 | |
| 6633 | testCases = append(testCases, testCase{ |
| 6634 | testType: serverTest, |
| 6635 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6636 | config: Config{ |
| 6637 | MaxVersion: ver.version, |
| 6638 | CipherSuites: signingCiphers, |
| 6639 | VerifySignatureAlgorithms: allAlgorithms, |
| 6640 | }, |
| 6641 | flags: []string{ |
| 6642 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6643 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6644 | "-enable-all-curves", |
| 6645 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6646 | }, |
| 6647 | expectedPeerSignatureAlgorithm: alg.id, |
| 6648 | }) |
| 6649 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6650 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6651 | } |
| 6652 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6653 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6654 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6655 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6656 | config: Config{ |
| 6657 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6658 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6659 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6660 | signatureECDSAWithP521AndSHA512, |
| 6661 | signatureRSAPKCS1WithSHA384, |
| 6662 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6663 | }, |
| 6664 | }, |
| 6665 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6666 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6667 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6668 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6669 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6670 | }) |
| 6671 | |
| 6672 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6673 | name: "ClientAuth-SignatureType-TLS13", |
| 6674 | config: Config{ |
| 6675 | ClientAuth: RequireAnyClientCert, |
| 6676 | MaxVersion: VersionTLS13, |
| 6677 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6678 | signatureECDSAWithP521AndSHA512, |
| 6679 | signatureRSAPKCS1WithSHA384, |
| 6680 | signatureRSAPSSWithSHA384, |
| 6681 | signatureECDSAWithSHA1, |
| 6682 | }, |
| 6683 | }, |
| 6684 | flags: []string{ |
| 6685 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6686 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6687 | }, |
| 6688 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6689 | }) |
| 6690 | |
| 6691 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6692 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6693 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6694 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6695 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6696 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6697 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6698 | signatureECDSAWithP521AndSHA512, |
| 6699 | signatureRSAPKCS1WithSHA384, |
| 6700 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6701 | }, |
| 6702 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6703 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6704 | }) |
| 6705 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6706 | testCases = append(testCases, testCase{ |
| 6707 | testType: serverTest, |
| 6708 | name: "ServerAuth-SignatureType-TLS13", |
| 6709 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6710 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6711 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6712 | signatureECDSAWithP521AndSHA512, |
| 6713 | signatureRSAPKCS1WithSHA384, |
| 6714 | signatureRSAPSSWithSHA384, |
| 6715 | signatureECDSAWithSHA1, |
| 6716 | }, |
| 6717 | }, |
| 6718 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6719 | }) |
| 6720 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6721 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6722 | testCases = append(testCases, testCase{ |
| 6723 | testType: serverTest, |
| 6724 | name: "Verify-ClientAuth-SignatureType", |
| 6725 | config: Config{ |
| 6726 | MaxVersion: VersionTLS12, |
| 6727 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6728 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6729 | signatureRSAPKCS1WithSHA256, |
| 6730 | }, |
| 6731 | Bugs: ProtocolBugs{ |
| 6732 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6733 | }, |
| 6734 | }, |
| 6735 | flags: []string{ |
| 6736 | "-require-any-client-certificate", |
| 6737 | }, |
| 6738 | shouldFail: true, |
| 6739 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6740 | }) |
| 6741 | |
| 6742 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6743 | testType: serverTest, |
| 6744 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6745 | config: Config{ |
| 6746 | MaxVersion: VersionTLS13, |
| 6747 | Certificates: []Certificate{rsaCertificate}, |
| 6748 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6749 | signatureRSAPSSWithSHA256, |
| 6750 | }, |
| 6751 | Bugs: ProtocolBugs{ |
| 6752 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6753 | }, |
| 6754 | }, |
| 6755 | flags: []string{ |
| 6756 | "-require-any-client-certificate", |
| 6757 | }, |
| 6758 | shouldFail: true, |
| 6759 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6760 | }) |
| 6761 | |
| 6762 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6763 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6764 | config: Config{ |
| 6765 | MaxVersion: VersionTLS12, |
| 6766 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6767 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6768 | signatureRSAPKCS1WithSHA256, |
| 6769 | }, |
| 6770 | Bugs: ProtocolBugs{ |
| 6771 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6772 | }, |
| 6773 | }, |
| 6774 | shouldFail: true, |
| 6775 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6776 | }) |
| 6777 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6778 | testCases = append(testCases, testCase{ |
| 6779 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6780 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6781 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6782 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6783 | signatureRSAPSSWithSHA256, |
| 6784 | }, |
| 6785 | Bugs: ProtocolBugs{ |
| 6786 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6787 | }, |
| 6788 | }, |
| 6789 | shouldFail: true, |
| 6790 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6791 | }) |
| 6792 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6793 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6794 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6795 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6796 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6797 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6798 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6799 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6800 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6801 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6802 | }, |
| 6803 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6804 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6805 | }, |
| 6806 | }, |
| 6807 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6808 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6809 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6810 | }, |
| 6811 | }) |
| 6812 | |
| 6813 | testCases = append(testCases, testCase{ |
| 6814 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6815 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6816 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6817 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6818 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6819 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6820 | }, |
| 6821 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6822 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6823 | }, |
| 6824 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6825 | flags: []string{ |
| 6826 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6827 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6828 | }, |
| 6829 | }) |
| 6830 | |
| 6831 | testCases = append(testCases, testCase{ |
| 6832 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6833 | config: Config{ |
| 6834 | MaxVersion: VersionTLS12, |
| 6835 | ClientAuth: RequireAnyClientCert, |
| 6836 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6837 | signatureECDSAWithSHA1, |
| 6838 | }, |
| 6839 | Bugs: ProtocolBugs{ |
| 6840 | NoSignatureAlgorithms: true, |
| 6841 | }, |
| 6842 | }, |
| 6843 | flags: []string{ |
| 6844 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6845 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6846 | }, |
| 6847 | }) |
| 6848 | |
| 6849 | testCases = append(testCases, testCase{ |
| 6850 | testType: serverTest, |
| 6851 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6852 | config: Config{ |
| 6853 | MaxVersion: VersionTLS12, |
| 6854 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6855 | signatureECDSAWithSHA1, |
| 6856 | }, |
| 6857 | Bugs: ProtocolBugs{ |
| 6858 | NoSignatureAlgorithms: true, |
| 6859 | }, |
| 6860 | }, |
| 6861 | flags: []string{ |
| 6862 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6863 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6864 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6865 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6866 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6867 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6868 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6869 | config: Config{ |
| 6870 | MaxVersion: VersionTLS13, |
| 6871 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6872 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6873 | signatureRSAPKCS1WithSHA1, |
| 6874 | }, |
| 6875 | Bugs: ProtocolBugs{ |
| 6876 | NoSignatureAlgorithms: true, |
| 6877 | }, |
| 6878 | }, |
| 6879 | flags: []string{ |
| 6880 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6881 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6882 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6883 | shouldFail: true, |
| 6884 | // An empty CertificateRequest signature algorithm list is a |
| 6885 | // syntax error in TLS 1.3. |
| 6886 | expectedError: ":DECODE_ERROR:", |
| 6887 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6888 | }) |
| 6889 | |
| 6890 | testCases = append(testCases, testCase{ |
| 6891 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6892 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6893 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6894 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6895 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6896 | signatureRSAPKCS1WithSHA1, |
| 6897 | }, |
| 6898 | Bugs: ProtocolBugs{ |
| 6899 | NoSignatureAlgorithms: true, |
| 6900 | }, |
| 6901 | }, |
| 6902 | shouldFail: true, |
| 6903 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6904 | }) |
| 6905 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6906 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6907 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6908 | testCases = append(testCases, testCase{ |
| 6909 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6910 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6911 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6912 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6913 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6914 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6915 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6916 | }, |
| 6917 | Bugs: ProtocolBugs{ |
| 6918 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6919 | }, |
| 6920 | }, |
| 6921 | flags: []string{"-require-any-client-certificate"}, |
| 6922 | shouldFail: true, |
| 6923 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6924 | }) |
| 6925 | |
| 6926 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6927 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6928 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6929 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6930 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6931 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6932 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6933 | }, |
| 6934 | Bugs: ProtocolBugs{ |
| 6935 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6936 | }, |
| 6937 | }, |
| 6938 | shouldFail: true, |
| 6939 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6940 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6941 | testCases = append(testCases, testCase{ |
| 6942 | testType: serverTest, |
| 6943 | name: "ClientAuth-Enforced-TLS13", |
| 6944 | config: Config{ |
| 6945 | MaxVersion: VersionTLS13, |
| 6946 | Certificates: []Certificate{rsaCertificate}, |
| 6947 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6948 | signatureRSAPKCS1WithMD5, |
| 6949 | }, |
| 6950 | Bugs: ProtocolBugs{ |
| 6951 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6952 | IgnoreSignatureVersionChecks: true, |
| 6953 | }, |
| 6954 | }, |
| 6955 | flags: []string{"-require-any-client-certificate"}, |
| 6956 | shouldFail: true, |
| 6957 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6958 | }) |
| 6959 | |
| 6960 | testCases = append(testCases, testCase{ |
| 6961 | name: "ServerAuth-Enforced-TLS13", |
| 6962 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6963 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6964 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6965 | signatureRSAPKCS1WithMD5, |
| 6966 | }, |
| 6967 | Bugs: ProtocolBugs{ |
| 6968 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6969 | IgnoreSignatureVersionChecks: true, |
| 6970 | }, |
| 6971 | }, |
| 6972 | shouldFail: true, |
| 6973 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6974 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6975 | |
| 6976 | // Test that the agreed upon digest respects the client preferences and |
| 6977 | // the server digests. |
| 6978 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6979 | name: "NoCommonAlgorithms-Digests", |
| 6980 | config: Config{ |
| 6981 | MaxVersion: VersionTLS12, |
| 6982 | ClientAuth: RequireAnyClientCert, |
| 6983 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6984 | signatureRSAPKCS1WithSHA512, |
| 6985 | signatureRSAPKCS1WithSHA1, |
| 6986 | }, |
| 6987 | }, |
| 6988 | flags: []string{ |
| 6989 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6990 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6991 | "-digest-prefs", "SHA256", |
| 6992 | }, |
| 6993 | shouldFail: true, |
| 6994 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6995 | }) |
| 6996 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6997 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6998 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6999 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7000 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7001 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7002 | signatureRSAPKCS1WithSHA512, |
| 7003 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7004 | }, |
| 7005 | }, |
| 7006 | flags: []string{ |
| 7007 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7008 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7009 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7010 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7011 | shouldFail: true, |
| 7012 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7013 | }) |
| 7014 | testCases = append(testCases, testCase{ |
| 7015 | name: "NoCommonAlgorithms-TLS13", |
| 7016 | config: Config{ |
| 7017 | MaxVersion: VersionTLS13, |
| 7018 | ClientAuth: RequireAnyClientCert, |
| 7019 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7020 | signatureRSAPSSWithSHA512, |
| 7021 | signatureRSAPSSWithSHA384, |
| 7022 | }, |
| 7023 | }, |
| 7024 | flags: []string{ |
| 7025 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7026 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7027 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7028 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7029 | shouldFail: true, |
| 7030 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7031 | }) |
| 7032 | testCases = append(testCases, testCase{ |
| 7033 | name: "Agree-Digest-SHA256", |
| 7034 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7035 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7036 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7037 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7038 | signatureRSAPKCS1WithSHA1, |
| 7039 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7040 | }, |
| 7041 | }, |
| 7042 | flags: []string{ |
| 7043 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7044 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7045 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7046 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7047 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7048 | }) |
| 7049 | testCases = append(testCases, testCase{ |
| 7050 | name: "Agree-Digest-SHA1", |
| 7051 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7052 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7053 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7054 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7055 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7056 | }, |
| 7057 | }, |
| 7058 | flags: []string{ |
| 7059 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7060 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7061 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7062 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7063 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7064 | }) |
| 7065 | testCases = append(testCases, testCase{ |
| 7066 | name: "Agree-Digest-Default", |
| 7067 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7068 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7069 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7070 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7071 | signatureRSAPKCS1WithSHA256, |
| 7072 | signatureECDSAWithP256AndSHA256, |
| 7073 | signatureRSAPKCS1WithSHA1, |
| 7074 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7075 | }, |
| 7076 | }, |
| 7077 | flags: []string{ |
| 7078 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7079 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7080 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7081 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7082 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7083 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7084 | // Test that the signing preference list may include extra algorithms |
| 7085 | // without negotiation problems. |
| 7086 | testCases = append(testCases, testCase{ |
| 7087 | testType: serverTest, |
| 7088 | name: "FilterExtraAlgorithms", |
| 7089 | config: Config{ |
| 7090 | MaxVersion: VersionTLS12, |
| 7091 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7092 | signatureRSAPKCS1WithSHA256, |
| 7093 | }, |
| 7094 | }, |
| 7095 | flags: []string{ |
| 7096 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7097 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7098 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7099 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7100 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7101 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7102 | }, |
| 7103 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7104 | }) |
| 7105 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7106 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7107 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7108 | testCases = append(testCases, testCase{ |
| 7109 | name: "CheckLeafCurve", |
| 7110 | config: Config{ |
| 7111 | MaxVersion: VersionTLS12, |
| 7112 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7113 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7114 | }, |
| 7115 | flags: []string{"-p384-only"}, |
| 7116 | shouldFail: true, |
| 7117 | expectedError: ":BAD_ECC_CERT:", |
| 7118 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7119 | |
| 7120 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7121 | testCases = append(testCases, testCase{ |
| 7122 | name: "CheckLeafCurve-TLS13", |
| 7123 | config: Config{ |
| 7124 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7125 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7126 | }, |
| 7127 | flags: []string{"-p384-only"}, |
| 7128 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7129 | |
| 7130 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7131 | testCases = append(testCases, testCase{ |
| 7132 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7133 | config: Config{ |
| 7134 | MaxVersion: VersionTLS12, |
| 7135 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7136 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7137 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7138 | signatureECDSAWithP384AndSHA384, |
| 7139 | }, |
| 7140 | }, |
| 7141 | }) |
| 7142 | |
| 7143 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7144 | testCases = append(testCases, testCase{ |
| 7145 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7146 | config: Config{ |
| 7147 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7148 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7149 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7150 | signatureECDSAWithP384AndSHA384, |
| 7151 | }, |
| 7152 | Bugs: ProtocolBugs{ |
| 7153 | SkipECDSACurveCheck: true, |
| 7154 | }, |
| 7155 | }, |
| 7156 | shouldFail: true, |
| 7157 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7158 | }) |
| 7159 | |
| 7160 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7161 | // account. |
| 7162 | testCases = append(testCases, testCase{ |
| 7163 | testType: serverTest, |
| 7164 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7165 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7166 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7167 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7168 | signatureECDSAWithP384AndSHA384, |
| 7169 | signatureECDSAWithP256AndSHA256, |
| 7170 | }, |
| 7171 | }, |
| 7172 | flags: []string{ |
| 7173 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7174 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7175 | }, |
| 7176 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7177 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7178 | |
| 7179 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7180 | // server does not attempt to sign in that case. |
| 7181 | testCases = append(testCases, testCase{ |
| 7182 | testType: serverTest, |
| 7183 | name: "RSA-PSS-Large", |
| 7184 | config: Config{ |
| 7185 | MaxVersion: VersionTLS13, |
| 7186 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7187 | signatureRSAPSSWithSHA512, |
| 7188 | }, |
| 7189 | }, |
| 7190 | flags: []string{ |
| 7191 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7192 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7193 | }, |
| 7194 | shouldFail: true, |
| 7195 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7196 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7197 | |
| 7198 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7199 | testCases = append(testCases, testCase{ |
| 7200 | testType: clientTest, |
| 7201 | name: "RSA-PSS-Default-Verify", |
| 7202 | config: Config{ |
| 7203 | MaxVersion: VersionTLS12, |
| 7204 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7205 | signatureRSAPSSWithSHA256, |
| 7206 | }, |
| 7207 | }, |
| 7208 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7209 | }) |
| 7210 | |
| 7211 | testCases = append(testCases, testCase{ |
| 7212 | testType: serverTest, |
| 7213 | name: "RSA-PSS-Default-Sign", |
| 7214 | config: Config{ |
| 7215 | MaxVersion: VersionTLS12, |
| 7216 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7217 | signatureRSAPSSWithSHA256, |
| 7218 | }, |
| 7219 | }, |
| 7220 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7221 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7222 | } |
| 7223 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7224 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7225 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7226 | var timeouts = []time.Duration{ |
| 7227 | 1 * time.Second, |
| 7228 | 2 * time.Second, |
| 7229 | 4 * time.Second, |
| 7230 | 8 * time.Second, |
| 7231 | 16 * time.Second, |
| 7232 | 32 * time.Second, |
| 7233 | 60 * time.Second, |
| 7234 | 60 * time.Second, |
| 7235 | 60 * time.Second, |
| 7236 | 60 * time.Second, |
| 7237 | 60 * time.Second, |
| 7238 | 60 * time.Second, |
| 7239 | 60 * time.Second, |
| 7240 | } |
| 7241 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7242 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7243 | // initial timeout duration was set to 250ms. |
| 7244 | var shortTimeouts = []time.Duration{ |
| 7245 | 250 * time.Millisecond, |
| 7246 | 500 * time.Millisecond, |
| 7247 | 1 * time.Second, |
| 7248 | 2 * time.Second, |
| 7249 | 4 * time.Second, |
| 7250 | 8 * time.Second, |
| 7251 | 16 * time.Second, |
| 7252 | 32 * time.Second, |
| 7253 | 60 * time.Second, |
| 7254 | 60 * time.Second, |
| 7255 | 60 * time.Second, |
| 7256 | 60 * time.Second, |
| 7257 | 60 * time.Second, |
| 7258 | } |
| 7259 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7260 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7261 | // These tests work by coordinating some behavior on both the shim and |
| 7262 | // the runner. |
| 7263 | // |
| 7264 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7265 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7266 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7267 | // timeout in the shim and acts as a synchronization point to help the |
| 7268 | // runner bracket each handshake flight. |
| 7269 | // |
| 7270 | // We assume the shim does not read from the channel eagerly. It must |
| 7271 | // first wait until it has sent flight N and is ready to receive |
| 7272 | // handshake flight N+1. At this point, it will process the timeout |
| 7273 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7274 | // as if the shim was idle for the specified amount of time. |
| 7275 | // |
| 7276 | // The runner then drops all packets received before the ACK and |
| 7277 | // continues waiting for flight N. This ordering results in one attempt |
| 7278 | // at sending flight N to be dropped. For the test to complete, the |
| 7279 | // shim must send flight N again, testing that the shim implements DTLS |
| 7280 | // retransmit on a timeout. |
| 7281 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7282 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7283 | // likely be more epochs to cross and the final message's retransmit may |
| 7284 | // be more complex. |
| 7285 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7286 | for _, async := range []bool{true, false} { |
| 7287 | var tests []testCase |
| 7288 | |
| 7289 | // Test that this is indeed the timeout schedule. Stress all |
| 7290 | // four patterns of handshake. |
| 7291 | for i := 1; i < len(timeouts); i++ { |
| 7292 | number := strconv.Itoa(i) |
| 7293 | tests = append(tests, testCase{ |
| 7294 | protocol: dtls, |
| 7295 | name: "DTLS-Retransmit-Client-" + number, |
| 7296 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7297 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7298 | Bugs: ProtocolBugs{ |
| 7299 | TimeoutSchedule: timeouts[:i], |
| 7300 | }, |
| 7301 | }, |
| 7302 | resumeSession: true, |
| 7303 | }) |
| 7304 | tests = append(tests, testCase{ |
| 7305 | protocol: dtls, |
| 7306 | testType: serverTest, |
| 7307 | name: "DTLS-Retransmit-Server-" + number, |
| 7308 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7309 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7310 | Bugs: ProtocolBugs{ |
| 7311 | TimeoutSchedule: timeouts[:i], |
| 7312 | }, |
| 7313 | }, |
| 7314 | resumeSession: true, |
| 7315 | }) |
| 7316 | } |
| 7317 | |
| 7318 | // Test that exceeding the timeout schedule hits a read |
| 7319 | // timeout. |
| 7320 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7321 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7322 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7323 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7324 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7325 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7326 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7327 | }, |
| 7328 | }, |
| 7329 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7330 | shouldFail: true, |
| 7331 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7332 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7333 | |
| 7334 | if async { |
| 7335 | // Test that timeout handling has a fudge factor, due to API |
| 7336 | // problems. |
| 7337 | tests = append(tests, testCase{ |
| 7338 | protocol: dtls, |
| 7339 | name: "DTLS-Retransmit-Fudge", |
| 7340 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7341 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7342 | Bugs: ProtocolBugs{ |
| 7343 | TimeoutSchedule: []time.Duration{ |
| 7344 | timeouts[0] - 10*time.Millisecond, |
| 7345 | }, |
| 7346 | }, |
| 7347 | }, |
| 7348 | resumeSession: true, |
| 7349 | }) |
| 7350 | } |
| 7351 | |
| 7352 | // Test that the final Finished retransmitting isn't |
| 7353 | // duplicated if the peer badly fragments everything. |
| 7354 | tests = append(tests, testCase{ |
| 7355 | testType: serverTest, |
| 7356 | protocol: dtls, |
| 7357 | name: "DTLS-Retransmit-Fragmented", |
| 7358 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7359 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7360 | Bugs: ProtocolBugs{ |
| 7361 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7362 | MaxHandshakeRecordLength: 2, |
| 7363 | }, |
| 7364 | }, |
| 7365 | }) |
| 7366 | |
| 7367 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7368 | tests = append(tests, testCase{ |
| 7369 | protocol: dtls, |
| 7370 | name: "DTLS-Retransmit-Short-Client", |
| 7371 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7372 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7373 | Bugs: ProtocolBugs{ |
| 7374 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7375 | }, |
| 7376 | }, |
| 7377 | resumeSession: true, |
| 7378 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 7379 | }) |
| 7380 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7381 | protocol: dtls, |
| 7382 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7383 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7384 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7385 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7386 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7387 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7388 | }, |
| 7389 | }, |
| 7390 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7391 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7392 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7393 | |
| 7394 | for _, test := range tests { |
| 7395 | if async { |
| 7396 | test.name += "-Async" |
| 7397 | test.flags = append(test.flags, "-async") |
| 7398 | } |
| 7399 | |
| 7400 | testCases = append(testCases, test) |
| 7401 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7402 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7403 | } |
| 7404 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7405 | func addExportKeyingMaterialTests() { |
| 7406 | for _, vers := range tlsVersions { |
| 7407 | if vers.version == VersionSSL30 { |
| 7408 | continue |
| 7409 | } |
| 7410 | testCases = append(testCases, testCase{ |
| 7411 | name: "ExportKeyingMaterial-" + vers.name, |
| 7412 | config: Config{ |
| 7413 | MaxVersion: vers.version, |
| 7414 | }, |
| 7415 | exportKeyingMaterial: 1024, |
| 7416 | exportLabel: "label", |
| 7417 | exportContext: "context", |
| 7418 | useExportContext: true, |
| 7419 | }) |
| 7420 | testCases = append(testCases, testCase{ |
| 7421 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7422 | config: Config{ |
| 7423 | MaxVersion: vers.version, |
| 7424 | }, |
| 7425 | exportKeyingMaterial: 1024, |
| 7426 | }) |
| 7427 | testCases = append(testCases, testCase{ |
| 7428 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7429 | config: Config{ |
| 7430 | MaxVersion: vers.version, |
| 7431 | }, |
| 7432 | exportKeyingMaterial: 1024, |
| 7433 | useExportContext: true, |
| 7434 | }) |
| 7435 | testCases = append(testCases, testCase{ |
| 7436 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7437 | config: Config{ |
| 7438 | MaxVersion: vers.version, |
| 7439 | }, |
| 7440 | exportKeyingMaterial: 1, |
| 7441 | exportLabel: "label", |
| 7442 | exportContext: "context", |
| 7443 | useExportContext: true, |
| 7444 | }) |
| 7445 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7446 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7447 | testCases = append(testCases, testCase{ |
| 7448 | name: "ExportKeyingMaterial-SSL3", |
| 7449 | config: Config{ |
| 7450 | MaxVersion: VersionSSL30, |
| 7451 | }, |
| 7452 | exportKeyingMaterial: 1024, |
| 7453 | exportLabel: "label", |
| 7454 | exportContext: "context", |
| 7455 | useExportContext: true, |
| 7456 | shouldFail: true, |
| 7457 | expectedError: "failed to export keying material", |
| 7458 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7459 | |
| 7460 | // Exporters work during a False Start. |
| 7461 | testCases = append(testCases, testCase{ |
| 7462 | name: "ExportKeyingMaterial-FalseStart", |
| 7463 | config: Config{ |
| 7464 | MaxVersion: VersionTLS12, |
| 7465 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7466 | NextProtos: []string{"foo"}, |
| 7467 | Bugs: ProtocolBugs{ |
| 7468 | ExpectFalseStart: true, |
| 7469 | }, |
| 7470 | }, |
| 7471 | flags: []string{ |
| 7472 | "-false-start", |
| 7473 | "-advertise-alpn", "\x03foo", |
| 7474 | }, |
| 7475 | shimWritesFirst: true, |
| 7476 | exportKeyingMaterial: 1024, |
| 7477 | exportLabel: "label", |
| 7478 | exportContext: "context", |
| 7479 | useExportContext: true, |
| 7480 | }) |
| 7481 | |
| 7482 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7483 | // triggering the exporter after every SSL_read call and configuring the |
| 7484 | // shim to run asynchronously. |
| 7485 | testCases = append(testCases, testCase{ |
| 7486 | name: "ExportKeyingMaterial-Renegotiate", |
| 7487 | config: Config{ |
| 7488 | MaxVersion: VersionTLS12, |
| 7489 | }, |
| 7490 | renegotiate: 1, |
| 7491 | flags: []string{ |
| 7492 | "-async", |
| 7493 | "-use-exporter-between-reads", |
| 7494 | "-renegotiate-freely", |
| 7495 | "-expect-total-renegotiations", "1", |
| 7496 | }, |
| 7497 | shouldFail: true, |
| 7498 | expectedError: "failed to export keying material", |
| 7499 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7500 | } |
| 7501 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7502 | func addTLSUniqueTests() { |
| 7503 | for _, isClient := range []bool{false, true} { |
| 7504 | for _, isResumption := range []bool{false, true} { |
| 7505 | for _, hasEMS := range []bool{false, true} { |
| 7506 | var suffix string |
| 7507 | if isResumption { |
| 7508 | suffix = "Resume-" |
| 7509 | } else { |
| 7510 | suffix = "Full-" |
| 7511 | } |
| 7512 | |
| 7513 | if hasEMS { |
| 7514 | suffix += "EMS-" |
| 7515 | } else { |
| 7516 | suffix += "NoEMS-" |
| 7517 | } |
| 7518 | |
| 7519 | if isClient { |
| 7520 | suffix += "Client" |
| 7521 | } else { |
| 7522 | suffix += "Server" |
| 7523 | } |
| 7524 | |
| 7525 | test := testCase{ |
| 7526 | name: "TLSUnique-" + suffix, |
| 7527 | testTLSUnique: true, |
| 7528 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7529 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7530 | Bugs: ProtocolBugs{ |
| 7531 | NoExtendedMasterSecret: !hasEMS, |
| 7532 | }, |
| 7533 | }, |
| 7534 | } |
| 7535 | |
| 7536 | if isResumption { |
| 7537 | test.resumeSession = true |
| 7538 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7539 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7540 | Bugs: ProtocolBugs{ |
| 7541 | NoExtendedMasterSecret: !hasEMS, |
| 7542 | }, |
| 7543 | } |
| 7544 | } |
| 7545 | |
| 7546 | if isResumption && !hasEMS { |
| 7547 | test.shouldFail = true |
| 7548 | test.expectedError = "failed to get tls-unique" |
| 7549 | } |
| 7550 | |
| 7551 | testCases = append(testCases, test) |
| 7552 | } |
| 7553 | } |
| 7554 | } |
| 7555 | } |
| 7556 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7557 | func addCustomExtensionTests() { |
| 7558 | expectedContents := "custom extension" |
| 7559 | emptyString := "" |
| 7560 | |
| 7561 | for _, isClient := range []bool{false, true} { |
| 7562 | suffix := "Server" |
| 7563 | flag := "-enable-server-custom-extension" |
| 7564 | testType := serverTest |
| 7565 | if isClient { |
| 7566 | suffix = "Client" |
| 7567 | flag = "-enable-client-custom-extension" |
| 7568 | testType = clientTest |
| 7569 | } |
| 7570 | |
| 7571 | testCases = append(testCases, testCase{ |
| 7572 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7573 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7574 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7575 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7576 | Bugs: ProtocolBugs{ |
| 7577 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7578 | ExpectedCustomExtension: &expectedContents, |
| 7579 | }, |
| 7580 | }, |
| 7581 | flags: []string{flag}, |
| 7582 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7583 | testCases = append(testCases, testCase{ |
| 7584 | testType: testType, |
| 7585 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7586 | config: Config{ |
| 7587 | MaxVersion: VersionTLS13, |
| 7588 | Bugs: ProtocolBugs{ |
| 7589 | CustomExtension: expectedContents, |
| 7590 | ExpectedCustomExtension: &expectedContents, |
| 7591 | }, |
| 7592 | }, |
| 7593 | flags: []string{flag}, |
| 7594 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7595 | |
| 7596 | // If the parse callback fails, the handshake should also fail. |
| 7597 | testCases = append(testCases, testCase{ |
| 7598 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7599 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7600 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7601 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7602 | Bugs: ProtocolBugs{ |
| 7603 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7604 | ExpectedCustomExtension: &expectedContents, |
| 7605 | }, |
| 7606 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7607 | flags: []string{flag}, |
| 7608 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7609 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7610 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7611 | testCases = append(testCases, testCase{ |
| 7612 | testType: testType, |
| 7613 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7614 | config: Config{ |
| 7615 | MaxVersion: VersionTLS13, |
| 7616 | Bugs: ProtocolBugs{ |
| 7617 | CustomExtension: expectedContents + "foo", |
| 7618 | ExpectedCustomExtension: &expectedContents, |
| 7619 | }, |
| 7620 | }, |
| 7621 | flags: []string{flag}, |
| 7622 | shouldFail: true, |
| 7623 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7624 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7625 | |
| 7626 | // If the add callback fails, the handshake should also fail. |
| 7627 | testCases = append(testCases, testCase{ |
| 7628 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7629 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7630 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7631 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7632 | Bugs: ProtocolBugs{ |
| 7633 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7634 | ExpectedCustomExtension: &expectedContents, |
| 7635 | }, |
| 7636 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7637 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7638 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7639 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7640 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7641 | testCases = append(testCases, testCase{ |
| 7642 | testType: testType, |
| 7643 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7644 | config: Config{ |
| 7645 | MaxVersion: VersionTLS13, |
| 7646 | Bugs: ProtocolBugs{ |
| 7647 | CustomExtension: expectedContents, |
| 7648 | ExpectedCustomExtension: &expectedContents, |
| 7649 | }, |
| 7650 | }, |
| 7651 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7652 | shouldFail: true, |
| 7653 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7654 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7655 | |
| 7656 | // If the add callback returns zero, no extension should be |
| 7657 | // added. |
| 7658 | skipCustomExtension := expectedContents |
| 7659 | if isClient { |
| 7660 | // For the case where the client skips sending the |
| 7661 | // custom extension, the server must not “echo” it. |
| 7662 | skipCustomExtension = "" |
| 7663 | } |
| 7664 | testCases = append(testCases, testCase{ |
| 7665 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7666 | name: "CustomExtensions-Skip-" + 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: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7671 | ExpectedCustomExtension: &emptyString, |
| 7672 | }, |
| 7673 | }, |
| 7674 | flags: []string{flag, "-custom-extension-skip"}, |
| 7675 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7676 | testCases = append(testCases, testCase{ |
| 7677 | testType: testType, |
| 7678 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7679 | config: Config{ |
| 7680 | MaxVersion: VersionTLS13, |
| 7681 | Bugs: ProtocolBugs{ |
| 7682 | CustomExtension: skipCustomExtension, |
| 7683 | ExpectedCustomExtension: &emptyString, |
| 7684 | }, |
| 7685 | }, |
| 7686 | flags: []string{flag, "-custom-extension-skip"}, |
| 7687 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7688 | } |
| 7689 | |
| 7690 | // The custom extension add callback should not be called if the client |
| 7691 | // doesn't send the extension. |
| 7692 | testCases = append(testCases, testCase{ |
| 7693 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7694 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7695 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7696 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7697 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7698 | ExpectedCustomExtension: &emptyString, |
| 7699 | }, |
| 7700 | }, |
| 7701 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7702 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7703 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7704 | testCases = append(testCases, testCase{ |
| 7705 | testType: serverTest, |
| 7706 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7707 | config: Config{ |
| 7708 | MaxVersion: VersionTLS13, |
| 7709 | Bugs: ProtocolBugs{ |
| 7710 | ExpectedCustomExtension: &emptyString, |
| 7711 | }, |
| 7712 | }, |
| 7713 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7714 | }) |
| 7715 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7716 | // Test an unknown extension from the server. |
| 7717 | testCases = append(testCases, testCase{ |
| 7718 | testType: clientTest, |
| 7719 | name: "UnknownExtension-Client", |
| 7720 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7721 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7722 | Bugs: ProtocolBugs{ |
| 7723 | CustomExtension: expectedContents, |
| 7724 | }, |
| 7725 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7726 | shouldFail: true, |
| 7727 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7728 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7729 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7730 | testCases = append(testCases, testCase{ |
| 7731 | testType: clientTest, |
| 7732 | name: "UnknownExtension-Client-TLS13", |
| 7733 | config: Config{ |
| 7734 | MaxVersion: VersionTLS13, |
| 7735 | Bugs: ProtocolBugs{ |
| 7736 | CustomExtension: expectedContents, |
| 7737 | }, |
| 7738 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7739 | shouldFail: true, |
| 7740 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7741 | expectedLocalError: "remote error: unsupported extension", |
| 7742 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7743 | testCases = append(testCases, testCase{ |
| 7744 | testType: clientTest, |
| 7745 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7746 | config: Config{ |
| 7747 | MaxVersion: VersionTLS13, |
| 7748 | Bugs: ProtocolBugs{ |
| 7749 | CustomUnencryptedExtension: expectedContents, |
| 7750 | }, |
| 7751 | }, |
| 7752 | shouldFail: true, |
| 7753 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7754 | // The shim must send an alert, but alerts at this point do not |
| 7755 | // get successfully decrypted by the runner. |
| 7756 | expectedLocalError: "local error: bad record MAC", |
| 7757 | }) |
| 7758 | testCases = append(testCases, testCase{ |
| 7759 | testType: clientTest, |
| 7760 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7761 | config: Config{ |
| 7762 | MaxVersion: VersionTLS13, |
| 7763 | Bugs: ProtocolBugs{ |
| 7764 | SendUnencryptedALPN: "foo", |
| 7765 | }, |
| 7766 | }, |
| 7767 | flags: []string{ |
| 7768 | "-advertise-alpn", "\x03foo\x03bar", |
| 7769 | }, |
| 7770 | shouldFail: true, |
| 7771 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7772 | // The shim must send an alert, but alerts at this point do not |
| 7773 | // get successfully decrypted by the runner. |
| 7774 | expectedLocalError: "local error: bad record MAC", |
| 7775 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7776 | |
| 7777 | // Test a known but unoffered extension from the server. |
| 7778 | testCases = append(testCases, testCase{ |
| 7779 | testType: clientTest, |
| 7780 | name: "UnofferedExtension-Client", |
| 7781 | config: Config{ |
| 7782 | MaxVersion: VersionTLS12, |
| 7783 | Bugs: ProtocolBugs{ |
| 7784 | SendALPN: "alpn", |
| 7785 | }, |
| 7786 | }, |
| 7787 | shouldFail: true, |
| 7788 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7789 | expectedLocalError: "remote error: unsupported extension", |
| 7790 | }) |
| 7791 | testCases = append(testCases, testCase{ |
| 7792 | testType: clientTest, |
| 7793 | name: "UnofferedExtension-Client-TLS13", |
| 7794 | config: Config{ |
| 7795 | MaxVersion: VersionTLS13, |
| 7796 | Bugs: ProtocolBugs{ |
| 7797 | SendALPN: "alpn", |
| 7798 | }, |
| 7799 | }, |
| 7800 | shouldFail: true, |
| 7801 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7802 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7803 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7804 | } |
| 7805 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7806 | func addRSAClientKeyExchangeTests() { |
| 7807 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7808 | testCases = append(testCases, testCase{ |
| 7809 | testType: serverTest, |
| 7810 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7811 | config: Config{ |
| 7812 | // Ensure the ClientHello version and final |
| 7813 | // version are different, to detect if the |
| 7814 | // server uses the wrong one. |
| 7815 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7816 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7817 | Bugs: ProtocolBugs{ |
| 7818 | BadRSAClientKeyExchange: bad, |
| 7819 | }, |
| 7820 | }, |
| 7821 | shouldFail: true, |
| 7822 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7823 | }) |
| 7824 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7825 | |
| 7826 | // The server must compare whatever was in ClientHello.version for the |
| 7827 | // RSA premaster. |
| 7828 | testCases = append(testCases, testCase{ |
| 7829 | testType: serverTest, |
| 7830 | name: "SendClientVersion-RSA", |
| 7831 | config: Config{ |
| 7832 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7833 | Bugs: ProtocolBugs{ |
| 7834 | SendClientVersion: 0x1234, |
| 7835 | }, |
| 7836 | }, |
| 7837 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7838 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7839 | } |
| 7840 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7841 | var testCurves = []struct { |
| 7842 | name string |
| 7843 | id CurveID |
| 7844 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7845 | {"P-256", CurveP256}, |
| 7846 | {"P-384", CurveP384}, |
| 7847 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7848 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7849 | } |
| 7850 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7851 | const bogusCurve = 0x1234 |
| 7852 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7853 | func addCurveTests() { |
| 7854 | for _, curve := range testCurves { |
| 7855 | testCases = append(testCases, testCase{ |
| 7856 | name: "CurveTest-Client-" + curve.name, |
| 7857 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7858 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7859 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7860 | CurvePreferences: []CurveID{curve.id}, |
| 7861 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7862 | flags: []string{ |
| 7863 | "-enable-all-curves", |
| 7864 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7865 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7866 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7867 | }) |
| 7868 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7869 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7870 | config: Config{ |
| 7871 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7872 | CurvePreferences: []CurveID{curve.id}, |
| 7873 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7874 | flags: []string{ |
| 7875 | "-enable-all-curves", |
| 7876 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7877 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7878 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7879 | }) |
| 7880 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7881 | testType: serverTest, |
| 7882 | name: "CurveTest-Server-" + curve.name, |
| 7883 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7884 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7885 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7886 | CurvePreferences: []CurveID{curve.id}, |
| 7887 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7888 | flags: []string{ |
| 7889 | "-enable-all-curves", |
| 7890 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7891 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7892 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7893 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7894 | testCases = append(testCases, testCase{ |
| 7895 | testType: serverTest, |
| 7896 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7897 | config: Config{ |
| 7898 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7899 | CurvePreferences: []CurveID{curve.id}, |
| 7900 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7901 | flags: []string{ |
| 7902 | "-enable-all-curves", |
| 7903 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7904 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7905 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7906 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7907 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7908 | |
| 7909 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7910 | testCases = append(testCases, testCase{ |
| 7911 | testType: serverTest, |
| 7912 | name: "UnknownCurve", |
| 7913 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7914 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7915 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7916 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7917 | }, |
| 7918 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7919 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7920 | // The server must be tolerant to bogus curves. |
| 7921 | testCases = append(testCases, testCase{ |
| 7922 | testType: serverTest, |
| 7923 | name: "UnknownCurve-TLS13", |
| 7924 | config: Config{ |
| 7925 | MaxVersion: VersionTLS13, |
| 7926 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7927 | }, |
| 7928 | }) |
| 7929 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7930 | // The server must not consider ECDHE ciphers when there are no |
| 7931 | // supported curves. |
| 7932 | testCases = append(testCases, testCase{ |
| 7933 | testType: serverTest, |
| 7934 | name: "NoSupportedCurves", |
| 7935 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7936 | MaxVersion: VersionTLS12, |
| 7937 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7938 | Bugs: ProtocolBugs{ |
| 7939 | NoSupportedCurves: true, |
| 7940 | }, |
| 7941 | }, |
| 7942 | shouldFail: true, |
| 7943 | expectedError: ":NO_SHARED_CIPHER:", |
| 7944 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7945 | testCases = append(testCases, testCase{ |
| 7946 | testType: serverTest, |
| 7947 | name: "NoSupportedCurves-TLS13", |
| 7948 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7949 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7950 | Bugs: ProtocolBugs{ |
| 7951 | NoSupportedCurves: true, |
| 7952 | }, |
| 7953 | }, |
| 7954 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7955 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7956 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7957 | |
| 7958 | // The server must fall back to another cipher when there are no |
| 7959 | // supported curves. |
| 7960 | testCases = append(testCases, testCase{ |
| 7961 | testType: serverTest, |
| 7962 | name: "NoCommonCurves", |
| 7963 | config: Config{ |
| 7964 | MaxVersion: VersionTLS12, |
| 7965 | CipherSuites: []uint16{ |
| 7966 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7967 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7968 | }, |
| 7969 | CurvePreferences: []CurveID{CurveP224}, |
| 7970 | }, |
| 7971 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7972 | }) |
| 7973 | |
| 7974 | // The client must reject bogus curves and disabled curves. |
| 7975 | testCases = append(testCases, testCase{ |
| 7976 | name: "BadECDHECurve", |
| 7977 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7978 | MaxVersion: VersionTLS12, |
| 7979 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7980 | Bugs: ProtocolBugs{ |
| 7981 | SendCurve: bogusCurve, |
| 7982 | }, |
| 7983 | }, |
| 7984 | shouldFail: true, |
| 7985 | expectedError: ":WRONG_CURVE:", |
| 7986 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7987 | testCases = append(testCases, testCase{ |
| 7988 | name: "BadECDHECurve-TLS13", |
| 7989 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7990 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7991 | Bugs: ProtocolBugs{ |
| 7992 | SendCurve: bogusCurve, |
| 7993 | }, |
| 7994 | }, |
| 7995 | shouldFail: true, |
| 7996 | expectedError: ":WRONG_CURVE:", |
| 7997 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7998 | |
| 7999 | testCases = append(testCases, testCase{ |
| 8000 | name: "UnsupportedCurve", |
| 8001 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8002 | MaxVersion: VersionTLS12, |
| 8003 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8004 | CurvePreferences: []CurveID{CurveP256}, |
| 8005 | Bugs: ProtocolBugs{ |
| 8006 | IgnorePeerCurvePreferences: true, |
| 8007 | }, |
| 8008 | }, |
| 8009 | flags: []string{"-p384-only"}, |
| 8010 | shouldFail: true, |
| 8011 | expectedError: ":WRONG_CURVE:", |
| 8012 | }) |
| 8013 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8014 | testCases = append(testCases, testCase{ |
| 8015 | // TODO(davidben): Add a TLS 1.3 version where |
| 8016 | // HelloRetryRequest requests an unsupported curve. |
| 8017 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8018 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8019 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8020 | CurvePreferences: []CurveID{CurveP384}, |
| 8021 | Bugs: ProtocolBugs{ |
| 8022 | SendCurve: CurveP256, |
| 8023 | }, |
| 8024 | }, |
| 8025 | flags: []string{"-p384-only"}, |
| 8026 | shouldFail: true, |
| 8027 | expectedError: ":WRONG_CURVE:", |
| 8028 | }) |
| 8029 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8030 | // Test invalid curve points. |
| 8031 | testCases = append(testCases, testCase{ |
| 8032 | name: "InvalidECDHPoint-Client", |
| 8033 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8034 | MaxVersion: VersionTLS12, |
| 8035 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8036 | CurvePreferences: []CurveID{CurveP256}, |
| 8037 | Bugs: ProtocolBugs{ |
| 8038 | InvalidECDHPoint: true, |
| 8039 | }, |
| 8040 | }, |
| 8041 | shouldFail: true, |
| 8042 | expectedError: ":INVALID_ENCODING:", |
| 8043 | }) |
| 8044 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8045 | name: "InvalidECDHPoint-Client-TLS13", |
| 8046 | config: Config{ |
| 8047 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8048 | CurvePreferences: []CurveID{CurveP256}, |
| 8049 | Bugs: ProtocolBugs{ |
| 8050 | InvalidECDHPoint: true, |
| 8051 | }, |
| 8052 | }, |
| 8053 | shouldFail: true, |
| 8054 | expectedError: ":INVALID_ENCODING:", |
| 8055 | }) |
| 8056 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8057 | testType: serverTest, |
| 8058 | name: "InvalidECDHPoint-Server", |
| 8059 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8060 | MaxVersion: VersionTLS12, |
| 8061 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8062 | CurvePreferences: []CurveID{CurveP256}, |
| 8063 | Bugs: ProtocolBugs{ |
| 8064 | InvalidECDHPoint: true, |
| 8065 | }, |
| 8066 | }, |
| 8067 | shouldFail: true, |
| 8068 | expectedError: ":INVALID_ENCODING:", |
| 8069 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8070 | testCases = append(testCases, testCase{ |
| 8071 | testType: serverTest, |
| 8072 | name: "InvalidECDHPoint-Server-TLS13", |
| 8073 | config: Config{ |
| 8074 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8075 | CurvePreferences: []CurveID{CurveP256}, |
| 8076 | Bugs: ProtocolBugs{ |
| 8077 | InvalidECDHPoint: true, |
| 8078 | }, |
| 8079 | }, |
| 8080 | shouldFail: true, |
| 8081 | expectedError: ":INVALID_ENCODING:", |
| 8082 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8083 | |
| 8084 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 8085 | testCases = append(testCases, testCase{ |
| 8086 | name: "CurveID-Resume-Client", |
| 8087 | config: Config{ |
| 8088 | MaxVersion: VersionTLS12, |
| 8089 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8090 | CurvePreferences: []CurveID{CurveX25519}, |
| 8091 | }, |
| 8092 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8093 | resumeSession: true, |
| 8094 | }) |
| 8095 | testCases = append(testCases, testCase{ |
| 8096 | testType: serverTest, |
| 8097 | name: "CurveID-Resume-Server", |
| 8098 | config: Config{ |
| 8099 | MaxVersion: VersionTLS12, |
| 8100 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8101 | CurvePreferences: []CurveID{CurveX25519}, |
| 8102 | }, |
| 8103 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8104 | resumeSession: true, |
| 8105 | }) |
| 8106 | |
| 8107 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 8108 | // one should be reported. |
| 8109 | testCases = append(testCases, testCase{ |
| 8110 | name: "CurveID-Resume-Client-TLS13", |
| 8111 | config: Config{ |
| 8112 | MaxVersion: VersionTLS13, |
| 8113 | CurvePreferences: []CurveID{CurveX25519}, |
| 8114 | }, |
| 8115 | resumeConfig: &Config{ |
| 8116 | MaxVersion: VersionTLS13, |
| 8117 | CurvePreferences: []CurveID{CurveP256}, |
| 8118 | }, |
| 8119 | flags: []string{ |
| 8120 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8121 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8122 | }, |
| 8123 | resumeSession: true, |
| 8124 | }) |
| 8125 | testCases = append(testCases, testCase{ |
| 8126 | testType: serverTest, |
| 8127 | name: "CurveID-Resume-Server-TLS13", |
| 8128 | config: Config{ |
| 8129 | MaxVersion: VersionTLS13, |
| 8130 | CurvePreferences: []CurveID{CurveX25519}, |
| 8131 | }, |
| 8132 | resumeConfig: &Config{ |
| 8133 | MaxVersion: VersionTLS13, |
| 8134 | CurvePreferences: []CurveID{CurveP256}, |
| 8135 | }, |
| 8136 | flags: []string{ |
| 8137 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8138 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8139 | }, |
| 8140 | resumeSession: true, |
| 8141 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 8142 | |
| 8143 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 8144 | testCases = append(testCases, testCase{ |
| 8145 | name: "PointFormat-ServerHello-TLS12", |
| 8146 | config: Config{ |
| 8147 | MaxVersion: VersionTLS12, |
| 8148 | Bugs: ProtocolBugs{ |
| 8149 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8150 | }, |
| 8151 | }, |
| 8152 | }) |
| 8153 | testCases = append(testCases, testCase{ |
| 8154 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 8155 | config: Config{ |
| 8156 | MaxVersion: VersionTLS13, |
| 8157 | Bugs: ProtocolBugs{ |
| 8158 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8159 | }, |
| 8160 | }, |
| 8161 | shouldFail: true, |
| 8162 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8163 | }) |
| 8164 | |
| 8165 | // Test that we tolerate unknown point formats, as long as |
| 8166 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 8167 | // check they are still functional. |
| 8168 | testCases = append(testCases, testCase{ |
| 8169 | name: "PointFormat-Client-Tolerance", |
| 8170 | config: Config{ |
| 8171 | MaxVersion: VersionTLS12, |
| 8172 | Bugs: ProtocolBugs{ |
| 8173 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8174 | }, |
| 8175 | }, |
| 8176 | }) |
| 8177 | testCases = append(testCases, testCase{ |
| 8178 | testType: serverTest, |
| 8179 | name: "PointFormat-Server-Tolerance", |
| 8180 | config: Config{ |
| 8181 | MaxVersion: VersionTLS12, |
| 8182 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8183 | Bugs: ProtocolBugs{ |
| 8184 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8185 | }, |
| 8186 | }, |
| 8187 | }) |
| 8188 | |
| 8189 | // Test TLS 1.2 does not require the point format extension to be |
| 8190 | // present. |
| 8191 | testCases = append(testCases, testCase{ |
| 8192 | name: "PointFormat-Client-Missing", |
| 8193 | config: Config{ |
| 8194 | MaxVersion: VersionTLS12, |
| 8195 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8196 | Bugs: ProtocolBugs{ |
| 8197 | SendSupportedPointFormats: []byte{}, |
| 8198 | }, |
| 8199 | }, |
| 8200 | }) |
| 8201 | testCases = append(testCases, testCase{ |
| 8202 | testType: serverTest, |
| 8203 | name: "PointFormat-Server-Missing", |
| 8204 | config: Config{ |
| 8205 | MaxVersion: VersionTLS12, |
| 8206 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8207 | Bugs: ProtocolBugs{ |
| 8208 | SendSupportedPointFormats: []byte{}, |
| 8209 | }, |
| 8210 | }, |
| 8211 | }) |
| 8212 | |
| 8213 | // If the point format extension is present, uncompressed points must be |
| 8214 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 8215 | testCases = append(testCases, testCase{ |
| 8216 | name: "PointFormat-Client-MissingUncompressed", |
| 8217 | config: Config{ |
| 8218 | MaxVersion: VersionTLS12, |
| 8219 | Bugs: ProtocolBugs{ |
| 8220 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8221 | }, |
| 8222 | }, |
| 8223 | shouldFail: true, |
| 8224 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8225 | }) |
| 8226 | testCases = append(testCases, testCase{ |
| 8227 | testType: serverTest, |
| 8228 | name: "PointFormat-Server-MissingUncompressed", |
| 8229 | config: Config{ |
| 8230 | MaxVersion: VersionTLS12, |
| 8231 | Bugs: ProtocolBugs{ |
| 8232 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8233 | }, |
| 8234 | }, |
| 8235 | shouldFail: true, |
| 8236 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8237 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8238 | } |
| 8239 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8240 | func addTLS13RecordTests() { |
| 8241 | testCases = append(testCases, testCase{ |
| 8242 | name: "TLS13-RecordPadding", |
| 8243 | config: Config{ |
| 8244 | MaxVersion: VersionTLS13, |
| 8245 | MinVersion: VersionTLS13, |
| 8246 | Bugs: ProtocolBugs{ |
| 8247 | RecordPadding: 10, |
| 8248 | }, |
| 8249 | }, |
| 8250 | }) |
| 8251 | |
| 8252 | testCases = append(testCases, testCase{ |
| 8253 | name: "TLS13-EmptyRecords", |
| 8254 | config: Config{ |
| 8255 | MaxVersion: VersionTLS13, |
| 8256 | MinVersion: VersionTLS13, |
| 8257 | Bugs: ProtocolBugs{ |
| 8258 | OmitRecordContents: true, |
| 8259 | }, |
| 8260 | }, |
| 8261 | shouldFail: true, |
| 8262 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8263 | }) |
| 8264 | |
| 8265 | testCases = append(testCases, testCase{ |
| 8266 | name: "TLS13-OnlyPadding", |
| 8267 | config: Config{ |
| 8268 | MaxVersion: VersionTLS13, |
| 8269 | MinVersion: VersionTLS13, |
| 8270 | Bugs: ProtocolBugs{ |
| 8271 | OmitRecordContents: true, |
| 8272 | RecordPadding: 10, |
| 8273 | }, |
| 8274 | }, |
| 8275 | shouldFail: true, |
| 8276 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8277 | }) |
| 8278 | |
| 8279 | testCases = append(testCases, testCase{ |
| 8280 | name: "TLS13-WrongOuterRecord", |
| 8281 | config: Config{ |
| 8282 | MaxVersion: VersionTLS13, |
| 8283 | MinVersion: VersionTLS13, |
| 8284 | Bugs: ProtocolBugs{ |
| 8285 | OuterRecordType: recordTypeHandshake, |
| 8286 | }, |
| 8287 | }, |
| 8288 | shouldFail: true, |
| 8289 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8290 | }) |
| 8291 | } |
| 8292 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8293 | func addSessionTicketTests() { |
| 8294 | testCases = append(testCases, testCase{ |
| 8295 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8296 | // mean the server changed its mind on sending a ticket. |
| 8297 | name: "SendEmptySessionTicket", |
| 8298 | config: Config{ |
| 8299 | MaxVersion: VersionTLS12, |
| 8300 | Bugs: ProtocolBugs{ |
| 8301 | SendEmptySessionTicket: true, |
| 8302 | }, |
| 8303 | }, |
| 8304 | flags: []string{"-expect-no-session"}, |
| 8305 | }) |
| 8306 | |
| 8307 | // Test that the server ignores unknown PSK modes. |
| 8308 | testCases = append(testCases, testCase{ |
| 8309 | testType: serverTest, |
| 8310 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8311 | config: Config{ |
| 8312 | MaxVersion: VersionTLS13, |
| 8313 | Bugs: ProtocolBugs{ |
| 8314 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8315 | }, |
| 8316 | }, |
| 8317 | resumeSession: true, |
| 8318 | expectedResumeVersion: VersionTLS13, |
| 8319 | }) |
| 8320 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8321 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8322 | testCases = append(testCases, testCase{ |
| 8323 | testType: serverTest, |
| 8324 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8325 | config: Config{ |
| 8326 | MaxVersion: VersionTLS13, |
| 8327 | Bugs: ProtocolBugs{ |
| 8328 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8329 | ExpectNoNewSessionTicket: true, |
| 8330 | }, |
| 8331 | }, |
| 8332 | }) |
| 8333 | |
| 8334 | // 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] | 8335 | testCases = append(testCases, testCase{ |
| 8336 | testType: serverTest, |
| 8337 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8338 | config: Config{ |
| 8339 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8340 | }, |
| 8341 | resumeConfig: &Config{ |
| 8342 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8343 | Bugs: ProtocolBugs{ |
| 8344 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8345 | }, |
| 8346 | }, |
| 8347 | resumeSession: true, |
| 8348 | expectResumeRejected: true, |
| 8349 | }) |
| 8350 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8351 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8352 | testCases = append(testCases, testCase{ |
| 8353 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8354 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8355 | config: Config{ |
| 8356 | MaxVersion: VersionTLS13, |
| 8357 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8358 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8359 | }, |
| 8360 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8361 | resumeSession: true, |
| 8362 | flags: []string{ |
| 8363 | "-resumption-delay", "10", |
| 8364 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8365 | }) |
| 8366 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8367 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8368 | testCases = append(testCases, testCase{ |
| 8369 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8370 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8371 | config: Config{ |
| 8372 | MaxVersion: VersionTLS13, |
| 8373 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8374 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8375 | }, |
| 8376 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8377 | resumeSession: true, |
| 8378 | shouldFail: true, |
| 8379 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8380 | }) |
| 8381 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame^] | 8382 | testCases = append(testCases, testCase{ |
| 8383 | testType: clientTest, |
| 8384 | name: "TLS13-SendTicketEarlyDataInfo", |
| 8385 | config: Config{ |
| 8386 | MaxVersion: VersionTLS13, |
| 8387 | Bugs: ProtocolBugs{ |
| 8388 | SendTicketEarlyDataInfo: 16384, |
| 8389 | }, |
| 8390 | }, |
| 8391 | flags: []string{ |
| 8392 | "-expect-early-data-info", |
| 8393 | }, |
| 8394 | }) |
| 8395 | |
| 8396 | testCases = append(testCases, testCase{ |
| 8397 | testType: serverTest, |
| 8398 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 8399 | config: Config{ |
| 8400 | MaxVersion: VersionTLS13, |
| 8401 | Bugs: ProtocolBugs{ |
| 8402 | ExpectTicketEarlyDataInfo: true, |
| 8403 | }, |
| 8404 | }, |
| 8405 | flags: []string{ |
| 8406 | "-enable-early-data", |
| 8407 | }, |
| 8408 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8409 | } |
| 8410 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8411 | func addChangeCipherSpecTests() { |
| 8412 | // Test missing ChangeCipherSpecs. |
| 8413 | testCases = append(testCases, testCase{ |
| 8414 | name: "SkipChangeCipherSpec-Client", |
| 8415 | config: Config{ |
| 8416 | MaxVersion: VersionTLS12, |
| 8417 | Bugs: ProtocolBugs{ |
| 8418 | SkipChangeCipherSpec: true, |
| 8419 | }, |
| 8420 | }, |
| 8421 | shouldFail: true, |
| 8422 | expectedError: ":UNEXPECTED_RECORD:", |
| 8423 | }) |
| 8424 | testCases = append(testCases, testCase{ |
| 8425 | testType: serverTest, |
| 8426 | name: "SkipChangeCipherSpec-Server", |
| 8427 | config: Config{ |
| 8428 | MaxVersion: VersionTLS12, |
| 8429 | Bugs: ProtocolBugs{ |
| 8430 | SkipChangeCipherSpec: true, |
| 8431 | }, |
| 8432 | }, |
| 8433 | shouldFail: true, |
| 8434 | expectedError: ":UNEXPECTED_RECORD:", |
| 8435 | }) |
| 8436 | testCases = append(testCases, testCase{ |
| 8437 | testType: serverTest, |
| 8438 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8439 | config: Config{ |
| 8440 | MaxVersion: VersionTLS12, |
| 8441 | NextProtos: []string{"bar"}, |
| 8442 | Bugs: ProtocolBugs{ |
| 8443 | SkipChangeCipherSpec: true, |
| 8444 | }, |
| 8445 | }, |
| 8446 | flags: []string{ |
| 8447 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8448 | }, |
| 8449 | shouldFail: true, |
| 8450 | expectedError: ":UNEXPECTED_RECORD:", |
| 8451 | }) |
| 8452 | |
| 8453 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8454 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8455 | // rejected. Test both with and without handshake packing to handle both |
| 8456 | // when the partial post-CCS message is in its own record and when it is |
| 8457 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8458 | for _, packed := range []bool{false, true} { |
| 8459 | var suffix string |
| 8460 | if packed { |
| 8461 | suffix = "-Packed" |
| 8462 | } |
| 8463 | |
| 8464 | testCases = append(testCases, testCase{ |
| 8465 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8466 | config: Config{ |
| 8467 | MaxVersion: VersionTLS12, |
| 8468 | Bugs: ProtocolBugs{ |
| 8469 | FragmentAcrossChangeCipherSpec: true, |
| 8470 | PackHandshakeFlight: packed, |
| 8471 | }, |
| 8472 | }, |
| 8473 | shouldFail: true, |
| 8474 | expectedError: ":UNEXPECTED_RECORD:", |
| 8475 | }) |
| 8476 | testCases = append(testCases, testCase{ |
| 8477 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8478 | config: Config{ |
| 8479 | MaxVersion: VersionTLS12, |
| 8480 | }, |
| 8481 | resumeSession: true, |
| 8482 | resumeConfig: &Config{ |
| 8483 | MaxVersion: VersionTLS12, |
| 8484 | Bugs: ProtocolBugs{ |
| 8485 | FragmentAcrossChangeCipherSpec: true, |
| 8486 | PackHandshakeFlight: packed, |
| 8487 | }, |
| 8488 | }, |
| 8489 | shouldFail: true, |
| 8490 | expectedError: ":UNEXPECTED_RECORD:", |
| 8491 | }) |
| 8492 | testCases = append(testCases, testCase{ |
| 8493 | testType: serverTest, |
| 8494 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8495 | config: Config{ |
| 8496 | MaxVersion: VersionTLS12, |
| 8497 | Bugs: ProtocolBugs{ |
| 8498 | FragmentAcrossChangeCipherSpec: true, |
| 8499 | PackHandshakeFlight: packed, |
| 8500 | }, |
| 8501 | }, |
| 8502 | shouldFail: true, |
| 8503 | expectedError: ":UNEXPECTED_RECORD:", |
| 8504 | }) |
| 8505 | testCases = append(testCases, testCase{ |
| 8506 | testType: serverTest, |
| 8507 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8508 | config: Config{ |
| 8509 | MaxVersion: VersionTLS12, |
| 8510 | }, |
| 8511 | resumeSession: true, |
| 8512 | resumeConfig: &Config{ |
| 8513 | MaxVersion: VersionTLS12, |
| 8514 | Bugs: ProtocolBugs{ |
| 8515 | FragmentAcrossChangeCipherSpec: true, |
| 8516 | PackHandshakeFlight: packed, |
| 8517 | }, |
| 8518 | }, |
| 8519 | shouldFail: true, |
| 8520 | expectedError: ":UNEXPECTED_RECORD:", |
| 8521 | }) |
| 8522 | testCases = append(testCases, testCase{ |
| 8523 | testType: serverTest, |
| 8524 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8525 | config: Config{ |
| 8526 | MaxVersion: VersionTLS12, |
| 8527 | NextProtos: []string{"bar"}, |
| 8528 | Bugs: ProtocolBugs{ |
| 8529 | FragmentAcrossChangeCipherSpec: true, |
| 8530 | PackHandshakeFlight: packed, |
| 8531 | }, |
| 8532 | }, |
| 8533 | flags: []string{ |
| 8534 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8535 | }, |
| 8536 | shouldFail: true, |
| 8537 | expectedError: ":UNEXPECTED_RECORD:", |
| 8538 | }) |
| 8539 | } |
| 8540 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8541 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8542 | // messages in the handshake queue. Do this by testing the server |
| 8543 | // reading the client Finished, reversing the flight so Finished comes |
| 8544 | // first. |
| 8545 | testCases = append(testCases, testCase{ |
| 8546 | protocol: dtls, |
| 8547 | testType: serverTest, |
| 8548 | name: "SendUnencryptedFinished-DTLS", |
| 8549 | config: Config{ |
| 8550 | MaxVersion: VersionTLS12, |
| 8551 | Bugs: ProtocolBugs{ |
| 8552 | SendUnencryptedFinished: true, |
| 8553 | ReverseHandshakeFragments: true, |
| 8554 | }, |
| 8555 | }, |
| 8556 | shouldFail: true, |
| 8557 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8558 | }) |
| 8559 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8560 | // Test synchronization between encryption changes and the handshake in |
| 8561 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8562 | testCases = append(testCases, testCase{ |
| 8563 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8564 | config: Config{ |
| 8565 | MaxVersion: VersionTLS13, |
| 8566 | Bugs: ProtocolBugs{ |
| 8567 | PartialEncryptedExtensionsWithServerHello: true, |
| 8568 | }, |
| 8569 | }, |
| 8570 | shouldFail: true, |
| 8571 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8572 | }) |
| 8573 | testCases = append(testCases, testCase{ |
| 8574 | testType: serverTest, |
| 8575 | name: "PartialClientFinishedWithClientHello", |
| 8576 | config: Config{ |
| 8577 | MaxVersion: VersionTLS13, |
| 8578 | Bugs: ProtocolBugs{ |
| 8579 | PartialClientFinishedWithClientHello: true, |
| 8580 | }, |
| 8581 | }, |
| 8582 | shouldFail: true, |
| 8583 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8584 | }) |
| 8585 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8586 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8587 | testCases = append(testCases, testCase{ |
| 8588 | testType: serverTest, |
| 8589 | name: "EarlyChangeCipherSpec-server-1", |
| 8590 | config: Config{ |
| 8591 | MaxVersion: VersionTLS12, |
| 8592 | Bugs: ProtocolBugs{ |
| 8593 | EarlyChangeCipherSpec: 1, |
| 8594 | }, |
| 8595 | }, |
| 8596 | shouldFail: true, |
| 8597 | expectedError: ":UNEXPECTED_RECORD:", |
| 8598 | }) |
| 8599 | testCases = append(testCases, testCase{ |
| 8600 | testType: serverTest, |
| 8601 | name: "EarlyChangeCipherSpec-server-2", |
| 8602 | config: Config{ |
| 8603 | MaxVersion: VersionTLS12, |
| 8604 | Bugs: ProtocolBugs{ |
| 8605 | EarlyChangeCipherSpec: 2, |
| 8606 | }, |
| 8607 | }, |
| 8608 | shouldFail: true, |
| 8609 | expectedError: ":UNEXPECTED_RECORD:", |
| 8610 | }) |
| 8611 | testCases = append(testCases, testCase{ |
| 8612 | protocol: dtls, |
| 8613 | name: "StrayChangeCipherSpec", |
| 8614 | config: Config{ |
| 8615 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8616 | // that stray ChangeCipherSpec messages are |
| 8617 | // rejected. |
| 8618 | MaxVersion: VersionTLS12, |
| 8619 | Bugs: ProtocolBugs{ |
| 8620 | StrayChangeCipherSpec: true, |
| 8621 | }, |
| 8622 | }, |
| 8623 | }) |
| 8624 | |
| 8625 | // Test that the contents of ChangeCipherSpec are checked. |
| 8626 | testCases = append(testCases, testCase{ |
| 8627 | name: "BadChangeCipherSpec-1", |
| 8628 | config: Config{ |
| 8629 | MaxVersion: VersionTLS12, |
| 8630 | Bugs: ProtocolBugs{ |
| 8631 | BadChangeCipherSpec: []byte{2}, |
| 8632 | }, |
| 8633 | }, |
| 8634 | shouldFail: true, |
| 8635 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8636 | }) |
| 8637 | testCases = append(testCases, testCase{ |
| 8638 | name: "BadChangeCipherSpec-2", |
| 8639 | config: Config{ |
| 8640 | MaxVersion: VersionTLS12, |
| 8641 | Bugs: ProtocolBugs{ |
| 8642 | BadChangeCipherSpec: []byte{1, 1}, |
| 8643 | }, |
| 8644 | }, |
| 8645 | shouldFail: true, |
| 8646 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8647 | }) |
| 8648 | testCases = append(testCases, testCase{ |
| 8649 | protocol: dtls, |
| 8650 | name: "BadChangeCipherSpec-DTLS-1", |
| 8651 | config: Config{ |
| 8652 | MaxVersion: VersionTLS12, |
| 8653 | Bugs: ProtocolBugs{ |
| 8654 | BadChangeCipherSpec: []byte{2}, |
| 8655 | }, |
| 8656 | }, |
| 8657 | shouldFail: true, |
| 8658 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8659 | }) |
| 8660 | testCases = append(testCases, testCase{ |
| 8661 | protocol: dtls, |
| 8662 | name: "BadChangeCipherSpec-DTLS-2", |
| 8663 | config: Config{ |
| 8664 | MaxVersion: VersionTLS12, |
| 8665 | Bugs: ProtocolBugs{ |
| 8666 | BadChangeCipherSpec: []byte{1, 1}, |
| 8667 | }, |
| 8668 | }, |
| 8669 | shouldFail: true, |
| 8670 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8671 | }) |
| 8672 | } |
| 8673 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8674 | type perMessageTest struct { |
| 8675 | messageType uint8 |
| 8676 | test testCase |
| 8677 | } |
| 8678 | |
| 8679 | // makePerMessageTests returns a series of test templates which cover each |
| 8680 | // message in the TLS handshake. These may be used with bugs like |
| 8681 | // WrongMessageType to fully test a per-message bug. |
| 8682 | func makePerMessageTests() []perMessageTest { |
| 8683 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8684 | for _, protocol := range []protocol{tls, dtls} { |
| 8685 | var suffix string |
| 8686 | if protocol == dtls { |
| 8687 | suffix = "-DTLS" |
| 8688 | } |
| 8689 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8690 | ret = append(ret, perMessageTest{ |
| 8691 | messageType: typeClientHello, |
| 8692 | test: testCase{ |
| 8693 | protocol: protocol, |
| 8694 | testType: serverTest, |
| 8695 | name: "ClientHello" + suffix, |
| 8696 | config: Config{ |
| 8697 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8698 | }, |
| 8699 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8700 | }) |
| 8701 | |
| 8702 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8703 | ret = append(ret, perMessageTest{ |
| 8704 | messageType: typeHelloVerifyRequest, |
| 8705 | test: testCase{ |
| 8706 | protocol: protocol, |
| 8707 | name: "HelloVerifyRequest" + suffix, |
| 8708 | config: Config{ |
| 8709 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8710 | }, |
| 8711 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8712 | }) |
| 8713 | } |
| 8714 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8715 | ret = append(ret, perMessageTest{ |
| 8716 | messageType: typeServerHello, |
| 8717 | test: testCase{ |
| 8718 | protocol: protocol, |
| 8719 | name: "ServerHello" + suffix, |
| 8720 | config: Config{ |
| 8721 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8722 | }, |
| 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: typeCertificate, |
| 8728 | test: testCase{ |
| 8729 | protocol: protocol, |
| 8730 | name: "ServerCertificate" + suffix, |
| 8731 | config: Config{ |
| 8732 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8733 | }, |
| 8734 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8735 | }) |
| 8736 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8737 | ret = append(ret, perMessageTest{ |
| 8738 | messageType: typeCertificateStatus, |
| 8739 | test: testCase{ |
| 8740 | protocol: protocol, |
| 8741 | name: "CertificateStatus" + suffix, |
| 8742 | config: Config{ |
| 8743 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8744 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8745 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8746 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8747 | }) |
| 8748 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8749 | ret = append(ret, perMessageTest{ |
| 8750 | messageType: typeServerKeyExchange, |
| 8751 | test: testCase{ |
| 8752 | protocol: protocol, |
| 8753 | name: "ServerKeyExchange" + suffix, |
| 8754 | config: Config{ |
| 8755 | MaxVersion: VersionTLS12, |
| 8756 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8757 | }, |
| 8758 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8759 | }) |
| 8760 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8761 | ret = append(ret, perMessageTest{ |
| 8762 | messageType: typeCertificateRequest, |
| 8763 | test: testCase{ |
| 8764 | protocol: protocol, |
| 8765 | name: "CertificateRequest" + suffix, |
| 8766 | config: Config{ |
| 8767 | MaxVersion: VersionTLS12, |
| 8768 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8769 | }, |
| 8770 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8771 | }) |
| 8772 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8773 | ret = append(ret, perMessageTest{ |
| 8774 | messageType: typeServerHelloDone, |
| 8775 | test: testCase{ |
| 8776 | protocol: protocol, |
| 8777 | name: "ServerHelloDone" + suffix, |
| 8778 | config: Config{ |
| 8779 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8780 | }, |
| 8781 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8782 | }) |
| 8783 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8784 | ret = append(ret, perMessageTest{ |
| 8785 | messageType: typeCertificate, |
| 8786 | test: testCase{ |
| 8787 | testType: serverTest, |
| 8788 | protocol: protocol, |
| 8789 | name: "ClientCertificate" + suffix, |
| 8790 | config: Config{ |
| 8791 | Certificates: []Certificate{rsaCertificate}, |
| 8792 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8793 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8794 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8795 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8796 | }) |
| 8797 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8798 | ret = append(ret, perMessageTest{ |
| 8799 | messageType: typeCertificateVerify, |
| 8800 | test: testCase{ |
| 8801 | testType: serverTest, |
| 8802 | protocol: protocol, |
| 8803 | name: "CertificateVerify" + suffix, |
| 8804 | config: Config{ |
| 8805 | Certificates: []Certificate{rsaCertificate}, |
| 8806 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8807 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8808 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8809 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8810 | }) |
| 8811 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8812 | ret = append(ret, perMessageTest{ |
| 8813 | messageType: typeClientKeyExchange, |
| 8814 | test: testCase{ |
| 8815 | testType: serverTest, |
| 8816 | protocol: protocol, |
| 8817 | name: "ClientKeyExchange" + suffix, |
| 8818 | config: Config{ |
| 8819 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8820 | }, |
| 8821 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8822 | }) |
| 8823 | |
| 8824 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8825 | ret = append(ret, perMessageTest{ |
| 8826 | messageType: typeNextProtocol, |
| 8827 | test: testCase{ |
| 8828 | testType: serverTest, |
| 8829 | protocol: protocol, |
| 8830 | name: "NextProtocol" + suffix, |
| 8831 | config: Config{ |
| 8832 | MaxVersion: VersionTLS12, |
| 8833 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8834 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8835 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8836 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8837 | }) |
| 8838 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8839 | ret = append(ret, perMessageTest{ |
| 8840 | messageType: typeChannelID, |
| 8841 | test: testCase{ |
| 8842 | testType: serverTest, |
| 8843 | protocol: protocol, |
| 8844 | name: "ChannelID" + suffix, |
| 8845 | config: Config{ |
| 8846 | MaxVersion: VersionTLS12, |
| 8847 | ChannelID: channelIDKey, |
| 8848 | }, |
| 8849 | flags: []string{ |
| 8850 | "-expect-channel-id", |
| 8851 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8852 | }, |
| 8853 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8854 | }) |
| 8855 | } |
| 8856 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8857 | ret = append(ret, perMessageTest{ |
| 8858 | messageType: typeFinished, |
| 8859 | test: testCase{ |
| 8860 | testType: serverTest, |
| 8861 | protocol: protocol, |
| 8862 | name: "ClientFinished" + suffix, |
| 8863 | config: Config{ |
| 8864 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8865 | }, |
| 8866 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8867 | }) |
| 8868 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8869 | ret = append(ret, perMessageTest{ |
| 8870 | messageType: typeNewSessionTicket, |
| 8871 | test: testCase{ |
| 8872 | protocol: protocol, |
| 8873 | name: "NewSessionTicket" + suffix, |
| 8874 | config: Config{ |
| 8875 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8876 | }, |
| 8877 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8878 | }) |
| 8879 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8880 | ret = append(ret, perMessageTest{ |
| 8881 | messageType: typeFinished, |
| 8882 | test: testCase{ |
| 8883 | protocol: protocol, |
| 8884 | name: "ServerFinished" + suffix, |
| 8885 | config: Config{ |
| 8886 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8887 | }, |
| 8888 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8889 | }) |
| 8890 | |
| 8891 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8892 | |
| 8893 | ret = append(ret, perMessageTest{ |
| 8894 | messageType: typeClientHello, |
| 8895 | test: testCase{ |
| 8896 | testType: serverTest, |
| 8897 | name: "TLS13-ClientHello", |
| 8898 | config: Config{ |
| 8899 | MaxVersion: VersionTLS13, |
| 8900 | }, |
| 8901 | }, |
| 8902 | }) |
| 8903 | |
| 8904 | ret = append(ret, perMessageTest{ |
| 8905 | messageType: typeServerHello, |
| 8906 | test: testCase{ |
| 8907 | name: "TLS13-ServerHello", |
| 8908 | config: Config{ |
| 8909 | MaxVersion: VersionTLS13, |
| 8910 | }, |
| 8911 | }, |
| 8912 | }) |
| 8913 | |
| 8914 | ret = append(ret, perMessageTest{ |
| 8915 | messageType: typeEncryptedExtensions, |
| 8916 | test: testCase{ |
| 8917 | name: "TLS13-EncryptedExtensions", |
| 8918 | config: Config{ |
| 8919 | MaxVersion: VersionTLS13, |
| 8920 | }, |
| 8921 | }, |
| 8922 | }) |
| 8923 | |
| 8924 | ret = append(ret, perMessageTest{ |
| 8925 | messageType: typeCertificateRequest, |
| 8926 | test: testCase{ |
| 8927 | name: "TLS13-CertificateRequest", |
| 8928 | config: Config{ |
| 8929 | MaxVersion: VersionTLS13, |
| 8930 | ClientAuth: RequireAnyClientCert, |
| 8931 | }, |
| 8932 | }, |
| 8933 | }) |
| 8934 | |
| 8935 | ret = append(ret, perMessageTest{ |
| 8936 | messageType: typeCertificate, |
| 8937 | test: testCase{ |
| 8938 | name: "TLS13-ServerCertificate", |
| 8939 | config: Config{ |
| 8940 | MaxVersion: VersionTLS13, |
| 8941 | }, |
| 8942 | }, |
| 8943 | }) |
| 8944 | |
| 8945 | ret = append(ret, perMessageTest{ |
| 8946 | messageType: typeCertificateVerify, |
| 8947 | test: testCase{ |
| 8948 | name: "TLS13-ServerCertificateVerify", |
| 8949 | config: Config{ |
| 8950 | MaxVersion: VersionTLS13, |
| 8951 | }, |
| 8952 | }, |
| 8953 | }) |
| 8954 | |
| 8955 | ret = append(ret, perMessageTest{ |
| 8956 | messageType: typeFinished, |
| 8957 | test: testCase{ |
| 8958 | name: "TLS13-ServerFinished", |
| 8959 | config: Config{ |
| 8960 | MaxVersion: VersionTLS13, |
| 8961 | }, |
| 8962 | }, |
| 8963 | }) |
| 8964 | |
| 8965 | ret = append(ret, perMessageTest{ |
| 8966 | messageType: typeCertificate, |
| 8967 | test: testCase{ |
| 8968 | testType: serverTest, |
| 8969 | name: "TLS13-ClientCertificate", |
| 8970 | config: Config{ |
| 8971 | Certificates: []Certificate{rsaCertificate}, |
| 8972 | MaxVersion: VersionTLS13, |
| 8973 | }, |
| 8974 | flags: []string{"-require-any-client-certificate"}, |
| 8975 | }, |
| 8976 | }) |
| 8977 | |
| 8978 | ret = append(ret, perMessageTest{ |
| 8979 | messageType: typeCertificateVerify, |
| 8980 | test: testCase{ |
| 8981 | testType: serverTest, |
| 8982 | name: "TLS13-ClientCertificateVerify", |
| 8983 | config: Config{ |
| 8984 | Certificates: []Certificate{rsaCertificate}, |
| 8985 | MaxVersion: VersionTLS13, |
| 8986 | }, |
| 8987 | flags: []string{"-require-any-client-certificate"}, |
| 8988 | }, |
| 8989 | }) |
| 8990 | |
| 8991 | ret = append(ret, perMessageTest{ |
| 8992 | messageType: typeFinished, |
| 8993 | test: testCase{ |
| 8994 | testType: serverTest, |
| 8995 | name: "TLS13-ClientFinished", |
| 8996 | config: Config{ |
| 8997 | MaxVersion: VersionTLS13, |
| 8998 | }, |
| 8999 | }, |
| 9000 | }) |
| 9001 | |
| 9002 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9003 | } |
| 9004 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9005 | func addWrongMessageTypeTests() { |
| 9006 | for _, t := range makePerMessageTests() { |
| 9007 | t.test.name = "WrongMessageType-" + t.test.name |
| 9008 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 9009 | t.test.shouldFail = true |
| 9010 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 9011 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9012 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9013 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9014 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9015 | // an unencrypted alert while the server expects |
| 9016 | // encryption, so the alert is not readable by runner. |
| 9017 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9018 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9019 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9020 | testCases = append(testCases, t.test) |
| 9021 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9022 | } |
| 9023 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9024 | func addTrailingMessageDataTests() { |
| 9025 | for _, t := range makePerMessageTests() { |
| 9026 | t.test.name = "TrailingMessageData-" + t.test.name |
| 9027 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 9028 | t.test.shouldFail = true |
| 9029 | t.test.expectedError = ":DECODE_ERROR:" |
| 9030 | t.test.expectedLocalError = "remote error: error decoding message" |
| 9031 | |
| 9032 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9033 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9034 | // an unencrypted alert while the server expects |
| 9035 | // encryption, so the alert is not readable by runner. |
| 9036 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9037 | } |
| 9038 | |
| 9039 | if t.messageType == typeFinished { |
| 9040 | // Bad Finished messages read as the verify data having |
| 9041 | // the wrong length. |
| 9042 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 9043 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 9044 | } |
| 9045 | |
| 9046 | testCases = append(testCases, t.test) |
| 9047 | } |
| 9048 | } |
| 9049 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9050 | func addTLS13HandshakeTests() { |
| 9051 | testCases = append(testCases, testCase{ |
| 9052 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9053 | name: "NegotiatePSKResumption-TLS13", |
| 9054 | config: Config{ |
| 9055 | MaxVersion: VersionTLS13, |
| 9056 | Bugs: ProtocolBugs{ |
| 9057 | NegotiatePSKResumption: true, |
| 9058 | }, |
| 9059 | }, |
| 9060 | resumeSession: true, |
| 9061 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9062 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9063 | }) |
| 9064 | |
| 9065 | testCases = append(testCases, testCase{ |
| 9066 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9067 | name: "MissingKeyShare-Client", |
| 9068 | config: Config{ |
| 9069 | MaxVersion: VersionTLS13, |
| 9070 | Bugs: ProtocolBugs{ |
| 9071 | MissingKeyShare: true, |
| 9072 | }, |
| 9073 | }, |
| 9074 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9075 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9076 | }) |
| 9077 | |
| 9078 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9079 | testType: serverTest, |
| 9080 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9081 | config: Config{ |
| 9082 | MaxVersion: VersionTLS13, |
| 9083 | Bugs: ProtocolBugs{ |
| 9084 | MissingKeyShare: true, |
| 9085 | }, |
| 9086 | }, |
| 9087 | shouldFail: true, |
| 9088 | expectedError: ":MISSING_KEY_SHARE:", |
| 9089 | }) |
| 9090 | |
| 9091 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9092 | testType: serverTest, |
| 9093 | name: "DuplicateKeyShares", |
| 9094 | config: Config{ |
| 9095 | MaxVersion: VersionTLS13, |
| 9096 | Bugs: ProtocolBugs{ |
| 9097 | DuplicateKeyShares: true, |
| 9098 | }, |
| 9099 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9100 | shouldFail: true, |
| 9101 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9102 | }) |
| 9103 | |
| 9104 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9105 | testType: serverTest, |
| 9106 | name: "SkipEarlyData", |
| 9107 | config: Config{ |
| 9108 | MaxVersion: VersionTLS13, |
| 9109 | Bugs: ProtocolBugs{ |
| 9110 | SendEarlyDataLength: 4, |
| 9111 | }, |
| 9112 | }, |
| 9113 | }) |
| 9114 | |
| 9115 | testCases = append(testCases, testCase{ |
| 9116 | testType: serverTest, |
| 9117 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9118 | config: Config{ |
| 9119 | MaxVersion: VersionTLS13, |
| 9120 | Bugs: ProtocolBugs{ |
| 9121 | SendEarlyDataLength: 4, |
| 9122 | OmitEarlyDataExtension: true, |
| 9123 | }, |
| 9124 | }, |
| 9125 | shouldFail: true, |
| 9126 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9127 | }) |
| 9128 | |
| 9129 | testCases = append(testCases, testCase{ |
| 9130 | testType: serverTest, |
| 9131 | name: "SkipEarlyData-TooMuchData", |
| 9132 | config: Config{ |
| 9133 | MaxVersion: VersionTLS13, |
| 9134 | Bugs: ProtocolBugs{ |
| 9135 | SendEarlyDataLength: 16384 + 1, |
| 9136 | }, |
| 9137 | }, |
| 9138 | shouldFail: true, |
| 9139 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9140 | }) |
| 9141 | |
| 9142 | testCases = append(testCases, testCase{ |
| 9143 | testType: serverTest, |
| 9144 | name: "SkipEarlyData-Interleaved", |
| 9145 | config: Config{ |
| 9146 | MaxVersion: VersionTLS13, |
| 9147 | Bugs: ProtocolBugs{ |
| 9148 | SendEarlyDataLength: 4, |
| 9149 | InterleaveEarlyData: true, |
| 9150 | }, |
| 9151 | }, |
| 9152 | shouldFail: true, |
| 9153 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9154 | }) |
| 9155 | |
| 9156 | testCases = append(testCases, testCase{ |
| 9157 | testType: serverTest, |
| 9158 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 9159 | config: Config{ |
| 9160 | MaxVersion: VersionTLS13, |
| 9161 | Bugs: ProtocolBugs{ |
| 9162 | SendEarlyDataLength: 4, |
| 9163 | }, |
| 9164 | }, |
| 9165 | shouldFail: true, |
| 9166 | expectedError: ":UNEXPECTED_RECORD:", |
| 9167 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9168 | }) |
| 9169 | |
| 9170 | testCases = append(testCases, testCase{ |
| 9171 | testType: serverTest, |
| 9172 | name: "SkipEarlyData-HRR", |
| 9173 | config: Config{ |
| 9174 | MaxVersion: VersionTLS13, |
| 9175 | Bugs: ProtocolBugs{ |
| 9176 | SendEarlyDataLength: 4, |
| 9177 | }, |
| 9178 | DefaultCurves: []CurveID{}, |
| 9179 | }, |
| 9180 | }) |
| 9181 | |
| 9182 | testCases = append(testCases, testCase{ |
| 9183 | testType: serverTest, |
| 9184 | name: "SkipEarlyData-HRR-Interleaved", |
| 9185 | config: Config{ |
| 9186 | MaxVersion: VersionTLS13, |
| 9187 | Bugs: ProtocolBugs{ |
| 9188 | SendEarlyDataLength: 4, |
| 9189 | InterleaveEarlyData: true, |
| 9190 | }, |
| 9191 | DefaultCurves: []CurveID{}, |
| 9192 | }, |
| 9193 | shouldFail: true, |
| 9194 | expectedError: ":UNEXPECTED_RECORD:", |
| 9195 | }) |
| 9196 | |
| 9197 | testCases = append(testCases, testCase{ |
| 9198 | testType: serverTest, |
| 9199 | name: "SkipEarlyData-HRR-TooMuchData", |
| 9200 | config: Config{ |
| 9201 | MaxVersion: VersionTLS13, |
| 9202 | Bugs: ProtocolBugs{ |
| 9203 | SendEarlyDataLength: 16384 + 1, |
| 9204 | }, |
| 9205 | DefaultCurves: []CurveID{}, |
| 9206 | }, |
| 9207 | shouldFail: true, |
| 9208 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9209 | }) |
| 9210 | |
| 9211 | // Test that skipping early data looking for cleartext correctly |
| 9212 | // processes an alert record. |
| 9213 | testCases = append(testCases, testCase{ |
| 9214 | testType: serverTest, |
| 9215 | name: "SkipEarlyData-HRR-FatalAlert", |
| 9216 | config: Config{ |
| 9217 | MaxVersion: VersionTLS13, |
| 9218 | Bugs: ProtocolBugs{ |
| 9219 | SendEarlyAlert: true, |
| 9220 | SendEarlyDataLength: 4, |
| 9221 | }, |
| 9222 | DefaultCurves: []CurveID{}, |
| 9223 | }, |
| 9224 | shouldFail: true, |
| 9225 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 9226 | }) |
| 9227 | |
| 9228 | testCases = append(testCases, testCase{ |
| 9229 | testType: serverTest, |
| 9230 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 9231 | config: Config{ |
| 9232 | MaxVersion: VersionTLS13, |
| 9233 | Bugs: ProtocolBugs{ |
| 9234 | SendEarlyDataOnSecondClientHello: true, |
| 9235 | }, |
| 9236 | DefaultCurves: []CurveID{}, |
| 9237 | }, |
| 9238 | shouldFail: true, |
| 9239 | expectedLocalError: "remote error: bad record MAC", |
| 9240 | }) |
| 9241 | |
| 9242 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9243 | testType: clientTest, |
| 9244 | name: "EmptyEncryptedExtensions", |
| 9245 | config: Config{ |
| 9246 | MaxVersion: VersionTLS13, |
| 9247 | Bugs: ProtocolBugs{ |
| 9248 | EmptyEncryptedExtensions: true, |
| 9249 | }, |
| 9250 | }, |
| 9251 | shouldFail: true, |
| 9252 | expectedLocalError: "remote error: error decoding message", |
| 9253 | }) |
| 9254 | |
| 9255 | testCases = append(testCases, testCase{ |
| 9256 | testType: clientTest, |
| 9257 | name: "EncryptedExtensionsWithKeyShare", |
| 9258 | config: Config{ |
| 9259 | MaxVersion: VersionTLS13, |
| 9260 | Bugs: ProtocolBugs{ |
| 9261 | EncryptedExtensionsWithKeyShare: true, |
| 9262 | }, |
| 9263 | }, |
| 9264 | shouldFail: true, |
| 9265 | expectedLocalError: "remote error: unsupported extension", |
| 9266 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9267 | |
| 9268 | testCases = append(testCases, testCase{ |
| 9269 | testType: serverTest, |
| 9270 | name: "SendHelloRetryRequest", |
| 9271 | config: Config{ |
| 9272 | MaxVersion: VersionTLS13, |
| 9273 | // Require a HelloRetryRequest for every curve. |
| 9274 | DefaultCurves: []CurveID{}, |
| 9275 | }, |
| 9276 | expectedCurveID: CurveX25519, |
| 9277 | }) |
| 9278 | |
| 9279 | testCases = append(testCases, testCase{ |
| 9280 | testType: serverTest, |
| 9281 | name: "SendHelloRetryRequest-2", |
| 9282 | config: Config{ |
| 9283 | MaxVersion: VersionTLS13, |
| 9284 | DefaultCurves: []CurveID{CurveP384}, |
| 9285 | }, |
| 9286 | // Although the ClientHello did not predict our preferred curve, |
| 9287 | // we always select it whether it is predicted or not. |
| 9288 | expectedCurveID: CurveX25519, |
| 9289 | }) |
| 9290 | |
| 9291 | testCases = append(testCases, testCase{ |
| 9292 | name: "UnknownCurve-HelloRetryRequest", |
| 9293 | config: Config{ |
| 9294 | MaxVersion: VersionTLS13, |
| 9295 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9296 | CurvePreferences: []CurveID{CurveP384}, |
| 9297 | Bugs: ProtocolBugs{ |
| 9298 | SendHelloRetryRequestCurve: bogusCurve, |
| 9299 | }, |
| 9300 | }, |
| 9301 | shouldFail: true, |
| 9302 | expectedError: ":WRONG_CURVE:", |
| 9303 | }) |
| 9304 | |
| 9305 | testCases = append(testCases, testCase{ |
| 9306 | name: "DisabledCurve-HelloRetryRequest", |
| 9307 | config: Config{ |
| 9308 | MaxVersion: VersionTLS13, |
| 9309 | CurvePreferences: []CurveID{CurveP256}, |
| 9310 | Bugs: ProtocolBugs{ |
| 9311 | IgnorePeerCurvePreferences: true, |
| 9312 | }, |
| 9313 | }, |
| 9314 | flags: []string{"-p384-only"}, |
| 9315 | shouldFail: true, |
| 9316 | expectedError: ":WRONG_CURVE:", |
| 9317 | }) |
| 9318 | |
| 9319 | testCases = append(testCases, testCase{ |
| 9320 | name: "UnnecessaryHelloRetryRequest", |
| 9321 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9322 | MaxVersion: VersionTLS13, |
| 9323 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9324 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9325 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9326 | }, |
| 9327 | }, |
| 9328 | shouldFail: true, |
| 9329 | expectedError: ":WRONG_CURVE:", |
| 9330 | }) |
| 9331 | |
| 9332 | testCases = append(testCases, testCase{ |
| 9333 | name: "SecondHelloRetryRequest", |
| 9334 | config: Config{ |
| 9335 | MaxVersion: VersionTLS13, |
| 9336 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9337 | CurvePreferences: []CurveID{CurveP384}, |
| 9338 | Bugs: ProtocolBugs{ |
| 9339 | SecondHelloRetryRequest: true, |
| 9340 | }, |
| 9341 | }, |
| 9342 | shouldFail: true, |
| 9343 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9344 | }) |
| 9345 | |
| 9346 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9347 | name: "HelloRetryRequest-Empty", |
| 9348 | config: Config{ |
| 9349 | MaxVersion: VersionTLS13, |
| 9350 | Bugs: ProtocolBugs{ |
| 9351 | AlwaysSendHelloRetryRequest: true, |
| 9352 | }, |
| 9353 | }, |
| 9354 | shouldFail: true, |
| 9355 | expectedError: ":DECODE_ERROR:", |
| 9356 | }) |
| 9357 | |
| 9358 | testCases = append(testCases, testCase{ |
| 9359 | name: "HelloRetryRequest-DuplicateCurve", |
| 9360 | config: Config{ |
| 9361 | MaxVersion: VersionTLS13, |
| 9362 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9363 | // configuration. Assert this ExpectMissingKeyShare. |
| 9364 | CurvePreferences: []CurveID{CurveP384}, |
| 9365 | Bugs: ProtocolBugs{ |
| 9366 | ExpectMissingKeyShare: true, |
| 9367 | DuplicateHelloRetryRequestExtensions: true, |
| 9368 | }, |
| 9369 | }, |
| 9370 | shouldFail: true, |
| 9371 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9372 | expectedLocalError: "remote error: illegal parameter", |
| 9373 | }) |
| 9374 | |
| 9375 | testCases = append(testCases, testCase{ |
| 9376 | name: "HelloRetryRequest-Cookie", |
| 9377 | config: Config{ |
| 9378 | MaxVersion: VersionTLS13, |
| 9379 | Bugs: ProtocolBugs{ |
| 9380 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9381 | }, |
| 9382 | }, |
| 9383 | }) |
| 9384 | |
| 9385 | testCases = append(testCases, testCase{ |
| 9386 | name: "HelloRetryRequest-DuplicateCookie", |
| 9387 | config: Config{ |
| 9388 | MaxVersion: VersionTLS13, |
| 9389 | Bugs: ProtocolBugs{ |
| 9390 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9391 | DuplicateHelloRetryRequestExtensions: true, |
| 9392 | }, |
| 9393 | }, |
| 9394 | shouldFail: true, |
| 9395 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9396 | expectedLocalError: "remote error: illegal parameter", |
| 9397 | }) |
| 9398 | |
| 9399 | testCases = append(testCases, testCase{ |
| 9400 | name: "HelloRetryRequest-EmptyCookie", |
| 9401 | config: Config{ |
| 9402 | MaxVersion: VersionTLS13, |
| 9403 | Bugs: ProtocolBugs{ |
| 9404 | SendHelloRetryRequestCookie: []byte{}, |
| 9405 | }, |
| 9406 | }, |
| 9407 | shouldFail: true, |
| 9408 | expectedError: ":DECODE_ERROR:", |
| 9409 | }) |
| 9410 | |
| 9411 | testCases = append(testCases, testCase{ |
| 9412 | name: "HelloRetryRequest-Cookie-Curve", |
| 9413 | config: Config{ |
| 9414 | MaxVersion: VersionTLS13, |
| 9415 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9416 | CurvePreferences: []CurveID{CurveP384}, |
| 9417 | Bugs: ProtocolBugs{ |
| 9418 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9419 | ExpectMissingKeyShare: true, |
| 9420 | }, |
| 9421 | }, |
| 9422 | }) |
| 9423 | |
| 9424 | testCases = append(testCases, testCase{ |
| 9425 | name: "HelloRetryRequest-Unknown", |
| 9426 | config: Config{ |
| 9427 | MaxVersion: VersionTLS13, |
| 9428 | Bugs: ProtocolBugs{ |
| 9429 | CustomHelloRetryRequestExtension: "extension", |
| 9430 | }, |
| 9431 | }, |
| 9432 | shouldFail: true, |
| 9433 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9434 | expectedLocalError: "remote error: unsupported extension", |
| 9435 | }) |
| 9436 | |
| 9437 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9438 | testType: serverTest, |
| 9439 | name: "SecondClientHelloMissingKeyShare", |
| 9440 | config: Config{ |
| 9441 | MaxVersion: VersionTLS13, |
| 9442 | DefaultCurves: []CurveID{}, |
| 9443 | Bugs: ProtocolBugs{ |
| 9444 | SecondClientHelloMissingKeyShare: true, |
| 9445 | }, |
| 9446 | }, |
| 9447 | shouldFail: true, |
| 9448 | expectedError: ":MISSING_KEY_SHARE:", |
| 9449 | }) |
| 9450 | |
| 9451 | testCases = append(testCases, testCase{ |
| 9452 | testType: serverTest, |
| 9453 | name: "SecondClientHelloWrongCurve", |
| 9454 | config: Config{ |
| 9455 | MaxVersion: VersionTLS13, |
| 9456 | DefaultCurves: []CurveID{}, |
| 9457 | Bugs: ProtocolBugs{ |
| 9458 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9459 | }, |
| 9460 | }, |
| 9461 | shouldFail: true, |
| 9462 | expectedError: ":WRONG_CURVE:", |
| 9463 | }) |
| 9464 | |
| 9465 | testCases = append(testCases, testCase{ |
| 9466 | name: "HelloRetryRequestVersionMismatch", |
| 9467 | config: Config{ |
| 9468 | MaxVersion: VersionTLS13, |
| 9469 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9470 | CurvePreferences: []CurveID{CurveP384}, |
| 9471 | Bugs: ProtocolBugs{ |
| 9472 | SendServerHelloVersion: 0x0305, |
| 9473 | }, |
| 9474 | }, |
| 9475 | shouldFail: true, |
| 9476 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9477 | }) |
| 9478 | |
| 9479 | testCases = append(testCases, testCase{ |
| 9480 | name: "HelloRetryRequestCurveMismatch", |
| 9481 | config: Config{ |
| 9482 | MaxVersion: VersionTLS13, |
| 9483 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9484 | CurvePreferences: []CurveID{CurveP384}, |
| 9485 | Bugs: ProtocolBugs{ |
| 9486 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9487 | SendHelloRetryRequestCurve: CurveP384, |
| 9488 | // But send P-256 in the ServerHello. |
| 9489 | SendCurve: CurveP256, |
| 9490 | }, |
| 9491 | }, |
| 9492 | shouldFail: true, |
| 9493 | expectedError: ":WRONG_CURVE:", |
| 9494 | }) |
| 9495 | |
| 9496 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9497 | // without sending it. |
| 9498 | testCases = append(testCases, testCase{ |
| 9499 | name: "SkipHelloRetryRequest", |
| 9500 | config: Config{ |
| 9501 | MaxVersion: VersionTLS13, |
| 9502 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9503 | CurvePreferences: []CurveID{CurveP384}, |
| 9504 | Bugs: ProtocolBugs{ |
| 9505 | SkipHelloRetryRequest: true, |
| 9506 | }, |
| 9507 | }, |
| 9508 | shouldFail: true, |
| 9509 | expectedError: ":WRONG_CURVE:", |
| 9510 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9511 | |
| 9512 | testCases = append(testCases, testCase{ |
| 9513 | name: "TLS13-RequestContextInHandshake", |
| 9514 | config: Config{ |
| 9515 | MaxVersion: VersionTLS13, |
| 9516 | MinVersion: VersionTLS13, |
| 9517 | ClientAuth: RequireAnyClientCert, |
| 9518 | Bugs: ProtocolBugs{ |
| 9519 | SendRequestContext: []byte("request context"), |
| 9520 | }, |
| 9521 | }, |
| 9522 | flags: []string{ |
| 9523 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9524 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9525 | }, |
| 9526 | shouldFail: true, |
| 9527 | expectedError: ":DECODE_ERROR:", |
| 9528 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9529 | |
| 9530 | testCases = append(testCases, testCase{ |
| 9531 | testType: serverTest, |
| 9532 | name: "TLS13-TrailingKeyShareData", |
| 9533 | config: Config{ |
| 9534 | MaxVersion: VersionTLS13, |
| 9535 | Bugs: ProtocolBugs{ |
| 9536 | TrailingKeyShareData: true, |
| 9537 | }, |
| 9538 | }, |
| 9539 | shouldFail: true, |
| 9540 | expectedError: ":DECODE_ERROR:", |
| 9541 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9542 | |
| 9543 | testCases = append(testCases, testCase{ |
| 9544 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9545 | config: Config{ |
| 9546 | MaxVersion: VersionTLS13, |
| 9547 | Bugs: ProtocolBugs{ |
| 9548 | AlwaysSelectPSKIdentity: true, |
| 9549 | }, |
| 9550 | }, |
| 9551 | shouldFail: true, |
| 9552 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9553 | }) |
| 9554 | |
| 9555 | testCases = append(testCases, testCase{ |
| 9556 | name: "TLS13-InvalidPSKIdentity", |
| 9557 | config: Config{ |
| 9558 | MaxVersion: VersionTLS13, |
| 9559 | Bugs: ProtocolBugs{ |
| 9560 | SelectPSKIdentityOnResume: 1, |
| 9561 | }, |
| 9562 | }, |
| 9563 | resumeSession: true, |
| 9564 | shouldFail: true, |
| 9565 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9566 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9567 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9568 | testCases = append(testCases, testCase{ |
| 9569 | testType: serverTest, |
| 9570 | name: "TLS13-ExtraPSKIdentity", |
| 9571 | config: Config{ |
| 9572 | MaxVersion: VersionTLS13, |
| 9573 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 9574 | ExtraPSKIdentity: true, |
| 9575 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9576 | }, |
| 9577 | }, |
| 9578 | resumeSession: true, |
| 9579 | }) |
| 9580 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9581 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9582 | testCases = append(testCases, testCase{ |
| 9583 | name: "TLS13-CustomTicketExtension", |
| 9584 | config: Config{ |
| 9585 | MaxVersion: VersionTLS13, |
| 9586 | Bugs: ProtocolBugs{ |
| 9587 | CustomTicketExtension: "1234", |
| 9588 | }, |
| 9589 | }, |
| 9590 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9591 | } |
| 9592 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9593 | func addTLS13CipherPreferenceTests() { |
| 9594 | // Test that client preference is honored if the shim has AES hardware |
| 9595 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9596 | testCases = append(testCases, testCase{ |
| 9597 | testType: serverTest, |
| 9598 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9599 | config: Config{ |
| 9600 | MaxVersion: VersionTLS13, |
| 9601 | CipherSuites: []uint16{ |
| 9602 | TLS_CHACHA20_POLY1305_SHA256, |
| 9603 | TLS_AES_128_GCM_SHA256, |
| 9604 | }, |
| 9605 | }, |
| 9606 | flags: []string{ |
| 9607 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9608 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9609 | }, |
| 9610 | }) |
| 9611 | |
| 9612 | testCases = append(testCases, testCase{ |
| 9613 | testType: serverTest, |
| 9614 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9615 | config: Config{ |
| 9616 | MaxVersion: VersionTLS13, |
| 9617 | CipherSuites: []uint16{ |
| 9618 | TLS_AES_128_GCM_SHA256, |
| 9619 | TLS_CHACHA20_POLY1305_SHA256, |
| 9620 | }, |
| 9621 | }, |
| 9622 | flags: []string{ |
| 9623 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9624 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9625 | }, |
| 9626 | }) |
| 9627 | |
| 9628 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9629 | // whether it has AES hardware. |
| 9630 | testCases = append(testCases, testCase{ |
| 9631 | name: "TLS13-CipherPreference-Client", |
| 9632 | config: Config{ |
| 9633 | MaxVersion: VersionTLS13, |
| 9634 | // Use the client cipher order. (This is the default but |
| 9635 | // is listed to be explicit.) |
| 9636 | PreferServerCipherSuites: false, |
| 9637 | }, |
| 9638 | flags: []string{ |
| 9639 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9640 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9641 | }, |
| 9642 | }) |
| 9643 | } |
| 9644 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9645 | func addPeekTests() { |
| 9646 | // Test SSL_peek works, including on empty records. |
| 9647 | testCases = append(testCases, testCase{ |
| 9648 | name: "Peek-Basic", |
| 9649 | sendEmptyRecords: 1, |
| 9650 | flags: []string{"-peek-then-read"}, |
| 9651 | }) |
| 9652 | |
| 9653 | // Test SSL_peek can drive the initial handshake. |
| 9654 | testCases = append(testCases, testCase{ |
| 9655 | name: "Peek-ImplicitHandshake", |
| 9656 | flags: []string{ |
| 9657 | "-peek-then-read", |
| 9658 | "-implicit-handshake", |
| 9659 | }, |
| 9660 | }) |
| 9661 | |
| 9662 | // Test SSL_peek can discover and drive a renegotiation. |
| 9663 | testCases = append(testCases, testCase{ |
| 9664 | name: "Peek-Renegotiate", |
| 9665 | config: Config{ |
| 9666 | MaxVersion: VersionTLS12, |
| 9667 | }, |
| 9668 | renegotiate: 1, |
| 9669 | flags: []string{ |
| 9670 | "-peek-then-read", |
| 9671 | "-renegotiate-freely", |
| 9672 | "-expect-total-renegotiations", "1", |
| 9673 | }, |
| 9674 | }) |
| 9675 | |
| 9676 | // Test SSL_peek can discover a close_notify. |
| 9677 | testCases = append(testCases, testCase{ |
| 9678 | name: "Peek-Shutdown", |
| 9679 | config: Config{ |
| 9680 | Bugs: ProtocolBugs{ |
| 9681 | ExpectCloseNotify: true, |
| 9682 | }, |
| 9683 | }, |
| 9684 | flags: []string{ |
| 9685 | "-peek-then-read", |
| 9686 | "-check-close-notify", |
| 9687 | }, |
| 9688 | }) |
| 9689 | |
| 9690 | // Test SSL_peek can discover an alert. |
| 9691 | testCases = append(testCases, testCase{ |
| 9692 | name: "Peek-Alert", |
| 9693 | config: Config{ |
| 9694 | Bugs: ProtocolBugs{ |
| 9695 | SendSpuriousAlert: alertRecordOverflow, |
| 9696 | }, |
| 9697 | }, |
| 9698 | flags: []string{"-peek-then-read"}, |
| 9699 | shouldFail: true, |
| 9700 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9701 | }) |
| 9702 | |
| 9703 | // Test SSL_peek can handle KeyUpdate. |
| 9704 | testCases = append(testCases, testCase{ |
| 9705 | name: "Peek-KeyUpdate", |
| 9706 | config: Config{ |
| 9707 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9708 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9709 | sendKeyUpdates: 1, |
| 9710 | keyUpdateRequest: keyUpdateNotRequested, |
| 9711 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9712 | }) |
| 9713 | } |
| 9714 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9715 | func addRecordVersionTests() { |
| 9716 | for _, ver := range tlsVersions { |
| 9717 | // Test that the record version is enforced. |
| 9718 | testCases = append(testCases, testCase{ |
| 9719 | name: "CheckRecordVersion-" + ver.name, |
| 9720 | config: Config{ |
| 9721 | MinVersion: ver.version, |
| 9722 | MaxVersion: ver.version, |
| 9723 | Bugs: ProtocolBugs{ |
| 9724 | SendRecordVersion: 0x03ff, |
| 9725 | }, |
| 9726 | }, |
| 9727 | shouldFail: true, |
| 9728 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9729 | }) |
| 9730 | |
| 9731 | // Test that the ClientHello may use any record version, for |
| 9732 | // compatibility reasons. |
| 9733 | testCases = append(testCases, testCase{ |
| 9734 | testType: serverTest, |
| 9735 | name: "LooseInitialRecordVersion-" + ver.name, |
| 9736 | config: Config{ |
| 9737 | MinVersion: ver.version, |
| 9738 | MaxVersion: ver.version, |
| 9739 | Bugs: ProtocolBugs{ |
| 9740 | SendInitialRecordVersion: 0x03ff, |
| 9741 | }, |
| 9742 | }, |
| 9743 | }) |
| 9744 | |
| 9745 | // Test that garbage ClientHello record versions are rejected. |
| 9746 | testCases = append(testCases, testCase{ |
| 9747 | testType: serverTest, |
| 9748 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 9749 | config: Config{ |
| 9750 | MinVersion: ver.version, |
| 9751 | MaxVersion: ver.version, |
| 9752 | Bugs: ProtocolBugs{ |
| 9753 | SendInitialRecordVersion: 0xffff, |
| 9754 | }, |
| 9755 | }, |
| 9756 | shouldFail: true, |
| 9757 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9758 | }) |
| 9759 | } |
| 9760 | } |
| 9761 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9762 | func addCertificateTests() { |
| 9763 | // Test that a certificate chain with intermediate may be sent and |
| 9764 | // received as both client and server. |
| 9765 | for _, ver := range tlsVersions { |
| 9766 | testCases = append(testCases, testCase{ |
| 9767 | testType: clientTest, |
| 9768 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 9769 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9770 | MinVersion: ver.version, |
| 9771 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9772 | Certificates: []Certificate{rsaChainCertificate}, |
| 9773 | ClientAuth: RequireAnyClientCert, |
| 9774 | }, |
| 9775 | expectPeerCertificate: &rsaChainCertificate, |
| 9776 | flags: []string{ |
| 9777 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9778 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9779 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9780 | }, |
| 9781 | }) |
| 9782 | |
| 9783 | testCases = append(testCases, testCase{ |
| 9784 | testType: serverTest, |
| 9785 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 9786 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9787 | MinVersion: ver.version, |
| 9788 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9789 | Certificates: []Certificate{rsaChainCertificate}, |
| 9790 | }, |
| 9791 | expectPeerCertificate: &rsaChainCertificate, |
| 9792 | flags: []string{ |
| 9793 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9794 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9795 | "-require-any-client-certificate", |
| 9796 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9797 | }, |
| 9798 | }) |
| 9799 | } |
| 9800 | } |
| 9801 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9802 | func addRetainOnlySHA256ClientCertTests() { |
| 9803 | for _, ver := range tlsVersions { |
| 9804 | // Test that enabling |
| 9805 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 9806 | // actually requesting a client certificate is a no-op. |
| 9807 | testCases = append(testCases, testCase{ |
| 9808 | testType: serverTest, |
| 9809 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 9810 | config: Config{ |
| 9811 | MinVersion: ver.version, |
| 9812 | MaxVersion: ver.version, |
| 9813 | }, |
| 9814 | flags: []string{ |
| 9815 | "-retain-only-sha256-client-cert-initial", |
| 9816 | "-retain-only-sha256-client-cert-resume", |
| 9817 | }, |
| 9818 | resumeSession: true, |
| 9819 | }) |
| 9820 | |
| 9821 | // Test that when retaining only a SHA-256 certificate is |
| 9822 | // enabled, the hash appears as expected. |
| 9823 | testCases = append(testCases, testCase{ |
| 9824 | testType: serverTest, |
| 9825 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 9826 | config: Config{ |
| 9827 | MinVersion: ver.version, |
| 9828 | MaxVersion: ver.version, |
| 9829 | Certificates: []Certificate{rsaCertificate}, |
| 9830 | }, |
| 9831 | flags: []string{ |
| 9832 | "-verify-peer", |
| 9833 | "-retain-only-sha256-client-cert-initial", |
| 9834 | "-retain-only-sha256-client-cert-resume", |
| 9835 | "-expect-sha256-client-cert-initial", |
| 9836 | "-expect-sha256-client-cert-resume", |
| 9837 | }, |
| 9838 | resumeSession: true, |
| 9839 | }) |
| 9840 | |
| 9841 | // Test that when the config changes from on to off, a |
| 9842 | // resumption is rejected because the server now wants the full |
| 9843 | // certificate chain. |
| 9844 | testCases = append(testCases, testCase{ |
| 9845 | testType: serverTest, |
| 9846 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 9847 | config: Config{ |
| 9848 | MinVersion: ver.version, |
| 9849 | MaxVersion: ver.version, |
| 9850 | Certificates: []Certificate{rsaCertificate}, |
| 9851 | }, |
| 9852 | flags: []string{ |
| 9853 | "-verify-peer", |
| 9854 | "-retain-only-sha256-client-cert-initial", |
| 9855 | "-expect-sha256-client-cert-initial", |
| 9856 | }, |
| 9857 | resumeSession: true, |
| 9858 | expectResumeRejected: true, |
| 9859 | }) |
| 9860 | |
| 9861 | // Test that when the config changes from off to on, a |
| 9862 | // resumption is rejected because the server now wants just the |
| 9863 | // hash. |
| 9864 | testCases = append(testCases, testCase{ |
| 9865 | testType: serverTest, |
| 9866 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 9867 | config: Config{ |
| 9868 | MinVersion: ver.version, |
| 9869 | MaxVersion: ver.version, |
| 9870 | Certificates: []Certificate{rsaCertificate}, |
| 9871 | }, |
| 9872 | flags: []string{ |
| 9873 | "-verify-peer", |
| 9874 | "-retain-only-sha256-client-cert-resume", |
| 9875 | "-expect-sha256-client-cert-resume", |
| 9876 | }, |
| 9877 | resumeSession: true, |
| 9878 | expectResumeRejected: true, |
| 9879 | }) |
| 9880 | } |
| 9881 | } |
| 9882 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 9883 | func addECDSAKeyUsageTests() { |
| 9884 | p256 := elliptic.P256() |
| 9885 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 9886 | if err != nil { |
| 9887 | panic(err) |
| 9888 | } |
| 9889 | |
| 9890 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 9891 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 9892 | if err != nil { |
| 9893 | panic(err) |
| 9894 | } |
| 9895 | |
| 9896 | template := x509.Certificate{ |
| 9897 | SerialNumber: serialNumber, |
| 9898 | Subject: pkix.Name{ |
| 9899 | Organization: []string{"Acme Co"}, |
| 9900 | }, |
| 9901 | NotBefore: time.Now(), |
| 9902 | NotAfter: time.Now(), |
| 9903 | |
| 9904 | // An ECC certificate with only the keyAgreement key usgae may |
| 9905 | // be used with ECDH, but not ECDSA. |
| 9906 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 9907 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 9908 | BasicConstraintsValid: true, |
| 9909 | } |
| 9910 | |
| 9911 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 9912 | if err != nil { |
| 9913 | panic(err) |
| 9914 | } |
| 9915 | |
| 9916 | cert := Certificate{ |
| 9917 | Certificate: [][]byte{derBytes}, |
| 9918 | PrivateKey: priv, |
| 9919 | } |
| 9920 | |
| 9921 | for _, ver := range tlsVersions { |
| 9922 | if ver.version < VersionTLS12 { |
| 9923 | continue |
| 9924 | } |
| 9925 | |
| 9926 | testCases = append(testCases, testCase{ |
| 9927 | testType: clientTest, |
| 9928 | name: "ECDSAKeyUsage-" + ver.name, |
| 9929 | config: Config{ |
| 9930 | MinVersion: ver.version, |
| 9931 | MaxVersion: ver.version, |
| 9932 | Certificates: []Certificate{cert}, |
| 9933 | }, |
| 9934 | shouldFail: true, |
| 9935 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 9936 | }) |
| 9937 | } |
| 9938 | } |
| 9939 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 9940 | func addShortHeaderTests() { |
| 9941 | // The short header extension may be negotiated as either client or |
| 9942 | // server. |
| 9943 | testCases = append(testCases, testCase{ |
| 9944 | name: "ShortHeader-Client", |
| 9945 | config: Config{ |
| 9946 | MaxVersion: VersionTLS13, |
| 9947 | Bugs: ProtocolBugs{ |
| 9948 | EnableShortHeader: true, |
| 9949 | }, |
| 9950 | }, |
| 9951 | flags: []string{"-enable-short-header"}, |
| 9952 | expectShortHeader: true, |
| 9953 | }) |
| 9954 | testCases = append(testCases, testCase{ |
| 9955 | testType: serverTest, |
| 9956 | name: "ShortHeader-Server", |
| 9957 | config: Config{ |
| 9958 | MaxVersion: VersionTLS13, |
| 9959 | Bugs: ProtocolBugs{ |
| 9960 | EnableShortHeader: true, |
| 9961 | }, |
| 9962 | }, |
| 9963 | flags: []string{"-enable-short-header"}, |
| 9964 | expectShortHeader: true, |
| 9965 | }) |
| 9966 | |
| 9967 | // If the peer doesn't support it, it will not be negotiated. |
| 9968 | testCases = append(testCases, testCase{ |
| 9969 | name: "ShortHeader-No-Yes-Client", |
| 9970 | config: Config{ |
| 9971 | MaxVersion: VersionTLS13, |
| 9972 | }, |
| 9973 | flags: []string{"-enable-short-header"}, |
| 9974 | }) |
| 9975 | testCases = append(testCases, testCase{ |
| 9976 | testType: serverTest, |
| 9977 | name: "ShortHeader-No-Yes-Server", |
| 9978 | config: Config{ |
| 9979 | MaxVersion: VersionTLS13, |
| 9980 | }, |
| 9981 | flags: []string{"-enable-short-header"}, |
| 9982 | }) |
| 9983 | |
| 9984 | // If we don't support it, it will not be negotiated. |
| 9985 | testCases = append(testCases, testCase{ |
| 9986 | name: "ShortHeader-Yes-No-Client", |
| 9987 | config: Config{ |
| 9988 | MaxVersion: VersionTLS13, |
| 9989 | Bugs: ProtocolBugs{ |
| 9990 | EnableShortHeader: true, |
| 9991 | }, |
| 9992 | }, |
| 9993 | }) |
| 9994 | testCases = append(testCases, testCase{ |
| 9995 | testType: serverTest, |
| 9996 | name: "ShortHeader-Yes-No-Server", |
| 9997 | config: Config{ |
| 9998 | MaxVersion: VersionTLS13, |
| 9999 | Bugs: ProtocolBugs{ |
| 10000 | EnableShortHeader: true, |
| 10001 | }, |
| 10002 | }, |
| 10003 | }) |
| 10004 | |
| 10005 | // It will not be negotiated at TLS 1.2. |
| 10006 | testCases = append(testCases, testCase{ |
| 10007 | name: "ShortHeader-TLS12-Client", |
| 10008 | config: Config{ |
| 10009 | MaxVersion: VersionTLS12, |
| 10010 | Bugs: ProtocolBugs{ |
| 10011 | EnableShortHeader: true, |
| 10012 | }, |
| 10013 | }, |
| 10014 | flags: []string{"-enable-short-header"}, |
| 10015 | }) |
| 10016 | testCases = append(testCases, testCase{ |
| 10017 | testType: serverTest, |
| 10018 | name: "ShortHeader-TLS12-Server", |
| 10019 | config: Config{ |
| 10020 | MaxVersion: VersionTLS12, |
| 10021 | Bugs: ProtocolBugs{ |
| 10022 | EnableShortHeader: true, |
| 10023 | }, |
| 10024 | }, |
| 10025 | flags: []string{"-enable-short-header"}, |
| 10026 | }) |
| 10027 | |
| 10028 | // Servers reject early data and short header sent together. |
| 10029 | testCases = append(testCases, testCase{ |
| 10030 | testType: serverTest, |
| 10031 | name: "ShortHeader-EarlyData", |
| 10032 | config: Config{ |
| 10033 | MaxVersion: VersionTLS13, |
| 10034 | Bugs: ProtocolBugs{ |
| 10035 | EnableShortHeader: true, |
| 10036 | SendEarlyDataLength: 1, |
| 10037 | }, |
| 10038 | }, |
| 10039 | flags: []string{"-enable-short-header"}, |
| 10040 | shouldFail: true, |
| 10041 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10042 | }) |
| 10043 | |
| 10044 | // Clients reject unsolicited short header extensions. |
| 10045 | testCases = append(testCases, testCase{ |
| 10046 | name: "ShortHeader-Unsolicited", |
| 10047 | config: Config{ |
| 10048 | MaxVersion: VersionTLS13, |
| 10049 | Bugs: ProtocolBugs{ |
| 10050 | AlwaysNegotiateShortHeader: true, |
| 10051 | }, |
| 10052 | }, |
| 10053 | shouldFail: true, |
| 10054 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10055 | }) |
| 10056 | testCases = append(testCases, testCase{ |
| 10057 | name: "ShortHeader-Unsolicited-TLS12", |
| 10058 | config: Config{ |
| 10059 | MaxVersion: VersionTLS12, |
| 10060 | Bugs: ProtocolBugs{ |
| 10061 | AlwaysNegotiateShortHeader: true, |
| 10062 | }, |
| 10063 | }, |
| 10064 | shouldFail: true, |
| 10065 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10066 | }) |
| 10067 | |
| 10068 | // The high bit must be checked in short headers. |
| 10069 | testCases = append(testCases, testCase{ |
| 10070 | name: "ShortHeader-ClearShortHeaderBit", |
| 10071 | config: Config{ |
| 10072 | Bugs: ProtocolBugs{ |
| 10073 | EnableShortHeader: true, |
| 10074 | ClearShortHeaderBit: true, |
| 10075 | }, |
| 10076 | }, |
| 10077 | flags: []string{"-enable-short-header"}, |
| 10078 | shouldFail: true, |
| 10079 | expectedError: ":DECODE_ERROR:", |
| 10080 | expectedLocalError: "remote error: error decoding message", |
| 10081 | }) |
| 10082 | } |
| 10083 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10084 | 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] | 10085 | defer wg.Done() |
| 10086 | |
| 10087 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10088 | var err error |
| 10089 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10090 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10091 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 10092 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10093 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10094 | if err != nil { |
| 10095 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 10096 | } |
| 10097 | break |
| 10098 | } |
| 10099 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10100 | } else if *repeatUntilFailure { |
| 10101 | for err == nil { |
| 10102 | statusChan <- statusMsg{test: test, started: true} |
| 10103 | err = runTest(test, shimPath, -1) |
| 10104 | } |
| 10105 | } else { |
| 10106 | statusChan <- statusMsg{test: test, started: true} |
| 10107 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10108 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10109 | statusChan <- statusMsg{test: test, err: err} |
| 10110 | } |
| 10111 | } |
| 10112 | |
| 10113 | type statusMsg struct { |
| 10114 | test *testCase |
| 10115 | started bool |
| 10116 | err error |
| 10117 | } |
| 10118 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10119 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10120 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10121 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10122 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10123 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10124 | if !*pipe { |
| 10125 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 10126 | var erase string |
| 10127 | for i := 0; i < lineLen; i++ { |
| 10128 | erase += "\b \b" |
| 10129 | } |
| 10130 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10131 | } |
| 10132 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10133 | if msg.started { |
| 10134 | started++ |
| 10135 | } else { |
| 10136 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10137 | |
| 10138 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10139 | if msg.err == errUnimplemented { |
| 10140 | if *pipe { |
| 10141 | // Print each test instead of a status line. |
| 10142 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 10143 | } |
| 10144 | unimplemented++ |
| 10145 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 10146 | } else { |
| 10147 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 10148 | failed++ |
| 10149 | testOutput.addResult(msg.test.name, "FAIL") |
| 10150 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10151 | } else { |
| 10152 | if *pipe { |
| 10153 | // Print each test instead of a status line. |
| 10154 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 10155 | } |
| 10156 | testOutput.addResult(msg.test.name, "PASS") |
| 10157 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10158 | } |
| 10159 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10160 | if !*pipe { |
| 10161 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10162 | 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] | 10163 | lineLen = len(line) |
| 10164 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10165 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10166 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10167 | |
| 10168 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10169 | } |
| 10170 | |
| 10171 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10172 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10173 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 10174 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10175 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10176 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10177 | addCipherSuiteTests() |
| 10178 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10179 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 10180 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 10181 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 10182 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 10183 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 10184 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 10185 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 10186 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 10187 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 10188 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 10189 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 10190 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 10191 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 10192 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 10193 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 10194 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 10195 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 10196 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 10197 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 10198 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 10199 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10200 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10201 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10202 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10203 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 10204 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10205 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 10206 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10207 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 10208 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 10209 | addECDSAKeyUsageTests() |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 10210 | addShortHeaderTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10211 | |
| 10212 | var wg sync.WaitGroup |
| 10213 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10214 | statusChan := make(chan statusMsg, *numWorkers) |
| 10215 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10216 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10217 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10218 | if len(*shimConfigFile) != 0 { |
| 10219 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 10220 | if err != nil { |
| 10221 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 10222 | os.Exit(1) |
| 10223 | } |
| 10224 | |
| 10225 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 10226 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 10227 | os.Exit(1) |
| 10228 | } |
| 10229 | } |
| 10230 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10231 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10232 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10233 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10234 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10235 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10236 | } |
| 10237 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10238 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10239 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10240 | matched := true |
| 10241 | if len(*testToRun) != 0 { |
| 10242 | var err error |
| 10243 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 10244 | if err != nil { |
| 10245 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 10246 | os.Exit(1) |
| 10247 | } |
| 10248 | } |
| 10249 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10250 | if !*includeDisabled { |
| 10251 | for pattern := range shimConfig.DisabledTests { |
| 10252 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 10253 | if err != nil { |
| 10254 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 10255 | os.Exit(1) |
| 10256 | } |
| 10257 | |
| 10258 | if isDisabled { |
| 10259 | matched = false |
| 10260 | break |
| 10261 | } |
| 10262 | } |
| 10263 | } |
| 10264 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10265 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10266 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10267 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10268 | |
| 10269 | // Only run one test if repeating until failure. |
| 10270 | if *repeatUntilFailure { |
| 10271 | break |
| 10272 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10273 | } |
| 10274 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10275 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10276 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10277 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10278 | os.Exit(1) |
| 10279 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10280 | |
| 10281 | close(testChan) |
| 10282 | wg.Wait() |
| 10283 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10284 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10285 | |
| 10286 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10287 | |
| 10288 | if *jsonOutput != "" { |
| 10289 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 10290 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 10291 | } |
| 10292 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10293 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10294 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 10295 | os.Exit(1) |
| 10296 | } |
| 10297 | |
| 10298 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10299 | os.Exit(1) |
| 10300 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10301 | } |