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}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1103 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1104 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1105 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1106 | {"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] | 1107 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1108 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1109 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1110 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1111 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1112 | } |
| 1113 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1114 | func hasComponent(suiteName, component string) bool { |
| 1115 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1116 | } |
| 1117 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1118 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1119 | return hasComponent(suiteName, "GCM") || |
| 1120 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1121 | hasComponent(suiteName, "SHA384") || |
| 1122 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1123 | } |
| 1124 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1125 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1126 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1129 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1130 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1131 | } |
| 1132 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1133 | func bigFromHex(hex string) *big.Int { |
| 1134 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1135 | if !ok { |
| 1136 | panic("failed to parse hex number 0x" + hex) |
| 1137 | } |
| 1138 | return ret |
| 1139 | } |
| 1140 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1141 | func addBasicTests() { |
| 1142 | basicTests := []testCase{ |
| 1143 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1144 | name: "NoFallbackSCSV", |
| 1145 | config: Config{ |
| 1146 | Bugs: ProtocolBugs{ |
| 1147 | FailIfNotFallbackSCSV: true, |
| 1148 | }, |
| 1149 | }, |
| 1150 | shouldFail: true, |
| 1151 | expectedLocalError: "no fallback SCSV found", |
| 1152 | }, |
| 1153 | { |
| 1154 | name: "SendFallbackSCSV", |
| 1155 | config: Config{ |
| 1156 | Bugs: ProtocolBugs{ |
| 1157 | FailIfNotFallbackSCSV: true, |
| 1158 | }, |
| 1159 | }, |
| 1160 | flags: []string{"-fallback-scsv"}, |
| 1161 | }, |
| 1162 | { |
| 1163 | name: "ClientCertificateTypes", |
| 1164 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1165 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1166 | ClientAuth: RequestClientCert, |
| 1167 | ClientCertificateTypes: []byte{ |
| 1168 | CertTypeDSSSign, |
| 1169 | CertTypeRSASign, |
| 1170 | CertTypeECDSASign, |
| 1171 | }, |
| 1172 | }, |
| 1173 | flags: []string{ |
| 1174 | "-expect-certificate-types", |
| 1175 | base64.StdEncoding.EncodeToString([]byte{ |
| 1176 | CertTypeDSSSign, |
| 1177 | CertTypeRSASign, |
| 1178 | CertTypeECDSASign, |
| 1179 | }), |
| 1180 | }, |
| 1181 | }, |
| 1182 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1183 | name: "UnauthenticatedECDH", |
| 1184 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1185 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1186 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1187 | Bugs: ProtocolBugs{ |
| 1188 | UnauthenticatedECDH: true, |
| 1189 | }, |
| 1190 | }, |
| 1191 | shouldFail: true, |
| 1192 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1193 | }, |
| 1194 | { |
| 1195 | name: "SkipCertificateStatus", |
| 1196 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1197 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1198 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1199 | Bugs: ProtocolBugs{ |
| 1200 | SkipCertificateStatus: true, |
| 1201 | }, |
| 1202 | }, |
| 1203 | flags: []string{ |
| 1204 | "-enable-ocsp-stapling", |
| 1205 | }, |
| 1206 | }, |
| 1207 | { |
| 1208 | name: "SkipServerKeyExchange", |
| 1209 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1210 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1211 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1212 | Bugs: ProtocolBugs{ |
| 1213 | SkipServerKeyExchange: true, |
| 1214 | }, |
| 1215 | }, |
| 1216 | shouldFail: true, |
| 1217 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1218 | }, |
| 1219 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1220 | testType: serverTest, |
| 1221 | name: "Alert", |
| 1222 | config: Config{ |
| 1223 | Bugs: ProtocolBugs{ |
| 1224 | SendSpuriousAlert: alertRecordOverflow, |
| 1225 | }, |
| 1226 | }, |
| 1227 | shouldFail: true, |
| 1228 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1229 | }, |
| 1230 | { |
| 1231 | protocol: dtls, |
| 1232 | testType: serverTest, |
| 1233 | name: "Alert-DTLS", |
| 1234 | config: Config{ |
| 1235 | Bugs: ProtocolBugs{ |
| 1236 | SendSpuriousAlert: alertRecordOverflow, |
| 1237 | }, |
| 1238 | }, |
| 1239 | shouldFail: true, |
| 1240 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1241 | }, |
| 1242 | { |
| 1243 | testType: serverTest, |
| 1244 | name: "FragmentAlert", |
| 1245 | config: Config{ |
| 1246 | Bugs: ProtocolBugs{ |
| 1247 | FragmentAlert: true, |
| 1248 | SendSpuriousAlert: alertRecordOverflow, |
| 1249 | }, |
| 1250 | }, |
| 1251 | shouldFail: true, |
| 1252 | expectedError: ":BAD_ALERT:", |
| 1253 | }, |
| 1254 | { |
| 1255 | protocol: dtls, |
| 1256 | testType: serverTest, |
| 1257 | name: "FragmentAlert-DTLS", |
| 1258 | config: Config{ |
| 1259 | Bugs: ProtocolBugs{ |
| 1260 | FragmentAlert: true, |
| 1261 | SendSpuriousAlert: alertRecordOverflow, |
| 1262 | }, |
| 1263 | }, |
| 1264 | shouldFail: true, |
| 1265 | expectedError: ":BAD_ALERT:", |
| 1266 | }, |
| 1267 | { |
| 1268 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1269 | name: "DoubleAlert", |
| 1270 | config: Config{ |
| 1271 | Bugs: ProtocolBugs{ |
| 1272 | DoubleAlert: true, |
| 1273 | SendSpuriousAlert: alertRecordOverflow, |
| 1274 | }, |
| 1275 | }, |
| 1276 | shouldFail: true, |
| 1277 | expectedError: ":BAD_ALERT:", |
| 1278 | }, |
| 1279 | { |
| 1280 | protocol: dtls, |
| 1281 | testType: serverTest, |
| 1282 | name: "DoubleAlert-DTLS", |
| 1283 | config: Config{ |
| 1284 | Bugs: ProtocolBugs{ |
| 1285 | DoubleAlert: true, |
| 1286 | SendSpuriousAlert: alertRecordOverflow, |
| 1287 | }, |
| 1288 | }, |
| 1289 | shouldFail: true, |
| 1290 | expectedError: ":BAD_ALERT:", |
| 1291 | }, |
| 1292 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1293 | name: "SkipNewSessionTicket", |
| 1294 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1295 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1296 | Bugs: ProtocolBugs{ |
| 1297 | SkipNewSessionTicket: true, |
| 1298 | }, |
| 1299 | }, |
| 1300 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1301 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1302 | }, |
| 1303 | { |
| 1304 | testType: serverTest, |
| 1305 | name: "FallbackSCSV", |
| 1306 | config: Config{ |
| 1307 | MaxVersion: VersionTLS11, |
| 1308 | Bugs: ProtocolBugs{ |
| 1309 | SendFallbackSCSV: true, |
| 1310 | }, |
| 1311 | }, |
| 1312 | shouldFail: true, |
| 1313 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1314 | }, |
| 1315 | { |
| 1316 | testType: serverTest, |
| 1317 | name: "FallbackSCSV-VersionMatch", |
| 1318 | config: Config{ |
| 1319 | Bugs: ProtocolBugs{ |
| 1320 | SendFallbackSCSV: true, |
| 1321 | }, |
| 1322 | }, |
| 1323 | }, |
| 1324 | { |
| 1325 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1326 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1327 | config: Config{ |
| 1328 | MaxVersion: VersionTLS12, |
| 1329 | Bugs: ProtocolBugs{ |
| 1330 | SendFallbackSCSV: true, |
| 1331 | }, |
| 1332 | }, |
| 1333 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1334 | }, |
| 1335 | { |
| 1336 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1337 | name: "FragmentedClientVersion", |
| 1338 | config: Config{ |
| 1339 | Bugs: ProtocolBugs{ |
| 1340 | MaxHandshakeRecordLength: 1, |
| 1341 | FragmentClientVersion: true, |
| 1342 | }, |
| 1343 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1344 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1345 | }, |
| 1346 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1347 | testType: serverTest, |
| 1348 | name: "HttpGET", |
| 1349 | sendPrefix: "GET / HTTP/1.0\n", |
| 1350 | shouldFail: true, |
| 1351 | expectedError: ":HTTP_REQUEST:", |
| 1352 | }, |
| 1353 | { |
| 1354 | testType: serverTest, |
| 1355 | name: "HttpPOST", |
| 1356 | sendPrefix: "POST / HTTP/1.0\n", |
| 1357 | shouldFail: true, |
| 1358 | expectedError: ":HTTP_REQUEST:", |
| 1359 | }, |
| 1360 | { |
| 1361 | testType: serverTest, |
| 1362 | name: "HttpHEAD", |
| 1363 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1364 | shouldFail: true, |
| 1365 | expectedError: ":HTTP_REQUEST:", |
| 1366 | }, |
| 1367 | { |
| 1368 | testType: serverTest, |
| 1369 | name: "HttpPUT", |
| 1370 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1371 | shouldFail: true, |
| 1372 | expectedError: ":HTTP_REQUEST:", |
| 1373 | }, |
| 1374 | { |
| 1375 | testType: serverTest, |
| 1376 | name: "HttpCONNECT", |
| 1377 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1378 | shouldFail: true, |
| 1379 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1380 | }, |
| 1381 | { |
| 1382 | testType: serverTest, |
| 1383 | name: "Garbage", |
| 1384 | sendPrefix: "blah", |
| 1385 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1386 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1387 | }, |
| 1388 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1389 | name: "RSAEphemeralKey", |
| 1390 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1391 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1392 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1393 | Bugs: ProtocolBugs{ |
| 1394 | RSAEphemeralKey: true, |
| 1395 | }, |
| 1396 | }, |
| 1397 | shouldFail: true, |
| 1398 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1399 | }, |
| 1400 | { |
| 1401 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1402 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1403 | shouldFail: true, |
| 1404 | expectedError: ":WRONG_SSL_VERSION:", |
| 1405 | }, |
| 1406 | { |
| 1407 | protocol: dtls, |
| 1408 | name: "DisableEverything-DTLS", |
| 1409 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1410 | shouldFail: true, |
| 1411 | expectedError: ":WRONG_SSL_VERSION:", |
| 1412 | }, |
| 1413 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1414 | protocol: dtls, |
| 1415 | testType: serverTest, |
| 1416 | name: "MTU", |
| 1417 | config: Config{ |
| 1418 | Bugs: ProtocolBugs{ |
| 1419 | MaxPacketLength: 256, |
| 1420 | }, |
| 1421 | }, |
| 1422 | flags: []string{"-mtu", "256"}, |
| 1423 | }, |
| 1424 | { |
| 1425 | protocol: dtls, |
| 1426 | testType: serverTest, |
| 1427 | name: "MTUExceeded", |
| 1428 | config: Config{ |
| 1429 | Bugs: ProtocolBugs{ |
| 1430 | MaxPacketLength: 255, |
| 1431 | }, |
| 1432 | }, |
| 1433 | flags: []string{"-mtu", "256"}, |
| 1434 | shouldFail: true, |
| 1435 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1436 | }, |
| 1437 | { |
| 1438 | name: "CertMismatchRSA", |
| 1439 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1440 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1441 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1442 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1443 | Bugs: ProtocolBugs{ |
| 1444 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1445 | }, |
| 1446 | }, |
| 1447 | shouldFail: true, |
| 1448 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1449 | }, |
| 1450 | { |
| 1451 | name: "CertMismatchECDSA", |
| 1452 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1453 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1454 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1455 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1456 | Bugs: ProtocolBugs{ |
| 1457 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1458 | }, |
| 1459 | }, |
| 1460 | shouldFail: true, |
| 1461 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1462 | }, |
| 1463 | { |
| 1464 | name: "EmptyCertificateList", |
| 1465 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1466 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1467 | Bugs: ProtocolBugs{ |
| 1468 | EmptyCertificateList: true, |
| 1469 | }, |
| 1470 | }, |
| 1471 | shouldFail: true, |
| 1472 | expectedError: ":DECODE_ERROR:", |
| 1473 | }, |
| 1474 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1475 | name: "EmptyCertificateList-TLS13", |
| 1476 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1477 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1478 | Bugs: ProtocolBugs{ |
| 1479 | EmptyCertificateList: true, |
| 1480 | }, |
| 1481 | }, |
| 1482 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1483 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1484 | }, |
| 1485 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1486 | name: "TLSFatalBadPackets", |
| 1487 | damageFirstWrite: true, |
| 1488 | shouldFail: true, |
| 1489 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1490 | }, |
| 1491 | { |
| 1492 | protocol: dtls, |
| 1493 | name: "DTLSIgnoreBadPackets", |
| 1494 | damageFirstWrite: true, |
| 1495 | }, |
| 1496 | { |
| 1497 | protocol: dtls, |
| 1498 | name: "DTLSIgnoreBadPackets-Async", |
| 1499 | damageFirstWrite: true, |
| 1500 | flags: []string{"-async"}, |
| 1501 | }, |
| 1502 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1503 | name: "AppDataBeforeHandshake", |
| 1504 | config: Config{ |
| 1505 | Bugs: ProtocolBugs{ |
| 1506 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1507 | }, |
| 1508 | }, |
| 1509 | shouldFail: true, |
| 1510 | expectedError: ":UNEXPECTED_RECORD:", |
| 1511 | }, |
| 1512 | { |
| 1513 | name: "AppDataBeforeHandshake-Empty", |
| 1514 | config: Config{ |
| 1515 | Bugs: ProtocolBugs{ |
| 1516 | AppDataBeforeHandshake: []byte{}, |
| 1517 | }, |
| 1518 | }, |
| 1519 | shouldFail: true, |
| 1520 | expectedError: ":UNEXPECTED_RECORD:", |
| 1521 | }, |
| 1522 | { |
| 1523 | protocol: dtls, |
| 1524 | name: "AppDataBeforeHandshake-DTLS", |
| 1525 | config: Config{ |
| 1526 | Bugs: ProtocolBugs{ |
| 1527 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1528 | }, |
| 1529 | }, |
| 1530 | shouldFail: true, |
| 1531 | expectedError: ":UNEXPECTED_RECORD:", |
| 1532 | }, |
| 1533 | { |
| 1534 | protocol: dtls, |
| 1535 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1536 | config: Config{ |
| 1537 | Bugs: ProtocolBugs{ |
| 1538 | AppDataBeforeHandshake: []byte{}, |
| 1539 | }, |
| 1540 | }, |
| 1541 | shouldFail: true, |
| 1542 | expectedError: ":UNEXPECTED_RECORD:", |
| 1543 | }, |
| 1544 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1545 | name: "AppDataAfterChangeCipherSpec", |
| 1546 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1547 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1548 | Bugs: ProtocolBugs{ |
| 1549 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1550 | }, |
| 1551 | }, |
| 1552 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1553 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1554 | }, |
| 1555 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1556 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1557 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1558 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1559 | Bugs: ProtocolBugs{ |
| 1560 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1561 | }, |
| 1562 | }, |
| 1563 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1564 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1565 | }, |
| 1566 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1567 | protocol: dtls, |
| 1568 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1569 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1570 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1571 | Bugs: ProtocolBugs{ |
| 1572 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1573 | }, |
| 1574 | }, |
| 1575 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1576 | // application data. |
| 1577 | }, |
| 1578 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1579 | protocol: dtls, |
| 1580 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1581 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1582 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1583 | Bugs: ProtocolBugs{ |
| 1584 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1585 | }, |
| 1586 | }, |
| 1587 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1588 | // application data. |
| 1589 | }, |
| 1590 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1591 | name: "AlertAfterChangeCipherSpec", |
| 1592 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1593 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1594 | Bugs: ProtocolBugs{ |
| 1595 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1596 | }, |
| 1597 | }, |
| 1598 | shouldFail: true, |
| 1599 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1600 | }, |
| 1601 | { |
| 1602 | protocol: dtls, |
| 1603 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1604 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1605 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1606 | Bugs: ProtocolBugs{ |
| 1607 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1608 | }, |
| 1609 | }, |
| 1610 | shouldFail: true, |
| 1611 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1612 | }, |
| 1613 | { |
| 1614 | protocol: dtls, |
| 1615 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1616 | config: Config{ |
| 1617 | Bugs: ProtocolBugs{ |
| 1618 | ReorderHandshakeFragments: true, |
| 1619 | // Small enough that every handshake message is |
| 1620 | // fragmented. |
| 1621 | MaxHandshakeRecordLength: 2, |
| 1622 | }, |
| 1623 | }, |
| 1624 | }, |
| 1625 | { |
| 1626 | protocol: dtls, |
| 1627 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1628 | config: Config{ |
| 1629 | Bugs: ProtocolBugs{ |
| 1630 | ReorderHandshakeFragments: true, |
| 1631 | // Large enough that no handshake message is |
| 1632 | // fragmented. |
| 1633 | MaxHandshakeRecordLength: 2048, |
| 1634 | }, |
| 1635 | }, |
| 1636 | }, |
| 1637 | { |
| 1638 | protocol: dtls, |
| 1639 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1640 | config: Config{ |
| 1641 | Bugs: ProtocolBugs{ |
| 1642 | ReorderHandshakeFragments: true, |
| 1643 | MixCompleteMessageWithFragments: true, |
| 1644 | MaxHandshakeRecordLength: 2, |
| 1645 | }, |
| 1646 | }, |
| 1647 | }, |
| 1648 | { |
| 1649 | name: "SendInvalidRecordType", |
| 1650 | config: Config{ |
| 1651 | Bugs: ProtocolBugs{ |
| 1652 | SendInvalidRecordType: true, |
| 1653 | }, |
| 1654 | }, |
| 1655 | shouldFail: true, |
| 1656 | expectedError: ":UNEXPECTED_RECORD:", |
| 1657 | }, |
| 1658 | { |
| 1659 | protocol: dtls, |
| 1660 | name: "SendInvalidRecordType-DTLS", |
| 1661 | config: Config{ |
| 1662 | Bugs: ProtocolBugs{ |
| 1663 | SendInvalidRecordType: true, |
| 1664 | }, |
| 1665 | }, |
| 1666 | shouldFail: true, |
| 1667 | expectedError: ":UNEXPECTED_RECORD:", |
| 1668 | }, |
| 1669 | { |
| 1670 | name: "FalseStart-SkipServerSecondLeg", |
| 1671 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1672 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1673 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1674 | NextProtos: []string{"foo"}, |
| 1675 | Bugs: ProtocolBugs{ |
| 1676 | SkipNewSessionTicket: true, |
| 1677 | SkipChangeCipherSpec: true, |
| 1678 | SkipFinished: true, |
| 1679 | ExpectFalseStart: true, |
| 1680 | }, |
| 1681 | }, |
| 1682 | flags: []string{ |
| 1683 | "-false-start", |
| 1684 | "-handshake-never-done", |
| 1685 | "-advertise-alpn", "\x03foo", |
| 1686 | }, |
| 1687 | shimWritesFirst: true, |
| 1688 | shouldFail: true, |
| 1689 | expectedError: ":UNEXPECTED_RECORD:", |
| 1690 | }, |
| 1691 | { |
| 1692 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1693 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1694 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1695 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1696 | NextProtos: []string{"foo"}, |
| 1697 | Bugs: ProtocolBugs{ |
| 1698 | SkipNewSessionTicket: true, |
| 1699 | SkipChangeCipherSpec: true, |
| 1700 | SkipFinished: true, |
| 1701 | }, |
| 1702 | }, |
| 1703 | flags: []string{ |
| 1704 | "-implicit-handshake", |
| 1705 | "-false-start", |
| 1706 | "-handshake-never-done", |
| 1707 | "-advertise-alpn", "\x03foo", |
| 1708 | }, |
| 1709 | shouldFail: true, |
| 1710 | expectedError: ":UNEXPECTED_RECORD:", |
| 1711 | }, |
| 1712 | { |
| 1713 | testType: serverTest, |
| 1714 | name: "FailEarlyCallback", |
| 1715 | flags: []string{"-fail-early-callback"}, |
| 1716 | shouldFail: true, |
| 1717 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1718 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1719 | }, |
| 1720 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1721 | name: "FailCertCallback-Client-TLS12", |
| 1722 | config: Config{ |
| 1723 | MaxVersion: VersionTLS12, |
| 1724 | ClientAuth: RequestClientCert, |
| 1725 | }, |
| 1726 | flags: []string{"-fail-cert-callback"}, |
| 1727 | shouldFail: true, |
| 1728 | expectedError: ":CERT_CB_ERROR:", |
| 1729 | expectedLocalError: "remote error: internal error", |
| 1730 | }, |
| 1731 | { |
| 1732 | testType: serverTest, |
| 1733 | name: "FailCertCallback-Server-TLS12", |
| 1734 | config: Config{ |
| 1735 | MaxVersion: VersionTLS12, |
| 1736 | }, |
| 1737 | flags: []string{"-fail-cert-callback"}, |
| 1738 | shouldFail: true, |
| 1739 | expectedError: ":CERT_CB_ERROR:", |
| 1740 | expectedLocalError: "remote error: internal error", |
| 1741 | }, |
| 1742 | { |
| 1743 | name: "FailCertCallback-Client-TLS13", |
| 1744 | config: Config{ |
| 1745 | MaxVersion: VersionTLS13, |
| 1746 | ClientAuth: RequestClientCert, |
| 1747 | }, |
| 1748 | flags: []string{"-fail-cert-callback"}, |
| 1749 | shouldFail: true, |
| 1750 | expectedError: ":CERT_CB_ERROR:", |
| 1751 | expectedLocalError: "remote error: internal error", |
| 1752 | }, |
| 1753 | { |
| 1754 | testType: serverTest, |
| 1755 | name: "FailCertCallback-Server-TLS13", |
| 1756 | config: Config{ |
| 1757 | MaxVersion: VersionTLS13, |
| 1758 | }, |
| 1759 | flags: []string{"-fail-cert-callback"}, |
| 1760 | shouldFail: true, |
| 1761 | expectedError: ":CERT_CB_ERROR:", |
| 1762 | expectedLocalError: "remote error: internal error", |
| 1763 | }, |
| 1764 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1765 | protocol: dtls, |
| 1766 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1767 | config: Config{ |
| 1768 | Bugs: ProtocolBugs{ |
| 1769 | MaxHandshakeRecordLength: 2, |
| 1770 | FragmentMessageTypeMismatch: true, |
| 1771 | }, |
| 1772 | }, |
| 1773 | shouldFail: true, |
| 1774 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1775 | }, |
| 1776 | { |
| 1777 | protocol: dtls, |
| 1778 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1779 | config: Config{ |
| 1780 | Bugs: ProtocolBugs{ |
| 1781 | MaxHandshakeRecordLength: 2, |
| 1782 | FragmentMessageLengthMismatch: true, |
| 1783 | }, |
| 1784 | }, |
| 1785 | shouldFail: true, |
| 1786 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1787 | }, |
| 1788 | { |
| 1789 | protocol: dtls, |
| 1790 | name: "SplitFragments-Header-DTLS", |
| 1791 | config: Config{ |
| 1792 | Bugs: ProtocolBugs{ |
| 1793 | SplitFragments: 2, |
| 1794 | }, |
| 1795 | }, |
| 1796 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1797 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1798 | }, |
| 1799 | { |
| 1800 | protocol: dtls, |
| 1801 | name: "SplitFragments-Boundary-DTLS", |
| 1802 | config: Config{ |
| 1803 | Bugs: ProtocolBugs{ |
| 1804 | SplitFragments: dtlsRecordHeaderLen, |
| 1805 | }, |
| 1806 | }, |
| 1807 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1808 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1809 | }, |
| 1810 | { |
| 1811 | protocol: dtls, |
| 1812 | name: "SplitFragments-Body-DTLS", |
| 1813 | config: Config{ |
| 1814 | Bugs: ProtocolBugs{ |
| 1815 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1816 | }, |
| 1817 | }, |
| 1818 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1819 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1820 | }, |
| 1821 | { |
| 1822 | protocol: dtls, |
| 1823 | name: "SendEmptyFragments-DTLS", |
| 1824 | config: Config{ |
| 1825 | Bugs: ProtocolBugs{ |
| 1826 | SendEmptyFragments: true, |
| 1827 | }, |
| 1828 | }, |
| 1829 | }, |
| 1830 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1831 | name: "BadFinished-Client", |
| 1832 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1833 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1834 | Bugs: ProtocolBugs{ |
| 1835 | BadFinished: true, |
| 1836 | }, |
| 1837 | }, |
| 1838 | shouldFail: true, |
| 1839 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1840 | }, |
| 1841 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1842 | name: "BadFinished-Client-TLS13", |
| 1843 | config: Config{ |
| 1844 | MaxVersion: VersionTLS13, |
| 1845 | Bugs: ProtocolBugs{ |
| 1846 | BadFinished: true, |
| 1847 | }, |
| 1848 | }, |
| 1849 | shouldFail: true, |
| 1850 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1851 | }, |
| 1852 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1853 | testType: serverTest, |
| 1854 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1855 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1856 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1857 | Bugs: ProtocolBugs{ |
| 1858 | BadFinished: true, |
| 1859 | }, |
| 1860 | }, |
| 1861 | shouldFail: true, |
| 1862 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1863 | }, |
| 1864 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1865 | testType: serverTest, |
| 1866 | name: "BadFinished-Server-TLS13", |
| 1867 | config: Config{ |
| 1868 | MaxVersion: VersionTLS13, |
| 1869 | Bugs: ProtocolBugs{ |
| 1870 | BadFinished: true, |
| 1871 | }, |
| 1872 | }, |
| 1873 | shouldFail: true, |
| 1874 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1875 | }, |
| 1876 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1877 | name: "FalseStart-BadFinished", |
| 1878 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1879 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1880 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1881 | NextProtos: []string{"foo"}, |
| 1882 | Bugs: ProtocolBugs{ |
| 1883 | BadFinished: true, |
| 1884 | ExpectFalseStart: true, |
| 1885 | }, |
| 1886 | }, |
| 1887 | flags: []string{ |
| 1888 | "-false-start", |
| 1889 | "-handshake-never-done", |
| 1890 | "-advertise-alpn", "\x03foo", |
| 1891 | }, |
| 1892 | shimWritesFirst: true, |
| 1893 | shouldFail: true, |
| 1894 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1895 | }, |
| 1896 | { |
| 1897 | name: "NoFalseStart-NoALPN", |
| 1898 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1899 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1900 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1901 | Bugs: ProtocolBugs{ |
| 1902 | ExpectFalseStart: true, |
| 1903 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1904 | }, |
| 1905 | }, |
| 1906 | flags: []string{ |
| 1907 | "-false-start", |
| 1908 | }, |
| 1909 | shimWritesFirst: true, |
| 1910 | shouldFail: true, |
| 1911 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1912 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1913 | }, |
| 1914 | { |
| 1915 | name: "NoFalseStart-NoAEAD", |
| 1916 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1917 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1918 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1919 | NextProtos: []string{"foo"}, |
| 1920 | Bugs: ProtocolBugs{ |
| 1921 | ExpectFalseStart: true, |
| 1922 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1923 | }, |
| 1924 | }, |
| 1925 | flags: []string{ |
| 1926 | "-false-start", |
| 1927 | "-advertise-alpn", "\x03foo", |
| 1928 | }, |
| 1929 | shimWritesFirst: true, |
| 1930 | shouldFail: true, |
| 1931 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1932 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1933 | }, |
| 1934 | { |
| 1935 | name: "NoFalseStart-RSA", |
| 1936 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1937 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1938 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1939 | NextProtos: []string{"foo"}, |
| 1940 | Bugs: ProtocolBugs{ |
| 1941 | ExpectFalseStart: true, |
| 1942 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1943 | }, |
| 1944 | }, |
| 1945 | flags: []string{ |
| 1946 | "-false-start", |
| 1947 | "-advertise-alpn", "\x03foo", |
| 1948 | }, |
| 1949 | shimWritesFirst: true, |
| 1950 | shouldFail: true, |
| 1951 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1952 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1953 | }, |
| 1954 | { |
| 1955 | name: "NoFalseStart-DHE_RSA", |
| 1956 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1957 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1958 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1959 | NextProtos: []string{"foo"}, |
| 1960 | Bugs: ProtocolBugs{ |
| 1961 | ExpectFalseStart: true, |
| 1962 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1963 | }, |
| 1964 | }, |
| 1965 | flags: []string{ |
| 1966 | "-false-start", |
| 1967 | "-advertise-alpn", "\x03foo", |
| 1968 | }, |
| 1969 | shimWritesFirst: true, |
| 1970 | shouldFail: true, |
| 1971 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1972 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1973 | }, |
| 1974 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1975 | protocol: dtls, |
| 1976 | name: "SendSplitAlert-Sync", |
| 1977 | config: Config{ |
| 1978 | Bugs: ProtocolBugs{ |
| 1979 | SendSplitAlert: true, |
| 1980 | }, |
| 1981 | }, |
| 1982 | }, |
| 1983 | { |
| 1984 | protocol: dtls, |
| 1985 | name: "SendSplitAlert-Async", |
| 1986 | config: Config{ |
| 1987 | Bugs: ProtocolBugs{ |
| 1988 | SendSplitAlert: true, |
| 1989 | }, |
| 1990 | }, |
| 1991 | flags: []string{"-async"}, |
| 1992 | }, |
| 1993 | { |
| 1994 | protocol: dtls, |
| 1995 | name: "PackDTLSHandshake", |
| 1996 | config: Config{ |
| 1997 | Bugs: ProtocolBugs{ |
| 1998 | MaxHandshakeRecordLength: 2, |
| 1999 | PackHandshakeFragments: 20, |
| 2000 | PackHandshakeRecords: 200, |
| 2001 | }, |
| 2002 | }, |
| 2003 | }, |
| 2004 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2005 | name: "SendEmptyRecords-Pass", |
| 2006 | sendEmptyRecords: 32, |
| 2007 | }, |
| 2008 | { |
| 2009 | name: "SendEmptyRecords", |
| 2010 | sendEmptyRecords: 33, |
| 2011 | shouldFail: true, |
| 2012 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2013 | }, |
| 2014 | { |
| 2015 | name: "SendEmptyRecords-Async", |
| 2016 | sendEmptyRecords: 33, |
| 2017 | flags: []string{"-async"}, |
| 2018 | shouldFail: true, |
| 2019 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2020 | }, |
| 2021 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2022 | name: "SendWarningAlerts-Pass", |
| 2023 | config: Config{ |
| 2024 | MaxVersion: VersionTLS12, |
| 2025 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2026 | sendWarningAlerts: 4, |
| 2027 | }, |
| 2028 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2029 | protocol: dtls, |
| 2030 | name: "SendWarningAlerts-DTLS-Pass", |
| 2031 | config: Config{ |
| 2032 | MaxVersion: VersionTLS12, |
| 2033 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2034 | sendWarningAlerts: 4, |
| 2035 | }, |
| 2036 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2037 | name: "SendWarningAlerts-TLS13", |
| 2038 | config: Config{ |
| 2039 | MaxVersion: VersionTLS13, |
| 2040 | }, |
| 2041 | sendWarningAlerts: 4, |
| 2042 | shouldFail: true, |
| 2043 | expectedError: ":BAD_ALERT:", |
| 2044 | expectedLocalError: "remote error: error decoding message", |
| 2045 | }, |
| 2046 | { |
| 2047 | name: "SendWarningAlerts", |
| 2048 | config: Config{ |
| 2049 | MaxVersion: VersionTLS12, |
| 2050 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2051 | sendWarningAlerts: 5, |
| 2052 | shouldFail: true, |
| 2053 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2054 | }, |
| 2055 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2056 | name: "SendWarningAlerts-Async", |
| 2057 | config: Config{ |
| 2058 | MaxVersion: VersionTLS12, |
| 2059 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2060 | sendWarningAlerts: 5, |
| 2061 | flags: []string{"-async"}, |
| 2062 | shouldFail: true, |
| 2063 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2064 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2065 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2066 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2067 | config: Config{ |
| 2068 | MaxVersion: VersionTLS13, |
| 2069 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2070 | sendKeyUpdates: 33, |
| 2071 | keyUpdateRequest: keyUpdateNotRequested, |
| 2072 | shouldFail: true, |
| 2073 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2074 | }, |
| 2075 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2076 | name: "EmptySessionID", |
| 2077 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2078 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2079 | SessionTicketsDisabled: true, |
| 2080 | }, |
| 2081 | noSessionCache: true, |
| 2082 | flags: []string{"-expect-no-session"}, |
| 2083 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2084 | { |
| 2085 | name: "Unclean-Shutdown", |
| 2086 | config: Config{ |
| 2087 | Bugs: ProtocolBugs{ |
| 2088 | NoCloseNotify: true, |
| 2089 | ExpectCloseNotify: true, |
| 2090 | }, |
| 2091 | }, |
| 2092 | shimShutsDown: true, |
| 2093 | flags: []string{"-check-close-notify"}, |
| 2094 | shouldFail: true, |
| 2095 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2096 | }, |
| 2097 | { |
| 2098 | name: "Unclean-Shutdown-Ignored", |
| 2099 | config: Config{ |
| 2100 | Bugs: ProtocolBugs{ |
| 2101 | NoCloseNotify: true, |
| 2102 | }, |
| 2103 | }, |
| 2104 | shimShutsDown: true, |
| 2105 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2106 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2107 | name: "Unclean-Shutdown-Alert", |
| 2108 | config: Config{ |
| 2109 | Bugs: ProtocolBugs{ |
| 2110 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2111 | ExpectCloseNotify: true, |
| 2112 | }, |
| 2113 | }, |
| 2114 | shimShutsDown: true, |
| 2115 | flags: []string{"-check-close-notify"}, |
| 2116 | shouldFail: true, |
| 2117 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2118 | }, |
| 2119 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2120 | name: "LargePlaintext", |
| 2121 | config: Config{ |
| 2122 | Bugs: ProtocolBugs{ |
| 2123 | SendLargeRecords: true, |
| 2124 | }, |
| 2125 | }, |
| 2126 | messageLen: maxPlaintext + 1, |
| 2127 | shouldFail: true, |
| 2128 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2129 | }, |
| 2130 | { |
| 2131 | protocol: dtls, |
| 2132 | name: "LargePlaintext-DTLS", |
| 2133 | config: Config{ |
| 2134 | Bugs: ProtocolBugs{ |
| 2135 | SendLargeRecords: true, |
| 2136 | }, |
| 2137 | }, |
| 2138 | messageLen: maxPlaintext + 1, |
| 2139 | shouldFail: true, |
| 2140 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2141 | }, |
| 2142 | { |
| 2143 | name: "LargeCiphertext", |
| 2144 | config: Config{ |
| 2145 | Bugs: ProtocolBugs{ |
| 2146 | SendLargeRecords: true, |
| 2147 | }, |
| 2148 | }, |
| 2149 | messageLen: maxPlaintext * 2, |
| 2150 | shouldFail: true, |
| 2151 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2152 | }, |
| 2153 | { |
| 2154 | protocol: dtls, |
| 2155 | name: "LargeCiphertext-DTLS", |
| 2156 | config: Config{ |
| 2157 | Bugs: ProtocolBugs{ |
| 2158 | SendLargeRecords: true, |
| 2159 | }, |
| 2160 | }, |
| 2161 | messageLen: maxPlaintext * 2, |
| 2162 | // Unlike the other four cases, DTLS drops records which |
| 2163 | // are invalid before authentication, so the connection |
| 2164 | // does not fail. |
| 2165 | expectMessageDropped: true, |
| 2166 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2167 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2168 | name: "BadHelloRequest-1", |
| 2169 | renegotiate: 1, |
| 2170 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2171 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2172 | Bugs: ProtocolBugs{ |
| 2173 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2174 | }, |
| 2175 | }, |
| 2176 | flags: []string{ |
| 2177 | "-renegotiate-freely", |
| 2178 | "-expect-total-renegotiations", "1", |
| 2179 | }, |
| 2180 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2181 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2182 | }, |
| 2183 | { |
| 2184 | name: "BadHelloRequest-2", |
| 2185 | renegotiate: 1, |
| 2186 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2187 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2188 | Bugs: ProtocolBugs{ |
| 2189 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2190 | }, |
| 2191 | }, |
| 2192 | flags: []string{ |
| 2193 | "-renegotiate-freely", |
| 2194 | "-expect-total-renegotiations", "1", |
| 2195 | }, |
| 2196 | shouldFail: true, |
| 2197 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2198 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2199 | { |
| 2200 | testType: serverTest, |
| 2201 | name: "SupportTicketsWithSessionID", |
| 2202 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2203 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2204 | SessionTicketsDisabled: true, |
| 2205 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2206 | resumeConfig: &Config{ |
| 2207 | MaxVersion: VersionTLS12, |
| 2208 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2209 | resumeSession: true, |
| 2210 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2211 | { |
| 2212 | protocol: dtls, |
| 2213 | name: "DTLS-SendExtraFinished", |
| 2214 | config: Config{ |
| 2215 | Bugs: ProtocolBugs{ |
| 2216 | SendExtraFinished: true, |
| 2217 | }, |
| 2218 | }, |
| 2219 | shouldFail: true, |
| 2220 | expectedError: ":UNEXPECTED_RECORD:", |
| 2221 | }, |
| 2222 | { |
| 2223 | protocol: dtls, |
| 2224 | name: "DTLS-SendExtraFinished-Reordered", |
| 2225 | config: Config{ |
| 2226 | Bugs: ProtocolBugs{ |
| 2227 | MaxHandshakeRecordLength: 2, |
| 2228 | ReorderHandshakeFragments: true, |
| 2229 | SendExtraFinished: true, |
| 2230 | }, |
| 2231 | }, |
| 2232 | shouldFail: true, |
| 2233 | expectedError: ":UNEXPECTED_RECORD:", |
| 2234 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2235 | { |
| 2236 | testType: serverTest, |
| 2237 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2238 | config: Config{ |
| 2239 | // Choose a cipher suite that does not involve |
| 2240 | // elliptic curves, so no extensions are |
| 2241 | // involved. |
| 2242 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2243 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2244 | Bugs: ProtocolBugs{ |
| 2245 | SendV2ClientHello: true, |
| 2246 | }, |
| 2247 | }, |
| 2248 | sendPrefix: string([]byte{ |
| 2249 | byte(recordTypeHandshake), |
| 2250 | 3, 1, // version |
| 2251 | 0, 0, // length |
| 2252 | }), |
| 2253 | // A no-op empty record may not be sent before V2ClientHello. |
| 2254 | shouldFail: true, |
| 2255 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2256 | }, |
| 2257 | { |
| 2258 | testType: serverTest, |
| 2259 | name: "V2ClientHello-WarningAlertPrefix", |
| 2260 | config: Config{ |
| 2261 | // Choose a cipher suite that does not involve |
| 2262 | // elliptic curves, so no extensions are |
| 2263 | // involved. |
| 2264 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2265 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2266 | Bugs: ProtocolBugs{ |
| 2267 | SendV2ClientHello: true, |
| 2268 | }, |
| 2269 | }, |
| 2270 | sendPrefix: string([]byte{ |
| 2271 | byte(recordTypeAlert), |
| 2272 | 3, 1, // version |
| 2273 | 0, 2, // length |
| 2274 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2275 | }), |
| 2276 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2277 | shouldFail: true, |
| 2278 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2279 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2280 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2281 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2282 | config: Config{ |
| 2283 | MaxVersion: VersionTLS13, |
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 | sendKeyUpdates: 1, |
| 2286 | keyUpdateRequest: keyUpdateNotRequested, |
| 2287 | }, |
| 2288 | { |
| 2289 | name: "KeyUpdate-InvalidRequestMode", |
| 2290 | config: Config{ |
| 2291 | MaxVersion: VersionTLS13, |
| 2292 | }, |
| 2293 | sendKeyUpdates: 1, |
| 2294 | keyUpdateRequest: 42, |
| 2295 | shouldFail: true, |
| 2296 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2297 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2298 | { |
| 2299 | name: "SendSNIWarningAlert", |
| 2300 | config: Config{ |
| 2301 | MaxVersion: VersionTLS12, |
| 2302 | Bugs: ProtocolBugs{ |
| 2303 | SendSNIWarningAlert: true, |
| 2304 | }, |
| 2305 | }, |
| 2306 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2307 | { |
| 2308 | testType: serverTest, |
| 2309 | name: "ExtraCompressionMethods-TLS12", |
| 2310 | config: Config{ |
| 2311 | MaxVersion: VersionTLS12, |
| 2312 | Bugs: ProtocolBugs{ |
| 2313 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2314 | }, |
| 2315 | }, |
| 2316 | }, |
| 2317 | { |
| 2318 | testType: serverTest, |
| 2319 | name: "ExtraCompressionMethods-TLS13", |
| 2320 | config: Config{ |
| 2321 | MaxVersion: VersionTLS13, |
| 2322 | Bugs: ProtocolBugs{ |
| 2323 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2324 | }, |
| 2325 | }, |
| 2326 | shouldFail: true, |
| 2327 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2328 | expectedLocalError: "remote error: illegal parameter", |
| 2329 | }, |
| 2330 | { |
| 2331 | testType: serverTest, |
| 2332 | name: "NoNullCompression-TLS12", |
| 2333 | config: Config{ |
| 2334 | MaxVersion: VersionTLS12, |
| 2335 | Bugs: ProtocolBugs{ |
| 2336 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2337 | }, |
| 2338 | }, |
| 2339 | shouldFail: true, |
| 2340 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2341 | expectedLocalError: "remote error: illegal parameter", |
| 2342 | }, |
| 2343 | { |
| 2344 | testType: serverTest, |
| 2345 | name: "NoNullCompression-TLS13", |
| 2346 | config: Config{ |
| 2347 | MaxVersion: VersionTLS13, |
| 2348 | Bugs: ProtocolBugs{ |
| 2349 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2350 | }, |
| 2351 | }, |
| 2352 | shouldFail: true, |
| 2353 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2354 | expectedLocalError: "remote error: illegal parameter", |
| 2355 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2356 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2357 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2358 | config: Config{ |
| 2359 | MaxVersion: VersionTLS12, |
| 2360 | Bugs: ProtocolBugs{ |
| 2361 | ExpectGREASE: true, |
| 2362 | }, |
| 2363 | }, |
| 2364 | flags: []string{"-enable-grease"}, |
| 2365 | }, |
| 2366 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2367 | name: "GREASE-Client-TLS13", |
| 2368 | config: Config{ |
| 2369 | MaxVersion: VersionTLS13, |
| 2370 | Bugs: ProtocolBugs{ |
| 2371 | ExpectGREASE: true, |
| 2372 | }, |
| 2373 | }, |
| 2374 | flags: []string{"-enable-grease"}, |
| 2375 | }, |
| 2376 | { |
| 2377 | testType: serverTest, |
| 2378 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2379 | config: Config{ |
| 2380 | MaxVersion: VersionTLS13, |
| 2381 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2382 | // TLS 1.3 servers are expected to |
| 2383 | // always enable GREASE. TLS 1.3 is new, |
| 2384 | // so there is no existing ecosystem to |
| 2385 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2386 | ExpectGREASE: true, |
| 2387 | }, |
| 2388 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2389 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2390 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2391 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2392 | |
| 2393 | // Test that very large messages can be received. |
| 2394 | cert := rsaCertificate |
| 2395 | for i := 0; i < 50; i++ { |
| 2396 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2397 | } |
| 2398 | testCases = append(testCases, testCase{ |
| 2399 | name: "LargeMessage", |
| 2400 | config: Config{ |
| 2401 | Certificates: []Certificate{cert}, |
| 2402 | }, |
| 2403 | }) |
| 2404 | testCases = append(testCases, testCase{ |
| 2405 | protocol: dtls, |
| 2406 | name: "LargeMessage-DTLS", |
| 2407 | config: Config{ |
| 2408 | Certificates: []Certificate{cert}, |
| 2409 | }, |
| 2410 | }) |
| 2411 | |
| 2412 | // They are rejected if the maximum certificate chain length is capped. |
| 2413 | testCases = append(testCases, testCase{ |
| 2414 | name: "LargeMessage-Reject", |
| 2415 | config: Config{ |
| 2416 | Certificates: []Certificate{cert}, |
| 2417 | }, |
| 2418 | flags: []string{"-max-cert-list", "16384"}, |
| 2419 | shouldFail: true, |
| 2420 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2421 | }) |
| 2422 | testCases = append(testCases, testCase{ |
| 2423 | protocol: dtls, |
| 2424 | name: "LargeMessage-Reject-DTLS", |
| 2425 | config: Config{ |
| 2426 | Certificates: []Certificate{cert}, |
| 2427 | }, |
| 2428 | flags: []string{"-max-cert-list", "16384"}, |
| 2429 | shouldFail: true, |
| 2430 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2431 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2432 | } |
| 2433 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2434 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2435 | const bogusCipher = 0xfe00 |
| 2436 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2437 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2438 | const psk = "12345" |
| 2439 | const pskIdentity = "luggage combo" |
| 2440 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2441 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2442 | var certFile string |
| 2443 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2444 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2445 | cert = ecdsaP256Certificate |
| 2446 | certFile = ecdsaP256CertificateFile |
| 2447 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2448 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2449 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2450 | certFile = rsaCertificateFile |
| 2451 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2452 | } |
| 2453 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2454 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2455 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2456 | flags = append(flags, |
| 2457 | "-psk", psk, |
| 2458 | "-psk-identity", pskIdentity) |
| 2459 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2460 | if hasComponent(suite.name, "NULL") { |
| 2461 | // NULL ciphers must be explicitly enabled. |
| 2462 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2463 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2464 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2465 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2466 | // for now. |
| 2467 | flags = append(flags, "-cipher", suite.name) |
| 2468 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2469 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2470 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2471 | for _, protocol := range []protocol{tls, dtls} { |
| 2472 | var prefix string |
| 2473 | if protocol == dtls { |
| 2474 | if !ver.hasDTLS { |
| 2475 | continue |
| 2476 | } |
| 2477 | prefix = "D" |
| 2478 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2479 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2480 | var shouldServerFail, shouldClientFail bool |
| 2481 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2482 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2483 | // a BoringSSL server will never select it |
| 2484 | // because the extension is missing. |
| 2485 | shouldServerFail = true |
| 2486 | } |
| 2487 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2488 | shouldClientFail = true |
| 2489 | shouldServerFail = true |
| 2490 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2491 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2492 | shouldClientFail = true |
| 2493 | shouldServerFail = true |
| 2494 | } |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2495 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2496 | shouldClientFail = true |
| 2497 | shouldServerFail = true |
| 2498 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2499 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2500 | shouldClientFail = true |
| 2501 | shouldServerFail = true |
| 2502 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2503 | |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2504 | var sendCipherSuite uint16 |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2505 | var expectedServerError, expectedClientError string |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2506 | serverCipherSuites := []uint16{suite.id} |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2507 | if shouldServerFail { |
| 2508 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2509 | } |
| 2510 | if shouldClientFail { |
| 2511 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2512 | // Configure the server to select ciphers as normal but |
| 2513 | // select an incompatible cipher in ServerHello. |
| 2514 | serverCipherSuites = nil |
| 2515 | sendCipherSuite = suite.id |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2516 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2517 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2518 | testCases = append(testCases, testCase{ |
| 2519 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2520 | protocol: protocol, |
| 2521 | |
| 2522 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2523 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2524 | MinVersion: ver.version, |
| 2525 | MaxVersion: ver.version, |
| 2526 | CipherSuites: []uint16{suite.id}, |
| 2527 | Certificates: []Certificate{cert}, |
| 2528 | PreSharedKey: []byte(psk), |
| 2529 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2530 | Bugs: ProtocolBugs{ |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2531 | AdvertiseAllConfiguredCiphers: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2532 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2533 | }, |
| 2534 | certFile: certFile, |
| 2535 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2536 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2537 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2538 | shouldFail: shouldServerFail, |
| 2539 | expectedError: expectedServerError, |
| 2540 | }) |
| 2541 | |
| 2542 | testCases = append(testCases, testCase{ |
| 2543 | testType: clientTest, |
| 2544 | protocol: protocol, |
| 2545 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2546 | config: Config{ |
| 2547 | MinVersion: ver.version, |
| 2548 | MaxVersion: ver.version, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2549 | CipherSuites: serverCipherSuites, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2550 | Certificates: []Certificate{cert}, |
| 2551 | PreSharedKey: []byte(psk), |
| 2552 | PreSharedKeyIdentity: pskIdentity, |
| 2553 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2554 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2555 | SendCipherSuite: sendCipherSuite, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2556 | }, |
| 2557 | }, |
| 2558 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2559 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2560 | shouldFail: shouldClientFail, |
| 2561 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2562 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2563 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2564 | if !shouldClientFail { |
| 2565 | // Ensure the maximum record size is accepted. |
| 2566 | testCases = append(testCases, testCase{ |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2567 | protocol: protocol, |
| 2568 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2569 | config: Config{ |
| 2570 | MinVersion: ver.version, |
| 2571 | MaxVersion: ver.version, |
| 2572 | CipherSuites: []uint16{suite.id}, |
| 2573 | Certificates: []Certificate{cert}, |
| 2574 | PreSharedKey: []byte(psk), |
| 2575 | PreSharedKeyIdentity: pskIdentity, |
| 2576 | }, |
| 2577 | flags: flags, |
| 2578 | messageLen: maxPlaintext, |
| 2579 | }) |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2580 | |
| 2581 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2582 | // and ignored in DTLS. |
| 2583 | var shouldFail bool |
| 2584 | var expectedError string |
| 2585 | if protocol == tls { |
| 2586 | shouldFail = true |
| 2587 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2588 | } |
| 2589 | |
| 2590 | testCases = append(testCases, testCase{ |
| 2591 | protocol: protocol, |
| 2592 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2593 | config: Config{ |
| 2594 | MinVersion: ver.version, |
| 2595 | MaxVersion: ver.version, |
| 2596 | CipherSuites: []uint16{suite.id}, |
| 2597 | Certificates: []Certificate{cert}, |
| 2598 | PreSharedKey: []byte(psk), |
| 2599 | PreSharedKeyIdentity: pskIdentity, |
| 2600 | }, |
| 2601 | flags: flags, |
| 2602 | damageFirstWrite: true, |
| 2603 | messageLen: maxPlaintext, |
| 2604 | shouldFail: shouldFail, |
| 2605 | expectedError: expectedError, |
| 2606 | }) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2607 | } |
| 2608 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2609 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2610 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2611 | |
| 2612 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2613 | name: "NoSharedCipher", |
| 2614 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2615 | MaxVersion: VersionTLS12, |
| 2616 | CipherSuites: []uint16{}, |
| 2617 | }, |
| 2618 | shouldFail: true, |
| 2619 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2620 | }) |
| 2621 | |
| 2622 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2623 | name: "NoSharedCipher-TLS13", |
| 2624 | config: Config{ |
| 2625 | MaxVersion: VersionTLS13, |
| 2626 | CipherSuites: []uint16{}, |
| 2627 | }, |
| 2628 | shouldFail: true, |
| 2629 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2630 | }) |
| 2631 | |
| 2632 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2633 | name: "UnsupportedCipherSuite", |
| 2634 | config: Config{ |
| 2635 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2636 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2637 | Bugs: ProtocolBugs{ |
| 2638 | IgnorePeerCipherPreferences: true, |
| 2639 | }, |
| 2640 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2641 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2642 | shouldFail: true, |
| 2643 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2644 | }) |
| 2645 | |
| 2646 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2647 | name: "ServerHelloBogusCipher", |
| 2648 | config: Config{ |
| 2649 | MaxVersion: VersionTLS12, |
| 2650 | Bugs: ProtocolBugs{ |
| 2651 | SendCipherSuite: bogusCipher, |
| 2652 | }, |
| 2653 | }, |
| 2654 | shouldFail: true, |
| 2655 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2656 | }) |
| 2657 | testCases = append(testCases, testCase{ |
| 2658 | name: "ServerHelloBogusCipher-TLS13", |
| 2659 | config: Config{ |
| 2660 | MaxVersion: VersionTLS13, |
| 2661 | Bugs: ProtocolBugs{ |
| 2662 | SendCipherSuite: bogusCipher, |
| 2663 | }, |
| 2664 | }, |
| 2665 | shouldFail: true, |
| 2666 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2667 | }) |
| 2668 | |
| 2669 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2670 | name: "WeakDH", |
| 2671 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2672 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2673 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2674 | Bugs: ProtocolBugs{ |
| 2675 | // This is a 1023-bit prime number, generated |
| 2676 | // with: |
| 2677 | // openssl gendh 1023 | openssl asn1parse -i |
| 2678 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2679 | }, |
| 2680 | }, |
| 2681 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2682 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2683 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2684 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2685 | testCases = append(testCases, testCase{ |
| 2686 | name: "SillyDH", |
| 2687 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2688 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2689 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2690 | Bugs: ProtocolBugs{ |
| 2691 | // This is a 4097-bit prime number, generated |
| 2692 | // with: |
| 2693 | // openssl gendh 4097 | openssl asn1parse -i |
| 2694 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2695 | }, |
| 2696 | }, |
| 2697 | shouldFail: true, |
| 2698 | expectedError: ":DH_P_TOO_LONG:", |
| 2699 | }) |
| 2700 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2701 | // This test ensures that Diffie-Hellman public values are padded with |
| 2702 | // zeros so that they're the same length as the prime. This is to avoid |
| 2703 | // hitting a bug in yaSSL. |
| 2704 | testCases = append(testCases, testCase{ |
| 2705 | testType: serverTest, |
| 2706 | name: "DHPublicValuePadded", |
| 2707 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2708 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2709 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2710 | Bugs: ProtocolBugs{ |
| 2711 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2712 | }, |
| 2713 | }, |
| 2714 | flags: []string{"-use-sparse-dh-prime"}, |
| 2715 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2716 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2717 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2718 | testCases = append(testCases, testCase{ |
| 2719 | testType: serverTest, |
| 2720 | name: "UnknownCipher", |
| 2721 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2722 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2723 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2724 | Bugs: ProtocolBugs{ |
| 2725 | AdvertiseAllConfiguredCiphers: true, |
| 2726 | }, |
| 2727 | }, |
| 2728 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2729 | |
| 2730 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2731 | testCases = append(testCases, testCase{ |
| 2732 | testType: serverTest, |
| 2733 | name: "UnknownCipher-TLS13", |
| 2734 | config: Config{ |
| 2735 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2736 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2737 | Bugs: ProtocolBugs{ |
| 2738 | AdvertiseAllConfiguredCiphers: true, |
| 2739 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2740 | }, |
| 2741 | }) |
| 2742 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2743 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2744 | testCases = append(testCases, testCase{ |
| 2745 | name: "EmptyECDHEPSKHint", |
| 2746 | config: Config{ |
| 2747 | MaxVersion: VersionTLS12, |
| 2748 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2749 | PreSharedKey: []byte("secret"), |
| 2750 | }, |
| 2751 | flags: []string{"-psk", "secret"}, |
| 2752 | }) |
| 2753 | |
| 2754 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2755 | // ServerKeyExchange is sent. |
| 2756 | testCases = append(testCases, testCase{ |
| 2757 | name: "ExplicitEmptyPSKHint", |
| 2758 | config: Config{ |
| 2759 | MaxVersion: VersionTLS12, |
| 2760 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2761 | PreSharedKey: []byte("secret"), |
| 2762 | Bugs: ProtocolBugs{ |
| 2763 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2764 | }, |
| 2765 | }, |
| 2766 | flags: []string{"-psk", "secret"}, |
| 2767 | }) |
| 2768 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2769 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2770 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2771 | // cipher lists and then a connection is made for each member of |
| 2772 | // expectations. The cipher suite that the server selects must match |
| 2773 | // the specified one. |
| 2774 | var versionSpecificCiphersTest = []struct { |
| 2775 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2776 | // expectations is a map from TLS version to cipher suite id. |
| 2777 | expectations map[uint16]uint16 |
| 2778 | }{ |
| 2779 | { |
| 2780 | // Test that the null case (where no version-specific ciphers are set) |
| 2781 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2782 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2783 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2784 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2785 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2786 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2787 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2788 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2789 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2790 | }, |
| 2791 | }, |
| 2792 | { |
| 2793 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2794 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2795 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2796 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2797 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2798 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2799 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2800 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2801 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2802 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2803 | }, |
| 2804 | }, |
| 2805 | { |
| 2806 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2807 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2808 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2809 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2810 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2811 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2812 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2813 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2814 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2815 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2816 | }, |
| 2817 | }, |
| 2818 | { |
| 2819 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2820 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2821 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2822 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2823 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2824 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2825 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2826 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2827 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2828 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2829 | }, |
| 2830 | }, |
| 2831 | } |
| 2832 | |
| 2833 | for i, test := range versionSpecificCiphersTest { |
| 2834 | for version, expectedCipherSuite := range test.expectations { |
| 2835 | flags := []string{"-cipher", test.ciphersDefault} |
| 2836 | if len(test.ciphersTLS10) > 0 { |
| 2837 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2838 | } |
| 2839 | if len(test.ciphersTLS11) > 0 { |
| 2840 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2841 | } |
| 2842 | |
| 2843 | testCases = append(testCases, testCase{ |
| 2844 | testType: serverTest, |
| 2845 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2846 | config: Config{ |
| 2847 | MaxVersion: version, |
| 2848 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2849 | 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] | 2850 | }, |
| 2851 | flags: flags, |
| 2852 | expectedCipher: expectedCipherSuite, |
| 2853 | }) |
| 2854 | } |
| 2855 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2856 | } |
| 2857 | |
| 2858 | func addBadECDSASignatureTests() { |
| 2859 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2860 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2861 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2862 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2863 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2864 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2865 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2866 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2867 | Bugs: ProtocolBugs{ |
| 2868 | BadECDSAR: badR, |
| 2869 | BadECDSAS: badS, |
| 2870 | }, |
| 2871 | }, |
| 2872 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2873 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2874 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2875 | testCases = append(testCases, testCase{ |
| 2876 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2877 | config: Config{ |
| 2878 | MaxVersion: VersionTLS13, |
| 2879 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2880 | Bugs: ProtocolBugs{ |
| 2881 | BadECDSAR: badR, |
| 2882 | BadECDSAS: badS, |
| 2883 | }, |
| 2884 | }, |
| 2885 | shouldFail: true, |
| 2886 | expectedError: ":BAD_SIGNATURE:", |
| 2887 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2888 | } |
| 2889 | } |
| 2890 | } |
| 2891 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2892 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2893 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2894 | name: "MaxCBCPadding", |
| 2895 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2896 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2897 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2898 | Bugs: ProtocolBugs{ |
| 2899 | MaxPadding: true, |
| 2900 | }, |
| 2901 | }, |
| 2902 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2903 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2904 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2905 | name: "BadCBCPadding", |
| 2906 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2907 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2908 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2909 | Bugs: ProtocolBugs{ |
| 2910 | PaddingFirstByteBad: true, |
| 2911 | }, |
| 2912 | }, |
| 2913 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2914 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2915 | }) |
| 2916 | // OpenSSL previously had an issue where the first byte of padding in |
| 2917 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2918 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2919 | name: "BadCBCPadding255", |
| 2920 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2921 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2922 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2923 | Bugs: ProtocolBugs{ |
| 2924 | MaxPadding: true, |
| 2925 | PaddingFirstByteBadIf255: true, |
| 2926 | }, |
| 2927 | }, |
| 2928 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2929 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2930 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2931 | }) |
| 2932 | } |
| 2933 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2934 | func addCBCSplittingTests() { |
| 2935 | testCases = append(testCases, testCase{ |
| 2936 | name: "CBCRecordSplitting", |
| 2937 | config: Config{ |
| 2938 | MaxVersion: VersionTLS10, |
| 2939 | MinVersion: VersionTLS10, |
| 2940 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2941 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2942 | messageLen: -1, // read until EOF |
| 2943 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2944 | flags: []string{ |
| 2945 | "-async", |
| 2946 | "-write-different-record-sizes", |
| 2947 | "-cbc-record-splitting", |
| 2948 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2949 | }) |
| 2950 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2951 | name: "CBCRecordSplittingPartialWrite", |
| 2952 | config: Config{ |
| 2953 | MaxVersion: VersionTLS10, |
| 2954 | MinVersion: VersionTLS10, |
| 2955 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2956 | }, |
| 2957 | messageLen: -1, // read until EOF |
| 2958 | flags: []string{ |
| 2959 | "-async", |
| 2960 | "-write-different-record-sizes", |
| 2961 | "-cbc-record-splitting", |
| 2962 | "-partial-write", |
| 2963 | }, |
| 2964 | }) |
| 2965 | } |
| 2966 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2967 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2968 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2969 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2970 | certPool := x509.NewCertPool() |
| 2971 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2972 | if err != nil { |
| 2973 | panic(err) |
| 2974 | } |
| 2975 | certPool.AddCert(cert) |
| 2976 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2977 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2978 | testCases = append(testCases, testCase{ |
| 2979 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2980 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2981 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2982 | MinVersion: ver.version, |
| 2983 | MaxVersion: ver.version, |
| 2984 | ClientAuth: RequireAnyClientCert, |
| 2985 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2986 | }, |
| 2987 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2988 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2989 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2990 | }, |
| 2991 | }) |
| 2992 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2993 | testType: serverTest, |
| 2994 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2995 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2996 | MinVersion: ver.version, |
| 2997 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2998 | Certificates: []Certificate{rsaCertificate}, |
| 2999 | }, |
| 3000 | flags: []string{"-require-any-client-certificate"}, |
| 3001 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3002 | if ver.version != VersionSSL30 { |
| 3003 | testCases = append(testCases, testCase{ |
| 3004 | testType: serverTest, |
| 3005 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3006 | config: Config{ |
| 3007 | MinVersion: ver.version, |
| 3008 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3009 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3010 | }, |
| 3011 | flags: []string{"-require-any-client-certificate"}, |
| 3012 | }) |
| 3013 | testCases = append(testCases, testCase{ |
| 3014 | testType: clientTest, |
| 3015 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3016 | config: Config{ |
| 3017 | MinVersion: ver.version, |
| 3018 | MaxVersion: ver.version, |
| 3019 | ClientAuth: RequireAnyClientCert, |
| 3020 | ClientCAs: certPool, |
| 3021 | }, |
| 3022 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3023 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3024 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3025 | }, |
| 3026 | }) |
| 3027 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3028 | |
| 3029 | testCases = append(testCases, testCase{ |
| 3030 | name: "NoClientCertificate-" + ver.name, |
| 3031 | config: Config{ |
| 3032 | MinVersion: ver.version, |
| 3033 | MaxVersion: ver.version, |
| 3034 | ClientAuth: RequireAnyClientCert, |
| 3035 | }, |
| 3036 | shouldFail: true, |
| 3037 | expectedLocalError: "client didn't provide a certificate", |
| 3038 | }) |
| 3039 | |
| 3040 | testCases = append(testCases, testCase{ |
| 3041 | // Even if not configured to expect a certificate, OpenSSL will |
| 3042 | // return X509_V_OK as the verify_result. |
| 3043 | testType: serverTest, |
| 3044 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3045 | config: Config{ |
| 3046 | MinVersion: ver.version, |
| 3047 | MaxVersion: ver.version, |
| 3048 | }, |
| 3049 | flags: []string{ |
| 3050 | "-expect-verify-result", |
| 3051 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3052 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3053 | }) |
| 3054 | |
| 3055 | testCases = append(testCases, testCase{ |
| 3056 | // If a client certificate is not provided, OpenSSL will still |
| 3057 | // return X509_V_OK as the verify_result. |
| 3058 | testType: serverTest, |
| 3059 | name: "NoClientCertificate-Server-" + ver.name, |
| 3060 | config: Config{ |
| 3061 | MinVersion: ver.version, |
| 3062 | MaxVersion: ver.version, |
| 3063 | }, |
| 3064 | flags: []string{ |
| 3065 | "-expect-verify-result", |
| 3066 | "-verify-peer", |
| 3067 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3068 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3069 | }) |
| 3070 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3071 | certificateRequired := "remote error: certificate required" |
| 3072 | if ver.version < VersionTLS13 { |
| 3073 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3074 | // was used. |
| 3075 | certificateRequired = "remote error: handshake failure" |
| 3076 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3077 | testCases = append(testCases, testCase{ |
| 3078 | testType: serverTest, |
| 3079 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3080 | config: Config{ |
| 3081 | MinVersion: ver.version, |
| 3082 | MaxVersion: ver.version, |
| 3083 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3084 | flags: []string{"-require-any-client-certificate"}, |
| 3085 | shouldFail: true, |
| 3086 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3087 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3088 | }) |
| 3089 | |
| 3090 | if ver.version != VersionSSL30 { |
| 3091 | testCases = append(testCases, testCase{ |
| 3092 | testType: serverTest, |
| 3093 | name: "SkipClientCertificate-" + ver.name, |
| 3094 | config: Config{ |
| 3095 | MinVersion: ver.version, |
| 3096 | MaxVersion: ver.version, |
| 3097 | Bugs: ProtocolBugs{ |
| 3098 | SkipClientCertificate: true, |
| 3099 | }, |
| 3100 | }, |
| 3101 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3102 | flags: []string{"-verify-peer"}, |
| 3103 | shouldFail: true, |
| 3104 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3105 | }) |
| 3106 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3107 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3108 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3109 | // Client auth is only legal in certificate-based ciphers. |
| 3110 | testCases = append(testCases, testCase{ |
| 3111 | testType: clientTest, |
| 3112 | name: "ClientAuth-PSK", |
| 3113 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3114 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3115 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3116 | PreSharedKey: []byte("secret"), |
| 3117 | ClientAuth: RequireAnyClientCert, |
| 3118 | }, |
| 3119 | flags: []string{ |
| 3120 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3121 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3122 | "-psk", "secret", |
| 3123 | }, |
| 3124 | shouldFail: true, |
| 3125 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3126 | }) |
| 3127 | testCases = append(testCases, testCase{ |
| 3128 | testType: clientTest, |
| 3129 | name: "ClientAuth-ECDHE_PSK", |
| 3130 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3131 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3132 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3133 | PreSharedKey: []byte("secret"), |
| 3134 | ClientAuth: RequireAnyClientCert, |
| 3135 | }, |
| 3136 | flags: []string{ |
| 3137 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3138 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3139 | "-psk", "secret", |
| 3140 | }, |
| 3141 | shouldFail: true, |
| 3142 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3143 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3144 | |
| 3145 | // Regression test for a bug where the client CA list, if explicitly |
| 3146 | // set to NULL, was mis-encoded. |
| 3147 | testCases = append(testCases, testCase{ |
| 3148 | testType: serverTest, |
| 3149 | name: "Null-Client-CA-List", |
| 3150 | config: Config{ |
| 3151 | MaxVersion: VersionTLS12, |
| 3152 | Certificates: []Certificate{rsaCertificate}, |
| 3153 | }, |
| 3154 | flags: []string{ |
| 3155 | "-require-any-client-certificate", |
| 3156 | "-use-null-client-ca-list", |
| 3157 | }, |
| 3158 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3159 | } |
| 3160 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3161 | func addExtendedMasterSecretTests() { |
| 3162 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3163 | |
| 3164 | for _, with := range []bool{false, true} { |
| 3165 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3166 | if with { |
| 3167 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3168 | } |
| 3169 | |
| 3170 | for _, isClient := range []bool{false, true} { |
| 3171 | suffix := "-Server" |
| 3172 | testType := serverTest |
| 3173 | if isClient { |
| 3174 | suffix = "-Client" |
| 3175 | testType = clientTest |
| 3176 | } |
| 3177 | |
| 3178 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3179 | // In TLS 1.3, the extension is irrelevant and |
| 3180 | // always reports as enabled. |
| 3181 | var flags []string |
| 3182 | if with || ver.version >= VersionTLS13 { |
| 3183 | flags = []string{expectEMSFlag} |
| 3184 | } |
| 3185 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3186 | test := testCase{ |
| 3187 | testType: testType, |
| 3188 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3189 | config: Config{ |
| 3190 | MinVersion: ver.version, |
| 3191 | MaxVersion: ver.version, |
| 3192 | Bugs: ProtocolBugs{ |
| 3193 | NoExtendedMasterSecret: !with, |
| 3194 | RequireExtendedMasterSecret: with, |
| 3195 | }, |
| 3196 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3197 | flags: flags, |
| 3198 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3199 | } |
| 3200 | if test.shouldFail { |
| 3201 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3202 | } |
| 3203 | testCases = append(testCases, test) |
| 3204 | } |
| 3205 | } |
| 3206 | } |
| 3207 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3208 | for _, isClient := range []bool{false, true} { |
| 3209 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3210 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3211 | boolToWord := func(b bool) string { |
| 3212 | if b { |
| 3213 | return "Yes" |
| 3214 | } |
| 3215 | return "No" |
| 3216 | } |
| 3217 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3218 | if isClient { |
| 3219 | suffix += "Client" |
| 3220 | } else { |
| 3221 | suffix += "Server" |
| 3222 | } |
| 3223 | |
| 3224 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3225 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3226 | Bugs: ProtocolBugs{ |
| 3227 | RequireExtendedMasterSecret: true, |
| 3228 | }, |
| 3229 | } |
| 3230 | |
| 3231 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3232 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3233 | Bugs: ProtocolBugs{ |
| 3234 | NoExtendedMasterSecret: true, |
| 3235 | }, |
| 3236 | } |
| 3237 | |
| 3238 | test := testCase{ |
| 3239 | name: "ExtendedMasterSecret-" + suffix, |
| 3240 | resumeSession: true, |
| 3241 | } |
| 3242 | |
| 3243 | if !isClient { |
| 3244 | test.testType = serverTest |
| 3245 | } |
| 3246 | |
| 3247 | if supportedInFirstConnection { |
| 3248 | test.config = supportedConfig |
| 3249 | } else { |
| 3250 | test.config = noSupportConfig |
| 3251 | } |
| 3252 | |
| 3253 | if supportedInResumeConnection { |
| 3254 | test.resumeConfig = &supportedConfig |
| 3255 | } else { |
| 3256 | test.resumeConfig = &noSupportConfig |
| 3257 | } |
| 3258 | |
| 3259 | switch suffix { |
| 3260 | case "YesToYes-Client", "YesToYes-Server": |
| 3261 | // When a session is resumed, it should |
| 3262 | // still be aware that its master |
| 3263 | // secret was generated via EMS and |
| 3264 | // thus it's safe to use tls-unique. |
| 3265 | test.flags = []string{expectEMSFlag} |
| 3266 | case "NoToYes-Server": |
| 3267 | // If an original connection did not |
| 3268 | // contain EMS, but a resumption |
| 3269 | // handshake does, then a server should |
| 3270 | // not resume the session. |
| 3271 | test.expectResumeRejected = true |
| 3272 | case "YesToNo-Server": |
| 3273 | // Resuming an EMS session without the |
| 3274 | // EMS extension should cause the |
| 3275 | // server to abort the connection. |
| 3276 | test.shouldFail = true |
| 3277 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3278 | case "NoToYes-Client": |
| 3279 | // A client should abort a connection |
| 3280 | // where the server resumed a non-EMS |
| 3281 | // session but echoed the EMS |
| 3282 | // extension. |
| 3283 | test.shouldFail = true |
| 3284 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3285 | case "YesToNo-Client": |
| 3286 | // A client should abort a connection |
| 3287 | // where the server didn't echo EMS |
| 3288 | // when the session used it. |
| 3289 | test.shouldFail = true |
| 3290 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3291 | } |
| 3292 | |
| 3293 | testCases = append(testCases, test) |
| 3294 | } |
| 3295 | } |
| 3296 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3297 | |
| 3298 | // Switching EMS on renegotiation is forbidden. |
| 3299 | testCases = append(testCases, testCase{ |
| 3300 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3301 | config: Config{ |
| 3302 | MaxVersion: VersionTLS12, |
| 3303 | Bugs: ProtocolBugs{ |
| 3304 | NoExtendedMasterSecret: true, |
| 3305 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3306 | }, |
| 3307 | }, |
| 3308 | renegotiate: 1, |
| 3309 | flags: []string{ |
| 3310 | "-renegotiate-freely", |
| 3311 | "-expect-total-renegotiations", "1", |
| 3312 | }, |
| 3313 | }) |
| 3314 | |
| 3315 | testCases = append(testCases, testCase{ |
| 3316 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3317 | config: Config{ |
| 3318 | MaxVersion: VersionTLS12, |
| 3319 | Bugs: ProtocolBugs{ |
| 3320 | NoExtendedMasterSecret: true, |
| 3321 | }, |
| 3322 | }, |
| 3323 | renegotiate: 1, |
| 3324 | flags: []string{ |
| 3325 | "-renegotiate-freely", |
| 3326 | "-expect-total-renegotiations", "1", |
| 3327 | }, |
| 3328 | shouldFail: true, |
| 3329 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3330 | }) |
| 3331 | |
| 3332 | testCases = append(testCases, testCase{ |
| 3333 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3334 | config: Config{ |
| 3335 | MaxVersion: VersionTLS12, |
| 3336 | Bugs: ProtocolBugs{ |
| 3337 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3338 | }, |
| 3339 | }, |
| 3340 | renegotiate: 1, |
| 3341 | flags: []string{ |
| 3342 | "-renegotiate-freely", |
| 3343 | "-expect-total-renegotiations", "1", |
| 3344 | }, |
| 3345 | shouldFail: true, |
| 3346 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3347 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3348 | } |
| 3349 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3350 | type stateMachineTestConfig struct { |
| 3351 | protocol protocol |
| 3352 | async bool |
| 3353 | splitHandshake, packHandshakeFlight bool |
| 3354 | } |
| 3355 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3356 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3357 | // various conditions. Some of these are redundant with other tests, but they |
| 3358 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3359 | func addAllStateMachineCoverageTests() { |
| 3360 | for _, async := range []bool{false, true} { |
| 3361 | for _, protocol := range []protocol{tls, dtls} { |
| 3362 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3363 | protocol: protocol, |
| 3364 | async: async, |
| 3365 | }) |
| 3366 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3367 | protocol: protocol, |
| 3368 | async: async, |
| 3369 | splitHandshake: true, |
| 3370 | }) |
| 3371 | if protocol == tls { |
| 3372 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3373 | protocol: protocol, |
| 3374 | async: async, |
| 3375 | packHandshakeFlight: true, |
| 3376 | }) |
| 3377 | } |
| 3378 | } |
| 3379 | } |
| 3380 | } |
| 3381 | |
| 3382 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3383 | var tests []testCase |
| 3384 | |
| 3385 | // Basic handshake, with resumption. Client and server, |
| 3386 | // session ID and session ticket. |
| 3387 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3388 | name: "Basic-Client", |
| 3389 | config: Config{ |
| 3390 | MaxVersion: VersionTLS12, |
| 3391 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3392 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3393 | // Ensure session tickets are used, not session IDs. |
| 3394 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3395 | }) |
| 3396 | tests = append(tests, testCase{ |
| 3397 | name: "Basic-Client-RenewTicket", |
| 3398 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3399 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3400 | Bugs: ProtocolBugs{ |
| 3401 | RenewTicketOnResume: true, |
| 3402 | }, |
| 3403 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3404 | flags: []string{"-expect-ticket-renewal"}, |
| 3405 | resumeSession: true, |
| 3406 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3407 | }) |
| 3408 | tests = append(tests, testCase{ |
| 3409 | name: "Basic-Client-NoTicket", |
| 3410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3411 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3412 | SessionTicketsDisabled: true, |
| 3413 | }, |
| 3414 | resumeSession: true, |
| 3415 | }) |
| 3416 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3417 | name: "Basic-Client-Implicit", |
| 3418 | config: Config{ |
| 3419 | MaxVersion: VersionTLS12, |
| 3420 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3421 | flags: []string{"-implicit-handshake"}, |
| 3422 | resumeSession: true, |
| 3423 | }) |
| 3424 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3425 | testType: serverTest, |
| 3426 | name: "Basic-Server", |
| 3427 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3428 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3429 | Bugs: ProtocolBugs{ |
| 3430 | RequireSessionTickets: true, |
| 3431 | }, |
| 3432 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3433 | resumeSession: true, |
| 3434 | }) |
| 3435 | tests = append(tests, testCase{ |
| 3436 | testType: serverTest, |
| 3437 | name: "Basic-Server-NoTickets", |
| 3438 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3439 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3440 | SessionTicketsDisabled: true, |
| 3441 | }, |
| 3442 | resumeSession: true, |
| 3443 | }) |
| 3444 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3445 | testType: serverTest, |
| 3446 | name: "Basic-Server-Implicit", |
| 3447 | config: Config{ |
| 3448 | MaxVersion: VersionTLS12, |
| 3449 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3450 | flags: []string{"-implicit-handshake"}, |
| 3451 | resumeSession: true, |
| 3452 | }) |
| 3453 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3454 | testType: serverTest, |
| 3455 | name: "Basic-Server-EarlyCallback", |
| 3456 | config: Config{ |
| 3457 | MaxVersion: VersionTLS12, |
| 3458 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3459 | flags: []string{"-use-early-callback"}, |
| 3460 | resumeSession: true, |
| 3461 | }) |
| 3462 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3463 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3464 | if config.protocol == tls { |
| 3465 | tests = append(tests, testCase{ |
| 3466 | name: "TLS13-1RTT-Client", |
| 3467 | config: Config{ |
| 3468 | MaxVersion: VersionTLS13, |
| 3469 | MinVersion: VersionTLS13, |
| 3470 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3471 | resumeSession: true, |
| 3472 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3473 | }) |
| 3474 | |
| 3475 | tests = append(tests, testCase{ |
| 3476 | testType: serverTest, |
| 3477 | name: "TLS13-1RTT-Server", |
| 3478 | config: Config{ |
| 3479 | MaxVersion: VersionTLS13, |
| 3480 | MinVersion: VersionTLS13, |
| 3481 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3482 | resumeSession: true, |
| 3483 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3484 | }) |
| 3485 | |
| 3486 | tests = append(tests, testCase{ |
| 3487 | name: "TLS13-HelloRetryRequest-Client", |
| 3488 | config: Config{ |
| 3489 | MaxVersion: VersionTLS13, |
| 3490 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3491 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3492 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3493 | CurvePreferences: []CurveID{CurveP384}, |
| 3494 | Bugs: ProtocolBugs{ |
| 3495 | ExpectMissingKeyShare: true, |
| 3496 | }, |
| 3497 | }, |
| 3498 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3499 | resumeSession: true, |
| 3500 | }) |
| 3501 | |
| 3502 | tests = append(tests, testCase{ |
| 3503 | testType: serverTest, |
| 3504 | name: "TLS13-HelloRetryRequest-Server", |
| 3505 | config: Config{ |
| 3506 | MaxVersion: VersionTLS13, |
| 3507 | MinVersion: VersionTLS13, |
| 3508 | // Require a HelloRetryRequest for every curve. |
| 3509 | DefaultCurves: []CurveID{}, |
| 3510 | }, |
| 3511 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3512 | resumeSession: true, |
| 3513 | }) |
| 3514 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3515 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3516 | // TLS client auth. |
| 3517 | tests = append(tests, testCase{ |
| 3518 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3519 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3520 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3521 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3522 | ClientAuth: RequestClientCert, |
| 3523 | }, |
| 3524 | }) |
| 3525 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3526 | testType: serverTest, |
| 3527 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3528 | config: Config{ |
| 3529 | MaxVersion: VersionTLS12, |
| 3530 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3531 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3532 | flags: []string{"-verify-peer"}, |
| 3533 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3534 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3535 | tests = append(tests, testCase{ |
| 3536 | testType: clientTest, |
| 3537 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3538 | config: Config{ |
| 3539 | MaxVersion: VersionSSL30, |
| 3540 | ClientAuth: RequestClientCert, |
| 3541 | }, |
| 3542 | }) |
| 3543 | tests = append(tests, testCase{ |
| 3544 | testType: serverTest, |
| 3545 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3546 | config: Config{ |
| 3547 | MaxVersion: VersionSSL30, |
| 3548 | }, |
| 3549 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3550 | flags: []string{"-verify-peer"}, |
| 3551 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3552 | tests = append(tests, testCase{ |
| 3553 | testType: clientTest, |
| 3554 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3555 | config: Config{ |
| 3556 | MaxVersion: VersionTLS13, |
| 3557 | ClientAuth: RequestClientCert, |
| 3558 | }, |
| 3559 | }) |
| 3560 | tests = append(tests, testCase{ |
| 3561 | testType: serverTest, |
| 3562 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3563 | config: Config{ |
| 3564 | MaxVersion: VersionTLS13, |
| 3565 | }, |
| 3566 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3567 | flags: []string{"-verify-peer"}, |
| 3568 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3569 | } |
| 3570 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3571 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3572 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3573 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3574 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3575 | ClientAuth: RequireAnyClientCert, |
| 3576 | }, |
| 3577 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3578 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3579 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3580 | }, |
| 3581 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3582 | tests = append(tests, testCase{ |
| 3583 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3584 | name: "ClientAuth-RSA-Client-TLS13", |
| 3585 | config: Config{ |
| 3586 | MaxVersion: VersionTLS13, |
| 3587 | ClientAuth: RequireAnyClientCert, |
| 3588 | }, |
| 3589 | flags: []string{ |
| 3590 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3591 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3592 | }, |
| 3593 | }) |
| 3594 | tests = append(tests, testCase{ |
| 3595 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3596 | name: "ClientAuth-ECDSA-Client", |
| 3597 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3598 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3599 | ClientAuth: RequireAnyClientCert, |
| 3600 | }, |
| 3601 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3602 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3603 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3604 | }, |
| 3605 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3606 | tests = append(tests, testCase{ |
| 3607 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3608 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3609 | config: Config{ |
| 3610 | MaxVersion: VersionTLS13, |
| 3611 | ClientAuth: RequireAnyClientCert, |
| 3612 | }, |
| 3613 | flags: []string{ |
| 3614 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3615 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3616 | }, |
| 3617 | }) |
| 3618 | tests = append(tests, testCase{ |
| 3619 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3620 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3621 | config: Config{ |
| 3622 | MaxVersion: VersionTLS12, |
| 3623 | ClientAuth: RequestClientCert, |
| 3624 | }, |
| 3625 | flags: []string{"-use-old-client-cert-callback"}, |
| 3626 | }) |
| 3627 | tests = append(tests, testCase{ |
| 3628 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3629 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3630 | config: Config{ |
| 3631 | MaxVersion: VersionTLS13, |
| 3632 | ClientAuth: RequestClientCert, |
| 3633 | }, |
| 3634 | flags: []string{"-use-old-client-cert-callback"}, |
| 3635 | }) |
| 3636 | tests = append(tests, testCase{ |
| 3637 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3638 | name: "ClientAuth-OldCallback", |
| 3639 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3640 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3641 | ClientAuth: RequireAnyClientCert, |
| 3642 | }, |
| 3643 | flags: []string{ |
| 3644 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3645 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3646 | "-use-old-client-cert-callback", |
| 3647 | }, |
| 3648 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3649 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3650 | testType: clientTest, |
| 3651 | name: "ClientAuth-OldCallback-TLS13", |
| 3652 | config: Config{ |
| 3653 | MaxVersion: VersionTLS13, |
| 3654 | ClientAuth: RequireAnyClientCert, |
| 3655 | }, |
| 3656 | flags: []string{ |
| 3657 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3658 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3659 | "-use-old-client-cert-callback", |
| 3660 | }, |
| 3661 | }) |
| 3662 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3663 | testType: serverTest, |
| 3664 | name: "ClientAuth-Server", |
| 3665 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3666 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3667 | Certificates: []Certificate{rsaCertificate}, |
| 3668 | }, |
| 3669 | flags: []string{"-require-any-client-certificate"}, |
| 3670 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3671 | tests = append(tests, testCase{ |
| 3672 | testType: serverTest, |
| 3673 | name: "ClientAuth-Server-TLS13", |
| 3674 | config: Config{ |
| 3675 | MaxVersion: VersionTLS13, |
| 3676 | Certificates: []Certificate{rsaCertificate}, |
| 3677 | }, |
| 3678 | flags: []string{"-require-any-client-certificate"}, |
| 3679 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3680 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3681 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3682 | tests = append(tests, testCase{ |
| 3683 | testType: serverTest, |
| 3684 | name: "Basic-Server-RSA", |
| 3685 | config: Config{ |
| 3686 | MaxVersion: VersionTLS12, |
| 3687 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3688 | }, |
| 3689 | flags: []string{ |
| 3690 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3691 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3692 | }, |
| 3693 | }) |
| 3694 | tests = append(tests, testCase{ |
| 3695 | testType: serverTest, |
| 3696 | name: "Basic-Server-ECDHE-RSA", |
| 3697 | config: Config{ |
| 3698 | MaxVersion: VersionTLS12, |
| 3699 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3700 | }, |
| 3701 | flags: []string{ |
| 3702 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3703 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3704 | }, |
| 3705 | }) |
| 3706 | tests = append(tests, testCase{ |
| 3707 | testType: serverTest, |
| 3708 | name: "Basic-Server-ECDHE-ECDSA", |
| 3709 | config: Config{ |
| 3710 | MaxVersion: VersionTLS12, |
| 3711 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3712 | }, |
| 3713 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3714 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3715 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3716 | }, |
| 3717 | }) |
| 3718 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3719 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3720 | tests = append(tests, testCase{ |
| 3721 | name: "SessionTicketsDisabled-Client", |
| 3722 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3723 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3724 | SessionTicketsDisabled: true, |
| 3725 | }, |
| 3726 | }) |
| 3727 | tests = append(tests, testCase{ |
| 3728 | testType: serverTest, |
| 3729 | name: "SessionTicketsDisabled-Server", |
| 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 | |
| 3736 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3737 | // identity hint. |
| 3738 | tests = append(tests, testCase{ |
| 3739 | name: "EmptyPSKHint-Client", |
| 3740 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3741 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3742 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3743 | PreSharedKey: []byte("secret"), |
| 3744 | }, |
| 3745 | flags: []string{"-psk", "secret"}, |
| 3746 | }) |
| 3747 | tests = append(tests, testCase{ |
| 3748 | testType: serverTest, |
| 3749 | name: "EmptyPSKHint-Server", |
| 3750 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3751 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3752 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3753 | PreSharedKey: []byte("secret"), |
| 3754 | }, |
| 3755 | flags: []string{"-psk", "secret"}, |
| 3756 | }) |
| 3757 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3758 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3759 | tests = append(tests, testCase{ |
| 3760 | testType: clientTest, |
| 3761 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3762 | config: Config{ |
| 3763 | MaxVersion: VersionTLS12, |
| 3764 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3765 | flags: []string{ |
| 3766 | "-enable-ocsp-stapling", |
| 3767 | "-expect-ocsp-response", |
| 3768 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3769 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3770 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3771 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3772 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3773 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3774 | testType: serverTest, |
| 3775 | name: "OCSPStapling-Server", |
| 3776 | config: Config{ |
| 3777 | MaxVersion: VersionTLS12, |
| 3778 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3779 | expectedOCSPResponse: testOCSPResponse, |
| 3780 | flags: []string{ |
| 3781 | "-ocsp-response", |
| 3782 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3783 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3784 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3785 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3786 | tests = append(tests, testCase{ |
| 3787 | testType: clientTest, |
| 3788 | name: "OCSPStapling-Client-TLS13", |
| 3789 | config: Config{ |
| 3790 | MaxVersion: VersionTLS13, |
| 3791 | }, |
| 3792 | flags: []string{ |
| 3793 | "-enable-ocsp-stapling", |
| 3794 | "-expect-ocsp-response", |
| 3795 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3796 | "-verify-peer", |
| 3797 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3798 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3799 | }) |
| 3800 | tests = append(tests, testCase{ |
| 3801 | testType: serverTest, |
| 3802 | name: "OCSPStapling-Server-TLS13", |
| 3803 | config: Config{ |
| 3804 | MaxVersion: VersionTLS13, |
| 3805 | }, |
| 3806 | expectedOCSPResponse: testOCSPResponse, |
| 3807 | flags: []string{ |
| 3808 | "-ocsp-response", |
| 3809 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3810 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3811 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3812 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3813 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3814 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3815 | for _, vers := range tlsVersions { |
| 3816 | if config.protocol == dtls && !vers.hasDTLS { |
| 3817 | continue |
| 3818 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3819 | for _, testType := range []testType{clientTest, serverTest} { |
| 3820 | suffix := "-Client" |
| 3821 | if testType == serverTest { |
| 3822 | suffix = "-Server" |
| 3823 | } |
| 3824 | suffix += "-" + vers.name |
| 3825 | |
| 3826 | flag := "-verify-peer" |
| 3827 | if testType == serverTest { |
| 3828 | flag = "-require-any-client-certificate" |
| 3829 | } |
| 3830 | |
| 3831 | tests = append(tests, testCase{ |
| 3832 | testType: testType, |
| 3833 | name: "CertificateVerificationSucceed" + suffix, |
| 3834 | config: Config{ |
| 3835 | MaxVersion: vers.version, |
| 3836 | Certificates: []Certificate{rsaCertificate}, |
| 3837 | }, |
| 3838 | flags: []string{ |
| 3839 | flag, |
| 3840 | "-expect-verify-result", |
| 3841 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3842 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3843 | }) |
| 3844 | tests = append(tests, testCase{ |
| 3845 | testType: testType, |
| 3846 | name: "CertificateVerificationFail" + suffix, |
| 3847 | config: Config{ |
| 3848 | MaxVersion: vers.version, |
| 3849 | Certificates: []Certificate{rsaCertificate}, |
| 3850 | }, |
| 3851 | flags: []string{ |
| 3852 | flag, |
| 3853 | "-verify-fail", |
| 3854 | }, |
| 3855 | shouldFail: true, |
| 3856 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3857 | }) |
| 3858 | } |
| 3859 | |
| 3860 | // By default, the client is in a soft fail mode where the peer |
| 3861 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3862 | tests = append(tests, testCase{ |
| 3863 | testType: clientTest, |
| 3864 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3865 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3866 | MaxVersion: vers.version, |
| 3867 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3868 | }, |
| 3869 | flags: []string{ |
| 3870 | "-verify-fail", |
| 3871 | "-expect-verify-result", |
| 3872 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3873 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3874 | }) |
| 3875 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3876 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3877 | tests = append(tests, testCase{ |
| 3878 | name: "ShimSendAlert", |
| 3879 | flags: []string{"-send-alert"}, |
| 3880 | shimWritesFirst: true, |
| 3881 | shouldFail: true, |
| 3882 | expectedLocalError: "remote error: decompression failure", |
| 3883 | }) |
| 3884 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3885 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3886 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3887 | name: "Renegotiate-Client", |
| 3888 | config: Config{ |
| 3889 | MaxVersion: VersionTLS12, |
| 3890 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3891 | renegotiate: 1, |
| 3892 | flags: []string{ |
| 3893 | "-renegotiate-freely", |
| 3894 | "-expect-total-renegotiations", "1", |
| 3895 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3896 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3897 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3898 | tests = append(tests, testCase{ |
| 3899 | name: "SendHalfHelloRequest", |
| 3900 | config: Config{ |
| 3901 | MaxVersion: VersionTLS12, |
| 3902 | Bugs: ProtocolBugs{ |
| 3903 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3904 | }, |
| 3905 | }, |
| 3906 | sendHalfHelloRequest: true, |
| 3907 | flags: []string{"-renegotiate-ignore"}, |
| 3908 | shouldFail: true, |
| 3909 | expectedError: ":UNEXPECTED_RECORD:", |
| 3910 | }) |
| 3911 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3912 | // NPN on client and server; results in post-handshake message. |
| 3913 | tests = append(tests, testCase{ |
| 3914 | name: "NPN-Client", |
| 3915 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3916 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3917 | NextProtos: []string{"foo"}, |
| 3918 | }, |
| 3919 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3920 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3921 | expectedNextProto: "foo", |
| 3922 | expectedNextProtoType: npn, |
| 3923 | }) |
| 3924 | tests = append(tests, testCase{ |
| 3925 | testType: serverTest, |
| 3926 | name: "NPN-Server", |
| 3927 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3928 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3929 | NextProtos: []string{"bar"}, |
| 3930 | }, |
| 3931 | flags: []string{ |
| 3932 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3933 | "-expect-next-proto", "bar", |
| 3934 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3935 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3936 | expectedNextProto: "bar", |
| 3937 | expectedNextProtoType: npn, |
| 3938 | }) |
| 3939 | |
| 3940 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3941 | |
| 3942 | // Client does False Start and negotiates NPN. |
| 3943 | tests = append(tests, testCase{ |
| 3944 | name: "FalseStart", |
| 3945 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3946 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3947 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3948 | NextProtos: []string{"foo"}, |
| 3949 | Bugs: ProtocolBugs{ |
| 3950 | ExpectFalseStart: true, |
| 3951 | }, |
| 3952 | }, |
| 3953 | flags: []string{ |
| 3954 | "-false-start", |
| 3955 | "-select-next-proto", "foo", |
| 3956 | }, |
| 3957 | shimWritesFirst: true, |
| 3958 | resumeSession: true, |
| 3959 | }) |
| 3960 | |
| 3961 | // Client does False Start and negotiates ALPN. |
| 3962 | tests = append(tests, testCase{ |
| 3963 | name: "FalseStart-ALPN", |
| 3964 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3965 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3966 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3967 | NextProtos: []string{"foo"}, |
| 3968 | Bugs: ProtocolBugs{ |
| 3969 | ExpectFalseStart: true, |
| 3970 | }, |
| 3971 | }, |
| 3972 | flags: []string{ |
| 3973 | "-false-start", |
| 3974 | "-advertise-alpn", "\x03foo", |
| 3975 | }, |
| 3976 | shimWritesFirst: true, |
| 3977 | resumeSession: true, |
| 3978 | }) |
| 3979 | |
| 3980 | // Client does False Start but doesn't explicitly call |
| 3981 | // SSL_connect. |
| 3982 | tests = append(tests, testCase{ |
| 3983 | name: "FalseStart-Implicit", |
| 3984 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3985 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3986 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3987 | NextProtos: []string{"foo"}, |
| 3988 | }, |
| 3989 | flags: []string{ |
| 3990 | "-implicit-handshake", |
| 3991 | "-false-start", |
| 3992 | "-advertise-alpn", "\x03foo", |
| 3993 | }, |
| 3994 | }) |
| 3995 | |
| 3996 | // False Start without session tickets. |
| 3997 | tests = append(tests, testCase{ |
| 3998 | name: "FalseStart-SessionTicketsDisabled", |
| 3999 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4000 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4001 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4002 | NextProtos: []string{"foo"}, |
| 4003 | SessionTicketsDisabled: true, |
| 4004 | Bugs: ProtocolBugs{ |
| 4005 | ExpectFalseStart: true, |
| 4006 | }, |
| 4007 | }, |
| 4008 | flags: []string{ |
| 4009 | "-false-start", |
| 4010 | "-select-next-proto", "foo", |
| 4011 | }, |
| 4012 | shimWritesFirst: true, |
| 4013 | }) |
| 4014 | |
| 4015 | // Server parses a V2ClientHello. |
| 4016 | tests = append(tests, testCase{ |
| 4017 | testType: serverTest, |
| 4018 | name: "SendV2ClientHello", |
| 4019 | config: Config{ |
| 4020 | // Choose a cipher suite that does not involve |
| 4021 | // elliptic curves, so no extensions are |
| 4022 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4023 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4024 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4025 | Bugs: ProtocolBugs{ |
| 4026 | SendV2ClientHello: true, |
| 4027 | }, |
| 4028 | }, |
| 4029 | }) |
| 4030 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4031 | // Test Channel ID |
| 4032 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4033 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4034 | continue |
| 4035 | } |
| 4036 | // Client sends a Channel ID. |
| 4037 | tests = append(tests, testCase{ |
| 4038 | name: "ChannelID-Client-" + ver.name, |
| 4039 | config: Config{ |
| 4040 | MaxVersion: ver.version, |
| 4041 | RequestChannelID: true, |
| 4042 | }, |
| 4043 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4044 | resumeSession: true, |
| 4045 | expectChannelID: true, |
| 4046 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4047 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4048 | // Server accepts a Channel ID. |
| 4049 | tests = append(tests, testCase{ |
| 4050 | testType: serverTest, |
| 4051 | name: "ChannelID-Server-" + ver.name, |
| 4052 | config: Config{ |
| 4053 | MaxVersion: ver.version, |
| 4054 | ChannelID: channelIDKey, |
| 4055 | }, |
| 4056 | flags: []string{ |
| 4057 | "-expect-channel-id", |
| 4058 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4059 | }, |
| 4060 | resumeSession: true, |
| 4061 | expectChannelID: true, |
| 4062 | }) |
| 4063 | |
| 4064 | tests = append(tests, testCase{ |
| 4065 | testType: serverTest, |
| 4066 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4067 | config: Config{ |
| 4068 | MaxVersion: ver.version, |
| 4069 | ChannelID: channelIDKey, |
| 4070 | Bugs: ProtocolBugs{ |
| 4071 | InvalidChannelIDSignature: true, |
| 4072 | }, |
| 4073 | }, |
| 4074 | flags: []string{"-enable-channel-id"}, |
| 4075 | shouldFail: true, |
| 4076 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4077 | }) |
| 4078 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4079 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4080 | // Channel ID and NPN at the same time, to ensure their relative |
| 4081 | // ordering is correct. |
| 4082 | tests = append(tests, testCase{ |
| 4083 | name: "ChannelID-NPN-Client", |
| 4084 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4085 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4086 | RequestChannelID: true, |
| 4087 | NextProtos: []string{"foo"}, |
| 4088 | }, |
| 4089 | flags: []string{ |
| 4090 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4091 | "-select-next-proto", "foo", |
| 4092 | }, |
| 4093 | resumeSession: true, |
| 4094 | expectChannelID: true, |
| 4095 | expectedNextProto: "foo", |
| 4096 | expectedNextProtoType: npn, |
| 4097 | }) |
| 4098 | tests = append(tests, testCase{ |
| 4099 | testType: serverTest, |
| 4100 | name: "ChannelID-NPN-Server", |
| 4101 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4102 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4103 | ChannelID: channelIDKey, |
| 4104 | NextProtos: []string{"bar"}, |
| 4105 | }, |
| 4106 | flags: []string{ |
| 4107 | "-expect-channel-id", |
| 4108 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4109 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4110 | "-expect-next-proto", "bar", |
| 4111 | }, |
| 4112 | resumeSession: true, |
| 4113 | expectChannelID: true, |
| 4114 | expectedNextProto: "bar", |
| 4115 | expectedNextProtoType: npn, |
| 4116 | }) |
| 4117 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4118 | // Bidirectional shutdown with the runner initiating. |
| 4119 | tests = append(tests, testCase{ |
| 4120 | name: "Shutdown-Runner", |
| 4121 | config: Config{ |
| 4122 | Bugs: ProtocolBugs{ |
| 4123 | ExpectCloseNotify: true, |
| 4124 | }, |
| 4125 | }, |
| 4126 | flags: []string{"-check-close-notify"}, |
| 4127 | }) |
| 4128 | |
| 4129 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4130 | // in the meantime, sends garbage before the close_notify which |
| 4131 | // the shim must ignore. |
| 4132 | tests = append(tests, testCase{ |
| 4133 | name: "Shutdown-Shim", |
| 4134 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4135 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4136 | Bugs: ProtocolBugs{ |
| 4137 | ExpectCloseNotify: true, |
| 4138 | }, |
| 4139 | }, |
| 4140 | shimShutsDown: true, |
| 4141 | sendEmptyRecords: 1, |
| 4142 | sendWarningAlerts: 1, |
| 4143 | flags: []string{"-check-close-notify"}, |
| 4144 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4145 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4146 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4147 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4148 | tests = append(tests, testCase{ |
| 4149 | name: "SkipHelloVerifyRequest", |
| 4150 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4151 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4152 | Bugs: ProtocolBugs{ |
| 4153 | SkipHelloVerifyRequest: true, |
| 4154 | }, |
| 4155 | }, |
| 4156 | }) |
| 4157 | } |
| 4158 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4159 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4160 | test.protocol = config.protocol |
| 4161 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4162 | test.name += "-DTLS" |
| 4163 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4164 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4165 | test.name += "-Async" |
| 4166 | test.flags = append(test.flags, "-async") |
| 4167 | } else { |
| 4168 | test.name += "-Sync" |
| 4169 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4170 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4171 | test.name += "-SplitHandshakeRecords" |
| 4172 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4173 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4174 | test.config.Bugs.MaxPacketLength = 256 |
| 4175 | test.flags = append(test.flags, "-mtu", "256") |
| 4176 | } |
| 4177 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4178 | if config.packHandshakeFlight { |
| 4179 | test.name += "-PackHandshakeFlight" |
| 4180 | test.config.Bugs.PackHandshakeFlight = true |
| 4181 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4182 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4183 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4184 | } |
| 4185 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4186 | func addDDoSCallbackTests() { |
| 4187 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4188 | for _, resume := range []bool{false, true} { |
| 4189 | suffix := "Resume" |
| 4190 | if resume { |
| 4191 | suffix = "No" + suffix |
| 4192 | } |
| 4193 | |
| 4194 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4195 | testType: serverTest, |
| 4196 | name: "Server-DDoS-OK-" + suffix, |
| 4197 | config: Config{ |
| 4198 | MaxVersion: VersionTLS12, |
| 4199 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4200 | flags: []string{"-install-ddos-callback"}, |
| 4201 | resumeSession: resume, |
| 4202 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4203 | testCases = append(testCases, testCase{ |
| 4204 | testType: serverTest, |
| 4205 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4206 | config: Config{ |
| 4207 | MaxVersion: VersionTLS13, |
| 4208 | }, |
| 4209 | flags: []string{"-install-ddos-callback"}, |
| 4210 | resumeSession: resume, |
| 4211 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4212 | |
| 4213 | failFlag := "-fail-ddos-callback" |
| 4214 | if resume { |
| 4215 | failFlag = "-fail-second-ddos-callback" |
| 4216 | } |
| 4217 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4218 | testType: serverTest, |
| 4219 | name: "Server-DDoS-Reject-" + suffix, |
| 4220 | config: Config{ |
| 4221 | MaxVersion: VersionTLS12, |
| 4222 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4223 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4224 | resumeSession: resume, |
| 4225 | shouldFail: true, |
| 4226 | expectedError: ":CONNECTION_REJECTED:", |
| 4227 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4228 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4229 | testCases = append(testCases, testCase{ |
| 4230 | testType: serverTest, |
| 4231 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4232 | config: Config{ |
| 4233 | MaxVersion: VersionTLS13, |
| 4234 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4235 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4236 | resumeSession: resume, |
| 4237 | shouldFail: true, |
| 4238 | expectedError: ":CONNECTION_REJECTED:", |
| 4239 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4240 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4241 | } |
| 4242 | } |
| 4243 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4244 | func addVersionNegotiationTests() { |
| 4245 | for i, shimVers := range tlsVersions { |
| 4246 | // Assemble flags to disable all newer versions on the shim. |
| 4247 | var flags []string |
| 4248 | for _, vers := range tlsVersions[i+1:] { |
| 4249 | flags = append(flags, vers.flag) |
| 4250 | } |
| 4251 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4252 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4253 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4254 | protocols := []protocol{tls} |
| 4255 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4256 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4257 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4258 | for _, protocol := range protocols { |
| 4259 | expectedVersion := shimVers.version |
| 4260 | if runnerVers.version < shimVers.version { |
| 4261 | expectedVersion = runnerVers.version |
| 4262 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4263 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4264 | suffix := shimVers.name + "-" + runnerVers.name |
| 4265 | if protocol == dtls { |
| 4266 | suffix += "-DTLS" |
| 4267 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4268 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4269 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4270 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4271 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4272 | clientVers := shimVers.version |
| 4273 | if clientVers > VersionTLS10 { |
| 4274 | clientVers = VersionTLS10 |
| 4275 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4276 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4277 | serverVers := expectedVersion |
| 4278 | if expectedVersion >= VersionTLS13 { |
| 4279 | serverVers = VersionTLS10 |
| 4280 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4281 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4282 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4283 | testCases = append(testCases, testCase{ |
| 4284 | protocol: protocol, |
| 4285 | testType: clientTest, |
| 4286 | name: "VersionNegotiation-Client-" + suffix, |
| 4287 | config: Config{ |
| 4288 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4289 | Bugs: ProtocolBugs{ |
| 4290 | ExpectInitialRecordVersion: clientVers, |
| 4291 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4292 | }, |
| 4293 | flags: flags, |
| 4294 | expectedVersion: expectedVersion, |
| 4295 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4296 | testCases = append(testCases, testCase{ |
| 4297 | protocol: protocol, |
| 4298 | testType: clientTest, |
| 4299 | name: "VersionNegotiation-Client2-" + suffix, |
| 4300 | config: Config{ |
| 4301 | MaxVersion: runnerVers.version, |
| 4302 | Bugs: ProtocolBugs{ |
| 4303 | ExpectInitialRecordVersion: clientVers, |
| 4304 | }, |
| 4305 | }, |
| 4306 | flags: []string{"-max-version", shimVersFlag}, |
| 4307 | expectedVersion: expectedVersion, |
| 4308 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4309 | |
| 4310 | testCases = append(testCases, testCase{ |
| 4311 | protocol: protocol, |
| 4312 | testType: serverTest, |
| 4313 | name: "VersionNegotiation-Server-" + suffix, |
| 4314 | config: Config{ |
| 4315 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4316 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4317 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 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: serverTest, |
| 4326 | name: "VersionNegotiation-Server2-" + suffix, |
| 4327 | config: Config{ |
| 4328 | MaxVersion: runnerVers.version, |
| 4329 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4330 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 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 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4337 | } |
| 4338 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4339 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4340 | // Test the version extension at all versions. |
| 4341 | for _, vers := range tlsVersions { |
| 4342 | protocols := []protocol{tls} |
| 4343 | if vers.hasDTLS { |
| 4344 | protocols = append(protocols, dtls) |
| 4345 | } |
| 4346 | for _, protocol := range protocols { |
| 4347 | suffix := vers.name |
| 4348 | if protocol == dtls { |
| 4349 | suffix += "-DTLS" |
| 4350 | } |
| 4351 | |
| 4352 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4353 | testCases = append(testCases, testCase{ |
| 4354 | protocol: protocol, |
| 4355 | testType: serverTest, |
| 4356 | name: "VersionNegotiationExtension-" + suffix, |
| 4357 | config: Config{ |
| 4358 | Bugs: ProtocolBugs{ |
| 4359 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4360 | }, |
| 4361 | }, |
| 4362 | expectedVersion: vers.version, |
| 4363 | }) |
| 4364 | } |
| 4365 | |
| 4366 | } |
| 4367 | |
| 4368 | // If all versions are unknown, negotiation fails. |
| 4369 | testCases = append(testCases, testCase{ |
| 4370 | testType: serverTest, |
| 4371 | name: "NoSupportedVersions", |
| 4372 | config: Config{ |
| 4373 | Bugs: ProtocolBugs{ |
| 4374 | SendSupportedVersions: []uint16{0x1111}, |
| 4375 | }, |
| 4376 | }, |
| 4377 | shouldFail: true, |
| 4378 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4379 | }) |
| 4380 | testCases = append(testCases, testCase{ |
| 4381 | protocol: dtls, |
| 4382 | testType: serverTest, |
| 4383 | name: "NoSupportedVersions-DTLS", |
| 4384 | config: Config{ |
| 4385 | Bugs: ProtocolBugs{ |
| 4386 | SendSupportedVersions: []uint16{0x1111}, |
| 4387 | }, |
| 4388 | }, |
| 4389 | shouldFail: true, |
| 4390 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4391 | }) |
| 4392 | |
| 4393 | testCases = append(testCases, testCase{ |
| 4394 | testType: serverTest, |
| 4395 | name: "ClientHelloVersionTooHigh", |
| 4396 | config: Config{ |
| 4397 | MaxVersion: VersionTLS13, |
| 4398 | Bugs: ProtocolBugs{ |
| 4399 | SendClientVersion: 0x0304, |
| 4400 | OmitSupportedVersions: true, |
| 4401 | }, |
| 4402 | }, |
| 4403 | expectedVersion: VersionTLS12, |
| 4404 | }) |
| 4405 | |
| 4406 | testCases = append(testCases, testCase{ |
| 4407 | testType: serverTest, |
| 4408 | name: "ConflictingVersionNegotiation", |
| 4409 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4410 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4411 | SendClientVersion: VersionTLS12, |
| 4412 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4413 | }, |
| 4414 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4415 | // The extension takes precedence over the ClientHello version. |
| 4416 | expectedVersion: VersionTLS11, |
| 4417 | }) |
| 4418 | |
| 4419 | testCases = append(testCases, testCase{ |
| 4420 | testType: serverTest, |
| 4421 | name: "ConflictingVersionNegotiation-2", |
| 4422 | config: Config{ |
| 4423 | Bugs: ProtocolBugs{ |
| 4424 | SendClientVersion: VersionTLS11, |
| 4425 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4426 | }, |
| 4427 | }, |
| 4428 | // The extension takes precedence over the ClientHello version. |
| 4429 | expectedVersion: VersionTLS12, |
| 4430 | }) |
| 4431 | |
| 4432 | testCases = append(testCases, testCase{ |
| 4433 | testType: serverTest, |
| 4434 | name: "RejectFinalTLS13", |
| 4435 | config: Config{ |
| 4436 | Bugs: ProtocolBugs{ |
| 4437 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4438 | }, |
| 4439 | }, |
| 4440 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4441 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4442 | expectedVersion: VersionTLS12, |
| 4443 | }) |
| 4444 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4445 | // Test that the maximum version is selected regardless of the |
| 4446 | // client-sent order. |
| 4447 | testCases = append(testCases, testCase{ |
| 4448 | testType: serverTest, |
| 4449 | name: "IgnoreClientVersionOrder", |
| 4450 | config: Config{ |
| 4451 | Bugs: ProtocolBugs{ |
| 4452 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4453 | }, |
| 4454 | }, |
| 4455 | expectedVersion: VersionTLS13, |
| 4456 | }) |
| 4457 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4458 | // Test for version tolerance. |
| 4459 | testCases = append(testCases, testCase{ |
| 4460 | testType: serverTest, |
| 4461 | name: "MinorVersionTolerance", |
| 4462 | config: Config{ |
| 4463 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4464 | SendClientVersion: 0x03ff, |
| 4465 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4466 | }, |
| 4467 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4468 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4469 | }) |
| 4470 | testCases = append(testCases, testCase{ |
| 4471 | testType: serverTest, |
| 4472 | name: "MajorVersionTolerance", |
| 4473 | config: Config{ |
| 4474 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4475 | SendClientVersion: 0x0400, |
| 4476 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4477 | }, |
| 4478 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4479 | // TLS 1.3 must be negotiated with the supported_versions |
| 4480 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4481 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4482 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4483 | testCases = append(testCases, testCase{ |
| 4484 | testType: serverTest, |
| 4485 | name: "VersionTolerance-TLS13", |
| 4486 | config: Config{ |
| 4487 | Bugs: ProtocolBugs{ |
| 4488 | // Although TLS 1.3 does not use |
| 4489 | // ClientHello.version, it still tolerates high |
| 4490 | // values there. |
| 4491 | SendClientVersion: 0x0400, |
| 4492 | }, |
| 4493 | }, |
| 4494 | expectedVersion: VersionTLS13, |
| 4495 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4496 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4497 | testCases = append(testCases, testCase{ |
| 4498 | protocol: dtls, |
| 4499 | testType: serverTest, |
| 4500 | name: "MinorVersionTolerance-DTLS", |
| 4501 | config: Config{ |
| 4502 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4503 | SendClientVersion: 0xfe00, |
| 4504 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4505 | }, |
| 4506 | }, |
| 4507 | expectedVersion: VersionTLS12, |
| 4508 | }) |
| 4509 | testCases = append(testCases, testCase{ |
| 4510 | protocol: dtls, |
| 4511 | testType: serverTest, |
| 4512 | name: "MajorVersionTolerance-DTLS", |
| 4513 | config: Config{ |
| 4514 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4515 | SendClientVersion: 0xfdff, |
| 4516 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4517 | }, |
| 4518 | }, |
| 4519 | expectedVersion: VersionTLS12, |
| 4520 | }) |
| 4521 | |
| 4522 | // Test that versions below 3.0 are rejected. |
| 4523 | testCases = append(testCases, testCase{ |
| 4524 | testType: serverTest, |
| 4525 | name: "VersionTooLow", |
| 4526 | config: Config{ |
| 4527 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4528 | SendClientVersion: 0x0200, |
| 4529 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4530 | }, |
| 4531 | }, |
| 4532 | shouldFail: true, |
| 4533 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4534 | }) |
| 4535 | testCases = append(testCases, testCase{ |
| 4536 | protocol: dtls, |
| 4537 | testType: serverTest, |
| 4538 | name: "VersionTooLow-DTLS", |
| 4539 | config: Config{ |
| 4540 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4541 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4542 | }, |
| 4543 | }, |
| 4544 | shouldFail: true, |
| 4545 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4546 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4547 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4548 | testCases = append(testCases, testCase{ |
| 4549 | name: "ServerBogusVersion", |
| 4550 | config: Config{ |
| 4551 | Bugs: ProtocolBugs{ |
| 4552 | SendServerHelloVersion: 0x1234, |
| 4553 | }, |
| 4554 | }, |
| 4555 | shouldFail: true, |
| 4556 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4557 | }) |
| 4558 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4559 | // Test TLS 1.3's downgrade signal. |
| 4560 | testCases = append(testCases, testCase{ |
| 4561 | name: "Downgrade-TLS12-Client", |
| 4562 | config: Config{ |
| 4563 | Bugs: ProtocolBugs{ |
| 4564 | NegotiateVersion: VersionTLS12, |
| 4565 | }, |
| 4566 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4567 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4568 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4569 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4570 | }) |
| 4571 | testCases = append(testCases, testCase{ |
| 4572 | testType: serverTest, |
| 4573 | name: "Downgrade-TLS12-Server", |
| 4574 | config: Config{ |
| 4575 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4576 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4577 | }, |
| 4578 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4579 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4580 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4581 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4582 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4583 | } |
| 4584 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4585 | func addMinimumVersionTests() { |
| 4586 | for i, shimVers := range tlsVersions { |
| 4587 | // Assemble flags to disable all older versions on the shim. |
| 4588 | var flags []string |
| 4589 | for _, vers := range tlsVersions[:i] { |
| 4590 | flags = append(flags, vers.flag) |
| 4591 | } |
| 4592 | |
| 4593 | for _, runnerVers := range tlsVersions { |
| 4594 | protocols := []protocol{tls} |
| 4595 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4596 | protocols = append(protocols, dtls) |
| 4597 | } |
| 4598 | for _, protocol := range protocols { |
| 4599 | suffix := shimVers.name + "-" + runnerVers.name |
| 4600 | if protocol == dtls { |
| 4601 | suffix += "-DTLS" |
| 4602 | } |
| 4603 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4604 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4605 | var expectedVersion uint16 |
| 4606 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4607 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4608 | if runnerVers.version >= shimVers.version { |
| 4609 | expectedVersion = runnerVers.version |
| 4610 | } else { |
| 4611 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4612 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4613 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4614 | } |
| 4615 | |
| 4616 | testCases = append(testCases, testCase{ |
| 4617 | protocol: protocol, |
| 4618 | testType: clientTest, |
| 4619 | name: "MinimumVersion-Client-" + suffix, |
| 4620 | config: Config{ |
| 4621 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4622 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4623 | // Ensure the server does not decline to |
| 4624 | // select a version (versions extension) or |
| 4625 | // cipher (some ciphers depend on versions). |
| 4626 | NegotiateVersion: runnerVers.version, |
| 4627 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4628 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4629 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4630 | flags: flags, |
| 4631 | expectedVersion: expectedVersion, |
| 4632 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4633 | expectedError: expectedError, |
| 4634 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4635 | }) |
| 4636 | testCases = append(testCases, testCase{ |
| 4637 | protocol: protocol, |
| 4638 | testType: clientTest, |
| 4639 | name: "MinimumVersion-Client2-" + suffix, |
| 4640 | config: Config{ |
| 4641 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4642 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4643 | // Ensure the server does not decline to |
| 4644 | // select a version (versions extension) or |
| 4645 | // cipher (some ciphers depend on versions). |
| 4646 | NegotiateVersion: runnerVers.version, |
| 4647 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4648 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4649 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4650 | flags: []string{"-min-version", shimVersFlag}, |
| 4651 | expectedVersion: expectedVersion, |
| 4652 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4653 | expectedError: expectedError, |
| 4654 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4655 | }) |
| 4656 | |
| 4657 | testCases = append(testCases, testCase{ |
| 4658 | protocol: protocol, |
| 4659 | testType: serverTest, |
| 4660 | name: "MinimumVersion-Server-" + suffix, |
| 4661 | config: Config{ |
| 4662 | MaxVersion: runnerVers.version, |
| 4663 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4664 | flags: flags, |
| 4665 | expectedVersion: expectedVersion, |
| 4666 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4667 | expectedError: expectedError, |
| 4668 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4669 | }) |
| 4670 | testCases = append(testCases, testCase{ |
| 4671 | protocol: protocol, |
| 4672 | testType: serverTest, |
| 4673 | name: "MinimumVersion-Server2-" + suffix, |
| 4674 | config: Config{ |
| 4675 | MaxVersion: runnerVers.version, |
| 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 | } |
| 4685 | } |
| 4686 | } |
| 4687 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4688 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4689 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4690 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4691 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4692 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4693 | // Repeat extensions tests all versions except SSL 3.0. |
| 4694 | for _, ver := range tlsVersions { |
| 4695 | if ver.version == VersionSSL30 { |
| 4696 | continue |
| 4697 | } |
| 4698 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4699 | // Test that duplicate extensions are rejected. |
| 4700 | testCases = append(testCases, testCase{ |
| 4701 | testType: clientTest, |
| 4702 | name: "DuplicateExtensionClient-" + ver.name, |
| 4703 | config: Config{ |
| 4704 | MaxVersion: ver.version, |
| 4705 | Bugs: ProtocolBugs{ |
| 4706 | DuplicateExtension: true, |
| 4707 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4708 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4709 | shouldFail: true, |
| 4710 | expectedLocalError: "remote error: error decoding message", |
| 4711 | }) |
| 4712 | testCases = append(testCases, testCase{ |
| 4713 | testType: serverTest, |
| 4714 | name: "DuplicateExtensionServer-" + ver.name, |
| 4715 | config: Config{ |
| 4716 | MaxVersion: ver.version, |
| 4717 | Bugs: ProtocolBugs{ |
| 4718 | DuplicateExtension: true, |
| 4719 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4720 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4721 | shouldFail: true, |
| 4722 | expectedLocalError: "remote error: error decoding message", |
| 4723 | }) |
| 4724 | |
| 4725 | // Test SNI. |
| 4726 | testCases = append(testCases, testCase{ |
| 4727 | testType: clientTest, |
| 4728 | name: "ServerNameExtensionClient-" + ver.name, |
| 4729 | config: Config{ |
| 4730 | MaxVersion: ver.version, |
| 4731 | Bugs: ProtocolBugs{ |
| 4732 | ExpectServerName: "example.com", |
| 4733 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4734 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4735 | flags: []string{"-host-name", "example.com"}, |
| 4736 | }) |
| 4737 | testCases = append(testCases, testCase{ |
| 4738 | testType: clientTest, |
| 4739 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4740 | config: Config{ |
| 4741 | MaxVersion: ver.version, |
| 4742 | Bugs: ProtocolBugs{ |
| 4743 | ExpectServerName: "mismatch.com", |
| 4744 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4745 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4746 | flags: []string{"-host-name", "example.com"}, |
| 4747 | shouldFail: true, |
| 4748 | expectedLocalError: "tls: unexpected server name", |
| 4749 | }) |
| 4750 | testCases = append(testCases, testCase{ |
| 4751 | testType: clientTest, |
| 4752 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4753 | config: Config{ |
| 4754 | MaxVersion: ver.version, |
| 4755 | Bugs: ProtocolBugs{ |
| 4756 | ExpectServerName: "missing.com", |
| 4757 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4758 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4759 | shouldFail: true, |
| 4760 | expectedLocalError: "tls: unexpected server name", |
| 4761 | }) |
| 4762 | testCases = append(testCases, testCase{ |
| 4763 | testType: serverTest, |
| 4764 | name: "ServerNameExtensionServer-" + ver.name, |
| 4765 | config: Config{ |
| 4766 | MaxVersion: ver.version, |
| 4767 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4768 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4769 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4770 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4771 | }) |
| 4772 | |
| 4773 | // Test ALPN. |
| 4774 | testCases = append(testCases, testCase{ |
| 4775 | testType: clientTest, |
| 4776 | name: "ALPNClient-" + ver.name, |
| 4777 | config: Config{ |
| 4778 | MaxVersion: ver.version, |
| 4779 | NextProtos: []string{"foo"}, |
| 4780 | }, |
| 4781 | flags: []string{ |
| 4782 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4783 | "-expect-alpn", "foo", |
| 4784 | }, |
| 4785 | expectedNextProto: "foo", |
| 4786 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4787 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4788 | }) |
| 4789 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4790 | testType: clientTest, |
| 4791 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4792 | config: Config{ |
| 4793 | MaxVersion: ver.version, |
| 4794 | Bugs: ProtocolBugs{ |
| 4795 | SendALPN: "baz", |
| 4796 | }, |
| 4797 | }, |
| 4798 | flags: []string{ |
| 4799 | "-advertise-alpn", "\x03foo\x03bar", |
| 4800 | }, |
| 4801 | shouldFail: true, |
| 4802 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4803 | expectedLocalError: "remote error: illegal parameter", |
| 4804 | }) |
| 4805 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4806 | testType: serverTest, |
| 4807 | name: "ALPNServer-" + ver.name, |
| 4808 | config: Config{ |
| 4809 | MaxVersion: ver.version, |
| 4810 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4811 | }, |
| 4812 | flags: []string{ |
| 4813 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4814 | "-select-alpn", "foo", |
| 4815 | }, |
| 4816 | expectedNextProto: "foo", |
| 4817 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4818 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4819 | }) |
| 4820 | testCases = append(testCases, testCase{ |
| 4821 | testType: serverTest, |
| 4822 | name: "ALPNServer-Decline-" + ver.name, |
| 4823 | config: Config{ |
| 4824 | MaxVersion: ver.version, |
| 4825 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4826 | }, |
| 4827 | flags: []string{"-decline-alpn"}, |
| 4828 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4829 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4830 | }) |
| 4831 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4832 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4833 | // called once. |
| 4834 | testCases = append(testCases, testCase{ |
| 4835 | testType: serverTest, |
| 4836 | name: "ALPNServer-Async-" + ver.name, |
| 4837 | config: Config{ |
| 4838 | MaxVersion: ver.version, |
| 4839 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 4840 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 4841 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4842 | }, |
| 4843 | flags: []string{ |
| 4844 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4845 | "-select-alpn", "foo", |
| 4846 | "-async", |
| 4847 | }, |
| 4848 | expectedNextProto: "foo", |
| 4849 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4850 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4851 | }) |
| 4852 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4853 | var emptyString string |
| 4854 | testCases = append(testCases, testCase{ |
| 4855 | testType: clientTest, |
| 4856 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4857 | config: Config{ |
| 4858 | MaxVersion: ver.version, |
| 4859 | NextProtos: []string{""}, |
| 4860 | Bugs: ProtocolBugs{ |
| 4861 | // A server returning an empty ALPN protocol |
| 4862 | // should be rejected. |
| 4863 | ALPNProtocol: &emptyString, |
| 4864 | }, |
| 4865 | }, |
| 4866 | flags: []string{ |
| 4867 | "-advertise-alpn", "\x03foo", |
| 4868 | }, |
| 4869 | shouldFail: true, |
| 4870 | expectedError: ":PARSE_TLSEXT:", |
| 4871 | }) |
| 4872 | testCases = append(testCases, testCase{ |
| 4873 | testType: serverTest, |
| 4874 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4875 | config: Config{ |
| 4876 | MaxVersion: ver.version, |
| 4877 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4878 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4879 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4880 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4881 | flags: []string{ |
| 4882 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4883 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4884 | shouldFail: true, |
| 4885 | expectedError: ":PARSE_TLSEXT:", |
| 4886 | }) |
| 4887 | |
| 4888 | // Test NPN and the interaction with ALPN. |
| 4889 | if ver.version < VersionTLS13 { |
| 4890 | // Test that the server prefers ALPN over NPN. |
| 4891 | testCases = append(testCases, testCase{ |
| 4892 | testType: serverTest, |
| 4893 | name: "ALPNServer-Preferred-" + ver.name, |
| 4894 | config: Config{ |
| 4895 | MaxVersion: ver.version, |
| 4896 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4897 | }, |
| 4898 | flags: []string{ |
| 4899 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4900 | "-select-alpn", "foo", |
| 4901 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4902 | }, |
| 4903 | expectedNextProto: "foo", |
| 4904 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4905 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4906 | }) |
| 4907 | testCases = append(testCases, testCase{ |
| 4908 | testType: serverTest, |
| 4909 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4910 | config: Config{ |
| 4911 | MaxVersion: ver.version, |
| 4912 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4913 | Bugs: ProtocolBugs{ |
| 4914 | SwapNPNAndALPN: true, |
| 4915 | }, |
| 4916 | }, |
| 4917 | flags: []string{ |
| 4918 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4919 | "-select-alpn", "foo", |
| 4920 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4921 | }, |
| 4922 | expectedNextProto: "foo", |
| 4923 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4924 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4925 | }) |
| 4926 | |
| 4927 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4928 | testCases = append(testCases, testCase{ |
| 4929 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4930 | config: Config{ |
| 4931 | MaxVersion: ver.version, |
| 4932 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4933 | Bugs: ProtocolBugs{ |
| 4934 | NegotiateALPNAndNPN: true, |
| 4935 | }, |
| 4936 | }, |
| 4937 | flags: []string{ |
| 4938 | "-advertise-alpn", "\x03foo", |
| 4939 | "-select-next-proto", "foo", |
| 4940 | }, |
| 4941 | shouldFail: true, |
| 4942 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4943 | }) |
| 4944 | testCases = append(testCases, testCase{ |
| 4945 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4946 | config: Config{ |
| 4947 | MaxVersion: ver.version, |
| 4948 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4949 | Bugs: ProtocolBugs{ |
| 4950 | NegotiateALPNAndNPN: true, |
| 4951 | SwapNPNAndALPN: true, |
| 4952 | }, |
| 4953 | }, |
| 4954 | flags: []string{ |
| 4955 | "-advertise-alpn", "\x03foo", |
| 4956 | "-select-next-proto", "foo", |
| 4957 | }, |
| 4958 | shouldFail: true, |
| 4959 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4960 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4961 | } |
| 4962 | |
| 4963 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4964 | |
| 4965 | // Resume with a corrupt ticket. |
| 4966 | testCases = append(testCases, testCase{ |
| 4967 | testType: serverTest, |
| 4968 | name: "CorruptTicket-" + ver.name, |
| 4969 | config: Config{ |
| 4970 | MaxVersion: ver.version, |
| 4971 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 4972 | FilterTicket: func(in []byte) ([]byte, error) { |
| 4973 | in[len(in)-1] ^= 1 |
| 4974 | return in, nil |
| 4975 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4976 | }, |
| 4977 | }, |
| 4978 | resumeSession: true, |
| 4979 | expectResumeRejected: true, |
| 4980 | }) |
| 4981 | // Test the ticket callback, with and without renewal. |
| 4982 | testCases = append(testCases, testCase{ |
| 4983 | testType: serverTest, |
| 4984 | name: "TicketCallback-" + ver.name, |
| 4985 | config: Config{ |
| 4986 | MaxVersion: ver.version, |
| 4987 | }, |
| 4988 | resumeSession: true, |
| 4989 | flags: []string{"-use-ticket-callback"}, |
| 4990 | }) |
| 4991 | testCases = append(testCases, testCase{ |
| 4992 | testType: serverTest, |
| 4993 | name: "TicketCallback-Renew-" + ver.name, |
| 4994 | config: Config{ |
| 4995 | MaxVersion: ver.version, |
| 4996 | Bugs: ProtocolBugs{ |
| 4997 | ExpectNewTicket: true, |
| 4998 | }, |
| 4999 | }, |
| 5000 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5001 | resumeSession: true, |
| 5002 | }) |
| 5003 | |
| 5004 | // Test that the ticket callback is only called once when everything before |
| 5005 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5006 | // certificate selection callbacks run. |
| 5007 | testCases = append(testCases, testCase{ |
| 5008 | testType: serverTest, |
| 5009 | name: "TicketCallback-SingleCall-" + 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 | flags: []string{ |
| 5022 | "-use-ticket-callback", |
| 5023 | "-async", |
| 5024 | }, |
| 5025 | }) |
| 5026 | |
| 5027 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5028 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5029 | testCases = append(testCases, testCase{ |
| 5030 | testType: serverTest, |
| 5031 | name: "OversizedSessionId-" + ver.name, |
| 5032 | config: Config{ |
| 5033 | MaxVersion: ver.version, |
| 5034 | Bugs: ProtocolBugs{ |
| 5035 | OversizedSessionId: true, |
| 5036 | }, |
| 5037 | }, |
| 5038 | resumeSession: true, |
| 5039 | shouldFail: true, |
| 5040 | expectedError: ":DECODE_ERROR:", |
| 5041 | }) |
| 5042 | } |
| 5043 | |
| 5044 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5045 | // are ignored. |
| 5046 | if ver.hasDTLS { |
| 5047 | testCases = append(testCases, testCase{ |
| 5048 | protocol: dtls, |
| 5049 | name: "SRTP-Client-" + ver.name, |
| 5050 | config: Config{ |
| 5051 | MaxVersion: ver.version, |
| 5052 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5053 | }, |
| 5054 | flags: []string{ |
| 5055 | "-srtp-profiles", |
| 5056 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5057 | }, |
| 5058 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5059 | }) |
| 5060 | testCases = append(testCases, testCase{ |
| 5061 | protocol: dtls, |
| 5062 | testType: serverTest, |
| 5063 | name: "SRTP-Server-" + ver.name, |
| 5064 | config: Config{ |
| 5065 | MaxVersion: ver.version, |
| 5066 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5067 | }, |
| 5068 | flags: []string{ |
| 5069 | "-srtp-profiles", |
| 5070 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5071 | }, |
| 5072 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5073 | }) |
| 5074 | // Test that the MKI is ignored. |
| 5075 | testCases = append(testCases, testCase{ |
| 5076 | protocol: dtls, |
| 5077 | testType: serverTest, |
| 5078 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5079 | config: Config{ |
| 5080 | MaxVersion: ver.version, |
| 5081 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5082 | Bugs: ProtocolBugs{ |
| 5083 | SRTPMasterKeyIdentifer: "bogus", |
| 5084 | }, |
| 5085 | }, |
| 5086 | flags: []string{ |
| 5087 | "-srtp-profiles", |
| 5088 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5089 | }, |
| 5090 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5091 | }) |
| 5092 | // Test that SRTP isn't negotiated on the server if there were |
| 5093 | // no matching profiles. |
| 5094 | testCases = append(testCases, testCase{ |
| 5095 | protocol: dtls, |
| 5096 | testType: serverTest, |
| 5097 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5098 | config: Config{ |
| 5099 | MaxVersion: ver.version, |
| 5100 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5101 | }, |
| 5102 | flags: []string{ |
| 5103 | "-srtp-profiles", |
| 5104 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5105 | }, |
| 5106 | expectedSRTPProtectionProfile: 0, |
| 5107 | }) |
| 5108 | // Test that the server returning an invalid SRTP profile is |
| 5109 | // flagged as an error by the client. |
| 5110 | testCases = append(testCases, testCase{ |
| 5111 | protocol: dtls, |
| 5112 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5113 | config: Config{ |
| 5114 | MaxVersion: ver.version, |
| 5115 | Bugs: ProtocolBugs{ |
| 5116 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5117 | }, |
| 5118 | }, |
| 5119 | flags: []string{ |
| 5120 | "-srtp-profiles", |
| 5121 | "SRTP_AES128_CM_SHA1_80", |
| 5122 | }, |
| 5123 | shouldFail: true, |
| 5124 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5125 | }) |
| 5126 | } |
| 5127 | |
| 5128 | // Test SCT list. |
| 5129 | testCases = append(testCases, testCase{ |
| 5130 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5131 | testType: clientTest, |
| 5132 | config: Config{ |
| 5133 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5134 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5135 | flags: []string{ |
| 5136 | "-enable-signed-cert-timestamps", |
| 5137 | "-expect-signed-cert-timestamps", |
| 5138 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5139 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5140 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5141 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5142 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5143 | var differentSCTList []byte |
| 5144 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5145 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5146 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5147 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5148 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5149 | testCases = append(testCases, testCase{ |
| 5150 | name: "SendSCTListOnResume-" + ver.name, |
| 5151 | config: Config{ |
| 5152 | MaxVersion: ver.version, |
| 5153 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5154 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5155 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5156 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5157 | flags: []string{ |
| 5158 | "-enable-signed-cert-timestamps", |
| 5159 | "-expect-signed-cert-timestamps", |
| 5160 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5161 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5162 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5163 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5164 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5165 | testCases = append(testCases, testCase{ |
| 5166 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5167 | testType: serverTest, |
| 5168 | config: Config{ |
| 5169 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5170 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5171 | flags: []string{ |
| 5172 | "-signed-cert-timestamps", |
| 5173 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5174 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5175 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5176 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5177 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5178 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5179 | emptySCTListCert := *testCerts[0].cert |
| 5180 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5181 | |
| 5182 | // Test empty SCT list. |
| 5183 | testCases = append(testCases, testCase{ |
| 5184 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5185 | testType: clientTest, |
| 5186 | config: Config{ |
| 5187 | MaxVersion: ver.version, |
| 5188 | Certificates: []Certificate{emptySCTListCert}, |
| 5189 | }, |
| 5190 | flags: []string{ |
| 5191 | "-enable-signed-cert-timestamps", |
| 5192 | }, |
| 5193 | shouldFail: true, |
| 5194 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5195 | }) |
| 5196 | |
| 5197 | emptySCTCert := *testCerts[0].cert |
| 5198 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5199 | |
| 5200 | // Test empty SCT in non-empty list. |
| 5201 | testCases = append(testCases, testCase{ |
| 5202 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5203 | testType: clientTest, |
| 5204 | config: Config{ |
| 5205 | MaxVersion: ver.version, |
| 5206 | Certificates: []Certificate{emptySCTCert}, |
| 5207 | }, |
| 5208 | flags: []string{ |
| 5209 | "-enable-signed-cert-timestamps", |
| 5210 | }, |
| 5211 | shouldFail: true, |
| 5212 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5213 | }) |
| 5214 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5215 | // Test that certificate-related extensions are not sent unsolicited. |
| 5216 | testCases = append(testCases, testCase{ |
| 5217 | testType: serverTest, |
| 5218 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5219 | config: Config{ |
| 5220 | MaxVersion: ver.version, |
| 5221 | Bugs: ProtocolBugs{ |
| 5222 | NoOCSPStapling: true, |
| 5223 | NoSignedCertificateTimestamps: true, |
| 5224 | }, |
| 5225 | }, |
| 5226 | flags: []string{ |
| 5227 | "-ocsp-response", |
| 5228 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5229 | "-signed-cert-timestamps", |
| 5230 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5231 | }, |
| 5232 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5233 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5234 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5235 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5236 | testType: clientTest, |
| 5237 | name: "ClientHelloPadding", |
| 5238 | config: Config{ |
| 5239 | Bugs: ProtocolBugs{ |
| 5240 | RequireClientHelloSize: 512, |
| 5241 | }, |
| 5242 | }, |
| 5243 | // This hostname just needs to be long enough to push the |
| 5244 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5245 | // long. |
| 5246 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5247 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5248 | |
| 5249 | // Extensions should not function in SSL 3.0. |
| 5250 | testCases = append(testCases, testCase{ |
| 5251 | testType: serverTest, |
| 5252 | name: "SSLv3Extensions-NoALPN", |
| 5253 | config: Config{ |
| 5254 | MaxVersion: VersionSSL30, |
| 5255 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5256 | }, |
| 5257 | flags: []string{ |
| 5258 | "-select-alpn", "foo", |
| 5259 | }, |
| 5260 | expectNoNextProto: true, |
| 5261 | }) |
| 5262 | |
| 5263 | // Test session tickets separately as they follow a different codepath. |
| 5264 | testCases = append(testCases, testCase{ |
| 5265 | testType: serverTest, |
| 5266 | name: "SSLv3Extensions-NoTickets", |
| 5267 | config: Config{ |
| 5268 | MaxVersion: VersionSSL30, |
| 5269 | Bugs: ProtocolBugs{ |
| 5270 | // Historically, session tickets in SSL 3.0 |
| 5271 | // failed in different ways depending on whether |
| 5272 | // the client supported renegotiation_info. |
| 5273 | NoRenegotiationInfo: true, |
| 5274 | }, |
| 5275 | }, |
| 5276 | resumeSession: true, |
| 5277 | }) |
| 5278 | testCases = append(testCases, testCase{ |
| 5279 | testType: serverTest, |
| 5280 | name: "SSLv3Extensions-NoTickets2", |
| 5281 | config: Config{ |
| 5282 | MaxVersion: VersionSSL30, |
| 5283 | }, |
| 5284 | resumeSession: true, |
| 5285 | }) |
| 5286 | |
| 5287 | // But SSL 3.0 does send and process renegotiation_info. |
| 5288 | testCases = append(testCases, testCase{ |
| 5289 | testType: serverTest, |
| 5290 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5291 | config: Config{ |
| 5292 | MaxVersion: VersionSSL30, |
| 5293 | Bugs: ProtocolBugs{ |
| 5294 | RequireRenegotiationInfo: true, |
| 5295 | }, |
| 5296 | }, |
| 5297 | }) |
| 5298 | testCases = append(testCases, testCase{ |
| 5299 | testType: serverTest, |
| 5300 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5301 | config: Config{ |
| 5302 | MaxVersion: VersionSSL30, |
| 5303 | Bugs: ProtocolBugs{ |
| 5304 | NoRenegotiationInfo: true, |
| 5305 | SendRenegotiationSCSV: true, |
| 5306 | RequireRenegotiationInfo: true, |
| 5307 | }, |
| 5308 | }, |
| 5309 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5310 | |
| 5311 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5312 | // in ServerHello. |
| 5313 | testCases = append(testCases, testCase{ |
| 5314 | name: "NPN-Forbidden-TLS13", |
| 5315 | config: Config{ |
| 5316 | MaxVersion: VersionTLS13, |
| 5317 | NextProtos: []string{"foo"}, |
| 5318 | Bugs: ProtocolBugs{ |
| 5319 | NegotiateNPNAtAllVersions: true, |
| 5320 | }, |
| 5321 | }, |
| 5322 | flags: []string{"-select-next-proto", "foo"}, |
| 5323 | shouldFail: true, |
| 5324 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5325 | }) |
| 5326 | testCases = append(testCases, testCase{ |
| 5327 | name: "EMS-Forbidden-TLS13", |
| 5328 | config: Config{ |
| 5329 | MaxVersion: VersionTLS13, |
| 5330 | Bugs: ProtocolBugs{ |
| 5331 | NegotiateEMSAtAllVersions: true, |
| 5332 | }, |
| 5333 | }, |
| 5334 | shouldFail: true, |
| 5335 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5336 | }) |
| 5337 | testCases = append(testCases, testCase{ |
| 5338 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5339 | config: Config{ |
| 5340 | MaxVersion: VersionTLS13, |
| 5341 | Bugs: ProtocolBugs{ |
| 5342 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5343 | }, |
| 5344 | }, |
| 5345 | shouldFail: true, |
| 5346 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5347 | }) |
| 5348 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5349 | name: "Ticket-Forbidden-TLS13", |
| 5350 | config: Config{ |
| 5351 | MaxVersion: VersionTLS12, |
| 5352 | }, |
| 5353 | resumeConfig: &Config{ |
| 5354 | MaxVersion: VersionTLS13, |
| 5355 | Bugs: ProtocolBugs{ |
| 5356 | AdvertiseTicketExtension: true, |
| 5357 | }, |
| 5358 | }, |
| 5359 | resumeSession: true, |
| 5360 | shouldFail: true, |
| 5361 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5362 | }) |
| 5363 | |
| 5364 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5365 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5366 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5367 | // implicit in every test.) |
| 5368 | testCases = append(testCases, testCase{ |
| 5369 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5370 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5371 | config: Config{ |
| 5372 | MaxVersion: VersionTLS13, |
| 5373 | NextProtos: []string{"bar"}, |
| 5374 | }, |
| 5375 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5376 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5377 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5378 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5379 | // tolerated. |
| 5380 | testCases = append(testCases, testCase{ |
| 5381 | name: "SendOCSPResponseOnResume-TLS12", |
| 5382 | config: Config{ |
| 5383 | MaxVersion: VersionTLS12, |
| 5384 | Bugs: ProtocolBugs{ |
| 5385 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5386 | }, |
| 5387 | }, |
| 5388 | flags: []string{ |
| 5389 | "-enable-ocsp-stapling", |
| 5390 | "-expect-ocsp-response", |
| 5391 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5392 | }, |
| 5393 | resumeSession: true, |
| 5394 | }) |
| 5395 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5396 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5397 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5398 | config: Config{ |
| 5399 | MaxVersion: VersionTLS13, |
| 5400 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5401 | SendExtensionOnCertificate: testOCSPExtension, |
| 5402 | }, |
| 5403 | }, |
| 5404 | shouldFail: true, |
| 5405 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5406 | }) |
| 5407 | |
| 5408 | testCases = append(testCases, testCase{ |
| 5409 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5410 | config: Config{ |
| 5411 | MaxVersion: VersionTLS13, |
| 5412 | Bugs: ProtocolBugs{ |
| 5413 | SendExtensionOnCertificate: testSCTExtension, |
| 5414 | }, |
| 5415 | }, |
| 5416 | shouldFail: true, |
| 5417 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5418 | }) |
| 5419 | |
| 5420 | // Test that extensions on client certificates are never accepted. |
| 5421 | testCases = append(testCases, testCase{ |
| 5422 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5423 | testType: serverTest, |
| 5424 | config: Config{ |
| 5425 | MaxVersion: VersionTLS13, |
| 5426 | Certificates: []Certificate{rsaCertificate}, |
| 5427 | Bugs: ProtocolBugs{ |
| 5428 | SendExtensionOnCertificate: testOCSPExtension, |
| 5429 | }, |
| 5430 | }, |
| 5431 | flags: []string{ |
| 5432 | "-enable-ocsp-stapling", |
| 5433 | "-require-any-client-certificate", |
| 5434 | }, |
| 5435 | shouldFail: true, |
| 5436 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5437 | }) |
| 5438 | |
| 5439 | testCases = append(testCases, testCase{ |
| 5440 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5441 | config: Config{ |
| 5442 | MaxVersion: VersionTLS13, |
| 5443 | Bugs: ProtocolBugs{ |
| 5444 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5445 | }, |
| 5446 | }, |
| 5447 | shouldFail: true, |
| 5448 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5449 | }) |
| 5450 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5451 | var differentSCTList []byte |
| 5452 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5453 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5454 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5455 | // Test that extensions on intermediates are allowed but ignored. |
| 5456 | testCases = append(testCases, testCase{ |
| 5457 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5458 | config: Config{ |
| 5459 | MaxVersion: VersionTLS13, |
| 5460 | Certificates: []Certificate{rsaChainCertificate}, |
| 5461 | Bugs: ProtocolBugs{ |
| 5462 | // Send different values on the intermediate. This tests |
| 5463 | // the intermediate's extensions do not override the |
| 5464 | // leaf's. |
| 5465 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5466 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5467 | }, |
| 5468 | }, |
| 5469 | flags: []string{ |
| 5470 | "-enable-ocsp-stapling", |
| 5471 | "-expect-ocsp-response", |
| 5472 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5473 | "-enable-signed-cert-timestamps", |
| 5474 | "-expect-signed-cert-timestamps", |
| 5475 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5476 | }, |
| 5477 | resumeSession: true, |
| 5478 | }) |
| 5479 | |
| 5480 | // Test that extensions are not sent on intermediates when configured |
| 5481 | // only for a leaf. |
| 5482 | testCases = append(testCases, testCase{ |
| 5483 | testType: serverTest, |
| 5484 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5485 | config: Config{ |
| 5486 | MaxVersion: VersionTLS13, |
| 5487 | Bugs: ProtocolBugs{ |
| 5488 | ExpectNoExtensionsOnIntermediate: true, |
| 5489 | }, |
| 5490 | }, |
| 5491 | flags: []string{ |
| 5492 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5493 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5494 | "-ocsp-response", |
| 5495 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5496 | "-signed-cert-timestamps", |
| 5497 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5498 | }, |
| 5499 | }) |
| 5500 | |
| 5501 | // Test that extensions are not sent on client certificates. |
| 5502 | testCases = append(testCases, testCase{ |
| 5503 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5504 | config: Config{ |
| 5505 | MaxVersion: VersionTLS13, |
| 5506 | ClientAuth: RequireAnyClientCert, |
| 5507 | }, |
| 5508 | flags: []string{ |
| 5509 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5510 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5511 | "-ocsp-response", |
| 5512 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5513 | "-signed-cert-timestamps", |
| 5514 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5515 | }, |
| 5516 | }) |
| 5517 | |
| 5518 | testCases = append(testCases, testCase{ |
| 5519 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5520 | config: Config{ |
| 5521 | MaxVersion: VersionTLS13, |
| 5522 | Bugs: ProtocolBugs{ |
| 5523 | SendDuplicateCertExtensions: true, |
| 5524 | }, |
| 5525 | }, |
| 5526 | flags: []string{ |
| 5527 | "-enable-ocsp-stapling", |
| 5528 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5529 | }, |
| 5530 | resumeSession: true, |
| 5531 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5532 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5533 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5534 | |
| 5535 | testCases = append(testCases, testCase{ |
| 5536 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5537 | testType: serverTest, |
| 5538 | flags: []string{ |
| 5539 | "-signed-cert-timestamps", |
| 5540 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5541 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5542 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5543 | expectedError: ":INVALID_SCT_LIST:", |
| 5544 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5545 | } |
| 5546 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5547 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5548 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5549 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5550 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5551 | // have session IDs, so skip their cross-resumption |
| 5552 | // tests. |
| 5553 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5554 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5555 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5556 | } |
| 5557 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5558 | protocols := []protocol{tls} |
| 5559 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5560 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5561 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5562 | for _, protocol := range protocols { |
| 5563 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5564 | if protocol == dtls { |
| 5565 | suffix += "-DTLS" |
| 5566 | } |
| 5567 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5568 | if sessionVers.version == resumeVers.version { |
| 5569 | testCases = append(testCases, testCase{ |
| 5570 | protocol: protocol, |
| 5571 | name: "Resume-Client" + suffix, |
| 5572 | resumeSession: true, |
| 5573 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5574 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5575 | Bugs: ProtocolBugs{ |
| 5576 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5577 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5578 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5579 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5580 | expectedVersion: sessionVers.version, |
| 5581 | expectedResumeVersion: resumeVers.version, |
| 5582 | }) |
| 5583 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5584 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5585 | |
| 5586 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5587 | // there is no way to convince a non-lookahead client the |
| 5588 | // session was resumed. It will appear to the client that a |
| 5589 | // stray ChangeCipherSpec was sent. |
| 5590 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5591 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5592 | } |
| 5593 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5594 | testCases = append(testCases, testCase{ |
| 5595 | protocol: protocol, |
| 5596 | name: "Resume-Client-Mismatch" + suffix, |
| 5597 | resumeSession: true, |
| 5598 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5599 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5600 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5601 | expectedVersion: sessionVers.version, |
| 5602 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5603 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5604 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5605 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5606 | }, |
| 5607 | }, |
| 5608 | expectedResumeVersion: resumeVers.version, |
| 5609 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5610 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5611 | }) |
| 5612 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5613 | |
| 5614 | testCases = append(testCases, testCase{ |
| 5615 | protocol: protocol, |
| 5616 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5617 | resumeSession: true, |
| 5618 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5619 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5620 | }, |
| 5621 | expectedVersion: sessionVers.version, |
| 5622 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5623 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5624 | }, |
| 5625 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5626 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5627 | expectedResumeVersion: resumeVers.version, |
| 5628 | }) |
| 5629 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5630 | testCases = append(testCases, testCase{ |
| 5631 | protocol: protocol, |
| 5632 | testType: serverTest, |
| 5633 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5634 | resumeSession: true, |
| 5635 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5636 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5637 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5638 | expectedVersion: sessionVers.version, |
| 5639 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5640 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5641 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5642 | Bugs: ProtocolBugs{ |
| 5643 | SendBothTickets: true, |
| 5644 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5645 | }, |
| 5646 | expectedResumeVersion: resumeVers.version, |
| 5647 | }) |
| 5648 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5649 | } |
| 5650 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5651 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5652 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5653 | testCases = append(testCases, testCase{ |
| 5654 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5655 | name: "ShimTicketRewritable", |
| 5656 | resumeSession: true, |
| 5657 | config: Config{ |
| 5658 | MaxVersion: VersionTLS12, |
| 5659 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5660 | Bugs: ProtocolBugs{ |
| 5661 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5662 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5663 | if err != nil { |
| 5664 | return nil, err |
| 5665 | } |
| 5666 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5667 | }, |
| 5668 | }, |
| 5669 | }, |
| 5670 | flags: []string{ |
| 5671 | "-ticket-key", |
| 5672 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5673 | }, |
| 5674 | }) |
| 5675 | |
| 5676 | // Resumptions are declined if the version does not match. |
| 5677 | testCases = append(testCases, testCase{ |
| 5678 | testType: serverTest, |
| 5679 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5680 | resumeSession: true, |
| 5681 | config: Config{ |
| 5682 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5683 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5684 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5685 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5686 | return SetShimTicketVersion(in, VersionTLS13) |
| 5687 | }, |
| 5688 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5689 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5690 | flags: []string{ |
| 5691 | "-ticket-key", |
| 5692 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5693 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5694 | expectResumeRejected: true, |
| 5695 | }) |
| 5696 | |
| 5697 | testCases = append(testCases, testCase{ |
| 5698 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5699 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5700 | resumeSession: true, |
| 5701 | config: Config{ |
| 5702 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5703 | Bugs: ProtocolBugs{ |
| 5704 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5705 | return SetShimTicketVersion(in, VersionTLS12) |
| 5706 | }, |
| 5707 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5708 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5709 | flags: []string{ |
| 5710 | "-ticket-key", |
| 5711 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5712 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5713 | expectResumeRejected: true, |
| 5714 | }) |
| 5715 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5716 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5717 | testCases = append(testCases, testCase{ |
| 5718 | testType: serverTest, |
| 5719 | name: "Resume-Server-DeclineBadCipher", |
| 5720 | resumeSession: true, |
| 5721 | config: Config{ |
| 5722 | MaxVersion: VersionTLS12, |
| 5723 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5724 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5725 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5726 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5727 | }, |
| 5728 | }, |
| 5729 | }, |
| 5730 | flags: []string{ |
| 5731 | "-ticket-key", |
| 5732 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5733 | }, |
| 5734 | expectResumeRejected: true, |
| 5735 | }) |
| 5736 | |
| 5737 | testCases = append(testCases, testCase{ |
| 5738 | testType: serverTest, |
| 5739 | name: "Resume-Server-DeclineBadCipher-2", |
| 5740 | resumeSession: true, |
| 5741 | config: Config{ |
| 5742 | MaxVersion: VersionTLS12, |
| 5743 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5744 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5745 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5746 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5747 | }, |
| 5748 | }, |
| 5749 | }, |
| 5750 | flags: []string{ |
| 5751 | "-cipher", "AES128", |
| 5752 | "-ticket-key", |
| 5753 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5754 | }, |
| 5755 | expectResumeRejected: true, |
| 5756 | }) |
| 5757 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5758 | // Sessions are not resumed if they do not use the preferred cipher. |
| 5759 | testCases = append(testCases, testCase{ |
| 5760 | testType: serverTest, |
| 5761 | name: "Resume-Server-CipherNotPreferred", |
| 5762 | resumeSession: true, |
| 5763 | config: Config{ |
| 5764 | MaxVersion: VersionTLS12, |
| 5765 | Bugs: ProtocolBugs{ |
| 5766 | ExpectNewTicket: true, |
| 5767 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5768 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 5769 | }, |
| 5770 | }, |
| 5771 | }, |
| 5772 | flags: []string{ |
| 5773 | "-ticket-key", |
| 5774 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5775 | }, |
| 5776 | shouldFail: false, |
| 5777 | expectResumeRejected: true, |
| 5778 | }) |
| 5779 | |
| 5780 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 5781 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 5782 | testCases = append(testCases, testCase{ |
| 5783 | testType: serverTest, |
| 5784 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 5785 | resumeSession: true, |
| 5786 | config: Config{ |
| 5787 | MaxVersion: VersionTLS13, |
| 5788 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 5789 | Bugs: ProtocolBugs{ |
| 5790 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5791 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 5792 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 5793 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5794 | }, |
| 5795 | }, |
| 5796 | }, |
| 5797 | flags: []string{ |
| 5798 | "-ticket-key", |
| 5799 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5800 | }, |
| 5801 | shouldFail: false, |
| 5802 | expectResumeRejected: true, |
| 5803 | }) |
| 5804 | |
| 5805 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5806 | testCases = append(testCases, testCase{ |
| 5807 | testType: serverTest, |
| 5808 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5809 | resumeSession: true, |
| 5810 | config: Config{ |
| 5811 | MaxVersion: VersionTLS13, |
| 5812 | Bugs: ProtocolBugs{ |
| 5813 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5814 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5815 | }, |
| 5816 | }, |
| 5817 | }, |
| 5818 | flags: []string{ |
| 5819 | "-ticket-key", |
| 5820 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5821 | }, |
| 5822 | expectResumeRejected: true, |
| 5823 | }) |
| 5824 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5825 | // If the client does not offer the cipher from the session, decline to |
| 5826 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 5827 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5828 | testCases = append(testCases, testCase{ |
| 5829 | testType: serverTest, |
| 5830 | name: "Resume-Server-UnofferedCipher", |
| 5831 | resumeSession: true, |
| 5832 | config: Config{ |
| 5833 | MaxVersion: VersionTLS12, |
| 5834 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5835 | }, |
| 5836 | resumeConfig: &Config{ |
| 5837 | MaxVersion: VersionTLS12, |
| 5838 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5839 | Bugs: ProtocolBugs{ |
| 5840 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5841 | }, |
| 5842 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5843 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5844 | }) |
| 5845 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5846 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 5847 | // include the selected cipher. Test that we tolerate this. Servers may |
| 5848 | // resume at another cipher if the PRF matches, but BoringSSL will |
| 5849 | // always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5850 | testCases = append(testCases, testCase{ |
| 5851 | testType: serverTest, |
| 5852 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5853 | resumeSession: true, |
| 5854 | config: Config{ |
| 5855 | MaxVersion: VersionTLS13, |
| 5856 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5857 | }, |
| 5858 | resumeConfig: &Config{ |
| 5859 | MaxVersion: VersionTLS13, |
| 5860 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5861 | Bugs: ProtocolBugs{ |
| 5862 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5863 | }, |
| 5864 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5865 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5866 | }) |
| 5867 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5868 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5869 | testCases = append(testCases, testCase{ |
| 5870 | name: "Resume-Client-CipherMismatch", |
| 5871 | resumeSession: true, |
| 5872 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5873 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5874 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5875 | }, |
| 5876 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5877 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5878 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5879 | Bugs: ProtocolBugs{ |
| 5880 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5881 | }, |
| 5882 | }, |
| 5883 | shouldFail: true, |
| 5884 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5885 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5886 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5887 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 5888 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5889 | testCases = append(testCases, testCase{ |
| 5890 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5891 | resumeSession: true, |
| 5892 | config: Config{ |
| 5893 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5894 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5895 | }, |
| 5896 | resumeConfig: &Config{ |
| 5897 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5898 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5899 | }, |
| 5900 | }) |
| 5901 | |
| 5902 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 5903 | testCases = append(testCases, testCase{ |
| 5904 | name: "Resume-Client-PRFMismatch-TLS13", |
| 5905 | resumeSession: true, |
| 5906 | config: Config{ |
| 5907 | MaxVersion: VersionTLS13, |
| 5908 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5909 | }, |
| 5910 | resumeConfig: &Config{ |
| 5911 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5912 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5913 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5914 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5915 | }, |
| 5916 | }, |
| 5917 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5918 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5919 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5920 | |
| 5921 | testCases = append(testCases, testCase{ |
| 5922 | testType: serverTest, |
| 5923 | name: "Resume-Server-BinderWrongLength", |
| 5924 | resumeSession: true, |
| 5925 | config: Config{ |
| 5926 | MaxVersion: VersionTLS13, |
| 5927 | Bugs: ProtocolBugs{ |
| 5928 | SendShortPSKBinder: true, |
| 5929 | }, |
| 5930 | }, |
| 5931 | shouldFail: true, |
| 5932 | expectedLocalError: "remote error: error decrypting message", |
| 5933 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5934 | }) |
| 5935 | |
| 5936 | testCases = append(testCases, testCase{ |
| 5937 | testType: serverTest, |
| 5938 | name: "Resume-Server-NoPSKBinder", |
| 5939 | resumeSession: true, |
| 5940 | config: Config{ |
| 5941 | MaxVersion: VersionTLS13, |
| 5942 | Bugs: ProtocolBugs{ |
| 5943 | SendNoPSKBinder: true, |
| 5944 | }, |
| 5945 | }, |
| 5946 | shouldFail: true, |
| 5947 | expectedLocalError: "remote error: error decoding message", |
| 5948 | expectedError: ":DECODE_ERROR:", |
| 5949 | }) |
| 5950 | |
| 5951 | testCases = append(testCases, testCase{ |
| 5952 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 5953 | name: "Resume-Server-ExtraPSKBinder", |
| 5954 | resumeSession: true, |
| 5955 | config: Config{ |
| 5956 | MaxVersion: VersionTLS13, |
| 5957 | Bugs: ProtocolBugs{ |
| 5958 | SendExtraPSKBinder: true, |
| 5959 | }, |
| 5960 | }, |
| 5961 | shouldFail: true, |
| 5962 | expectedLocalError: "remote error: illegal parameter", |
| 5963 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 5964 | }) |
| 5965 | |
| 5966 | testCases = append(testCases, testCase{ |
| 5967 | testType: serverTest, |
| 5968 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 5969 | resumeSession: true, |
| 5970 | config: Config{ |
| 5971 | MaxVersion: VersionTLS13, |
| 5972 | Bugs: ProtocolBugs{ |
| 5973 | ExtraPSKIdentity: true, |
| 5974 | }, |
| 5975 | }, |
| 5976 | shouldFail: true, |
| 5977 | expectedLocalError: "remote error: illegal parameter", |
| 5978 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 5979 | }) |
| 5980 | |
| 5981 | testCases = append(testCases, testCase{ |
| 5982 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5983 | name: "Resume-Server-InvalidPSKBinder", |
| 5984 | resumeSession: true, |
| 5985 | config: Config{ |
| 5986 | MaxVersion: VersionTLS13, |
| 5987 | Bugs: ProtocolBugs{ |
| 5988 | SendInvalidPSKBinder: true, |
| 5989 | }, |
| 5990 | }, |
| 5991 | shouldFail: true, |
| 5992 | expectedLocalError: "remote error: error decrypting message", |
| 5993 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5994 | }) |
| 5995 | |
| 5996 | testCases = append(testCases, testCase{ |
| 5997 | testType: serverTest, |
| 5998 | name: "Resume-Server-PSKBinderFirstExtension", |
| 5999 | resumeSession: true, |
| 6000 | config: Config{ |
| 6001 | MaxVersion: VersionTLS13, |
| 6002 | Bugs: ProtocolBugs{ |
| 6003 | PSKBinderFirst: true, |
| 6004 | }, |
| 6005 | }, |
| 6006 | shouldFail: true, |
| 6007 | expectedLocalError: "remote error: illegal parameter", |
| 6008 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6009 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6010 | } |
| 6011 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6012 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6013 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6014 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6015 | testType: serverTest, |
| 6016 | name: "Renegotiate-Server-Forbidden", |
| 6017 | config: Config{ |
| 6018 | MaxVersion: VersionTLS12, |
| 6019 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6020 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6021 | shouldFail: true, |
| 6022 | expectedError: ":NO_RENEGOTIATION:", |
| 6023 | expectedLocalError: "remote error: no renegotiation", |
| 6024 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6025 | // The server shouldn't echo the renegotiation extension unless |
| 6026 | // requested by the client. |
| 6027 | testCases = append(testCases, testCase{ |
| 6028 | testType: serverTest, |
| 6029 | name: "Renegotiate-Server-NoExt", |
| 6030 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6031 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6032 | Bugs: ProtocolBugs{ |
| 6033 | NoRenegotiationInfo: true, |
| 6034 | RequireRenegotiationInfo: true, |
| 6035 | }, |
| 6036 | }, |
| 6037 | shouldFail: true, |
| 6038 | expectedLocalError: "renegotiation extension missing", |
| 6039 | }) |
| 6040 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6041 | // the extension. |
| 6042 | testCases = append(testCases, testCase{ |
| 6043 | testType: serverTest, |
| 6044 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6045 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6046 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6047 | Bugs: ProtocolBugs{ |
| 6048 | NoRenegotiationInfo: true, |
| 6049 | SendRenegotiationSCSV: true, |
| 6050 | RequireRenegotiationInfo: true, |
| 6051 | }, |
| 6052 | }, |
| 6053 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6054 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6055 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6056 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6057 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6058 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6059 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6060 | }, |
| 6061 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6062 | renegotiate: 1, |
| 6063 | flags: []string{ |
| 6064 | "-renegotiate-freely", |
| 6065 | "-expect-total-renegotiations", "1", |
| 6066 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6067 | }) |
| 6068 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6069 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6070 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6071 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6072 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6073 | Bugs: ProtocolBugs{ |
| 6074 | EmptyRenegotiationInfo: true, |
| 6075 | }, |
| 6076 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6077 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6078 | shouldFail: true, |
| 6079 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6080 | }) |
| 6081 | testCases = append(testCases, testCase{ |
| 6082 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6083 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6084 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6085 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6086 | Bugs: ProtocolBugs{ |
| 6087 | BadRenegotiationInfo: true, |
| 6088 | }, |
| 6089 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6090 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6091 | shouldFail: true, |
| 6092 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6093 | }) |
| 6094 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6095 | name: "Renegotiate-Client-Downgrade", |
| 6096 | renegotiate: 1, |
| 6097 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6098 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6099 | Bugs: ProtocolBugs{ |
| 6100 | NoRenegotiationInfoAfterInitial: true, |
| 6101 | }, |
| 6102 | }, |
| 6103 | flags: []string{"-renegotiate-freely"}, |
| 6104 | shouldFail: true, |
| 6105 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6106 | }) |
| 6107 | testCases = append(testCases, testCase{ |
| 6108 | name: "Renegotiate-Client-Upgrade", |
| 6109 | renegotiate: 1, |
| 6110 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6111 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6112 | Bugs: ProtocolBugs{ |
| 6113 | NoRenegotiationInfoInInitial: true, |
| 6114 | }, |
| 6115 | }, |
| 6116 | flags: []string{"-renegotiate-freely"}, |
| 6117 | shouldFail: true, |
| 6118 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6119 | }) |
| 6120 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6121 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6122 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6123 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6124 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6125 | Bugs: ProtocolBugs{ |
| 6126 | NoRenegotiationInfo: true, |
| 6127 | }, |
| 6128 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6129 | flags: []string{ |
| 6130 | "-renegotiate-freely", |
| 6131 | "-expect-total-renegotiations", "1", |
| 6132 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6133 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6134 | |
| 6135 | // Test that the server may switch ciphers on renegotiation without |
| 6136 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6137 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6138 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6139 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6140 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6141 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6142 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6143 | }, |
| 6144 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6145 | flags: []string{ |
| 6146 | "-renegotiate-freely", |
| 6147 | "-expect-total-renegotiations", "1", |
| 6148 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6149 | }) |
| 6150 | testCases = append(testCases, testCase{ |
| 6151 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6152 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6153 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6154 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6155 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6156 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6157 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6158 | flags: []string{ |
| 6159 | "-renegotiate-freely", |
| 6160 | "-expect-total-renegotiations", "1", |
| 6161 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6162 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6163 | |
| 6164 | // Test that the server may not switch versions on renegotiation. |
| 6165 | testCases = append(testCases, testCase{ |
| 6166 | name: "Renegotiate-Client-SwitchVersion", |
| 6167 | config: Config{ |
| 6168 | MaxVersion: VersionTLS12, |
| 6169 | // Pick a cipher which exists at both versions. |
| 6170 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6171 | Bugs: ProtocolBugs{ |
| 6172 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6173 | // Avoid failing early at the record layer. |
| 6174 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6175 | }, |
| 6176 | }, |
| 6177 | renegotiate: 1, |
| 6178 | flags: []string{ |
| 6179 | "-renegotiate-freely", |
| 6180 | "-expect-total-renegotiations", "1", |
| 6181 | }, |
| 6182 | shouldFail: true, |
| 6183 | expectedError: ":WRONG_SSL_VERSION:", |
| 6184 | }) |
| 6185 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6186 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6187 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6188 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6189 | config: Config{ |
| 6190 | MaxVersion: VersionTLS10, |
| 6191 | Bugs: ProtocolBugs{ |
| 6192 | RequireSameRenegoClientVersion: true, |
| 6193 | }, |
| 6194 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6195 | flags: []string{ |
| 6196 | "-renegotiate-freely", |
| 6197 | "-expect-total-renegotiations", "1", |
| 6198 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6199 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6200 | testCases = append(testCases, testCase{ |
| 6201 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6202 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6203 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6204 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6205 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6206 | NextProtos: []string{"foo"}, |
| 6207 | }, |
| 6208 | flags: []string{ |
| 6209 | "-false-start", |
| 6210 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6211 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6212 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6213 | }, |
| 6214 | shimWritesFirst: true, |
| 6215 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6216 | |
| 6217 | // Client-side renegotiation controls. |
| 6218 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6219 | name: "Renegotiate-Client-Forbidden-1", |
| 6220 | config: Config{ |
| 6221 | MaxVersion: VersionTLS12, |
| 6222 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6223 | renegotiate: 1, |
| 6224 | shouldFail: true, |
| 6225 | expectedError: ":NO_RENEGOTIATION:", |
| 6226 | expectedLocalError: "remote error: no renegotiation", |
| 6227 | }) |
| 6228 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6229 | name: "Renegotiate-Client-Once-1", |
| 6230 | config: Config{ |
| 6231 | MaxVersion: VersionTLS12, |
| 6232 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6233 | renegotiate: 1, |
| 6234 | flags: []string{ |
| 6235 | "-renegotiate-once", |
| 6236 | "-expect-total-renegotiations", "1", |
| 6237 | }, |
| 6238 | }) |
| 6239 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6240 | name: "Renegotiate-Client-Freely-1", |
| 6241 | config: Config{ |
| 6242 | MaxVersion: VersionTLS12, |
| 6243 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6244 | renegotiate: 1, |
| 6245 | flags: []string{ |
| 6246 | "-renegotiate-freely", |
| 6247 | "-expect-total-renegotiations", "1", |
| 6248 | }, |
| 6249 | }) |
| 6250 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6251 | name: "Renegotiate-Client-Once-2", |
| 6252 | config: Config{ |
| 6253 | MaxVersion: VersionTLS12, |
| 6254 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6255 | renegotiate: 2, |
| 6256 | flags: []string{"-renegotiate-once"}, |
| 6257 | shouldFail: true, |
| 6258 | expectedError: ":NO_RENEGOTIATION:", |
| 6259 | expectedLocalError: "remote error: no renegotiation", |
| 6260 | }) |
| 6261 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6262 | name: "Renegotiate-Client-Freely-2", |
| 6263 | config: Config{ |
| 6264 | MaxVersion: VersionTLS12, |
| 6265 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6266 | renegotiate: 2, |
| 6267 | flags: []string{ |
| 6268 | "-renegotiate-freely", |
| 6269 | "-expect-total-renegotiations", "2", |
| 6270 | }, |
| 6271 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6272 | testCases = append(testCases, testCase{ |
| 6273 | name: "Renegotiate-Client-NoIgnore", |
| 6274 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6275 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6276 | Bugs: ProtocolBugs{ |
| 6277 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6278 | }, |
| 6279 | }, |
| 6280 | shouldFail: true, |
| 6281 | expectedError: ":NO_RENEGOTIATION:", |
| 6282 | }) |
| 6283 | testCases = append(testCases, testCase{ |
| 6284 | name: "Renegotiate-Client-Ignore", |
| 6285 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6286 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6287 | Bugs: ProtocolBugs{ |
| 6288 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6289 | }, |
| 6290 | }, |
| 6291 | flags: []string{ |
| 6292 | "-renegotiate-ignore", |
| 6293 | "-expect-total-renegotiations", "0", |
| 6294 | }, |
| 6295 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6296 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6297 | // Renegotiation is not allowed at SSL 3.0. |
| 6298 | testCases = append(testCases, testCase{ |
| 6299 | name: "Renegotiate-Client-SSL3", |
| 6300 | config: Config{ |
| 6301 | MaxVersion: VersionSSL30, |
| 6302 | }, |
| 6303 | renegotiate: 1, |
| 6304 | flags: []string{ |
| 6305 | "-renegotiate-freely", |
| 6306 | "-expect-total-renegotiations", "1", |
| 6307 | }, |
| 6308 | shouldFail: true, |
| 6309 | expectedError: ":NO_RENEGOTIATION:", |
| 6310 | expectedLocalError: "remote error: no renegotiation", |
| 6311 | }) |
| 6312 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6313 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6314 | testCases = append(testCases, testCase{ |
| 6315 | name: "StrayHelloRequest", |
| 6316 | config: Config{ |
| 6317 | MaxVersion: VersionTLS12, |
| 6318 | Bugs: ProtocolBugs{ |
| 6319 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6320 | }, |
| 6321 | }, |
| 6322 | }) |
| 6323 | testCases = append(testCases, testCase{ |
| 6324 | name: "StrayHelloRequest-Packed", |
| 6325 | config: Config{ |
| 6326 | MaxVersion: VersionTLS12, |
| 6327 | Bugs: ProtocolBugs{ |
| 6328 | PackHandshakeFlight: true, |
| 6329 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6330 | }, |
| 6331 | }, |
| 6332 | }) |
| 6333 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6334 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6335 | // the same record. |
| 6336 | testCases = append(testCases, testCase{ |
| 6337 | name: "Renegotiate-Client-Packed", |
| 6338 | config: Config{ |
| 6339 | MaxVersion: VersionTLS12, |
| 6340 | Bugs: ProtocolBugs{ |
| 6341 | PackHandshakeFlight: true, |
| 6342 | PackHelloRequestWithFinished: true, |
| 6343 | }, |
| 6344 | }, |
| 6345 | renegotiate: 1, |
| 6346 | flags: []string{ |
| 6347 | "-renegotiate-freely", |
| 6348 | "-expect-total-renegotiations", "1", |
| 6349 | }, |
| 6350 | }) |
| 6351 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6352 | // Renegotiation is forbidden in TLS 1.3. |
| 6353 | testCases = append(testCases, testCase{ |
| 6354 | name: "Renegotiate-Client-TLS13", |
| 6355 | config: Config{ |
| 6356 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6357 | Bugs: ProtocolBugs{ |
| 6358 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6359 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6360 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6361 | flags: []string{ |
| 6362 | "-renegotiate-freely", |
| 6363 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6364 | shouldFail: true, |
| 6365 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6366 | }) |
| 6367 | |
| 6368 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6369 | testCases = append(testCases, testCase{ |
| 6370 | name: "StrayHelloRequest-TLS13", |
| 6371 | config: Config{ |
| 6372 | MaxVersion: VersionTLS13, |
| 6373 | Bugs: ProtocolBugs{ |
| 6374 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6375 | }, |
| 6376 | }, |
| 6377 | shouldFail: true, |
| 6378 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6379 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6380 | } |
| 6381 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6382 | func addDTLSReplayTests() { |
| 6383 | // Test that sequence number replays are detected. |
| 6384 | testCases = append(testCases, testCase{ |
| 6385 | protocol: dtls, |
| 6386 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6387 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6388 | replayWrites: true, |
| 6389 | }) |
| 6390 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6391 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6392 | // than the retransmit window. |
| 6393 | testCases = append(testCases, testCase{ |
| 6394 | protocol: dtls, |
| 6395 | name: "DTLS-Replay-LargeGaps", |
| 6396 | config: Config{ |
| 6397 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6398 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6399 | return in * 127 |
| 6400 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6401 | }, |
| 6402 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6403 | messageCount: 200, |
| 6404 | replayWrites: true, |
| 6405 | }) |
| 6406 | |
| 6407 | // Test the incoming sequence number changing non-monotonically. |
| 6408 | testCases = append(testCases, testCase{ |
| 6409 | protocol: dtls, |
| 6410 | name: "DTLS-Replay-NonMonotonic", |
| 6411 | config: Config{ |
| 6412 | Bugs: ProtocolBugs{ |
| 6413 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6414 | return in ^ 31 |
| 6415 | }, |
| 6416 | }, |
| 6417 | }, |
| 6418 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6419 | replayWrites: true, |
| 6420 | }) |
| 6421 | } |
| 6422 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6423 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6424 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6425 | id signatureAlgorithm |
| 6426 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6427 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6428 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6429 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6430 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6431 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6432 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6433 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6434 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6435 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6436 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6437 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6438 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6439 | // Tests for key types prior to TLS 1.2. |
| 6440 | {"RSA", 0, testCertRSA}, |
| 6441 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6442 | } |
| 6443 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6444 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6445 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6446 | |
| 6447 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6448 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6449 | // versions a signing cipher. |
| 6450 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6451 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6452 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6453 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6454 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6455 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6456 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6457 | } |
| 6458 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6459 | var allAlgorithms []signatureAlgorithm |
| 6460 | for _, alg := range testSignatureAlgorithms { |
| 6461 | if alg.id != 0 { |
| 6462 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6463 | } |
| 6464 | } |
| 6465 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6466 | // Make sure each signature algorithm works. Include some fake values in |
| 6467 | // the list and ensure they're ignored. |
| 6468 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6469 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6470 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6471 | continue |
| 6472 | } |
| 6473 | |
| 6474 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6475 | // or remove it in C. |
| 6476 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6477 | continue |
| 6478 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6479 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6480 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6481 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6482 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6483 | shouldSignFail = true |
| 6484 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6485 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6486 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6487 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6488 | shouldSignFail = true |
| 6489 | shouldVerifyFail = true |
| 6490 | } |
| 6491 | |
| 6492 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6493 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6494 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6495 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6496 | |
| 6497 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6498 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6499 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6500 | } |
| 6501 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6502 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6503 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6504 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6505 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6506 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6507 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6508 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6509 | config: Config{ |
| 6510 | MaxVersion: ver.version, |
| 6511 | ClientAuth: RequireAnyClientCert, |
| 6512 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6513 | fakeSigAlg1, |
| 6514 | alg.id, |
| 6515 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6516 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6517 | }, |
| 6518 | flags: []string{ |
| 6519 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6520 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6521 | "-enable-all-curves", |
| 6522 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6523 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6524 | expectedError: signError, |
| 6525 | expectedPeerSignatureAlgorithm: alg.id, |
| 6526 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6527 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6528 | testCases = append(testCases, testCase{ |
| 6529 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6530 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6531 | config: Config{ |
| 6532 | MaxVersion: ver.version, |
| 6533 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6534 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6535 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6536 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6537 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6538 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6539 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6540 | // Some signature algorithms may not be advertised. |
| 6541 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6542 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6543 | }, |
| 6544 | flags: []string{ |
| 6545 | "-require-any-client-certificate", |
| 6546 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6547 | "-enable-all-curves", |
| 6548 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6549 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6550 | expectedError: verifyError, |
| 6551 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6552 | |
| 6553 | testCases = append(testCases, testCase{ |
| 6554 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6555 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6556 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6557 | MaxVersion: ver.version, |
| 6558 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6559 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6560 | fakeSigAlg1, |
| 6561 | alg.id, |
| 6562 | fakeSigAlg2, |
| 6563 | }, |
| 6564 | }, |
| 6565 | flags: []string{ |
| 6566 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6567 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6568 | "-enable-all-curves", |
| 6569 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6570 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6571 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6572 | expectedPeerSignatureAlgorithm: alg.id, |
| 6573 | }) |
| 6574 | |
| 6575 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6576 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6577 | config: Config{ |
| 6578 | MaxVersion: ver.version, |
| 6579 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6580 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6581 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6582 | alg.id, |
| 6583 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6584 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6585 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6586 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6587 | // Some signature algorithms may not be advertised. |
| 6588 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6589 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6590 | }, |
| 6591 | flags: []string{ |
| 6592 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6593 | "-enable-all-curves", |
| 6594 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6595 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6596 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6597 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6598 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6599 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6600 | testCases = append(testCases, testCase{ |
| 6601 | testType: serverTest, |
| 6602 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6603 | config: Config{ |
| 6604 | MaxVersion: ver.version, |
| 6605 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6606 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6607 | alg.id, |
| 6608 | }, |
| 6609 | Bugs: ProtocolBugs{ |
| 6610 | InvalidSignature: true, |
| 6611 | }, |
| 6612 | }, |
| 6613 | flags: []string{ |
| 6614 | "-require-any-client-certificate", |
| 6615 | "-enable-all-curves", |
| 6616 | }, |
| 6617 | shouldFail: true, |
| 6618 | expectedError: ":BAD_SIGNATURE:", |
| 6619 | }) |
| 6620 | |
| 6621 | testCases = append(testCases, testCase{ |
| 6622 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6623 | config: Config{ |
| 6624 | MaxVersion: ver.version, |
| 6625 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6626 | CipherSuites: signingCiphers, |
| 6627 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6628 | alg.id, |
| 6629 | }, |
| 6630 | Bugs: ProtocolBugs{ |
| 6631 | InvalidSignature: true, |
| 6632 | }, |
| 6633 | }, |
| 6634 | flags: []string{"-enable-all-curves"}, |
| 6635 | shouldFail: true, |
| 6636 | expectedError: ":BAD_SIGNATURE:", |
| 6637 | }) |
| 6638 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6639 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6640 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6641 | testCases = append(testCases, testCase{ |
| 6642 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6643 | config: Config{ |
| 6644 | MaxVersion: ver.version, |
| 6645 | ClientAuth: RequireAnyClientCert, |
| 6646 | VerifySignatureAlgorithms: allAlgorithms, |
| 6647 | }, |
| 6648 | flags: []string{ |
| 6649 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6650 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6651 | "-enable-all-curves", |
| 6652 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6653 | }, |
| 6654 | expectedPeerSignatureAlgorithm: alg.id, |
| 6655 | }) |
| 6656 | |
| 6657 | testCases = append(testCases, testCase{ |
| 6658 | testType: serverTest, |
| 6659 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6660 | config: Config{ |
| 6661 | MaxVersion: ver.version, |
| 6662 | CipherSuites: signingCiphers, |
| 6663 | VerifySignatureAlgorithms: allAlgorithms, |
| 6664 | }, |
| 6665 | flags: []string{ |
| 6666 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6667 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6668 | "-enable-all-curves", |
| 6669 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6670 | }, |
| 6671 | expectedPeerSignatureAlgorithm: alg.id, |
| 6672 | }) |
| 6673 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6674 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6675 | } |
| 6676 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6677 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6678 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6679 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6680 | config: Config{ |
| 6681 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6682 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6683 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6684 | signatureECDSAWithP521AndSHA512, |
| 6685 | signatureRSAPKCS1WithSHA384, |
| 6686 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6687 | }, |
| 6688 | }, |
| 6689 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6690 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6691 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6692 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6693 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6694 | }) |
| 6695 | |
| 6696 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6697 | name: "ClientAuth-SignatureType-TLS13", |
| 6698 | config: Config{ |
| 6699 | ClientAuth: RequireAnyClientCert, |
| 6700 | MaxVersion: VersionTLS13, |
| 6701 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6702 | signatureECDSAWithP521AndSHA512, |
| 6703 | signatureRSAPKCS1WithSHA384, |
| 6704 | signatureRSAPSSWithSHA384, |
| 6705 | signatureECDSAWithSHA1, |
| 6706 | }, |
| 6707 | }, |
| 6708 | flags: []string{ |
| 6709 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6710 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6711 | }, |
| 6712 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6713 | }) |
| 6714 | |
| 6715 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6716 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6717 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6718 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6719 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6720 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6721 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6722 | signatureECDSAWithP521AndSHA512, |
| 6723 | signatureRSAPKCS1WithSHA384, |
| 6724 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6725 | }, |
| 6726 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6727 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6728 | }) |
| 6729 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6730 | testCases = append(testCases, testCase{ |
| 6731 | testType: serverTest, |
| 6732 | name: "ServerAuth-SignatureType-TLS13", |
| 6733 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6734 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6735 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6736 | signatureECDSAWithP521AndSHA512, |
| 6737 | signatureRSAPKCS1WithSHA384, |
| 6738 | signatureRSAPSSWithSHA384, |
| 6739 | signatureECDSAWithSHA1, |
| 6740 | }, |
| 6741 | }, |
| 6742 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6743 | }) |
| 6744 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6745 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6746 | testCases = append(testCases, testCase{ |
| 6747 | testType: serverTest, |
| 6748 | name: "Verify-ClientAuth-SignatureType", |
| 6749 | config: Config{ |
| 6750 | MaxVersion: VersionTLS12, |
| 6751 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6752 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6753 | signatureRSAPKCS1WithSHA256, |
| 6754 | }, |
| 6755 | Bugs: ProtocolBugs{ |
| 6756 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6757 | }, |
| 6758 | }, |
| 6759 | flags: []string{ |
| 6760 | "-require-any-client-certificate", |
| 6761 | }, |
| 6762 | shouldFail: true, |
| 6763 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6764 | }) |
| 6765 | |
| 6766 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6767 | testType: serverTest, |
| 6768 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6769 | config: Config{ |
| 6770 | MaxVersion: VersionTLS13, |
| 6771 | Certificates: []Certificate{rsaCertificate}, |
| 6772 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6773 | signatureRSAPSSWithSHA256, |
| 6774 | }, |
| 6775 | Bugs: ProtocolBugs{ |
| 6776 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6777 | }, |
| 6778 | }, |
| 6779 | flags: []string{ |
| 6780 | "-require-any-client-certificate", |
| 6781 | }, |
| 6782 | shouldFail: true, |
| 6783 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6784 | }) |
| 6785 | |
| 6786 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6787 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6788 | config: Config{ |
| 6789 | MaxVersion: VersionTLS12, |
| 6790 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6791 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6792 | signatureRSAPKCS1WithSHA256, |
| 6793 | }, |
| 6794 | Bugs: ProtocolBugs{ |
| 6795 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6796 | }, |
| 6797 | }, |
| 6798 | shouldFail: true, |
| 6799 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6800 | }) |
| 6801 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6802 | testCases = append(testCases, testCase{ |
| 6803 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6804 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6805 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6806 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6807 | signatureRSAPSSWithSHA256, |
| 6808 | }, |
| 6809 | Bugs: ProtocolBugs{ |
| 6810 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6811 | }, |
| 6812 | }, |
| 6813 | shouldFail: true, |
| 6814 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6815 | }) |
| 6816 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6817 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6818 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6819 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6820 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6821 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6822 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6823 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6824 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6825 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6826 | }, |
| 6827 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6828 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6829 | }, |
| 6830 | }, |
| 6831 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6832 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6833 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6834 | }, |
| 6835 | }) |
| 6836 | |
| 6837 | testCases = append(testCases, testCase{ |
| 6838 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6839 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6840 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6841 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6842 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6843 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6844 | }, |
| 6845 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6846 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6847 | }, |
| 6848 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6849 | flags: []string{ |
| 6850 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6851 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6852 | }, |
| 6853 | }) |
| 6854 | |
| 6855 | testCases = append(testCases, testCase{ |
| 6856 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6857 | config: Config{ |
| 6858 | MaxVersion: VersionTLS12, |
| 6859 | ClientAuth: RequireAnyClientCert, |
| 6860 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6861 | signatureECDSAWithSHA1, |
| 6862 | }, |
| 6863 | Bugs: ProtocolBugs{ |
| 6864 | NoSignatureAlgorithms: true, |
| 6865 | }, |
| 6866 | }, |
| 6867 | flags: []string{ |
| 6868 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6869 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6870 | }, |
| 6871 | }) |
| 6872 | |
| 6873 | testCases = append(testCases, testCase{ |
| 6874 | testType: serverTest, |
| 6875 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6876 | config: Config{ |
| 6877 | MaxVersion: VersionTLS12, |
| 6878 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6879 | signatureECDSAWithSHA1, |
| 6880 | }, |
| 6881 | Bugs: ProtocolBugs{ |
| 6882 | NoSignatureAlgorithms: true, |
| 6883 | }, |
| 6884 | }, |
| 6885 | flags: []string{ |
| 6886 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6887 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6888 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6889 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6890 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6891 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6892 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6893 | config: Config{ |
| 6894 | MaxVersion: VersionTLS13, |
| 6895 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6896 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6897 | signatureRSAPKCS1WithSHA1, |
| 6898 | }, |
| 6899 | Bugs: ProtocolBugs{ |
| 6900 | NoSignatureAlgorithms: true, |
| 6901 | }, |
| 6902 | }, |
| 6903 | flags: []string{ |
| 6904 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6905 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6906 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6907 | shouldFail: true, |
| 6908 | // An empty CertificateRequest signature algorithm list is a |
| 6909 | // syntax error in TLS 1.3. |
| 6910 | expectedError: ":DECODE_ERROR:", |
| 6911 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6912 | }) |
| 6913 | |
| 6914 | testCases = append(testCases, testCase{ |
| 6915 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6916 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6917 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6918 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6919 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6920 | signatureRSAPKCS1WithSHA1, |
| 6921 | }, |
| 6922 | Bugs: ProtocolBugs{ |
| 6923 | NoSignatureAlgorithms: true, |
| 6924 | }, |
| 6925 | }, |
| 6926 | shouldFail: true, |
| 6927 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6928 | }) |
| 6929 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6930 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6931 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6932 | testCases = append(testCases, testCase{ |
| 6933 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6934 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6935 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6936 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6937 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6938 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6939 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6940 | }, |
| 6941 | Bugs: ProtocolBugs{ |
| 6942 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6943 | }, |
| 6944 | }, |
| 6945 | flags: []string{"-require-any-client-certificate"}, |
| 6946 | shouldFail: true, |
| 6947 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6948 | }) |
| 6949 | |
| 6950 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6951 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6952 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6953 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6954 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6955 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6956 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6957 | }, |
| 6958 | Bugs: ProtocolBugs{ |
| 6959 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6960 | }, |
| 6961 | }, |
| 6962 | shouldFail: true, |
| 6963 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6964 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6965 | testCases = append(testCases, testCase{ |
| 6966 | testType: serverTest, |
| 6967 | name: "ClientAuth-Enforced-TLS13", |
| 6968 | config: Config{ |
| 6969 | MaxVersion: VersionTLS13, |
| 6970 | Certificates: []Certificate{rsaCertificate}, |
| 6971 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6972 | signatureRSAPKCS1WithMD5, |
| 6973 | }, |
| 6974 | Bugs: ProtocolBugs{ |
| 6975 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6976 | IgnoreSignatureVersionChecks: true, |
| 6977 | }, |
| 6978 | }, |
| 6979 | flags: []string{"-require-any-client-certificate"}, |
| 6980 | shouldFail: true, |
| 6981 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6982 | }) |
| 6983 | |
| 6984 | testCases = append(testCases, testCase{ |
| 6985 | name: "ServerAuth-Enforced-TLS13", |
| 6986 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6987 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6988 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6989 | signatureRSAPKCS1WithMD5, |
| 6990 | }, |
| 6991 | Bugs: ProtocolBugs{ |
| 6992 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6993 | IgnoreSignatureVersionChecks: true, |
| 6994 | }, |
| 6995 | }, |
| 6996 | shouldFail: true, |
| 6997 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6998 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6999 | |
| 7000 | // Test that the agreed upon digest respects the client preferences and |
| 7001 | // the server digests. |
| 7002 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7003 | name: "NoCommonAlgorithms-Digests", |
| 7004 | config: Config{ |
| 7005 | MaxVersion: VersionTLS12, |
| 7006 | ClientAuth: RequireAnyClientCert, |
| 7007 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7008 | signatureRSAPKCS1WithSHA512, |
| 7009 | signatureRSAPKCS1WithSHA1, |
| 7010 | }, |
| 7011 | }, |
| 7012 | flags: []string{ |
| 7013 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7014 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7015 | "-digest-prefs", "SHA256", |
| 7016 | }, |
| 7017 | shouldFail: true, |
| 7018 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7019 | }) |
| 7020 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7021 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7022 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7023 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7024 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7025 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7026 | signatureRSAPKCS1WithSHA512, |
| 7027 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7028 | }, |
| 7029 | }, |
| 7030 | flags: []string{ |
| 7031 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7032 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7033 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7034 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7035 | shouldFail: true, |
| 7036 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7037 | }) |
| 7038 | testCases = append(testCases, testCase{ |
| 7039 | name: "NoCommonAlgorithms-TLS13", |
| 7040 | config: Config{ |
| 7041 | MaxVersion: VersionTLS13, |
| 7042 | ClientAuth: RequireAnyClientCert, |
| 7043 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7044 | signatureRSAPSSWithSHA512, |
| 7045 | signatureRSAPSSWithSHA384, |
| 7046 | }, |
| 7047 | }, |
| 7048 | flags: []string{ |
| 7049 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7050 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7051 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7052 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7053 | shouldFail: true, |
| 7054 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7055 | }) |
| 7056 | testCases = append(testCases, testCase{ |
| 7057 | name: "Agree-Digest-SHA256", |
| 7058 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7059 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7060 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7061 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7062 | signatureRSAPKCS1WithSHA1, |
| 7063 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7064 | }, |
| 7065 | }, |
| 7066 | flags: []string{ |
| 7067 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7068 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7069 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7070 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7071 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7072 | }) |
| 7073 | testCases = append(testCases, testCase{ |
| 7074 | name: "Agree-Digest-SHA1", |
| 7075 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7076 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7077 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7078 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7079 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7080 | }, |
| 7081 | }, |
| 7082 | flags: []string{ |
| 7083 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7084 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7085 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7086 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7087 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7088 | }) |
| 7089 | testCases = append(testCases, testCase{ |
| 7090 | name: "Agree-Digest-Default", |
| 7091 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7092 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7093 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7094 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7095 | signatureRSAPKCS1WithSHA256, |
| 7096 | signatureECDSAWithP256AndSHA256, |
| 7097 | signatureRSAPKCS1WithSHA1, |
| 7098 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7099 | }, |
| 7100 | }, |
| 7101 | flags: []string{ |
| 7102 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7103 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7104 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7105 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7106 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7107 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7108 | // Test that the signing preference list may include extra algorithms |
| 7109 | // without negotiation problems. |
| 7110 | testCases = append(testCases, testCase{ |
| 7111 | testType: serverTest, |
| 7112 | name: "FilterExtraAlgorithms", |
| 7113 | config: Config{ |
| 7114 | MaxVersion: VersionTLS12, |
| 7115 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7116 | signatureRSAPKCS1WithSHA256, |
| 7117 | }, |
| 7118 | }, |
| 7119 | flags: []string{ |
| 7120 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7121 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7122 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7123 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7124 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7125 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7126 | }, |
| 7127 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7128 | }) |
| 7129 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7130 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7131 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7132 | testCases = append(testCases, testCase{ |
| 7133 | name: "CheckLeafCurve", |
| 7134 | config: Config{ |
| 7135 | MaxVersion: VersionTLS12, |
| 7136 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7137 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7138 | }, |
| 7139 | flags: []string{"-p384-only"}, |
| 7140 | shouldFail: true, |
| 7141 | expectedError: ":BAD_ECC_CERT:", |
| 7142 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7143 | |
| 7144 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7145 | testCases = append(testCases, testCase{ |
| 7146 | name: "CheckLeafCurve-TLS13", |
| 7147 | config: Config{ |
| 7148 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7149 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7150 | }, |
| 7151 | flags: []string{"-p384-only"}, |
| 7152 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7153 | |
| 7154 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7155 | testCases = append(testCases, testCase{ |
| 7156 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7157 | config: Config{ |
| 7158 | MaxVersion: VersionTLS12, |
| 7159 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7160 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7161 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7162 | signatureECDSAWithP384AndSHA384, |
| 7163 | }, |
| 7164 | }, |
| 7165 | }) |
| 7166 | |
| 7167 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7168 | testCases = append(testCases, testCase{ |
| 7169 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7170 | config: Config{ |
| 7171 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7172 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7173 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7174 | signatureECDSAWithP384AndSHA384, |
| 7175 | }, |
| 7176 | Bugs: ProtocolBugs{ |
| 7177 | SkipECDSACurveCheck: true, |
| 7178 | }, |
| 7179 | }, |
| 7180 | shouldFail: true, |
| 7181 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7182 | }) |
| 7183 | |
| 7184 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7185 | // account. |
| 7186 | testCases = append(testCases, testCase{ |
| 7187 | testType: serverTest, |
| 7188 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7189 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7190 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7191 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7192 | signatureECDSAWithP384AndSHA384, |
| 7193 | signatureECDSAWithP256AndSHA256, |
| 7194 | }, |
| 7195 | }, |
| 7196 | flags: []string{ |
| 7197 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7198 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7199 | }, |
| 7200 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7201 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7202 | |
| 7203 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7204 | // server does not attempt to sign in that case. |
| 7205 | testCases = append(testCases, testCase{ |
| 7206 | testType: serverTest, |
| 7207 | name: "RSA-PSS-Large", |
| 7208 | config: Config{ |
| 7209 | MaxVersion: VersionTLS13, |
| 7210 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7211 | signatureRSAPSSWithSHA512, |
| 7212 | }, |
| 7213 | }, |
| 7214 | flags: []string{ |
| 7215 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7216 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7217 | }, |
| 7218 | shouldFail: true, |
| 7219 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7220 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7221 | |
| 7222 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7223 | testCases = append(testCases, testCase{ |
| 7224 | testType: clientTest, |
| 7225 | name: "RSA-PSS-Default-Verify", |
| 7226 | config: Config{ |
| 7227 | MaxVersion: VersionTLS12, |
| 7228 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7229 | signatureRSAPSSWithSHA256, |
| 7230 | }, |
| 7231 | }, |
| 7232 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7233 | }) |
| 7234 | |
| 7235 | testCases = append(testCases, testCase{ |
| 7236 | testType: serverTest, |
| 7237 | name: "RSA-PSS-Default-Sign", |
| 7238 | config: Config{ |
| 7239 | MaxVersion: VersionTLS12, |
| 7240 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7241 | signatureRSAPSSWithSHA256, |
| 7242 | }, |
| 7243 | }, |
| 7244 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7245 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7246 | } |
| 7247 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7248 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7249 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7250 | var timeouts = []time.Duration{ |
| 7251 | 1 * time.Second, |
| 7252 | 2 * time.Second, |
| 7253 | 4 * time.Second, |
| 7254 | 8 * time.Second, |
| 7255 | 16 * time.Second, |
| 7256 | 32 * time.Second, |
| 7257 | 60 * time.Second, |
| 7258 | 60 * time.Second, |
| 7259 | 60 * time.Second, |
| 7260 | 60 * time.Second, |
| 7261 | 60 * time.Second, |
| 7262 | 60 * time.Second, |
| 7263 | 60 * time.Second, |
| 7264 | } |
| 7265 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7266 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7267 | // initial timeout duration was set to 250ms. |
| 7268 | var shortTimeouts = []time.Duration{ |
| 7269 | 250 * time.Millisecond, |
| 7270 | 500 * time.Millisecond, |
| 7271 | 1 * time.Second, |
| 7272 | 2 * time.Second, |
| 7273 | 4 * time.Second, |
| 7274 | 8 * time.Second, |
| 7275 | 16 * time.Second, |
| 7276 | 32 * time.Second, |
| 7277 | 60 * time.Second, |
| 7278 | 60 * time.Second, |
| 7279 | 60 * time.Second, |
| 7280 | 60 * time.Second, |
| 7281 | 60 * time.Second, |
| 7282 | } |
| 7283 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7284 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7285 | // These tests work by coordinating some behavior on both the shim and |
| 7286 | // the runner. |
| 7287 | // |
| 7288 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7289 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7290 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7291 | // timeout in the shim and acts as a synchronization point to help the |
| 7292 | // runner bracket each handshake flight. |
| 7293 | // |
| 7294 | // We assume the shim does not read from the channel eagerly. It must |
| 7295 | // first wait until it has sent flight N and is ready to receive |
| 7296 | // handshake flight N+1. At this point, it will process the timeout |
| 7297 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7298 | // as if the shim was idle for the specified amount of time. |
| 7299 | // |
| 7300 | // The runner then drops all packets received before the ACK and |
| 7301 | // continues waiting for flight N. This ordering results in one attempt |
| 7302 | // at sending flight N to be dropped. For the test to complete, the |
| 7303 | // shim must send flight N again, testing that the shim implements DTLS |
| 7304 | // retransmit on a timeout. |
| 7305 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7306 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7307 | // likely be more epochs to cross and the final message's retransmit may |
| 7308 | // be more complex. |
| 7309 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7310 | for _, async := range []bool{true, false} { |
| 7311 | var tests []testCase |
| 7312 | |
| 7313 | // Test that this is indeed the timeout schedule. Stress all |
| 7314 | // four patterns of handshake. |
| 7315 | for i := 1; i < len(timeouts); i++ { |
| 7316 | number := strconv.Itoa(i) |
| 7317 | tests = append(tests, testCase{ |
| 7318 | protocol: dtls, |
| 7319 | name: "DTLS-Retransmit-Client-" + number, |
| 7320 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7321 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7322 | Bugs: ProtocolBugs{ |
| 7323 | TimeoutSchedule: timeouts[:i], |
| 7324 | }, |
| 7325 | }, |
| 7326 | resumeSession: true, |
| 7327 | }) |
| 7328 | tests = append(tests, testCase{ |
| 7329 | protocol: dtls, |
| 7330 | testType: serverTest, |
| 7331 | name: "DTLS-Retransmit-Server-" + number, |
| 7332 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7333 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7334 | Bugs: ProtocolBugs{ |
| 7335 | TimeoutSchedule: timeouts[:i], |
| 7336 | }, |
| 7337 | }, |
| 7338 | resumeSession: true, |
| 7339 | }) |
| 7340 | } |
| 7341 | |
| 7342 | // Test that exceeding the timeout schedule hits a read |
| 7343 | // timeout. |
| 7344 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7345 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7346 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7347 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7348 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7349 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7350 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7351 | }, |
| 7352 | }, |
| 7353 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7354 | shouldFail: true, |
| 7355 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7356 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7357 | |
| 7358 | if async { |
| 7359 | // Test that timeout handling has a fudge factor, due to API |
| 7360 | // problems. |
| 7361 | tests = append(tests, testCase{ |
| 7362 | protocol: dtls, |
| 7363 | name: "DTLS-Retransmit-Fudge", |
| 7364 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7365 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7366 | Bugs: ProtocolBugs{ |
| 7367 | TimeoutSchedule: []time.Duration{ |
| 7368 | timeouts[0] - 10*time.Millisecond, |
| 7369 | }, |
| 7370 | }, |
| 7371 | }, |
| 7372 | resumeSession: true, |
| 7373 | }) |
| 7374 | } |
| 7375 | |
| 7376 | // Test that the final Finished retransmitting isn't |
| 7377 | // duplicated if the peer badly fragments everything. |
| 7378 | tests = append(tests, testCase{ |
| 7379 | testType: serverTest, |
| 7380 | protocol: dtls, |
| 7381 | name: "DTLS-Retransmit-Fragmented", |
| 7382 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7383 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7384 | Bugs: ProtocolBugs{ |
| 7385 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7386 | MaxHandshakeRecordLength: 2, |
| 7387 | }, |
| 7388 | }, |
| 7389 | }) |
| 7390 | |
| 7391 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7392 | tests = append(tests, testCase{ |
| 7393 | protocol: dtls, |
| 7394 | name: "DTLS-Retransmit-Short-Client", |
| 7395 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7396 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7397 | Bugs: ProtocolBugs{ |
| 7398 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7399 | }, |
| 7400 | }, |
| 7401 | resumeSession: true, |
| 7402 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 7403 | }) |
| 7404 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7405 | protocol: dtls, |
| 7406 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7407 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7408 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7409 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7410 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7411 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7412 | }, |
| 7413 | }, |
| 7414 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7415 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7416 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7417 | |
| 7418 | for _, test := range tests { |
| 7419 | if async { |
| 7420 | test.name += "-Async" |
| 7421 | test.flags = append(test.flags, "-async") |
| 7422 | } |
| 7423 | |
| 7424 | testCases = append(testCases, test) |
| 7425 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7426 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7427 | } |
| 7428 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7429 | func addExportKeyingMaterialTests() { |
| 7430 | for _, vers := range tlsVersions { |
| 7431 | if vers.version == VersionSSL30 { |
| 7432 | continue |
| 7433 | } |
| 7434 | testCases = append(testCases, testCase{ |
| 7435 | name: "ExportKeyingMaterial-" + vers.name, |
| 7436 | config: Config{ |
| 7437 | MaxVersion: vers.version, |
| 7438 | }, |
| 7439 | exportKeyingMaterial: 1024, |
| 7440 | exportLabel: "label", |
| 7441 | exportContext: "context", |
| 7442 | useExportContext: true, |
| 7443 | }) |
| 7444 | testCases = append(testCases, testCase{ |
| 7445 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7446 | config: Config{ |
| 7447 | MaxVersion: vers.version, |
| 7448 | }, |
| 7449 | exportKeyingMaterial: 1024, |
| 7450 | }) |
| 7451 | testCases = append(testCases, testCase{ |
| 7452 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7453 | config: Config{ |
| 7454 | MaxVersion: vers.version, |
| 7455 | }, |
| 7456 | exportKeyingMaterial: 1024, |
| 7457 | useExportContext: true, |
| 7458 | }) |
| 7459 | testCases = append(testCases, testCase{ |
| 7460 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7461 | config: Config{ |
| 7462 | MaxVersion: vers.version, |
| 7463 | }, |
| 7464 | exportKeyingMaterial: 1, |
| 7465 | exportLabel: "label", |
| 7466 | exportContext: "context", |
| 7467 | useExportContext: true, |
| 7468 | }) |
| 7469 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7470 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7471 | testCases = append(testCases, testCase{ |
| 7472 | name: "ExportKeyingMaterial-SSL3", |
| 7473 | config: Config{ |
| 7474 | MaxVersion: VersionSSL30, |
| 7475 | }, |
| 7476 | exportKeyingMaterial: 1024, |
| 7477 | exportLabel: "label", |
| 7478 | exportContext: "context", |
| 7479 | useExportContext: true, |
| 7480 | shouldFail: true, |
| 7481 | expectedError: "failed to export keying material", |
| 7482 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7483 | |
| 7484 | // Exporters work during a False Start. |
| 7485 | testCases = append(testCases, testCase{ |
| 7486 | name: "ExportKeyingMaterial-FalseStart", |
| 7487 | config: Config{ |
| 7488 | MaxVersion: VersionTLS12, |
| 7489 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7490 | NextProtos: []string{"foo"}, |
| 7491 | Bugs: ProtocolBugs{ |
| 7492 | ExpectFalseStart: true, |
| 7493 | }, |
| 7494 | }, |
| 7495 | flags: []string{ |
| 7496 | "-false-start", |
| 7497 | "-advertise-alpn", "\x03foo", |
| 7498 | }, |
| 7499 | shimWritesFirst: true, |
| 7500 | exportKeyingMaterial: 1024, |
| 7501 | exportLabel: "label", |
| 7502 | exportContext: "context", |
| 7503 | useExportContext: true, |
| 7504 | }) |
| 7505 | |
| 7506 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7507 | // triggering the exporter after every SSL_read call and configuring the |
| 7508 | // shim to run asynchronously. |
| 7509 | testCases = append(testCases, testCase{ |
| 7510 | name: "ExportKeyingMaterial-Renegotiate", |
| 7511 | config: Config{ |
| 7512 | MaxVersion: VersionTLS12, |
| 7513 | }, |
| 7514 | renegotiate: 1, |
| 7515 | flags: []string{ |
| 7516 | "-async", |
| 7517 | "-use-exporter-between-reads", |
| 7518 | "-renegotiate-freely", |
| 7519 | "-expect-total-renegotiations", "1", |
| 7520 | }, |
| 7521 | shouldFail: true, |
| 7522 | expectedError: "failed to export keying material", |
| 7523 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7524 | } |
| 7525 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7526 | func addTLSUniqueTests() { |
| 7527 | for _, isClient := range []bool{false, true} { |
| 7528 | for _, isResumption := range []bool{false, true} { |
| 7529 | for _, hasEMS := range []bool{false, true} { |
| 7530 | var suffix string |
| 7531 | if isResumption { |
| 7532 | suffix = "Resume-" |
| 7533 | } else { |
| 7534 | suffix = "Full-" |
| 7535 | } |
| 7536 | |
| 7537 | if hasEMS { |
| 7538 | suffix += "EMS-" |
| 7539 | } else { |
| 7540 | suffix += "NoEMS-" |
| 7541 | } |
| 7542 | |
| 7543 | if isClient { |
| 7544 | suffix += "Client" |
| 7545 | } else { |
| 7546 | suffix += "Server" |
| 7547 | } |
| 7548 | |
| 7549 | test := testCase{ |
| 7550 | name: "TLSUnique-" + suffix, |
| 7551 | testTLSUnique: true, |
| 7552 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7553 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7554 | Bugs: ProtocolBugs{ |
| 7555 | NoExtendedMasterSecret: !hasEMS, |
| 7556 | }, |
| 7557 | }, |
| 7558 | } |
| 7559 | |
| 7560 | if isResumption { |
| 7561 | test.resumeSession = true |
| 7562 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7563 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7564 | Bugs: ProtocolBugs{ |
| 7565 | NoExtendedMasterSecret: !hasEMS, |
| 7566 | }, |
| 7567 | } |
| 7568 | } |
| 7569 | |
| 7570 | if isResumption && !hasEMS { |
| 7571 | test.shouldFail = true |
| 7572 | test.expectedError = "failed to get tls-unique" |
| 7573 | } |
| 7574 | |
| 7575 | testCases = append(testCases, test) |
| 7576 | } |
| 7577 | } |
| 7578 | } |
| 7579 | } |
| 7580 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7581 | func addCustomExtensionTests() { |
| 7582 | expectedContents := "custom extension" |
| 7583 | emptyString := "" |
| 7584 | |
| 7585 | for _, isClient := range []bool{false, true} { |
| 7586 | suffix := "Server" |
| 7587 | flag := "-enable-server-custom-extension" |
| 7588 | testType := serverTest |
| 7589 | if isClient { |
| 7590 | suffix = "Client" |
| 7591 | flag = "-enable-client-custom-extension" |
| 7592 | testType = clientTest |
| 7593 | } |
| 7594 | |
| 7595 | testCases = append(testCases, testCase{ |
| 7596 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7597 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7598 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7599 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7600 | Bugs: ProtocolBugs{ |
| 7601 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7602 | ExpectedCustomExtension: &expectedContents, |
| 7603 | }, |
| 7604 | }, |
| 7605 | flags: []string{flag}, |
| 7606 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7607 | testCases = append(testCases, testCase{ |
| 7608 | testType: testType, |
| 7609 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7610 | config: Config{ |
| 7611 | MaxVersion: VersionTLS13, |
| 7612 | Bugs: ProtocolBugs{ |
| 7613 | CustomExtension: expectedContents, |
| 7614 | ExpectedCustomExtension: &expectedContents, |
| 7615 | }, |
| 7616 | }, |
| 7617 | flags: []string{flag}, |
| 7618 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7619 | |
| 7620 | // If the parse callback fails, the handshake should also fail. |
| 7621 | testCases = append(testCases, testCase{ |
| 7622 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7623 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7624 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7625 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7626 | Bugs: ProtocolBugs{ |
| 7627 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7628 | ExpectedCustomExtension: &expectedContents, |
| 7629 | }, |
| 7630 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7631 | flags: []string{flag}, |
| 7632 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7633 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7634 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7635 | testCases = append(testCases, testCase{ |
| 7636 | testType: testType, |
| 7637 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7638 | config: Config{ |
| 7639 | MaxVersion: VersionTLS13, |
| 7640 | Bugs: ProtocolBugs{ |
| 7641 | CustomExtension: expectedContents + "foo", |
| 7642 | ExpectedCustomExtension: &expectedContents, |
| 7643 | }, |
| 7644 | }, |
| 7645 | flags: []string{flag}, |
| 7646 | shouldFail: true, |
| 7647 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7648 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7649 | |
| 7650 | // If the add callback fails, the handshake should also fail. |
| 7651 | testCases = append(testCases, testCase{ |
| 7652 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7653 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7654 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7655 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7656 | Bugs: ProtocolBugs{ |
| 7657 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7658 | ExpectedCustomExtension: &expectedContents, |
| 7659 | }, |
| 7660 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7661 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7662 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7663 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7664 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7665 | testCases = append(testCases, testCase{ |
| 7666 | testType: testType, |
| 7667 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7668 | config: Config{ |
| 7669 | MaxVersion: VersionTLS13, |
| 7670 | Bugs: ProtocolBugs{ |
| 7671 | CustomExtension: expectedContents, |
| 7672 | ExpectedCustomExtension: &expectedContents, |
| 7673 | }, |
| 7674 | }, |
| 7675 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7676 | shouldFail: true, |
| 7677 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7678 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7679 | |
| 7680 | // If the add callback returns zero, no extension should be |
| 7681 | // added. |
| 7682 | skipCustomExtension := expectedContents |
| 7683 | if isClient { |
| 7684 | // For the case where the client skips sending the |
| 7685 | // custom extension, the server must not “echo” it. |
| 7686 | skipCustomExtension = "" |
| 7687 | } |
| 7688 | testCases = append(testCases, testCase{ |
| 7689 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7690 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7691 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7692 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7693 | Bugs: ProtocolBugs{ |
| 7694 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7695 | ExpectedCustomExtension: &emptyString, |
| 7696 | }, |
| 7697 | }, |
| 7698 | flags: []string{flag, "-custom-extension-skip"}, |
| 7699 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7700 | testCases = append(testCases, testCase{ |
| 7701 | testType: testType, |
| 7702 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7703 | config: Config{ |
| 7704 | MaxVersion: VersionTLS13, |
| 7705 | Bugs: ProtocolBugs{ |
| 7706 | CustomExtension: skipCustomExtension, |
| 7707 | ExpectedCustomExtension: &emptyString, |
| 7708 | }, |
| 7709 | }, |
| 7710 | flags: []string{flag, "-custom-extension-skip"}, |
| 7711 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7712 | } |
| 7713 | |
| 7714 | // The custom extension add callback should not be called if the client |
| 7715 | // doesn't send the extension. |
| 7716 | testCases = append(testCases, testCase{ |
| 7717 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7718 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7719 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7720 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7721 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7722 | ExpectedCustomExtension: &emptyString, |
| 7723 | }, |
| 7724 | }, |
| 7725 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7726 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7727 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7728 | testCases = append(testCases, testCase{ |
| 7729 | testType: serverTest, |
| 7730 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7731 | config: Config{ |
| 7732 | MaxVersion: VersionTLS13, |
| 7733 | Bugs: ProtocolBugs{ |
| 7734 | ExpectedCustomExtension: &emptyString, |
| 7735 | }, |
| 7736 | }, |
| 7737 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7738 | }) |
| 7739 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7740 | // Test an unknown extension from the server. |
| 7741 | testCases = append(testCases, testCase{ |
| 7742 | testType: clientTest, |
| 7743 | name: "UnknownExtension-Client", |
| 7744 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7745 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7746 | Bugs: ProtocolBugs{ |
| 7747 | CustomExtension: expectedContents, |
| 7748 | }, |
| 7749 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7750 | shouldFail: true, |
| 7751 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7752 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7753 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7754 | testCases = append(testCases, testCase{ |
| 7755 | testType: clientTest, |
| 7756 | name: "UnknownExtension-Client-TLS13", |
| 7757 | config: Config{ |
| 7758 | MaxVersion: VersionTLS13, |
| 7759 | Bugs: ProtocolBugs{ |
| 7760 | CustomExtension: expectedContents, |
| 7761 | }, |
| 7762 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7763 | shouldFail: true, |
| 7764 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7765 | expectedLocalError: "remote error: unsupported extension", |
| 7766 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7767 | testCases = append(testCases, testCase{ |
| 7768 | testType: clientTest, |
| 7769 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7770 | config: Config{ |
| 7771 | MaxVersion: VersionTLS13, |
| 7772 | Bugs: ProtocolBugs{ |
| 7773 | CustomUnencryptedExtension: expectedContents, |
| 7774 | }, |
| 7775 | }, |
| 7776 | shouldFail: true, |
| 7777 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7778 | // The shim must send an alert, but alerts at this point do not |
| 7779 | // get successfully decrypted by the runner. |
| 7780 | expectedLocalError: "local error: bad record MAC", |
| 7781 | }) |
| 7782 | testCases = append(testCases, testCase{ |
| 7783 | testType: clientTest, |
| 7784 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7785 | config: Config{ |
| 7786 | MaxVersion: VersionTLS13, |
| 7787 | Bugs: ProtocolBugs{ |
| 7788 | SendUnencryptedALPN: "foo", |
| 7789 | }, |
| 7790 | }, |
| 7791 | flags: []string{ |
| 7792 | "-advertise-alpn", "\x03foo\x03bar", |
| 7793 | }, |
| 7794 | shouldFail: true, |
| 7795 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7796 | // The shim must send an alert, but alerts at this point do not |
| 7797 | // get successfully decrypted by the runner. |
| 7798 | expectedLocalError: "local error: bad record MAC", |
| 7799 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7800 | |
| 7801 | // Test a known but unoffered extension from the server. |
| 7802 | testCases = append(testCases, testCase{ |
| 7803 | testType: clientTest, |
| 7804 | name: "UnofferedExtension-Client", |
| 7805 | config: Config{ |
| 7806 | MaxVersion: VersionTLS12, |
| 7807 | Bugs: ProtocolBugs{ |
| 7808 | SendALPN: "alpn", |
| 7809 | }, |
| 7810 | }, |
| 7811 | shouldFail: true, |
| 7812 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7813 | expectedLocalError: "remote error: unsupported extension", |
| 7814 | }) |
| 7815 | testCases = append(testCases, testCase{ |
| 7816 | testType: clientTest, |
| 7817 | name: "UnofferedExtension-Client-TLS13", |
| 7818 | config: Config{ |
| 7819 | MaxVersion: VersionTLS13, |
| 7820 | Bugs: ProtocolBugs{ |
| 7821 | SendALPN: "alpn", |
| 7822 | }, |
| 7823 | }, |
| 7824 | shouldFail: true, |
| 7825 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7826 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7827 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7828 | } |
| 7829 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7830 | func addRSAClientKeyExchangeTests() { |
| 7831 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7832 | testCases = append(testCases, testCase{ |
| 7833 | testType: serverTest, |
| 7834 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7835 | config: Config{ |
| 7836 | // Ensure the ClientHello version and final |
| 7837 | // version are different, to detect if the |
| 7838 | // server uses the wrong one. |
| 7839 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7840 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7841 | Bugs: ProtocolBugs{ |
| 7842 | BadRSAClientKeyExchange: bad, |
| 7843 | }, |
| 7844 | }, |
| 7845 | shouldFail: true, |
| 7846 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7847 | }) |
| 7848 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7849 | |
| 7850 | // The server must compare whatever was in ClientHello.version for the |
| 7851 | // RSA premaster. |
| 7852 | testCases = append(testCases, testCase{ |
| 7853 | testType: serverTest, |
| 7854 | name: "SendClientVersion-RSA", |
| 7855 | config: Config{ |
| 7856 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7857 | Bugs: ProtocolBugs{ |
| 7858 | SendClientVersion: 0x1234, |
| 7859 | }, |
| 7860 | }, |
| 7861 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7862 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7863 | } |
| 7864 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7865 | var testCurves = []struct { |
| 7866 | name string |
| 7867 | id CurveID |
| 7868 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7869 | {"P-256", CurveP256}, |
| 7870 | {"P-384", CurveP384}, |
| 7871 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7872 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7873 | } |
| 7874 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7875 | const bogusCurve = 0x1234 |
| 7876 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7877 | func addCurveTests() { |
| 7878 | for _, curve := range testCurves { |
| 7879 | testCases = append(testCases, testCase{ |
| 7880 | name: "CurveTest-Client-" + curve.name, |
| 7881 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7882 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7883 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7884 | CurvePreferences: []CurveID{curve.id}, |
| 7885 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7886 | flags: []string{ |
| 7887 | "-enable-all-curves", |
| 7888 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7889 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7890 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7891 | }) |
| 7892 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7893 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7894 | config: Config{ |
| 7895 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7896 | CurvePreferences: []CurveID{curve.id}, |
| 7897 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7898 | flags: []string{ |
| 7899 | "-enable-all-curves", |
| 7900 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7901 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7902 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7903 | }) |
| 7904 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7905 | testType: serverTest, |
| 7906 | name: "CurveTest-Server-" + curve.name, |
| 7907 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7908 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7909 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7910 | CurvePreferences: []CurveID{curve.id}, |
| 7911 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7912 | flags: []string{ |
| 7913 | "-enable-all-curves", |
| 7914 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7915 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7916 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7917 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7918 | testCases = append(testCases, testCase{ |
| 7919 | testType: serverTest, |
| 7920 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7921 | config: Config{ |
| 7922 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7923 | CurvePreferences: []CurveID{curve.id}, |
| 7924 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7925 | flags: []string{ |
| 7926 | "-enable-all-curves", |
| 7927 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7928 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7929 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7930 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7931 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7932 | |
| 7933 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7934 | testCases = append(testCases, testCase{ |
| 7935 | testType: serverTest, |
| 7936 | name: "UnknownCurve", |
| 7937 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7938 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7939 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7940 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7941 | }, |
| 7942 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7943 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7944 | // The server must be tolerant to bogus curves. |
| 7945 | testCases = append(testCases, testCase{ |
| 7946 | testType: serverTest, |
| 7947 | name: "UnknownCurve-TLS13", |
| 7948 | config: Config{ |
| 7949 | MaxVersion: VersionTLS13, |
| 7950 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7951 | }, |
| 7952 | }) |
| 7953 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7954 | // The server must not consider ECDHE ciphers when there are no |
| 7955 | // supported curves. |
| 7956 | testCases = append(testCases, testCase{ |
| 7957 | testType: serverTest, |
| 7958 | name: "NoSupportedCurves", |
| 7959 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7960 | MaxVersion: VersionTLS12, |
| 7961 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7962 | Bugs: ProtocolBugs{ |
| 7963 | NoSupportedCurves: true, |
| 7964 | }, |
| 7965 | }, |
| 7966 | shouldFail: true, |
| 7967 | expectedError: ":NO_SHARED_CIPHER:", |
| 7968 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7969 | testCases = append(testCases, testCase{ |
| 7970 | testType: serverTest, |
| 7971 | name: "NoSupportedCurves-TLS13", |
| 7972 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7973 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7974 | Bugs: ProtocolBugs{ |
| 7975 | NoSupportedCurves: true, |
| 7976 | }, |
| 7977 | }, |
| 7978 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7979 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7980 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7981 | |
| 7982 | // The server must fall back to another cipher when there are no |
| 7983 | // supported curves. |
| 7984 | testCases = append(testCases, testCase{ |
| 7985 | testType: serverTest, |
| 7986 | name: "NoCommonCurves", |
| 7987 | config: Config{ |
| 7988 | MaxVersion: VersionTLS12, |
| 7989 | CipherSuites: []uint16{ |
| 7990 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7991 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7992 | }, |
| 7993 | CurvePreferences: []CurveID{CurveP224}, |
| 7994 | }, |
| 7995 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7996 | }) |
| 7997 | |
| 7998 | // The client must reject bogus curves and disabled curves. |
| 7999 | testCases = append(testCases, testCase{ |
| 8000 | name: "BadECDHECurve", |
| 8001 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8002 | MaxVersion: VersionTLS12, |
| 8003 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8004 | Bugs: ProtocolBugs{ |
| 8005 | SendCurve: bogusCurve, |
| 8006 | }, |
| 8007 | }, |
| 8008 | shouldFail: true, |
| 8009 | expectedError: ":WRONG_CURVE:", |
| 8010 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8011 | testCases = append(testCases, testCase{ |
| 8012 | name: "BadECDHECurve-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 | SendCurve: bogusCurve, |
| 8017 | }, |
| 8018 | }, |
| 8019 | shouldFail: true, |
| 8020 | expectedError: ":WRONG_CURVE:", |
| 8021 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8022 | |
| 8023 | testCases = append(testCases, testCase{ |
| 8024 | name: "UnsupportedCurve", |
| 8025 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8026 | MaxVersion: VersionTLS12, |
| 8027 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8028 | CurvePreferences: []CurveID{CurveP256}, |
| 8029 | Bugs: ProtocolBugs{ |
| 8030 | IgnorePeerCurvePreferences: true, |
| 8031 | }, |
| 8032 | }, |
| 8033 | flags: []string{"-p384-only"}, |
| 8034 | shouldFail: true, |
| 8035 | expectedError: ":WRONG_CURVE:", |
| 8036 | }) |
| 8037 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8038 | testCases = append(testCases, testCase{ |
| 8039 | // TODO(davidben): Add a TLS 1.3 version where |
| 8040 | // HelloRetryRequest requests an unsupported curve. |
| 8041 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8042 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8043 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8044 | CurvePreferences: []CurveID{CurveP384}, |
| 8045 | Bugs: ProtocolBugs{ |
| 8046 | SendCurve: CurveP256, |
| 8047 | }, |
| 8048 | }, |
| 8049 | flags: []string{"-p384-only"}, |
| 8050 | shouldFail: true, |
| 8051 | expectedError: ":WRONG_CURVE:", |
| 8052 | }) |
| 8053 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8054 | // Test invalid curve points. |
| 8055 | testCases = append(testCases, testCase{ |
| 8056 | name: "InvalidECDHPoint-Client", |
| 8057 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8058 | MaxVersion: VersionTLS12, |
| 8059 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8060 | CurvePreferences: []CurveID{CurveP256}, |
| 8061 | Bugs: ProtocolBugs{ |
| 8062 | InvalidECDHPoint: true, |
| 8063 | }, |
| 8064 | }, |
| 8065 | shouldFail: true, |
| 8066 | expectedError: ":INVALID_ENCODING:", |
| 8067 | }) |
| 8068 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8069 | name: "InvalidECDHPoint-Client-TLS13", |
| 8070 | config: Config{ |
| 8071 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8072 | CurvePreferences: []CurveID{CurveP256}, |
| 8073 | Bugs: ProtocolBugs{ |
| 8074 | InvalidECDHPoint: true, |
| 8075 | }, |
| 8076 | }, |
| 8077 | shouldFail: true, |
| 8078 | expectedError: ":INVALID_ENCODING:", |
| 8079 | }) |
| 8080 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8081 | testType: serverTest, |
| 8082 | name: "InvalidECDHPoint-Server", |
| 8083 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8084 | MaxVersion: VersionTLS12, |
| 8085 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8086 | CurvePreferences: []CurveID{CurveP256}, |
| 8087 | Bugs: ProtocolBugs{ |
| 8088 | InvalidECDHPoint: true, |
| 8089 | }, |
| 8090 | }, |
| 8091 | shouldFail: true, |
| 8092 | expectedError: ":INVALID_ENCODING:", |
| 8093 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8094 | testCases = append(testCases, testCase{ |
| 8095 | testType: serverTest, |
| 8096 | name: "InvalidECDHPoint-Server-TLS13", |
| 8097 | config: Config{ |
| 8098 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8099 | CurvePreferences: []CurveID{CurveP256}, |
| 8100 | Bugs: ProtocolBugs{ |
| 8101 | InvalidECDHPoint: true, |
| 8102 | }, |
| 8103 | }, |
| 8104 | shouldFail: true, |
| 8105 | expectedError: ":INVALID_ENCODING:", |
| 8106 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame^] | 8107 | |
| 8108 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 8109 | testCases = append(testCases, testCase{ |
| 8110 | name: "CurveID-Resume-Client", |
| 8111 | config: Config{ |
| 8112 | MaxVersion: VersionTLS12, |
| 8113 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8114 | CurvePreferences: []CurveID{CurveX25519}, |
| 8115 | }, |
| 8116 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8117 | resumeSession: true, |
| 8118 | }) |
| 8119 | testCases = append(testCases, testCase{ |
| 8120 | testType: serverTest, |
| 8121 | name: "CurveID-Resume-Server", |
| 8122 | config: Config{ |
| 8123 | MaxVersion: VersionTLS12, |
| 8124 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8125 | CurvePreferences: []CurveID{CurveX25519}, |
| 8126 | }, |
| 8127 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8128 | resumeSession: true, |
| 8129 | }) |
| 8130 | |
| 8131 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 8132 | // one should be reported. |
| 8133 | testCases = append(testCases, testCase{ |
| 8134 | name: "CurveID-Resume-Client-TLS13", |
| 8135 | config: Config{ |
| 8136 | MaxVersion: VersionTLS13, |
| 8137 | CurvePreferences: []CurveID{CurveX25519}, |
| 8138 | }, |
| 8139 | resumeConfig: &Config{ |
| 8140 | MaxVersion: VersionTLS13, |
| 8141 | CurvePreferences: []CurveID{CurveP256}, |
| 8142 | }, |
| 8143 | flags: []string{ |
| 8144 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8145 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8146 | }, |
| 8147 | resumeSession: true, |
| 8148 | }) |
| 8149 | testCases = append(testCases, testCase{ |
| 8150 | testType: serverTest, |
| 8151 | name: "CurveID-Resume-Server-TLS13", |
| 8152 | config: Config{ |
| 8153 | MaxVersion: VersionTLS13, |
| 8154 | CurvePreferences: []CurveID{CurveX25519}, |
| 8155 | }, |
| 8156 | resumeConfig: &Config{ |
| 8157 | MaxVersion: VersionTLS13, |
| 8158 | CurvePreferences: []CurveID{CurveP256}, |
| 8159 | }, |
| 8160 | flags: []string{ |
| 8161 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8162 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8163 | }, |
| 8164 | resumeSession: true, |
| 8165 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8166 | } |
| 8167 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8168 | func addTLS13RecordTests() { |
| 8169 | testCases = append(testCases, testCase{ |
| 8170 | name: "TLS13-RecordPadding", |
| 8171 | config: Config{ |
| 8172 | MaxVersion: VersionTLS13, |
| 8173 | MinVersion: VersionTLS13, |
| 8174 | Bugs: ProtocolBugs{ |
| 8175 | RecordPadding: 10, |
| 8176 | }, |
| 8177 | }, |
| 8178 | }) |
| 8179 | |
| 8180 | testCases = append(testCases, testCase{ |
| 8181 | name: "TLS13-EmptyRecords", |
| 8182 | config: Config{ |
| 8183 | MaxVersion: VersionTLS13, |
| 8184 | MinVersion: VersionTLS13, |
| 8185 | Bugs: ProtocolBugs{ |
| 8186 | OmitRecordContents: true, |
| 8187 | }, |
| 8188 | }, |
| 8189 | shouldFail: true, |
| 8190 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8191 | }) |
| 8192 | |
| 8193 | testCases = append(testCases, testCase{ |
| 8194 | name: "TLS13-OnlyPadding", |
| 8195 | config: Config{ |
| 8196 | MaxVersion: VersionTLS13, |
| 8197 | MinVersion: VersionTLS13, |
| 8198 | Bugs: ProtocolBugs{ |
| 8199 | OmitRecordContents: true, |
| 8200 | RecordPadding: 10, |
| 8201 | }, |
| 8202 | }, |
| 8203 | shouldFail: true, |
| 8204 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8205 | }) |
| 8206 | |
| 8207 | testCases = append(testCases, testCase{ |
| 8208 | name: "TLS13-WrongOuterRecord", |
| 8209 | config: Config{ |
| 8210 | MaxVersion: VersionTLS13, |
| 8211 | MinVersion: VersionTLS13, |
| 8212 | Bugs: ProtocolBugs{ |
| 8213 | OuterRecordType: recordTypeHandshake, |
| 8214 | }, |
| 8215 | }, |
| 8216 | shouldFail: true, |
| 8217 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8218 | }) |
| 8219 | } |
| 8220 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8221 | func addSessionTicketTests() { |
| 8222 | testCases = append(testCases, testCase{ |
| 8223 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8224 | // mean the server changed its mind on sending a ticket. |
| 8225 | name: "SendEmptySessionTicket", |
| 8226 | config: Config{ |
| 8227 | MaxVersion: VersionTLS12, |
| 8228 | Bugs: ProtocolBugs{ |
| 8229 | SendEmptySessionTicket: true, |
| 8230 | }, |
| 8231 | }, |
| 8232 | flags: []string{"-expect-no-session"}, |
| 8233 | }) |
| 8234 | |
| 8235 | // Test that the server ignores unknown PSK modes. |
| 8236 | testCases = append(testCases, testCase{ |
| 8237 | testType: serverTest, |
| 8238 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8239 | config: Config{ |
| 8240 | MaxVersion: VersionTLS13, |
| 8241 | Bugs: ProtocolBugs{ |
| 8242 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8243 | }, |
| 8244 | }, |
| 8245 | resumeSession: true, |
| 8246 | expectedResumeVersion: VersionTLS13, |
| 8247 | }) |
| 8248 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8249 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8250 | testCases = append(testCases, testCase{ |
| 8251 | testType: serverTest, |
| 8252 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8253 | config: Config{ |
| 8254 | MaxVersion: VersionTLS13, |
| 8255 | Bugs: ProtocolBugs{ |
| 8256 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8257 | ExpectNoNewSessionTicket: true, |
| 8258 | }, |
| 8259 | }, |
| 8260 | }) |
| 8261 | |
| 8262 | // 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] | 8263 | testCases = append(testCases, testCase{ |
| 8264 | testType: serverTest, |
| 8265 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8266 | config: Config{ |
| 8267 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8268 | }, |
| 8269 | resumeConfig: &Config{ |
| 8270 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8271 | Bugs: ProtocolBugs{ |
| 8272 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8273 | }, |
| 8274 | }, |
| 8275 | resumeSession: true, |
| 8276 | expectResumeRejected: true, |
| 8277 | }) |
| 8278 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8279 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8280 | testCases = append(testCases, testCase{ |
| 8281 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8282 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8283 | config: Config{ |
| 8284 | MaxVersion: VersionTLS13, |
| 8285 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8286 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8287 | }, |
| 8288 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8289 | resumeSession: true, |
| 8290 | flags: []string{ |
| 8291 | "-resumption-delay", "10", |
| 8292 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8293 | }) |
| 8294 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8295 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8296 | testCases = append(testCases, testCase{ |
| 8297 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8298 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8299 | config: Config{ |
| 8300 | MaxVersion: VersionTLS13, |
| 8301 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8302 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8303 | }, |
| 8304 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8305 | resumeSession: true, |
| 8306 | shouldFail: true, |
| 8307 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8308 | }) |
| 8309 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8310 | } |
| 8311 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8312 | func addChangeCipherSpecTests() { |
| 8313 | // Test missing ChangeCipherSpecs. |
| 8314 | testCases = append(testCases, testCase{ |
| 8315 | name: "SkipChangeCipherSpec-Client", |
| 8316 | config: Config{ |
| 8317 | MaxVersion: VersionTLS12, |
| 8318 | Bugs: ProtocolBugs{ |
| 8319 | SkipChangeCipherSpec: true, |
| 8320 | }, |
| 8321 | }, |
| 8322 | shouldFail: true, |
| 8323 | expectedError: ":UNEXPECTED_RECORD:", |
| 8324 | }) |
| 8325 | testCases = append(testCases, testCase{ |
| 8326 | testType: serverTest, |
| 8327 | name: "SkipChangeCipherSpec-Server", |
| 8328 | config: Config{ |
| 8329 | MaxVersion: VersionTLS12, |
| 8330 | Bugs: ProtocolBugs{ |
| 8331 | SkipChangeCipherSpec: true, |
| 8332 | }, |
| 8333 | }, |
| 8334 | shouldFail: true, |
| 8335 | expectedError: ":UNEXPECTED_RECORD:", |
| 8336 | }) |
| 8337 | testCases = append(testCases, testCase{ |
| 8338 | testType: serverTest, |
| 8339 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8340 | config: Config{ |
| 8341 | MaxVersion: VersionTLS12, |
| 8342 | NextProtos: []string{"bar"}, |
| 8343 | Bugs: ProtocolBugs{ |
| 8344 | SkipChangeCipherSpec: true, |
| 8345 | }, |
| 8346 | }, |
| 8347 | flags: []string{ |
| 8348 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8349 | }, |
| 8350 | shouldFail: true, |
| 8351 | expectedError: ":UNEXPECTED_RECORD:", |
| 8352 | }) |
| 8353 | |
| 8354 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8355 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8356 | // rejected. Test both with and without handshake packing to handle both |
| 8357 | // when the partial post-CCS message is in its own record and when it is |
| 8358 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8359 | for _, packed := range []bool{false, true} { |
| 8360 | var suffix string |
| 8361 | if packed { |
| 8362 | suffix = "-Packed" |
| 8363 | } |
| 8364 | |
| 8365 | testCases = append(testCases, testCase{ |
| 8366 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8367 | config: Config{ |
| 8368 | MaxVersion: VersionTLS12, |
| 8369 | Bugs: ProtocolBugs{ |
| 8370 | FragmentAcrossChangeCipherSpec: true, |
| 8371 | PackHandshakeFlight: packed, |
| 8372 | }, |
| 8373 | }, |
| 8374 | shouldFail: true, |
| 8375 | expectedError: ":UNEXPECTED_RECORD:", |
| 8376 | }) |
| 8377 | testCases = append(testCases, testCase{ |
| 8378 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8379 | config: Config{ |
| 8380 | MaxVersion: VersionTLS12, |
| 8381 | }, |
| 8382 | resumeSession: true, |
| 8383 | resumeConfig: &Config{ |
| 8384 | MaxVersion: VersionTLS12, |
| 8385 | Bugs: ProtocolBugs{ |
| 8386 | FragmentAcrossChangeCipherSpec: true, |
| 8387 | PackHandshakeFlight: packed, |
| 8388 | }, |
| 8389 | }, |
| 8390 | shouldFail: true, |
| 8391 | expectedError: ":UNEXPECTED_RECORD:", |
| 8392 | }) |
| 8393 | testCases = append(testCases, testCase{ |
| 8394 | testType: serverTest, |
| 8395 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8396 | config: Config{ |
| 8397 | MaxVersion: VersionTLS12, |
| 8398 | Bugs: ProtocolBugs{ |
| 8399 | FragmentAcrossChangeCipherSpec: true, |
| 8400 | PackHandshakeFlight: packed, |
| 8401 | }, |
| 8402 | }, |
| 8403 | shouldFail: true, |
| 8404 | expectedError: ":UNEXPECTED_RECORD:", |
| 8405 | }) |
| 8406 | testCases = append(testCases, testCase{ |
| 8407 | testType: serverTest, |
| 8408 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8409 | config: Config{ |
| 8410 | MaxVersion: VersionTLS12, |
| 8411 | }, |
| 8412 | resumeSession: true, |
| 8413 | resumeConfig: &Config{ |
| 8414 | MaxVersion: VersionTLS12, |
| 8415 | Bugs: ProtocolBugs{ |
| 8416 | FragmentAcrossChangeCipherSpec: true, |
| 8417 | PackHandshakeFlight: packed, |
| 8418 | }, |
| 8419 | }, |
| 8420 | shouldFail: true, |
| 8421 | expectedError: ":UNEXPECTED_RECORD:", |
| 8422 | }) |
| 8423 | testCases = append(testCases, testCase{ |
| 8424 | testType: serverTest, |
| 8425 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8426 | config: Config{ |
| 8427 | MaxVersion: VersionTLS12, |
| 8428 | NextProtos: []string{"bar"}, |
| 8429 | Bugs: ProtocolBugs{ |
| 8430 | FragmentAcrossChangeCipherSpec: true, |
| 8431 | PackHandshakeFlight: packed, |
| 8432 | }, |
| 8433 | }, |
| 8434 | flags: []string{ |
| 8435 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8436 | }, |
| 8437 | shouldFail: true, |
| 8438 | expectedError: ":UNEXPECTED_RECORD:", |
| 8439 | }) |
| 8440 | } |
| 8441 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8442 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8443 | // messages in the handshake queue. Do this by testing the server |
| 8444 | // reading the client Finished, reversing the flight so Finished comes |
| 8445 | // first. |
| 8446 | testCases = append(testCases, testCase{ |
| 8447 | protocol: dtls, |
| 8448 | testType: serverTest, |
| 8449 | name: "SendUnencryptedFinished-DTLS", |
| 8450 | config: Config{ |
| 8451 | MaxVersion: VersionTLS12, |
| 8452 | Bugs: ProtocolBugs{ |
| 8453 | SendUnencryptedFinished: true, |
| 8454 | ReverseHandshakeFragments: true, |
| 8455 | }, |
| 8456 | }, |
| 8457 | shouldFail: true, |
| 8458 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8459 | }) |
| 8460 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8461 | // Test synchronization between encryption changes and the handshake in |
| 8462 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8463 | testCases = append(testCases, testCase{ |
| 8464 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8465 | config: Config{ |
| 8466 | MaxVersion: VersionTLS13, |
| 8467 | Bugs: ProtocolBugs{ |
| 8468 | PartialEncryptedExtensionsWithServerHello: true, |
| 8469 | }, |
| 8470 | }, |
| 8471 | shouldFail: true, |
| 8472 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8473 | }) |
| 8474 | testCases = append(testCases, testCase{ |
| 8475 | testType: serverTest, |
| 8476 | name: "PartialClientFinishedWithClientHello", |
| 8477 | config: Config{ |
| 8478 | MaxVersion: VersionTLS13, |
| 8479 | Bugs: ProtocolBugs{ |
| 8480 | PartialClientFinishedWithClientHello: true, |
| 8481 | }, |
| 8482 | }, |
| 8483 | shouldFail: true, |
| 8484 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8485 | }) |
| 8486 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8487 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8488 | testCases = append(testCases, testCase{ |
| 8489 | testType: serverTest, |
| 8490 | name: "EarlyChangeCipherSpec-server-1", |
| 8491 | config: Config{ |
| 8492 | MaxVersion: VersionTLS12, |
| 8493 | Bugs: ProtocolBugs{ |
| 8494 | EarlyChangeCipherSpec: 1, |
| 8495 | }, |
| 8496 | }, |
| 8497 | shouldFail: true, |
| 8498 | expectedError: ":UNEXPECTED_RECORD:", |
| 8499 | }) |
| 8500 | testCases = append(testCases, testCase{ |
| 8501 | testType: serverTest, |
| 8502 | name: "EarlyChangeCipherSpec-server-2", |
| 8503 | config: Config{ |
| 8504 | MaxVersion: VersionTLS12, |
| 8505 | Bugs: ProtocolBugs{ |
| 8506 | EarlyChangeCipherSpec: 2, |
| 8507 | }, |
| 8508 | }, |
| 8509 | shouldFail: true, |
| 8510 | expectedError: ":UNEXPECTED_RECORD:", |
| 8511 | }) |
| 8512 | testCases = append(testCases, testCase{ |
| 8513 | protocol: dtls, |
| 8514 | name: "StrayChangeCipherSpec", |
| 8515 | config: Config{ |
| 8516 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8517 | // that stray ChangeCipherSpec messages are |
| 8518 | // rejected. |
| 8519 | MaxVersion: VersionTLS12, |
| 8520 | Bugs: ProtocolBugs{ |
| 8521 | StrayChangeCipherSpec: true, |
| 8522 | }, |
| 8523 | }, |
| 8524 | }) |
| 8525 | |
| 8526 | // Test that the contents of ChangeCipherSpec are checked. |
| 8527 | testCases = append(testCases, testCase{ |
| 8528 | name: "BadChangeCipherSpec-1", |
| 8529 | config: Config{ |
| 8530 | MaxVersion: VersionTLS12, |
| 8531 | Bugs: ProtocolBugs{ |
| 8532 | BadChangeCipherSpec: []byte{2}, |
| 8533 | }, |
| 8534 | }, |
| 8535 | shouldFail: true, |
| 8536 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8537 | }) |
| 8538 | testCases = append(testCases, testCase{ |
| 8539 | name: "BadChangeCipherSpec-2", |
| 8540 | config: Config{ |
| 8541 | MaxVersion: VersionTLS12, |
| 8542 | Bugs: ProtocolBugs{ |
| 8543 | BadChangeCipherSpec: []byte{1, 1}, |
| 8544 | }, |
| 8545 | }, |
| 8546 | shouldFail: true, |
| 8547 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8548 | }) |
| 8549 | testCases = append(testCases, testCase{ |
| 8550 | protocol: dtls, |
| 8551 | name: "BadChangeCipherSpec-DTLS-1", |
| 8552 | config: Config{ |
| 8553 | MaxVersion: VersionTLS12, |
| 8554 | Bugs: ProtocolBugs{ |
| 8555 | BadChangeCipherSpec: []byte{2}, |
| 8556 | }, |
| 8557 | }, |
| 8558 | shouldFail: true, |
| 8559 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8560 | }) |
| 8561 | testCases = append(testCases, testCase{ |
| 8562 | protocol: dtls, |
| 8563 | name: "BadChangeCipherSpec-DTLS-2", |
| 8564 | config: Config{ |
| 8565 | MaxVersion: VersionTLS12, |
| 8566 | Bugs: ProtocolBugs{ |
| 8567 | BadChangeCipherSpec: []byte{1, 1}, |
| 8568 | }, |
| 8569 | }, |
| 8570 | shouldFail: true, |
| 8571 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8572 | }) |
| 8573 | } |
| 8574 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8575 | type perMessageTest struct { |
| 8576 | messageType uint8 |
| 8577 | test testCase |
| 8578 | } |
| 8579 | |
| 8580 | // makePerMessageTests returns a series of test templates which cover each |
| 8581 | // message in the TLS handshake. These may be used with bugs like |
| 8582 | // WrongMessageType to fully test a per-message bug. |
| 8583 | func makePerMessageTests() []perMessageTest { |
| 8584 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8585 | for _, protocol := range []protocol{tls, dtls} { |
| 8586 | var suffix string |
| 8587 | if protocol == dtls { |
| 8588 | suffix = "-DTLS" |
| 8589 | } |
| 8590 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8591 | ret = append(ret, perMessageTest{ |
| 8592 | messageType: typeClientHello, |
| 8593 | test: testCase{ |
| 8594 | protocol: protocol, |
| 8595 | testType: serverTest, |
| 8596 | name: "ClientHello" + suffix, |
| 8597 | config: Config{ |
| 8598 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8599 | }, |
| 8600 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8601 | }) |
| 8602 | |
| 8603 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8604 | ret = append(ret, perMessageTest{ |
| 8605 | messageType: typeHelloVerifyRequest, |
| 8606 | test: testCase{ |
| 8607 | protocol: protocol, |
| 8608 | name: "HelloVerifyRequest" + suffix, |
| 8609 | config: Config{ |
| 8610 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8611 | }, |
| 8612 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8613 | }) |
| 8614 | } |
| 8615 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8616 | ret = append(ret, perMessageTest{ |
| 8617 | messageType: typeServerHello, |
| 8618 | test: testCase{ |
| 8619 | protocol: protocol, |
| 8620 | name: "ServerHello" + suffix, |
| 8621 | config: Config{ |
| 8622 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8623 | }, |
| 8624 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8625 | }) |
| 8626 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8627 | ret = append(ret, perMessageTest{ |
| 8628 | messageType: typeCertificate, |
| 8629 | test: testCase{ |
| 8630 | protocol: protocol, |
| 8631 | name: "ServerCertificate" + suffix, |
| 8632 | config: Config{ |
| 8633 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8634 | }, |
| 8635 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8636 | }) |
| 8637 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8638 | ret = append(ret, perMessageTest{ |
| 8639 | messageType: typeCertificateStatus, |
| 8640 | test: testCase{ |
| 8641 | protocol: protocol, |
| 8642 | name: "CertificateStatus" + suffix, |
| 8643 | config: Config{ |
| 8644 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8645 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8646 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8647 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8648 | }) |
| 8649 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8650 | ret = append(ret, perMessageTest{ |
| 8651 | messageType: typeServerKeyExchange, |
| 8652 | test: testCase{ |
| 8653 | protocol: protocol, |
| 8654 | name: "ServerKeyExchange" + suffix, |
| 8655 | config: Config{ |
| 8656 | MaxVersion: VersionTLS12, |
| 8657 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8658 | }, |
| 8659 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8660 | }) |
| 8661 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8662 | ret = append(ret, perMessageTest{ |
| 8663 | messageType: typeCertificateRequest, |
| 8664 | test: testCase{ |
| 8665 | protocol: protocol, |
| 8666 | name: "CertificateRequest" + suffix, |
| 8667 | config: Config{ |
| 8668 | MaxVersion: VersionTLS12, |
| 8669 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8670 | }, |
| 8671 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8672 | }) |
| 8673 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8674 | ret = append(ret, perMessageTest{ |
| 8675 | messageType: typeServerHelloDone, |
| 8676 | test: testCase{ |
| 8677 | protocol: protocol, |
| 8678 | name: "ServerHelloDone" + suffix, |
| 8679 | config: Config{ |
| 8680 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8681 | }, |
| 8682 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8683 | }) |
| 8684 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8685 | ret = append(ret, perMessageTest{ |
| 8686 | messageType: typeCertificate, |
| 8687 | test: testCase{ |
| 8688 | testType: serverTest, |
| 8689 | protocol: protocol, |
| 8690 | name: "ClientCertificate" + suffix, |
| 8691 | config: Config{ |
| 8692 | Certificates: []Certificate{rsaCertificate}, |
| 8693 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8694 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8695 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 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: typeCertificateVerify, |
| 8701 | test: testCase{ |
| 8702 | testType: serverTest, |
| 8703 | protocol: protocol, |
| 8704 | name: "CertificateVerify" + suffix, |
| 8705 | config: Config{ |
| 8706 | Certificates: []Certificate{rsaCertificate}, |
| 8707 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8708 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8709 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8710 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8711 | }) |
| 8712 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8713 | ret = append(ret, perMessageTest{ |
| 8714 | messageType: typeClientKeyExchange, |
| 8715 | test: testCase{ |
| 8716 | testType: serverTest, |
| 8717 | protocol: protocol, |
| 8718 | name: "ClientKeyExchange" + suffix, |
| 8719 | config: Config{ |
| 8720 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8721 | }, |
| 8722 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8723 | }) |
| 8724 | |
| 8725 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8726 | ret = append(ret, perMessageTest{ |
| 8727 | messageType: typeNextProtocol, |
| 8728 | test: testCase{ |
| 8729 | testType: serverTest, |
| 8730 | protocol: protocol, |
| 8731 | name: "NextProtocol" + suffix, |
| 8732 | config: Config{ |
| 8733 | MaxVersion: VersionTLS12, |
| 8734 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8735 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8736 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8737 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8738 | }) |
| 8739 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8740 | ret = append(ret, perMessageTest{ |
| 8741 | messageType: typeChannelID, |
| 8742 | test: testCase{ |
| 8743 | testType: serverTest, |
| 8744 | protocol: protocol, |
| 8745 | name: "ChannelID" + suffix, |
| 8746 | config: Config{ |
| 8747 | MaxVersion: VersionTLS12, |
| 8748 | ChannelID: channelIDKey, |
| 8749 | }, |
| 8750 | flags: []string{ |
| 8751 | "-expect-channel-id", |
| 8752 | base64.StdEncoding.EncodeToString(channelIDBytes), |
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 | } |
| 8757 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8758 | ret = append(ret, perMessageTest{ |
| 8759 | messageType: typeFinished, |
| 8760 | test: testCase{ |
| 8761 | testType: serverTest, |
| 8762 | protocol: protocol, |
| 8763 | name: "ClientFinished" + suffix, |
| 8764 | config: Config{ |
| 8765 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8766 | }, |
| 8767 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8768 | }) |
| 8769 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8770 | ret = append(ret, perMessageTest{ |
| 8771 | messageType: typeNewSessionTicket, |
| 8772 | test: testCase{ |
| 8773 | protocol: protocol, |
| 8774 | name: "NewSessionTicket" + suffix, |
| 8775 | config: Config{ |
| 8776 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8777 | }, |
| 8778 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8779 | }) |
| 8780 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8781 | ret = append(ret, perMessageTest{ |
| 8782 | messageType: typeFinished, |
| 8783 | test: testCase{ |
| 8784 | protocol: protocol, |
| 8785 | name: "ServerFinished" + suffix, |
| 8786 | config: Config{ |
| 8787 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8788 | }, |
| 8789 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8790 | }) |
| 8791 | |
| 8792 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8793 | |
| 8794 | ret = append(ret, perMessageTest{ |
| 8795 | messageType: typeClientHello, |
| 8796 | test: testCase{ |
| 8797 | testType: serverTest, |
| 8798 | name: "TLS13-ClientHello", |
| 8799 | config: Config{ |
| 8800 | MaxVersion: VersionTLS13, |
| 8801 | }, |
| 8802 | }, |
| 8803 | }) |
| 8804 | |
| 8805 | ret = append(ret, perMessageTest{ |
| 8806 | messageType: typeServerHello, |
| 8807 | test: testCase{ |
| 8808 | name: "TLS13-ServerHello", |
| 8809 | config: Config{ |
| 8810 | MaxVersion: VersionTLS13, |
| 8811 | }, |
| 8812 | }, |
| 8813 | }) |
| 8814 | |
| 8815 | ret = append(ret, perMessageTest{ |
| 8816 | messageType: typeEncryptedExtensions, |
| 8817 | test: testCase{ |
| 8818 | name: "TLS13-EncryptedExtensions", |
| 8819 | config: Config{ |
| 8820 | MaxVersion: VersionTLS13, |
| 8821 | }, |
| 8822 | }, |
| 8823 | }) |
| 8824 | |
| 8825 | ret = append(ret, perMessageTest{ |
| 8826 | messageType: typeCertificateRequest, |
| 8827 | test: testCase{ |
| 8828 | name: "TLS13-CertificateRequest", |
| 8829 | config: Config{ |
| 8830 | MaxVersion: VersionTLS13, |
| 8831 | ClientAuth: RequireAnyClientCert, |
| 8832 | }, |
| 8833 | }, |
| 8834 | }) |
| 8835 | |
| 8836 | ret = append(ret, perMessageTest{ |
| 8837 | messageType: typeCertificate, |
| 8838 | test: testCase{ |
| 8839 | name: "TLS13-ServerCertificate", |
| 8840 | config: Config{ |
| 8841 | MaxVersion: VersionTLS13, |
| 8842 | }, |
| 8843 | }, |
| 8844 | }) |
| 8845 | |
| 8846 | ret = append(ret, perMessageTest{ |
| 8847 | messageType: typeCertificateVerify, |
| 8848 | test: testCase{ |
| 8849 | name: "TLS13-ServerCertificateVerify", |
| 8850 | config: Config{ |
| 8851 | MaxVersion: VersionTLS13, |
| 8852 | }, |
| 8853 | }, |
| 8854 | }) |
| 8855 | |
| 8856 | ret = append(ret, perMessageTest{ |
| 8857 | messageType: typeFinished, |
| 8858 | test: testCase{ |
| 8859 | name: "TLS13-ServerFinished", |
| 8860 | config: Config{ |
| 8861 | MaxVersion: VersionTLS13, |
| 8862 | }, |
| 8863 | }, |
| 8864 | }) |
| 8865 | |
| 8866 | ret = append(ret, perMessageTest{ |
| 8867 | messageType: typeCertificate, |
| 8868 | test: testCase{ |
| 8869 | testType: serverTest, |
| 8870 | name: "TLS13-ClientCertificate", |
| 8871 | config: Config{ |
| 8872 | Certificates: []Certificate{rsaCertificate}, |
| 8873 | MaxVersion: VersionTLS13, |
| 8874 | }, |
| 8875 | flags: []string{"-require-any-client-certificate"}, |
| 8876 | }, |
| 8877 | }) |
| 8878 | |
| 8879 | ret = append(ret, perMessageTest{ |
| 8880 | messageType: typeCertificateVerify, |
| 8881 | test: testCase{ |
| 8882 | testType: serverTest, |
| 8883 | name: "TLS13-ClientCertificateVerify", |
| 8884 | config: Config{ |
| 8885 | Certificates: []Certificate{rsaCertificate}, |
| 8886 | MaxVersion: VersionTLS13, |
| 8887 | }, |
| 8888 | flags: []string{"-require-any-client-certificate"}, |
| 8889 | }, |
| 8890 | }) |
| 8891 | |
| 8892 | ret = append(ret, perMessageTest{ |
| 8893 | messageType: typeFinished, |
| 8894 | test: testCase{ |
| 8895 | testType: serverTest, |
| 8896 | name: "TLS13-ClientFinished", |
| 8897 | config: Config{ |
| 8898 | MaxVersion: VersionTLS13, |
| 8899 | }, |
| 8900 | }, |
| 8901 | }) |
| 8902 | |
| 8903 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8904 | } |
| 8905 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8906 | func addWrongMessageTypeTests() { |
| 8907 | for _, t := range makePerMessageTests() { |
| 8908 | t.test.name = "WrongMessageType-" + t.test.name |
| 8909 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 8910 | t.test.shouldFail = true |
| 8911 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 8912 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8913 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8914 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8915 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8916 | // an unencrypted alert while the server expects |
| 8917 | // encryption, so the alert is not readable by runner. |
| 8918 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8919 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8920 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8921 | testCases = append(testCases, t.test) |
| 8922 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8923 | } |
| 8924 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8925 | func addTrailingMessageDataTests() { |
| 8926 | for _, t := range makePerMessageTests() { |
| 8927 | t.test.name = "TrailingMessageData-" + t.test.name |
| 8928 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 8929 | t.test.shouldFail = true |
| 8930 | t.test.expectedError = ":DECODE_ERROR:" |
| 8931 | t.test.expectedLocalError = "remote error: error decoding message" |
| 8932 | |
| 8933 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8934 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8935 | // an unencrypted alert while the server expects |
| 8936 | // encryption, so the alert is not readable by runner. |
| 8937 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8938 | } |
| 8939 | |
| 8940 | if t.messageType == typeFinished { |
| 8941 | // Bad Finished messages read as the verify data having |
| 8942 | // the wrong length. |
| 8943 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 8944 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 8945 | } |
| 8946 | |
| 8947 | testCases = append(testCases, t.test) |
| 8948 | } |
| 8949 | } |
| 8950 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8951 | func addTLS13HandshakeTests() { |
| 8952 | testCases = append(testCases, testCase{ |
| 8953 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8954 | name: "NegotiatePSKResumption-TLS13", |
| 8955 | config: Config{ |
| 8956 | MaxVersion: VersionTLS13, |
| 8957 | Bugs: ProtocolBugs{ |
| 8958 | NegotiatePSKResumption: true, |
| 8959 | }, |
| 8960 | }, |
| 8961 | resumeSession: true, |
| 8962 | shouldFail: true, |
| 8963 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8964 | }) |
| 8965 | |
| 8966 | testCases = append(testCases, testCase{ |
| 8967 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8968 | name: "MissingKeyShare-Client", |
| 8969 | config: Config{ |
| 8970 | MaxVersion: VersionTLS13, |
| 8971 | Bugs: ProtocolBugs{ |
| 8972 | MissingKeyShare: true, |
| 8973 | }, |
| 8974 | }, |
| 8975 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8976 | expectedError: ":UNEXPECTED_EXTENSION:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8977 | }) |
| 8978 | |
| 8979 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8980 | testType: serverTest, |
| 8981 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8982 | config: Config{ |
| 8983 | MaxVersion: VersionTLS13, |
| 8984 | Bugs: ProtocolBugs{ |
| 8985 | MissingKeyShare: true, |
| 8986 | }, |
| 8987 | }, |
| 8988 | shouldFail: true, |
| 8989 | expectedError: ":MISSING_KEY_SHARE:", |
| 8990 | }) |
| 8991 | |
| 8992 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8993 | testType: serverTest, |
| 8994 | name: "DuplicateKeyShares", |
| 8995 | config: Config{ |
| 8996 | MaxVersion: VersionTLS13, |
| 8997 | Bugs: ProtocolBugs{ |
| 8998 | DuplicateKeyShares: true, |
| 8999 | }, |
| 9000 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9001 | shouldFail: true, |
| 9002 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9003 | }) |
| 9004 | |
| 9005 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9006 | testType: serverTest, |
| 9007 | name: "SkipEarlyData", |
| 9008 | config: Config{ |
| 9009 | MaxVersion: VersionTLS13, |
| 9010 | Bugs: ProtocolBugs{ |
| 9011 | SendEarlyDataLength: 4, |
| 9012 | }, |
| 9013 | }, |
| 9014 | }) |
| 9015 | |
| 9016 | testCases = append(testCases, testCase{ |
| 9017 | testType: serverTest, |
| 9018 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9019 | config: Config{ |
| 9020 | MaxVersion: VersionTLS13, |
| 9021 | Bugs: ProtocolBugs{ |
| 9022 | SendEarlyDataLength: 4, |
| 9023 | OmitEarlyDataExtension: true, |
| 9024 | }, |
| 9025 | }, |
| 9026 | shouldFail: true, |
| 9027 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9028 | }) |
| 9029 | |
| 9030 | testCases = append(testCases, testCase{ |
| 9031 | testType: serverTest, |
| 9032 | name: "SkipEarlyData-TooMuchData", |
| 9033 | config: Config{ |
| 9034 | MaxVersion: VersionTLS13, |
| 9035 | Bugs: ProtocolBugs{ |
| 9036 | SendEarlyDataLength: 16384 + 1, |
| 9037 | }, |
| 9038 | }, |
| 9039 | shouldFail: true, |
| 9040 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9041 | }) |
| 9042 | |
| 9043 | testCases = append(testCases, testCase{ |
| 9044 | testType: serverTest, |
| 9045 | name: "SkipEarlyData-Interleaved", |
| 9046 | config: Config{ |
| 9047 | MaxVersion: VersionTLS13, |
| 9048 | Bugs: ProtocolBugs{ |
| 9049 | SendEarlyDataLength: 4, |
| 9050 | InterleaveEarlyData: true, |
| 9051 | }, |
| 9052 | }, |
| 9053 | shouldFail: true, |
| 9054 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9055 | }) |
| 9056 | |
| 9057 | testCases = append(testCases, testCase{ |
| 9058 | testType: serverTest, |
| 9059 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 9060 | config: Config{ |
| 9061 | MaxVersion: VersionTLS13, |
| 9062 | Bugs: ProtocolBugs{ |
| 9063 | SendEarlyDataLength: 4, |
| 9064 | }, |
| 9065 | }, |
| 9066 | shouldFail: true, |
| 9067 | expectedError: ":UNEXPECTED_RECORD:", |
| 9068 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9069 | }) |
| 9070 | |
| 9071 | testCases = append(testCases, testCase{ |
| 9072 | testType: serverTest, |
| 9073 | name: "SkipEarlyData-HRR", |
| 9074 | config: Config{ |
| 9075 | MaxVersion: VersionTLS13, |
| 9076 | Bugs: ProtocolBugs{ |
| 9077 | SendEarlyDataLength: 4, |
| 9078 | }, |
| 9079 | DefaultCurves: []CurveID{}, |
| 9080 | }, |
| 9081 | }) |
| 9082 | |
| 9083 | testCases = append(testCases, testCase{ |
| 9084 | testType: serverTest, |
| 9085 | name: "SkipEarlyData-HRR-Interleaved", |
| 9086 | config: Config{ |
| 9087 | MaxVersion: VersionTLS13, |
| 9088 | Bugs: ProtocolBugs{ |
| 9089 | SendEarlyDataLength: 4, |
| 9090 | InterleaveEarlyData: true, |
| 9091 | }, |
| 9092 | DefaultCurves: []CurveID{}, |
| 9093 | }, |
| 9094 | shouldFail: true, |
| 9095 | expectedError: ":UNEXPECTED_RECORD:", |
| 9096 | }) |
| 9097 | |
| 9098 | testCases = append(testCases, testCase{ |
| 9099 | testType: serverTest, |
| 9100 | name: "SkipEarlyData-HRR-TooMuchData", |
| 9101 | config: Config{ |
| 9102 | MaxVersion: VersionTLS13, |
| 9103 | Bugs: ProtocolBugs{ |
| 9104 | SendEarlyDataLength: 16384 + 1, |
| 9105 | }, |
| 9106 | DefaultCurves: []CurveID{}, |
| 9107 | }, |
| 9108 | shouldFail: true, |
| 9109 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9110 | }) |
| 9111 | |
| 9112 | // Test that skipping early data looking for cleartext correctly |
| 9113 | // processes an alert record. |
| 9114 | testCases = append(testCases, testCase{ |
| 9115 | testType: serverTest, |
| 9116 | name: "SkipEarlyData-HRR-FatalAlert", |
| 9117 | config: Config{ |
| 9118 | MaxVersion: VersionTLS13, |
| 9119 | Bugs: ProtocolBugs{ |
| 9120 | SendEarlyAlert: true, |
| 9121 | SendEarlyDataLength: 4, |
| 9122 | }, |
| 9123 | DefaultCurves: []CurveID{}, |
| 9124 | }, |
| 9125 | shouldFail: true, |
| 9126 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 9127 | }) |
| 9128 | |
| 9129 | testCases = append(testCases, testCase{ |
| 9130 | testType: serverTest, |
| 9131 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 9132 | config: Config{ |
| 9133 | MaxVersion: VersionTLS13, |
| 9134 | Bugs: ProtocolBugs{ |
| 9135 | SendEarlyDataOnSecondClientHello: true, |
| 9136 | }, |
| 9137 | DefaultCurves: []CurveID{}, |
| 9138 | }, |
| 9139 | shouldFail: true, |
| 9140 | expectedLocalError: "remote error: bad record MAC", |
| 9141 | }) |
| 9142 | |
| 9143 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9144 | testType: clientTest, |
| 9145 | name: "EmptyEncryptedExtensions", |
| 9146 | config: Config{ |
| 9147 | MaxVersion: VersionTLS13, |
| 9148 | Bugs: ProtocolBugs{ |
| 9149 | EmptyEncryptedExtensions: true, |
| 9150 | }, |
| 9151 | }, |
| 9152 | shouldFail: true, |
| 9153 | expectedLocalError: "remote error: error decoding message", |
| 9154 | }) |
| 9155 | |
| 9156 | testCases = append(testCases, testCase{ |
| 9157 | testType: clientTest, |
| 9158 | name: "EncryptedExtensionsWithKeyShare", |
| 9159 | config: Config{ |
| 9160 | MaxVersion: VersionTLS13, |
| 9161 | Bugs: ProtocolBugs{ |
| 9162 | EncryptedExtensionsWithKeyShare: true, |
| 9163 | }, |
| 9164 | }, |
| 9165 | shouldFail: true, |
| 9166 | expectedLocalError: "remote error: unsupported extension", |
| 9167 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9168 | |
| 9169 | testCases = append(testCases, testCase{ |
| 9170 | testType: serverTest, |
| 9171 | name: "SendHelloRetryRequest", |
| 9172 | config: Config{ |
| 9173 | MaxVersion: VersionTLS13, |
| 9174 | // Require a HelloRetryRequest for every curve. |
| 9175 | DefaultCurves: []CurveID{}, |
| 9176 | }, |
| 9177 | expectedCurveID: CurveX25519, |
| 9178 | }) |
| 9179 | |
| 9180 | testCases = append(testCases, testCase{ |
| 9181 | testType: serverTest, |
| 9182 | name: "SendHelloRetryRequest-2", |
| 9183 | config: Config{ |
| 9184 | MaxVersion: VersionTLS13, |
| 9185 | DefaultCurves: []CurveID{CurveP384}, |
| 9186 | }, |
| 9187 | // Although the ClientHello did not predict our preferred curve, |
| 9188 | // we always select it whether it is predicted or not. |
| 9189 | expectedCurveID: CurveX25519, |
| 9190 | }) |
| 9191 | |
| 9192 | testCases = append(testCases, testCase{ |
| 9193 | name: "UnknownCurve-HelloRetryRequest", |
| 9194 | config: Config{ |
| 9195 | MaxVersion: VersionTLS13, |
| 9196 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9197 | CurvePreferences: []CurveID{CurveP384}, |
| 9198 | Bugs: ProtocolBugs{ |
| 9199 | SendHelloRetryRequestCurve: bogusCurve, |
| 9200 | }, |
| 9201 | }, |
| 9202 | shouldFail: true, |
| 9203 | expectedError: ":WRONG_CURVE:", |
| 9204 | }) |
| 9205 | |
| 9206 | testCases = append(testCases, testCase{ |
| 9207 | name: "DisabledCurve-HelloRetryRequest", |
| 9208 | config: Config{ |
| 9209 | MaxVersion: VersionTLS13, |
| 9210 | CurvePreferences: []CurveID{CurveP256}, |
| 9211 | Bugs: ProtocolBugs{ |
| 9212 | IgnorePeerCurvePreferences: true, |
| 9213 | }, |
| 9214 | }, |
| 9215 | flags: []string{"-p384-only"}, |
| 9216 | shouldFail: true, |
| 9217 | expectedError: ":WRONG_CURVE:", |
| 9218 | }) |
| 9219 | |
| 9220 | testCases = append(testCases, testCase{ |
| 9221 | name: "UnnecessaryHelloRetryRequest", |
| 9222 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9223 | MaxVersion: VersionTLS13, |
| 9224 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9225 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9226 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9227 | }, |
| 9228 | }, |
| 9229 | shouldFail: true, |
| 9230 | expectedError: ":WRONG_CURVE:", |
| 9231 | }) |
| 9232 | |
| 9233 | testCases = append(testCases, testCase{ |
| 9234 | name: "SecondHelloRetryRequest", |
| 9235 | config: Config{ |
| 9236 | MaxVersion: VersionTLS13, |
| 9237 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9238 | CurvePreferences: []CurveID{CurveP384}, |
| 9239 | Bugs: ProtocolBugs{ |
| 9240 | SecondHelloRetryRequest: true, |
| 9241 | }, |
| 9242 | }, |
| 9243 | shouldFail: true, |
| 9244 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9245 | }) |
| 9246 | |
| 9247 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9248 | name: "HelloRetryRequest-Empty", |
| 9249 | config: Config{ |
| 9250 | MaxVersion: VersionTLS13, |
| 9251 | Bugs: ProtocolBugs{ |
| 9252 | AlwaysSendHelloRetryRequest: true, |
| 9253 | }, |
| 9254 | }, |
| 9255 | shouldFail: true, |
| 9256 | expectedError: ":DECODE_ERROR:", |
| 9257 | }) |
| 9258 | |
| 9259 | testCases = append(testCases, testCase{ |
| 9260 | name: "HelloRetryRequest-DuplicateCurve", |
| 9261 | config: Config{ |
| 9262 | MaxVersion: VersionTLS13, |
| 9263 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9264 | // configuration. Assert this ExpectMissingKeyShare. |
| 9265 | CurvePreferences: []CurveID{CurveP384}, |
| 9266 | Bugs: ProtocolBugs{ |
| 9267 | ExpectMissingKeyShare: true, |
| 9268 | DuplicateHelloRetryRequestExtensions: true, |
| 9269 | }, |
| 9270 | }, |
| 9271 | shouldFail: true, |
| 9272 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9273 | expectedLocalError: "remote error: illegal parameter", |
| 9274 | }) |
| 9275 | |
| 9276 | testCases = append(testCases, testCase{ |
| 9277 | name: "HelloRetryRequest-Cookie", |
| 9278 | config: Config{ |
| 9279 | MaxVersion: VersionTLS13, |
| 9280 | Bugs: ProtocolBugs{ |
| 9281 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9282 | }, |
| 9283 | }, |
| 9284 | }) |
| 9285 | |
| 9286 | testCases = append(testCases, testCase{ |
| 9287 | name: "HelloRetryRequest-DuplicateCookie", |
| 9288 | config: Config{ |
| 9289 | MaxVersion: VersionTLS13, |
| 9290 | Bugs: ProtocolBugs{ |
| 9291 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9292 | DuplicateHelloRetryRequestExtensions: true, |
| 9293 | }, |
| 9294 | }, |
| 9295 | shouldFail: true, |
| 9296 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9297 | expectedLocalError: "remote error: illegal parameter", |
| 9298 | }) |
| 9299 | |
| 9300 | testCases = append(testCases, testCase{ |
| 9301 | name: "HelloRetryRequest-EmptyCookie", |
| 9302 | config: Config{ |
| 9303 | MaxVersion: VersionTLS13, |
| 9304 | Bugs: ProtocolBugs{ |
| 9305 | SendHelloRetryRequestCookie: []byte{}, |
| 9306 | }, |
| 9307 | }, |
| 9308 | shouldFail: true, |
| 9309 | expectedError: ":DECODE_ERROR:", |
| 9310 | }) |
| 9311 | |
| 9312 | testCases = append(testCases, testCase{ |
| 9313 | name: "HelloRetryRequest-Cookie-Curve", |
| 9314 | config: Config{ |
| 9315 | MaxVersion: VersionTLS13, |
| 9316 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9317 | CurvePreferences: []CurveID{CurveP384}, |
| 9318 | Bugs: ProtocolBugs{ |
| 9319 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9320 | ExpectMissingKeyShare: true, |
| 9321 | }, |
| 9322 | }, |
| 9323 | }) |
| 9324 | |
| 9325 | testCases = append(testCases, testCase{ |
| 9326 | name: "HelloRetryRequest-Unknown", |
| 9327 | config: Config{ |
| 9328 | MaxVersion: VersionTLS13, |
| 9329 | Bugs: ProtocolBugs{ |
| 9330 | CustomHelloRetryRequestExtension: "extension", |
| 9331 | }, |
| 9332 | }, |
| 9333 | shouldFail: true, |
| 9334 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9335 | expectedLocalError: "remote error: unsupported extension", |
| 9336 | }) |
| 9337 | |
| 9338 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9339 | testType: serverTest, |
| 9340 | name: "SecondClientHelloMissingKeyShare", |
| 9341 | config: Config{ |
| 9342 | MaxVersion: VersionTLS13, |
| 9343 | DefaultCurves: []CurveID{}, |
| 9344 | Bugs: ProtocolBugs{ |
| 9345 | SecondClientHelloMissingKeyShare: true, |
| 9346 | }, |
| 9347 | }, |
| 9348 | shouldFail: true, |
| 9349 | expectedError: ":MISSING_KEY_SHARE:", |
| 9350 | }) |
| 9351 | |
| 9352 | testCases = append(testCases, testCase{ |
| 9353 | testType: serverTest, |
| 9354 | name: "SecondClientHelloWrongCurve", |
| 9355 | config: Config{ |
| 9356 | MaxVersion: VersionTLS13, |
| 9357 | DefaultCurves: []CurveID{}, |
| 9358 | Bugs: ProtocolBugs{ |
| 9359 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9360 | }, |
| 9361 | }, |
| 9362 | shouldFail: true, |
| 9363 | expectedError: ":WRONG_CURVE:", |
| 9364 | }) |
| 9365 | |
| 9366 | testCases = append(testCases, testCase{ |
| 9367 | name: "HelloRetryRequestVersionMismatch", |
| 9368 | config: Config{ |
| 9369 | MaxVersion: VersionTLS13, |
| 9370 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9371 | CurvePreferences: []CurveID{CurveP384}, |
| 9372 | Bugs: ProtocolBugs{ |
| 9373 | SendServerHelloVersion: 0x0305, |
| 9374 | }, |
| 9375 | }, |
| 9376 | shouldFail: true, |
| 9377 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9378 | }) |
| 9379 | |
| 9380 | testCases = append(testCases, testCase{ |
| 9381 | name: "HelloRetryRequestCurveMismatch", |
| 9382 | config: Config{ |
| 9383 | MaxVersion: VersionTLS13, |
| 9384 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9385 | CurvePreferences: []CurveID{CurveP384}, |
| 9386 | Bugs: ProtocolBugs{ |
| 9387 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9388 | SendHelloRetryRequestCurve: CurveP384, |
| 9389 | // But send P-256 in the ServerHello. |
| 9390 | SendCurve: CurveP256, |
| 9391 | }, |
| 9392 | }, |
| 9393 | shouldFail: true, |
| 9394 | expectedError: ":WRONG_CURVE:", |
| 9395 | }) |
| 9396 | |
| 9397 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9398 | // without sending it. |
| 9399 | testCases = append(testCases, testCase{ |
| 9400 | name: "SkipHelloRetryRequest", |
| 9401 | config: Config{ |
| 9402 | MaxVersion: VersionTLS13, |
| 9403 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9404 | CurvePreferences: []CurveID{CurveP384}, |
| 9405 | Bugs: ProtocolBugs{ |
| 9406 | SkipHelloRetryRequest: true, |
| 9407 | }, |
| 9408 | }, |
| 9409 | shouldFail: true, |
| 9410 | expectedError: ":WRONG_CURVE:", |
| 9411 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9412 | |
| 9413 | testCases = append(testCases, testCase{ |
| 9414 | name: "TLS13-RequestContextInHandshake", |
| 9415 | config: Config{ |
| 9416 | MaxVersion: VersionTLS13, |
| 9417 | MinVersion: VersionTLS13, |
| 9418 | ClientAuth: RequireAnyClientCert, |
| 9419 | Bugs: ProtocolBugs{ |
| 9420 | SendRequestContext: []byte("request context"), |
| 9421 | }, |
| 9422 | }, |
| 9423 | flags: []string{ |
| 9424 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9425 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9426 | }, |
| 9427 | shouldFail: true, |
| 9428 | expectedError: ":DECODE_ERROR:", |
| 9429 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9430 | |
| 9431 | testCases = append(testCases, testCase{ |
| 9432 | testType: serverTest, |
| 9433 | name: "TLS13-TrailingKeyShareData", |
| 9434 | config: Config{ |
| 9435 | MaxVersion: VersionTLS13, |
| 9436 | Bugs: ProtocolBugs{ |
| 9437 | TrailingKeyShareData: true, |
| 9438 | }, |
| 9439 | }, |
| 9440 | shouldFail: true, |
| 9441 | expectedError: ":DECODE_ERROR:", |
| 9442 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9443 | |
| 9444 | testCases = append(testCases, testCase{ |
| 9445 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9446 | config: Config{ |
| 9447 | MaxVersion: VersionTLS13, |
| 9448 | Bugs: ProtocolBugs{ |
| 9449 | AlwaysSelectPSKIdentity: true, |
| 9450 | }, |
| 9451 | }, |
| 9452 | shouldFail: true, |
| 9453 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9454 | }) |
| 9455 | |
| 9456 | testCases = append(testCases, testCase{ |
| 9457 | name: "TLS13-InvalidPSKIdentity", |
| 9458 | config: Config{ |
| 9459 | MaxVersion: VersionTLS13, |
| 9460 | Bugs: ProtocolBugs{ |
| 9461 | SelectPSKIdentityOnResume: 1, |
| 9462 | }, |
| 9463 | }, |
| 9464 | resumeSession: true, |
| 9465 | shouldFail: true, |
| 9466 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9467 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9468 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9469 | testCases = append(testCases, testCase{ |
| 9470 | testType: serverTest, |
| 9471 | name: "TLS13-ExtraPSKIdentity", |
| 9472 | config: Config{ |
| 9473 | MaxVersion: VersionTLS13, |
| 9474 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 9475 | ExtraPSKIdentity: true, |
| 9476 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9477 | }, |
| 9478 | }, |
| 9479 | resumeSession: true, |
| 9480 | }) |
| 9481 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9482 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9483 | testCases = append(testCases, testCase{ |
| 9484 | name: "TLS13-CustomTicketExtension", |
| 9485 | config: Config{ |
| 9486 | MaxVersion: VersionTLS13, |
| 9487 | Bugs: ProtocolBugs{ |
| 9488 | CustomTicketExtension: "1234", |
| 9489 | }, |
| 9490 | }, |
| 9491 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9492 | } |
| 9493 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9494 | func addTLS13CipherPreferenceTests() { |
| 9495 | // Test that client preference is honored if the shim has AES hardware |
| 9496 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9497 | testCases = append(testCases, testCase{ |
| 9498 | testType: serverTest, |
| 9499 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9500 | config: Config{ |
| 9501 | MaxVersion: VersionTLS13, |
| 9502 | CipherSuites: []uint16{ |
| 9503 | TLS_CHACHA20_POLY1305_SHA256, |
| 9504 | TLS_AES_128_GCM_SHA256, |
| 9505 | }, |
| 9506 | }, |
| 9507 | flags: []string{ |
| 9508 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9509 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9510 | }, |
| 9511 | }) |
| 9512 | |
| 9513 | testCases = append(testCases, testCase{ |
| 9514 | testType: serverTest, |
| 9515 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9516 | config: Config{ |
| 9517 | MaxVersion: VersionTLS13, |
| 9518 | CipherSuites: []uint16{ |
| 9519 | TLS_AES_128_GCM_SHA256, |
| 9520 | TLS_CHACHA20_POLY1305_SHA256, |
| 9521 | }, |
| 9522 | }, |
| 9523 | flags: []string{ |
| 9524 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9525 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9526 | }, |
| 9527 | }) |
| 9528 | |
| 9529 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9530 | // whether it has AES hardware. |
| 9531 | testCases = append(testCases, testCase{ |
| 9532 | name: "TLS13-CipherPreference-Client", |
| 9533 | config: Config{ |
| 9534 | MaxVersion: VersionTLS13, |
| 9535 | // Use the client cipher order. (This is the default but |
| 9536 | // is listed to be explicit.) |
| 9537 | PreferServerCipherSuites: false, |
| 9538 | }, |
| 9539 | flags: []string{ |
| 9540 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9541 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9542 | }, |
| 9543 | }) |
| 9544 | } |
| 9545 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9546 | func addPeekTests() { |
| 9547 | // Test SSL_peek works, including on empty records. |
| 9548 | testCases = append(testCases, testCase{ |
| 9549 | name: "Peek-Basic", |
| 9550 | sendEmptyRecords: 1, |
| 9551 | flags: []string{"-peek-then-read"}, |
| 9552 | }) |
| 9553 | |
| 9554 | // Test SSL_peek can drive the initial handshake. |
| 9555 | testCases = append(testCases, testCase{ |
| 9556 | name: "Peek-ImplicitHandshake", |
| 9557 | flags: []string{ |
| 9558 | "-peek-then-read", |
| 9559 | "-implicit-handshake", |
| 9560 | }, |
| 9561 | }) |
| 9562 | |
| 9563 | // Test SSL_peek can discover and drive a renegotiation. |
| 9564 | testCases = append(testCases, testCase{ |
| 9565 | name: "Peek-Renegotiate", |
| 9566 | config: Config{ |
| 9567 | MaxVersion: VersionTLS12, |
| 9568 | }, |
| 9569 | renegotiate: 1, |
| 9570 | flags: []string{ |
| 9571 | "-peek-then-read", |
| 9572 | "-renegotiate-freely", |
| 9573 | "-expect-total-renegotiations", "1", |
| 9574 | }, |
| 9575 | }) |
| 9576 | |
| 9577 | // Test SSL_peek can discover a close_notify. |
| 9578 | testCases = append(testCases, testCase{ |
| 9579 | name: "Peek-Shutdown", |
| 9580 | config: Config{ |
| 9581 | Bugs: ProtocolBugs{ |
| 9582 | ExpectCloseNotify: true, |
| 9583 | }, |
| 9584 | }, |
| 9585 | flags: []string{ |
| 9586 | "-peek-then-read", |
| 9587 | "-check-close-notify", |
| 9588 | }, |
| 9589 | }) |
| 9590 | |
| 9591 | // Test SSL_peek can discover an alert. |
| 9592 | testCases = append(testCases, testCase{ |
| 9593 | name: "Peek-Alert", |
| 9594 | config: Config{ |
| 9595 | Bugs: ProtocolBugs{ |
| 9596 | SendSpuriousAlert: alertRecordOverflow, |
| 9597 | }, |
| 9598 | }, |
| 9599 | flags: []string{"-peek-then-read"}, |
| 9600 | shouldFail: true, |
| 9601 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9602 | }) |
| 9603 | |
| 9604 | // Test SSL_peek can handle KeyUpdate. |
| 9605 | testCases = append(testCases, testCase{ |
| 9606 | name: "Peek-KeyUpdate", |
| 9607 | config: Config{ |
| 9608 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9609 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9610 | sendKeyUpdates: 1, |
| 9611 | keyUpdateRequest: keyUpdateNotRequested, |
| 9612 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9613 | }) |
| 9614 | } |
| 9615 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9616 | func addRecordVersionTests() { |
| 9617 | for _, ver := range tlsVersions { |
| 9618 | // Test that the record version is enforced. |
| 9619 | testCases = append(testCases, testCase{ |
| 9620 | name: "CheckRecordVersion-" + ver.name, |
| 9621 | config: Config{ |
| 9622 | MinVersion: ver.version, |
| 9623 | MaxVersion: ver.version, |
| 9624 | Bugs: ProtocolBugs{ |
| 9625 | SendRecordVersion: 0x03ff, |
| 9626 | }, |
| 9627 | }, |
| 9628 | shouldFail: true, |
| 9629 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9630 | }) |
| 9631 | |
| 9632 | // Test that the ClientHello may use any record version, for |
| 9633 | // compatibility reasons. |
| 9634 | testCases = append(testCases, testCase{ |
| 9635 | testType: serverTest, |
| 9636 | name: "LooseInitialRecordVersion-" + ver.name, |
| 9637 | config: Config{ |
| 9638 | MinVersion: ver.version, |
| 9639 | MaxVersion: ver.version, |
| 9640 | Bugs: ProtocolBugs{ |
| 9641 | SendInitialRecordVersion: 0x03ff, |
| 9642 | }, |
| 9643 | }, |
| 9644 | }) |
| 9645 | |
| 9646 | // Test that garbage ClientHello record versions are rejected. |
| 9647 | testCases = append(testCases, testCase{ |
| 9648 | testType: serverTest, |
| 9649 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 9650 | config: Config{ |
| 9651 | MinVersion: ver.version, |
| 9652 | MaxVersion: ver.version, |
| 9653 | Bugs: ProtocolBugs{ |
| 9654 | SendInitialRecordVersion: 0xffff, |
| 9655 | }, |
| 9656 | }, |
| 9657 | shouldFail: true, |
| 9658 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9659 | }) |
| 9660 | } |
| 9661 | } |
| 9662 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9663 | func addCertificateTests() { |
| 9664 | // Test that a certificate chain with intermediate may be sent and |
| 9665 | // received as both client and server. |
| 9666 | for _, ver := range tlsVersions { |
| 9667 | testCases = append(testCases, testCase{ |
| 9668 | testType: clientTest, |
| 9669 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 9670 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9671 | MinVersion: ver.version, |
| 9672 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9673 | Certificates: []Certificate{rsaChainCertificate}, |
| 9674 | ClientAuth: RequireAnyClientCert, |
| 9675 | }, |
| 9676 | expectPeerCertificate: &rsaChainCertificate, |
| 9677 | flags: []string{ |
| 9678 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9679 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9680 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9681 | }, |
| 9682 | }) |
| 9683 | |
| 9684 | testCases = append(testCases, testCase{ |
| 9685 | testType: serverTest, |
| 9686 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 9687 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 9688 | MinVersion: ver.version, |
| 9689 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9690 | Certificates: []Certificate{rsaChainCertificate}, |
| 9691 | }, |
| 9692 | expectPeerCertificate: &rsaChainCertificate, |
| 9693 | flags: []string{ |
| 9694 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9695 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9696 | "-require-any-client-certificate", |
| 9697 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9698 | }, |
| 9699 | }) |
| 9700 | } |
| 9701 | } |
| 9702 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9703 | func addRetainOnlySHA256ClientCertTests() { |
| 9704 | for _, ver := range tlsVersions { |
| 9705 | // Test that enabling |
| 9706 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 9707 | // actually requesting a client certificate is a no-op. |
| 9708 | testCases = append(testCases, testCase{ |
| 9709 | testType: serverTest, |
| 9710 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 9711 | config: Config{ |
| 9712 | MinVersion: ver.version, |
| 9713 | MaxVersion: ver.version, |
| 9714 | }, |
| 9715 | flags: []string{ |
| 9716 | "-retain-only-sha256-client-cert-initial", |
| 9717 | "-retain-only-sha256-client-cert-resume", |
| 9718 | }, |
| 9719 | resumeSession: true, |
| 9720 | }) |
| 9721 | |
| 9722 | // Test that when retaining only a SHA-256 certificate is |
| 9723 | // enabled, the hash appears as expected. |
| 9724 | testCases = append(testCases, testCase{ |
| 9725 | testType: serverTest, |
| 9726 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 9727 | config: Config{ |
| 9728 | MinVersion: ver.version, |
| 9729 | MaxVersion: ver.version, |
| 9730 | Certificates: []Certificate{rsaCertificate}, |
| 9731 | }, |
| 9732 | flags: []string{ |
| 9733 | "-verify-peer", |
| 9734 | "-retain-only-sha256-client-cert-initial", |
| 9735 | "-retain-only-sha256-client-cert-resume", |
| 9736 | "-expect-sha256-client-cert-initial", |
| 9737 | "-expect-sha256-client-cert-resume", |
| 9738 | }, |
| 9739 | resumeSession: true, |
| 9740 | }) |
| 9741 | |
| 9742 | // Test that when the config changes from on to off, a |
| 9743 | // resumption is rejected because the server now wants the full |
| 9744 | // certificate chain. |
| 9745 | testCases = append(testCases, testCase{ |
| 9746 | testType: serverTest, |
| 9747 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 9748 | config: Config{ |
| 9749 | MinVersion: ver.version, |
| 9750 | MaxVersion: ver.version, |
| 9751 | Certificates: []Certificate{rsaCertificate}, |
| 9752 | }, |
| 9753 | flags: []string{ |
| 9754 | "-verify-peer", |
| 9755 | "-retain-only-sha256-client-cert-initial", |
| 9756 | "-expect-sha256-client-cert-initial", |
| 9757 | }, |
| 9758 | resumeSession: true, |
| 9759 | expectResumeRejected: true, |
| 9760 | }) |
| 9761 | |
| 9762 | // Test that when the config changes from off to on, a |
| 9763 | // resumption is rejected because the server now wants just the |
| 9764 | // hash. |
| 9765 | testCases = append(testCases, testCase{ |
| 9766 | testType: serverTest, |
| 9767 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 9768 | config: Config{ |
| 9769 | MinVersion: ver.version, |
| 9770 | MaxVersion: ver.version, |
| 9771 | Certificates: []Certificate{rsaCertificate}, |
| 9772 | }, |
| 9773 | flags: []string{ |
| 9774 | "-verify-peer", |
| 9775 | "-retain-only-sha256-client-cert-resume", |
| 9776 | "-expect-sha256-client-cert-resume", |
| 9777 | }, |
| 9778 | resumeSession: true, |
| 9779 | expectResumeRejected: true, |
| 9780 | }) |
| 9781 | } |
| 9782 | } |
| 9783 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9784 | 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] | 9785 | defer wg.Done() |
| 9786 | |
| 9787 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9788 | var err error |
| 9789 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9790 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9791 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 9792 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9793 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9794 | if err != nil { |
| 9795 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 9796 | } |
| 9797 | break |
| 9798 | } |
| 9799 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9800 | } else if *repeatUntilFailure { |
| 9801 | for err == nil { |
| 9802 | statusChan <- statusMsg{test: test, started: true} |
| 9803 | err = runTest(test, shimPath, -1) |
| 9804 | } |
| 9805 | } else { |
| 9806 | statusChan <- statusMsg{test: test, started: true} |
| 9807 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9808 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9809 | statusChan <- statusMsg{test: test, err: err} |
| 9810 | } |
| 9811 | } |
| 9812 | |
| 9813 | type statusMsg struct { |
| 9814 | test *testCase |
| 9815 | started bool |
| 9816 | err error |
| 9817 | } |
| 9818 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9819 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9820 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9821 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9822 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9823 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9824 | if !*pipe { |
| 9825 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 9826 | var erase string |
| 9827 | for i := 0; i < lineLen; i++ { |
| 9828 | erase += "\b \b" |
| 9829 | } |
| 9830 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9831 | } |
| 9832 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9833 | if msg.started { |
| 9834 | started++ |
| 9835 | } else { |
| 9836 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9837 | |
| 9838 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9839 | if msg.err == errUnimplemented { |
| 9840 | if *pipe { |
| 9841 | // Print each test instead of a status line. |
| 9842 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 9843 | } |
| 9844 | unimplemented++ |
| 9845 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 9846 | } else { |
| 9847 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 9848 | failed++ |
| 9849 | testOutput.addResult(msg.test.name, "FAIL") |
| 9850 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9851 | } else { |
| 9852 | if *pipe { |
| 9853 | // Print each test instead of a status line. |
| 9854 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 9855 | } |
| 9856 | testOutput.addResult(msg.test.name, "PASS") |
| 9857 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9858 | } |
| 9859 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9860 | if !*pipe { |
| 9861 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9862 | 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] | 9863 | lineLen = len(line) |
| 9864 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9865 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9866 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9867 | |
| 9868 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9869 | } |
| 9870 | |
| 9871 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9872 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9873 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 9874 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9875 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9876 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9877 | addCipherSuiteTests() |
| 9878 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9879 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 9880 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 9881 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 9882 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 9883 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 9884 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 9885 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 9886 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 9887 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 9888 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 9889 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 9890 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 9891 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 9892 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 9893 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9894 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9895 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9896 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9897 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9898 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 9899 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9900 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9901 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9902 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9903 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9904 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9905 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9906 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9907 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 9908 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9909 | |
| 9910 | var wg sync.WaitGroup |
| 9911 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9912 | statusChan := make(chan statusMsg, *numWorkers) |
| 9913 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9914 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9915 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9916 | if len(*shimConfigFile) != 0 { |
| 9917 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 9918 | if err != nil { |
| 9919 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 9920 | os.Exit(1) |
| 9921 | } |
| 9922 | |
| 9923 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 9924 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 9925 | os.Exit(1) |
| 9926 | } |
| 9927 | } |
| 9928 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9929 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9930 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9931 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9932 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9933 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9934 | } |
| 9935 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9936 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9937 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9938 | matched := true |
| 9939 | if len(*testToRun) != 0 { |
| 9940 | var err error |
| 9941 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 9942 | if err != nil { |
| 9943 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 9944 | os.Exit(1) |
| 9945 | } |
| 9946 | } |
| 9947 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9948 | if !*includeDisabled { |
| 9949 | for pattern := range shimConfig.DisabledTests { |
| 9950 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 9951 | if err != nil { |
| 9952 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 9953 | os.Exit(1) |
| 9954 | } |
| 9955 | |
| 9956 | if isDisabled { |
| 9957 | matched = false |
| 9958 | break |
| 9959 | } |
| 9960 | } |
| 9961 | } |
| 9962 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9963 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9964 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9965 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9966 | |
| 9967 | // Only run one test if repeating until failure. |
| 9968 | if *repeatUntilFailure { |
| 9969 | break |
| 9970 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9971 | } |
| 9972 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9973 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9974 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9975 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9976 | os.Exit(1) |
| 9977 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9978 | |
| 9979 | close(testChan) |
| 9980 | wg.Wait() |
| 9981 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9982 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9983 | |
| 9984 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9985 | |
| 9986 | if *jsonOutput != "" { |
| 9987 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 9988 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 9989 | } |
| 9990 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9991 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9992 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 9993 | os.Exit(1) |
| 9994 | } |
| 9995 | |
| 9996 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9997 | os.Exit(1) |
| 9998 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9999 | } |