Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2016, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 14 | |
Adam Langley | dc7e9c4 | 2015-09-29 15:21:04 -0700 | [diff] [blame] | 15 | package runner |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 19 | "crypto/ecdsa" |
| 20 | "crypto/elliptic" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 21 | "crypto/x509" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 22 | "encoding/base64" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 23 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 24 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 25 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 26 | "flag" |
| 27 | "fmt" |
| 28 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 29 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 30 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 31 | "net" |
| 32 | "os" |
| 33 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 34 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 35 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 36 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 37 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 38 | "strings" |
| 39 | "sync" |
| 40 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 41 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 42 | ) |
| 43 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 44 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 45 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 46 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 47 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 48 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 49 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 50 | mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask bssl_shim to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.") |
| 51 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 52 | pipe = flag.Bool("pipe", false, "If true, print status output suitable for piping into another program.") |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 53 | testToRun = flag.String("test", "", "The pattern to filter tests to run, or empty to run all tests") |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 54 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 55 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 56 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 57 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 58 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 59 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 60 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 61 | allowUnimplemented = flag.Bool("allow-unimplemented", false, "If true, report pass even if some tests are unimplemented.") |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 62 | looseErrors = flag.Bool("loose-errors", false, "If true, allow shims to report an untranslated error code.") |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 63 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 64 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 65 | repeatUntilFailure = flag.Bool("repeat-until-failure", false, "If true, the first selected test will be run repeatedly until failure.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 66 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 67 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 68 | // ShimConfigurations is used with the “json” package and represents a shim |
| 69 | // config file. |
| 70 | type ShimConfiguration struct { |
| 71 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 72 | // The glob pattern is used to exclude tests from being run and the |
| 73 | // freeform string is unparsed but expected to explain why the test is |
| 74 | // disabled. |
| 75 | DisabledTests map[string]string |
| 76 | |
| 77 | // ErrorMap maps from expected error strings to the correct error |
| 78 | // string for the shim in question. For example, it might map |
| 79 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 80 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 81 | ErrorMap map[string]string |
| 82 | } |
| 83 | |
| 84 | var shimConfig ShimConfiguration |
| 85 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 86 | type testCert int |
| 87 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 88 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 89 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 90 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 91 | testCertRSAChain |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 92 | testCertECDSAP256 |
| 93 | testCertECDSAP384 |
| 94 | testCertECDSAP521 |
| 95 | ) |
| 96 | |
| 97 | const ( |
| 98 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 99 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 100 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 101 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 102 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 103 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 104 | ) |
| 105 | |
| 106 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 107 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 108 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 109 | rsaChainKeyFile = "rsa_chain_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 110 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 111 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 112 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 113 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 114 | ) |
| 115 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 116 | var ( |
| 117 | rsaCertificate Certificate |
| 118 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 119 | rsaChainCertificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 120 | ecdsaP256Certificate Certificate |
| 121 | ecdsaP384Certificate Certificate |
| 122 | ecdsaP521Certificate Certificate |
| 123 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 124 | |
| 125 | var testCerts = []struct { |
| 126 | id testCert |
| 127 | certFile, keyFile string |
| 128 | cert *Certificate |
| 129 | }{ |
| 130 | { |
| 131 | id: testCertRSA, |
| 132 | certFile: rsaCertificateFile, |
| 133 | keyFile: rsaKeyFile, |
| 134 | cert: &rsaCertificate, |
| 135 | }, |
| 136 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 137 | id: testCertRSA1024, |
| 138 | certFile: rsa1024CertificateFile, |
| 139 | keyFile: rsa1024KeyFile, |
| 140 | cert: &rsa1024Certificate, |
| 141 | }, |
| 142 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 143 | id: testCertRSAChain, |
| 144 | certFile: rsaChainCertificateFile, |
| 145 | keyFile: rsaChainKeyFile, |
| 146 | cert: &rsaChainCertificate, |
| 147 | }, |
| 148 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 149 | id: testCertECDSAP256, |
| 150 | certFile: ecdsaP256CertificateFile, |
| 151 | keyFile: ecdsaP256KeyFile, |
| 152 | cert: &ecdsaP256Certificate, |
| 153 | }, |
| 154 | { |
| 155 | id: testCertECDSAP384, |
| 156 | certFile: ecdsaP384CertificateFile, |
| 157 | keyFile: ecdsaP384KeyFile, |
| 158 | cert: &ecdsaP384Certificate, |
| 159 | }, |
| 160 | { |
| 161 | id: testCertECDSAP521, |
| 162 | certFile: ecdsaP521CertificateFile, |
| 163 | keyFile: ecdsaP521KeyFile, |
| 164 | cert: &ecdsaP521Certificate, |
| 165 | }, |
| 166 | } |
| 167 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 168 | var channelIDKey *ecdsa.PrivateKey |
| 169 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 170 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 171 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 172 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 173 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 174 | var testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 175 | var testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, byte(len(testSCTList))}, testSCTList...) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 176 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 177 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 178 | for i := range testCerts { |
| 179 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 180 | if err != nil { |
| 181 | panic(err) |
| 182 | } |
| 183 | cert.OCSPStaple = testOCSPResponse |
| 184 | cert.SignedCertificateTimestampList = testSCTList |
| 185 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 186 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 187 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 188 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 189 | if err != nil { |
| 190 | panic(err) |
| 191 | } |
| 192 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 193 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 194 | panic("bad key type") |
| 195 | } |
| 196 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 197 | if err != nil { |
| 198 | panic(err) |
| 199 | } |
| 200 | if channelIDKey.Curve != elliptic.P256() { |
| 201 | panic("bad curve") |
| 202 | } |
| 203 | |
| 204 | channelIDBytes = make([]byte, 64) |
| 205 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 206 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | } |
| 208 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 209 | func getRunnerCertificate(t testCert) Certificate { |
| 210 | for _, cert := range testCerts { |
| 211 | if cert.id == t { |
| 212 | return *cert.cert |
| 213 | } |
| 214 | } |
| 215 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | } |
| 217 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 218 | func getShimCertificate(t testCert) string { |
| 219 | for _, cert := range testCerts { |
| 220 | if cert.id == t { |
| 221 | return cert.certFile |
| 222 | } |
| 223 | } |
| 224 | panic("Unknown test certificate") |
| 225 | } |
| 226 | |
| 227 | func getShimKey(t testCert) string { |
| 228 | for _, cert := range testCerts { |
| 229 | if cert.id == t { |
| 230 | return cert.keyFile |
| 231 | } |
| 232 | } |
| 233 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 234 | } |
| 235 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 236 | type testType int |
| 237 | |
| 238 | const ( |
| 239 | clientTest testType = iota |
| 240 | serverTest |
| 241 | ) |
| 242 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 243 | type protocol int |
| 244 | |
| 245 | const ( |
| 246 | tls protocol = iota |
| 247 | dtls |
| 248 | ) |
| 249 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 250 | const ( |
| 251 | alpn = 1 |
| 252 | npn = 2 |
| 253 | ) |
| 254 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 255 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 256 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 257 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 258 | name string |
| 259 | config Config |
| 260 | shouldFail bool |
| 261 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 262 | // expectedLocalError, if not empty, contains a substring that must be |
| 263 | // found in the local error. |
| 264 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 265 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 266 | // negotiated. |
| 267 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 268 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 269 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 270 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 271 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 272 | // should be negotiated. |
| 273 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 274 | // expectChannelID controls whether the connection should have |
| 275 | // negotiated a Channel ID with channelIDKey. |
| 276 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 277 | // expectedNextProto controls whether the connection should |
| 278 | // negotiate a next protocol via NPN or ALPN. |
| 279 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 280 | // expectNoNextProto, if true, means that no next protocol should be |
| 281 | // negotiated. |
| 282 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 283 | // expectedNextProtoType, if non-zero, is the expected next |
| 284 | // protocol negotiation mechanism. |
| 285 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 286 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 287 | // should be negotiated. If zero, none should be negotiated. |
| 288 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 289 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 290 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 291 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 292 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 293 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 294 | // algorithm that the peer should have used in the handshake. |
| 295 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 296 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 297 | // have used. |
| 298 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 299 | // messageLen is the length, in bytes, of the test message that will be |
| 300 | // sent. |
| 301 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 302 | // messageCount is the number of test messages that will be sent. |
| 303 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 304 | // certFile is the path to the certificate to use for the server. |
| 305 | certFile string |
| 306 | // keyFile is the path to the private key to use for the server. |
| 307 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 308 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 309 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 310 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 311 | // resumeRenewedSession controls whether a third connection should be |
| 312 | // tested which attempts to resume the second connection's session. |
| 313 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 314 | // expectResumeRejected, if true, specifies that the attempted |
| 315 | // resumption must be rejected by the client. This is only valid for a |
| 316 | // serverTest. |
| 317 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 318 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 319 | // resumption. Unless newSessionsOnResume is set, |
| 320 | // SessionTicketKey, ServerSessionCache, and |
| 321 | // ClientSessionCache are copied from the initial connection's |
| 322 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 323 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 324 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 325 | // use a different session resumption context. |
| 326 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 327 | // noSessionCache, if true, will cause the server to run without a |
| 328 | // session cache. |
| 329 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 330 | // sendPrefix sends a prefix on the socket before actually performing a |
| 331 | // handshake. |
| 332 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 333 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 334 | // message before doing a roundtrip with the runner. |
| 335 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 336 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 337 | // connection immediately after the handshake rather than echoing |
| 338 | // messages from the runner. |
| 339 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 340 | // renegotiate indicates the number of times the connection should be |
| 341 | // renegotiated during the exchange. |
| 342 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 343 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 344 | // HelloRequest when the handshake completes. |
| 345 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 346 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 347 | // switched in just before renegotiation. |
| 348 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 349 | // replayWrites, if true, configures the underlying transport |
| 350 | // to replay every write it makes in DTLS tests. |
| 351 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 352 | // damageFirstWrite, if true, configures the underlying transport to |
| 353 | // damage the final byte of the first application data write. |
| 354 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 355 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 356 | // keying material and verify they match. |
| 357 | exportKeyingMaterial int |
| 358 | exportLabel string |
| 359 | exportContext string |
| 360 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 361 | // flags, if not empty, contains a list of command-line flags that will |
| 362 | // be passed to the shim program. |
| 363 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 364 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 365 | // which will be compared against the expected value. |
| 366 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 367 | // sendEmptyRecords is the number of consecutive empty records to send |
| 368 | // before and after the test message. |
| 369 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 370 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 371 | // before and after the test message. |
| 372 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 373 | // sendKeyUpdates is the number of consecutive key updates to send |
| 374 | // before and after the test message. |
| 375 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 376 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 377 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 378 | // expectMessageDropped, if true, means the test message is expected to |
| 379 | // be dropped by the client rather than echoed back. |
| 380 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 381 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 382 | // is expected to send. |
| 383 | expectPeerCertificate *Certificate |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 386 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 387 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 388 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 389 | if len(data) == 0 { |
| 390 | return |
| 391 | } |
| 392 | |
| 393 | protocol := "tls" |
| 394 | if test.protocol == dtls { |
| 395 | protocol = "dtls" |
| 396 | } |
| 397 | |
| 398 | side := "client" |
| 399 | if test.testType == serverTest { |
| 400 | side = "server" |
| 401 | } |
| 402 | |
| 403 | dir := path.Join(*transcriptDir, protocol, side) |
| 404 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 405 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 406 | return |
| 407 | } |
| 408 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 409 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 410 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 411 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 412 | } |
| 413 | } |
| 414 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 415 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 416 | type timeoutConn struct { |
| 417 | net.Conn |
| 418 | timeout time.Duration |
| 419 | } |
| 420 | |
| 421 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 422 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 423 | return 0, err |
| 424 | } |
| 425 | return t.Conn.Read(b) |
| 426 | } |
| 427 | |
| 428 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 429 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 430 | return 0, err |
| 431 | } |
| 432 | return t.Conn.Write(b) |
| 433 | } |
| 434 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 435 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 436 | if !test.noSessionCache { |
| 437 | if config.ClientSessionCache == nil { |
| 438 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 439 | } |
| 440 | if config.ServerSessionCache == nil { |
| 441 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 442 | } |
| 443 | } |
| 444 | if test.testType == clientTest { |
| 445 | if len(config.Certificates) == 0 { |
| 446 | config.Certificates = []Certificate{rsaCertificate} |
| 447 | } |
| 448 | } else { |
| 449 | // Supply a ServerName to ensure a constant session cache key, |
| 450 | // rather than falling back to net.Conn.RemoteAddr. |
| 451 | if len(config.ServerName) == 0 { |
| 452 | config.ServerName = "test" |
| 453 | } |
| 454 | } |
| 455 | if *fuzzer { |
| 456 | config.Bugs.NullAllCiphers = true |
| 457 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 458 | if *deterministic { |
| 459 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 460 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 461 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 462 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 463 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 464 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 465 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 466 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 467 | } |
| 468 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 469 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 470 | local, peer := "client", "server" |
| 471 | if test.testType == clientTest { |
| 472 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 473 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 474 | connDebug := &recordingConn{ |
| 475 | Conn: conn, |
| 476 | isDatagram: test.protocol == dtls, |
| 477 | local: local, |
| 478 | peer: peer, |
| 479 | } |
| 480 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | if *flagDebug { |
| 482 | defer connDebug.WriteTo(os.Stdout) |
| 483 | } |
| 484 | if len(*transcriptDir) != 0 { |
| 485 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 486 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 487 | }() |
| 488 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 489 | |
| 490 | if config.Bugs.PacketAdaptor != nil { |
| 491 | config.Bugs.PacketAdaptor.debug = connDebug |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | if test.replayWrites { |
| 496 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 497 | } |
| 498 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 499 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 500 | if test.damageFirstWrite { |
| 501 | connDamage = newDamageAdaptor(conn) |
| 502 | conn = connDamage |
| 503 | } |
| 504 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 505 | if test.sendPrefix != "" { |
| 506 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 507 | return err |
| 508 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 509 | } |
| 510 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 511 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 512 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 513 | if test.protocol == dtls { |
| 514 | tlsConn = DTLSServer(conn, config) |
| 515 | } else { |
| 516 | tlsConn = Server(conn, config) |
| 517 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 518 | } else { |
| 519 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 520 | if test.protocol == dtls { |
| 521 | tlsConn = DTLSClient(conn, config) |
| 522 | } else { |
| 523 | tlsConn = Client(conn, config) |
| 524 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 525 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 526 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 527 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 528 | if err := tlsConn.Handshake(); err != nil { |
| 529 | return err |
| 530 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 531 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 532 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 533 | // expectations struct that can be specified separately for the two |
| 534 | // legs. |
| 535 | expectedVersion := test.expectedVersion |
| 536 | if isResume && test.expectedResumeVersion != 0 { |
| 537 | expectedVersion = test.expectedResumeVersion |
| 538 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 539 | connState := tlsConn.ConnectionState() |
| 540 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 541 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 542 | } |
| 543 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 544 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 545 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 546 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 547 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 548 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 549 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 550 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 551 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 552 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 553 | if channelID == nil { |
| 554 | return fmt.Errorf("no channel ID negotiated") |
| 555 | } |
| 556 | if channelID.Curve != channelIDKey.Curve || |
| 557 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 558 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 559 | return fmt.Errorf("incorrect channel ID") |
| 560 | } |
| 561 | } |
| 562 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 563 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 564 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 565 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 566 | } |
| 567 | } |
| 568 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 569 | if test.expectNoNextProto { |
| 570 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 571 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 572 | } |
| 573 | } |
| 574 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 575 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 576 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 577 | return fmt.Errorf("next proto type mismatch") |
| 578 | } |
| 579 | } |
| 580 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 581 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 582 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 583 | } |
| 584 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 585 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 586 | return fmt.Errorf("OCSP Response mismatch: got %x, wanted %x", tlsConn.OCSPResponse(), test.expectedOCSPResponse) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 587 | } |
| 588 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 589 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 590 | return fmt.Errorf("SCT list mismatch") |
| 591 | } |
| 592 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 593 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 594 | return fmt.Errorf("expected peer to use signature algorithm %04x, but got %04x", expected, connState.PeerSignatureAlgorithm) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 595 | } |
| 596 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 597 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 598 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 599 | } |
| 600 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 601 | if test.expectPeerCertificate != nil { |
| 602 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 603 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 604 | } |
| 605 | for i, cert := range connState.PeerCertificates { |
| 606 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 607 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 612 | if test.exportKeyingMaterial > 0 { |
| 613 | actual := make([]byte, test.exportKeyingMaterial) |
| 614 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 615 | return err |
| 616 | } |
| 617 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 618 | if err != nil { |
| 619 | return err |
| 620 | } |
| 621 | if !bytes.Equal(actual, expected) { |
| 622 | return fmt.Errorf("keying material mismatch") |
| 623 | } |
| 624 | } |
| 625 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 626 | if test.testTLSUnique { |
| 627 | var peersValue [12]byte |
| 628 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 629 | return err |
| 630 | } |
| 631 | expected := tlsConn.ConnectionState().TLSUnique |
| 632 | if !bytes.Equal(peersValue[:], expected) { |
| 633 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 634 | } |
| 635 | } |
| 636 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 637 | if test.shimWritesFirst { |
| 638 | var buf [5]byte |
| 639 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 640 | if err != nil { |
| 641 | return err |
| 642 | } |
| 643 | if string(buf[:]) != "hello" { |
| 644 | return fmt.Errorf("bad initial message") |
| 645 | } |
| 646 | } |
| 647 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 648 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 649 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 650 | return err |
| 651 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 652 | } |
| 653 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 654 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 655 | tlsConn.Write(nil) |
| 656 | } |
| 657 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 658 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 659 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 660 | } |
| 661 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 662 | if test.sendHalfHelloRequest { |
| 663 | tlsConn.SendHalfHelloRequest() |
| 664 | } |
| 665 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 666 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 667 | if test.renegotiateCiphers != nil { |
| 668 | config.CipherSuites = test.renegotiateCiphers |
| 669 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 670 | for i := 0; i < test.renegotiate; i++ { |
| 671 | if err := tlsConn.Renegotiate(); err != nil { |
| 672 | return err |
| 673 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 674 | } |
| 675 | } else if test.renegotiateCiphers != nil { |
| 676 | panic("renegotiateCiphers without renegotiate") |
| 677 | } |
| 678 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 679 | if test.damageFirstWrite { |
| 680 | connDamage.setDamage(true) |
| 681 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 682 | connDamage.setDamage(false) |
| 683 | } |
| 684 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 685 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 686 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 687 | if test.protocol == dtls { |
| 688 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 689 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 690 | // Read until EOF. |
| 691 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 692 | return err |
| 693 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 694 | if messageLen == 0 { |
| 695 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 696 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 697 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 698 | messageCount := test.messageCount |
| 699 | if messageCount == 0 { |
| 700 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 701 | } |
| 702 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 703 | for j := 0; j < messageCount; j++ { |
| 704 | testMessage := make([]byte, messageLen) |
| 705 | for i := range testMessage { |
| 706 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 707 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 708 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 709 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 710 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 711 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 712 | } |
| 713 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 714 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 715 | tlsConn.Write(nil) |
| 716 | } |
| 717 | |
| 718 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 719 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 720 | } |
| 721 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 722 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 723 | // The shim will not respond. |
| 724 | continue |
| 725 | } |
| 726 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 727 | buf := make([]byte, len(testMessage)) |
| 728 | if test.protocol == dtls { |
| 729 | bufTmp := make([]byte, len(buf)+1) |
| 730 | n, err := tlsConn.Read(bufTmp) |
| 731 | if err != nil { |
| 732 | return err |
| 733 | } |
| 734 | if n != len(buf) { |
| 735 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 736 | } |
| 737 | copy(buf, bufTmp) |
| 738 | } else { |
| 739 | _, err := io.ReadFull(tlsConn, buf) |
| 740 | if err != nil { |
| 741 | return err |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | for i, v := range buf { |
| 746 | if v != testMessage[i]^0xff { |
| 747 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 748 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 749 | } |
| 750 | } |
| 751 | |
| 752 | return nil |
| 753 | } |
| 754 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 755 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 756 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 757 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 758 | valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 759 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 760 | valgrindArgs = append(valgrindArgs, path) |
| 761 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 762 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 763 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 764 | } |
| 765 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 766 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 767 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 768 | xtermArgs = append(xtermArgs, path) |
| 769 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 770 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 771 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 772 | } |
| 773 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 774 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 775 | xtermArgs := []string{"-e", "lldb", "--"} |
| 776 | xtermArgs = append(xtermArgs, path) |
| 777 | xtermArgs = append(xtermArgs, args...) |
| 778 | |
| 779 | return exec.Command("xterm", xtermArgs...) |
| 780 | } |
| 781 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 782 | var ( |
| 783 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 784 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 785 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 786 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 787 | // accept accepts a connection from listener, unless waitChan signals a process |
| 788 | // exit first. |
| 789 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 790 | type connOrError struct { |
| 791 | conn net.Conn |
| 792 | err error |
| 793 | } |
| 794 | connChan := make(chan connOrError, 1) |
| 795 | go func() { |
| 796 | conn, err := listener.Accept() |
| 797 | connChan <- connOrError{conn, err} |
| 798 | close(connChan) |
| 799 | }() |
| 800 | select { |
| 801 | case result := <-connChan: |
| 802 | return result.conn, result.err |
| 803 | case childErr := <-waitChan: |
| 804 | waitChan <- childErr |
| 805 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 806 | } |
| 807 | } |
| 808 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 809 | func translateExpectedError(errorStr string) string { |
| 810 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 811 | return translated |
| 812 | } |
| 813 | |
| 814 | if *looseErrors { |
| 815 | return "" |
| 816 | } |
| 817 | |
| 818 | return errorStr |
| 819 | } |
| 820 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 821 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 822 | // Help debugging panics on the Go side. |
| 823 | defer func() { |
| 824 | if r := recover(); r != nil { |
| 825 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 826 | panic(r) |
| 827 | } |
| 828 | }() |
| 829 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 830 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 831 | panic("Error expected without shouldFail in " + test.name) |
| 832 | } |
| 833 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 834 | if test.expectResumeRejected && !test.resumeSession { |
| 835 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 836 | } |
| 837 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame^] | 838 | for _, ver := range tlsVersions { |
| 839 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 840 | continue |
| 841 | } |
| 842 | |
| 843 | if test.config.MaxVersion != 0 || test.config.MinVersion != 0 || test.expectedVersion != 0 { |
| 844 | continue |
| 845 | } |
| 846 | |
| 847 | panic(fmt.Sprintf("The name of test %q suggests that it's version specific, but min/max version in the Config is %x/%x. One of them should probably be %x", test.name, test.config.MinVersion, test.config.MaxVersion, ver.version)) |
| 848 | } |
| 849 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 850 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 851 | if err != nil { |
| 852 | panic(err) |
| 853 | } |
| 854 | defer func() { |
| 855 | if listener != nil { |
| 856 | listener.Close() |
| 857 | } |
| 858 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 859 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 860 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 861 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 862 | flags = append(flags, "-server") |
| 863 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 864 | flags = append(flags, "-key-file") |
| 865 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 866 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 867 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 868 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | flags = append(flags, "-cert-file") |
| 872 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 873 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 874 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 875 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 876 | } |
| 877 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 878 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 879 | if test.protocol == dtls { |
| 880 | flags = append(flags, "-dtls") |
| 881 | } |
| 882 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 883 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 884 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 885 | resumeCount++ |
| 886 | if test.resumeRenewedSession { |
| 887 | resumeCount++ |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | if resumeCount > 0 { |
| 892 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 893 | } |
| 894 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 895 | if test.shimWritesFirst { |
| 896 | flags = append(flags, "-shim-writes-first") |
| 897 | } |
| 898 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 899 | if test.shimShutsDown { |
| 900 | flags = append(flags, "-shim-shuts-down") |
| 901 | } |
| 902 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 903 | if test.exportKeyingMaterial > 0 { |
| 904 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 905 | flags = append(flags, "-export-label", test.exportLabel) |
| 906 | flags = append(flags, "-export-context", test.exportContext) |
| 907 | if test.useExportContext { |
| 908 | flags = append(flags, "-use-export-context") |
| 909 | } |
| 910 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 911 | if test.expectResumeRejected { |
| 912 | flags = append(flags, "-expect-session-miss") |
| 913 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 914 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 915 | if test.testTLSUnique { |
| 916 | flags = append(flags, "-tls-unique") |
| 917 | } |
| 918 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 919 | flags = append(flags, test.flags...) |
| 920 | |
| 921 | var shim *exec.Cmd |
| 922 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 923 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 924 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 925 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 926 | } else if *useLLDB { |
| 927 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 928 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 929 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 930 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 931 | shim.Stdin = os.Stdin |
| 932 | var stdoutBuf, stderrBuf bytes.Buffer |
| 933 | shim.Stdout = &stdoutBuf |
| 934 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 935 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 936 | shim.Env = os.Environ() |
| 937 | shim.Env = append(shim.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10)) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 938 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 939 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 940 | } |
| 941 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 942 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 943 | |
| 944 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 945 | panic(err) |
| 946 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 947 | waitChan := make(chan error, 1) |
| 948 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 949 | |
| 950 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 951 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 952 | if *deterministic { |
| 953 | config.Rand = &deterministicRand{} |
| 954 | } |
| 955 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 956 | conn, err := acceptOrWait(listener, waitChan) |
| 957 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 958 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 959 | conn.Close() |
| 960 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 961 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 962 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 963 | var resumeConfig Config |
| 964 | if test.resumeConfig != nil { |
| 965 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 966 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 967 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 968 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 969 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 970 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 971 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 972 | } else { |
| 973 | resumeConfig = config |
| 974 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 975 | var connResume net.Conn |
| 976 | connResume, err = acceptOrWait(listener, waitChan) |
| 977 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 978 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 979 | connResume.Close() |
| 980 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 981 | } |
| 982 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 983 | // Close the listener now. This is to avoid hangs should the shim try to |
| 984 | // open more connections than expected. |
| 985 | listener.Close() |
| 986 | listener = nil |
| 987 | |
| 988 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 989 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 990 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 991 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 992 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 993 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 994 | case 89: |
| 995 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 996 | case 99: |
| 997 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 998 | } |
| 999 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1000 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1001 | // Account for Windows line endings. |
| 1002 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1003 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1004 | |
| 1005 | // Separate the errors from the shim and those from tools like |
| 1006 | // AddressSanitizer. |
| 1007 | var extraStderr string |
| 1008 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1009 | stderr = stderrParts[0] |
| 1010 | extraStderr = stderrParts[1] |
| 1011 | } |
| 1012 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1013 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1014 | expectedError := translateExpectedError(test.expectedError) |
| 1015 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1016 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1017 | localError := "none" |
| 1018 | if err != nil { |
| 1019 | localError = err.Error() |
| 1020 | } |
| 1021 | if len(test.expectedLocalError) != 0 { |
| 1022 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1023 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1024 | |
| 1025 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1026 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1027 | if childErr != nil { |
| 1028 | childError = childErr.Error() |
| 1029 | } |
| 1030 | |
| 1031 | var msg string |
| 1032 | switch { |
| 1033 | case failed && !test.shouldFail: |
| 1034 | msg = "unexpected failure" |
| 1035 | case !failed && test.shouldFail: |
| 1036 | msg = "unexpected success" |
| 1037 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1038 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1039 | default: |
| 1040 | panic("internal error") |
| 1041 | } |
| 1042 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1043 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s\n%s", msg, localError, childError, stdout, stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1044 | } |
| 1045 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1046 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1047 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1048 | } |
| 1049 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1050 | if *useValgrind && isValgrindError { |
| 1051 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1052 | } |
| 1053 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1054 | return nil |
| 1055 | } |
| 1056 | |
| 1057 | var tlsVersions = []struct { |
| 1058 | name string |
| 1059 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1060 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1061 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1062 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1063 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1064 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1065 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1066 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1067 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | var testCipherSuites = []struct { |
| 1071 | name string |
| 1072 | id uint16 |
| 1073 | }{ |
| 1074 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1075 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1076 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1077 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1078 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1079 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1080 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1081 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1082 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1083 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1084 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1085 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1086 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1087 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1088 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1089 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1090 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1091 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1092 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1093 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1094 | {"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] | 1095 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1096 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1097 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1098 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1099 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1100 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1101 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1102 | {"ECDHE-RSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 1103 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1104 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1105 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1106 | {"CECPQ1-ECDSA-AES256-GCM-SHA384", TLS_CECPQ1_ECDSA_WITH_AES_256_GCM_SHA384}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1107 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1108 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1109 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1110 | {"ECDHE-PSK-AES256-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1111 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1112 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1113 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1114 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1115 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1118 | func hasComponent(suiteName, component string) bool { |
| 1119 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1120 | } |
| 1121 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1122 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1123 | return hasComponent(suiteName, "GCM") || |
| 1124 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1125 | hasComponent(suiteName, "SHA384") || |
| 1126 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1127 | } |
| 1128 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1129 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1130 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1131 | } |
| 1132 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1133 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1134 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1135 | } |
| 1136 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1137 | func bigFromHex(hex string) *big.Int { |
| 1138 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1139 | if !ok { |
| 1140 | panic("failed to parse hex number 0x" + hex) |
| 1141 | } |
| 1142 | return ret |
| 1143 | } |
| 1144 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1145 | func addBasicTests() { |
| 1146 | basicTests := []testCase{ |
| 1147 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1148 | name: "NoFallbackSCSV", |
| 1149 | config: Config{ |
| 1150 | Bugs: ProtocolBugs{ |
| 1151 | FailIfNotFallbackSCSV: true, |
| 1152 | }, |
| 1153 | }, |
| 1154 | shouldFail: true, |
| 1155 | expectedLocalError: "no fallback SCSV found", |
| 1156 | }, |
| 1157 | { |
| 1158 | name: "SendFallbackSCSV", |
| 1159 | config: Config{ |
| 1160 | Bugs: ProtocolBugs{ |
| 1161 | FailIfNotFallbackSCSV: true, |
| 1162 | }, |
| 1163 | }, |
| 1164 | flags: []string{"-fallback-scsv"}, |
| 1165 | }, |
| 1166 | { |
| 1167 | name: "ClientCertificateTypes", |
| 1168 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1169 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1170 | ClientAuth: RequestClientCert, |
| 1171 | ClientCertificateTypes: []byte{ |
| 1172 | CertTypeDSSSign, |
| 1173 | CertTypeRSASign, |
| 1174 | CertTypeECDSASign, |
| 1175 | }, |
| 1176 | }, |
| 1177 | flags: []string{ |
| 1178 | "-expect-certificate-types", |
| 1179 | base64.StdEncoding.EncodeToString([]byte{ |
| 1180 | CertTypeDSSSign, |
| 1181 | CertTypeRSASign, |
| 1182 | CertTypeECDSASign, |
| 1183 | }), |
| 1184 | }, |
| 1185 | }, |
| 1186 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1187 | name: "UnauthenticatedECDH", |
| 1188 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1189 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1190 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1191 | Bugs: ProtocolBugs{ |
| 1192 | UnauthenticatedECDH: true, |
| 1193 | }, |
| 1194 | }, |
| 1195 | shouldFail: true, |
| 1196 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1197 | }, |
| 1198 | { |
| 1199 | name: "SkipCertificateStatus", |
| 1200 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1201 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1202 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1203 | Bugs: ProtocolBugs{ |
| 1204 | SkipCertificateStatus: true, |
| 1205 | }, |
| 1206 | }, |
| 1207 | flags: []string{ |
| 1208 | "-enable-ocsp-stapling", |
| 1209 | }, |
| 1210 | }, |
| 1211 | { |
| 1212 | name: "SkipServerKeyExchange", |
| 1213 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1214 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1215 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1216 | Bugs: ProtocolBugs{ |
| 1217 | SkipServerKeyExchange: true, |
| 1218 | }, |
| 1219 | }, |
| 1220 | shouldFail: true, |
| 1221 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1222 | }, |
| 1223 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1224 | testType: serverTest, |
| 1225 | name: "Alert", |
| 1226 | config: Config{ |
| 1227 | Bugs: ProtocolBugs{ |
| 1228 | SendSpuriousAlert: alertRecordOverflow, |
| 1229 | }, |
| 1230 | }, |
| 1231 | shouldFail: true, |
| 1232 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1233 | }, |
| 1234 | { |
| 1235 | protocol: dtls, |
| 1236 | testType: serverTest, |
| 1237 | name: "Alert-DTLS", |
| 1238 | config: Config{ |
| 1239 | Bugs: ProtocolBugs{ |
| 1240 | SendSpuriousAlert: alertRecordOverflow, |
| 1241 | }, |
| 1242 | }, |
| 1243 | shouldFail: true, |
| 1244 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1245 | }, |
| 1246 | { |
| 1247 | testType: serverTest, |
| 1248 | name: "FragmentAlert", |
| 1249 | config: Config{ |
| 1250 | Bugs: ProtocolBugs{ |
| 1251 | FragmentAlert: true, |
| 1252 | SendSpuriousAlert: alertRecordOverflow, |
| 1253 | }, |
| 1254 | }, |
| 1255 | shouldFail: true, |
| 1256 | expectedError: ":BAD_ALERT:", |
| 1257 | }, |
| 1258 | { |
| 1259 | protocol: dtls, |
| 1260 | testType: serverTest, |
| 1261 | name: "FragmentAlert-DTLS", |
| 1262 | config: Config{ |
| 1263 | Bugs: ProtocolBugs{ |
| 1264 | FragmentAlert: true, |
| 1265 | SendSpuriousAlert: alertRecordOverflow, |
| 1266 | }, |
| 1267 | }, |
| 1268 | shouldFail: true, |
| 1269 | expectedError: ":BAD_ALERT:", |
| 1270 | }, |
| 1271 | { |
| 1272 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1273 | name: "DoubleAlert", |
| 1274 | config: Config{ |
| 1275 | Bugs: ProtocolBugs{ |
| 1276 | DoubleAlert: true, |
| 1277 | SendSpuriousAlert: alertRecordOverflow, |
| 1278 | }, |
| 1279 | }, |
| 1280 | shouldFail: true, |
| 1281 | expectedError: ":BAD_ALERT:", |
| 1282 | }, |
| 1283 | { |
| 1284 | protocol: dtls, |
| 1285 | testType: serverTest, |
| 1286 | name: "DoubleAlert-DTLS", |
| 1287 | config: Config{ |
| 1288 | Bugs: ProtocolBugs{ |
| 1289 | DoubleAlert: true, |
| 1290 | SendSpuriousAlert: alertRecordOverflow, |
| 1291 | }, |
| 1292 | }, |
| 1293 | shouldFail: true, |
| 1294 | expectedError: ":BAD_ALERT:", |
| 1295 | }, |
| 1296 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1297 | name: "SkipNewSessionTicket", |
| 1298 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1299 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1300 | Bugs: ProtocolBugs{ |
| 1301 | SkipNewSessionTicket: true, |
| 1302 | }, |
| 1303 | }, |
| 1304 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1305 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1306 | }, |
| 1307 | { |
| 1308 | testType: serverTest, |
| 1309 | name: "FallbackSCSV", |
| 1310 | config: Config{ |
| 1311 | MaxVersion: VersionTLS11, |
| 1312 | Bugs: ProtocolBugs{ |
| 1313 | SendFallbackSCSV: true, |
| 1314 | }, |
| 1315 | }, |
| 1316 | shouldFail: true, |
| 1317 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1318 | }, |
| 1319 | { |
| 1320 | testType: serverTest, |
| 1321 | name: "FallbackSCSV-VersionMatch", |
| 1322 | config: Config{ |
| 1323 | Bugs: ProtocolBugs{ |
| 1324 | SendFallbackSCSV: true, |
| 1325 | }, |
| 1326 | }, |
| 1327 | }, |
| 1328 | { |
| 1329 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1330 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1331 | config: Config{ |
| 1332 | MaxVersion: VersionTLS12, |
| 1333 | Bugs: ProtocolBugs{ |
| 1334 | SendFallbackSCSV: true, |
| 1335 | }, |
| 1336 | }, |
| 1337 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1338 | }, |
| 1339 | { |
| 1340 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1341 | name: "FragmentedClientVersion", |
| 1342 | config: Config{ |
| 1343 | Bugs: ProtocolBugs{ |
| 1344 | MaxHandshakeRecordLength: 1, |
| 1345 | FragmentClientVersion: true, |
| 1346 | }, |
| 1347 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1348 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1349 | }, |
| 1350 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1351 | testType: serverTest, |
| 1352 | name: "HttpGET", |
| 1353 | sendPrefix: "GET / HTTP/1.0\n", |
| 1354 | shouldFail: true, |
| 1355 | expectedError: ":HTTP_REQUEST:", |
| 1356 | }, |
| 1357 | { |
| 1358 | testType: serverTest, |
| 1359 | name: "HttpPOST", |
| 1360 | sendPrefix: "POST / HTTP/1.0\n", |
| 1361 | shouldFail: true, |
| 1362 | expectedError: ":HTTP_REQUEST:", |
| 1363 | }, |
| 1364 | { |
| 1365 | testType: serverTest, |
| 1366 | name: "HttpHEAD", |
| 1367 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1368 | shouldFail: true, |
| 1369 | expectedError: ":HTTP_REQUEST:", |
| 1370 | }, |
| 1371 | { |
| 1372 | testType: serverTest, |
| 1373 | name: "HttpPUT", |
| 1374 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1375 | shouldFail: true, |
| 1376 | expectedError: ":HTTP_REQUEST:", |
| 1377 | }, |
| 1378 | { |
| 1379 | testType: serverTest, |
| 1380 | name: "HttpCONNECT", |
| 1381 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1382 | shouldFail: true, |
| 1383 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1384 | }, |
| 1385 | { |
| 1386 | testType: serverTest, |
| 1387 | name: "Garbage", |
| 1388 | sendPrefix: "blah", |
| 1389 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1390 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1391 | }, |
| 1392 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1393 | name: "RSAEphemeralKey", |
| 1394 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1395 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1396 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1397 | Bugs: ProtocolBugs{ |
| 1398 | RSAEphemeralKey: true, |
| 1399 | }, |
| 1400 | }, |
| 1401 | shouldFail: true, |
| 1402 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1403 | }, |
| 1404 | { |
| 1405 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1406 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1407 | shouldFail: true, |
| 1408 | expectedError: ":WRONG_SSL_VERSION:", |
| 1409 | }, |
| 1410 | { |
| 1411 | protocol: dtls, |
| 1412 | name: "DisableEverything-DTLS", |
| 1413 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1414 | shouldFail: true, |
| 1415 | expectedError: ":WRONG_SSL_VERSION:", |
| 1416 | }, |
| 1417 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1418 | protocol: dtls, |
| 1419 | testType: serverTest, |
| 1420 | name: "MTU", |
| 1421 | config: Config{ |
| 1422 | Bugs: ProtocolBugs{ |
| 1423 | MaxPacketLength: 256, |
| 1424 | }, |
| 1425 | }, |
| 1426 | flags: []string{"-mtu", "256"}, |
| 1427 | }, |
| 1428 | { |
| 1429 | protocol: dtls, |
| 1430 | testType: serverTest, |
| 1431 | name: "MTUExceeded", |
| 1432 | config: Config{ |
| 1433 | Bugs: ProtocolBugs{ |
| 1434 | MaxPacketLength: 255, |
| 1435 | }, |
| 1436 | }, |
| 1437 | flags: []string{"-mtu", "256"}, |
| 1438 | shouldFail: true, |
| 1439 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1440 | }, |
| 1441 | { |
| 1442 | name: "CertMismatchRSA", |
| 1443 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1444 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1445 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1446 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1447 | Bugs: ProtocolBugs{ |
| 1448 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1449 | }, |
| 1450 | }, |
| 1451 | shouldFail: true, |
| 1452 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1453 | }, |
| 1454 | { |
| 1455 | name: "CertMismatchECDSA", |
| 1456 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1457 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1458 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1459 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1460 | Bugs: ProtocolBugs{ |
| 1461 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1462 | }, |
| 1463 | }, |
| 1464 | shouldFail: true, |
| 1465 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1466 | }, |
| 1467 | { |
| 1468 | name: "EmptyCertificateList", |
| 1469 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1470 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1471 | Bugs: ProtocolBugs{ |
| 1472 | EmptyCertificateList: true, |
| 1473 | }, |
| 1474 | }, |
| 1475 | shouldFail: true, |
| 1476 | expectedError: ":DECODE_ERROR:", |
| 1477 | }, |
| 1478 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1479 | name: "EmptyCertificateList-TLS13", |
| 1480 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1481 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1482 | Bugs: ProtocolBugs{ |
| 1483 | EmptyCertificateList: true, |
| 1484 | }, |
| 1485 | }, |
| 1486 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1487 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1488 | }, |
| 1489 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1490 | name: "TLSFatalBadPackets", |
| 1491 | damageFirstWrite: true, |
| 1492 | shouldFail: true, |
| 1493 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1494 | }, |
| 1495 | { |
| 1496 | protocol: dtls, |
| 1497 | name: "DTLSIgnoreBadPackets", |
| 1498 | damageFirstWrite: true, |
| 1499 | }, |
| 1500 | { |
| 1501 | protocol: dtls, |
| 1502 | name: "DTLSIgnoreBadPackets-Async", |
| 1503 | damageFirstWrite: true, |
| 1504 | flags: []string{"-async"}, |
| 1505 | }, |
| 1506 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1507 | name: "AppDataBeforeHandshake", |
| 1508 | config: Config{ |
| 1509 | Bugs: ProtocolBugs{ |
| 1510 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1511 | }, |
| 1512 | }, |
| 1513 | shouldFail: true, |
| 1514 | expectedError: ":UNEXPECTED_RECORD:", |
| 1515 | }, |
| 1516 | { |
| 1517 | name: "AppDataBeforeHandshake-Empty", |
| 1518 | config: Config{ |
| 1519 | Bugs: ProtocolBugs{ |
| 1520 | AppDataBeforeHandshake: []byte{}, |
| 1521 | }, |
| 1522 | }, |
| 1523 | shouldFail: true, |
| 1524 | expectedError: ":UNEXPECTED_RECORD:", |
| 1525 | }, |
| 1526 | { |
| 1527 | protocol: dtls, |
| 1528 | name: "AppDataBeforeHandshake-DTLS", |
| 1529 | config: Config{ |
| 1530 | Bugs: ProtocolBugs{ |
| 1531 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1532 | }, |
| 1533 | }, |
| 1534 | shouldFail: true, |
| 1535 | expectedError: ":UNEXPECTED_RECORD:", |
| 1536 | }, |
| 1537 | { |
| 1538 | protocol: dtls, |
| 1539 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1540 | config: Config{ |
| 1541 | Bugs: ProtocolBugs{ |
| 1542 | AppDataBeforeHandshake: []byte{}, |
| 1543 | }, |
| 1544 | }, |
| 1545 | shouldFail: true, |
| 1546 | expectedError: ":UNEXPECTED_RECORD:", |
| 1547 | }, |
| 1548 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1549 | name: "AppDataAfterChangeCipherSpec", |
| 1550 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1551 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1552 | Bugs: ProtocolBugs{ |
| 1553 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1554 | }, |
| 1555 | }, |
| 1556 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1557 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1558 | }, |
| 1559 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1560 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1561 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1562 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1563 | Bugs: ProtocolBugs{ |
| 1564 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1565 | }, |
| 1566 | }, |
| 1567 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1568 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1569 | }, |
| 1570 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1571 | protocol: dtls, |
| 1572 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1573 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1574 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1575 | Bugs: ProtocolBugs{ |
| 1576 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1577 | }, |
| 1578 | }, |
| 1579 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1580 | // application data. |
| 1581 | }, |
| 1582 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1583 | protocol: dtls, |
| 1584 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1585 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1586 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1587 | Bugs: ProtocolBugs{ |
| 1588 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1589 | }, |
| 1590 | }, |
| 1591 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1592 | // application data. |
| 1593 | }, |
| 1594 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1595 | name: "AlertAfterChangeCipherSpec", |
| 1596 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1597 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1598 | Bugs: ProtocolBugs{ |
| 1599 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1600 | }, |
| 1601 | }, |
| 1602 | shouldFail: true, |
| 1603 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1604 | }, |
| 1605 | { |
| 1606 | protocol: dtls, |
| 1607 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1608 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1609 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1610 | Bugs: ProtocolBugs{ |
| 1611 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1612 | }, |
| 1613 | }, |
| 1614 | shouldFail: true, |
| 1615 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1616 | }, |
| 1617 | { |
| 1618 | protocol: dtls, |
| 1619 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1620 | config: Config{ |
| 1621 | Bugs: ProtocolBugs{ |
| 1622 | ReorderHandshakeFragments: true, |
| 1623 | // Small enough that every handshake message is |
| 1624 | // fragmented. |
| 1625 | MaxHandshakeRecordLength: 2, |
| 1626 | }, |
| 1627 | }, |
| 1628 | }, |
| 1629 | { |
| 1630 | protocol: dtls, |
| 1631 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1632 | config: Config{ |
| 1633 | Bugs: ProtocolBugs{ |
| 1634 | ReorderHandshakeFragments: true, |
| 1635 | // Large enough that no handshake message is |
| 1636 | // fragmented. |
| 1637 | MaxHandshakeRecordLength: 2048, |
| 1638 | }, |
| 1639 | }, |
| 1640 | }, |
| 1641 | { |
| 1642 | protocol: dtls, |
| 1643 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1644 | config: Config{ |
| 1645 | Bugs: ProtocolBugs{ |
| 1646 | ReorderHandshakeFragments: true, |
| 1647 | MixCompleteMessageWithFragments: true, |
| 1648 | MaxHandshakeRecordLength: 2, |
| 1649 | }, |
| 1650 | }, |
| 1651 | }, |
| 1652 | { |
| 1653 | name: "SendInvalidRecordType", |
| 1654 | config: Config{ |
| 1655 | Bugs: ProtocolBugs{ |
| 1656 | SendInvalidRecordType: true, |
| 1657 | }, |
| 1658 | }, |
| 1659 | shouldFail: true, |
| 1660 | expectedError: ":UNEXPECTED_RECORD:", |
| 1661 | }, |
| 1662 | { |
| 1663 | protocol: dtls, |
| 1664 | name: "SendInvalidRecordType-DTLS", |
| 1665 | config: Config{ |
| 1666 | Bugs: ProtocolBugs{ |
| 1667 | SendInvalidRecordType: true, |
| 1668 | }, |
| 1669 | }, |
| 1670 | shouldFail: true, |
| 1671 | expectedError: ":UNEXPECTED_RECORD:", |
| 1672 | }, |
| 1673 | { |
| 1674 | name: "FalseStart-SkipServerSecondLeg", |
| 1675 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1676 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1677 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1678 | NextProtos: []string{"foo"}, |
| 1679 | Bugs: ProtocolBugs{ |
| 1680 | SkipNewSessionTicket: true, |
| 1681 | SkipChangeCipherSpec: true, |
| 1682 | SkipFinished: true, |
| 1683 | ExpectFalseStart: true, |
| 1684 | }, |
| 1685 | }, |
| 1686 | flags: []string{ |
| 1687 | "-false-start", |
| 1688 | "-handshake-never-done", |
| 1689 | "-advertise-alpn", "\x03foo", |
| 1690 | }, |
| 1691 | shimWritesFirst: true, |
| 1692 | shouldFail: true, |
| 1693 | expectedError: ":UNEXPECTED_RECORD:", |
| 1694 | }, |
| 1695 | { |
| 1696 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1697 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1698 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1699 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1700 | NextProtos: []string{"foo"}, |
| 1701 | Bugs: ProtocolBugs{ |
| 1702 | SkipNewSessionTicket: true, |
| 1703 | SkipChangeCipherSpec: true, |
| 1704 | SkipFinished: true, |
| 1705 | }, |
| 1706 | }, |
| 1707 | flags: []string{ |
| 1708 | "-implicit-handshake", |
| 1709 | "-false-start", |
| 1710 | "-handshake-never-done", |
| 1711 | "-advertise-alpn", "\x03foo", |
| 1712 | }, |
| 1713 | shouldFail: true, |
| 1714 | expectedError: ":UNEXPECTED_RECORD:", |
| 1715 | }, |
| 1716 | { |
| 1717 | testType: serverTest, |
| 1718 | name: "FailEarlyCallback", |
| 1719 | flags: []string{"-fail-early-callback"}, |
| 1720 | shouldFail: true, |
| 1721 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1722 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1723 | }, |
| 1724 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1725 | name: "FailCertCallback-Client-TLS12", |
| 1726 | config: Config{ |
| 1727 | MaxVersion: VersionTLS12, |
| 1728 | ClientAuth: RequestClientCert, |
| 1729 | }, |
| 1730 | flags: []string{"-fail-cert-callback"}, |
| 1731 | shouldFail: true, |
| 1732 | expectedError: ":CERT_CB_ERROR:", |
| 1733 | expectedLocalError: "remote error: internal error", |
| 1734 | }, |
| 1735 | { |
| 1736 | testType: serverTest, |
| 1737 | name: "FailCertCallback-Server-TLS12", |
| 1738 | config: Config{ |
| 1739 | MaxVersion: VersionTLS12, |
| 1740 | }, |
| 1741 | flags: []string{"-fail-cert-callback"}, |
| 1742 | shouldFail: true, |
| 1743 | expectedError: ":CERT_CB_ERROR:", |
| 1744 | expectedLocalError: "remote error: internal error", |
| 1745 | }, |
| 1746 | { |
| 1747 | name: "FailCertCallback-Client-TLS13", |
| 1748 | config: Config{ |
| 1749 | MaxVersion: VersionTLS13, |
| 1750 | ClientAuth: RequestClientCert, |
| 1751 | }, |
| 1752 | flags: []string{"-fail-cert-callback"}, |
| 1753 | shouldFail: true, |
| 1754 | expectedError: ":CERT_CB_ERROR:", |
| 1755 | expectedLocalError: "remote error: internal error", |
| 1756 | }, |
| 1757 | { |
| 1758 | testType: serverTest, |
| 1759 | name: "FailCertCallback-Server-TLS13", |
| 1760 | config: Config{ |
| 1761 | MaxVersion: VersionTLS13, |
| 1762 | }, |
| 1763 | flags: []string{"-fail-cert-callback"}, |
| 1764 | shouldFail: true, |
| 1765 | expectedError: ":CERT_CB_ERROR:", |
| 1766 | expectedLocalError: "remote error: internal error", |
| 1767 | }, |
| 1768 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1769 | protocol: dtls, |
| 1770 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1771 | config: Config{ |
| 1772 | Bugs: ProtocolBugs{ |
| 1773 | MaxHandshakeRecordLength: 2, |
| 1774 | FragmentMessageTypeMismatch: true, |
| 1775 | }, |
| 1776 | }, |
| 1777 | shouldFail: true, |
| 1778 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1779 | }, |
| 1780 | { |
| 1781 | protocol: dtls, |
| 1782 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1783 | config: Config{ |
| 1784 | Bugs: ProtocolBugs{ |
| 1785 | MaxHandshakeRecordLength: 2, |
| 1786 | FragmentMessageLengthMismatch: true, |
| 1787 | }, |
| 1788 | }, |
| 1789 | shouldFail: true, |
| 1790 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1791 | }, |
| 1792 | { |
| 1793 | protocol: dtls, |
| 1794 | name: "SplitFragments-Header-DTLS", |
| 1795 | config: Config{ |
| 1796 | Bugs: ProtocolBugs{ |
| 1797 | SplitFragments: 2, |
| 1798 | }, |
| 1799 | }, |
| 1800 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1801 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1802 | }, |
| 1803 | { |
| 1804 | protocol: dtls, |
| 1805 | name: "SplitFragments-Boundary-DTLS", |
| 1806 | config: Config{ |
| 1807 | Bugs: ProtocolBugs{ |
| 1808 | SplitFragments: dtlsRecordHeaderLen, |
| 1809 | }, |
| 1810 | }, |
| 1811 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1812 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1813 | }, |
| 1814 | { |
| 1815 | protocol: dtls, |
| 1816 | name: "SplitFragments-Body-DTLS", |
| 1817 | config: Config{ |
| 1818 | Bugs: ProtocolBugs{ |
| 1819 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1820 | }, |
| 1821 | }, |
| 1822 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1823 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1824 | }, |
| 1825 | { |
| 1826 | protocol: dtls, |
| 1827 | name: "SendEmptyFragments-DTLS", |
| 1828 | config: Config{ |
| 1829 | Bugs: ProtocolBugs{ |
| 1830 | SendEmptyFragments: true, |
| 1831 | }, |
| 1832 | }, |
| 1833 | }, |
| 1834 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1835 | name: "BadFinished-Client", |
| 1836 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1837 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1838 | Bugs: ProtocolBugs{ |
| 1839 | BadFinished: true, |
| 1840 | }, |
| 1841 | }, |
| 1842 | shouldFail: true, |
| 1843 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1844 | }, |
| 1845 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1846 | name: "BadFinished-Client-TLS13", |
| 1847 | config: Config{ |
| 1848 | MaxVersion: VersionTLS13, |
| 1849 | Bugs: ProtocolBugs{ |
| 1850 | BadFinished: true, |
| 1851 | }, |
| 1852 | }, |
| 1853 | shouldFail: true, |
| 1854 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1855 | }, |
| 1856 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1857 | testType: serverTest, |
| 1858 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1859 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1860 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1861 | Bugs: ProtocolBugs{ |
| 1862 | BadFinished: true, |
| 1863 | }, |
| 1864 | }, |
| 1865 | shouldFail: true, |
| 1866 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1867 | }, |
| 1868 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1869 | testType: serverTest, |
| 1870 | name: "BadFinished-Server-TLS13", |
| 1871 | config: Config{ |
| 1872 | MaxVersion: VersionTLS13, |
| 1873 | Bugs: ProtocolBugs{ |
| 1874 | BadFinished: true, |
| 1875 | }, |
| 1876 | }, |
| 1877 | shouldFail: true, |
| 1878 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1879 | }, |
| 1880 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1881 | name: "FalseStart-BadFinished", |
| 1882 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1883 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1884 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1885 | NextProtos: []string{"foo"}, |
| 1886 | Bugs: ProtocolBugs{ |
| 1887 | BadFinished: true, |
| 1888 | ExpectFalseStart: true, |
| 1889 | }, |
| 1890 | }, |
| 1891 | flags: []string{ |
| 1892 | "-false-start", |
| 1893 | "-handshake-never-done", |
| 1894 | "-advertise-alpn", "\x03foo", |
| 1895 | }, |
| 1896 | shimWritesFirst: true, |
| 1897 | shouldFail: true, |
| 1898 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1899 | }, |
| 1900 | { |
| 1901 | name: "NoFalseStart-NoALPN", |
| 1902 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1903 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1904 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1905 | Bugs: ProtocolBugs{ |
| 1906 | ExpectFalseStart: true, |
| 1907 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1908 | }, |
| 1909 | }, |
| 1910 | flags: []string{ |
| 1911 | "-false-start", |
| 1912 | }, |
| 1913 | shimWritesFirst: true, |
| 1914 | shouldFail: true, |
| 1915 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1916 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1917 | }, |
| 1918 | { |
| 1919 | name: "NoFalseStart-NoAEAD", |
| 1920 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1921 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1922 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1923 | NextProtos: []string{"foo"}, |
| 1924 | Bugs: ProtocolBugs{ |
| 1925 | ExpectFalseStart: true, |
| 1926 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1927 | }, |
| 1928 | }, |
| 1929 | flags: []string{ |
| 1930 | "-false-start", |
| 1931 | "-advertise-alpn", "\x03foo", |
| 1932 | }, |
| 1933 | shimWritesFirst: true, |
| 1934 | shouldFail: true, |
| 1935 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1936 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1937 | }, |
| 1938 | { |
| 1939 | name: "NoFalseStart-RSA", |
| 1940 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1941 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1942 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1943 | NextProtos: []string{"foo"}, |
| 1944 | Bugs: ProtocolBugs{ |
| 1945 | ExpectFalseStart: true, |
| 1946 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1947 | }, |
| 1948 | }, |
| 1949 | flags: []string{ |
| 1950 | "-false-start", |
| 1951 | "-advertise-alpn", "\x03foo", |
| 1952 | }, |
| 1953 | shimWritesFirst: true, |
| 1954 | shouldFail: true, |
| 1955 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1956 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1957 | }, |
| 1958 | { |
| 1959 | name: "NoFalseStart-DHE_RSA", |
| 1960 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1961 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1962 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1963 | NextProtos: []string{"foo"}, |
| 1964 | Bugs: ProtocolBugs{ |
| 1965 | ExpectFalseStart: true, |
| 1966 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1967 | }, |
| 1968 | }, |
| 1969 | flags: []string{ |
| 1970 | "-false-start", |
| 1971 | "-advertise-alpn", "\x03foo", |
| 1972 | }, |
| 1973 | shimWritesFirst: true, |
| 1974 | shouldFail: true, |
| 1975 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1976 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1977 | }, |
| 1978 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1979 | protocol: dtls, |
| 1980 | name: "SendSplitAlert-Sync", |
| 1981 | config: Config{ |
| 1982 | Bugs: ProtocolBugs{ |
| 1983 | SendSplitAlert: true, |
| 1984 | }, |
| 1985 | }, |
| 1986 | }, |
| 1987 | { |
| 1988 | protocol: dtls, |
| 1989 | name: "SendSplitAlert-Async", |
| 1990 | config: Config{ |
| 1991 | Bugs: ProtocolBugs{ |
| 1992 | SendSplitAlert: true, |
| 1993 | }, |
| 1994 | }, |
| 1995 | flags: []string{"-async"}, |
| 1996 | }, |
| 1997 | { |
| 1998 | protocol: dtls, |
| 1999 | name: "PackDTLSHandshake", |
| 2000 | config: Config{ |
| 2001 | Bugs: ProtocolBugs{ |
| 2002 | MaxHandshakeRecordLength: 2, |
| 2003 | PackHandshakeFragments: 20, |
| 2004 | PackHandshakeRecords: 200, |
| 2005 | }, |
| 2006 | }, |
| 2007 | }, |
| 2008 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2009 | name: "SendEmptyRecords-Pass", |
| 2010 | sendEmptyRecords: 32, |
| 2011 | }, |
| 2012 | { |
| 2013 | name: "SendEmptyRecords", |
| 2014 | sendEmptyRecords: 33, |
| 2015 | shouldFail: true, |
| 2016 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2017 | }, |
| 2018 | { |
| 2019 | name: "SendEmptyRecords-Async", |
| 2020 | sendEmptyRecords: 33, |
| 2021 | flags: []string{"-async"}, |
| 2022 | shouldFail: true, |
| 2023 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2024 | }, |
| 2025 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2026 | name: "SendWarningAlerts-Pass", |
| 2027 | config: Config{ |
| 2028 | MaxVersion: VersionTLS12, |
| 2029 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2030 | sendWarningAlerts: 4, |
| 2031 | }, |
| 2032 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2033 | protocol: dtls, |
| 2034 | name: "SendWarningAlerts-DTLS-Pass", |
| 2035 | config: Config{ |
| 2036 | MaxVersion: VersionTLS12, |
| 2037 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2038 | sendWarningAlerts: 4, |
| 2039 | }, |
| 2040 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2041 | name: "SendWarningAlerts-TLS13", |
| 2042 | config: Config{ |
| 2043 | MaxVersion: VersionTLS13, |
| 2044 | }, |
| 2045 | sendWarningAlerts: 4, |
| 2046 | shouldFail: true, |
| 2047 | expectedError: ":BAD_ALERT:", |
| 2048 | expectedLocalError: "remote error: error decoding message", |
| 2049 | }, |
| 2050 | { |
| 2051 | name: "SendWarningAlerts", |
| 2052 | config: Config{ |
| 2053 | MaxVersion: VersionTLS12, |
| 2054 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2055 | sendWarningAlerts: 5, |
| 2056 | shouldFail: true, |
| 2057 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2058 | }, |
| 2059 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2060 | name: "SendWarningAlerts-Async", |
| 2061 | config: Config{ |
| 2062 | MaxVersion: VersionTLS12, |
| 2063 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2064 | sendWarningAlerts: 5, |
| 2065 | flags: []string{"-async"}, |
| 2066 | shouldFail: true, |
| 2067 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2068 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2069 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2070 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2071 | config: Config{ |
| 2072 | MaxVersion: VersionTLS13, |
| 2073 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2074 | sendKeyUpdates: 33, |
| 2075 | keyUpdateRequest: keyUpdateNotRequested, |
| 2076 | shouldFail: true, |
| 2077 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2078 | }, |
| 2079 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2080 | name: "EmptySessionID", |
| 2081 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2082 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2083 | SessionTicketsDisabled: true, |
| 2084 | }, |
| 2085 | noSessionCache: true, |
| 2086 | flags: []string{"-expect-no-session"}, |
| 2087 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2088 | { |
| 2089 | name: "Unclean-Shutdown", |
| 2090 | config: Config{ |
| 2091 | Bugs: ProtocolBugs{ |
| 2092 | NoCloseNotify: true, |
| 2093 | ExpectCloseNotify: true, |
| 2094 | }, |
| 2095 | }, |
| 2096 | shimShutsDown: true, |
| 2097 | flags: []string{"-check-close-notify"}, |
| 2098 | shouldFail: true, |
| 2099 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2100 | }, |
| 2101 | { |
| 2102 | name: "Unclean-Shutdown-Ignored", |
| 2103 | config: Config{ |
| 2104 | Bugs: ProtocolBugs{ |
| 2105 | NoCloseNotify: true, |
| 2106 | }, |
| 2107 | }, |
| 2108 | shimShutsDown: true, |
| 2109 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2110 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2111 | name: "Unclean-Shutdown-Alert", |
| 2112 | config: Config{ |
| 2113 | Bugs: ProtocolBugs{ |
| 2114 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2115 | ExpectCloseNotify: true, |
| 2116 | }, |
| 2117 | }, |
| 2118 | shimShutsDown: true, |
| 2119 | flags: []string{"-check-close-notify"}, |
| 2120 | shouldFail: true, |
| 2121 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2122 | }, |
| 2123 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2124 | name: "LargePlaintext", |
| 2125 | config: Config{ |
| 2126 | Bugs: ProtocolBugs{ |
| 2127 | SendLargeRecords: true, |
| 2128 | }, |
| 2129 | }, |
| 2130 | messageLen: maxPlaintext + 1, |
| 2131 | shouldFail: true, |
| 2132 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2133 | }, |
| 2134 | { |
| 2135 | protocol: dtls, |
| 2136 | name: "LargePlaintext-DTLS", |
| 2137 | config: Config{ |
| 2138 | Bugs: ProtocolBugs{ |
| 2139 | SendLargeRecords: true, |
| 2140 | }, |
| 2141 | }, |
| 2142 | messageLen: maxPlaintext + 1, |
| 2143 | shouldFail: true, |
| 2144 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2145 | }, |
| 2146 | { |
| 2147 | name: "LargeCiphertext", |
| 2148 | config: Config{ |
| 2149 | Bugs: ProtocolBugs{ |
| 2150 | SendLargeRecords: true, |
| 2151 | }, |
| 2152 | }, |
| 2153 | messageLen: maxPlaintext * 2, |
| 2154 | shouldFail: true, |
| 2155 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2156 | }, |
| 2157 | { |
| 2158 | protocol: dtls, |
| 2159 | name: "LargeCiphertext-DTLS", |
| 2160 | config: Config{ |
| 2161 | Bugs: ProtocolBugs{ |
| 2162 | SendLargeRecords: true, |
| 2163 | }, |
| 2164 | }, |
| 2165 | messageLen: maxPlaintext * 2, |
| 2166 | // Unlike the other four cases, DTLS drops records which |
| 2167 | // are invalid before authentication, so the connection |
| 2168 | // does not fail. |
| 2169 | expectMessageDropped: true, |
| 2170 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2171 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2172 | name: "BadHelloRequest-1", |
| 2173 | renegotiate: 1, |
| 2174 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2175 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2176 | Bugs: ProtocolBugs{ |
| 2177 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2178 | }, |
| 2179 | }, |
| 2180 | flags: []string{ |
| 2181 | "-renegotiate-freely", |
| 2182 | "-expect-total-renegotiations", "1", |
| 2183 | }, |
| 2184 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2185 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2186 | }, |
| 2187 | { |
| 2188 | name: "BadHelloRequest-2", |
| 2189 | renegotiate: 1, |
| 2190 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2191 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2192 | Bugs: ProtocolBugs{ |
| 2193 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2194 | }, |
| 2195 | }, |
| 2196 | flags: []string{ |
| 2197 | "-renegotiate-freely", |
| 2198 | "-expect-total-renegotiations", "1", |
| 2199 | }, |
| 2200 | shouldFail: true, |
| 2201 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2202 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2203 | { |
| 2204 | testType: serverTest, |
| 2205 | name: "SupportTicketsWithSessionID", |
| 2206 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2207 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2208 | SessionTicketsDisabled: true, |
| 2209 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2210 | resumeConfig: &Config{ |
| 2211 | MaxVersion: VersionTLS12, |
| 2212 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2213 | resumeSession: true, |
| 2214 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2215 | { |
| 2216 | protocol: dtls, |
| 2217 | name: "DTLS-SendExtraFinished", |
| 2218 | config: Config{ |
| 2219 | Bugs: ProtocolBugs{ |
| 2220 | SendExtraFinished: true, |
| 2221 | }, |
| 2222 | }, |
| 2223 | shouldFail: true, |
| 2224 | expectedError: ":UNEXPECTED_RECORD:", |
| 2225 | }, |
| 2226 | { |
| 2227 | protocol: dtls, |
| 2228 | name: "DTLS-SendExtraFinished-Reordered", |
| 2229 | config: Config{ |
| 2230 | Bugs: ProtocolBugs{ |
| 2231 | MaxHandshakeRecordLength: 2, |
| 2232 | ReorderHandshakeFragments: true, |
| 2233 | SendExtraFinished: true, |
| 2234 | }, |
| 2235 | }, |
| 2236 | shouldFail: true, |
| 2237 | expectedError: ":UNEXPECTED_RECORD:", |
| 2238 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2239 | { |
| 2240 | testType: serverTest, |
| 2241 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2242 | config: Config{ |
| 2243 | // Choose a cipher suite that does not involve |
| 2244 | // elliptic curves, so no extensions are |
| 2245 | // involved. |
| 2246 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2247 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2248 | Bugs: ProtocolBugs{ |
| 2249 | SendV2ClientHello: true, |
| 2250 | }, |
| 2251 | }, |
| 2252 | sendPrefix: string([]byte{ |
| 2253 | byte(recordTypeHandshake), |
| 2254 | 3, 1, // version |
| 2255 | 0, 0, // length |
| 2256 | }), |
| 2257 | // A no-op empty record may not be sent before V2ClientHello. |
| 2258 | shouldFail: true, |
| 2259 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2260 | }, |
| 2261 | { |
| 2262 | testType: serverTest, |
| 2263 | name: "V2ClientHello-WarningAlertPrefix", |
| 2264 | config: Config{ |
| 2265 | // Choose a cipher suite that does not involve |
| 2266 | // elliptic curves, so no extensions are |
| 2267 | // involved. |
| 2268 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2269 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2270 | Bugs: ProtocolBugs{ |
| 2271 | SendV2ClientHello: true, |
| 2272 | }, |
| 2273 | }, |
| 2274 | sendPrefix: string([]byte{ |
| 2275 | byte(recordTypeAlert), |
| 2276 | 3, 1, // version |
| 2277 | 0, 2, // length |
| 2278 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2279 | }), |
| 2280 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2281 | shouldFail: true, |
| 2282 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2283 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2284 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2285 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2286 | config: Config{ |
| 2287 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2288 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2289 | sendKeyUpdates: 1, |
| 2290 | keyUpdateRequest: keyUpdateNotRequested, |
| 2291 | }, |
| 2292 | { |
| 2293 | name: "KeyUpdate-InvalidRequestMode", |
| 2294 | config: Config{ |
| 2295 | MaxVersion: VersionTLS13, |
| 2296 | }, |
| 2297 | sendKeyUpdates: 1, |
| 2298 | keyUpdateRequest: 42, |
| 2299 | shouldFail: true, |
| 2300 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2301 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2302 | { |
| 2303 | name: "SendSNIWarningAlert", |
| 2304 | config: Config{ |
| 2305 | MaxVersion: VersionTLS12, |
| 2306 | Bugs: ProtocolBugs{ |
| 2307 | SendSNIWarningAlert: true, |
| 2308 | }, |
| 2309 | }, |
| 2310 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2311 | { |
| 2312 | testType: serverTest, |
| 2313 | name: "ExtraCompressionMethods-TLS12", |
| 2314 | config: Config{ |
| 2315 | MaxVersion: VersionTLS12, |
| 2316 | Bugs: ProtocolBugs{ |
| 2317 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2318 | }, |
| 2319 | }, |
| 2320 | }, |
| 2321 | { |
| 2322 | testType: serverTest, |
| 2323 | name: "ExtraCompressionMethods-TLS13", |
| 2324 | config: Config{ |
| 2325 | MaxVersion: VersionTLS13, |
| 2326 | Bugs: ProtocolBugs{ |
| 2327 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2328 | }, |
| 2329 | }, |
| 2330 | shouldFail: true, |
| 2331 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2332 | expectedLocalError: "remote error: illegal parameter", |
| 2333 | }, |
| 2334 | { |
| 2335 | testType: serverTest, |
| 2336 | name: "NoNullCompression-TLS12", |
| 2337 | config: Config{ |
| 2338 | MaxVersion: VersionTLS12, |
| 2339 | Bugs: ProtocolBugs{ |
| 2340 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2341 | }, |
| 2342 | }, |
| 2343 | shouldFail: true, |
| 2344 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2345 | expectedLocalError: "remote error: illegal parameter", |
| 2346 | }, |
| 2347 | { |
| 2348 | testType: serverTest, |
| 2349 | name: "NoNullCompression-TLS13", |
| 2350 | config: Config{ |
| 2351 | MaxVersion: VersionTLS13, |
| 2352 | Bugs: ProtocolBugs{ |
| 2353 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2354 | }, |
| 2355 | }, |
| 2356 | shouldFail: true, |
| 2357 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2358 | expectedLocalError: "remote error: illegal parameter", |
| 2359 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2360 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2361 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2362 | config: Config{ |
| 2363 | MaxVersion: VersionTLS12, |
| 2364 | Bugs: ProtocolBugs{ |
| 2365 | ExpectGREASE: true, |
| 2366 | }, |
| 2367 | }, |
| 2368 | flags: []string{"-enable-grease"}, |
| 2369 | }, |
| 2370 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2371 | name: "GREASE-Client-TLS13", |
| 2372 | config: Config{ |
| 2373 | MaxVersion: VersionTLS13, |
| 2374 | Bugs: ProtocolBugs{ |
| 2375 | ExpectGREASE: true, |
| 2376 | }, |
| 2377 | }, |
| 2378 | flags: []string{"-enable-grease"}, |
| 2379 | }, |
| 2380 | { |
| 2381 | testType: serverTest, |
| 2382 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2383 | config: Config{ |
| 2384 | MaxVersion: VersionTLS13, |
| 2385 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2386 | // TLS 1.3 servers are expected to |
| 2387 | // always enable GREASE. TLS 1.3 is new, |
| 2388 | // so there is no existing ecosystem to |
| 2389 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2390 | ExpectGREASE: true, |
| 2391 | }, |
| 2392 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2393 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2394 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2395 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2396 | |
| 2397 | // Test that very large messages can be received. |
| 2398 | cert := rsaCertificate |
| 2399 | for i := 0; i < 50; i++ { |
| 2400 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2401 | } |
| 2402 | testCases = append(testCases, testCase{ |
| 2403 | name: "LargeMessage", |
| 2404 | config: Config{ |
| 2405 | Certificates: []Certificate{cert}, |
| 2406 | }, |
| 2407 | }) |
| 2408 | testCases = append(testCases, testCase{ |
| 2409 | protocol: dtls, |
| 2410 | name: "LargeMessage-DTLS", |
| 2411 | config: Config{ |
| 2412 | Certificates: []Certificate{cert}, |
| 2413 | }, |
| 2414 | }) |
| 2415 | |
| 2416 | // They are rejected if the maximum certificate chain length is capped. |
| 2417 | testCases = append(testCases, testCase{ |
| 2418 | name: "LargeMessage-Reject", |
| 2419 | config: Config{ |
| 2420 | Certificates: []Certificate{cert}, |
| 2421 | }, |
| 2422 | flags: []string{"-max-cert-list", "16384"}, |
| 2423 | shouldFail: true, |
| 2424 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2425 | }) |
| 2426 | testCases = append(testCases, testCase{ |
| 2427 | protocol: dtls, |
| 2428 | name: "LargeMessage-Reject-DTLS", |
| 2429 | config: Config{ |
| 2430 | Certificates: []Certificate{cert}, |
| 2431 | }, |
| 2432 | flags: []string{"-max-cert-list", "16384"}, |
| 2433 | shouldFail: true, |
| 2434 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2435 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2436 | } |
| 2437 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2438 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2439 | const bogusCipher = 0xfe00 |
| 2440 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2441 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2442 | const psk = "12345" |
| 2443 | const pskIdentity = "luggage combo" |
| 2444 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2445 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2446 | var certFile string |
| 2447 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2448 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2449 | cert = ecdsaP256Certificate |
| 2450 | certFile = ecdsaP256CertificateFile |
| 2451 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2452 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2453 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2454 | certFile = rsaCertificateFile |
| 2455 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2456 | } |
| 2457 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2458 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2459 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2460 | flags = append(flags, |
| 2461 | "-psk", psk, |
| 2462 | "-psk-identity", pskIdentity) |
| 2463 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2464 | if hasComponent(suite.name, "NULL") { |
| 2465 | // NULL ciphers must be explicitly enabled. |
| 2466 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2467 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2468 | if hasComponent(suite.name, "CECPQ1") { |
| 2469 | // CECPQ1 ciphers must be explicitly enabled. |
| 2470 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2471 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2472 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2473 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2474 | // for now. |
| 2475 | flags = append(flags, "-cipher", suite.name) |
| 2476 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2477 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2478 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2479 | for _, protocol := range []protocol{tls, dtls} { |
| 2480 | var prefix string |
| 2481 | if protocol == dtls { |
| 2482 | if !ver.hasDTLS { |
| 2483 | continue |
| 2484 | } |
| 2485 | prefix = "D" |
| 2486 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2487 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2488 | var shouldServerFail, shouldClientFail bool |
| 2489 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2490 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2491 | // a BoringSSL server will never select it |
| 2492 | // because the extension is missing. |
| 2493 | shouldServerFail = true |
| 2494 | } |
| 2495 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2496 | shouldClientFail = true |
| 2497 | shouldServerFail = true |
| 2498 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2499 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2500 | shouldClientFail = true |
| 2501 | shouldServerFail = true |
| 2502 | } |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2503 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2504 | shouldClientFail = true |
| 2505 | shouldServerFail = true |
| 2506 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2507 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2508 | shouldClientFail = true |
| 2509 | shouldServerFail = true |
| 2510 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2511 | |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2512 | var sendCipherSuite uint16 |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2513 | var expectedServerError, expectedClientError string |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2514 | serverCipherSuites := []uint16{suite.id} |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2515 | if shouldServerFail { |
| 2516 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2517 | } |
| 2518 | if shouldClientFail { |
| 2519 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2520 | // Configure the server to select ciphers as normal but |
| 2521 | // select an incompatible cipher in ServerHello. |
| 2522 | serverCipherSuites = nil |
| 2523 | sendCipherSuite = suite.id |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2524 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2525 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2526 | testCases = append(testCases, testCase{ |
| 2527 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2528 | protocol: protocol, |
| 2529 | |
| 2530 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2531 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2532 | MinVersion: ver.version, |
| 2533 | MaxVersion: ver.version, |
| 2534 | CipherSuites: []uint16{suite.id}, |
| 2535 | Certificates: []Certificate{cert}, |
| 2536 | PreSharedKey: []byte(psk), |
| 2537 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2538 | Bugs: ProtocolBugs{ |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2539 | AdvertiseAllConfiguredCiphers: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2540 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2541 | }, |
| 2542 | certFile: certFile, |
| 2543 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2544 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2545 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 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, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2557 | CipherSuites: serverCipherSuites, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2558 | Certificates: []Certificate{cert}, |
| 2559 | PreSharedKey: []byte(psk), |
| 2560 | PreSharedKeyIdentity: pskIdentity, |
| 2561 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2562 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2563 | SendCipherSuite: sendCipherSuite, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2564 | }, |
| 2565 | }, |
| 2566 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2567 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2568 | shouldFail: shouldClientFail, |
| 2569 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2570 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2571 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2572 | if !shouldClientFail { |
| 2573 | // Ensure the maximum record size is accepted. |
| 2574 | testCases = append(testCases, testCase{ |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2575 | protocol: protocol, |
| 2576 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2577 | config: Config{ |
| 2578 | MinVersion: ver.version, |
| 2579 | MaxVersion: ver.version, |
| 2580 | CipherSuites: []uint16{suite.id}, |
| 2581 | Certificates: []Certificate{cert}, |
| 2582 | PreSharedKey: []byte(psk), |
| 2583 | PreSharedKeyIdentity: pskIdentity, |
| 2584 | }, |
| 2585 | flags: flags, |
| 2586 | messageLen: maxPlaintext, |
| 2587 | }) |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2588 | |
| 2589 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2590 | // and ignored in DTLS. |
| 2591 | var shouldFail bool |
| 2592 | var expectedError string |
| 2593 | if protocol == tls { |
| 2594 | shouldFail = true |
| 2595 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2596 | } |
| 2597 | |
| 2598 | testCases = append(testCases, testCase{ |
| 2599 | protocol: protocol, |
| 2600 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2601 | config: Config{ |
| 2602 | MinVersion: ver.version, |
| 2603 | MaxVersion: ver.version, |
| 2604 | CipherSuites: []uint16{suite.id}, |
| 2605 | Certificates: []Certificate{cert}, |
| 2606 | PreSharedKey: []byte(psk), |
| 2607 | PreSharedKeyIdentity: pskIdentity, |
| 2608 | }, |
| 2609 | flags: flags, |
| 2610 | damageFirstWrite: true, |
| 2611 | messageLen: maxPlaintext, |
| 2612 | shouldFail: shouldFail, |
| 2613 | expectedError: expectedError, |
| 2614 | }) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2615 | } |
| 2616 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2617 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2618 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2619 | |
| 2620 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2621 | name: "NoSharedCipher", |
| 2622 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2623 | MaxVersion: VersionTLS12, |
| 2624 | CipherSuites: []uint16{}, |
| 2625 | }, |
| 2626 | shouldFail: true, |
| 2627 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2628 | }) |
| 2629 | |
| 2630 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2631 | name: "NoSharedCipher-TLS13", |
| 2632 | config: Config{ |
| 2633 | MaxVersion: VersionTLS13, |
| 2634 | CipherSuites: []uint16{}, |
| 2635 | }, |
| 2636 | shouldFail: true, |
| 2637 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2638 | }) |
| 2639 | |
| 2640 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2641 | name: "UnsupportedCipherSuite", |
| 2642 | config: Config{ |
| 2643 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2644 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2645 | Bugs: ProtocolBugs{ |
| 2646 | IgnorePeerCipherPreferences: true, |
| 2647 | }, |
| 2648 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2649 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2650 | shouldFail: true, |
| 2651 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2652 | }) |
| 2653 | |
| 2654 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2655 | name: "ServerHelloBogusCipher", |
| 2656 | config: Config{ |
| 2657 | MaxVersion: VersionTLS12, |
| 2658 | Bugs: ProtocolBugs{ |
| 2659 | SendCipherSuite: bogusCipher, |
| 2660 | }, |
| 2661 | }, |
| 2662 | shouldFail: true, |
| 2663 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2664 | }) |
| 2665 | testCases = append(testCases, testCase{ |
| 2666 | name: "ServerHelloBogusCipher-TLS13", |
| 2667 | config: Config{ |
| 2668 | MaxVersion: VersionTLS13, |
| 2669 | Bugs: ProtocolBugs{ |
| 2670 | SendCipherSuite: bogusCipher, |
| 2671 | }, |
| 2672 | }, |
| 2673 | shouldFail: true, |
| 2674 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2675 | }) |
| 2676 | |
| 2677 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2678 | name: "WeakDH", |
| 2679 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2680 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2681 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2682 | Bugs: ProtocolBugs{ |
| 2683 | // This is a 1023-bit prime number, generated |
| 2684 | // with: |
| 2685 | // openssl gendh 1023 | openssl asn1parse -i |
| 2686 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2687 | }, |
| 2688 | }, |
| 2689 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2690 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2691 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2692 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2693 | testCases = append(testCases, testCase{ |
| 2694 | name: "SillyDH", |
| 2695 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2696 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2697 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2698 | Bugs: ProtocolBugs{ |
| 2699 | // This is a 4097-bit prime number, generated |
| 2700 | // with: |
| 2701 | // openssl gendh 4097 | openssl asn1parse -i |
| 2702 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2703 | }, |
| 2704 | }, |
| 2705 | shouldFail: true, |
| 2706 | expectedError: ":DH_P_TOO_LONG:", |
| 2707 | }) |
| 2708 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2709 | // This test ensures that Diffie-Hellman public values are padded with |
| 2710 | // zeros so that they're the same length as the prime. This is to avoid |
| 2711 | // hitting a bug in yaSSL. |
| 2712 | testCases = append(testCases, testCase{ |
| 2713 | testType: serverTest, |
| 2714 | name: "DHPublicValuePadded", |
| 2715 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2716 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2717 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2718 | Bugs: ProtocolBugs{ |
| 2719 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2720 | }, |
| 2721 | }, |
| 2722 | flags: []string{"-use-sparse-dh-prime"}, |
| 2723 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2724 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2725 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2726 | testCases = append(testCases, testCase{ |
| 2727 | testType: serverTest, |
| 2728 | name: "UnknownCipher", |
| 2729 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2730 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2731 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2732 | Bugs: ProtocolBugs{ |
| 2733 | AdvertiseAllConfiguredCiphers: true, |
| 2734 | }, |
| 2735 | }, |
| 2736 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2737 | |
| 2738 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2739 | testCases = append(testCases, testCase{ |
| 2740 | testType: serverTest, |
| 2741 | name: "UnknownCipher-TLS13", |
| 2742 | config: Config{ |
| 2743 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2744 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2745 | Bugs: ProtocolBugs{ |
| 2746 | AdvertiseAllConfiguredCiphers: true, |
| 2747 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2748 | }, |
| 2749 | }) |
| 2750 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2751 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2752 | testCases = append(testCases, testCase{ |
| 2753 | name: "EmptyECDHEPSKHint", |
| 2754 | config: Config{ |
| 2755 | MaxVersion: VersionTLS12, |
| 2756 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2757 | PreSharedKey: []byte("secret"), |
| 2758 | }, |
| 2759 | flags: []string{"-psk", "secret"}, |
| 2760 | }) |
| 2761 | |
| 2762 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2763 | // ServerKeyExchange is sent. |
| 2764 | testCases = append(testCases, testCase{ |
| 2765 | name: "ExplicitEmptyPSKHint", |
| 2766 | config: Config{ |
| 2767 | MaxVersion: VersionTLS12, |
| 2768 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2769 | PreSharedKey: []byte("secret"), |
| 2770 | Bugs: ProtocolBugs{ |
| 2771 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2772 | }, |
| 2773 | }, |
| 2774 | flags: []string{"-psk", "secret"}, |
| 2775 | }) |
| 2776 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2777 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2778 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2779 | // cipher lists and then a connection is made for each member of |
| 2780 | // expectations. The cipher suite that the server selects must match |
| 2781 | // the specified one. |
| 2782 | var versionSpecificCiphersTest = []struct { |
| 2783 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2784 | // expectations is a map from TLS version to cipher suite id. |
| 2785 | expectations map[uint16]uint16 |
| 2786 | }{ |
| 2787 | { |
| 2788 | // Test that the null case (where no version-specific ciphers are set) |
| 2789 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2790 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2791 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2792 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2793 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2794 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2795 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2796 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2797 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2798 | }, |
| 2799 | }, |
| 2800 | { |
| 2801 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2802 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2803 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2804 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2805 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2806 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2807 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2808 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2809 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2810 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2811 | }, |
| 2812 | }, |
| 2813 | { |
| 2814 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2815 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2816 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2817 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2818 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2819 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2820 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2821 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2822 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2823 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2824 | }, |
| 2825 | }, |
| 2826 | { |
| 2827 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2828 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2829 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2830 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2831 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2832 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2833 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2834 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2835 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2836 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2837 | }, |
| 2838 | }, |
| 2839 | } |
| 2840 | |
| 2841 | for i, test := range versionSpecificCiphersTest { |
| 2842 | for version, expectedCipherSuite := range test.expectations { |
| 2843 | flags := []string{"-cipher", test.ciphersDefault} |
| 2844 | if len(test.ciphersTLS10) > 0 { |
| 2845 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2846 | } |
| 2847 | if len(test.ciphersTLS11) > 0 { |
| 2848 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2849 | } |
| 2850 | |
| 2851 | testCases = append(testCases, testCase{ |
| 2852 | testType: serverTest, |
| 2853 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2854 | config: Config{ |
| 2855 | MaxVersion: version, |
| 2856 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2857 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA}, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2858 | }, |
| 2859 | flags: flags, |
| 2860 | expectedCipher: expectedCipherSuite, |
| 2861 | }) |
| 2862 | } |
| 2863 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2864 | } |
| 2865 | |
| 2866 | func addBadECDSASignatureTests() { |
| 2867 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2868 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2869 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2870 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2871 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2872 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2873 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2874 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2875 | Bugs: ProtocolBugs{ |
| 2876 | BadECDSAR: badR, |
| 2877 | BadECDSAS: badS, |
| 2878 | }, |
| 2879 | }, |
| 2880 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2881 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2882 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2883 | testCases = append(testCases, testCase{ |
| 2884 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2885 | config: Config{ |
| 2886 | MaxVersion: VersionTLS13, |
| 2887 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2888 | Bugs: ProtocolBugs{ |
| 2889 | BadECDSAR: badR, |
| 2890 | BadECDSAS: badS, |
| 2891 | }, |
| 2892 | }, |
| 2893 | shouldFail: true, |
| 2894 | expectedError: ":BAD_SIGNATURE:", |
| 2895 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2896 | } |
| 2897 | } |
| 2898 | } |
| 2899 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2900 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2901 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2902 | name: "MaxCBCPadding", |
| 2903 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2904 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2905 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2906 | Bugs: ProtocolBugs{ |
| 2907 | MaxPadding: true, |
| 2908 | }, |
| 2909 | }, |
| 2910 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2911 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2912 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2913 | name: "BadCBCPadding", |
| 2914 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2915 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2916 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2917 | Bugs: ProtocolBugs{ |
| 2918 | PaddingFirstByteBad: true, |
| 2919 | }, |
| 2920 | }, |
| 2921 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2922 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2923 | }) |
| 2924 | // OpenSSL previously had an issue where the first byte of padding in |
| 2925 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2926 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2927 | name: "BadCBCPadding255", |
| 2928 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2929 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2930 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2931 | Bugs: ProtocolBugs{ |
| 2932 | MaxPadding: true, |
| 2933 | PaddingFirstByteBadIf255: true, |
| 2934 | }, |
| 2935 | }, |
| 2936 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2937 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2938 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2939 | }) |
| 2940 | } |
| 2941 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2942 | func addCBCSplittingTests() { |
| 2943 | testCases = append(testCases, testCase{ |
| 2944 | name: "CBCRecordSplitting", |
| 2945 | config: Config{ |
| 2946 | MaxVersion: VersionTLS10, |
| 2947 | MinVersion: VersionTLS10, |
| 2948 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2949 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2950 | messageLen: -1, // read until EOF |
| 2951 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2952 | flags: []string{ |
| 2953 | "-async", |
| 2954 | "-write-different-record-sizes", |
| 2955 | "-cbc-record-splitting", |
| 2956 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2957 | }) |
| 2958 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2959 | name: "CBCRecordSplittingPartialWrite", |
| 2960 | config: Config{ |
| 2961 | MaxVersion: VersionTLS10, |
| 2962 | MinVersion: VersionTLS10, |
| 2963 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2964 | }, |
| 2965 | messageLen: -1, // read until EOF |
| 2966 | flags: []string{ |
| 2967 | "-async", |
| 2968 | "-write-different-record-sizes", |
| 2969 | "-cbc-record-splitting", |
| 2970 | "-partial-write", |
| 2971 | }, |
| 2972 | }) |
| 2973 | } |
| 2974 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2975 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2976 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2977 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2978 | certPool := x509.NewCertPool() |
| 2979 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2980 | if err != nil { |
| 2981 | panic(err) |
| 2982 | } |
| 2983 | certPool.AddCert(cert) |
| 2984 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2985 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2986 | testCases = append(testCases, testCase{ |
| 2987 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2988 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2989 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2990 | MinVersion: ver.version, |
| 2991 | MaxVersion: ver.version, |
| 2992 | ClientAuth: RequireAnyClientCert, |
| 2993 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2994 | }, |
| 2995 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2996 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2997 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2998 | }, |
| 2999 | }) |
| 3000 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3001 | testType: serverTest, |
| 3002 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3003 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3004 | MinVersion: ver.version, |
| 3005 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3006 | Certificates: []Certificate{rsaCertificate}, |
| 3007 | }, |
| 3008 | flags: []string{"-require-any-client-certificate"}, |
| 3009 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3010 | if ver.version != VersionSSL30 { |
| 3011 | testCases = append(testCases, testCase{ |
| 3012 | testType: serverTest, |
| 3013 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3014 | config: Config{ |
| 3015 | MinVersion: ver.version, |
| 3016 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3017 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3018 | }, |
| 3019 | flags: []string{"-require-any-client-certificate"}, |
| 3020 | }) |
| 3021 | testCases = append(testCases, testCase{ |
| 3022 | testType: clientTest, |
| 3023 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3024 | config: Config{ |
| 3025 | MinVersion: ver.version, |
| 3026 | MaxVersion: ver.version, |
| 3027 | ClientAuth: RequireAnyClientCert, |
| 3028 | ClientCAs: certPool, |
| 3029 | }, |
| 3030 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3031 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3032 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3033 | }, |
| 3034 | }) |
| 3035 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3036 | |
| 3037 | testCases = append(testCases, testCase{ |
| 3038 | name: "NoClientCertificate-" + ver.name, |
| 3039 | config: Config{ |
| 3040 | MinVersion: ver.version, |
| 3041 | MaxVersion: ver.version, |
| 3042 | ClientAuth: RequireAnyClientCert, |
| 3043 | }, |
| 3044 | shouldFail: true, |
| 3045 | expectedLocalError: "client didn't provide a certificate", |
| 3046 | }) |
| 3047 | |
| 3048 | testCases = append(testCases, testCase{ |
| 3049 | // Even if not configured to expect a certificate, OpenSSL will |
| 3050 | // return X509_V_OK as the verify_result. |
| 3051 | testType: serverTest, |
| 3052 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3053 | config: Config{ |
| 3054 | MinVersion: ver.version, |
| 3055 | MaxVersion: ver.version, |
| 3056 | }, |
| 3057 | flags: []string{ |
| 3058 | "-expect-verify-result", |
| 3059 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3060 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3061 | }) |
| 3062 | |
| 3063 | testCases = append(testCases, testCase{ |
| 3064 | // If a client certificate is not provided, OpenSSL will still |
| 3065 | // return X509_V_OK as the verify_result. |
| 3066 | testType: serverTest, |
| 3067 | name: "NoClientCertificate-Server-" + ver.name, |
| 3068 | config: Config{ |
| 3069 | MinVersion: ver.version, |
| 3070 | MaxVersion: ver.version, |
| 3071 | }, |
| 3072 | flags: []string{ |
| 3073 | "-expect-verify-result", |
| 3074 | "-verify-peer", |
| 3075 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3076 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3077 | }) |
| 3078 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3079 | certificateRequired := "remote error: certificate required" |
| 3080 | if ver.version < VersionTLS13 { |
| 3081 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3082 | // was used. |
| 3083 | certificateRequired = "remote error: handshake failure" |
| 3084 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3085 | testCases = append(testCases, testCase{ |
| 3086 | testType: serverTest, |
| 3087 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3088 | config: Config{ |
| 3089 | MinVersion: ver.version, |
| 3090 | MaxVersion: ver.version, |
| 3091 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3092 | flags: []string{"-require-any-client-certificate"}, |
| 3093 | shouldFail: true, |
| 3094 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3095 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3096 | }) |
| 3097 | |
| 3098 | if ver.version != VersionSSL30 { |
| 3099 | testCases = append(testCases, testCase{ |
| 3100 | testType: serverTest, |
| 3101 | name: "SkipClientCertificate-" + ver.name, |
| 3102 | config: Config{ |
| 3103 | MinVersion: ver.version, |
| 3104 | MaxVersion: ver.version, |
| 3105 | Bugs: ProtocolBugs{ |
| 3106 | SkipClientCertificate: true, |
| 3107 | }, |
| 3108 | }, |
| 3109 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3110 | flags: []string{"-verify-peer"}, |
| 3111 | shouldFail: true, |
| 3112 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3113 | }) |
| 3114 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3115 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3116 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3117 | // Client auth is only legal in certificate-based ciphers. |
| 3118 | testCases = append(testCases, testCase{ |
| 3119 | testType: clientTest, |
| 3120 | name: "ClientAuth-PSK", |
| 3121 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3122 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3123 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3124 | PreSharedKey: []byte("secret"), |
| 3125 | ClientAuth: RequireAnyClientCert, |
| 3126 | }, |
| 3127 | flags: []string{ |
| 3128 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3129 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3130 | "-psk", "secret", |
| 3131 | }, |
| 3132 | shouldFail: true, |
| 3133 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3134 | }) |
| 3135 | testCases = append(testCases, testCase{ |
| 3136 | testType: clientTest, |
| 3137 | name: "ClientAuth-ECDHE_PSK", |
| 3138 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3139 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3140 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3141 | PreSharedKey: []byte("secret"), |
| 3142 | ClientAuth: RequireAnyClientCert, |
| 3143 | }, |
| 3144 | flags: []string{ |
| 3145 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3146 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3147 | "-psk", "secret", |
| 3148 | }, |
| 3149 | shouldFail: true, |
| 3150 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3151 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3152 | |
| 3153 | // Regression test for a bug where the client CA list, if explicitly |
| 3154 | // set to NULL, was mis-encoded. |
| 3155 | testCases = append(testCases, testCase{ |
| 3156 | testType: serverTest, |
| 3157 | name: "Null-Client-CA-List", |
| 3158 | config: Config{ |
| 3159 | MaxVersion: VersionTLS12, |
| 3160 | Certificates: []Certificate{rsaCertificate}, |
| 3161 | }, |
| 3162 | flags: []string{ |
| 3163 | "-require-any-client-certificate", |
| 3164 | "-use-null-client-ca-list", |
| 3165 | }, |
| 3166 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3167 | } |
| 3168 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3169 | func addExtendedMasterSecretTests() { |
| 3170 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3171 | |
| 3172 | for _, with := range []bool{false, true} { |
| 3173 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3174 | if with { |
| 3175 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3176 | } |
| 3177 | |
| 3178 | for _, isClient := range []bool{false, true} { |
| 3179 | suffix := "-Server" |
| 3180 | testType := serverTest |
| 3181 | if isClient { |
| 3182 | suffix = "-Client" |
| 3183 | testType = clientTest |
| 3184 | } |
| 3185 | |
| 3186 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3187 | // In TLS 1.3, the extension is irrelevant and |
| 3188 | // always reports as enabled. |
| 3189 | var flags []string |
| 3190 | if with || ver.version >= VersionTLS13 { |
| 3191 | flags = []string{expectEMSFlag} |
| 3192 | } |
| 3193 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3194 | test := testCase{ |
| 3195 | testType: testType, |
| 3196 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3197 | config: Config{ |
| 3198 | MinVersion: ver.version, |
| 3199 | MaxVersion: ver.version, |
| 3200 | Bugs: ProtocolBugs{ |
| 3201 | NoExtendedMasterSecret: !with, |
| 3202 | RequireExtendedMasterSecret: with, |
| 3203 | }, |
| 3204 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3205 | flags: flags, |
| 3206 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3207 | } |
| 3208 | if test.shouldFail { |
| 3209 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3210 | } |
| 3211 | testCases = append(testCases, test) |
| 3212 | } |
| 3213 | } |
| 3214 | } |
| 3215 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3216 | for _, isClient := range []bool{false, true} { |
| 3217 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3218 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3219 | boolToWord := func(b bool) string { |
| 3220 | if b { |
| 3221 | return "Yes" |
| 3222 | } |
| 3223 | return "No" |
| 3224 | } |
| 3225 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3226 | if isClient { |
| 3227 | suffix += "Client" |
| 3228 | } else { |
| 3229 | suffix += "Server" |
| 3230 | } |
| 3231 | |
| 3232 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3233 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3234 | Bugs: ProtocolBugs{ |
| 3235 | RequireExtendedMasterSecret: true, |
| 3236 | }, |
| 3237 | } |
| 3238 | |
| 3239 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3240 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3241 | Bugs: ProtocolBugs{ |
| 3242 | NoExtendedMasterSecret: true, |
| 3243 | }, |
| 3244 | } |
| 3245 | |
| 3246 | test := testCase{ |
| 3247 | name: "ExtendedMasterSecret-" + suffix, |
| 3248 | resumeSession: true, |
| 3249 | } |
| 3250 | |
| 3251 | if !isClient { |
| 3252 | test.testType = serverTest |
| 3253 | } |
| 3254 | |
| 3255 | if supportedInFirstConnection { |
| 3256 | test.config = supportedConfig |
| 3257 | } else { |
| 3258 | test.config = noSupportConfig |
| 3259 | } |
| 3260 | |
| 3261 | if supportedInResumeConnection { |
| 3262 | test.resumeConfig = &supportedConfig |
| 3263 | } else { |
| 3264 | test.resumeConfig = &noSupportConfig |
| 3265 | } |
| 3266 | |
| 3267 | switch suffix { |
| 3268 | case "YesToYes-Client", "YesToYes-Server": |
| 3269 | // When a session is resumed, it should |
| 3270 | // still be aware that its master |
| 3271 | // secret was generated via EMS and |
| 3272 | // thus it's safe to use tls-unique. |
| 3273 | test.flags = []string{expectEMSFlag} |
| 3274 | case "NoToYes-Server": |
| 3275 | // If an original connection did not |
| 3276 | // contain EMS, but a resumption |
| 3277 | // handshake does, then a server should |
| 3278 | // not resume the session. |
| 3279 | test.expectResumeRejected = true |
| 3280 | case "YesToNo-Server": |
| 3281 | // Resuming an EMS session without the |
| 3282 | // EMS extension should cause the |
| 3283 | // server to abort the connection. |
| 3284 | test.shouldFail = true |
| 3285 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3286 | case "NoToYes-Client": |
| 3287 | // A client should abort a connection |
| 3288 | // where the server resumed a non-EMS |
| 3289 | // session but echoed the EMS |
| 3290 | // extension. |
| 3291 | test.shouldFail = true |
| 3292 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3293 | case "YesToNo-Client": |
| 3294 | // A client should abort a connection |
| 3295 | // where the server didn't echo EMS |
| 3296 | // when the session used it. |
| 3297 | test.shouldFail = true |
| 3298 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3299 | } |
| 3300 | |
| 3301 | testCases = append(testCases, test) |
| 3302 | } |
| 3303 | } |
| 3304 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3305 | |
| 3306 | // Switching EMS on renegotiation is forbidden. |
| 3307 | testCases = append(testCases, testCase{ |
| 3308 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3309 | config: Config{ |
| 3310 | MaxVersion: VersionTLS12, |
| 3311 | Bugs: ProtocolBugs{ |
| 3312 | NoExtendedMasterSecret: true, |
| 3313 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3314 | }, |
| 3315 | }, |
| 3316 | renegotiate: 1, |
| 3317 | flags: []string{ |
| 3318 | "-renegotiate-freely", |
| 3319 | "-expect-total-renegotiations", "1", |
| 3320 | }, |
| 3321 | }) |
| 3322 | |
| 3323 | testCases = append(testCases, testCase{ |
| 3324 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3325 | config: Config{ |
| 3326 | MaxVersion: VersionTLS12, |
| 3327 | Bugs: ProtocolBugs{ |
| 3328 | NoExtendedMasterSecret: true, |
| 3329 | }, |
| 3330 | }, |
| 3331 | renegotiate: 1, |
| 3332 | flags: []string{ |
| 3333 | "-renegotiate-freely", |
| 3334 | "-expect-total-renegotiations", "1", |
| 3335 | }, |
| 3336 | shouldFail: true, |
| 3337 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3338 | }) |
| 3339 | |
| 3340 | testCases = append(testCases, testCase{ |
| 3341 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3342 | config: Config{ |
| 3343 | MaxVersion: VersionTLS12, |
| 3344 | Bugs: ProtocolBugs{ |
| 3345 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3346 | }, |
| 3347 | }, |
| 3348 | renegotiate: 1, |
| 3349 | flags: []string{ |
| 3350 | "-renegotiate-freely", |
| 3351 | "-expect-total-renegotiations", "1", |
| 3352 | }, |
| 3353 | shouldFail: true, |
| 3354 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3355 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3356 | } |
| 3357 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3358 | type stateMachineTestConfig struct { |
| 3359 | protocol protocol |
| 3360 | async bool |
| 3361 | splitHandshake, packHandshakeFlight bool |
| 3362 | } |
| 3363 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3364 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3365 | // various conditions. Some of these are redundant with other tests, but they |
| 3366 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3367 | func addAllStateMachineCoverageTests() { |
| 3368 | for _, async := range []bool{false, true} { |
| 3369 | for _, protocol := range []protocol{tls, dtls} { |
| 3370 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3371 | protocol: protocol, |
| 3372 | async: async, |
| 3373 | }) |
| 3374 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3375 | protocol: protocol, |
| 3376 | async: async, |
| 3377 | splitHandshake: true, |
| 3378 | }) |
| 3379 | if protocol == tls { |
| 3380 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3381 | protocol: protocol, |
| 3382 | async: async, |
| 3383 | packHandshakeFlight: true, |
| 3384 | }) |
| 3385 | } |
| 3386 | } |
| 3387 | } |
| 3388 | } |
| 3389 | |
| 3390 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3391 | var tests []testCase |
| 3392 | |
| 3393 | // Basic handshake, with resumption. Client and server, |
| 3394 | // session ID and session ticket. |
| 3395 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3396 | name: "Basic-Client", |
| 3397 | config: Config{ |
| 3398 | MaxVersion: VersionTLS12, |
| 3399 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3400 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3401 | // Ensure session tickets are used, not session IDs. |
| 3402 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3403 | }) |
| 3404 | tests = append(tests, testCase{ |
| 3405 | name: "Basic-Client-RenewTicket", |
| 3406 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3407 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3408 | Bugs: ProtocolBugs{ |
| 3409 | RenewTicketOnResume: true, |
| 3410 | }, |
| 3411 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3412 | flags: []string{"-expect-ticket-renewal"}, |
| 3413 | resumeSession: true, |
| 3414 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3415 | }) |
| 3416 | tests = append(tests, testCase{ |
| 3417 | name: "Basic-Client-NoTicket", |
| 3418 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3419 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3420 | SessionTicketsDisabled: true, |
| 3421 | }, |
| 3422 | resumeSession: true, |
| 3423 | }) |
| 3424 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3425 | name: "Basic-Client-Implicit", |
| 3426 | config: Config{ |
| 3427 | MaxVersion: VersionTLS12, |
| 3428 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3429 | flags: []string{"-implicit-handshake"}, |
| 3430 | resumeSession: true, |
| 3431 | }) |
| 3432 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3433 | testType: serverTest, |
| 3434 | name: "Basic-Server", |
| 3435 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3436 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3437 | Bugs: ProtocolBugs{ |
| 3438 | RequireSessionTickets: true, |
| 3439 | }, |
| 3440 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3441 | resumeSession: true, |
| 3442 | }) |
| 3443 | tests = append(tests, testCase{ |
| 3444 | testType: serverTest, |
| 3445 | name: "Basic-Server-NoTickets", |
| 3446 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3447 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3448 | SessionTicketsDisabled: true, |
| 3449 | }, |
| 3450 | resumeSession: true, |
| 3451 | }) |
| 3452 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3453 | testType: serverTest, |
| 3454 | name: "Basic-Server-Implicit", |
| 3455 | config: Config{ |
| 3456 | MaxVersion: VersionTLS12, |
| 3457 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3458 | flags: []string{"-implicit-handshake"}, |
| 3459 | resumeSession: true, |
| 3460 | }) |
| 3461 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3462 | testType: serverTest, |
| 3463 | name: "Basic-Server-EarlyCallback", |
| 3464 | config: Config{ |
| 3465 | MaxVersion: VersionTLS12, |
| 3466 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3467 | flags: []string{"-use-early-callback"}, |
| 3468 | resumeSession: true, |
| 3469 | }) |
| 3470 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3471 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3472 | if config.protocol == tls { |
| 3473 | tests = append(tests, testCase{ |
| 3474 | name: "TLS13-1RTT-Client", |
| 3475 | config: Config{ |
| 3476 | MaxVersion: VersionTLS13, |
| 3477 | MinVersion: VersionTLS13, |
| 3478 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3479 | resumeSession: true, |
| 3480 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3481 | }) |
| 3482 | |
| 3483 | tests = append(tests, testCase{ |
| 3484 | testType: serverTest, |
| 3485 | name: "TLS13-1RTT-Server", |
| 3486 | config: Config{ |
| 3487 | MaxVersion: VersionTLS13, |
| 3488 | MinVersion: VersionTLS13, |
| 3489 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3490 | resumeSession: true, |
| 3491 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3492 | }) |
| 3493 | |
| 3494 | tests = append(tests, testCase{ |
| 3495 | name: "TLS13-HelloRetryRequest-Client", |
| 3496 | config: Config{ |
| 3497 | MaxVersion: VersionTLS13, |
| 3498 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3499 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3500 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3501 | CurvePreferences: []CurveID{CurveP384}, |
| 3502 | Bugs: ProtocolBugs{ |
| 3503 | ExpectMissingKeyShare: true, |
| 3504 | }, |
| 3505 | }, |
| 3506 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3507 | resumeSession: true, |
| 3508 | }) |
| 3509 | |
| 3510 | tests = append(tests, testCase{ |
| 3511 | testType: serverTest, |
| 3512 | name: "TLS13-HelloRetryRequest-Server", |
| 3513 | config: Config{ |
| 3514 | MaxVersion: VersionTLS13, |
| 3515 | MinVersion: VersionTLS13, |
| 3516 | // Require a HelloRetryRequest for every curve. |
| 3517 | DefaultCurves: []CurveID{}, |
| 3518 | }, |
| 3519 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3520 | resumeSession: true, |
| 3521 | }) |
| 3522 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3523 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3524 | // TLS client auth. |
| 3525 | tests = append(tests, testCase{ |
| 3526 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3527 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3528 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3529 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3530 | ClientAuth: RequestClientCert, |
| 3531 | }, |
| 3532 | }) |
| 3533 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3534 | testType: serverTest, |
| 3535 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3536 | config: Config{ |
| 3537 | MaxVersion: VersionTLS12, |
| 3538 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3539 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3540 | flags: []string{"-verify-peer"}, |
| 3541 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3542 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3543 | tests = append(tests, testCase{ |
| 3544 | testType: clientTest, |
| 3545 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3546 | config: Config{ |
| 3547 | MaxVersion: VersionSSL30, |
| 3548 | ClientAuth: RequestClientCert, |
| 3549 | }, |
| 3550 | }) |
| 3551 | tests = append(tests, testCase{ |
| 3552 | testType: serverTest, |
| 3553 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3554 | config: Config{ |
| 3555 | MaxVersion: VersionSSL30, |
| 3556 | }, |
| 3557 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3558 | flags: []string{"-verify-peer"}, |
| 3559 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3560 | tests = append(tests, testCase{ |
| 3561 | testType: clientTest, |
| 3562 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3563 | config: Config{ |
| 3564 | MaxVersion: VersionTLS13, |
| 3565 | ClientAuth: RequestClientCert, |
| 3566 | }, |
| 3567 | }) |
| 3568 | tests = append(tests, testCase{ |
| 3569 | testType: serverTest, |
| 3570 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3571 | config: Config{ |
| 3572 | MaxVersion: VersionTLS13, |
| 3573 | }, |
| 3574 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3575 | flags: []string{"-verify-peer"}, |
| 3576 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3577 | } |
| 3578 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3579 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3580 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3581 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3582 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3583 | ClientAuth: RequireAnyClientCert, |
| 3584 | }, |
| 3585 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3586 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3587 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3588 | }, |
| 3589 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3590 | tests = append(tests, testCase{ |
| 3591 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3592 | name: "ClientAuth-RSA-Client-TLS13", |
| 3593 | config: Config{ |
| 3594 | MaxVersion: VersionTLS13, |
| 3595 | ClientAuth: RequireAnyClientCert, |
| 3596 | }, |
| 3597 | flags: []string{ |
| 3598 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3599 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3600 | }, |
| 3601 | }) |
| 3602 | tests = append(tests, testCase{ |
| 3603 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3604 | name: "ClientAuth-ECDSA-Client", |
| 3605 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3606 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3607 | ClientAuth: RequireAnyClientCert, |
| 3608 | }, |
| 3609 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3610 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3611 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3612 | }, |
| 3613 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3614 | tests = append(tests, testCase{ |
| 3615 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3616 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3617 | config: Config{ |
| 3618 | MaxVersion: VersionTLS13, |
| 3619 | ClientAuth: RequireAnyClientCert, |
| 3620 | }, |
| 3621 | flags: []string{ |
| 3622 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3623 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3624 | }, |
| 3625 | }) |
| 3626 | tests = append(tests, testCase{ |
| 3627 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3628 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3629 | config: Config{ |
| 3630 | MaxVersion: VersionTLS12, |
| 3631 | ClientAuth: RequestClientCert, |
| 3632 | }, |
| 3633 | flags: []string{"-use-old-client-cert-callback"}, |
| 3634 | }) |
| 3635 | tests = append(tests, testCase{ |
| 3636 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3637 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3638 | config: Config{ |
| 3639 | MaxVersion: VersionTLS13, |
| 3640 | ClientAuth: RequestClientCert, |
| 3641 | }, |
| 3642 | flags: []string{"-use-old-client-cert-callback"}, |
| 3643 | }) |
| 3644 | tests = append(tests, testCase{ |
| 3645 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3646 | name: "ClientAuth-OldCallback", |
| 3647 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3648 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3649 | ClientAuth: RequireAnyClientCert, |
| 3650 | }, |
| 3651 | flags: []string{ |
| 3652 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3653 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3654 | "-use-old-client-cert-callback", |
| 3655 | }, |
| 3656 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3657 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3658 | testType: clientTest, |
| 3659 | name: "ClientAuth-OldCallback-TLS13", |
| 3660 | config: Config{ |
| 3661 | MaxVersion: VersionTLS13, |
| 3662 | ClientAuth: RequireAnyClientCert, |
| 3663 | }, |
| 3664 | flags: []string{ |
| 3665 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3666 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3667 | "-use-old-client-cert-callback", |
| 3668 | }, |
| 3669 | }) |
| 3670 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3671 | testType: serverTest, |
| 3672 | name: "ClientAuth-Server", |
| 3673 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3674 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3675 | Certificates: []Certificate{rsaCertificate}, |
| 3676 | }, |
| 3677 | flags: []string{"-require-any-client-certificate"}, |
| 3678 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3679 | tests = append(tests, testCase{ |
| 3680 | testType: serverTest, |
| 3681 | name: "ClientAuth-Server-TLS13", |
| 3682 | config: Config{ |
| 3683 | MaxVersion: VersionTLS13, |
| 3684 | Certificates: []Certificate{rsaCertificate}, |
| 3685 | }, |
| 3686 | flags: []string{"-require-any-client-certificate"}, |
| 3687 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3688 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3689 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3690 | tests = append(tests, testCase{ |
| 3691 | testType: serverTest, |
| 3692 | name: "Basic-Server-RSA", |
| 3693 | config: Config{ |
| 3694 | MaxVersion: VersionTLS12, |
| 3695 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3696 | }, |
| 3697 | flags: []string{ |
| 3698 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3699 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3700 | }, |
| 3701 | }) |
| 3702 | tests = append(tests, testCase{ |
| 3703 | testType: serverTest, |
| 3704 | name: "Basic-Server-ECDHE-RSA", |
| 3705 | config: Config{ |
| 3706 | MaxVersion: VersionTLS12, |
| 3707 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3708 | }, |
| 3709 | flags: []string{ |
| 3710 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3711 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3712 | }, |
| 3713 | }) |
| 3714 | tests = append(tests, testCase{ |
| 3715 | testType: serverTest, |
| 3716 | name: "Basic-Server-ECDHE-ECDSA", |
| 3717 | config: Config{ |
| 3718 | MaxVersion: VersionTLS12, |
| 3719 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3720 | }, |
| 3721 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3722 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3723 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3724 | }, |
| 3725 | }) |
| 3726 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3727 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3728 | tests = append(tests, testCase{ |
| 3729 | name: "SessionTicketsDisabled-Client", |
| 3730 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3731 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3732 | SessionTicketsDisabled: true, |
| 3733 | }, |
| 3734 | }) |
| 3735 | tests = append(tests, testCase{ |
| 3736 | testType: serverTest, |
| 3737 | name: "SessionTicketsDisabled-Server", |
| 3738 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3739 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3740 | SessionTicketsDisabled: true, |
| 3741 | }, |
| 3742 | }) |
| 3743 | |
| 3744 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3745 | // identity hint. |
| 3746 | tests = append(tests, testCase{ |
| 3747 | name: "EmptyPSKHint-Client", |
| 3748 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3749 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3750 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3751 | PreSharedKey: []byte("secret"), |
| 3752 | }, |
| 3753 | flags: []string{"-psk", "secret"}, |
| 3754 | }) |
| 3755 | tests = append(tests, testCase{ |
| 3756 | testType: serverTest, |
| 3757 | name: "EmptyPSKHint-Server", |
| 3758 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3759 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3760 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3761 | PreSharedKey: []byte("secret"), |
| 3762 | }, |
| 3763 | flags: []string{"-psk", "secret"}, |
| 3764 | }) |
| 3765 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3766 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3767 | tests = append(tests, testCase{ |
| 3768 | testType: clientTest, |
| 3769 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3770 | config: Config{ |
| 3771 | MaxVersion: VersionTLS12, |
| 3772 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3773 | flags: []string{ |
| 3774 | "-enable-ocsp-stapling", |
| 3775 | "-expect-ocsp-response", |
| 3776 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3777 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3778 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3779 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3780 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3781 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3782 | testType: serverTest, |
| 3783 | name: "OCSPStapling-Server", |
| 3784 | config: Config{ |
| 3785 | MaxVersion: VersionTLS12, |
| 3786 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3787 | expectedOCSPResponse: testOCSPResponse, |
| 3788 | flags: []string{ |
| 3789 | "-ocsp-response", |
| 3790 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3791 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3792 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3793 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3794 | tests = append(tests, testCase{ |
| 3795 | testType: clientTest, |
| 3796 | name: "OCSPStapling-Client-TLS13", |
| 3797 | config: Config{ |
| 3798 | MaxVersion: VersionTLS13, |
| 3799 | }, |
| 3800 | flags: []string{ |
| 3801 | "-enable-ocsp-stapling", |
| 3802 | "-expect-ocsp-response", |
| 3803 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3804 | "-verify-peer", |
| 3805 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3806 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3807 | }) |
| 3808 | tests = append(tests, testCase{ |
| 3809 | testType: serverTest, |
| 3810 | name: "OCSPStapling-Server-TLS13", |
| 3811 | config: Config{ |
| 3812 | MaxVersion: VersionTLS13, |
| 3813 | }, |
| 3814 | expectedOCSPResponse: testOCSPResponse, |
| 3815 | flags: []string{ |
| 3816 | "-ocsp-response", |
| 3817 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3818 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3819 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3820 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3821 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3822 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3823 | for _, vers := range tlsVersions { |
| 3824 | if config.protocol == dtls && !vers.hasDTLS { |
| 3825 | continue |
| 3826 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3827 | for _, testType := range []testType{clientTest, serverTest} { |
| 3828 | suffix := "-Client" |
| 3829 | if testType == serverTest { |
| 3830 | suffix = "-Server" |
| 3831 | } |
| 3832 | suffix += "-" + vers.name |
| 3833 | |
| 3834 | flag := "-verify-peer" |
| 3835 | if testType == serverTest { |
| 3836 | flag = "-require-any-client-certificate" |
| 3837 | } |
| 3838 | |
| 3839 | tests = append(tests, testCase{ |
| 3840 | testType: testType, |
| 3841 | name: "CertificateVerificationSucceed" + suffix, |
| 3842 | config: Config{ |
| 3843 | MaxVersion: vers.version, |
| 3844 | Certificates: []Certificate{rsaCertificate}, |
| 3845 | }, |
| 3846 | flags: []string{ |
| 3847 | flag, |
| 3848 | "-expect-verify-result", |
| 3849 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3850 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3851 | }) |
| 3852 | tests = append(tests, testCase{ |
| 3853 | testType: testType, |
| 3854 | name: "CertificateVerificationFail" + suffix, |
| 3855 | config: Config{ |
| 3856 | MaxVersion: vers.version, |
| 3857 | Certificates: []Certificate{rsaCertificate}, |
| 3858 | }, |
| 3859 | flags: []string{ |
| 3860 | flag, |
| 3861 | "-verify-fail", |
| 3862 | }, |
| 3863 | shouldFail: true, |
| 3864 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3865 | }) |
| 3866 | } |
| 3867 | |
| 3868 | // By default, the client is in a soft fail mode where the peer |
| 3869 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3870 | tests = append(tests, testCase{ |
| 3871 | testType: clientTest, |
| 3872 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3873 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3874 | MaxVersion: vers.version, |
| 3875 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3876 | }, |
| 3877 | flags: []string{ |
| 3878 | "-verify-fail", |
| 3879 | "-expect-verify-result", |
| 3880 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3881 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3882 | }) |
| 3883 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3884 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3885 | tests = append(tests, testCase{ |
| 3886 | name: "ShimSendAlert", |
| 3887 | flags: []string{"-send-alert"}, |
| 3888 | shimWritesFirst: true, |
| 3889 | shouldFail: true, |
| 3890 | expectedLocalError: "remote error: decompression failure", |
| 3891 | }) |
| 3892 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3893 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3894 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3895 | name: "Renegotiate-Client", |
| 3896 | config: Config{ |
| 3897 | MaxVersion: VersionTLS12, |
| 3898 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3899 | renegotiate: 1, |
| 3900 | flags: []string{ |
| 3901 | "-renegotiate-freely", |
| 3902 | "-expect-total-renegotiations", "1", |
| 3903 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3904 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3905 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3906 | tests = append(tests, testCase{ |
| 3907 | name: "SendHalfHelloRequest", |
| 3908 | config: Config{ |
| 3909 | MaxVersion: VersionTLS12, |
| 3910 | Bugs: ProtocolBugs{ |
| 3911 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3912 | }, |
| 3913 | }, |
| 3914 | sendHalfHelloRequest: true, |
| 3915 | flags: []string{"-renegotiate-ignore"}, |
| 3916 | shouldFail: true, |
| 3917 | expectedError: ":UNEXPECTED_RECORD:", |
| 3918 | }) |
| 3919 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3920 | // NPN on client and server; results in post-handshake message. |
| 3921 | tests = append(tests, testCase{ |
| 3922 | name: "NPN-Client", |
| 3923 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3924 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3925 | NextProtos: []string{"foo"}, |
| 3926 | }, |
| 3927 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3928 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3929 | expectedNextProto: "foo", |
| 3930 | expectedNextProtoType: npn, |
| 3931 | }) |
| 3932 | tests = append(tests, testCase{ |
| 3933 | testType: serverTest, |
| 3934 | name: "NPN-Server", |
| 3935 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3936 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3937 | NextProtos: []string{"bar"}, |
| 3938 | }, |
| 3939 | flags: []string{ |
| 3940 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3941 | "-expect-next-proto", "bar", |
| 3942 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3943 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3944 | expectedNextProto: "bar", |
| 3945 | expectedNextProtoType: npn, |
| 3946 | }) |
| 3947 | |
| 3948 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3949 | |
| 3950 | // Client does False Start and negotiates NPN. |
| 3951 | tests = append(tests, testCase{ |
| 3952 | name: "FalseStart", |
| 3953 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3954 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3955 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3956 | NextProtos: []string{"foo"}, |
| 3957 | Bugs: ProtocolBugs{ |
| 3958 | ExpectFalseStart: true, |
| 3959 | }, |
| 3960 | }, |
| 3961 | flags: []string{ |
| 3962 | "-false-start", |
| 3963 | "-select-next-proto", "foo", |
| 3964 | }, |
| 3965 | shimWritesFirst: true, |
| 3966 | resumeSession: true, |
| 3967 | }) |
| 3968 | |
| 3969 | // Client does False Start and negotiates ALPN. |
| 3970 | tests = append(tests, testCase{ |
| 3971 | name: "FalseStart-ALPN", |
| 3972 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3973 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3974 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3975 | NextProtos: []string{"foo"}, |
| 3976 | Bugs: ProtocolBugs{ |
| 3977 | ExpectFalseStart: true, |
| 3978 | }, |
| 3979 | }, |
| 3980 | flags: []string{ |
| 3981 | "-false-start", |
| 3982 | "-advertise-alpn", "\x03foo", |
| 3983 | }, |
| 3984 | shimWritesFirst: true, |
| 3985 | resumeSession: true, |
| 3986 | }) |
| 3987 | |
| 3988 | // Client does False Start but doesn't explicitly call |
| 3989 | // SSL_connect. |
| 3990 | tests = append(tests, testCase{ |
| 3991 | name: "FalseStart-Implicit", |
| 3992 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3993 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3994 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3995 | NextProtos: []string{"foo"}, |
| 3996 | }, |
| 3997 | flags: []string{ |
| 3998 | "-implicit-handshake", |
| 3999 | "-false-start", |
| 4000 | "-advertise-alpn", "\x03foo", |
| 4001 | }, |
| 4002 | }) |
| 4003 | |
| 4004 | // False Start without session tickets. |
| 4005 | tests = append(tests, testCase{ |
| 4006 | name: "FalseStart-SessionTicketsDisabled", |
| 4007 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4008 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4009 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4010 | NextProtos: []string{"foo"}, |
| 4011 | SessionTicketsDisabled: true, |
| 4012 | Bugs: ProtocolBugs{ |
| 4013 | ExpectFalseStart: true, |
| 4014 | }, |
| 4015 | }, |
| 4016 | flags: []string{ |
| 4017 | "-false-start", |
| 4018 | "-select-next-proto", "foo", |
| 4019 | }, |
| 4020 | shimWritesFirst: true, |
| 4021 | }) |
| 4022 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 4023 | tests = append(tests, testCase{ |
| 4024 | name: "FalseStart-CECPQ1", |
| 4025 | config: Config{ |
| 4026 | MaxVersion: VersionTLS12, |
| 4027 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 4028 | NextProtos: []string{"foo"}, |
| 4029 | Bugs: ProtocolBugs{ |
| 4030 | ExpectFalseStart: true, |
| 4031 | }, |
| 4032 | }, |
| 4033 | flags: []string{ |
| 4034 | "-false-start", |
| 4035 | "-cipher", "DEFAULT:kCECPQ1", |
| 4036 | "-select-next-proto", "foo", |
| 4037 | }, |
| 4038 | shimWritesFirst: true, |
| 4039 | resumeSession: true, |
| 4040 | }) |
| 4041 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4042 | // Server parses a V2ClientHello. |
| 4043 | tests = append(tests, testCase{ |
| 4044 | testType: serverTest, |
| 4045 | name: "SendV2ClientHello", |
| 4046 | config: Config{ |
| 4047 | // Choose a cipher suite that does not involve |
| 4048 | // elliptic curves, so no extensions are |
| 4049 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4050 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4051 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4052 | Bugs: ProtocolBugs{ |
| 4053 | SendV2ClientHello: true, |
| 4054 | }, |
| 4055 | }, |
| 4056 | }) |
| 4057 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4058 | // Test Channel ID |
| 4059 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4060 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4061 | continue |
| 4062 | } |
| 4063 | // Client sends a Channel ID. |
| 4064 | tests = append(tests, testCase{ |
| 4065 | name: "ChannelID-Client-" + ver.name, |
| 4066 | config: Config{ |
| 4067 | MaxVersion: ver.version, |
| 4068 | RequestChannelID: true, |
| 4069 | }, |
| 4070 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4071 | resumeSession: true, |
| 4072 | expectChannelID: true, |
| 4073 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4074 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4075 | // Server accepts a Channel ID. |
| 4076 | tests = append(tests, testCase{ |
| 4077 | testType: serverTest, |
| 4078 | name: "ChannelID-Server-" + ver.name, |
| 4079 | config: Config{ |
| 4080 | MaxVersion: ver.version, |
| 4081 | ChannelID: channelIDKey, |
| 4082 | }, |
| 4083 | flags: []string{ |
| 4084 | "-expect-channel-id", |
| 4085 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4086 | }, |
| 4087 | resumeSession: true, |
| 4088 | expectChannelID: true, |
| 4089 | }) |
| 4090 | |
| 4091 | tests = append(tests, testCase{ |
| 4092 | testType: serverTest, |
| 4093 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4094 | config: Config{ |
| 4095 | MaxVersion: ver.version, |
| 4096 | ChannelID: channelIDKey, |
| 4097 | Bugs: ProtocolBugs{ |
| 4098 | InvalidChannelIDSignature: true, |
| 4099 | }, |
| 4100 | }, |
| 4101 | flags: []string{"-enable-channel-id"}, |
| 4102 | shouldFail: true, |
| 4103 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4104 | }) |
| 4105 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4106 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4107 | // Channel ID and NPN at the same time, to ensure their relative |
| 4108 | // ordering is correct. |
| 4109 | tests = append(tests, testCase{ |
| 4110 | name: "ChannelID-NPN-Client", |
| 4111 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4112 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4113 | RequestChannelID: true, |
| 4114 | NextProtos: []string{"foo"}, |
| 4115 | }, |
| 4116 | flags: []string{ |
| 4117 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4118 | "-select-next-proto", "foo", |
| 4119 | }, |
| 4120 | resumeSession: true, |
| 4121 | expectChannelID: true, |
| 4122 | expectedNextProto: "foo", |
| 4123 | expectedNextProtoType: npn, |
| 4124 | }) |
| 4125 | tests = append(tests, testCase{ |
| 4126 | testType: serverTest, |
| 4127 | name: "ChannelID-NPN-Server", |
| 4128 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4129 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4130 | ChannelID: channelIDKey, |
| 4131 | NextProtos: []string{"bar"}, |
| 4132 | }, |
| 4133 | flags: []string{ |
| 4134 | "-expect-channel-id", |
| 4135 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4136 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4137 | "-expect-next-proto", "bar", |
| 4138 | }, |
| 4139 | resumeSession: true, |
| 4140 | expectChannelID: true, |
| 4141 | expectedNextProto: "bar", |
| 4142 | expectedNextProtoType: npn, |
| 4143 | }) |
| 4144 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4145 | // Bidirectional shutdown with the runner initiating. |
| 4146 | tests = append(tests, testCase{ |
| 4147 | name: "Shutdown-Runner", |
| 4148 | config: Config{ |
| 4149 | Bugs: ProtocolBugs{ |
| 4150 | ExpectCloseNotify: true, |
| 4151 | }, |
| 4152 | }, |
| 4153 | flags: []string{"-check-close-notify"}, |
| 4154 | }) |
| 4155 | |
| 4156 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4157 | // in the meantime, sends garbage before the close_notify which |
| 4158 | // the shim must ignore. |
| 4159 | tests = append(tests, testCase{ |
| 4160 | name: "Shutdown-Shim", |
| 4161 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4162 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4163 | Bugs: ProtocolBugs{ |
| 4164 | ExpectCloseNotify: true, |
| 4165 | }, |
| 4166 | }, |
| 4167 | shimShutsDown: true, |
| 4168 | sendEmptyRecords: 1, |
| 4169 | sendWarningAlerts: 1, |
| 4170 | flags: []string{"-check-close-notify"}, |
| 4171 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4172 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4173 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4174 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4175 | tests = append(tests, testCase{ |
| 4176 | name: "SkipHelloVerifyRequest", |
| 4177 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4178 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4179 | Bugs: ProtocolBugs{ |
| 4180 | SkipHelloVerifyRequest: true, |
| 4181 | }, |
| 4182 | }, |
| 4183 | }) |
| 4184 | } |
| 4185 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4186 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4187 | test.protocol = config.protocol |
| 4188 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4189 | test.name += "-DTLS" |
| 4190 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4191 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4192 | test.name += "-Async" |
| 4193 | test.flags = append(test.flags, "-async") |
| 4194 | } else { |
| 4195 | test.name += "-Sync" |
| 4196 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4197 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4198 | test.name += "-SplitHandshakeRecords" |
| 4199 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4200 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4201 | test.config.Bugs.MaxPacketLength = 256 |
| 4202 | test.flags = append(test.flags, "-mtu", "256") |
| 4203 | } |
| 4204 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4205 | if config.packHandshakeFlight { |
| 4206 | test.name += "-PackHandshakeFlight" |
| 4207 | test.config.Bugs.PackHandshakeFlight = true |
| 4208 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4209 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4210 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4211 | } |
| 4212 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4213 | func addDDoSCallbackTests() { |
| 4214 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4215 | for _, resume := range []bool{false, true} { |
| 4216 | suffix := "Resume" |
| 4217 | if resume { |
| 4218 | suffix = "No" + suffix |
| 4219 | } |
| 4220 | |
| 4221 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4222 | testType: serverTest, |
| 4223 | name: "Server-DDoS-OK-" + suffix, |
| 4224 | config: Config{ |
| 4225 | MaxVersion: VersionTLS12, |
| 4226 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4227 | flags: []string{"-install-ddos-callback"}, |
| 4228 | resumeSession: resume, |
| 4229 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4230 | testCases = append(testCases, testCase{ |
| 4231 | testType: serverTest, |
| 4232 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4233 | config: Config{ |
| 4234 | MaxVersion: VersionTLS13, |
| 4235 | }, |
| 4236 | flags: []string{"-install-ddos-callback"}, |
| 4237 | resumeSession: resume, |
| 4238 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4239 | |
| 4240 | failFlag := "-fail-ddos-callback" |
| 4241 | if resume { |
| 4242 | failFlag = "-fail-second-ddos-callback" |
| 4243 | } |
| 4244 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4245 | testType: serverTest, |
| 4246 | name: "Server-DDoS-Reject-" + suffix, |
| 4247 | config: Config{ |
| 4248 | MaxVersion: VersionTLS12, |
| 4249 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4250 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4251 | resumeSession: resume, |
| 4252 | shouldFail: true, |
| 4253 | expectedError: ":CONNECTION_REJECTED:", |
| 4254 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4255 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4256 | testCases = append(testCases, testCase{ |
| 4257 | testType: serverTest, |
| 4258 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4259 | config: Config{ |
| 4260 | MaxVersion: VersionTLS13, |
| 4261 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4262 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4263 | resumeSession: resume, |
| 4264 | shouldFail: true, |
| 4265 | expectedError: ":CONNECTION_REJECTED:", |
| 4266 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4267 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4268 | } |
| 4269 | } |
| 4270 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4271 | func addVersionNegotiationTests() { |
| 4272 | for i, shimVers := range tlsVersions { |
| 4273 | // Assemble flags to disable all newer versions on the shim. |
| 4274 | var flags []string |
| 4275 | for _, vers := range tlsVersions[i+1:] { |
| 4276 | flags = append(flags, vers.flag) |
| 4277 | } |
| 4278 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4279 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4280 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4281 | protocols := []protocol{tls} |
| 4282 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4283 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4284 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4285 | for _, protocol := range protocols { |
| 4286 | expectedVersion := shimVers.version |
| 4287 | if runnerVers.version < shimVers.version { |
| 4288 | expectedVersion = runnerVers.version |
| 4289 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4290 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4291 | suffix := shimVers.name + "-" + runnerVers.name |
| 4292 | if protocol == dtls { |
| 4293 | suffix += "-DTLS" |
| 4294 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4295 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4296 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4297 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4298 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4299 | clientVers := shimVers.version |
| 4300 | if clientVers > VersionTLS10 { |
| 4301 | clientVers = VersionTLS10 |
| 4302 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4303 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4304 | serverVers := expectedVersion |
| 4305 | if expectedVersion >= VersionTLS13 { |
| 4306 | serverVers = VersionTLS10 |
| 4307 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4308 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4309 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4310 | testCases = append(testCases, testCase{ |
| 4311 | protocol: protocol, |
| 4312 | testType: clientTest, |
| 4313 | name: "VersionNegotiation-Client-" + suffix, |
| 4314 | config: Config{ |
| 4315 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4316 | Bugs: ProtocolBugs{ |
| 4317 | ExpectInitialRecordVersion: clientVers, |
| 4318 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4319 | }, |
| 4320 | flags: flags, |
| 4321 | expectedVersion: expectedVersion, |
| 4322 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4323 | testCases = append(testCases, testCase{ |
| 4324 | protocol: protocol, |
| 4325 | testType: clientTest, |
| 4326 | name: "VersionNegotiation-Client2-" + suffix, |
| 4327 | config: Config{ |
| 4328 | MaxVersion: runnerVers.version, |
| 4329 | Bugs: ProtocolBugs{ |
| 4330 | ExpectInitialRecordVersion: clientVers, |
| 4331 | }, |
| 4332 | }, |
| 4333 | flags: []string{"-max-version", shimVersFlag}, |
| 4334 | expectedVersion: expectedVersion, |
| 4335 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4336 | |
| 4337 | testCases = append(testCases, testCase{ |
| 4338 | protocol: protocol, |
| 4339 | testType: serverTest, |
| 4340 | name: "VersionNegotiation-Server-" + suffix, |
| 4341 | config: Config{ |
| 4342 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4343 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4344 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4345 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4346 | }, |
| 4347 | flags: flags, |
| 4348 | expectedVersion: expectedVersion, |
| 4349 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4350 | testCases = append(testCases, testCase{ |
| 4351 | protocol: protocol, |
| 4352 | testType: serverTest, |
| 4353 | name: "VersionNegotiation-Server2-" + suffix, |
| 4354 | config: Config{ |
| 4355 | MaxVersion: runnerVers.version, |
| 4356 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4357 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4358 | }, |
| 4359 | }, |
| 4360 | flags: []string{"-max-version", shimVersFlag}, |
| 4361 | expectedVersion: expectedVersion, |
| 4362 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4363 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4364 | } |
| 4365 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4366 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4367 | // Test the version extension at all versions. |
| 4368 | for _, vers := range tlsVersions { |
| 4369 | protocols := []protocol{tls} |
| 4370 | if vers.hasDTLS { |
| 4371 | protocols = append(protocols, dtls) |
| 4372 | } |
| 4373 | for _, protocol := range protocols { |
| 4374 | suffix := vers.name |
| 4375 | if protocol == dtls { |
| 4376 | suffix += "-DTLS" |
| 4377 | } |
| 4378 | |
| 4379 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4380 | testCases = append(testCases, testCase{ |
| 4381 | protocol: protocol, |
| 4382 | testType: serverTest, |
| 4383 | name: "VersionNegotiationExtension-" + suffix, |
| 4384 | config: Config{ |
| 4385 | Bugs: ProtocolBugs{ |
| 4386 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4387 | }, |
| 4388 | }, |
| 4389 | expectedVersion: vers.version, |
| 4390 | }) |
| 4391 | } |
| 4392 | |
| 4393 | } |
| 4394 | |
| 4395 | // If all versions are unknown, negotiation fails. |
| 4396 | testCases = append(testCases, testCase{ |
| 4397 | testType: serverTest, |
| 4398 | name: "NoSupportedVersions", |
| 4399 | config: Config{ |
| 4400 | Bugs: ProtocolBugs{ |
| 4401 | SendSupportedVersions: []uint16{0x1111}, |
| 4402 | }, |
| 4403 | }, |
| 4404 | shouldFail: true, |
| 4405 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4406 | }) |
| 4407 | testCases = append(testCases, testCase{ |
| 4408 | protocol: dtls, |
| 4409 | testType: serverTest, |
| 4410 | name: "NoSupportedVersions-DTLS", |
| 4411 | config: Config{ |
| 4412 | Bugs: ProtocolBugs{ |
| 4413 | SendSupportedVersions: []uint16{0x1111}, |
| 4414 | }, |
| 4415 | }, |
| 4416 | shouldFail: true, |
| 4417 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4418 | }) |
| 4419 | |
| 4420 | testCases = append(testCases, testCase{ |
| 4421 | testType: serverTest, |
| 4422 | name: "ClientHelloVersionTooHigh", |
| 4423 | config: Config{ |
| 4424 | MaxVersion: VersionTLS13, |
| 4425 | Bugs: ProtocolBugs{ |
| 4426 | SendClientVersion: 0x0304, |
| 4427 | OmitSupportedVersions: true, |
| 4428 | }, |
| 4429 | }, |
| 4430 | expectedVersion: VersionTLS12, |
| 4431 | }) |
| 4432 | |
| 4433 | testCases = append(testCases, testCase{ |
| 4434 | testType: serverTest, |
| 4435 | name: "ConflictingVersionNegotiation", |
| 4436 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4437 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4438 | SendClientVersion: VersionTLS12, |
| 4439 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4440 | }, |
| 4441 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4442 | // The extension takes precedence over the ClientHello version. |
| 4443 | expectedVersion: VersionTLS11, |
| 4444 | }) |
| 4445 | |
| 4446 | testCases = append(testCases, testCase{ |
| 4447 | testType: serverTest, |
| 4448 | name: "ConflictingVersionNegotiation-2", |
| 4449 | config: Config{ |
| 4450 | Bugs: ProtocolBugs{ |
| 4451 | SendClientVersion: VersionTLS11, |
| 4452 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4453 | }, |
| 4454 | }, |
| 4455 | // The extension takes precedence over the ClientHello version. |
| 4456 | expectedVersion: VersionTLS12, |
| 4457 | }) |
| 4458 | |
| 4459 | testCases = append(testCases, testCase{ |
| 4460 | testType: serverTest, |
| 4461 | name: "RejectFinalTLS13", |
| 4462 | config: Config{ |
| 4463 | Bugs: ProtocolBugs{ |
| 4464 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4465 | }, |
| 4466 | }, |
| 4467 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4468 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4469 | expectedVersion: VersionTLS12, |
| 4470 | }) |
| 4471 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4472 | // Test that the maximum version is selected regardless of the |
| 4473 | // client-sent order. |
| 4474 | testCases = append(testCases, testCase{ |
| 4475 | testType: serverTest, |
| 4476 | name: "IgnoreClientVersionOrder", |
| 4477 | config: Config{ |
| 4478 | Bugs: ProtocolBugs{ |
| 4479 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4480 | }, |
| 4481 | }, |
| 4482 | expectedVersion: VersionTLS13, |
| 4483 | }) |
| 4484 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4485 | // Test for version tolerance. |
| 4486 | testCases = append(testCases, testCase{ |
| 4487 | testType: serverTest, |
| 4488 | name: "MinorVersionTolerance", |
| 4489 | config: Config{ |
| 4490 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4491 | SendClientVersion: 0x03ff, |
| 4492 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4493 | }, |
| 4494 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4495 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4496 | }) |
| 4497 | testCases = append(testCases, testCase{ |
| 4498 | testType: serverTest, |
| 4499 | name: "MajorVersionTolerance", |
| 4500 | config: Config{ |
| 4501 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4502 | SendClientVersion: 0x0400, |
| 4503 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4504 | }, |
| 4505 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4506 | // TLS 1.3 must be negotiated with the supported_versions |
| 4507 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4508 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4509 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4510 | testCases = append(testCases, testCase{ |
| 4511 | testType: serverTest, |
| 4512 | name: "VersionTolerance-TLS13", |
| 4513 | config: Config{ |
| 4514 | Bugs: ProtocolBugs{ |
| 4515 | // Although TLS 1.3 does not use |
| 4516 | // ClientHello.version, it still tolerates high |
| 4517 | // values there. |
| 4518 | SendClientVersion: 0x0400, |
| 4519 | }, |
| 4520 | }, |
| 4521 | expectedVersion: VersionTLS13, |
| 4522 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4523 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4524 | testCases = append(testCases, testCase{ |
| 4525 | protocol: dtls, |
| 4526 | testType: serverTest, |
| 4527 | name: "MinorVersionTolerance-DTLS", |
| 4528 | config: Config{ |
| 4529 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4530 | SendClientVersion: 0xfe00, |
| 4531 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4532 | }, |
| 4533 | }, |
| 4534 | expectedVersion: VersionTLS12, |
| 4535 | }) |
| 4536 | testCases = append(testCases, testCase{ |
| 4537 | protocol: dtls, |
| 4538 | testType: serverTest, |
| 4539 | name: "MajorVersionTolerance-DTLS", |
| 4540 | config: Config{ |
| 4541 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4542 | SendClientVersion: 0xfdff, |
| 4543 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4544 | }, |
| 4545 | }, |
| 4546 | expectedVersion: VersionTLS12, |
| 4547 | }) |
| 4548 | |
| 4549 | // Test that versions below 3.0 are rejected. |
| 4550 | testCases = append(testCases, testCase{ |
| 4551 | testType: serverTest, |
| 4552 | name: "VersionTooLow", |
| 4553 | config: Config{ |
| 4554 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4555 | SendClientVersion: 0x0200, |
| 4556 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4557 | }, |
| 4558 | }, |
| 4559 | shouldFail: true, |
| 4560 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4561 | }) |
| 4562 | testCases = append(testCases, testCase{ |
| 4563 | protocol: dtls, |
| 4564 | testType: serverTest, |
| 4565 | name: "VersionTooLow-DTLS", |
| 4566 | config: Config{ |
| 4567 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4568 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4569 | }, |
| 4570 | }, |
| 4571 | shouldFail: true, |
| 4572 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4573 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4574 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4575 | testCases = append(testCases, testCase{ |
| 4576 | name: "ServerBogusVersion", |
| 4577 | config: Config{ |
| 4578 | Bugs: ProtocolBugs{ |
| 4579 | SendServerHelloVersion: 0x1234, |
| 4580 | }, |
| 4581 | }, |
| 4582 | shouldFail: true, |
| 4583 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4584 | }) |
| 4585 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4586 | // Test TLS 1.3's downgrade signal. |
| 4587 | testCases = append(testCases, testCase{ |
| 4588 | name: "Downgrade-TLS12-Client", |
| 4589 | config: Config{ |
| 4590 | Bugs: ProtocolBugs{ |
| 4591 | NegotiateVersion: VersionTLS12, |
| 4592 | }, |
| 4593 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4594 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4595 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4596 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4597 | }) |
| 4598 | testCases = append(testCases, testCase{ |
| 4599 | testType: serverTest, |
| 4600 | name: "Downgrade-TLS12-Server", |
| 4601 | config: Config{ |
| 4602 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4603 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4604 | }, |
| 4605 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4606 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4607 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4608 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4609 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4610 | } |
| 4611 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4612 | func addMinimumVersionTests() { |
| 4613 | for i, shimVers := range tlsVersions { |
| 4614 | // Assemble flags to disable all older versions on the shim. |
| 4615 | var flags []string |
| 4616 | for _, vers := range tlsVersions[:i] { |
| 4617 | flags = append(flags, vers.flag) |
| 4618 | } |
| 4619 | |
| 4620 | for _, runnerVers := range tlsVersions { |
| 4621 | protocols := []protocol{tls} |
| 4622 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4623 | protocols = append(protocols, dtls) |
| 4624 | } |
| 4625 | for _, protocol := range protocols { |
| 4626 | suffix := shimVers.name + "-" + runnerVers.name |
| 4627 | if protocol == dtls { |
| 4628 | suffix += "-DTLS" |
| 4629 | } |
| 4630 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4631 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4632 | var expectedVersion uint16 |
| 4633 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4634 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4635 | if runnerVers.version >= shimVers.version { |
| 4636 | expectedVersion = runnerVers.version |
| 4637 | } else { |
| 4638 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4639 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4640 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4641 | } |
| 4642 | |
| 4643 | testCases = append(testCases, testCase{ |
| 4644 | protocol: protocol, |
| 4645 | testType: clientTest, |
| 4646 | name: "MinimumVersion-Client-" + suffix, |
| 4647 | config: Config{ |
| 4648 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4649 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4650 | // Ensure the server does not decline to |
| 4651 | // select a version (versions extension) or |
| 4652 | // cipher (some ciphers depend on versions). |
| 4653 | NegotiateVersion: runnerVers.version, |
| 4654 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4655 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4656 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4657 | flags: flags, |
| 4658 | expectedVersion: expectedVersion, |
| 4659 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4660 | expectedError: expectedError, |
| 4661 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4662 | }) |
| 4663 | testCases = append(testCases, testCase{ |
| 4664 | protocol: protocol, |
| 4665 | testType: clientTest, |
| 4666 | name: "MinimumVersion-Client2-" + suffix, |
| 4667 | config: Config{ |
| 4668 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4669 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4670 | // Ensure the server does not decline to |
| 4671 | // select a version (versions extension) or |
| 4672 | // cipher (some ciphers depend on versions). |
| 4673 | NegotiateVersion: runnerVers.version, |
| 4674 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4675 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4676 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4677 | flags: []string{"-min-version", shimVersFlag}, |
| 4678 | expectedVersion: expectedVersion, |
| 4679 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4680 | expectedError: expectedError, |
| 4681 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4682 | }) |
| 4683 | |
| 4684 | testCases = append(testCases, testCase{ |
| 4685 | protocol: protocol, |
| 4686 | testType: serverTest, |
| 4687 | name: "MinimumVersion-Server-" + suffix, |
| 4688 | config: Config{ |
| 4689 | MaxVersion: runnerVers.version, |
| 4690 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4691 | flags: flags, |
| 4692 | expectedVersion: expectedVersion, |
| 4693 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4694 | expectedError: expectedError, |
| 4695 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4696 | }) |
| 4697 | testCases = append(testCases, testCase{ |
| 4698 | protocol: protocol, |
| 4699 | testType: serverTest, |
| 4700 | name: "MinimumVersion-Server2-" + suffix, |
| 4701 | config: Config{ |
| 4702 | MaxVersion: runnerVers.version, |
| 4703 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4704 | flags: []string{"-min-version", shimVersFlag}, |
| 4705 | expectedVersion: expectedVersion, |
| 4706 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4707 | expectedError: expectedError, |
| 4708 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4709 | }) |
| 4710 | } |
| 4711 | } |
| 4712 | } |
| 4713 | } |
| 4714 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4715 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4716 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4717 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4718 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4719 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4720 | // Repeat extensions tests all versions except SSL 3.0. |
| 4721 | for _, ver := range tlsVersions { |
| 4722 | if ver.version == VersionSSL30 { |
| 4723 | continue |
| 4724 | } |
| 4725 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4726 | // Test that duplicate extensions are rejected. |
| 4727 | testCases = append(testCases, testCase{ |
| 4728 | testType: clientTest, |
| 4729 | name: "DuplicateExtensionClient-" + ver.name, |
| 4730 | config: Config{ |
| 4731 | MaxVersion: ver.version, |
| 4732 | Bugs: ProtocolBugs{ |
| 4733 | DuplicateExtension: true, |
| 4734 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4735 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4736 | shouldFail: true, |
| 4737 | expectedLocalError: "remote error: error decoding message", |
| 4738 | }) |
| 4739 | testCases = append(testCases, testCase{ |
| 4740 | testType: serverTest, |
| 4741 | name: "DuplicateExtensionServer-" + ver.name, |
| 4742 | config: Config{ |
| 4743 | MaxVersion: ver.version, |
| 4744 | Bugs: ProtocolBugs{ |
| 4745 | DuplicateExtension: true, |
| 4746 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4747 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4748 | shouldFail: true, |
| 4749 | expectedLocalError: "remote error: error decoding message", |
| 4750 | }) |
| 4751 | |
| 4752 | // Test SNI. |
| 4753 | testCases = append(testCases, testCase{ |
| 4754 | testType: clientTest, |
| 4755 | name: "ServerNameExtensionClient-" + ver.name, |
| 4756 | config: Config{ |
| 4757 | MaxVersion: ver.version, |
| 4758 | Bugs: ProtocolBugs{ |
| 4759 | ExpectServerName: "example.com", |
| 4760 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4761 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4762 | flags: []string{"-host-name", "example.com"}, |
| 4763 | }) |
| 4764 | testCases = append(testCases, testCase{ |
| 4765 | testType: clientTest, |
| 4766 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4767 | config: Config{ |
| 4768 | MaxVersion: ver.version, |
| 4769 | Bugs: ProtocolBugs{ |
| 4770 | ExpectServerName: "mismatch.com", |
| 4771 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4772 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4773 | flags: []string{"-host-name", "example.com"}, |
| 4774 | shouldFail: true, |
| 4775 | expectedLocalError: "tls: unexpected server name", |
| 4776 | }) |
| 4777 | testCases = append(testCases, testCase{ |
| 4778 | testType: clientTest, |
| 4779 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4780 | config: Config{ |
| 4781 | MaxVersion: ver.version, |
| 4782 | Bugs: ProtocolBugs{ |
| 4783 | ExpectServerName: "missing.com", |
| 4784 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4785 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4786 | shouldFail: true, |
| 4787 | expectedLocalError: "tls: unexpected server name", |
| 4788 | }) |
| 4789 | testCases = append(testCases, testCase{ |
| 4790 | testType: serverTest, |
| 4791 | name: "ServerNameExtensionServer-" + ver.name, |
| 4792 | config: Config{ |
| 4793 | MaxVersion: ver.version, |
| 4794 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4795 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4796 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4797 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4798 | }) |
| 4799 | |
| 4800 | // Test ALPN. |
| 4801 | testCases = append(testCases, testCase{ |
| 4802 | testType: clientTest, |
| 4803 | name: "ALPNClient-" + ver.name, |
| 4804 | config: Config{ |
| 4805 | MaxVersion: ver.version, |
| 4806 | NextProtos: []string{"foo"}, |
| 4807 | }, |
| 4808 | flags: []string{ |
| 4809 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4810 | "-expect-alpn", "foo", |
| 4811 | }, |
| 4812 | expectedNextProto: "foo", |
| 4813 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4814 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4815 | }) |
| 4816 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4817 | testType: clientTest, |
| 4818 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4819 | config: Config{ |
| 4820 | MaxVersion: ver.version, |
| 4821 | Bugs: ProtocolBugs{ |
| 4822 | SendALPN: "baz", |
| 4823 | }, |
| 4824 | }, |
| 4825 | flags: []string{ |
| 4826 | "-advertise-alpn", "\x03foo\x03bar", |
| 4827 | }, |
| 4828 | shouldFail: true, |
| 4829 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4830 | expectedLocalError: "remote error: illegal parameter", |
| 4831 | }) |
| 4832 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4833 | testType: serverTest, |
| 4834 | name: "ALPNServer-" + ver.name, |
| 4835 | config: Config{ |
| 4836 | MaxVersion: ver.version, |
| 4837 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4838 | }, |
| 4839 | flags: []string{ |
| 4840 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4841 | "-select-alpn", "foo", |
| 4842 | }, |
| 4843 | expectedNextProto: "foo", |
| 4844 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4845 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4846 | }) |
| 4847 | testCases = append(testCases, testCase{ |
| 4848 | testType: serverTest, |
| 4849 | name: "ALPNServer-Decline-" + ver.name, |
| 4850 | config: Config{ |
| 4851 | MaxVersion: ver.version, |
| 4852 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4853 | }, |
| 4854 | flags: []string{"-decline-alpn"}, |
| 4855 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4856 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4857 | }) |
| 4858 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4859 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4860 | // called once. |
| 4861 | testCases = append(testCases, testCase{ |
| 4862 | testType: serverTest, |
| 4863 | name: "ALPNServer-Async-" + ver.name, |
| 4864 | config: Config{ |
| 4865 | MaxVersion: ver.version, |
| 4866 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 4867 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 4868 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4869 | }, |
| 4870 | flags: []string{ |
| 4871 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4872 | "-select-alpn", "foo", |
| 4873 | "-async", |
| 4874 | }, |
| 4875 | expectedNextProto: "foo", |
| 4876 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4877 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4878 | }) |
| 4879 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4880 | var emptyString string |
| 4881 | testCases = append(testCases, testCase{ |
| 4882 | testType: clientTest, |
| 4883 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4884 | config: Config{ |
| 4885 | MaxVersion: ver.version, |
| 4886 | NextProtos: []string{""}, |
| 4887 | Bugs: ProtocolBugs{ |
| 4888 | // A server returning an empty ALPN protocol |
| 4889 | // should be rejected. |
| 4890 | ALPNProtocol: &emptyString, |
| 4891 | }, |
| 4892 | }, |
| 4893 | flags: []string{ |
| 4894 | "-advertise-alpn", "\x03foo", |
| 4895 | }, |
| 4896 | shouldFail: true, |
| 4897 | expectedError: ":PARSE_TLSEXT:", |
| 4898 | }) |
| 4899 | testCases = append(testCases, testCase{ |
| 4900 | testType: serverTest, |
| 4901 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4902 | config: Config{ |
| 4903 | MaxVersion: ver.version, |
| 4904 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4905 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4906 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4907 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4908 | flags: []string{ |
| 4909 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4910 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4911 | shouldFail: true, |
| 4912 | expectedError: ":PARSE_TLSEXT:", |
| 4913 | }) |
| 4914 | |
| 4915 | // Test NPN and the interaction with ALPN. |
| 4916 | if ver.version < VersionTLS13 { |
| 4917 | // Test that the server prefers ALPN over NPN. |
| 4918 | testCases = append(testCases, testCase{ |
| 4919 | testType: serverTest, |
| 4920 | name: "ALPNServer-Preferred-" + ver.name, |
| 4921 | config: Config{ |
| 4922 | MaxVersion: ver.version, |
| 4923 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4924 | }, |
| 4925 | flags: []string{ |
| 4926 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4927 | "-select-alpn", "foo", |
| 4928 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4929 | }, |
| 4930 | expectedNextProto: "foo", |
| 4931 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4932 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4933 | }) |
| 4934 | testCases = append(testCases, testCase{ |
| 4935 | testType: serverTest, |
| 4936 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4937 | config: Config{ |
| 4938 | MaxVersion: ver.version, |
| 4939 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4940 | Bugs: ProtocolBugs{ |
| 4941 | SwapNPNAndALPN: true, |
| 4942 | }, |
| 4943 | }, |
| 4944 | flags: []string{ |
| 4945 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4946 | "-select-alpn", "foo", |
| 4947 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4948 | }, |
| 4949 | expectedNextProto: "foo", |
| 4950 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4951 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4952 | }) |
| 4953 | |
| 4954 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4955 | testCases = append(testCases, testCase{ |
| 4956 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4957 | config: Config{ |
| 4958 | MaxVersion: ver.version, |
| 4959 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4960 | Bugs: ProtocolBugs{ |
| 4961 | NegotiateALPNAndNPN: true, |
| 4962 | }, |
| 4963 | }, |
| 4964 | flags: []string{ |
| 4965 | "-advertise-alpn", "\x03foo", |
| 4966 | "-select-next-proto", "foo", |
| 4967 | }, |
| 4968 | shouldFail: true, |
| 4969 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4970 | }) |
| 4971 | testCases = append(testCases, testCase{ |
| 4972 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4973 | config: Config{ |
| 4974 | MaxVersion: ver.version, |
| 4975 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4976 | Bugs: ProtocolBugs{ |
| 4977 | NegotiateALPNAndNPN: true, |
| 4978 | SwapNPNAndALPN: true, |
| 4979 | }, |
| 4980 | }, |
| 4981 | flags: []string{ |
| 4982 | "-advertise-alpn", "\x03foo", |
| 4983 | "-select-next-proto", "foo", |
| 4984 | }, |
| 4985 | shouldFail: true, |
| 4986 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4987 | }) |
| 4988 | |
| 4989 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4990 | testCases = append(testCases, testCase{ |
| 4991 | name: "DisableNPN-" + ver.name, |
| 4992 | config: Config{ |
| 4993 | MaxVersion: ver.version, |
| 4994 | NextProtos: []string{"foo"}, |
| 4995 | }, |
| 4996 | flags: []string{ |
| 4997 | "-select-next-proto", "foo", |
| 4998 | "-disable-npn", |
| 4999 | }, |
| 5000 | expectNoNextProto: true, |
| 5001 | }) |
| 5002 | } |
| 5003 | |
| 5004 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5005 | |
| 5006 | // Resume with a corrupt ticket. |
| 5007 | testCases = append(testCases, testCase{ |
| 5008 | testType: serverTest, |
| 5009 | name: "CorruptTicket-" + ver.name, |
| 5010 | config: Config{ |
| 5011 | MaxVersion: ver.version, |
| 5012 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5013 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5014 | in[len(in)-1] ^= 1 |
| 5015 | return in, nil |
| 5016 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5017 | }, |
| 5018 | }, |
| 5019 | resumeSession: true, |
| 5020 | expectResumeRejected: true, |
| 5021 | }) |
| 5022 | // Test the ticket callback, with and without renewal. |
| 5023 | testCases = append(testCases, testCase{ |
| 5024 | testType: serverTest, |
| 5025 | name: "TicketCallback-" + ver.name, |
| 5026 | config: Config{ |
| 5027 | MaxVersion: ver.version, |
| 5028 | }, |
| 5029 | resumeSession: true, |
| 5030 | flags: []string{"-use-ticket-callback"}, |
| 5031 | }) |
| 5032 | testCases = append(testCases, testCase{ |
| 5033 | testType: serverTest, |
| 5034 | name: "TicketCallback-Renew-" + ver.name, |
| 5035 | config: Config{ |
| 5036 | MaxVersion: ver.version, |
| 5037 | Bugs: ProtocolBugs{ |
| 5038 | ExpectNewTicket: true, |
| 5039 | }, |
| 5040 | }, |
| 5041 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5042 | resumeSession: true, |
| 5043 | }) |
| 5044 | |
| 5045 | // Test that the ticket callback is only called once when everything before |
| 5046 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5047 | // certificate selection callbacks run. |
| 5048 | testCases = append(testCases, testCase{ |
| 5049 | testType: serverTest, |
| 5050 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5051 | config: Config{ |
| 5052 | MaxVersion: ver.version, |
| 5053 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5054 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5055 | in[len(in)-1] ^= 1 |
| 5056 | return in, nil |
| 5057 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5058 | }, |
| 5059 | }, |
| 5060 | resumeSession: true, |
| 5061 | expectResumeRejected: true, |
| 5062 | flags: []string{ |
| 5063 | "-use-ticket-callback", |
| 5064 | "-async", |
| 5065 | }, |
| 5066 | }) |
| 5067 | |
| 5068 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5069 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5070 | testCases = append(testCases, testCase{ |
| 5071 | testType: serverTest, |
| 5072 | name: "OversizedSessionId-" + ver.name, |
| 5073 | config: Config{ |
| 5074 | MaxVersion: ver.version, |
| 5075 | Bugs: ProtocolBugs{ |
| 5076 | OversizedSessionId: true, |
| 5077 | }, |
| 5078 | }, |
| 5079 | resumeSession: true, |
| 5080 | shouldFail: true, |
| 5081 | expectedError: ":DECODE_ERROR:", |
| 5082 | }) |
| 5083 | } |
| 5084 | |
| 5085 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5086 | // are ignored. |
| 5087 | if ver.hasDTLS { |
| 5088 | testCases = append(testCases, testCase{ |
| 5089 | protocol: dtls, |
| 5090 | name: "SRTP-Client-" + ver.name, |
| 5091 | config: Config{ |
| 5092 | MaxVersion: ver.version, |
| 5093 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5094 | }, |
| 5095 | flags: []string{ |
| 5096 | "-srtp-profiles", |
| 5097 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5098 | }, |
| 5099 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5100 | }) |
| 5101 | testCases = append(testCases, testCase{ |
| 5102 | protocol: dtls, |
| 5103 | testType: serverTest, |
| 5104 | name: "SRTP-Server-" + ver.name, |
| 5105 | config: Config{ |
| 5106 | MaxVersion: ver.version, |
| 5107 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5108 | }, |
| 5109 | flags: []string{ |
| 5110 | "-srtp-profiles", |
| 5111 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5112 | }, |
| 5113 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5114 | }) |
| 5115 | // Test that the MKI is ignored. |
| 5116 | testCases = append(testCases, testCase{ |
| 5117 | protocol: dtls, |
| 5118 | testType: serverTest, |
| 5119 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5120 | config: Config{ |
| 5121 | MaxVersion: ver.version, |
| 5122 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5123 | Bugs: ProtocolBugs{ |
| 5124 | SRTPMasterKeyIdentifer: "bogus", |
| 5125 | }, |
| 5126 | }, |
| 5127 | flags: []string{ |
| 5128 | "-srtp-profiles", |
| 5129 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5130 | }, |
| 5131 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5132 | }) |
| 5133 | // Test that SRTP isn't negotiated on the server if there were |
| 5134 | // no matching profiles. |
| 5135 | testCases = append(testCases, testCase{ |
| 5136 | protocol: dtls, |
| 5137 | testType: serverTest, |
| 5138 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5139 | config: Config{ |
| 5140 | MaxVersion: ver.version, |
| 5141 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5142 | }, |
| 5143 | flags: []string{ |
| 5144 | "-srtp-profiles", |
| 5145 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5146 | }, |
| 5147 | expectedSRTPProtectionProfile: 0, |
| 5148 | }) |
| 5149 | // Test that the server returning an invalid SRTP profile is |
| 5150 | // flagged as an error by the client. |
| 5151 | testCases = append(testCases, testCase{ |
| 5152 | protocol: dtls, |
| 5153 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5154 | config: Config{ |
| 5155 | MaxVersion: ver.version, |
| 5156 | Bugs: ProtocolBugs{ |
| 5157 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5158 | }, |
| 5159 | }, |
| 5160 | flags: []string{ |
| 5161 | "-srtp-profiles", |
| 5162 | "SRTP_AES128_CM_SHA1_80", |
| 5163 | }, |
| 5164 | shouldFail: true, |
| 5165 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5166 | }) |
| 5167 | } |
| 5168 | |
| 5169 | // Test SCT list. |
| 5170 | testCases = append(testCases, testCase{ |
| 5171 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5172 | testType: clientTest, |
| 5173 | config: Config{ |
| 5174 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5175 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5176 | flags: []string{ |
| 5177 | "-enable-signed-cert-timestamps", |
| 5178 | "-expect-signed-cert-timestamps", |
| 5179 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5180 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5181 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5182 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5183 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5184 | var differentSCTList []byte |
| 5185 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5186 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5187 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5188 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5189 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5190 | testCases = append(testCases, testCase{ |
| 5191 | name: "SendSCTListOnResume-" + ver.name, |
| 5192 | config: Config{ |
| 5193 | MaxVersion: ver.version, |
| 5194 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5195 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5196 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5197 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5198 | flags: []string{ |
| 5199 | "-enable-signed-cert-timestamps", |
| 5200 | "-expect-signed-cert-timestamps", |
| 5201 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5202 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5203 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5204 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5205 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5206 | testCases = append(testCases, testCase{ |
| 5207 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5208 | testType: serverTest, |
| 5209 | config: Config{ |
| 5210 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5211 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5212 | flags: []string{ |
| 5213 | "-signed-cert-timestamps", |
| 5214 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5215 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5216 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5217 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5218 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5219 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5220 | emptySCTListCert := *testCerts[0].cert |
| 5221 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5222 | |
| 5223 | // Test empty SCT list. |
| 5224 | testCases = append(testCases, testCase{ |
| 5225 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5226 | testType: clientTest, |
| 5227 | config: Config{ |
| 5228 | MaxVersion: ver.version, |
| 5229 | Certificates: []Certificate{emptySCTListCert}, |
| 5230 | }, |
| 5231 | flags: []string{ |
| 5232 | "-enable-signed-cert-timestamps", |
| 5233 | }, |
| 5234 | shouldFail: true, |
| 5235 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5236 | }) |
| 5237 | |
| 5238 | emptySCTCert := *testCerts[0].cert |
| 5239 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5240 | |
| 5241 | // Test empty SCT in non-empty list. |
| 5242 | testCases = append(testCases, testCase{ |
| 5243 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5244 | testType: clientTest, |
| 5245 | config: Config{ |
| 5246 | MaxVersion: ver.version, |
| 5247 | Certificates: []Certificate{emptySCTCert}, |
| 5248 | }, |
| 5249 | flags: []string{ |
| 5250 | "-enable-signed-cert-timestamps", |
| 5251 | }, |
| 5252 | shouldFail: true, |
| 5253 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5254 | }) |
| 5255 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5256 | // Test that certificate-related extensions are not sent unsolicited. |
| 5257 | testCases = append(testCases, testCase{ |
| 5258 | testType: serverTest, |
| 5259 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5260 | config: Config{ |
| 5261 | MaxVersion: ver.version, |
| 5262 | Bugs: ProtocolBugs{ |
| 5263 | NoOCSPStapling: true, |
| 5264 | NoSignedCertificateTimestamps: true, |
| 5265 | }, |
| 5266 | }, |
| 5267 | flags: []string{ |
| 5268 | "-ocsp-response", |
| 5269 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5270 | "-signed-cert-timestamps", |
| 5271 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5272 | }, |
| 5273 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5274 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5275 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5276 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5277 | testType: clientTest, |
| 5278 | name: "ClientHelloPadding", |
| 5279 | config: Config{ |
| 5280 | Bugs: ProtocolBugs{ |
| 5281 | RequireClientHelloSize: 512, |
| 5282 | }, |
| 5283 | }, |
| 5284 | // This hostname just needs to be long enough to push the |
| 5285 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5286 | // long. |
| 5287 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5288 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5289 | |
| 5290 | // Extensions should not function in SSL 3.0. |
| 5291 | testCases = append(testCases, testCase{ |
| 5292 | testType: serverTest, |
| 5293 | name: "SSLv3Extensions-NoALPN", |
| 5294 | config: Config{ |
| 5295 | MaxVersion: VersionSSL30, |
| 5296 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5297 | }, |
| 5298 | flags: []string{ |
| 5299 | "-select-alpn", "foo", |
| 5300 | }, |
| 5301 | expectNoNextProto: true, |
| 5302 | }) |
| 5303 | |
| 5304 | // Test session tickets separately as they follow a different codepath. |
| 5305 | testCases = append(testCases, testCase{ |
| 5306 | testType: serverTest, |
| 5307 | name: "SSLv3Extensions-NoTickets", |
| 5308 | config: Config{ |
| 5309 | MaxVersion: VersionSSL30, |
| 5310 | Bugs: ProtocolBugs{ |
| 5311 | // Historically, session tickets in SSL 3.0 |
| 5312 | // failed in different ways depending on whether |
| 5313 | // the client supported renegotiation_info. |
| 5314 | NoRenegotiationInfo: true, |
| 5315 | }, |
| 5316 | }, |
| 5317 | resumeSession: true, |
| 5318 | }) |
| 5319 | testCases = append(testCases, testCase{ |
| 5320 | testType: serverTest, |
| 5321 | name: "SSLv3Extensions-NoTickets2", |
| 5322 | config: Config{ |
| 5323 | MaxVersion: VersionSSL30, |
| 5324 | }, |
| 5325 | resumeSession: true, |
| 5326 | }) |
| 5327 | |
| 5328 | // But SSL 3.0 does send and process renegotiation_info. |
| 5329 | testCases = append(testCases, testCase{ |
| 5330 | testType: serverTest, |
| 5331 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5332 | config: Config{ |
| 5333 | MaxVersion: VersionSSL30, |
| 5334 | Bugs: ProtocolBugs{ |
| 5335 | RequireRenegotiationInfo: true, |
| 5336 | }, |
| 5337 | }, |
| 5338 | }) |
| 5339 | testCases = append(testCases, testCase{ |
| 5340 | testType: serverTest, |
| 5341 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5342 | config: Config{ |
| 5343 | MaxVersion: VersionSSL30, |
| 5344 | Bugs: ProtocolBugs{ |
| 5345 | NoRenegotiationInfo: true, |
| 5346 | SendRenegotiationSCSV: true, |
| 5347 | RequireRenegotiationInfo: true, |
| 5348 | }, |
| 5349 | }, |
| 5350 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5351 | |
| 5352 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5353 | // in ServerHello. |
| 5354 | testCases = append(testCases, testCase{ |
| 5355 | name: "NPN-Forbidden-TLS13", |
| 5356 | config: Config{ |
| 5357 | MaxVersion: VersionTLS13, |
| 5358 | NextProtos: []string{"foo"}, |
| 5359 | Bugs: ProtocolBugs{ |
| 5360 | NegotiateNPNAtAllVersions: true, |
| 5361 | }, |
| 5362 | }, |
| 5363 | flags: []string{"-select-next-proto", "foo"}, |
| 5364 | shouldFail: true, |
| 5365 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5366 | }) |
| 5367 | testCases = append(testCases, testCase{ |
| 5368 | name: "EMS-Forbidden-TLS13", |
| 5369 | config: Config{ |
| 5370 | MaxVersion: VersionTLS13, |
| 5371 | Bugs: ProtocolBugs{ |
| 5372 | NegotiateEMSAtAllVersions: true, |
| 5373 | }, |
| 5374 | }, |
| 5375 | shouldFail: true, |
| 5376 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5377 | }) |
| 5378 | testCases = append(testCases, testCase{ |
| 5379 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5380 | config: Config{ |
| 5381 | MaxVersion: VersionTLS13, |
| 5382 | Bugs: ProtocolBugs{ |
| 5383 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5384 | }, |
| 5385 | }, |
| 5386 | shouldFail: true, |
| 5387 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5388 | }) |
| 5389 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5390 | name: "Ticket-Forbidden-TLS13", |
| 5391 | config: Config{ |
| 5392 | MaxVersion: VersionTLS12, |
| 5393 | }, |
| 5394 | resumeConfig: &Config{ |
| 5395 | MaxVersion: VersionTLS13, |
| 5396 | Bugs: ProtocolBugs{ |
| 5397 | AdvertiseTicketExtension: true, |
| 5398 | }, |
| 5399 | }, |
| 5400 | resumeSession: true, |
| 5401 | shouldFail: true, |
| 5402 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5403 | }) |
| 5404 | |
| 5405 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5406 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5407 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5408 | // implicit in every test.) |
| 5409 | testCases = append(testCases, testCase{ |
| 5410 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5411 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5412 | config: Config{ |
| 5413 | MaxVersion: VersionTLS13, |
| 5414 | NextProtos: []string{"bar"}, |
| 5415 | }, |
| 5416 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5417 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5418 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5419 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5420 | // tolerated. |
| 5421 | testCases = append(testCases, testCase{ |
| 5422 | name: "SendOCSPResponseOnResume-TLS12", |
| 5423 | config: Config{ |
| 5424 | MaxVersion: VersionTLS12, |
| 5425 | Bugs: ProtocolBugs{ |
| 5426 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5427 | }, |
| 5428 | }, |
| 5429 | flags: []string{ |
| 5430 | "-enable-ocsp-stapling", |
| 5431 | "-expect-ocsp-response", |
| 5432 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5433 | }, |
| 5434 | resumeSession: true, |
| 5435 | }) |
| 5436 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5437 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5438 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5439 | config: Config{ |
| 5440 | MaxVersion: VersionTLS13, |
| 5441 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5442 | SendExtensionOnCertificate: testOCSPExtension, |
| 5443 | }, |
| 5444 | }, |
| 5445 | shouldFail: true, |
| 5446 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5447 | }) |
| 5448 | |
| 5449 | testCases = append(testCases, testCase{ |
| 5450 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5451 | config: Config{ |
| 5452 | MaxVersion: VersionTLS13, |
| 5453 | Bugs: ProtocolBugs{ |
| 5454 | SendExtensionOnCertificate: testSCTExtension, |
| 5455 | }, |
| 5456 | }, |
| 5457 | shouldFail: true, |
| 5458 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5459 | }) |
| 5460 | |
| 5461 | // Test that extensions on client certificates are never accepted. |
| 5462 | testCases = append(testCases, testCase{ |
| 5463 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5464 | testType: serverTest, |
| 5465 | config: Config{ |
| 5466 | MaxVersion: VersionTLS13, |
| 5467 | Certificates: []Certificate{rsaCertificate}, |
| 5468 | Bugs: ProtocolBugs{ |
| 5469 | SendExtensionOnCertificate: testOCSPExtension, |
| 5470 | }, |
| 5471 | }, |
| 5472 | flags: []string{ |
| 5473 | "-enable-ocsp-stapling", |
| 5474 | "-require-any-client-certificate", |
| 5475 | }, |
| 5476 | shouldFail: true, |
| 5477 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5478 | }) |
| 5479 | |
| 5480 | testCases = append(testCases, testCase{ |
| 5481 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5482 | config: Config{ |
| 5483 | MaxVersion: VersionTLS13, |
| 5484 | Bugs: ProtocolBugs{ |
| 5485 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5486 | }, |
| 5487 | }, |
| 5488 | shouldFail: true, |
| 5489 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5490 | }) |
| 5491 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5492 | var differentSCTList []byte |
| 5493 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5494 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5495 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5496 | // Test that extensions on intermediates are allowed but ignored. |
| 5497 | testCases = append(testCases, testCase{ |
| 5498 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5499 | config: Config{ |
| 5500 | MaxVersion: VersionTLS13, |
| 5501 | Certificates: []Certificate{rsaChainCertificate}, |
| 5502 | Bugs: ProtocolBugs{ |
| 5503 | // Send different values on the intermediate. This tests |
| 5504 | // the intermediate's extensions do not override the |
| 5505 | // leaf's. |
| 5506 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5507 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5508 | }, |
| 5509 | }, |
| 5510 | flags: []string{ |
| 5511 | "-enable-ocsp-stapling", |
| 5512 | "-expect-ocsp-response", |
| 5513 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5514 | "-enable-signed-cert-timestamps", |
| 5515 | "-expect-signed-cert-timestamps", |
| 5516 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5517 | }, |
| 5518 | resumeSession: true, |
| 5519 | }) |
| 5520 | |
| 5521 | // Test that extensions are not sent on intermediates when configured |
| 5522 | // only for a leaf. |
| 5523 | testCases = append(testCases, testCase{ |
| 5524 | testType: serverTest, |
| 5525 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5526 | config: Config{ |
| 5527 | MaxVersion: VersionTLS13, |
| 5528 | Bugs: ProtocolBugs{ |
| 5529 | ExpectNoExtensionsOnIntermediate: true, |
| 5530 | }, |
| 5531 | }, |
| 5532 | flags: []string{ |
| 5533 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5534 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5535 | "-ocsp-response", |
| 5536 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5537 | "-signed-cert-timestamps", |
| 5538 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5539 | }, |
| 5540 | }) |
| 5541 | |
| 5542 | // Test that extensions are not sent on client certificates. |
| 5543 | testCases = append(testCases, testCase{ |
| 5544 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5545 | config: Config{ |
| 5546 | MaxVersion: VersionTLS13, |
| 5547 | ClientAuth: RequireAnyClientCert, |
| 5548 | }, |
| 5549 | flags: []string{ |
| 5550 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5551 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5552 | "-ocsp-response", |
| 5553 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5554 | "-signed-cert-timestamps", |
| 5555 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5556 | }, |
| 5557 | }) |
| 5558 | |
| 5559 | testCases = append(testCases, testCase{ |
| 5560 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5561 | config: Config{ |
| 5562 | MaxVersion: VersionTLS13, |
| 5563 | Bugs: ProtocolBugs{ |
| 5564 | SendDuplicateCertExtensions: true, |
| 5565 | }, |
| 5566 | }, |
| 5567 | flags: []string{ |
| 5568 | "-enable-ocsp-stapling", |
| 5569 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5570 | }, |
| 5571 | resumeSession: true, |
| 5572 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5573 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5574 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5575 | |
| 5576 | testCases = append(testCases, testCase{ |
| 5577 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5578 | testType: serverTest, |
| 5579 | flags: []string{ |
| 5580 | "-signed-cert-timestamps", |
| 5581 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5582 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5583 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5584 | expectedError: ":INVALID_SCT_LIST:", |
| 5585 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5586 | } |
| 5587 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5588 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5589 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5590 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5591 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5592 | // have session IDs, so skip their cross-resumption |
| 5593 | // tests. |
| 5594 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5595 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5596 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5597 | } |
| 5598 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5599 | protocols := []protocol{tls} |
| 5600 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5601 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5602 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5603 | for _, protocol := range protocols { |
| 5604 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5605 | if protocol == dtls { |
| 5606 | suffix += "-DTLS" |
| 5607 | } |
| 5608 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5609 | if sessionVers.version == resumeVers.version { |
| 5610 | testCases = append(testCases, testCase{ |
| 5611 | protocol: protocol, |
| 5612 | name: "Resume-Client" + suffix, |
| 5613 | resumeSession: true, |
| 5614 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5615 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5616 | Bugs: ProtocolBugs{ |
| 5617 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5618 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5619 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5620 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5621 | expectedVersion: sessionVers.version, |
| 5622 | expectedResumeVersion: resumeVers.version, |
| 5623 | }) |
| 5624 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5625 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5626 | |
| 5627 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5628 | // there is no way to convince a non-lookahead client the |
| 5629 | // session was resumed. It will appear to the client that a |
| 5630 | // stray ChangeCipherSpec was sent. |
| 5631 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5632 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5633 | } |
| 5634 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5635 | testCases = append(testCases, testCase{ |
| 5636 | protocol: protocol, |
| 5637 | name: "Resume-Client-Mismatch" + suffix, |
| 5638 | resumeSession: true, |
| 5639 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5640 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5641 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5642 | expectedVersion: sessionVers.version, |
| 5643 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5644 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5645 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5646 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5647 | }, |
| 5648 | }, |
| 5649 | expectedResumeVersion: resumeVers.version, |
| 5650 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5651 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5652 | }) |
| 5653 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5654 | |
| 5655 | testCases = append(testCases, testCase{ |
| 5656 | protocol: protocol, |
| 5657 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5658 | resumeSession: true, |
| 5659 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5660 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5661 | }, |
| 5662 | expectedVersion: sessionVers.version, |
| 5663 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5664 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5665 | }, |
| 5666 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5667 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5668 | expectedResumeVersion: resumeVers.version, |
| 5669 | }) |
| 5670 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5671 | testCases = append(testCases, testCase{ |
| 5672 | protocol: protocol, |
| 5673 | testType: serverTest, |
| 5674 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5675 | resumeSession: true, |
| 5676 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5677 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5678 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5679 | expectedVersion: sessionVers.version, |
| 5680 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5681 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5682 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5683 | Bugs: ProtocolBugs{ |
| 5684 | SendBothTickets: true, |
| 5685 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5686 | }, |
| 5687 | expectedResumeVersion: resumeVers.version, |
| 5688 | }) |
| 5689 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5690 | } |
| 5691 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5692 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5693 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5694 | testCases = append(testCases, testCase{ |
| 5695 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5696 | name: "ShimTicketRewritable", |
| 5697 | resumeSession: true, |
| 5698 | config: Config{ |
| 5699 | MaxVersion: VersionTLS12, |
| 5700 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5701 | Bugs: ProtocolBugs{ |
| 5702 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5703 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5704 | if err != nil { |
| 5705 | return nil, err |
| 5706 | } |
| 5707 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5708 | }, |
| 5709 | }, |
| 5710 | }, |
| 5711 | flags: []string{ |
| 5712 | "-ticket-key", |
| 5713 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5714 | }, |
| 5715 | }) |
| 5716 | |
| 5717 | // Resumptions are declined if the version does not match. |
| 5718 | testCases = append(testCases, testCase{ |
| 5719 | testType: serverTest, |
| 5720 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5721 | resumeSession: true, |
| 5722 | config: Config{ |
| 5723 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5724 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5725 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5726 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5727 | return SetShimTicketVersion(in, VersionTLS13) |
| 5728 | }, |
| 5729 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5730 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5731 | flags: []string{ |
| 5732 | "-ticket-key", |
| 5733 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5734 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5735 | expectResumeRejected: true, |
| 5736 | }) |
| 5737 | |
| 5738 | testCases = append(testCases, testCase{ |
| 5739 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5740 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5741 | resumeSession: true, |
| 5742 | config: Config{ |
| 5743 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5744 | Bugs: ProtocolBugs{ |
| 5745 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5746 | return SetShimTicketVersion(in, VersionTLS12) |
| 5747 | }, |
| 5748 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5749 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5750 | flags: []string{ |
| 5751 | "-ticket-key", |
| 5752 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5753 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5754 | expectResumeRejected: true, |
| 5755 | }) |
| 5756 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5757 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5758 | testCases = append(testCases, testCase{ |
| 5759 | testType: serverTest, |
| 5760 | name: "Resume-Server-DeclineBadCipher", |
| 5761 | resumeSession: true, |
| 5762 | config: Config{ |
| 5763 | MaxVersion: VersionTLS12, |
| 5764 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5765 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5766 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5767 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5768 | }, |
| 5769 | }, |
| 5770 | }, |
| 5771 | flags: []string{ |
| 5772 | "-ticket-key", |
| 5773 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5774 | }, |
| 5775 | expectResumeRejected: true, |
| 5776 | }) |
| 5777 | |
| 5778 | testCases = append(testCases, testCase{ |
| 5779 | testType: serverTest, |
| 5780 | name: "Resume-Server-DeclineBadCipher-2", |
| 5781 | resumeSession: true, |
| 5782 | config: Config{ |
| 5783 | MaxVersion: VersionTLS12, |
| 5784 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5785 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5786 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5787 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5788 | }, |
| 5789 | }, |
| 5790 | }, |
| 5791 | flags: []string{ |
| 5792 | "-cipher", "AES128", |
| 5793 | "-ticket-key", |
| 5794 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5795 | }, |
| 5796 | expectResumeRejected: true, |
| 5797 | }) |
| 5798 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5799 | // Sessions are not resumed if they do not use the preferred cipher. |
| 5800 | testCases = append(testCases, testCase{ |
| 5801 | testType: serverTest, |
| 5802 | name: "Resume-Server-CipherNotPreferred", |
| 5803 | resumeSession: true, |
| 5804 | config: Config{ |
| 5805 | MaxVersion: VersionTLS12, |
| 5806 | Bugs: ProtocolBugs{ |
| 5807 | ExpectNewTicket: true, |
| 5808 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5809 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 5810 | }, |
| 5811 | }, |
| 5812 | }, |
| 5813 | flags: []string{ |
| 5814 | "-ticket-key", |
| 5815 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5816 | }, |
| 5817 | shouldFail: false, |
| 5818 | expectResumeRejected: true, |
| 5819 | }) |
| 5820 | |
| 5821 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 5822 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 5823 | testCases = append(testCases, testCase{ |
| 5824 | testType: serverTest, |
| 5825 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 5826 | resumeSession: true, |
| 5827 | config: Config{ |
| 5828 | MaxVersion: VersionTLS13, |
| 5829 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 5830 | Bugs: ProtocolBugs{ |
| 5831 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5832 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 5833 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 5834 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5835 | }, |
| 5836 | }, |
| 5837 | }, |
| 5838 | flags: []string{ |
| 5839 | "-ticket-key", |
| 5840 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5841 | }, |
| 5842 | shouldFail: false, |
| 5843 | expectResumeRejected: true, |
| 5844 | }) |
| 5845 | |
| 5846 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5847 | testCases = append(testCases, testCase{ |
| 5848 | testType: serverTest, |
| 5849 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5850 | resumeSession: true, |
| 5851 | config: Config{ |
| 5852 | MaxVersion: VersionTLS13, |
| 5853 | Bugs: ProtocolBugs{ |
| 5854 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5855 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5856 | }, |
| 5857 | }, |
| 5858 | }, |
| 5859 | flags: []string{ |
| 5860 | "-ticket-key", |
| 5861 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5862 | }, |
| 5863 | expectResumeRejected: true, |
| 5864 | }) |
| 5865 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5866 | // If the client does not offer the cipher from the session, decline to |
| 5867 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 5868 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5869 | testCases = append(testCases, testCase{ |
| 5870 | testType: serverTest, |
| 5871 | name: "Resume-Server-UnofferedCipher", |
| 5872 | resumeSession: true, |
| 5873 | config: Config{ |
| 5874 | MaxVersion: VersionTLS12, |
| 5875 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5876 | }, |
| 5877 | resumeConfig: &Config{ |
| 5878 | MaxVersion: VersionTLS12, |
| 5879 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5880 | Bugs: ProtocolBugs{ |
| 5881 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5882 | }, |
| 5883 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5884 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5885 | }) |
| 5886 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5887 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 5888 | // include the selected cipher. Test that we tolerate this. Servers may |
| 5889 | // resume at another cipher if the PRF matches, but BoringSSL will |
| 5890 | // always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5891 | testCases = append(testCases, testCase{ |
| 5892 | testType: serverTest, |
| 5893 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5894 | resumeSession: true, |
| 5895 | config: Config{ |
| 5896 | MaxVersion: VersionTLS13, |
| 5897 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5898 | }, |
| 5899 | resumeConfig: &Config{ |
| 5900 | MaxVersion: VersionTLS13, |
| 5901 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5902 | Bugs: ProtocolBugs{ |
| 5903 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5904 | }, |
| 5905 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5906 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5907 | }) |
| 5908 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5909 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5910 | testCases = append(testCases, testCase{ |
| 5911 | name: "Resume-Client-CipherMismatch", |
| 5912 | resumeSession: true, |
| 5913 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5914 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5915 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5916 | }, |
| 5917 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5918 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5919 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5920 | Bugs: ProtocolBugs{ |
| 5921 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5922 | }, |
| 5923 | }, |
| 5924 | shouldFail: true, |
| 5925 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5926 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5927 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5928 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 5929 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5930 | testCases = append(testCases, testCase{ |
| 5931 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5932 | resumeSession: true, |
| 5933 | config: Config{ |
| 5934 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5935 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5936 | }, |
| 5937 | resumeConfig: &Config{ |
| 5938 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5939 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5940 | }, |
| 5941 | }) |
| 5942 | |
| 5943 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 5944 | testCases = append(testCases, testCase{ |
| 5945 | name: "Resume-Client-PRFMismatch-TLS13", |
| 5946 | resumeSession: true, |
| 5947 | config: Config{ |
| 5948 | MaxVersion: VersionTLS13, |
| 5949 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5950 | }, |
| 5951 | resumeConfig: &Config{ |
| 5952 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5953 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5954 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5955 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5956 | }, |
| 5957 | }, |
| 5958 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5959 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5960 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5961 | |
| 5962 | testCases = append(testCases, testCase{ |
| 5963 | testType: serverTest, |
| 5964 | name: "Resume-Server-BinderWrongLength", |
| 5965 | resumeSession: true, |
| 5966 | config: Config{ |
| 5967 | MaxVersion: VersionTLS13, |
| 5968 | Bugs: ProtocolBugs{ |
| 5969 | SendShortPSKBinder: true, |
| 5970 | }, |
| 5971 | }, |
| 5972 | shouldFail: true, |
| 5973 | expectedLocalError: "remote error: error decrypting message", |
| 5974 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5975 | }) |
| 5976 | |
| 5977 | testCases = append(testCases, testCase{ |
| 5978 | testType: serverTest, |
| 5979 | name: "Resume-Server-NoPSKBinder", |
| 5980 | resumeSession: true, |
| 5981 | config: Config{ |
| 5982 | MaxVersion: VersionTLS13, |
| 5983 | Bugs: ProtocolBugs{ |
| 5984 | SendNoPSKBinder: true, |
| 5985 | }, |
| 5986 | }, |
| 5987 | shouldFail: true, |
| 5988 | expectedLocalError: "remote error: error decoding message", |
| 5989 | expectedError: ":DECODE_ERROR:", |
| 5990 | }) |
| 5991 | |
| 5992 | testCases = append(testCases, testCase{ |
| 5993 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 5994 | name: "Resume-Server-ExtraPSKBinder", |
| 5995 | resumeSession: true, |
| 5996 | config: Config{ |
| 5997 | MaxVersion: VersionTLS13, |
| 5998 | Bugs: ProtocolBugs{ |
| 5999 | SendExtraPSKBinder: true, |
| 6000 | }, |
| 6001 | }, |
| 6002 | shouldFail: true, |
| 6003 | expectedLocalError: "remote error: illegal parameter", |
| 6004 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6005 | }) |
| 6006 | |
| 6007 | testCases = append(testCases, testCase{ |
| 6008 | testType: serverTest, |
| 6009 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6010 | resumeSession: true, |
| 6011 | config: Config{ |
| 6012 | MaxVersion: VersionTLS13, |
| 6013 | Bugs: ProtocolBugs{ |
| 6014 | ExtraPSKIdentity: true, |
| 6015 | }, |
| 6016 | }, |
| 6017 | shouldFail: true, |
| 6018 | expectedLocalError: "remote error: illegal parameter", |
| 6019 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6020 | }) |
| 6021 | |
| 6022 | testCases = append(testCases, testCase{ |
| 6023 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6024 | name: "Resume-Server-InvalidPSKBinder", |
| 6025 | resumeSession: true, |
| 6026 | config: Config{ |
| 6027 | MaxVersion: VersionTLS13, |
| 6028 | Bugs: ProtocolBugs{ |
| 6029 | SendInvalidPSKBinder: true, |
| 6030 | }, |
| 6031 | }, |
| 6032 | shouldFail: true, |
| 6033 | expectedLocalError: "remote error: error decrypting message", |
| 6034 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6035 | }) |
| 6036 | |
| 6037 | testCases = append(testCases, testCase{ |
| 6038 | testType: serverTest, |
| 6039 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6040 | resumeSession: true, |
| 6041 | config: Config{ |
| 6042 | MaxVersion: VersionTLS13, |
| 6043 | Bugs: ProtocolBugs{ |
| 6044 | PSKBinderFirst: true, |
| 6045 | }, |
| 6046 | }, |
| 6047 | shouldFail: true, |
| 6048 | expectedLocalError: "remote error: illegal parameter", |
| 6049 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6050 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6051 | } |
| 6052 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6053 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6054 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6055 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6056 | testType: serverTest, |
| 6057 | name: "Renegotiate-Server-Forbidden", |
| 6058 | config: Config{ |
| 6059 | MaxVersion: VersionTLS12, |
| 6060 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6061 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6062 | shouldFail: true, |
| 6063 | expectedError: ":NO_RENEGOTIATION:", |
| 6064 | expectedLocalError: "remote error: no renegotiation", |
| 6065 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6066 | // The server shouldn't echo the renegotiation extension unless |
| 6067 | // requested by the client. |
| 6068 | testCases = append(testCases, testCase{ |
| 6069 | testType: serverTest, |
| 6070 | name: "Renegotiate-Server-NoExt", |
| 6071 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6072 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6073 | Bugs: ProtocolBugs{ |
| 6074 | NoRenegotiationInfo: true, |
| 6075 | RequireRenegotiationInfo: true, |
| 6076 | }, |
| 6077 | }, |
| 6078 | shouldFail: true, |
| 6079 | expectedLocalError: "renegotiation extension missing", |
| 6080 | }) |
| 6081 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6082 | // the extension. |
| 6083 | testCases = append(testCases, testCase{ |
| 6084 | testType: serverTest, |
| 6085 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6086 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6087 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6088 | Bugs: ProtocolBugs{ |
| 6089 | NoRenegotiationInfo: true, |
| 6090 | SendRenegotiationSCSV: true, |
| 6091 | RequireRenegotiationInfo: true, |
| 6092 | }, |
| 6093 | }, |
| 6094 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6095 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6096 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6097 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6098 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6099 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6100 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6101 | }, |
| 6102 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6103 | renegotiate: 1, |
| 6104 | flags: []string{ |
| 6105 | "-renegotiate-freely", |
| 6106 | "-expect-total-renegotiations", "1", |
| 6107 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6108 | }) |
| 6109 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6110 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6111 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6112 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6113 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6114 | Bugs: ProtocolBugs{ |
| 6115 | EmptyRenegotiationInfo: true, |
| 6116 | }, |
| 6117 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6118 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6119 | shouldFail: true, |
| 6120 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6121 | }) |
| 6122 | testCases = append(testCases, testCase{ |
| 6123 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6124 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6125 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6126 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6127 | Bugs: ProtocolBugs{ |
| 6128 | BadRenegotiationInfo: true, |
| 6129 | }, |
| 6130 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6131 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6132 | shouldFail: true, |
| 6133 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6134 | }) |
| 6135 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6136 | name: "Renegotiate-Client-Downgrade", |
| 6137 | renegotiate: 1, |
| 6138 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6139 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6140 | Bugs: ProtocolBugs{ |
| 6141 | NoRenegotiationInfoAfterInitial: true, |
| 6142 | }, |
| 6143 | }, |
| 6144 | flags: []string{"-renegotiate-freely"}, |
| 6145 | shouldFail: true, |
| 6146 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6147 | }) |
| 6148 | testCases = append(testCases, testCase{ |
| 6149 | name: "Renegotiate-Client-Upgrade", |
| 6150 | renegotiate: 1, |
| 6151 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6152 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6153 | Bugs: ProtocolBugs{ |
| 6154 | NoRenegotiationInfoInInitial: true, |
| 6155 | }, |
| 6156 | }, |
| 6157 | flags: []string{"-renegotiate-freely"}, |
| 6158 | shouldFail: true, |
| 6159 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6160 | }) |
| 6161 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6162 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6163 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6164 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6165 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6166 | Bugs: ProtocolBugs{ |
| 6167 | NoRenegotiationInfo: true, |
| 6168 | }, |
| 6169 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6170 | flags: []string{ |
| 6171 | "-renegotiate-freely", |
| 6172 | "-expect-total-renegotiations", "1", |
| 6173 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6174 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6175 | |
| 6176 | // Test that the server may switch ciphers on renegotiation without |
| 6177 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6178 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6179 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6180 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6181 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6182 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6183 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6184 | }, |
| 6185 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6186 | flags: []string{ |
| 6187 | "-renegotiate-freely", |
| 6188 | "-expect-total-renegotiations", "1", |
| 6189 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6190 | }) |
| 6191 | testCases = append(testCases, testCase{ |
| 6192 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6193 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6194 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6195 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6196 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6197 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6198 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6199 | flags: []string{ |
| 6200 | "-renegotiate-freely", |
| 6201 | "-expect-total-renegotiations", "1", |
| 6202 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6203 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6204 | |
| 6205 | // Test that the server may not switch versions on renegotiation. |
| 6206 | testCases = append(testCases, testCase{ |
| 6207 | name: "Renegotiate-Client-SwitchVersion", |
| 6208 | config: Config{ |
| 6209 | MaxVersion: VersionTLS12, |
| 6210 | // Pick a cipher which exists at both versions. |
| 6211 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6212 | Bugs: ProtocolBugs{ |
| 6213 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6214 | // Avoid failing early at the record layer. |
| 6215 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6216 | }, |
| 6217 | }, |
| 6218 | renegotiate: 1, |
| 6219 | flags: []string{ |
| 6220 | "-renegotiate-freely", |
| 6221 | "-expect-total-renegotiations", "1", |
| 6222 | }, |
| 6223 | shouldFail: true, |
| 6224 | expectedError: ":WRONG_SSL_VERSION:", |
| 6225 | }) |
| 6226 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6227 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6228 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6229 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6230 | config: Config{ |
| 6231 | MaxVersion: VersionTLS10, |
| 6232 | Bugs: ProtocolBugs{ |
| 6233 | RequireSameRenegoClientVersion: true, |
| 6234 | }, |
| 6235 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6236 | flags: []string{ |
| 6237 | "-renegotiate-freely", |
| 6238 | "-expect-total-renegotiations", "1", |
| 6239 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6240 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6241 | testCases = append(testCases, testCase{ |
| 6242 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6243 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6244 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6245 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6246 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6247 | NextProtos: []string{"foo"}, |
| 6248 | }, |
| 6249 | flags: []string{ |
| 6250 | "-false-start", |
| 6251 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6252 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6253 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6254 | }, |
| 6255 | shimWritesFirst: true, |
| 6256 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6257 | |
| 6258 | // Client-side renegotiation controls. |
| 6259 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6260 | name: "Renegotiate-Client-Forbidden-1", |
| 6261 | config: Config{ |
| 6262 | MaxVersion: VersionTLS12, |
| 6263 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6264 | renegotiate: 1, |
| 6265 | shouldFail: true, |
| 6266 | expectedError: ":NO_RENEGOTIATION:", |
| 6267 | expectedLocalError: "remote error: no renegotiation", |
| 6268 | }) |
| 6269 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6270 | name: "Renegotiate-Client-Once-1", |
| 6271 | config: Config{ |
| 6272 | MaxVersion: VersionTLS12, |
| 6273 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6274 | renegotiate: 1, |
| 6275 | flags: []string{ |
| 6276 | "-renegotiate-once", |
| 6277 | "-expect-total-renegotiations", "1", |
| 6278 | }, |
| 6279 | }) |
| 6280 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6281 | name: "Renegotiate-Client-Freely-1", |
| 6282 | config: Config{ |
| 6283 | MaxVersion: VersionTLS12, |
| 6284 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6285 | renegotiate: 1, |
| 6286 | flags: []string{ |
| 6287 | "-renegotiate-freely", |
| 6288 | "-expect-total-renegotiations", "1", |
| 6289 | }, |
| 6290 | }) |
| 6291 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6292 | name: "Renegotiate-Client-Once-2", |
| 6293 | config: Config{ |
| 6294 | MaxVersion: VersionTLS12, |
| 6295 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6296 | renegotiate: 2, |
| 6297 | flags: []string{"-renegotiate-once"}, |
| 6298 | shouldFail: true, |
| 6299 | expectedError: ":NO_RENEGOTIATION:", |
| 6300 | expectedLocalError: "remote error: no renegotiation", |
| 6301 | }) |
| 6302 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6303 | name: "Renegotiate-Client-Freely-2", |
| 6304 | config: Config{ |
| 6305 | MaxVersion: VersionTLS12, |
| 6306 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6307 | renegotiate: 2, |
| 6308 | flags: []string{ |
| 6309 | "-renegotiate-freely", |
| 6310 | "-expect-total-renegotiations", "2", |
| 6311 | }, |
| 6312 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6313 | testCases = append(testCases, testCase{ |
| 6314 | name: "Renegotiate-Client-NoIgnore", |
| 6315 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6316 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6317 | Bugs: ProtocolBugs{ |
| 6318 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6319 | }, |
| 6320 | }, |
| 6321 | shouldFail: true, |
| 6322 | expectedError: ":NO_RENEGOTIATION:", |
| 6323 | }) |
| 6324 | testCases = append(testCases, testCase{ |
| 6325 | name: "Renegotiate-Client-Ignore", |
| 6326 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6327 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6328 | Bugs: ProtocolBugs{ |
| 6329 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6330 | }, |
| 6331 | }, |
| 6332 | flags: []string{ |
| 6333 | "-renegotiate-ignore", |
| 6334 | "-expect-total-renegotiations", "0", |
| 6335 | }, |
| 6336 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6337 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6338 | // Renegotiation is not allowed at SSL 3.0. |
| 6339 | testCases = append(testCases, testCase{ |
| 6340 | name: "Renegotiate-Client-SSL3", |
| 6341 | config: Config{ |
| 6342 | MaxVersion: VersionSSL30, |
| 6343 | }, |
| 6344 | renegotiate: 1, |
| 6345 | flags: []string{ |
| 6346 | "-renegotiate-freely", |
| 6347 | "-expect-total-renegotiations", "1", |
| 6348 | }, |
| 6349 | shouldFail: true, |
| 6350 | expectedError: ":NO_RENEGOTIATION:", |
| 6351 | expectedLocalError: "remote error: no renegotiation", |
| 6352 | }) |
| 6353 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6354 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6355 | testCases = append(testCases, testCase{ |
| 6356 | name: "StrayHelloRequest", |
| 6357 | config: Config{ |
| 6358 | MaxVersion: VersionTLS12, |
| 6359 | Bugs: ProtocolBugs{ |
| 6360 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6361 | }, |
| 6362 | }, |
| 6363 | }) |
| 6364 | testCases = append(testCases, testCase{ |
| 6365 | name: "StrayHelloRequest-Packed", |
| 6366 | config: Config{ |
| 6367 | MaxVersion: VersionTLS12, |
| 6368 | Bugs: ProtocolBugs{ |
| 6369 | PackHandshakeFlight: true, |
| 6370 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6371 | }, |
| 6372 | }, |
| 6373 | }) |
| 6374 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6375 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6376 | // the same record. |
| 6377 | testCases = append(testCases, testCase{ |
| 6378 | name: "Renegotiate-Client-Packed", |
| 6379 | config: Config{ |
| 6380 | MaxVersion: VersionTLS12, |
| 6381 | Bugs: ProtocolBugs{ |
| 6382 | PackHandshakeFlight: true, |
| 6383 | PackHelloRequestWithFinished: true, |
| 6384 | }, |
| 6385 | }, |
| 6386 | renegotiate: 1, |
| 6387 | flags: []string{ |
| 6388 | "-renegotiate-freely", |
| 6389 | "-expect-total-renegotiations", "1", |
| 6390 | }, |
| 6391 | }) |
| 6392 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6393 | // Renegotiation is forbidden in TLS 1.3. |
| 6394 | testCases = append(testCases, testCase{ |
| 6395 | name: "Renegotiate-Client-TLS13", |
| 6396 | config: Config{ |
| 6397 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6398 | Bugs: ProtocolBugs{ |
| 6399 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6400 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6401 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6402 | flags: []string{ |
| 6403 | "-renegotiate-freely", |
| 6404 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6405 | shouldFail: true, |
| 6406 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6407 | }) |
| 6408 | |
| 6409 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6410 | testCases = append(testCases, testCase{ |
| 6411 | name: "StrayHelloRequest-TLS13", |
| 6412 | config: Config{ |
| 6413 | MaxVersion: VersionTLS13, |
| 6414 | Bugs: ProtocolBugs{ |
| 6415 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6416 | }, |
| 6417 | }, |
| 6418 | shouldFail: true, |
| 6419 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6420 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6421 | } |
| 6422 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6423 | func addDTLSReplayTests() { |
| 6424 | // Test that sequence number replays are detected. |
| 6425 | testCases = append(testCases, testCase{ |
| 6426 | protocol: dtls, |
| 6427 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6428 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6429 | replayWrites: true, |
| 6430 | }) |
| 6431 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6432 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6433 | // than the retransmit window. |
| 6434 | testCases = append(testCases, testCase{ |
| 6435 | protocol: dtls, |
| 6436 | name: "DTLS-Replay-LargeGaps", |
| 6437 | config: Config{ |
| 6438 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6439 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6440 | return in * 127 |
| 6441 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6442 | }, |
| 6443 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6444 | messageCount: 200, |
| 6445 | replayWrites: true, |
| 6446 | }) |
| 6447 | |
| 6448 | // Test the incoming sequence number changing non-monotonically. |
| 6449 | testCases = append(testCases, testCase{ |
| 6450 | protocol: dtls, |
| 6451 | name: "DTLS-Replay-NonMonotonic", |
| 6452 | config: Config{ |
| 6453 | Bugs: ProtocolBugs{ |
| 6454 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6455 | return in ^ 31 |
| 6456 | }, |
| 6457 | }, |
| 6458 | }, |
| 6459 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6460 | replayWrites: true, |
| 6461 | }) |
| 6462 | } |
| 6463 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6464 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6465 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6466 | id signatureAlgorithm |
| 6467 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6468 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6469 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6470 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6471 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6472 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6473 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6474 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6475 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6476 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6477 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6478 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6479 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6480 | // Tests for key types prior to TLS 1.2. |
| 6481 | {"RSA", 0, testCertRSA}, |
| 6482 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6483 | } |
| 6484 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6485 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6486 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6487 | |
| 6488 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6489 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6490 | // versions a signing cipher. |
| 6491 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6492 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6493 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6494 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6495 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6496 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6497 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6498 | } |
| 6499 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6500 | var allAlgorithms []signatureAlgorithm |
| 6501 | for _, alg := range testSignatureAlgorithms { |
| 6502 | if alg.id != 0 { |
| 6503 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6504 | } |
| 6505 | } |
| 6506 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6507 | // Make sure each signature algorithm works. Include some fake values in |
| 6508 | // the list and ensure they're ignored. |
| 6509 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6510 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6511 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6512 | continue |
| 6513 | } |
| 6514 | |
| 6515 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6516 | // or remove it in C. |
| 6517 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6518 | continue |
| 6519 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6520 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6521 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6522 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6523 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6524 | shouldSignFail = true |
| 6525 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6526 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6527 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6528 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6529 | shouldSignFail = true |
| 6530 | shouldVerifyFail = true |
| 6531 | } |
| 6532 | |
| 6533 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6534 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6535 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6536 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6537 | |
| 6538 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6539 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6540 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6541 | } |
| 6542 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6543 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6544 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6545 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6546 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6547 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6548 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6549 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6550 | config: Config{ |
| 6551 | MaxVersion: ver.version, |
| 6552 | ClientAuth: RequireAnyClientCert, |
| 6553 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6554 | fakeSigAlg1, |
| 6555 | alg.id, |
| 6556 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6557 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6558 | }, |
| 6559 | flags: []string{ |
| 6560 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6561 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6562 | "-enable-all-curves", |
| 6563 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6564 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6565 | expectedError: signError, |
| 6566 | expectedPeerSignatureAlgorithm: alg.id, |
| 6567 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6568 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6569 | testCases = append(testCases, testCase{ |
| 6570 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6571 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6572 | config: Config{ |
| 6573 | MaxVersion: ver.version, |
| 6574 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6575 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6576 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6577 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6578 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6579 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6580 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6581 | // Some signature algorithms may not be advertised. |
| 6582 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6583 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6584 | }, |
| 6585 | flags: []string{ |
| 6586 | "-require-any-client-certificate", |
| 6587 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6588 | "-enable-all-curves", |
| 6589 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6590 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6591 | expectedError: verifyError, |
| 6592 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6593 | |
| 6594 | testCases = append(testCases, testCase{ |
| 6595 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6596 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6597 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6598 | MaxVersion: ver.version, |
| 6599 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6600 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6601 | fakeSigAlg1, |
| 6602 | alg.id, |
| 6603 | fakeSigAlg2, |
| 6604 | }, |
| 6605 | }, |
| 6606 | flags: []string{ |
| 6607 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6608 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6609 | "-enable-all-curves", |
| 6610 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6611 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6612 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6613 | expectedPeerSignatureAlgorithm: alg.id, |
| 6614 | }) |
| 6615 | |
| 6616 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6617 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6618 | config: Config{ |
| 6619 | MaxVersion: ver.version, |
| 6620 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6621 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6622 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6623 | alg.id, |
| 6624 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6625 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6626 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6627 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6628 | // Some signature algorithms may not be advertised. |
| 6629 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6630 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6631 | }, |
| 6632 | flags: []string{ |
| 6633 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6634 | "-enable-all-curves", |
| 6635 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6636 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6637 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6638 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6639 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6640 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6641 | testCases = append(testCases, testCase{ |
| 6642 | testType: serverTest, |
| 6643 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6644 | config: Config{ |
| 6645 | MaxVersion: ver.version, |
| 6646 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6647 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6648 | alg.id, |
| 6649 | }, |
| 6650 | Bugs: ProtocolBugs{ |
| 6651 | InvalidSignature: true, |
| 6652 | }, |
| 6653 | }, |
| 6654 | flags: []string{ |
| 6655 | "-require-any-client-certificate", |
| 6656 | "-enable-all-curves", |
| 6657 | }, |
| 6658 | shouldFail: true, |
| 6659 | expectedError: ":BAD_SIGNATURE:", |
| 6660 | }) |
| 6661 | |
| 6662 | testCases = append(testCases, testCase{ |
| 6663 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6664 | config: Config{ |
| 6665 | MaxVersion: ver.version, |
| 6666 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6667 | CipherSuites: signingCiphers, |
| 6668 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6669 | alg.id, |
| 6670 | }, |
| 6671 | Bugs: ProtocolBugs{ |
| 6672 | InvalidSignature: true, |
| 6673 | }, |
| 6674 | }, |
| 6675 | flags: []string{"-enable-all-curves"}, |
| 6676 | shouldFail: true, |
| 6677 | expectedError: ":BAD_SIGNATURE:", |
| 6678 | }) |
| 6679 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6680 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6681 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6682 | testCases = append(testCases, testCase{ |
| 6683 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6684 | config: Config{ |
| 6685 | MaxVersion: ver.version, |
| 6686 | ClientAuth: RequireAnyClientCert, |
| 6687 | VerifySignatureAlgorithms: allAlgorithms, |
| 6688 | }, |
| 6689 | flags: []string{ |
| 6690 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6691 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6692 | "-enable-all-curves", |
| 6693 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6694 | }, |
| 6695 | expectedPeerSignatureAlgorithm: alg.id, |
| 6696 | }) |
| 6697 | |
| 6698 | testCases = append(testCases, testCase{ |
| 6699 | testType: serverTest, |
| 6700 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6701 | config: Config{ |
| 6702 | MaxVersion: ver.version, |
| 6703 | CipherSuites: signingCiphers, |
| 6704 | VerifySignatureAlgorithms: allAlgorithms, |
| 6705 | }, |
| 6706 | flags: []string{ |
| 6707 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6708 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6709 | "-enable-all-curves", |
| 6710 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6711 | }, |
| 6712 | expectedPeerSignatureAlgorithm: alg.id, |
| 6713 | }) |
| 6714 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6715 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6716 | } |
| 6717 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6718 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6719 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6720 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6721 | config: Config{ |
| 6722 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6723 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6724 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6725 | signatureECDSAWithP521AndSHA512, |
| 6726 | signatureRSAPKCS1WithSHA384, |
| 6727 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6728 | }, |
| 6729 | }, |
| 6730 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6731 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6732 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6733 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6734 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6735 | }) |
| 6736 | |
| 6737 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6738 | name: "ClientAuth-SignatureType-TLS13", |
| 6739 | config: Config{ |
| 6740 | ClientAuth: RequireAnyClientCert, |
| 6741 | MaxVersion: VersionTLS13, |
| 6742 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6743 | signatureECDSAWithP521AndSHA512, |
| 6744 | signatureRSAPKCS1WithSHA384, |
| 6745 | signatureRSAPSSWithSHA384, |
| 6746 | signatureECDSAWithSHA1, |
| 6747 | }, |
| 6748 | }, |
| 6749 | flags: []string{ |
| 6750 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6751 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6752 | }, |
| 6753 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6754 | }) |
| 6755 | |
| 6756 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6757 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6758 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6759 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6760 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6761 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6762 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6763 | signatureECDSAWithP521AndSHA512, |
| 6764 | signatureRSAPKCS1WithSHA384, |
| 6765 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6766 | }, |
| 6767 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6768 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6769 | }) |
| 6770 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6771 | testCases = append(testCases, testCase{ |
| 6772 | testType: serverTest, |
| 6773 | name: "ServerAuth-SignatureType-TLS13", |
| 6774 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6775 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6776 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6777 | signatureECDSAWithP521AndSHA512, |
| 6778 | signatureRSAPKCS1WithSHA384, |
| 6779 | signatureRSAPSSWithSHA384, |
| 6780 | signatureECDSAWithSHA1, |
| 6781 | }, |
| 6782 | }, |
| 6783 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6784 | }) |
| 6785 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6786 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6787 | testCases = append(testCases, testCase{ |
| 6788 | testType: serverTest, |
| 6789 | name: "Verify-ClientAuth-SignatureType", |
| 6790 | config: Config{ |
| 6791 | MaxVersion: VersionTLS12, |
| 6792 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6793 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6794 | signatureRSAPKCS1WithSHA256, |
| 6795 | }, |
| 6796 | Bugs: ProtocolBugs{ |
| 6797 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6798 | }, |
| 6799 | }, |
| 6800 | flags: []string{ |
| 6801 | "-require-any-client-certificate", |
| 6802 | }, |
| 6803 | shouldFail: true, |
| 6804 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6805 | }) |
| 6806 | |
| 6807 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6808 | testType: serverTest, |
| 6809 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6810 | config: Config{ |
| 6811 | MaxVersion: VersionTLS13, |
| 6812 | Certificates: []Certificate{rsaCertificate}, |
| 6813 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6814 | signatureRSAPSSWithSHA256, |
| 6815 | }, |
| 6816 | Bugs: ProtocolBugs{ |
| 6817 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6818 | }, |
| 6819 | }, |
| 6820 | flags: []string{ |
| 6821 | "-require-any-client-certificate", |
| 6822 | }, |
| 6823 | shouldFail: true, |
| 6824 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6825 | }) |
| 6826 | |
| 6827 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6828 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6829 | config: Config{ |
| 6830 | MaxVersion: VersionTLS12, |
| 6831 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6832 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6833 | signatureRSAPKCS1WithSHA256, |
| 6834 | }, |
| 6835 | Bugs: ProtocolBugs{ |
| 6836 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6837 | }, |
| 6838 | }, |
| 6839 | shouldFail: true, |
| 6840 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6841 | }) |
| 6842 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6843 | testCases = append(testCases, testCase{ |
| 6844 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6845 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6846 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6847 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6848 | signatureRSAPSSWithSHA256, |
| 6849 | }, |
| 6850 | Bugs: ProtocolBugs{ |
| 6851 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6852 | }, |
| 6853 | }, |
| 6854 | shouldFail: true, |
| 6855 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6856 | }) |
| 6857 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6858 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6859 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6860 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6861 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6862 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6863 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6864 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6865 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6866 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6867 | }, |
| 6868 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6869 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6870 | }, |
| 6871 | }, |
| 6872 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6873 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6874 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6875 | }, |
| 6876 | }) |
| 6877 | |
| 6878 | testCases = append(testCases, testCase{ |
| 6879 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6880 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6881 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6882 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6883 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6884 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6885 | }, |
| 6886 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6887 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6888 | }, |
| 6889 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6890 | flags: []string{ |
| 6891 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6892 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6893 | }, |
| 6894 | }) |
| 6895 | |
| 6896 | testCases = append(testCases, testCase{ |
| 6897 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6898 | config: Config{ |
| 6899 | MaxVersion: VersionTLS12, |
| 6900 | ClientAuth: RequireAnyClientCert, |
| 6901 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6902 | signatureECDSAWithSHA1, |
| 6903 | }, |
| 6904 | Bugs: ProtocolBugs{ |
| 6905 | NoSignatureAlgorithms: true, |
| 6906 | }, |
| 6907 | }, |
| 6908 | flags: []string{ |
| 6909 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6910 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6911 | }, |
| 6912 | }) |
| 6913 | |
| 6914 | testCases = append(testCases, testCase{ |
| 6915 | testType: serverTest, |
| 6916 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6917 | config: Config{ |
| 6918 | MaxVersion: VersionTLS12, |
| 6919 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6920 | signatureECDSAWithSHA1, |
| 6921 | }, |
| 6922 | Bugs: ProtocolBugs{ |
| 6923 | NoSignatureAlgorithms: true, |
| 6924 | }, |
| 6925 | }, |
| 6926 | flags: []string{ |
| 6927 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6928 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6929 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6930 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6931 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6932 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6933 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6934 | config: Config{ |
| 6935 | MaxVersion: VersionTLS13, |
| 6936 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6937 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6938 | signatureRSAPKCS1WithSHA1, |
| 6939 | }, |
| 6940 | Bugs: ProtocolBugs{ |
| 6941 | NoSignatureAlgorithms: true, |
| 6942 | }, |
| 6943 | }, |
| 6944 | flags: []string{ |
| 6945 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6946 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6947 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6948 | shouldFail: true, |
| 6949 | // An empty CertificateRequest signature algorithm list is a |
| 6950 | // syntax error in TLS 1.3. |
| 6951 | expectedError: ":DECODE_ERROR:", |
| 6952 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6953 | }) |
| 6954 | |
| 6955 | testCases = append(testCases, testCase{ |
| 6956 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6957 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6958 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6959 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6960 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6961 | signatureRSAPKCS1WithSHA1, |
| 6962 | }, |
| 6963 | Bugs: ProtocolBugs{ |
| 6964 | NoSignatureAlgorithms: true, |
| 6965 | }, |
| 6966 | }, |
| 6967 | shouldFail: true, |
| 6968 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6969 | }) |
| 6970 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6971 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6972 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6973 | testCases = append(testCases, testCase{ |
| 6974 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6975 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6976 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6977 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6978 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6979 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6980 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6981 | }, |
| 6982 | Bugs: ProtocolBugs{ |
| 6983 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6984 | }, |
| 6985 | }, |
| 6986 | flags: []string{"-require-any-client-certificate"}, |
| 6987 | shouldFail: true, |
| 6988 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6989 | }) |
| 6990 | |
| 6991 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6992 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6993 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6994 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6995 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6996 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6997 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6998 | }, |
| 6999 | Bugs: ProtocolBugs{ |
| 7000 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7001 | }, |
| 7002 | }, |
| 7003 | shouldFail: true, |
| 7004 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7005 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7006 | testCases = append(testCases, testCase{ |
| 7007 | testType: serverTest, |
| 7008 | name: "ClientAuth-Enforced-TLS13", |
| 7009 | config: Config{ |
| 7010 | MaxVersion: VersionTLS13, |
| 7011 | Certificates: []Certificate{rsaCertificate}, |
| 7012 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7013 | signatureRSAPKCS1WithMD5, |
| 7014 | }, |
| 7015 | Bugs: ProtocolBugs{ |
| 7016 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7017 | IgnoreSignatureVersionChecks: true, |
| 7018 | }, |
| 7019 | }, |
| 7020 | flags: []string{"-require-any-client-certificate"}, |
| 7021 | shouldFail: true, |
| 7022 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7023 | }) |
| 7024 | |
| 7025 | testCases = append(testCases, testCase{ |
| 7026 | name: "ServerAuth-Enforced-TLS13", |
| 7027 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7028 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7029 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7030 | signatureRSAPKCS1WithMD5, |
| 7031 | }, |
| 7032 | Bugs: ProtocolBugs{ |
| 7033 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7034 | IgnoreSignatureVersionChecks: true, |
| 7035 | }, |
| 7036 | }, |
| 7037 | shouldFail: true, |
| 7038 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7039 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7040 | |
| 7041 | // Test that the agreed upon digest respects the client preferences and |
| 7042 | // the server digests. |
| 7043 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7044 | name: "NoCommonAlgorithms-Digests", |
| 7045 | config: Config{ |
| 7046 | MaxVersion: VersionTLS12, |
| 7047 | ClientAuth: RequireAnyClientCert, |
| 7048 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7049 | signatureRSAPKCS1WithSHA512, |
| 7050 | signatureRSAPKCS1WithSHA1, |
| 7051 | }, |
| 7052 | }, |
| 7053 | flags: []string{ |
| 7054 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7055 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7056 | "-digest-prefs", "SHA256", |
| 7057 | }, |
| 7058 | shouldFail: true, |
| 7059 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7060 | }) |
| 7061 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7062 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7063 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7064 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7065 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7066 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7067 | signatureRSAPKCS1WithSHA512, |
| 7068 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7069 | }, |
| 7070 | }, |
| 7071 | flags: []string{ |
| 7072 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7073 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7074 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7075 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7076 | shouldFail: true, |
| 7077 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7078 | }) |
| 7079 | testCases = append(testCases, testCase{ |
| 7080 | name: "NoCommonAlgorithms-TLS13", |
| 7081 | config: Config{ |
| 7082 | MaxVersion: VersionTLS13, |
| 7083 | ClientAuth: RequireAnyClientCert, |
| 7084 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7085 | signatureRSAPSSWithSHA512, |
| 7086 | signatureRSAPSSWithSHA384, |
| 7087 | }, |
| 7088 | }, |
| 7089 | flags: []string{ |
| 7090 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7091 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7092 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7093 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7094 | shouldFail: true, |
| 7095 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7096 | }) |
| 7097 | testCases = append(testCases, testCase{ |
| 7098 | name: "Agree-Digest-SHA256", |
| 7099 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7100 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7101 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7102 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7103 | signatureRSAPKCS1WithSHA1, |
| 7104 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7105 | }, |
| 7106 | }, |
| 7107 | flags: []string{ |
| 7108 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7109 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7110 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7111 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7112 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7113 | }) |
| 7114 | testCases = append(testCases, testCase{ |
| 7115 | name: "Agree-Digest-SHA1", |
| 7116 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7117 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7118 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7119 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7120 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7121 | }, |
| 7122 | }, |
| 7123 | flags: []string{ |
| 7124 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7125 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7126 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7127 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7128 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7129 | }) |
| 7130 | testCases = append(testCases, testCase{ |
| 7131 | name: "Agree-Digest-Default", |
| 7132 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7133 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7134 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7135 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7136 | signatureRSAPKCS1WithSHA256, |
| 7137 | signatureECDSAWithP256AndSHA256, |
| 7138 | signatureRSAPKCS1WithSHA1, |
| 7139 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7140 | }, |
| 7141 | }, |
| 7142 | flags: []string{ |
| 7143 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7144 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7145 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7146 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7147 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7148 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7149 | // Test that the signing preference list may include extra algorithms |
| 7150 | // without negotiation problems. |
| 7151 | testCases = append(testCases, testCase{ |
| 7152 | testType: serverTest, |
| 7153 | name: "FilterExtraAlgorithms", |
| 7154 | config: Config{ |
| 7155 | MaxVersion: VersionTLS12, |
| 7156 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7157 | signatureRSAPKCS1WithSHA256, |
| 7158 | }, |
| 7159 | }, |
| 7160 | flags: []string{ |
| 7161 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7162 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7163 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7164 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7165 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7166 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7167 | }, |
| 7168 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7169 | }) |
| 7170 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7171 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7172 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7173 | testCases = append(testCases, testCase{ |
| 7174 | name: "CheckLeafCurve", |
| 7175 | config: Config{ |
| 7176 | MaxVersion: VersionTLS12, |
| 7177 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7178 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7179 | }, |
| 7180 | flags: []string{"-p384-only"}, |
| 7181 | shouldFail: true, |
| 7182 | expectedError: ":BAD_ECC_CERT:", |
| 7183 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7184 | |
| 7185 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7186 | testCases = append(testCases, testCase{ |
| 7187 | name: "CheckLeafCurve-TLS13", |
| 7188 | config: Config{ |
| 7189 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7190 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7191 | }, |
| 7192 | flags: []string{"-p384-only"}, |
| 7193 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7194 | |
| 7195 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7196 | testCases = append(testCases, testCase{ |
| 7197 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7198 | config: Config{ |
| 7199 | MaxVersion: VersionTLS12, |
| 7200 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7201 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7202 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7203 | signatureECDSAWithP384AndSHA384, |
| 7204 | }, |
| 7205 | }, |
| 7206 | }) |
| 7207 | |
| 7208 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7209 | testCases = append(testCases, testCase{ |
| 7210 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7211 | config: Config{ |
| 7212 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7213 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7214 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7215 | signatureECDSAWithP384AndSHA384, |
| 7216 | }, |
| 7217 | Bugs: ProtocolBugs{ |
| 7218 | SkipECDSACurveCheck: true, |
| 7219 | }, |
| 7220 | }, |
| 7221 | shouldFail: true, |
| 7222 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7223 | }) |
| 7224 | |
| 7225 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7226 | // account. |
| 7227 | testCases = append(testCases, testCase{ |
| 7228 | testType: serverTest, |
| 7229 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7230 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7231 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7232 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7233 | signatureECDSAWithP384AndSHA384, |
| 7234 | signatureECDSAWithP256AndSHA256, |
| 7235 | }, |
| 7236 | }, |
| 7237 | flags: []string{ |
| 7238 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7239 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7240 | }, |
| 7241 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7242 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7243 | |
| 7244 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7245 | // server does not attempt to sign in that case. |
| 7246 | testCases = append(testCases, testCase{ |
| 7247 | testType: serverTest, |
| 7248 | name: "RSA-PSS-Large", |
| 7249 | config: Config{ |
| 7250 | MaxVersion: VersionTLS13, |
| 7251 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7252 | signatureRSAPSSWithSHA512, |
| 7253 | }, |
| 7254 | }, |
| 7255 | flags: []string{ |
| 7256 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7257 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7258 | }, |
| 7259 | shouldFail: true, |
| 7260 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7261 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7262 | |
| 7263 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7264 | testCases = append(testCases, testCase{ |
| 7265 | testType: clientTest, |
| 7266 | name: "RSA-PSS-Default-Verify", |
| 7267 | config: Config{ |
| 7268 | MaxVersion: VersionTLS12, |
| 7269 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7270 | signatureRSAPSSWithSHA256, |
| 7271 | }, |
| 7272 | }, |
| 7273 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7274 | }) |
| 7275 | |
| 7276 | testCases = append(testCases, testCase{ |
| 7277 | testType: serverTest, |
| 7278 | name: "RSA-PSS-Default-Sign", |
| 7279 | config: Config{ |
| 7280 | MaxVersion: VersionTLS12, |
| 7281 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7282 | signatureRSAPSSWithSHA256, |
| 7283 | }, |
| 7284 | }, |
| 7285 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7286 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7287 | } |
| 7288 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7289 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7290 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7291 | var timeouts = []time.Duration{ |
| 7292 | 1 * time.Second, |
| 7293 | 2 * time.Second, |
| 7294 | 4 * time.Second, |
| 7295 | 8 * time.Second, |
| 7296 | 16 * time.Second, |
| 7297 | 32 * time.Second, |
| 7298 | 60 * time.Second, |
| 7299 | 60 * time.Second, |
| 7300 | 60 * time.Second, |
| 7301 | 60 * time.Second, |
| 7302 | 60 * time.Second, |
| 7303 | 60 * time.Second, |
| 7304 | 60 * time.Second, |
| 7305 | } |
| 7306 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7307 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7308 | // initial timeout duration was set to 250ms. |
| 7309 | var shortTimeouts = []time.Duration{ |
| 7310 | 250 * time.Millisecond, |
| 7311 | 500 * time.Millisecond, |
| 7312 | 1 * time.Second, |
| 7313 | 2 * time.Second, |
| 7314 | 4 * time.Second, |
| 7315 | 8 * time.Second, |
| 7316 | 16 * time.Second, |
| 7317 | 32 * time.Second, |
| 7318 | 60 * time.Second, |
| 7319 | 60 * time.Second, |
| 7320 | 60 * time.Second, |
| 7321 | 60 * time.Second, |
| 7322 | 60 * time.Second, |
| 7323 | } |
| 7324 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7325 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7326 | // These tests work by coordinating some behavior on both the shim and |
| 7327 | // the runner. |
| 7328 | // |
| 7329 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7330 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7331 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7332 | // timeout in the shim and acts as a synchronization point to help the |
| 7333 | // runner bracket each handshake flight. |
| 7334 | // |
| 7335 | // We assume the shim does not read from the channel eagerly. It must |
| 7336 | // first wait until it has sent flight N and is ready to receive |
| 7337 | // handshake flight N+1. At this point, it will process the timeout |
| 7338 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7339 | // as if the shim was idle for the specified amount of time. |
| 7340 | // |
| 7341 | // The runner then drops all packets received before the ACK and |
| 7342 | // continues waiting for flight N. This ordering results in one attempt |
| 7343 | // at sending flight N to be dropped. For the test to complete, the |
| 7344 | // shim must send flight N again, testing that the shim implements DTLS |
| 7345 | // retransmit on a timeout. |
| 7346 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7347 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7348 | // likely be more epochs to cross and the final message's retransmit may |
| 7349 | // be more complex. |
| 7350 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7351 | for _, async := range []bool{true, false} { |
| 7352 | var tests []testCase |
| 7353 | |
| 7354 | // Test that this is indeed the timeout schedule. Stress all |
| 7355 | // four patterns of handshake. |
| 7356 | for i := 1; i < len(timeouts); i++ { |
| 7357 | number := strconv.Itoa(i) |
| 7358 | tests = append(tests, testCase{ |
| 7359 | protocol: dtls, |
| 7360 | name: "DTLS-Retransmit-Client-" + number, |
| 7361 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7362 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7363 | Bugs: ProtocolBugs{ |
| 7364 | TimeoutSchedule: timeouts[:i], |
| 7365 | }, |
| 7366 | }, |
| 7367 | resumeSession: true, |
| 7368 | }) |
| 7369 | tests = append(tests, testCase{ |
| 7370 | protocol: dtls, |
| 7371 | testType: serverTest, |
| 7372 | name: "DTLS-Retransmit-Server-" + number, |
| 7373 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7374 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7375 | Bugs: ProtocolBugs{ |
| 7376 | TimeoutSchedule: timeouts[:i], |
| 7377 | }, |
| 7378 | }, |
| 7379 | resumeSession: true, |
| 7380 | }) |
| 7381 | } |
| 7382 | |
| 7383 | // Test that exceeding the timeout schedule hits a read |
| 7384 | // timeout. |
| 7385 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7386 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7387 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7388 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7389 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7390 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7391 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7392 | }, |
| 7393 | }, |
| 7394 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7395 | shouldFail: true, |
| 7396 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7397 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7398 | |
| 7399 | if async { |
| 7400 | // Test that timeout handling has a fudge factor, due to API |
| 7401 | // problems. |
| 7402 | tests = append(tests, testCase{ |
| 7403 | protocol: dtls, |
| 7404 | name: "DTLS-Retransmit-Fudge", |
| 7405 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7406 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7407 | Bugs: ProtocolBugs{ |
| 7408 | TimeoutSchedule: []time.Duration{ |
| 7409 | timeouts[0] - 10*time.Millisecond, |
| 7410 | }, |
| 7411 | }, |
| 7412 | }, |
| 7413 | resumeSession: true, |
| 7414 | }) |
| 7415 | } |
| 7416 | |
| 7417 | // Test that the final Finished retransmitting isn't |
| 7418 | // duplicated if the peer badly fragments everything. |
| 7419 | tests = append(tests, testCase{ |
| 7420 | testType: serverTest, |
| 7421 | protocol: dtls, |
| 7422 | name: "DTLS-Retransmit-Fragmented", |
| 7423 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7424 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7425 | Bugs: ProtocolBugs{ |
| 7426 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7427 | MaxHandshakeRecordLength: 2, |
| 7428 | }, |
| 7429 | }, |
| 7430 | }) |
| 7431 | |
| 7432 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7433 | tests = append(tests, testCase{ |
| 7434 | protocol: dtls, |
| 7435 | name: "DTLS-Retransmit-Short-Client", |
| 7436 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7437 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7438 | Bugs: ProtocolBugs{ |
| 7439 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7440 | }, |
| 7441 | }, |
| 7442 | resumeSession: true, |
| 7443 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 7444 | }) |
| 7445 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7446 | protocol: dtls, |
| 7447 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7448 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7449 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7450 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7451 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7452 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7453 | }, |
| 7454 | }, |
| 7455 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7456 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7457 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7458 | |
| 7459 | for _, test := range tests { |
| 7460 | if async { |
| 7461 | test.name += "-Async" |
| 7462 | test.flags = append(test.flags, "-async") |
| 7463 | } |
| 7464 | |
| 7465 | testCases = append(testCases, test) |
| 7466 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7467 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7468 | } |
| 7469 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7470 | func addExportKeyingMaterialTests() { |
| 7471 | for _, vers := range tlsVersions { |
| 7472 | if vers.version == VersionSSL30 { |
| 7473 | continue |
| 7474 | } |
| 7475 | testCases = append(testCases, testCase{ |
| 7476 | name: "ExportKeyingMaterial-" + vers.name, |
| 7477 | config: Config{ |
| 7478 | MaxVersion: vers.version, |
| 7479 | }, |
| 7480 | exportKeyingMaterial: 1024, |
| 7481 | exportLabel: "label", |
| 7482 | exportContext: "context", |
| 7483 | useExportContext: true, |
| 7484 | }) |
| 7485 | testCases = append(testCases, testCase{ |
| 7486 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7487 | config: Config{ |
| 7488 | MaxVersion: vers.version, |
| 7489 | }, |
| 7490 | exportKeyingMaterial: 1024, |
| 7491 | }) |
| 7492 | testCases = append(testCases, testCase{ |
| 7493 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7494 | config: Config{ |
| 7495 | MaxVersion: vers.version, |
| 7496 | }, |
| 7497 | exportKeyingMaterial: 1024, |
| 7498 | useExportContext: true, |
| 7499 | }) |
| 7500 | testCases = append(testCases, testCase{ |
| 7501 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7502 | config: Config{ |
| 7503 | MaxVersion: vers.version, |
| 7504 | }, |
| 7505 | exportKeyingMaterial: 1, |
| 7506 | exportLabel: "label", |
| 7507 | exportContext: "context", |
| 7508 | useExportContext: true, |
| 7509 | }) |
| 7510 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7511 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7512 | testCases = append(testCases, testCase{ |
| 7513 | name: "ExportKeyingMaterial-SSL3", |
| 7514 | config: Config{ |
| 7515 | MaxVersion: VersionSSL30, |
| 7516 | }, |
| 7517 | exportKeyingMaterial: 1024, |
| 7518 | exportLabel: "label", |
| 7519 | exportContext: "context", |
| 7520 | useExportContext: true, |
| 7521 | shouldFail: true, |
| 7522 | expectedError: "failed to export keying material", |
| 7523 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7524 | |
| 7525 | // Exporters work during a False Start. |
| 7526 | testCases = append(testCases, testCase{ |
| 7527 | name: "ExportKeyingMaterial-FalseStart", |
| 7528 | config: Config{ |
| 7529 | MaxVersion: VersionTLS12, |
| 7530 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7531 | NextProtos: []string{"foo"}, |
| 7532 | Bugs: ProtocolBugs{ |
| 7533 | ExpectFalseStart: true, |
| 7534 | }, |
| 7535 | }, |
| 7536 | flags: []string{ |
| 7537 | "-false-start", |
| 7538 | "-advertise-alpn", "\x03foo", |
| 7539 | }, |
| 7540 | shimWritesFirst: true, |
| 7541 | exportKeyingMaterial: 1024, |
| 7542 | exportLabel: "label", |
| 7543 | exportContext: "context", |
| 7544 | useExportContext: true, |
| 7545 | }) |
| 7546 | |
| 7547 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7548 | // triggering the exporter after every SSL_read call and configuring the |
| 7549 | // shim to run asynchronously. |
| 7550 | testCases = append(testCases, testCase{ |
| 7551 | name: "ExportKeyingMaterial-Renegotiate", |
| 7552 | config: Config{ |
| 7553 | MaxVersion: VersionTLS12, |
| 7554 | }, |
| 7555 | renegotiate: 1, |
| 7556 | flags: []string{ |
| 7557 | "-async", |
| 7558 | "-use-exporter-between-reads", |
| 7559 | "-renegotiate-freely", |
| 7560 | "-expect-total-renegotiations", "1", |
| 7561 | }, |
| 7562 | shouldFail: true, |
| 7563 | expectedError: "failed to export keying material", |
| 7564 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7565 | } |
| 7566 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7567 | func addTLSUniqueTests() { |
| 7568 | for _, isClient := range []bool{false, true} { |
| 7569 | for _, isResumption := range []bool{false, true} { |
| 7570 | for _, hasEMS := range []bool{false, true} { |
| 7571 | var suffix string |
| 7572 | if isResumption { |
| 7573 | suffix = "Resume-" |
| 7574 | } else { |
| 7575 | suffix = "Full-" |
| 7576 | } |
| 7577 | |
| 7578 | if hasEMS { |
| 7579 | suffix += "EMS-" |
| 7580 | } else { |
| 7581 | suffix += "NoEMS-" |
| 7582 | } |
| 7583 | |
| 7584 | if isClient { |
| 7585 | suffix += "Client" |
| 7586 | } else { |
| 7587 | suffix += "Server" |
| 7588 | } |
| 7589 | |
| 7590 | test := testCase{ |
| 7591 | name: "TLSUnique-" + suffix, |
| 7592 | testTLSUnique: true, |
| 7593 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7594 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7595 | Bugs: ProtocolBugs{ |
| 7596 | NoExtendedMasterSecret: !hasEMS, |
| 7597 | }, |
| 7598 | }, |
| 7599 | } |
| 7600 | |
| 7601 | if isResumption { |
| 7602 | test.resumeSession = true |
| 7603 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7604 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7605 | Bugs: ProtocolBugs{ |
| 7606 | NoExtendedMasterSecret: !hasEMS, |
| 7607 | }, |
| 7608 | } |
| 7609 | } |
| 7610 | |
| 7611 | if isResumption && !hasEMS { |
| 7612 | test.shouldFail = true |
| 7613 | test.expectedError = "failed to get tls-unique" |
| 7614 | } |
| 7615 | |
| 7616 | testCases = append(testCases, test) |
| 7617 | } |
| 7618 | } |
| 7619 | } |
| 7620 | } |
| 7621 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7622 | func addCustomExtensionTests() { |
| 7623 | expectedContents := "custom extension" |
| 7624 | emptyString := "" |
| 7625 | |
| 7626 | for _, isClient := range []bool{false, true} { |
| 7627 | suffix := "Server" |
| 7628 | flag := "-enable-server-custom-extension" |
| 7629 | testType := serverTest |
| 7630 | if isClient { |
| 7631 | suffix = "Client" |
| 7632 | flag = "-enable-client-custom-extension" |
| 7633 | testType = clientTest |
| 7634 | } |
| 7635 | |
| 7636 | testCases = append(testCases, testCase{ |
| 7637 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7638 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7639 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7640 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7641 | Bugs: ProtocolBugs{ |
| 7642 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7643 | ExpectedCustomExtension: &expectedContents, |
| 7644 | }, |
| 7645 | }, |
| 7646 | flags: []string{flag}, |
| 7647 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7648 | testCases = append(testCases, testCase{ |
| 7649 | testType: testType, |
| 7650 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7651 | config: Config{ |
| 7652 | MaxVersion: VersionTLS13, |
| 7653 | Bugs: ProtocolBugs{ |
| 7654 | CustomExtension: expectedContents, |
| 7655 | ExpectedCustomExtension: &expectedContents, |
| 7656 | }, |
| 7657 | }, |
| 7658 | flags: []string{flag}, |
| 7659 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7660 | |
| 7661 | // If the parse callback fails, the handshake should also fail. |
| 7662 | testCases = append(testCases, testCase{ |
| 7663 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7664 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7665 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7666 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7667 | Bugs: ProtocolBugs{ |
| 7668 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7669 | ExpectedCustomExtension: &expectedContents, |
| 7670 | }, |
| 7671 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7672 | flags: []string{flag}, |
| 7673 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7674 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7675 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7676 | testCases = append(testCases, testCase{ |
| 7677 | testType: testType, |
| 7678 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7679 | config: Config{ |
| 7680 | MaxVersion: VersionTLS13, |
| 7681 | Bugs: ProtocolBugs{ |
| 7682 | CustomExtension: expectedContents + "foo", |
| 7683 | ExpectedCustomExtension: &expectedContents, |
| 7684 | }, |
| 7685 | }, |
| 7686 | flags: []string{flag}, |
| 7687 | shouldFail: true, |
| 7688 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7689 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7690 | |
| 7691 | // If the add callback fails, the handshake should also fail. |
| 7692 | testCases = append(testCases, testCase{ |
| 7693 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7694 | name: "CustomExtensions-FailAdd-" + suffix, |
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{ |
| 7698 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7699 | ExpectedCustomExtension: &expectedContents, |
| 7700 | }, |
| 7701 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7702 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7703 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7704 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7705 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7706 | testCases = append(testCases, testCase{ |
| 7707 | testType: testType, |
| 7708 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7709 | config: Config{ |
| 7710 | MaxVersion: VersionTLS13, |
| 7711 | Bugs: ProtocolBugs{ |
| 7712 | CustomExtension: expectedContents, |
| 7713 | ExpectedCustomExtension: &expectedContents, |
| 7714 | }, |
| 7715 | }, |
| 7716 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7717 | shouldFail: true, |
| 7718 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7719 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7720 | |
| 7721 | // If the add callback returns zero, no extension should be |
| 7722 | // added. |
| 7723 | skipCustomExtension := expectedContents |
| 7724 | if isClient { |
| 7725 | // For the case where the client skips sending the |
| 7726 | // custom extension, the server must not “echo” it. |
| 7727 | skipCustomExtension = "" |
| 7728 | } |
| 7729 | testCases = append(testCases, testCase{ |
| 7730 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7731 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7732 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7733 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7734 | Bugs: ProtocolBugs{ |
| 7735 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7736 | ExpectedCustomExtension: &emptyString, |
| 7737 | }, |
| 7738 | }, |
| 7739 | flags: []string{flag, "-custom-extension-skip"}, |
| 7740 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7741 | testCases = append(testCases, testCase{ |
| 7742 | testType: testType, |
| 7743 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7744 | config: Config{ |
| 7745 | MaxVersion: VersionTLS13, |
| 7746 | Bugs: ProtocolBugs{ |
| 7747 | CustomExtension: skipCustomExtension, |
| 7748 | ExpectedCustomExtension: &emptyString, |
| 7749 | }, |
| 7750 | }, |
| 7751 | flags: []string{flag, "-custom-extension-skip"}, |
| 7752 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7753 | } |
| 7754 | |
| 7755 | // The custom extension add callback should not be called if the client |
| 7756 | // doesn't send the extension. |
| 7757 | testCases = append(testCases, testCase{ |
| 7758 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7759 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7760 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7761 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7762 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7763 | ExpectedCustomExtension: &emptyString, |
| 7764 | }, |
| 7765 | }, |
| 7766 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7767 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7768 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7769 | testCases = append(testCases, testCase{ |
| 7770 | testType: serverTest, |
| 7771 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7772 | config: Config{ |
| 7773 | MaxVersion: VersionTLS13, |
| 7774 | Bugs: ProtocolBugs{ |
| 7775 | ExpectedCustomExtension: &emptyString, |
| 7776 | }, |
| 7777 | }, |
| 7778 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7779 | }) |
| 7780 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7781 | // Test an unknown extension from the server. |
| 7782 | testCases = append(testCases, testCase{ |
| 7783 | testType: clientTest, |
| 7784 | name: "UnknownExtension-Client", |
| 7785 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7786 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7787 | Bugs: ProtocolBugs{ |
| 7788 | CustomExtension: expectedContents, |
| 7789 | }, |
| 7790 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7791 | shouldFail: true, |
| 7792 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7793 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7794 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7795 | testCases = append(testCases, testCase{ |
| 7796 | testType: clientTest, |
| 7797 | name: "UnknownExtension-Client-TLS13", |
| 7798 | config: Config{ |
| 7799 | MaxVersion: VersionTLS13, |
| 7800 | Bugs: ProtocolBugs{ |
| 7801 | CustomExtension: expectedContents, |
| 7802 | }, |
| 7803 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7804 | shouldFail: true, |
| 7805 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7806 | expectedLocalError: "remote error: unsupported extension", |
| 7807 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7808 | testCases = append(testCases, testCase{ |
| 7809 | testType: clientTest, |
| 7810 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7811 | config: Config{ |
| 7812 | MaxVersion: VersionTLS13, |
| 7813 | Bugs: ProtocolBugs{ |
| 7814 | CustomUnencryptedExtension: expectedContents, |
| 7815 | }, |
| 7816 | }, |
| 7817 | shouldFail: true, |
| 7818 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7819 | // The shim must send an alert, but alerts at this point do not |
| 7820 | // get successfully decrypted by the runner. |
| 7821 | expectedLocalError: "local error: bad record MAC", |
| 7822 | }) |
| 7823 | testCases = append(testCases, testCase{ |
| 7824 | testType: clientTest, |
| 7825 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7826 | config: Config{ |
| 7827 | MaxVersion: VersionTLS13, |
| 7828 | Bugs: ProtocolBugs{ |
| 7829 | SendUnencryptedALPN: "foo", |
| 7830 | }, |
| 7831 | }, |
| 7832 | flags: []string{ |
| 7833 | "-advertise-alpn", "\x03foo\x03bar", |
| 7834 | }, |
| 7835 | shouldFail: true, |
| 7836 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7837 | // The shim must send an alert, but alerts at this point do not |
| 7838 | // get successfully decrypted by the runner. |
| 7839 | expectedLocalError: "local error: bad record MAC", |
| 7840 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7841 | |
| 7842 | // Test a known but unoffered extension from the server. |
| 7843 | testCases = append(testCases, testCase{ |
| 7844 | testType: clientTest, |
| 7845 | name: "UnofferedExtension-Client", |
| 7846 | config: Config{ |
| 7847 | MaxVersion: VersionTLS12, |
| 7848 | Bugs: ProtocolBugs{ |
| 7849 | SendALPN: "alpn", |
| 7850 | }, |
| 7851 | }, |
| 7852 | shouldFail: true, |
| 7853 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7854 | expectedLocalError: "remote error: unsupported extension", |
| 7855 | }) |
| 7856 | testCases = append(testCases, testCase{ |
| 7857 | testType: clientTest, |
| 7858 | name: "UnofferedExtension-Client-TLS13", |
| 7859 | config: Config{ |
| 7860 | MaxVersion: VersionTLS13, |
| 7861 | Bugs: ProtocolBugs{ |
| 7862 | SendALPN: "alpn", |
| 7863 | }, |
| 7864 | }, |
| 7865 | shouldFail: true, |
| 7866 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7867 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7868 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7869 | } |
| 7870 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7871 | func addRSAClientKeyExchangeTests() { |
| 7872 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7873 | testCases = append(testCases, testCase{ |
| 7874 | testType: serverTest, |
| 7875 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7876 | config: Config{ |
| 7877 | // Ensure the ClientHello version and final |
| 7878 | // version are different, to detect if the |
| 7879 | // server uses the wrong one. |
| 7880 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7881 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7882 | Bugs: ProtocolBugs{ |
| 7883 | BadRSAClientKeyExchange: bad, |
| 7884 | }, |
| 7885 | }, |
| 7886 | shouldFail: true, |
| 7887 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7888 | }) |
| 7889 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7890 | |
| 7891 | // The server must compare whatever was in ClientHello.version for the |
| 7892 | // RSA premaster. |
| 7893 | testCases = append(testCases, testCase{ |
| 7894 | testType: serverTest, |
| 7895 | name: "SendClientVersion-RSA", |
| 7896 | config: Config{ |
| 7897 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7898 | Bugs: ProtocolBugs{ |
| 7899 | SendClientVersion: 0x1234, |
| 7900 | }, |
| 7901 | }, |
| 7902 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7903 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7904 | } |
| 7905 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7906 | var testCurves = []struct { |
| 7907 | name string |
| 7908 | id CurveID |
| 7909 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7910 | {"P-256", CurveP256}, |
| 7911 | {"P-384", CurveP384}, |
| 7912 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7913 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7914 | } |
| 7915 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7916 | const bogusCurve = 0x1234 |
| 7917 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7918 | func addCurveTests() { |
| 7919 | for _, curve := range testCurves { |
| 7920 | testCases = append(testCases, testCase{ |
| 7921 | name: "CurveTest-Client-" + curve.name, |
| 7922 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7923 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7924 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7925 | CurvePreferences: []CurveID{curve.id}, |
| 7926 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7927 | flags: []string{ |
| 7928 | "-enable-all-curves", |
| 7929 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7930 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7931 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7932 | }) |
| 7933 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7934 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7935 | config: Config{ |
| 7936 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7937 | CurvePreferences: []CurveID{curve.id}, |
| 7938 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7939 | flags: []string{ |
| 7940 | "-enable-all-curves", |
| 7941 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7942 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7943 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7944 | }) |
| 7945 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7946 | testType: serverTest, |
| 7947 | name: "CurveTest-Server-" + curve.name, |
| 7948 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7949 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7950 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7951 | CurvePreferences: []CurveID{curve.id}, |
| 7952 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7953 | flags: []string{ |
| 7954 | "-enable-all-curves", |
| 7955 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7956 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7957 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7958 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7959 | testCases = append(testCases, testCase{ |
| 7960 | testType: serverTest, |
| 7961 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7962 | config: Config{ |
| 7963 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7964 | CurvePreferences: []CurveID{curve.id}, |
| 7965 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7966 | flags: []string{ |
| 7967 | "-enable-all-curves", |
| 7968 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7969 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7970 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7971 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7972 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7973 | |
| 7974 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7975 | testCases = append(testCases, testCase{ |
| 7976 | testType: serverTest, |
| 7977 | name: "UnknownCurve", |
| 7978 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7979 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7980 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7981 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7982 | }, |
| 7983 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7984 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7985 | // The server must be tolerant to bogus curves. |
| 7986 | testCases = append(testCases, testCase{ |
| 7987 | testType: serverTest, |
| 7988 | name: "UnknownCurve-TLS13", |
| 7989 | config: Config{ |
| 7990 | MaxVersion: VersionTLS13, |
| 7991 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7992 | }, |
| 7993 | }) |
| 7994 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7995 | // The server must not consider ECDHE ciphers when there are no |
| 7996 | // supported curves. |
| 7997 | testCases = append(testCases, testCase{ |
| 7998 | testType: serverTest, |
| 7999 | name: "NoSupportedCurves", |
| 8000 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8001 | MaxVersion: VersionTLS12, |
| 8002 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8003 | Bugs: ProtocolBugs{ |
| 8004 | NoSupportedCurves: true, |
| 8005 | }, |
| 8006 | }, |
| 8007 | shouldFail: true, |
| 8008 | expectedError: ":NO_SHARED_CIPHER:", |
| 8009 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8010 | testCases = append(testCases, testCase{ |
| 8011 | testType: serverTest, |
| 8012 | name: "NoSupportedCurves-TLS13", |
| 8013 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8014 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8015 | Bugs: ProtocolBugs{ |
| 8016 | NoSupportedCurves: true, |
| 8017 | }, |
| 8018 | }, |
| 8019 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8020 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8021 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8022 | |
| 8023 | // The server must fall back to another cipher when there are no |
| 8024 | // supported curves. |
| 8025 | testCases = append(testCases, testCase{ |
| 8026 | testType: serverTest, |
| 8027 | name: "NoCommonCurves", |
| 8028 | config: Config{ |
| 8029 | MaxVersion: VersionTLS12, |
| 8030 | CipherSuites: []uint16{ |
| 8031 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8032 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8033 | }, |
| 8034 | CurvePreferences: []CurveID{CurveP224}, |
| 8035 | }, |
| 8036 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 8037 | }) |
| 8038 | |
| 8039 | // The client must reject bogus curves and disabled curves. |
| 8040 | testCases = append(testCases, testCase{ |
| 8041 | name: "BadECDHECurve", |
| 8042 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8043 | MaxVersion: VersionTLS12, |
| 8044 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8045 | Bugs: ProtocolBugs{ |
| 8046 | SendCurve: bogusCurve, |
| 8047 | }, |
| 8048 | }, |
| 8049 | shouldFail: true, |
| 8050 | expectedError: ":WRONG_CURVE:", |
| 8051 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8052 | testCases = append(testCases, testCase{ |
| 8053 | name: "BadECDHECurve-TLS13", |
| 8054 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8055 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8056 | Bugs: ProtocolBugs{ |
| 8057 | SendCurve: bogusCurve, |
| 8058 | }, |
| 8059 | }, |
| 8060 | shouldFail: true, |
| 8061 | expectedError: ":WRONG_CURVE:", |
| 8062 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8063 | |
| 8064 | testCases = append(testCases, testCase{ |
| 8065 | name: "UnsupportedCurve", |
| 8066 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8067 | MaxVersion: VersionTLS12, |
| 8068 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8069 | CurvePreferences: []CurveID{CurveP256}, |
| 8070 | Bugs: ProtocolBugs{ |
| 8071 | IgnorePeerCurvePreferences: true, |
| 8072 | }, |
| 8073 | }, |
| 8074 | flags: []string{"-p384-only"}, |
| 8075 | shouldFail: true, |
| 8076 | expectedError: ":WRONG_CURVE:", |
| 8077 | }) |
| 8078 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8079 | testCases = append(testCases, testCase{ |
| 8080 | // TODO(davidben): Add a TLS 1.3 version where |
| 8081 | // HelloRetryRequest requests an unsupported curve. |
| 8082 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8083 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8084 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8085 | CurvePreferences: []CurveID{CurveP384}, |
| 8086 | Bugs: ProtocolBugs{ |
| 8087 | SendCurve: CurveP256, |
| 8088 | }, |
| 8089 | }, |
| 8090 | flags: []string{"-p384-only"}, |
| 8091 | shouldFail: true, |
| 8092 | expectedError: ":WRONG_CURVE:", |
| 8093 | }) |
| 8094 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8095 | // Test invalid curve points. |
| 8096 | testCases = append(testCases, testCase{ |
| 8097 | name: "InvalidECDHPoint-Client", |
| 8098 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8099 | MaxVersion: VersionTLS12, |
| 8100 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8101 | CurvePreferences: []CurveID{CurveP256}, |
| 8102 | Bugs: ProtocolBugs{ |
| 8103 | InvalidECDHPoint: true, |
| 8104 | }, |
| 8105 | }, |
| 8106 | shouldFail: true, |
| 8107 | expectedError: ":INVALID_ENCODING:", |
| 8108 | }) |
| 8109 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8110 | name: "InvalidECDHPoint-Client-TLS13", |
| 8111 | config: Config{ |
| 8112 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8113 | CurvePreferences: []CurveID{CurveP256}, |
| 8114 | Bugs: ProtocolBugs{ |
| 8115 | InvalidECDHPoint: true, |
| 8116 | }, |
| 8117 | }, |
| 8118 | shouldFail: true, |
| 8119 | expectedError: ":INVALID_ENCODING:", |
| 8120 | }) |
| 8121 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8122 | testType: serverTest, |
| 8123 | name: "InvalidECDHPoint-Server", |
| 8124 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8125 | MaxVersion: VersionTLS12, |
| 8126 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8127 | CurvePreferences: []CurveID{CurveP256}, |
| 8128 | Bugs: ProtocolBugs{ |
| 8129 | InvalidECDHPoint: true, |
| 8130 | }, |
| 8131 | }, |
| 8132 | shouldFail: true, |
| 8133 | expectedError: ":INVALID_ENCODING:", |
| 8134 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8135 | testCases = append(testCases, testCase{ |
| 8136 | testType: serverTest, |
| 8137 | name: "InvalidECDHPoint-Server-TLS13", |
| 8138 | config: Config{ |
| 8139 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8140 | CurvePreferences: []CurveID{CurveP256}, |
| 8141 | Bugs: ProtocolBugs{ |
| 8142 | InvalidECDHPoint: true, |
| 8143 | }, |
| 8144 | }, |
| 8145 | shouldFail: true, |
| 8146 | expectedError: ":INVALID_ENCODING:", |
| 8147 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8148 | } |
| 8149 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8150 | func addCECPQ1Tests() { |
| 8151 | testCases = append(testCases, testCase{ |
| 8152 | testType: clientTest, |
| 8153 | name: "CECPQ1-Client-BadX25519Part", |
| 8154 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8155 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8156 | MinVersion: VersionTLS12, |
| 8157 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8158 | Bugs: ProtocolBugs{ |
| 8159 | CECPQ1BadX25519Part: true, |
| 8160 | }, |
| 8161 | }, |
| 8162 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8163 | shouldFail: true, |
| 8164 | expectedLocalError: "local error: bad record MAC", |
| 8165 | }) |
| 8166 | testCases = append(testCases, testCase{ |
| 8167 | testType: clientTest, |
| 8168 | name: "CECPQ1-Client-BadNewhopePart", |
| 8169 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8170 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8171 | MinVersion: VersionTLS12, |
| 8172 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8173 | Bugs: ProtocolBugs{ |
| 8174 | CECPQ1BadNewhopePart: true, |
| 8175 | }, |
| 8176 | }, |
| 8177 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8178 | shouldFail: true, |
| 8179 | expectedLocalError: "local error: bad record MAC", |
| 8180 | }) |
| 8181 | testCases = append(testCases, testCase{ |
| 8182 | testType: serverTest, |
| 8183 | name: "CECPQ1-Server-BadX25519Part", |
| 8184 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8185 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8186 | MinVersion: VersionTLS12, |
| 8187 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8188 | Bugs: ProtocolBugs{ |
| 8189 | CECPQ1BadX25519Part: true, |
| 8190 | }, |
| 8191 | }, |
| 8192 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8193 | shouldFail: true, |
| 8194 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8195 | }) |
| 8196 | testCases = append(testCases, testCase{ |
| 8197 | testType: serverTest, |
| 8198 | name: "CECPQ1-Server-BadNewhopePart", |
| 8199 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8200 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8201 | MinVersion: VersionTLS12, |
| 8202 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8203 | Bugs: ProtocolBugs{ |
| 8204 | CECPQ1BadNewhopePart: true, |
| 8205 | }, |
| 8206 | }, |
| 8207 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8208 | shouldFail: true, |
| 8209 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8210 | }) |
| 8211 | } |
| 8212 | |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8213 | func addDHEGroupSizeTests() { |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8214 | testCases = append(testCases, testCase{ |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8215 | name: "DHEGroupSize-Client", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8216 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8217 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8218 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8219 | Bugs: ProtocolBugs{ |
| 8220 | // This is a 1234-bit prime number, generated |
| 8221 | // with: |
| 8222 | // openssl gendh 1234 | openssl asn1parse -i |
| 8223 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 8224 | }, |
| 8225 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 8226 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8227 | }) |
| 8228 | testCases = append(testCases, testCase{ |
| 8229 | testType: serverTest, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8230 | name: "DHEGroupSize-Server", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8231 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8232 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8233 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8234 | }, |
| 8235 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 8236 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8237 | }) |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -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 | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8382 | } |
| 8383 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8384 | func addChangeCipherSpecTests() { |
| 8385 | // Test missing ChangeCipherSpecs. |
| 8386 | testCases = append(testCases, testCase{ |
| 8387 | name: "SkipChangeCipherSpec-Client", |
| 8388 | config: Config{ |
| 8389 | MaxVersion: VersionTLS12, |
| 8390 | Bugs: ProtocolBugs{ |
| 8391 | SkipChangeCipherSpec: true, |
| 8392 | }, |
| 8393 | }, |
| 8394 | shouldFail: true, |
| 8395 | expectedError: ":UNEXPECTED_RECORD:", |
| 8396 | }) |
| 8397 | testCases = append(testCases, testCase{ |
| 8398 | testType: serverTest, |
| 8399 | name: "SkipChangeCipherSpec-Server", |
| 8400 | config: Config{ |
| 8401 | MaxVersion: VersionTLS12, |
| 8402 | Bugs: ProtocolBugs{ |
| 8403 | SkipChangeCipherSpec: true, |
| 8404 | }, |
| 8405 | }, |
| 8406 | shouldFail: true, |
| 8407 | expectedError: ":UNEXPECTED_RECORD:", |
| 8408 | }) |
| 8409 | testCases = append(testCases, testCase{ |
| 8410 | testType: serverTest, |
| 8411 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8412 | config: Config{ |
| 8413 | MaxVersion: VersionTLS12, |
| 8414 | NextProtos: []string{"bar"}, |
| 8415 | Bugs: ProtocolBugs{ |
| 8416 | SkipChangeCipherSpec: true, |
| 8417 | }, |
| 8418 | }, |
| 8419 | flags: []string{ |
| 8420 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8421 | }, |
| 8422 | shouldFail: true, |
| 8423 | expectedError: ":UNEXPECTED_RECORD:", |
| 8424 | }) |
| 8425 | |
| 8426 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8427 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8428 | // rejected. Test both with and without handshake packing to handle both |
| 8429 | // when the partial post-CCS message is in its own record and when it is |
| 8430 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8431 | for _, packed := range []bool{false, true} { |
| 8432 | var suffix string |
| 8433 | if packed { |
| 8434 | suffix = "-Packed" |
| 8435 | } |
| 8436 | |
| 8437 | testCases = append(testCases, testCase{ |
| 8438 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8439 | config: Config{ |
| 8440 | MaxVersion: VersionTLS12, |
| 8441 | Bugs: ProtocolBugs{ |
| 8442 | FragmentAcrossChangeCipherSpec: true, |
| 8443 | PackHandshakeFlight: packed, |
| 8444 | }, |
| 8445 | }, |
| 8446 | shouldFail: true, |
| 8447 | expectedError: ":UNEXPECTED_RECORD:", |
| 8448 | }) |
| 8449 | testCases = append(testCases, testCase{ |
| 8450 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8451 | config: Config{ |
| 8452 | MaxVersion: VersionTLS12, |
| 8453 | }, |
| 8454 | resumeSession: true, |
| 8455 | resumeConfig: &Config{ |
| 8456 | MaxVersion: VersionTLS12, |
| 8457 | Bugs: ProtocolBugs{ |
| 8458 | FragmentAcrossChangeCipherSpec: true, |
| 8459 | PackHandshakeFlight: packed, |
| 8460 | }, |
| 8461 | }, |
| 8462 | shouldFail: true, |
| 8463 | expectedError: ":UNEXPECTED_RECORD:", |
| 8464 | }) |
| 8465 | testCases = append(testCases, testCase{ |
| 8466 | testType: serverTest, |
| 8467 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8468 | config: Config{ |
| 8469 | MaxVersion: VersionTLS12, |
| 8470 | Bugs: ProtocolBugs{ |
| 8471 | FragmentAcrossChangeCipherSpec: true, |
| 8472 | PackHandshakeFlight: packed, |
| 8473 | }, |
| 8474 | }, |
| 8475 | shouldFail: true, |
| 8476 | expectedError: ":UNEXPECTED_RECORD:", |
| 8477 | }) |
| 8478 | testCases = append(testCases, testCase{ |
| 8479 | testType: serverTest, |
| 8480 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8481 | config: Config{ |
| 8482 | MaxVersion: VersionTLS12, |
| 8483 | }, |
| 8484 | resumeSession: true, |
| 8485 | resumeConfig: &Config{ |
| 8486 | MaxVersion: VersionTLS12, |
| 8487 | Bugs: ProtocolBugs{ |
| 8488 | FragmentAcrossChangeCipherSpec: true, |
| 8489 | PackHandshakeFlight: packed, |
| 8490 | }, |
| 8491 | }, |
| 8492 | shouldFail: true, |
| 8493 | expectedError: ":UNEXPECTED_RECORD:", |
| 8494 | }) |
| 8495 | testCases = append(testCases, testCase{ |
| 8496 | testType: serverTest, |
| 8497 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8498 | config: Config{ |
| 8499 | MaxVersion: VersionTLS12, |
| 8500 | NextProtos: []string{"bar"}, |
| 8501 | Bugs: ProtocolBugs{ |
| 8502 | FragmentAcrossChangeCipherSpec: true, |
| 8503 | PackHandshakeFlight: packed, |
| 8504 | }, |
| 8505 | }, |
| 8506 | flags: []string{ |
| 8507 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8508 | }, |
| 8509 | shouldFail: true, |
| 8510 | expectedError: ":UNEXPECTED_RECORD:", |
| 8511 | }) |
| 8512 | } |
| 8513 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8514 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8515 | // messages in the handshake queue. Do this by testing the server |
| 8516 | // reading the client Finished, reversing the flight so Finished comes |
| 8517 | // first. |
| 8518 | testCases = append(testCases, testCase{ |
| 8519 | protocol: dtls, |
| 8520 | testType: serverTest, |
| 8521 | name: "SendUnencryptedFinished-DTLS", |
| 8522 | config: Config{ |
| 8523 | MaxVersion: VersionTLS12, |
| 8524 | Bugs: ProtocolBugs{ |
| 8525 | SendUnencryptedFinished: true, |
| 8526 | ReverseHandshakeFragments: true, |
| 8527 | }, |
| 8528 | }, |
| 8529 | shouldFail: true, |
| 8530 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8531 | }) |
| 8532 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8533 | // Test synchronization between encryption changes and the handshake in |
| 8534 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8535 | testCases = append(testCases, testCase{ |
| 8536 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8537 | config: Config{ |
| 8538 | MaxVersion: VersionTLS13, |
| 8539 | Bugs: ProtocolBugs{ |
| 8540 | PartialEncryptedExtensionsWithServerHello: true, |
| 8541 | }, |
| 8542 | }, |
| 8543 | shouldFail: true, |
| 8544 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8545 | }) |
| 8546 | testCases = append(testCases, testCase{ |
| 8547 | testType: serverTest, |
| 8548 | name: "PartialClientFinishedWithClientHello", |
| 8549 | config: Config{ |
| 8550 | MaxVersion: VersionTLS13, |
| 8551 | Bugs: ProtocolBugs{ |
| 8552 | PartialClientFinishedWithClientHello: true, |
| 8553 | }, |
| 8554 | }, |
| 8555 | shouldFail: true, |
| 8556 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8557 | }) |
| 8558 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8559 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8560 | testCases = append(testCases, testCase{ |
| 8561 | testType: serverTest, |
| 8562 | name: "EarlyChangeCipherSpec-server-1", |
| 8563 | config: Config{ |
| 8564 | MaxVersion: VersionTLS12, |
| 8565 | Bugs: ProtocolBugs{ |
| 8566 | EarlyChangeCipherSpec: 1, |
| 8567 | }, |
| 8568 | }, |
| 8569 | shouldFail: true, |
| 8570 | expectedError: ":UNEXPECTED_RECORD:", |
| 8571 | }) |
| 8572 | testCases = append(testCases, testCase{ |
| 8573 | testType: serverTest, |
| 8574 | name: "EarlyChangeCipherSpec-server-2", |
| 8575 | config: Config{ |
| 8576 | MaxVersion: VersionTLS12, |
| 8577 | Bugs: ProtocolBugs{ |
| 8578 | EarlyChangeCipherSpec: 2, |
| 8579 | }, |
| 8580 | }, |
| 8581 | shouldFail: true, |
| 8582 | expectedError: ":UNEXPECTED_RECORD:", |
| 8583 | }) |
| 8584 | testCases = append(testCases, testCase{ |
| 8585 | protocol: dtls, |
| 8586 | name: "StrayChangeCipherSpec", |
| 8587 | config: Config{ |
| 8588 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8589 | // that stray ChangeCipherSpec messages are |
| 8590 | // rejected. |
| 8591 | MaxVersion: VersionTLS12, |
| 8592 | Bugs: ProtocolBugs{ |
| 8593 | StrayChangeCipherSpec: true, |
| 8594 | }, |
| 8595 | }, |
| 8596 | }) |
| 8597 | |
| 8598 | // Test that the contents of ChangeCipherSpec are checked. |
| 8599 | testCases = append(testCases, testCase{ |
| 8600 | name: "BadChangeCipherSpec-1", |
| 8601 | config: Config{ |
| 8602 | MaxVersion: VersionTLS12, |
| 8603 | Bugs: ProtocolBugs{ |
| 8604 | BadChangeCipherSpec: []byte{2}, |
| 8605 | }, |
| 8606 | }, |
| 8607 | shouldFail: true, |
| 8608 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8609 | }) |
| 8610 | testCases = append(testCases, testCase{ |
| 8611 | name: "BadChangeCipherSpec-2", |
| 8612 | config: Config{ |
| 8613 | MaxVersion: VersionTLS12, |
| 8614 | Bugs: ProtocolBugs{ |
| 8615 | BadChangeCipherSpec: []byte{1, 1}, |
| 8616 | }, |
| 8617 | }, |
| 8618 | shouldFail: true, |
| 8619 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8620 | }) |
| 8621 | testCases = append(testCases, testCase{ |
| 8622 | protocol: dtls, |
| 8623 | name: "BadChangeCipherSpec-DTLS-1", |
| 8624 | config: Config{ |
| 8625 | MaxVersion: VersionTLS12, |
| 8626 | Bugs: ProtocolBugs{ |
| 8627 | BadChangeCipherSpec: []byte{2}, |
| 8628 | }, |
| 8629 | }, |
| 8630 | shouldFail: true, |
| 8631 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8632 | }) |
| 8633 | testCases = append(testCases, testCase{ |
| 8634 | protocol: dtls, |
| 8635 | name: "BadChangeCipherSpec-DTLS-2", |
| 8636 | config: Config{ |
| 8637 | MaxVersion: VersionTLS12, |
| 8638 | Bugs: ProtocolBugs{ |
| 8639 | BadChangeCipherSpec: []byte{1, 1}, |
| 8640 | }, |
| 8641 | }, |
| 8642 | shouldFail: true, |
| 8643 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8644 | }) |
| 8645 | } |
| 8646 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8647 | type perMessageTest struct { |
| 8648 | messageType uint8 |
| 8649 | test testCase |
| 8650 | } |
| 8651 | |
| 8652 | // makePerMessageTests returns a series of test templates which cover each |
| 8653 | // message in the TLS handshake. These may be used with bugs like |
| 8654 | // WrongMessageType to fully test a per-message bug. |
| 8655 | func makePerMessageTests() []perMessageTest { |
| 8656 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8657 | for _, protocol := range []protocol{tls, dtls} { |
| 8658 | var suffix string |
| 8659 | if protocol == dtls { |
| 8660 | suffix = "-DTLS" |
| 8661 | } |
| 8662 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8663 | ret = append(ret, perMessageTest{ |
| 8664 | messageType: typeClientHello, |
| 8665 | test: testCase{ |
| 8666 | protocol: protocol, |
| 8667 | testType: serverTest, |
| 8668 | name: "ClientHello" + suffix, |
| 8669 | config: Config{ |
| 8670 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8671 | }, |
| 8672 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8673 | }) |
| 8674 | |
| 8675 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8676 | ret = append(ret, perMessageTest{ |
| 8677 | messageType: typeHelloVerifyRequest, |
| 8678 | test: testCase{ |
| 8679 | protocol: protocol, |
| 8680 | name: "HelloVerifyRequest" + suffix, |
| 8681 | config: Config{ |
| 8682 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8683 | }, |
| 8684 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8685 | }) |
| 8686 | } |
| 8687 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8688 | ret = append(ret, perMessageTest{ |
| 8689 | messageType: typeServerHello, |
| 8690 | test: testCase{ |
| 8691 | protocol: protocol, |
| 8692 | name: "ServerHello" + suffix, |
| 8693 | config: Config{ |
| 8694 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8695 | }, |
| 8696 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8697 | }) |
| 8698 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8699 | ret = append(ret, perMessageTest{ |
| 8700 | messageType: typeCertificate, |
| 8701 | test: testCase{ |
| 8702 | protocol: protocol, |
| 8703 | name: "ServerCertificate" + suffix, |
| 8704 | config: Config{ |
| 8705 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8706 | }, |
| 8707 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8708 | }) |
| 8709 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8710 | ret = append(ret, perMessageTest{ |
| 8711 | messageType: typeCertificateStatus, |
| 8712 | test: testCase{ |
| 8713 | protocol: protocol, |
| 8714 | name: "CertificateStatus" + suffix, |
| 8715 | config: Config{ |
| 8716 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8717 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8718 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8719 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8720 | }) |
| 8721 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8722 | ret = append(ret, perMessageTest{ |
| 8723 | messageType: typeServerKeyExchange, |
| 8724 | test: testCase{ |
| 8725 | protocol: protocol, |
| 8726 | name: "ServerKeyExchange" + suffix, |
| 8727 | config: Config{ |
| 8728 | MaxVersion: VersionTLS12, |
| 8729 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8730 | }, |
| 8731 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8732 | }) |
| 8733 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8734 | ret = append(ret, perMessageTest{ |
| 8735 | messageType: typeCertificateRequest, |
| 8736 | test: testCase{ |
| 8737 | protocol: protocol, |
| 8738 | name: "CertificateRequest" + suffix, |
| 8739 | config: Config{ |
| 8740 | MaxVersion: VersionTLS12, |
| 8741 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8742 | }, |
| 8743 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8744 | }) |
| 8745 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8746 | ret = append(ret, perMessageTest{ |
| 8747 | messageType: typeServerHelloDone, |
| 8748 | test: testCase{ |
| 8749 | protocol: protocol, |
| 8750 | name: "ServerHelloDone" + suffix, |
| 8751 | config: Config{ |
| 8752 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8753 | }, |
| 8754 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8755 | }) |
| 8756 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8757 | ret = append(ret, perMessageTest{ |
| 8758 | messageType: typeCertificate, |
| 8759 | test: testCase{ |
| 8760 | testType: serverTest, |
| 8761 | protocol: protocol, |
| 8762 | name: "ClientCertificate" + suffix, |
| 8763 | config: Config{ |
| 8764 | Certificates: []Certificate{rsaCertificate}, |
| 8765 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8766 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8767 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8768 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8769 | }) |
| 8770 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8771 | ret = append(ret, perMessageTest{ |
| 8772 | messageType: typeCertificateVerify, |
| 8773 | test: testCase{ |
| 8774 | testType: serverTest, |
| 8775 | protocol: protocol, |
| 8776 | name: "CertificateVerify" + suffix, |
| 8777 | config: Config{ |
| 8778 | Certificates: []Certificate{rsaCertificate}, |
| 8779 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8780 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8781 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8782 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8783 | }) |
| 8784 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8785 | ret = append(ret, perMessageTest{ |
| 8786 | messageType: typeClientKeyExchange, |
| 8787 | test: testCase{ |
| 8788 | testType: serverTest, |
| 8789 | protocol: protocol, |
| 8790 | name: "ClientKeyExchange" + suffix, |
| 8791 | config: Config{ |
| 8792 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8793 | }, |
| 8794 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8795 | }) |
| 8796 | |
| 8797 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8798 | ret = append(ret, perMessageTest{ |
| 8799 | messageType: typeNextProtocol, |
| 8800 | test: testCase{ |
| 8801 | testType: serverTest, |
| 8802 | protocol: protocol, |
| 8803 | name: "NextProtocol" + suffix, |
| 8804 | config: Config{ |
| 8805 | MaxVersion: VersionTLS12, |
| 8806 | NextProtos: []string{"bar"}, |
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{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
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: typeChannelID, |
| 8814 | test: testCase{ |
| 8815 | testType: serverTest, |
| 8816 | protocol: protocol, |
| 8817 | name: "ChannelID" + suffix, |
| 8818 | config: Config{ |
| 8819 | MaxVersion: VersionTLS12, |
| 8820 | ChannelID: channelIDKey, |
| 8821 | }, |
| 8822 | flags: []string{ |
| 8823 | "-expect-channel-id", |
| 8824 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8825 | }, |
| 8826 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8827 | }) |
| 8828 | } |
| 8829 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8830 | ret = append(ret, perMessageTest{ |
| 8831 | messageType: typeFinished, |
| 8832 | test: testCase{ |
| 8833 | testType: serverTest, |
| 8834 | protocol: protocol, |
| 8835 | name: "ClientFinished" + suffix, |
| 8836 | config: Config{ |
| 8837 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8838 | }, |
| 8839 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8840 | }) |
| 8841 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8842 | ret = append(ret, perMessageTest{ |
| 8843 | messageType: typeNewSessionTicket, |
| 8844 | test: testCase{ |
| 8845 | protocol: protocol, |
| 8846 | name: "NewSessionTicket" + suffix, |
| 8847 | config: Config{ |
| 8848 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8849 | }, |
| 8850 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8851 | }) |
| 8852 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8853 | ret = append(ret, perMessageTest{ |
| 8854 | messageType: typeFinished, |
| 8855 | test: testCase{ |
| 8856 | protocol: protocol, |
| 8857 | name: "ServerFinished" + suffix, |
| 8858 | config: Config{ |
| 8859 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8860 | }, |
| 8861 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8862 | }) |
| 8863 | |
| 8864 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8865 | |
| 8866 | ret = append(ret, perMessageTest{ |
| 8867 | messageType: typeClientHello, |
| 8868 | test: testCase{ |
| 8869 | testType: serverTest, |
| 8870 | name: "TLS13-ClientHello", |
| 8871 | config: Config{ |
| 8872 | MaxVersion: VersionTLS13, |
| 8873 | }, |
| 8874 | }, |
| 8875 | }) |
| 8876 | |
| 8877 | ret = append(ret, perMessageTest{ |
| 8878 | messageType: typeServerHello, |
| 8879 | test: testCase{ |
| 8880 | name: "TLS13-ServerHello", |
| 8881 | config: Config{ |
| 8882 | MaxVersion: VersionTLS13, |
| 8883 | }, |
| 8884 | }, |
| 8885 | }) |
| 8886 | |
| 8887 | ret = append(ret, perMessageTest{ |
| 8888 | messageType: typeEncryptedExtensions, |
| 8889 | test: testCase{ |
| 8890 | name: "TLS13-EncryptedExtensions", |
| 8891 | config: Config{ |
| 8892 | MaxVersion: VersionTLS13, |
| 8893 | }, |
| 8894 | }, |
| 8895 | }) |
| 8896 | |
| 8897 | ret = append(ret, perMessageTest{ |
| 8898 | messageType: typeCertificateRequest, |
| 8899 | test: testCase{ |
| 8900 | name: "TLS13-CertificateRequest", |
| 8901 | config: Config{ |
| 8902 | MaxVersion: VersionTLS13, |
| 8903 | ClientAuth: RequireAnyClientCert, |
| 8904 | }, |
| 8905 | }, |
| 8906 | }) |
| 8907 | |
| 8908 | ret = append(ret, perMessageTest{ |
| 8909 | messageType: typeCertificate, |
| 8910 | test: testCase{ |
| 8911 | name: "TLS13-ServerCertificate", |
| 8912 | config: Config{ |
| 8913 | MaxVersion: VersionTLS13, |
| 8914 | }, |
| 8915 | }, |
| 8916 | }) |
| 8917 | |
| 8918 | ret = append(ret, perMessageTest{ |
| 8919 | messageType: typeCertificateVerify, |
| 8920 | test: testCase{ |
| 8921 | name: "TLS13-ServerCertificateVerify", |
| 8922 | config: Config{ |
| 8923 | MaxVersion: VersionTLS13, |
| 8924 | }, |
| 8925 | }, |
| 8926 | }) |
| 8927 | |
| 8928 | ret = append(ret, perMessageTest{ |
| 8929 | messageType: typeFinished, |
| 8930 | test: testCase{ |
| 8931 | name: "TLS13-ServerFinished", |
| 8932 | config: Config{ |
| 8933 | MaxVersion: VersionTLS13, |
| 8934 | }, |
| 8935 | }, |
| 8936 | }) |
| 8937 | |
| 8938 | ret = append(ret, perMessageTest{ |
| 8939 | messageType: typeCertificate, |
| 8940 | test: testCase{ |
| 8941 | testType: serverTest, |
| 8942 | name: "TLS13-ClientCertificate", |
| 8943 | config: Config{ |
| 8944 | Certificates: []Certificate{rsaCertificate}, |
| 8945 | MaxVersion: VersionTLS13, |
| 8946 | }, |
| 8947 | flags: []string{"-require-any-client-certificate"}, |
| 8948 | }, |
| 8949 | }) |
| 8950 | |
| 8951 | ret = append(ret, perMessageTest{ |
| 8952 | messageType: typeCertificateVerify, |
| 8953 | test: testCase{ |
| 8954 | testType: serverTest, |
| 8955 | name: "TLS13-ClientCertificateVerify", |
| 8956 | config: Config{ |
| 8957 | Certificates: []Certificate{rsaCertificate}, |
| 8958 | MaxVersion: VersionTLS13, |
| 8959 | }, |
| 8960 | flags: []string{"-require-any-client-certificate"}, |
| 8961 | }, |
| 8962 | }) |
| 8963 | |
| 8964 | ret = append(ret, perMessageTest{ |
| 8965 | messageType: typeFinished, |
| 8966 | test: testCase{ |
| 8967 | testType: serverTest, |
| 8968 | name: "TLS13-ClientFinished", |
| 8969 | config: Config{ |
| 8970 | MaxVersion: VersionTLS13, |
| 8971 | }, |
| 8972 | }, |
| 8973 | }) |
| 8974 | |
| 8975 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8976 | } |
| 8977 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8978 | func addWrongMessageTypeTests() { |
| 8979 | for _, t := range makePerMessageTests() { |
| 8980 | t.test.name = "WrongMessageType-" + t.test.name |
| 8981 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 8982 | t.test.shouldFail = true |
| 8983 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 8984 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8985 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8986 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8987 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8988 | // an unencrypted alert while the server expects |
| 8989 | // encryption, so the alert is not readable by runner. |
| 8990 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8991 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8992 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8993 | testCases = append(testCases, t.test) |
| 8994 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8995 | } |
| 8996 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8997 | func addTrailingMessageDataTests() { |
| 8998 | for _, t := range makePerMessageTests() { |
| 8999 | t.test.name = "TrailingMessageData-" + t.test.name |
| 9000 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 9001 | t.test.shouldFail = true |
| 9002 | t.test.expectedError = ":DECODE_ERROR:" |
| 9003 | t.test.expectedLocalError = "remote error: error decoding message" |
| 9004 | |
| 9005 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9006 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9007 | // an unencrypted alert while the server expects |
| 9008 | // encryption, so the alert is not readable by runner. |
| 9009 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9010 | } |
| 9011 | |
| 9012 | if t.messageType == typeFinished { |
| 9013 | // Bad Finished messages read as the verify data having |
| 9014 | // the wrong length. |
| 9015 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 9016 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 9017 | } |
| 9018 | |
| 9019 | testCases = append(testCases, t.test) |
| 9020 | } |
| 9021 | } |
| 9022 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9023 | func addTLS13HandshakeTests() { |
| 9024 | testCases = append(testCases, testCase{ |
| 9025 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9026 | name: "NegotiatePSKResumption-TLS13", |
| 9027 | config: Config{ |
| 9028 | MaxVersion: VersionTLS13, |
| 9029 | Bugs: ProtocolBugs{ |
| 9030 | NegotiatePSKResumption: true, |
| 9031 | }, |
| 9032 | }, |
| 9033 | resumeSession: true, |
| 9034 | shouldFail: true, |
| 9035 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9036 | }) |
| 9037 | |
| 9038 | testCases = append(testCases, testCase{ |
| 9039 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9040 | name: "MissingKeyShare-Client", |
| 9041 | config: Config{ |
| 9042 | MaxVersion: VersionTLS13, |
| 9043 | Bugs: ProtocolBugs{ |
| 9044 | MissingKeyShare: true, |
| 9045 | }, |
| 9046 | }, |
| 9047 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9048 | expectedError: ":UNEXPECTED_EXTENSION:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9049 | }) |
| 9050 | |
| 9051 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9052 | testType: serverTest, |
| 9053 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9054 | config: Config{ |
| 9055 | MaxVersion: VersionTLS13, |
| 9056 | Bugs: ProtocolBugs{ |
| 9057 | MissingKeyShare: true, |
| 9058 | }, |
| 9059 | }, |
| 9060 | shouldFail: true, |
| 9061 | expectedError: ":MISSING_KEY_SHARE:", |
| 9062 | }) |
| 9063 | |
| 9064 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9065 | testType: serverTest, |
| 9066 | name: "DuplicateKeyShares", |
| 9067 | config: Config{ |
| 9068 | MaxVersion: VersionTLS13, |
| 9069 | Bugs: ProtocolBugs{ |
| 9070 | DuplicateKeyShares: true, |
| 9071 | }, |
| 9072 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9073 | shouldFail: true, |
| 9074 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9075 | }) |
| 9076 | |
| 9077 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9078 | testType: serverTest, |
| 9079 | name: "SkipEarlyData", |
| 9080 | config: Config{ |
| 9081 | MaxVersion: VersionTLS13, |
| 9082 | Bugs: ProtocolBugs{ |
| 9083 | SendEarlyDataLength: 4, |
| 9084 | }, |
| 9085 | }, |
| 9086 | }) |
| 9087 | |
| 9088 | testCases = append(testCases, testCase{ |
| 9089 | testType: serverTest, |
| 9090 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9091 | config: Config{ |
| 9092 | MaxVersion: VersionTLS13, |
| 9093 | Bugs: ProtocolBugs{ |
| 9094 | SendEarlyDataLength: 4, |
| 9095 | OmitEarlyDataExtension: true, |
| 9096 | }, |
| 9097 | }, |
| 9098 | shouldFail: true, |
| 9099 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9100 | }) |
| 9101 | |
| 9102 | testCases = append(testCases, testCase{ |
| 9103 | testType: serverTest, |
| 9104 | name: "SkipEarlyData-TooMuchData", |
| 9105 | config: Config{ |
| 9106 | MaxVersion: VersionTLS13, |
| 9107 | Bugs: ProtocolBugs{ |
| 9108 | SendEarlyDataLength: 16384 + 1, |
| 9109 | }, |
| 9110 | }, |
| 9111 | shouldFail: true, |
| 9112 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9113 | }) |
| 9114 | |
| 9115 | testCases = append(testCases, testCase{ |
| 9116 | testType: serverTest, |
| 9117 | name: "SkipEarlyData-Interleaved", |
| 9118 | config: Config{ |
| 9119 | MaxVersion: VersionTLS13, |
| 9120 | Bugs: ProtocolBugs{ |
| 9121 | SendEarlyDataLength: 4, |
| 9122 | InterleaveEarlyData: 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-EarlyDataInTLS12", |
| 9132 | config: Config{ |
| 9133 | MaxVersion: VersionTLS13, |
| 9134 | Bugs: ProtocolBugs{ |
| 9135 | SendEarlyDataLength: 4, |
| 9136 | }, |
| 9137 | }, |
| 9138 | shouldFail: true, |
| 9139 | expectedError: ":UNEXPECTED_RECORD:", |
| 9140 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9141 | }) |
| 9142 | |
| 9143 | testCases = append(testCases, testCase{ |
| 9144 | testType: serverTest, |
| 9145 | name: "SkipEarlyData-HRR", |
| 9146 | config: Config{ |
| 9147 | MaxVersion: VersionTLS13, |
| 9148 | Bugs: ProtocolBugs{ |
| 9149 | SendEarlyDataLength: 4, |
| 9150 | }, |
| 9151 | DefaultCurves: []CurveID{}, |
| 9152 | }, |
| 9153 | }) |
| 9154 | |
| 9155 | testCases = append(testCases, testCase{ |
| 9156 | testType: serverTest, |
| 9157 | name: "SkipEarlyData-HRR-Interleaved", |
| 9158 | config: Config{ |
| 9159 | MaxVersion: VersionTLS13, |
| 9160 | Bugs: ProtocolBugs{ |
| 9161 | SendEarlyDataLength: 4, |
| 9162 | InterleaveEarlyData: true, |
| 9163 | }, |
| 9164 | DefaultCurves: []CurveID{}, |
| 9165 | }, |
| 9166 | shouldFail: true, |
| 9167 | expectedError: ":UNEXPECTED_RECORD:", |
| 9168 | }) |
| 9169 | |
| 9170 | testCases = append(testCases, testCase{ |
| 9171 | testType: serverTest, |
| 9172 | name: "SkipEarlyData-HRR-TooMuchData", |
| 9173 | config: Config{ |
| 9174 | MaxVersion: VersionTLS13, |
| 9175 | Bugs: ProtocolBugs{ |
| 9176 | SendEarlyDataLength: 16384 + 1, |
| 9177 | }, |
| 9178 | DefaultCurves: []CurveID{}, |
| 9179 | }, |
| 9180 | shouldFail: true, |
| 9181 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9182 | }) |
| 9183 | |
| 9184 | // Test that skipping early data looking for cleartext correctly |
| 9185 | // processes an alert record. |
| 9186 | testCases = append(testCases, testCase{ |
| 9187 | testType: serverTest, |
| 9188 | name: "SkipEarlyData-HRR-FatalAlert", |
| 9189 | config: Config{ |
| 9190 | MaxVersion: VersionTLS13, |
| 9191 | Bugs: ProtocolBugs{ |
| 9192 | SendEarlyAlert: true, |
| 9193 | SendEarlyDataLength: 4, |
| 9194 | }, |
| 9195 | DefaultCurves: []CurveID{}, |
| 9196 | }, |
| 9197 | shouldFail: true, |
| 9198 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 9199 | }) |
| 9200 | |
| 9201 | testCases = append(testCases, testCase{ |
| 9202 | testType: serverTest, |
| 9203 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 9204 | config: Config{ |
| 9205 | MaxVersion: VersionTLS13, |
| 9206 | Bugs: ProtocolBugs{ |
| 9207 | SendEarlyDataOnSecondClientHello: true, |
| 9208 | }, |
| 9209 | DefaultCurves: []CurveID{}, |
| 9210 | }, |
| 9211 | shouldFail: true, |
| 9212 | expectedLocalError: "remote error: bad record MAC", |
| 9213 | }) |
| 9214 | |
| 9215 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9216 | testType: clientTest, |
| 9217 | name: "EmptyEncryptedExtensions", |
| 9218 | config: Config{ |
| 9219 | MaxVersion: VersionTLS13, |
| 9220 | Bugs: ProtocolBugs{ |
| 9221 | EmptyEncryptedExtensions: true, |
| 9222 | }, |
| 9223 | }, |
| 9224 | shouldFail: true, |
| 9225 | expectedLocalError: "remote error: error decoding message", |
| 9226 | }) |
| 9227 | |
| 9228 | testCases = append(testCases, testCase{ |
| 9229 | testType: clientTest, |
| 9230 | name: "EncryptedExtensionsWithKeyShare", |
| 9231 | config: Config{ |
| 9232 | MaxVersion: VersionTLS13, |
| 9233 | Bugs: ProtocolBugs{ |
| 9234 | EncryptedExtensionsWithKeyShare: true, |
| 9235 | }, |
| 9236 | }, |
| 9237 | shouldFail: true, |
| 9238 | expectedLocalError: "remote error: unsupported extension", |
| 9239 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9240 | |
| 9241 | testCases = append(testCases, testCase{ |
| 9242 | testType: serverTest, |
| 9243 | name: "SendHelloRetryRequest", |
| 9244 | config: Config{ |
| 9245 | MaxVersion: VersionTLS13, |
| 9246 | // Require a HelloRetryRequest for every curve. |
| 9247 | DefaultCurves: []CurveID{}, |
| 9248 | }, |
| 9249 | expectedCurveID: CurveX25519, |
| 9250 | }) |
| 9251 | |
| 9252 | testCases = append(testCases, testCase{ |
| 9253 | testType: serverTest, |
| 9254 | name: "SendHelloRetryRequest-2", |
| 9255 | config: Config{ |
| 9256 | MaxVersion: VersionTLS13, |
| 9257 | DefaultCurves: []CurveID{CurveP384}, |
| 9258 | }, |
| 9259 | // Although the ClientHello did not predict our preferred curve, |
| 9260 | // we always select it whether it is predicted or not. |
| 9261 | expectedCurveID: CurveX25519, |
| 9262 | }) |
| 9263 | |
| 9264 | testCases = append(testCases, testCase{ |
| 9265 | name: "UnknownCurve-HelloRetryRequest", |
| 9266 | config: Config{ |
| 9267 | MaxVersion: VersionTLS13, |
| 9268 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9269 | CurvePreferences: []CurveID{CurveP384}, |
| 9270 | Bugs: ProtocolBugs{ |
| 9271 | SendHelloRetryRequestCurve: bogusCurve, |
| 9272 | }, |
| 9273 | }, |
| 9274 | shouldFail: true, |
| 9275 | expectedError: ":WRONG_CURVE:", |
| 9276 | }) |
| 9277 | |
| 9278 | testCases = append(testCases, testCase{ |
| 9279 | name: "DisabledCurve-HelloRetryRequest", |
| 9280 | config: Config{ |
| 9281 | MaxVersion: VersionTLS13, |
| 9282 | CurvePreferences: []CurveID{CurveP256}, |
| 9283 | Bugs: ProtocolBugs{ |
| 9284 | IgnorePeerCurvePreferences: true, |
| 9285 | }, |
| 9286 | }, |
| 9287 | flags: []string{"-p384-only"}, |
| 9288 | shouldFail: true, |
| 9289 | expectedError: ":WRONG_CURVE:", |
| 9290 | }) |
| 9291 | |
| 9292 | testCases = append(testCases, testCase{ |
| 9293 | name: "UnnecessaryHelloRetryRequest", |
| 9294 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9295 | MaxVersion: VersionTLS13, |
| 9296 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9297 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9298 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9299 | }, |
| 9300 | }, |
| 9301 | shouldFail: true, |
| 9302 | expectedError: ":WRONG_CURVE:", |
| 9303 | }) |
| 9304 | |
| 9305 | testCases = append(testCases, testCase{ |
| 9306 | name: "SecondHelloRetryRequest", |
| 9307 | config: Config{ |
| 9308 | MaxVersion: VersionTLS13, |
| 9309 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9310 | CurvePreferences: []CurveID{CurveP384}, |
| 9311 | Bugs: ProtocolBugs{ |
| 9312 | SecondHelloRetryRequest: true, |
| 9313 | }, |
| 9314 | }, |
| 9315 | shouldFail: true, |
| 9316 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9317 | }) |
| 9318 | |
| 9319 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9320 | name: "HelloRetryRequest-Empty", |
| 9321 | config: Config{ |
| 9322 | MaxVersion: VersionTLS13, |
| 9323 | Bugs: ProtocolBugs{ |
| 9324 | AlwaysSendHelloRetryRequest: true, |
| 9325 | }, |
| 9326 | }, |
| 9327 | shouldFail: true, |
| 9328 | expectedError: ":DECODE_ERROR:", |
| 9329 | }) |
| 9330 | |
| 9331 | testCases = append(testCases, testCase{ |
| 9332 | name: "HelloRetryRequest-DuplicateCurve", |
| 9333 | config: Config{ |
| 9334 | MaxVersion: VersionTLS13, |
| 9335 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9336 | // configuration. Assert this ExpectMissingKeyShare. |
| 9337 | CurvePreferences: []CurveID{CurveP384}, |
| 9338 | Bugs: ProtocolBugs{ |
| 9339 | ExpectMissingKeyShare: true, |
| 9340 | DuplicateHelloRetryRequestExtensions: true, |
| 9341 | }, |
| 9342 | }, |
| 9343 | shouldFail: true, |
| 9344 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9345 | expectedLocalError: "remote error: illegal parameter", |
| 9346 | }) |
| 9347 | |
| 9348 | testCases = append(testCases, testCase{ |
| 9349 | name: "HelloRetryRequest-Cookie", |
| 9350 | config: Config{ |
| 9351 | MaxVersion: VersionTLS13, |
| 9352 | Bugs: ProtocolBugs{ |
| 9353 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9354 | }, |
| 9355 | }, |
| 9356 | }) |
| 9357 | |
| 9358 | testCases = append(testCases, testCase{ |
| 9359 | name: "HelloRetryRequest-DuplicateCookie", |
| 9360 | config: Config{ |
| 9361 | MaxVersion: VersionTLS13, |
| 9362 | Bugs: ProtocolBugs{ |
| 9363 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9364 | DuplicateHelloRetryRequestExtensions: true, |
| 9365 | }, |
| 9366 | }, |
| 9367 | shouldFail: true, |
| 9368 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9369 | expectedLocalError: "remote error: illegal parameter", |
| 9370 | }) |
| 9371 | |
| 9372 | testCases = append(testCases, testCase{ |
| 9373 | name: "HelloRetryRequest-EmptyCookie", |
| 9374 | config: Config{ |
| 9375 | MaxVersion: VersionTLS13, |
| 9376 | Bugs: ProtocolBugs{ |
| 9377 | SendHelloRetryRequestCookie: []byte{}, |
| 9378 | }, |
| 9379 | }, |
| 9380 | shouldFail: true, |
| 9381 | expectedError: ":DECODE_ERROR:", |
| 9382 | }) |
| 9383 | |
| 9384 | testCases = append(testCases, testCase{ |
| 9385 | name: "HelloRetryRequest-Cookie-Curve", |
| 9386 | config: Config{ |
| 9387 | MaxVersion: VersionTLS13, |
| 9388 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9389 | CurvePreferences: []CurveID{CurveP384}, |
| 9390 | Bugs: ProtocolBugs{ |
| 9391 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9392 | ExpectMissingKeyShare: true, |
| 9393 | }, |
| 9394 | }, |
| 9395 | }) |
| 9396 | |
| 9397 | testCases = append(testCases, testCase{ |
| 9398 | name: "HelloRetryRequest-Unknown", |
| 9399 | config: Config{ |
| 9400 | MaxVersion: VersionTLS13, |
| 9401 | Bugs: ProtocolBugs{ |
| 9402 | CustomHelloRetryRequestExtension: "extension", |
| 9403 | }, |
| 9404 | }, |
| 9405 | shouldFail: true, |
| 9406 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9407 | expectedLocalError: "remote error: unsupported extension", |
| 9408 | }) |
| 9409 | |
| 9410 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9411 | testType: serverTest, |
| 9412 | name: "SecondClientHelloMissingKeyShare", |
| 9413 | config: Config{ |
| 9414 | MaxVersion: VersionTLS13, |
| 9415 | DefaultCurves: []CurveID{}, |
| 9416 | Bugs: ProtocolBugs{ |
| 9417 | SecondClientHelloMissingKeyShare: true, |
| 9418 | }, |
| 9419 | }, |
| 9420 | shouldFail: true, |
| 9421 | expectedError: ":MISSING_KEY_SHARE:", |
| 9422 | }) |
| 9423 | |
| 9424 | testCases = append(testCases, testCase{ |
| 9425 | testType: serverTest, |
| 9426 | name: "SecondClientHelloWrongCurve", |
| 9427 | config: Config{ |
| 9428 | MaxVersion: VersionTLS13, |
| 9429 | DefaultCurves: []CurveID{}, |
| 9430 | Bugs: ProtocolBugs{ |
| 9431 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9432 | }, |
| 9433 | }, |
| 9434 | shouldFail: true, |
| 9435 | expectedError: ":WRONG_CURVE:", |
| 9436 | }) |
| 9437 | |
| 9438 | testCases = append(testCases, testCase{ |
| 9439 | name: "HelloRetryRequestVersionMismatch", |
| 9440 | config: Config{ |
| 9441 | MaxVersion: VersionTLS13, |
| 9442 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9443 | CurvePreferences: []CurveID{CurveP384}, |
| 9444 | Bugs: ProtocolBugs{ |
| 9445 | SendServerHelloVersion: 0x0305, |
| 9446 | }, |
| 9447 | }, |
| 9448 | shouldFail: true, |
| 9449 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9450 | }) |
| 9451 | |
| 9452 | testCases = append(testCases, testCase{ |
| 9453 | name: "HelloRetryRequestCurveMismatch", |
| 9454 | config: Config{ |
| 9455 | MaxVersion: VersionTLS13, |
| 9456 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9457 | CurvePreferences: []CurveID{CurveP384}, |
| 9458 | Bugs: ProtocolBugs{ |
| 9459 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9460 | SendHelloRetryRequestCurve: CurveP384, |
| 9461 | // But send P-256 in the ServerHello. |
| 9462 | SendCurve: CurveP256, |
| 9463 | }, |
| 9464 | }, |
| 9465 | shouldFail: true, |
| 9466 | expectedError: ":WRONG_CURVE:", |
| 9467 | }) |
| 9468 | |
| 9469 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9470 | // without sending it. |
| 9471 | testCases = append(testCases, testCase{ |
| 9472 | name: "SkipHelloRetryRequest", |
| 9473 | config: Config{ |
| 9474 | MaxVersion: VersionTLS13, |
| 9475 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9476 | CurvePreferences: []CurveID{CurveP384}, |
| 9477 | Bugs: ProtocolBugs{ |
| 9478 | SkipHelloRetryRequest: true, |
| 9479 | }, |
| 9480 | }, |
| 9481 | shouldFail: true, |
| 9482 | expectedError: ":WRONG_CURVE:", |
| 9483 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9484 | |
| 9485 | testCases = append(testCases, testCase{ |
| 9486 | name: "TLS13-RequestContextInHandshake", |
| 9487 | config: Config{ |
| 9488 | MaxVersion: VersionTLS13, |
| 9489 | MinVersion: VersionTLS13, |
| 9490 | ClientAuth: RequireAnyClientCert, |
| 9491 | Bugs: ProtocolBugs{ |
| 9492 | SendRequestContext: []byte("request context"), |
| 9493 | }, |
| 9494 | }, |
| 9495 | flags: []string{ |
| 9496 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9497 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9498 | }, |
| 9499 | shouldFail: true, |
| 9500 | expectedError: ":DECODE_ERROR:", |
| 9501 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9502 | |
| 9503 | testCases = append(testCases, testCase{ |
| 9504 | testType: serverTest, |
| 9505 | name: "TLS13-TrailingKeyShareData", |
| 9506 | config: Config{ |
| 9507 | MaxVersion: VersionTLS13, |
| 9508 | Bugs: ProtocolBugs{ |
| 9509 | TrailingKeyShareData: true, |
| 9510 | }, |
| 9511 | }, |
| 9512 | shouldFail: true, |
| 9513 | expectedError: ":DECODE_ERROR:", |
| 9514 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9515 | |
| 9516 | testCases = append(testCases, testCase{ |
| 9517 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9518 | config: Config{ |
| 9519 | MaxVersion: VersionTLS13, |
| 9520 | Bugs: ProtocolBugs{ |
| 9521 | AlwaysSelectPSKIdentity: true, |
| 9522 | }, |
| 9523 | }, |
| 9524 | shouldFail: true, |
| 9525 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9526 | }) |
| 9527 | |
| 9528 | testCases = append(testCases, testCase{ |
| 9529 | name: "TLS13-InvalidPSKIdentity", |
| 9530 | config: Config{ |
| 9531 | MaxVersion: VersionTLS13, |
| 9532 | Bugs: ProtocolBugs{ |
| 9533 | SelectPSKIdentityOnResume: 1, |
| 9534 | }, |
| 9535 | }, |
| 9536 | resumeSession: true, |
| 9537 | shouldFail: true, |
| 9538 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9539 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9540 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9541 | testCases = append(testCases, testCase{ |
| 9542 | testType: serverTest, |
| 9543 | name: "TLS13-ExtraPSKIdentity", |
| 9544 | config: Config{ |
| 9545 | MaxVersion: VersionTLS13, |
| 9546 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 9547 | ExtraPSKIdentity: true, |
| 9548 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9549 | }, |
| 9550 | }, |
| 9551 | resumeSession: true, |
| 9552 | }) |
| 9553 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9554 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9555 | testCases = append(testCases, testCase{ |
| 9556 | name: "TLS13-CustomTicketExtension", |
| 9557 | config: Config{ |
| 9558 | MaxVersion: VersionTLS13, |
| 9559 | Bugs: ProtocolBugs{ |
| 9560 | CustomTicketExtension: "1234", |
| 9561 | }, |
| 9562 | }, |
| 9563 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9564 | } |
| 9565 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9566 | func addTLS13CipherPreferenceTests() { |
| 9567 | // Test that client preference is honored if the shim has AES hardware |
| 9568 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9569 | testCases = append(testCases, testCase{ |
| 9570 | testType: serverTest, |
| 9571 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9572 | config: Config{ |
| 9573 | MaxVersion: VersionTLS13, |
| 9574 | CipherSuites: []uint16{ |
| 9575 | TLS_CHACHA20_POLY1305_SHA256, |
| 9576 | TLS_AES_128_GCM_SHA256, |
| 9577 | }, |
| 9578 | }, |
| 9579 | flags: []string{ |
| 9580 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9581 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9582 | }, |
| 9583 | }) |
| 9584 | |
| 9585 | testCases = append(testCases, testCase{ |
| 9586 | testType: serverTest, |
| 9587 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9588 | config: Config{ |
| 9589 | MaxVersion: VersionTLS13, |
| 9590 | CipherSuites: []uint16{ |
| 9591 | TLS_AES_128_GCM_SHA256, |
| 9592 | TLS_CHACHA20_POLY1305_SHA256, |
| 9593 | }, |
| 9594 | }, |
| 9595 | flags: []string{ |
| 9596 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9597 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9598 | }, |
| 9599 | }) |
| 9600 | |
| 9601 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9602 | // whether it has AES hardware. |
| 9603 | testCases = append(testCases, testCase{ |
| 9604 | name: "TLS13-CipherPreference-Client", |
| 9605 | config: Config{ |
| 9606 | MaxVersion: VersionTLS13, |
| 9607 | // Use the client cipher order. (This is the default but |
| 9608 | // is listed to be explicit.) |
| 9609 | PreferServerCipherSuites: false, |
| 9610 | }, |
| 9611 | flags: []string{ |
| 9612 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9613 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9614 | }, |
| 9615 | }) |
| 9616 | } |
| 9617 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9618 | func addPeekTests() { |
| 9619 | // Test SSL_peek works, including on empty records. |
| 9620 | testCases = append(testCases, testCase{ |
| 9621 | name: "Peek-Basic", |
| 9622 | sendEmptyRecords: 1, |
| 9623 | flags: []string{"-peek-then-read"}, |
| 9624 | }) |
| 9625 | |
| 9626 | // Test SSL_peek can drive the initial handshake. |
| 9627 | testCases = append(testCases, testCase{ |
| 9628 | name: "Peek-ImplicitHandshake", |
| 9629 | flags: []string{ |
| 9630 | "-peek-then-read", |
| 9631 | "-implicit-handshake", |
| 9632 | }, |
| 9633 | }) |
| 9634 | |
| 9635 | // Test SSL_peek can discover and drive a renegotiation. |
| 9636 | testCases = append(testCases, testCase{ |
| 9637 | name: "Peek-Renegotiate", |
| 9638 | config: Config{ |
| 9639 | MaxVersion: VersionTLS12, |
| 9640 | }, |
| 9641 | renegotiate: 1, |
| 9642 | flags: []string{ |
| 9643 | "-peek-then-read", |
| 9644 | "-renegotiate-freely", |
| 9645 | "-expect-total-renegotiations", "1", |
| 9646 | }, |
| 9647 | }) |
| 9648 | |
| 9649 | // Test SSL_peek can discover a close_notify. |
| 9650 | testCases = append(testCases, testCase{ |
| 9651 | name: "Peek-Shutdown", |
| 9652 | config: Config{ |
| 9653 | Bugs: ProtocolBugs{ |
| 9654 | ExpectCloseNotify: true, |
| 9655 | }, |
| 9656 | }, |
| 9657 | flags: []string{ |
| 9658 | "-peek-then-read", |
| 9659 | "-check-close-notify", |
| 9660 | }, |
| 9661 | }) |
| 9662 | |
| 9663 | // Test SSL_peek can discover an alert. |
| 9664 | testCases = append(testCases, testCase{ |
| 9665 | name: "Peek-Alert", |
| 9666 | config: Config{ |
| 9667 | Bugs: ProtocolBugs{ |
| 9668 | SendSpuriousAlert: alertRecordOverflow, |
| 9669 | }, |
| 9670 | }, |
| 9671 | flags: []string{"-peek-then-read"}, |
| 9672 | shouldFail: true, |
| 9673 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9674 | }) |
| 9675 | |
| 9676 | // Test SSL_peek can handle KeyUpdate. |
| 9677 | testCases = append(testCases, testCase{ |
| 9678 | name: "Peek-KeyUpdate", |
| 9679 | config: Config{ |
| 9680 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9681 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9682 | sendKeyUpdates: 1, |
| 9683 | keyUpdateRequest: keyUpdateNotRequested, |
| 9684 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9685 | }) |
| 9686 | } |
| 9687 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9688 | func addRecordVersionTests() { |
| 9689 | for _, ver := range tlsVersions { |
| 9690 | // Test that the record version is enforced. |
| 9691 | testCases = append(testCases, testCase{ |
| 9692 | name: "CheckRecordVersion-" + ver.name, |
| 9693 | config: Config{ |
| 9694 | MinVersion: ver.version, |
| 9695 | MaxVersion: ver.version, |
| 9696 | Bugs: ProtocolBugs{ |
| 9697 | SendRecordVersion: 0x03ff, |
| 9698 | }, |
| 9699 | }, |
| 9700 | shouldFail: true, |
| 9701 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9702 | }) |
| 9703 | |
| 9704 | // Test that the ClientHello may use any record version, for |
| 9705 | // compatibility reasons. |
| 9706 | testCases = append(testCases, testCase{ |
| 9707 | testType: serverTest, |
| 9708 | name: "LooseInitialRecordVersion-" + ver.name, |
| 9709 | config: Config{ |
| 9710 | MinVersion: ver.version, |
| 9711 | MaxVersion: ver.version, |
| 9712 | Bugs: ProtocolBugs{ |
| 9713 | SendInitialRecordVersion: 0x03ff, |
| 9714 | }, |
| 9715 | }, |
| 9716 | }) |
| 9717 | |
| 9718 | // Test that garbage ClientHello record versions are rejected. |
| 9719 | testCases = append(testCases, testCase{ |
| 9720 | testType: serverTest, |
| 9721 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 9722 | config: Config{ |
| 9723 | MinVersion: ver.version, |
| 9724 | MaxVersion: ver.version, |
| 9725 | Bugs: ProtocolBugs{ |
| 9726 | SendInitialRecordVersion: 0xffff, |
| 9727 | }, |
| 9728 | }, |
| 9729 | shouldFail: true, |
| 9730 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9731 | }) |
| 9732 | } |
| 9733 | } |
| 9734 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9735 | func addCertificateTests() { |
| 9736 | // Test that a certificate chain with intermediate may be sent and |
| 9737 | // received as both client and server. |
| 9738 | for _, ver := range tlsVersions { |
| 9739 | testCases = append(testCases, testCase{ |
| 9740 | testType: clientTest, |
| 9741 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 9742 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9743 | MinVersion: ver.version, |
| 9744 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9745 | Certificates: []Certificate{rsaChainCertificate}, |
| 9746 | ClientAuth: RequireAnyClientCert, |
| 9747 | }, |
| 9748 | expectPeerCertificate: &rsaChainCertificate, |
| 9749 | flags: []string{ |
| 9750 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9751 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9752 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9753 | }, |
| 9754 | }) |
| 9755 | |
| 9756 | testCases = append(testCases, testCase{ |
| 9757 | testType: serverTest, |
| 9758 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 9759 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9760 | MinVersion: ver.version, |
| 9761 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9762 | Certificates: []Certificate{rsaChainCertificate}, |
| 9763 | }, |
| 9764 | expectPeerCertificate: &rsaChainCertificate, |
| 9765 | flags: []string{ |
| 9766 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9767 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9768 | "-require-any-client-certificate", |
| 9769 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9770 | }, |
| 9771 | }) |
| 9772 | } |
| 9773 | } |
| 9774 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9775 | func addRetainOnlySHA256ClientCertTests() { |
| 9776 | for _, ver := range tlsVersions { |
| 9777 | // Test that enabling |
| 9778 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 9779 | // actually requesting a client certificate is a no-op. |
| 9780 | testCases = append(testCases, testCase{ |
| 9781 | testType: serverTest, |
| 9782 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 9783 | config: Config{ |
| 9784 | MinVersion: ver.version, |
| 9785 | MaxVersion: ver.version, |
| 9786 | }, |
| 9787 | flags: []string{ |
| 9788 | "-retain-only-sha256-client-cert-initial", |
| 9789 | "-retain-only-sha256-client-cert-resume", |
| 9790 | }, |
| 9791 | resumeSession: true, |
| 9792 | }) |
| 9793 | |
| 9794 | // Test that when retaining only a SHA-256 certificate is |
| 9795 | // enabled, the hash appears as expected. |
| 9796 | testCases = append(testCases, testCase{ |
| 9797 | testType: serverTest, |
| 9798 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 9799 | config: Config{ |
| 9800 | MinVersion: ver.version, |
| 9801 | MaxVersion: ver.version, |
| 9802 | Certificates: []Certificate{rsaCertificate}, |
| 9803 | }, |
| 9804 | flags: []string{ |
| 9805 | "-verify-peer", |
| 9806 | "-retain-only-sha256-client-cert-initial", |
| 9807 | "-retain-only-sha256-client-cert-resume", |
| 9808 | "-expect-sha256-client-cert-initial", |
| 9809 | "-expect-sha256-client-cert-resume", |
| 9810 | }, |
| 9811 | resumeSession: true, |
| 9812 | }) |
| 9813 | |
| 9814 | // Test that when the config changes from on to off, a |
| 9815 | // resumption is rejected because the server now wants the full |
| 9816 | // certificate chain. |
| 9817 | testCases = append(testCases, testCase{ |
| 9818 | testType: serverTest, |
| 9819 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 9820 | config: Config{ |
| 9821 | MinVersion: ver.version, |
| 9822 | MaxVersion: ver.version, |
| 9823 | Certificates: []Certificate{rsaCertificate}, |
| 9824 | }, |
| 9825 | flags: []string{ |
| 9826 | "-verify-peer", |
| 9827 | "-retain-only-sha256-client-cert-initial", |
| 9828 | "-expect-sha256-client-cert-initial", |
| 9829 | }, |
| 9830 | resumeSession: true, |
| 9831 | expectResumeRejected: true, |
| 9832 | }) |
| 9833 | |
| 9834 | // Test that when the config changes from off to on, a |
| 9835 | // resumption is rejected because the server now wants just the |
| 9836 | // hash. |
| 9837 | testCases = append(testCases, testCase{ |
| 9838 | testType: serverTest, |
| 9839 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 9840 | config: Config{ |
| 9841 | MinVersion: ver.version, |
| 9842 | MaxVersion: ver.version, |
| 9843 | Certificates: []Certificate{rsaCertificate}, |
| 9844 | }, |
| 9845 | flags: []string{ |
| 9846 | "-verify-peer", |
| 9847 | "-retain-only-sha256-client-cert-resume", |
| 9848 | "-expect-sha256-client-cert-resume", |
| 9849 | }, |
| 9850 | resumeSession: true, |
| 9851 | expectResumeRejected: true, |
| 9852 | }) |
| 9853 | } |
| 9854 | } |
| 9855 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9856 | 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] | 9857 | defer wg.Done() |
| 9858 | |
| 9859 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9860 | var err error |
| 9861 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9862 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9863 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 9864 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9865 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9866 | if err != nil { |
| 9867 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 9868 | } |
| 9869 | break |
| 9870 | } |
| 9871 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9872 | } else if *repeatUntilFailure { |
| 9873 | for err == nil { |
| 9874 | statusChan <- statusMsg{test: test, started: true} |
| 9875 | err = runTest(test, shimPath, -1) |
| 9876 | } |
| 9877 | } else { |
| 9878 | statusChan <- statusMsg{test: test, started: true} |
| 9879 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9880 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9881 | statusChan <- statusMsg{test: test, err: err} |
| 9882 | } |
| 9883 | } |
| 9884 | |
| 9885 | type statusMsg struct { |
| 9886 | test *testCase |
| 9887 | started bool |
| 9888 | err error |
| 9889 | } |
| 9890 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9891 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9892 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9893 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9894 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9895 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9896 | if !*pipe { |
| 9897 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 9898 | var erase string |
| 9899 | for i := 0; i < lineLen; i++ { |
| 9900 | erase += "\b \b" |
| 9901 | } |
| 9902 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9903 | } |
| 9904 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9905 | if msg.started { |
| 9906 | started++ |
| 9907 | } else { |
| 9908 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9909 | |
| 9910 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9911 | if msg.err == errUnimplemented { |
| 9912 | if *pipe { |
| 9913 | // Print each test instead of a status line. |
| 9914 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 9915 | } |
| 9916 | unimplemented++ |
| 9917 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 9918 | } else { |
| 9919 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 9920 | failed++ |
| 9921 | testOutput.addResult(msg.test.name, "FAIL") |
| 9922 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9923 | } else { |
| 9924 | if *pipe { |
| 9925 | // Print each test instead of a status line. |
| 9926 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 9927 | } |
| 9928 | testOutput.addResult(msg.test.name, "PASS") |
| 9929 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9930 | } |
| 9931 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9932 | if !*pipe { |
| 9933 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9934 | 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] | 9935 | lineLen = len(line) |
| 9936 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9937 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9938 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9939 | |
| 9940 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9941 | } |
| 9942 | |
| 9943 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9944 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9945 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 9946 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9947 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9948 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9949 | addCipherSuiteTests() |
| 9950 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9951 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 9952 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 9953 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 9954 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 9955 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 9956 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 9957 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 9958 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 9959 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 9960 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 9961 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 9962 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 9963 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 9964 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 9965 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9966 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9967 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9968 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 9969 | addCECPQ1Tests() |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9970 | addDHEGroupSizeTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9971 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9972 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 9973 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9974 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9975 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9976 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9977 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9978 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9979 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9980 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9981 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9982 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9983 | |
| 9984 | var wg sync.WaitGroup |
| 9985 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9986 | statusChan := make(chan statusMsg, *numWorkers) |
| 9987 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9988 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9989 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9990 | if len(*shimConfigFile) != 0 { |
| 9991 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 9992 | if err != nil { |
| 9993 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 9994 | os.Exit(1) |
| 9995 | } |
| 9996 | |
| 9997 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 9998 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 9999 | os.Exit(1) |
| 10000 | } |
| 10001 | } |
| 10002 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10003 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10004 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10005 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10006 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10007 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10008 | } |
| 10009 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10010 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10011 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10012 | matched := true |
| 10013 | if len(*testToRun) != 0 { |
| 10014 | var err error |
| 10015 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 10016 | if err != nil { |
| 10017 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 10018 | os.Exit(1) |
| 10019 | } |
| 10020 | } |
| 10021 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10022 | if !*includeDisabled { |
| 10023 | for pattern := range shimConfig.DisabledTests { |
| 10024 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 10025 | if err != nil { |
| 10026 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 10027 | os.Exit(1) |
| 10028 | } |
| 10029 | |
| 10030 | if isDisabled { |
| 10031 | matched = false |
| 10032 | break |
| 10033 | } |
| 10034 | } |
| 10035 | } |
| 10036 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10037 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10038 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10039 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10040 | |
| 10041 | // Only run one test if repeating until failure. |
| 10042 | if *repeatUntilFailure { |
| 10043 | break |
| 10044 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10045 | } |
| 10046 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10047 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10048 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10049 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10050 | os.Exit(1) |
| 10051 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10052 | |
| 10053 | close(testChan) |
| 10054 | wg.Wait() |
| 10055 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10056 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10057 | |
| 10058 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10059 | |
| 10060 | if *jsonOutput != "" { |
| 10061 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 10062 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 10063 | } |
| 10064 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10065 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10066 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 10067 | os.Exit(1) |
| 10068 | } |
| 10069 | |
| 10070 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10071 | os.Exit(1) |
| 10072 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10073 | } |