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.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 65 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 66 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 67 | // ShimConfigurations is used with the “json” package and represents a shim |
| 68 | // config file. |
| 69 | type ShimConfiguration struct { |
| 70 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 71 | // The glob pattern is used to exclude tests from being run and the |
| 72 | // freeform string is unparsed but expected to explain why the test is |
| 73 | // disabled. |
| 74 | DisabledTests map[string]string |
| 75 | |
| 76 | // ErrorMap maps from expected error strings to the correct error |
| 77 | // string for the shim in question. For example, it might map |
| 78 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 79 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 80 | ErrorMap map[string]string |
| 81 | } |
| 82 | |
| 83 | var shimConfig ShimConfiguration |
| 84 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 85 | type testCert int |
| 86 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 87 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 88 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 89 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 90 | testCertRSAChain |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 91 | testCertECDSAP256 |
| 92 | testCertECDSAP384 |
| 93 | testCertECDSAP521 |
| 94 | ) |
| 95 | |
| 96 | const ( |
| 97 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 98 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 99 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 100 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 101 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 102 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 103 | ) |
| 104 | |
| 105 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 106 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 107 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 108 | rsaChainKeyFile = "rsa_chain_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 109 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 110 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 111 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 112 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 113 | ) |
| 114 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 115 | var ( |
| 116 | rsaCertificate Certificate |
| 117 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 118 | rsaChainCertificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 119 | ecdsaP256Certificate Certificate |
| 120 | ecdsaP384Certificate Certificate |
| 121 | ecdsaP521Certificate Certificate |
| 122 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 123 | |
| 124 | var testCerts = []struct { |
| 125 | id testCert |
| 126 | certFile, keyFile string |
| 127 | cert *Certificate |
| 128 | }{ |
| 129 | { |
| 130 | id: testCertRSA, |
| 131 | certFile: rsaCertificateFile, |
| 132 | keyFile: rsaKeyFile, |
| 133 | cert: &rsaCertificate, |
| 134 | }, |
| 135 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 136 | id: testCertRSA1024, |
| 137 | certFile: rsa1024CertificateFile, |
| 138 | keyFile: rsa1024KeyFile, |
| 139 | cert: &rsa1024Certificate, |
| 140 | }, |
| 141 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 142 | id: testCertRSAChain, |
| 143 | certFile: rsaChainCertificateFile, |
| 144 | keyFile: rsaChainKeyFile, |
| 145 | cert: &rsaChainCertificate, |
| 146 | }, |
| 147 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 148 | id: testCertECDSAP256, |
| 149 | certFile: ecdsaP256CertificateFile, |
| 150 | keyFile: ecdsaP256KeyFile, |
| 151 | cert: &ecdsaP256Certificate, |
| 152 | }, |
| 153 | { |
| 154 | id: testCertECDSAP384, |
| 155 | certFile: ecdsaP384CertificateFile, |
| 156 | keyFile: ecdsaP384KeyFile, |
| 157 | cert: &ecdsaP384Certificate, |
| 158 | }, |
| 159 | { |
| 160 | id: testCertECDSAP521, |
| 161 | certFile: ecdsaP521CertificateFile, |
| 162 | keyFile: ecdsaP521KeyFile, |
| 163 | cert: &ecdsaP521Certificate, |
| 164 | }, |
| 165 | } |
| 166 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 167 | var channelIDKey *ecdsa.PrivateKey |
| 168 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 169 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 170 | var testOCSPResponse = []byte{1, 2, 3, 4} |
| 171 | var testSCTList = []byte{5, 6, 7, 8} |
| 172 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 173 | var testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) |
| 174 | var testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, 4}, testSCTList...) |
| 175 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 176 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 177 | for i := range testCerts { |
| 178 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 179 | if err != nil { |
| 180 | panic(err) |
| 181 | } |
| 182 | cert.OCSPStaple = testOCSPResponse |
| 183 | cert.SignedCertificateTimestampList = testSCTList |
| 184 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 185 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 186 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 187 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 188 | if err != nil { |
| 189 | panic(err) |
| 190 | } |
| 191 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 192 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 193 | panic("bad key type") |
| 194 | } |
| 195 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 196 | if err != nil { |
| 197 | panic(err) |
| 198 | } |
| 199 | if channelIDKey.Curve != elliptic.P256() { |
| 200 | panic("bad curve") |
| 201 | } |
| 202 | |
| 203 | channelIDBytes = make([]byte, 64) |
| 204 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 205 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 206 | } |
| 207 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 208 | func getRunnerCertificate(t testCert) Certificate { |
| 209 | for _, cert := range testCerts { |
| 210 | if cert.id == t { |
| 211 | return *cert.cert |
| 212 | } |
| 213 | } |
| 214 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 215 | } |
| 216 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 217 | func getShimCertificate(t testCert) string { |
| 218 | for _, cert := range testCerts { |
| 219 | if cert.id == t { |
| 220 | return cert.certFile |
| 221 | } |
| 222 | } |
| 223 | panic("Unknown test certificate") |
| 224 | } |
| 225 | |
| 226 | func getShimKey(t testCert) string { |
| 227 | for _, cert := range testCerts { |
| 228 | if cert.id == t { |
| 229 | return cert.keyFile |
| 230 | } |
| 231 | } |
| 232 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 233 | } |
| 234 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 235 | type testType int |
| 236 | |
| 237 | const ( |
| 238 | clientTest testType = iota |
| 239 | serverTest |
| 240 | ) |
| 241 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 242 | type protocol int |
| 243 | |
| 244 | const ( |
| 245 | tls protocol = iota |
| 246 | dtls |
| 247 | ) |
| 248 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 249 | const ( |
| 250 | alpn = 1 |
| 251 | npn = 2 |
| 252 | ) |
| 253 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 254 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 255 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 256 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 257 | name string |
| 258 | config Config |
| 259 | shouldFail bool |
| 260 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 261 | // expectedLocalError, if not empty, contains a substring that must be |
| 262 | // found in the local error. |
| 263 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 264 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 265 | // negotiated. |
| 266 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 267 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 268 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 269 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 270 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 271 | // should be negotiated. |
| 272 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 273 | // expectChannelID controls whether the connection should have |
| 274 | // negotiated a Channel ID with channelIDKey. |
| 275 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 276 | // expectedNextProto controls whether the connection should |
| 277 | // negotiate a next protocol via NPN or ALPN. |
| 278 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 279 | // expectNoNextProto, if true, means that no next protocol should be |
| 280 | // negotiated. |
| 281 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 282 | // expectedNextProtoType, if non-zero, is the expected next |
| 283 | // protocol negotiation mechanism. |
| 284 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 285 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 286 | // should be negotiated. If zero, none should be negotiated. |
| 287 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 288 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 289 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 290 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 291 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 292 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 293 | // algorithm that the peer should have used in the handshake. |
| 294 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 295 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 296 | // have used. |
| 297 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 298 | // messageLen is the length, in bytes, of the test message that will be |
| 299 | // sent. |
| 300 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 301 | // messageCount is the number of test messages that will be sent. |
| 302 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 303 | // certFile is the path to the certificate to use for the server. |
| 304 | certFile string |
| 305 | // keyFile is the path to the private key to use for the server. |
| 306 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 307 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 308 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 309 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 310 | // resumeRenewedSession controls whether a third connection should be |
| 311 | // tested which attempts to resume the second connection's session. |
| 312 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 313 | // expectResumeRejected, if true, specifies that the attempted |
| 314 | // resumption must be rejected by the client. This is only valid for a |
| 315 | // serverTest. |
| 316 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 317 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 318 | // resumption. Unless newSessionsOnResume is set, |
| 319 | // SessionTicketKey, ServerSessionCache, and |
| 320 | // ClientSessionCache are copied from the initial connection's |
| 321 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 322 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 323 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 324 | // use a different session resumption context. |
| 325 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 326 | // noSessionCache, if true, will cause the server to run without a |
| 327 | // session cache. |
| 328 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 329 | // sendPrefix sends a prefix on the socket before actually performing a |
| 330 | // handshake. |
| 331 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 332 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 333 | // message before doing a roundtrip with the runner. |
| 334 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 335 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 336 | // connection immediately after the handshake rather than echoing |
| 337 | // messages from the runner. |
| 338 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 339 | // renegotiate indicates the number of times the connection should be |
| 340 | // renegotiated during the exchange. |
| 341 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 342 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 343 | // HelloRequest when the handshake completes. |
| 344 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 345 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 346 | // switched in just before renegotiation. |
| 347 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 348 | // replayWrites, if true, configures the underlying transport |
| 349 | // to replay every write it makes in DTLS tests. |
| 350 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 351 | // damageFirstWrite, if true, configures the underlying transport to |
| 352 | // damage the final byte of the first application data write. |
| 353 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 354 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 355 | // keying material and verify they match. |
| 356 | exportKeyingMaterial int |
| 357 | exportLabel string |
| 358 | exportContext string |
| 359 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 360 | // flags, if not empty, contains a list of command-line flags that will |
| 361 | // be passed to the shim program. |
| 362 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 363 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 364 | // which will be compared against the expected value. |
| 365 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 366 | // sendEmptyRecords is the number of consecutive empty records to send |
| 367 | // before and after the test message. |
| 368 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 369 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 370 | // before and after the test message. |
| 371 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 372 | // sendKeyUpdates is the number of consecutive key updates to send |
| 373 | // before and after the test message. |
| 374 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 375 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 376 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 377 | // expectMessageDropped, if true, means the test message is expected to |
| 378 | // be dropped by the client rather than echoed back. |
| 379 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 380 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 381 | // is expected to send. |
| 382 | expectPeerCertificate *Certificate |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 383 | } |
| 384 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 385 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 386 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 387 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 388 | if len(data) == 0 { |
| 389 | return |
| 390 | } |
| 391 | |
| 392 | protocol := "tls" |
| 393 | if test.protocol == dtls { |
| 394 | protocol = "dtls" |
| 395 | } |
| 396 | |
| 397 | side := "client" |
| 398 | if test.testType == serverTest { |
| 399 | side = "server" |
| 400 | } |
| 401 | |
| 402 | dir := path.Join(*transcriptDir, protocol, side) |
| 403 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 404 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 405 | return |
| 406 | } |
| 407 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 408 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 409 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 410 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 411 | } |
| 412 | } |
| 413 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 414 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 415 | type timeoutConn struct { |
| 416 | net.Conn |
| 417 | timeout time.Duration |
| 418 | } |
| 419 | |
| 420 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 421 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 422 | return 0, err |
| 423 | } |
| 424 | return t.Conn.Read(b) |
| 425 | } |
| 426 | |
| 427 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 428 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 429 | return 0, err |
| 430 | } |
| 431 | return t.Conn.Write(b) |
| 432 | } |
| 433 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 434 | 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] | 435 | if !test.noSessionCache { |
| 436 | if config.ClientSessionCache == nil { |
| 437 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 438 | } |
| 439 | if config.ServerSessionCache == nil { |
| 440 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 441 | } |
| 442 | } |
| 443 | if test.testType == clientTest { |
| 444 | if len(config.Certificates) == 0 { |
| 445 | config.Certificates = []Certificate{rsaCertificate} |
| 446 | } |
| 447 | } else { |
| 448 | // Supply a ServerName to ensure a constant session cache key, |
| 449 | // rather than falling back to net.Conn.RemoteAddr. |
| 450 | if len(config.ServerName) == 0 { |
| 451 | config.ServerName = "test" |
| 452 | } |
| 453 | } |
| 454 | if *fuzzer { |
| 455 | config.Bugs.NullAllCiphers = true |
| 456 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 457 | if *deterministic { |
| 458 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 459 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 460 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 461 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 462 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 463 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 464 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 465 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 466 | } |
| 467 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 468 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 469 | local, peer := "client", "server" |
| 470 | if test.testType == clientTest { |
| 471 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 472 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 473 | connDebug := &recordingConn{ |
| 474 | Conn: conn, |
| 475 | isDatagram: test.protocol == dtls, |
| 476 | local: local, |
| 477 | peer: peer, |
| 478 | } |
| 479 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 480 | if *flagDebug { |
| 481 | defer connDebug.WriteTo(os.Stdout) |
| 482 | } |
| 483 | if len(*transcriptDir) != 0 { |
| 484 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 485 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 486 | }() |
| 487 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 488 | |
| 489 | if config.Bugs.PacketAdaptor != nil { |
| 490 | config.Bugs.PacketAdaptor.debug = connDebug |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | if test.replayWrites { |
| 495 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 496 | } |
| 497 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 498 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 499 | if test.damageFirstWrite { |
| 500 | connDamage = newDamageAdaptor(conn) |
| 501 | conn = connDamage |
| 502 | } |
| 503 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 504 | if test.sendPrefix != "" { |
| 505 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 506 | return err |
| 507 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 508 | } |
| 509 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 510 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 511 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 512 | if test.protocol == dtls { |
| 513 | tlsConn = DTLSServer(conn, config) |
| 514 | } else { |
| 515 | tlsConn = Server(conn, config) |
| 516 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 517 | } else { |
| 518 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 519 | if test.protocol == dtls { |
| 520 | tlsConn = DTLSClient(conn, config) |
| 521 | } else { |
| 522 | tlsConn = Client(conn, config) |
| 523 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 524 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 525 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 526 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 527 | if err := tlsConn.Handshake(); err != nil { |
| 528 | return err |
| 529 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 530 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 531 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 532 | // expectations struct that can be specified separately for the two |
| 533 | // legs. |
| 534 | expectedVersion := test.expectedVersion |
| 535 | if isResume && test.expectedResumeVersion != 0 { |
| 536 | expectedVersion = test.expectedResumeVersion |
| 537 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 538 | connState := tlsConn.ConnectionState() |
| 539 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 540 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 541 | } |
| 542 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 543 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 544 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 545 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 546 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 547 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 548 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 549 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 550 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 551 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 552 | if channelID == nil { |
| 553 | return fmt.Errorf("no channel ID negotiated") |
| 554 | } |
| 555 | if channelID.Curve != channelIDKey.Curve || |
| 556 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 557 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 558 | return fmt.Errorf("incorrect channel ID") |
| 559 | } |
| 560 | } |
| 561 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 562 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 563 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 564 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 565 | } |
| 566 | } |
| 567 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 568 | if test.expectNoNextProto { |
| 569 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 570 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 571 | } |
| 572 | } |
| 573 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 574 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 575 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 576 | return fmt.Errorf("next proto type mismatch") |
| 577 | } |
| 578 | } |
| 579 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 580 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 581 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 582 | } |
| 583 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 584 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 585 | 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] | 586 | } |
| 587 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 588 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 589 | return fmt.Errorf("SCT list mismatch") |
| 590 | } |
| 591 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 592 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 593 | 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] | 594 | } |
| 595 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 596 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 597 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 598 | } |
| 599 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 600 | if test.expectPeerCertificate != nil { |
| 601 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 602 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 603 | } |
| 604 | for i, cert := range connState.PeerCertificates { |
| 605 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 606 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 607 | } |
| 608 | } |
| 609 | } |
| 610 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 611 | if test.exportKeyingMaterial > 0 { |
| 612 | actual := make([]byte, test.exportKeyingMaterial) |
| 613 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 614 | return err |
| 615 | } |
| 616 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 617 | if err != nil { |
| 618 | return err |
| 619 | } |
| 620 | if !bytes.Equal(actual, expected) { |
| 621 | return fmt.Errorf("keying material mismatch") |
| 622 | } |
| 623 | } |
| 624 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 625 | if test.testTLSUnique { |
| 626 | var peersValue [12]byte |
| 627 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 628 | return err |
| 629 | } |
| 630 | expected := tlsConn.ConnectionState().TLSUnique |
| 631 | if !bytes.Equal(peersValue[:], expected) { |
| 632 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 633 | } |
| 634 | } |
| 635 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 636 | if test.shimWritesFirst { |
| 637 | var buf [5]byte |
| 638 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 639 | if err != nil { |
| 640 | return err |
| 641 | } |
| 642 | if string(buf[:]) != "hello" { |
| 643 | return fmt.Errorf("bad initial message") |
| 644 | } |
| 645 | } |
| 646 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 647 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 648 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 649 | return err |
| 650 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 651 | } |
| 652 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 653 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 654 | tlsConn.Write(nil) |
| 655 | } |
| 656 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 657 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 658 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 659 | } |
| 660 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 661 | if test.sendHalfHelloRequest { |
| 662 | tlsConn.SendHalfHelloRequest() |
| 663 | } |
| 664 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 665 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 666 | if test.renegotiateCiphers != nil { |
| 667 | config.CipherSuites = test.renegotiateCiphers |
| 668 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 669 | for i := 0; i < test.renegotiate; i++ { |
| 670 | if err := tlsConn.Renegotiate(); err != nil { |
| 671 | return err |
| 672 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 673 | } |
| 674 | } else if test.renegotiateCiphers != nil { |
| 675 | panic("renegotiateCiphers without renegotiate") |
| 676 | } |
| 677 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 678 | if test.damageFirstWrite { |
| 679 | connDamage.setDamage(true) |
| 680 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 681 | connDamage.setDamage(false) |
| 682 | } |
| 683 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 684 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 685 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 686 | if test.protocol == dtls { |
| 687 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 688 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 689 | // Read until EOF. |
| 690 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 691 | return err |
| 692 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 693 | if messageLen == 0 { |
| 694 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 695 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 696 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 697 | messageCount := test.messageCount |
| 698 | if messageCount == 0 { |
| 699 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 700 | } |
| 701 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 702 | for j := 0; j < messageCount; j++ { |
| 703 | testMessage := make([]byte, messageLen) |
| 704 | for i := range testMessage { |
| 705 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 706 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 707 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 708 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 709 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 710 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 711 | } |
| 712 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 713 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 714 | tlsConn.Write(nil) |
| 715 | } |
| 716 | |
| 717 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 718 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 719 | } |
| 720 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 721 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 722 | // The shim will not respond. |
| 723 | continue |
| 724 | } |
| 725 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 726 | buf := make([]byte, len(testMessage)) |
| 727 | if test.protocol == dtls { |
| 728 | bufTmp := make([]byte, len(buf)+1) |
| 729 | n, err := tlsConn.Read(bufTmp) |
| 730 | if err != nil { |
| 731 | return err |
| 732 | } |
| 733 | if n != len(buf) { |
| 734 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 735 | } |
| 736 | copy(buf, bufTmp) |
| 737 | } else { |
| 738 | _, err := io.ReadFull(tlsConn, buf) |
| 739 | if err != nil { |
| 740 | return err |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | for i, v := range buf { |
| 745 | if v != testMessage[i]^0xff { |
| 746 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 747 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 748 | } |
| 749 | } |
| 750 | |
| 751 | return nil |
| 752 | } |
| 753 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 754 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 755 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 756 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 757 | 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] | 758 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 759 | valgrindArgs = append(valgrindArgs, path) |
| 760 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 761 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 762 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 763 | } |
| 764 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 765 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 766 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 767 | xtermArgs = append(xtermArgs, path) |
| 768 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 769 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 770 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 771 | } |
| 772 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 773 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 774 | xtermArgs := []string{"-e", "lldb", "--"} |
| 775 | xtermArgs = append(xtermArgs, path) |
| 776 | xtermArgs = append(xtermArgs, args...) |
| 777 | |
| 778 | return exec.Command("xterm", xtermArgs...) |
| 779 | } |
| 780 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 781 | var ( |
| 782 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 783 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 784 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 785 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 786 | // accept accepts a connection from listener, unless waitChan signals a process |
| 787 | // exit first. |
| 788 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 789 | type connOrError struct { |
| 790 | conn net.Conn |
| 791 | err error |
| 792 | } |
| 793 | connChan := make(chan connOrError, 1) |
| 794 | go func() { |
| 795 | conn, err := listener.Accept() |
| 796 | connChan <- connOrError{conn, err} |
| 797 | close(connChan) |
| 798 | }() |
| 799 | select { |
| 800 | case result := <-connChan: |
| 801 | return result.conn, result.err |
| 802 | case childErr := <-waitChan: |
| 803 | waitChan <- childErr |
| 804 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 805 | } |
| 806 | } |
| 807 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 808 | func translateExpectedError(errorStr string) string { |
| 809 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 810 | return translated |
| 811 | } |
| 812 | |
| 813 | if *looseErrors { |
| 814 | return "" |
| 815 | } |
| 816 | |
| 817 | return errorStr |
| 818 | } |
| 819 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 820 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 821 | // Help debugging panics on the Go side. |
| 822 | defer func() { |
| 823 | if r := recover(); r != nil { |
| 824 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 825 | panic(r) |
| 826 | } |
| 827 | }() |
| 828 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 829 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 830 | panic("Error expected without shouldFail in " + test.name) |
| 831 | } |
| 832 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 833 | if test.expectResumeRejected && !test.resumeSession { |
| 834 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 835 | } |
| 836 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 837 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 838 | if err != nil { |
| 839 | panic(err) |
| 840 | } |
| 841 | defer func() { |
| 842 | if listener != nil { |
| 843 | listener.Close() |
| 844 | } |
| 845 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 846 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 847 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 848 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 849 | flags = append(flags, "-server") |
| 850 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 851 | flags = append(flags, "-key-file") |
| 852 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 853 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 854 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 855 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | flags = append(flags, "-cert-file") |
| 859 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 860 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 861 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 862 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 863 | } |
| 864 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 865 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 866 | if test.protocol == dtls { |
| 867 | flags = append(flags, "-dtls") |
| 868 | } |
| 869 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 870 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 871 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 872 | resumeCount++ |
| 873 | if test.resumeRenewedSession { |
| 874 | resumeCount++ |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | if resumeCount > 0 { |
| 879 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 880 | } |
| 881 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 882 | if test.shimWritesFirst { |
| 883 | flags = append(flags, "-shim-writes-first") |
| 884 | } |
| 885 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 886 | if test.shimShutsDown { |
| 887 | flags = append(flags, "-shim-shuts-down") |
| 888 | } |
| 889 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 890 | if test.exportKeyingMaterial > 0 { |
| 891 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 892 | flags = append(flags, "-export-label", test.exportLabel) |
| 893 | flags = append(flags, "-export-context", test.exportContext) |
| 894 | if test.useExportContext { |
| 895 | flags = append(flags, "-use-export-context") |
| 896 | } |
| 897 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 898 | if test.expectResumeRejected { |
| 899 | flags = append(flags, "-expect-session-miss") |
| 900 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 901 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 902 | if test.testTLSUnique { |
| 903 | flags = append(flags, "-tls-unique") |
| 904 | } |
| 905 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 906 | flags = append(flags, test.flags...) |
| 907 | |
| 908 | var shim *exec.Cmd |
| 909 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 910 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 911 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 912 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 913 | } else if *useLLDB { |
| 914 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 915 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 916 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 917 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 918 | shim.Stdin = os.Stdin |
| 919 | var stdoutBuf, stderrBuf bytes.Buffer |
| 920 | shim.Stdout = &stdoutBuf |
| 921 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 922 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 923 | shim.Env = os.Environ() |
| 924 | 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] | 925 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 926 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 927 | } |
| 928 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 929 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 930 | |
| 931 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 932 | panic(err) |
| 933 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 934 | waitChan := make(chan error, 1) |
| 935 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 936 | |
| 937 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 938 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 939 | if *deterministic { |
| 940 | config.Rand = &deterministicRand{} |
| 941 | } |
| 942 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 943 | conn, err := acceptOrWait(listener, waitChan) |
| 944 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 945 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 946 | conn.Close() |
| 947 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 948 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 949 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 950 | var resumeConfig Config |
| 951 | if test.resumeConfig != nil { |
| 952 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 953 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 954 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 955 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 956 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 957 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 958 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 959 | } else { |
| 960 | resumeConfig = config |
| 961 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 962 | var connResume net.Conn |
| 963 | connResume, err = acceptOrWait(listener, waitChan) |
| 964 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 965 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 966 | connResume.Close() |
| 967 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 968 | } |
| 969 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 970 | // Close the listener now. This is to avoid hangs should the shim try to |
| 971 | // open more connections than expected. |
| 972 | listener.Close() |
| 973 | listener = nil |
| 974 | |
| 975 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 976 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 977 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 978 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 979 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 980 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 981 | case 89: |
| 982 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 983 | case 99: |
| 984 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 985 | } |
| 986 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 987 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 988 | // Account for Windows line endings. |
| 989 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 990 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 991 | |
| 992 | // Separate the errors from the shim and those from tools like |
| 993 | // AddressSanitizer. |
| 994 | var extraStderr string |
| 995 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 996 | stderr = stderrParts[0] |
| 997 | extraStderr = stderrParts[1] |
| 998 | } |
| 999 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1000 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1001 | expectedError := translateExpectedError(test.expectedError) |
| 1002 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1003 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1004 | localError := "none" |
| 1005 | if err != nil { |
| 1006 | localError = err.Error() |
| 1007 | } |
| 1008 | if len(test.expectedLocalError) != 0 { |
| 1009 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1010 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1011 | |
| 1012 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1013 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1014 | if childErr != nil { |
| 1015 | childError = childErr.Error() |
| 1016 | } |
| 1017 | |
| 1018 | var msg string |
| 1019 | switch { |
| 1020 | case failed && !test.shouldFail: |
| 1021 | msg = "unexpected failure" |
| 1022 | case !failed && test.shouldFail: |
| 1023 | msg = "unexpected success" |
| 1024 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1025 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1026 | default: |
| 1027 | panic("internal error") |
| 1028 | } |
| 1029 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1030 | 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] | 1031 | } |
| 1032 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1033 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1034 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1037 | if *useValgrind && isValgrindError { |
| 1038 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1039 | } |
| 1040 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1041 | return nil |
| 1042 | } |
| 1043 | |
| 1044 | var tlsVersions = []struct { |
| 1045 | name string |
| 1046 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1047 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1048 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1049 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1050 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1051 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1052 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1053 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1054 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | var testCipherSuites = []struct { |
| 1058 | name string |
| 1059 | id uint16 |
| 1060 | }{ |
| 1061 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1062 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1063 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1064 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1065 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1066 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1067 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1068 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1069 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1070 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1071 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1072 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1073 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1074 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1075 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1076 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1077 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1078 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1079 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1080 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1081 | {"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] | 1082 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1083 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1084 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1085 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1086 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1087 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1088 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1089 | {"ECDHE-RSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 1090 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1091 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1092 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1093 | {"CECPQ1-ECDSA-AES256-GCM-SHA384", TLS_CECPQ1_ECDSA_WITH_AES_256_GCM_SHA384}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1094 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1095 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1096 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1097 | {"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] | 1098 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1099 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1100 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1101 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1102 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1103 | } |
| 1104 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1105 | func hasComponent(suiteName, component string) bool { |
| 1106 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1107 | } |
| 1108 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1109 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1110 | return hasComponent(suiteName, "GCM") || |
| 1111 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1112 | hasComponent(suiteName, "SHA384") || |
| 1113 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1114 | } |
| 1115 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1116 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1117 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1120 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1121 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1122 | } |
| 1123 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1124 | func bigFromHex(hex string) *big.Int { |
| 1125 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1126 | if !ok { |
| 1127 | panic("failed to parse hex number 0x" + hex) |
| 1128 | } |
| 1129 | return ret |
| 1130 | } |
| 1131 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1132 | func addBasicTests() { |
| 1133 | basicTests := []testCase{ |
| 1134 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1135 | name: "NoFallbackSCSV", |
| 1136 | config: Config{ |
| 1137 | Bugs: ProtocolBugs{ |
| 1138 | FailIfNotFallbackSCSV: true, |
| 1139 | }, |
| 1140 | }, |
| 1141 | shouldFail: true, |
| 1142 | expectedLocalError: "no fallback SCSV found", |
| 1143 | }, |
| 1144 | { |
| 1145 | name: "SendFallbackSCSV", |
| 1146 | config: Config{ |
| 1147 | Bugs: ProtocolBugs{ |
| 1148 | FailIfNotFallbackSCSV: true, |
| 1149 | }, |
| 1150 | }, |
| 1151 | flags: []string{"-fallback-scsv"}, |
| 1152 | }, |
| 1153 | { |
| 1154 | name: "ClientCertificateTypes", |
| 1155 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1156 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1157 | ClientAuth: RequestClientCert, |
| 1158 | ClientCertificateTypes: []byte{ |
| 1159 | CertTypeDSSSign, |
| 1160 | CertTypeRSASign, |
| 1161 | CertTypeECDSASign, |
| 1162 | }, |
| 1163 | }, |
| 1164 | flags: []string{ |
| 1165 | "-expect-certificate-types", |
| 1166 | base64.StdEncoding.EncodeToString([]byte{ |
| 1167 | CertTypeDSSSign, |
| 1168 | CertTypeRSASign, |
| 1169 | CertTypeECDSASign, |
| 1170 | }), |
| 1171 | }, |
| 1172 | }, |
| 1173 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1174 | name: "UnauthenticatedECDH", |
| 1175 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1176 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1177 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1178 | Bugs: ProtocolBugs{ |
| 1179 | UnauthenticatedECDH: true, |
| 1180 | }, |
| 1181 | }, |
| 1182 | shouldFail: true, |
| 1183 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1184 | }, |
| 1185 | { |
| 1186 | name: "SkipCertificateStatus", |
| 1187 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1188 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1189 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1190 | Bugs: ProtocolBugs{ |
| 1191 | SkipCertificateStatus: true, |
| 1192 | }, |
| 1193 | }, |
| 1194 | flags: []string{ |
| 1195 | "-enable-ocsp-stapling", |
| 1196 | }, |
| 1197 | }, |
| 1198 | { |
| 1199 | name: "SkipServerKeyExchange", |
| 1200 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1201 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1202 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1203 | Bugs: ProtocolBugs{ |
| 1204 | SkipServerKeyExchange: true, |
| 1205 | }, |
| 1206 | }, |
| 1207 | shouldFail: true, |
| 1208 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1209 | }, |
| 1210 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1211 | testType: serverTest, |
| 1212 | name: "Alert", |
| 1213 | config: Config{ |
| 1214 | Bugs: ProtocolBugs{ |
| 1215 | SendSpuriousAlert: alertRecordOverflow, |
| 1216 | }, |
| 1217 | }, |
| 1218 | shouldFail: true, |
| 1219 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1220 | }, |
| 1221 | { |
| 1222 | protocol: dtls, |
| 1223 | testType: serverTest, |
| 1224 | name: "Alert-DTLS", |
| 1225 | config: Config{ |
| 1226 | Bugs: ProtocolBugs{ |
| 1227 | SendSpuriousAlert: alertRecordOverflow, |
| 1228 | }, |
| 1229 | }, |
| 1230 | shouldFail: true, |
| 1231 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1232 | }, |
| 1233 | { |
| 1234 | testType: serverTest, |
| 1235 | name: "FragmentAlert", |
| 1236 | config: Config{ |
| 1237 | Bugs: ProtocolBugs{ |
| 1238 | FragmentAlert: true, |
| 1239 | SendSpuriousAlert: alertRecordOverflow, |
| 1240 | }, |
| 1241 | }, |
| 1242 | shouldFail: true, |
| 1243 | expectedError: ":BAD_ALERT:", |
| 1244 | }, |
| 1245 | { |
| 1246 | protocol: dtls, |
| 1247 | testType: serverTest, |
| 1248 | name: "FragmentAlert-DTLS", |
| 1249 | config: Config{ |
| 1250 | Bugs: ProtocolBugs{ |
| 1251 | FragmentAlert: true, |
| 1252 | SendSpuriousAlert: alertRecordOverflow, |
| 1253 | }, |
| 1254 | }, |
| 1255 | shouldFail: true, |
| 1256 | expectedError: ":BAD_ALERT:", |
| 1257 | }, |
| 1258 | { |
| 1259 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1260 | name: "DoubleAlert", |
| 1261 | config: Config{ |
| 1262 | Bugs: ProtocolBugs{ |
| 1263 | DoubleAlert: true, |
| 1264 | SendSpuriousAlert: alertRecordOverflow, |
| 1265 | }, |
| 1266 | }, |
| 1267 | shouldFail: true, |
| 1268 | expectedError: ":BAD_ALERT:", |
| 1269 | }, |
| 1270 | { |
| 1271 | protocol: dtls, |
| 1272 | testType: serverTest, |
| 1273 | name: "DoubleAlert-DTLS", |
| 1274 | config: Config{ |
| 1275 | Bugs: ProtocolBugs{ |
| 1276 | DoubleAlert: true, |
| 1277 | SendSpuriousAlert: alertRecordOverflow, |
| 1278 | }, |
| 1279 | }, |
| 1280 | shouldFail: true, |
| 1281 | expectedError: ":BAD_ALERT:", |
| 1282 | }, |
| 1283 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1284 | name: "SkipNewSessionTicket", |
| 1285 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1286 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1287 | Bugs: ProtocolBugs{ |
| 1288 | SkipNewSessionTicket: true, |
| 1289 | }, |
| 1290 | }, |
| 1291 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1292 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1293 | }, |
| 1294 | { |
| 1295 | testType: serverTest, |
| 1296 | name: "FallbackSCSV", |
| 1297 | config: Config{ |
| 1298 | MaxVersion: VersionTLS11, |
| 1299 | Bugs: ProtocolBugs{ |
| 1300 | SendFallbackSCSV: true, |
| 1301 | }, |
| 1302 | }, |
| 1303 | shouldFail: true, |
| 1304 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1305 | }, |
| 1306 | { |
| 1307 | testType: serverTest, |
| 1308 | name: "FallbackSCSV-VersionMatch", |
| 1309 | config: Config{ |
| 1310 | Bugs: ProtocolBugs{ |
| 1311 | SendFallbackSCSV: true, |
| 1312 | }, |
| 1313 | }, |
| 1314 | }, |
| 1315 | { |
| 1316 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1317 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1318 | config: Config{ |
| 1319 | MaxVersion: VersionTLS12, |
| 1320 | Bugs: ProtocolBugs{ |
| 1321 | SendFallbackSCSV: true, |
| 1322 | }, |
| 1323 | }, |
| 1324 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1325 | }, |
| 1326 | { |
| 1327 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1328 | name: "FragmentedClientVersion", |
| 1329 | config: Config{ |
| 1330 | Bugs: ProtocolBugs{ |
| 1331 | MaxHandshakeRecordLength: 1, |
| 1332 | FragmentClientVersion: true, |
| 1333 | }, |
| 1334 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1335 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1336 | }, |
| 1337 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1338 | testType: serverTest, |
| 1339 | name: "HttpGET", |
| 1340 | sendPrefix: "GET / HTTP/1.0\n", |
| 1341 | shouldFail: true, |
| 1342 | expectedError: ":HTTP_REQUEST:", |
| 1343 | }, |
| 1344 | { |
| 1345 | testType: serverTest, |
| 1346 | name: "HttpPOST", |
| 1347 | sendPrefix: "POST / HTTP/1.0\n", |
| 1348 | shouldFail: true, |
| 1349 | expectedError: ":HTTP_REQUEST:", |
| 1350 | }, |
| 1351 | { |
| 1352 | testType: serverTest, |
| 1353 | name: "HttpHEAD", |
| 1354 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1355 | shouldFail: true, |
| 1356 | expectedError: ":HTTP_REQUEST:", |
| 1357 | }, |
| 1358 | { |
| 1359 | testType: serverTest, |
| 1360 | name: "HttpPUT", |
| 1361 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1362 | shouldFail: true, |
| 1363 | expectedError: ":HTTP_REQUEST:", |
| 1364 | }, |
| 1365 | { |
| 1366 | testType: serverTest, |
| 1367 | name: "HttpCONNECT", |
| 1368 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1369 | shouldFail: true, |
| 1370 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1371 | }, |
| 1372 | { |
| 1373 | testType: serverTest, |
| 1374 | name: "Garbage", |
| 1375 | sendPrefix: "blah", |
| 1376 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1377 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1378 | }, |
| 1379 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1380 | name: "RSAEphemeralKey", |
| 1381 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1382 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1383 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1384 | Bugs: ProtocolBugs{ |
| 1385 | RSAEphemeralKey: true, |
| 1386 | }, |
| 1387 | }, |
| 1388 | shouldFail: true, |
| 1389 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1390 | }, |
| 1391 | { |
| 1392 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1393 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1394 | shouldFail: true, |
| 1395 | expectedError: ":WRONG_SSL_VERSION:", |
| 1396 | }, |
| 1397 | { |
| 1398 | protocol: dtls, |
| 1399 | name: "DisableEverything-DTLS", |
| 1400 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1401 | shouldFail: true, |
| 1402 | expectedError: ":WRONG_SSL_VERSION:", |
| 1403 | }, |
| 1404 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1405 | protocol: dtls, |
| 1406 | testType: serverTest, |
| 1407 | name: "MTU", |
| 1408 | config: Config{ |
| 1409 | Bugs: ProtocolBugs{ |
| 1410 | MaxPacketLength: 256, |
| 1411 | }, |
| 1412 | }, |
| 1413 | flags: []string{"-mtu", "256"}, |
| 1414 | }, |
| 1415 | { |
| 1416 | protocol: dtls, |
| 1417 | testType: serverTest, |
| 1418 | name: "MTUExceeded", |
| 1419 | config: Config{ |
| 1420 | Bugs: ProtocolBugs{ |
| 1421 | MaxPacketLength: 255, |
| 1422 | }, |
| 1423 | }, |
| 1424 | flags: []string{"-mtu", "256"}, |
| 1425 | shouldFail: true, |
| 1426 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1427 | }, |
| 1428 | { |
| 1429 | name: "CertMismatchRSA", |
| 1430 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1431 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1432 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1433 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1434 | Bugs: ProtocolBugs{ |
| 1435 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1436 | }, |
| 1437 | }, |
| 1438 | shouldFail: true, |
| 1439 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1440 | }, |
| 1441 | { |
| 1442 | name: "CertMismatchECDSA", |
| 1443 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1444 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1445 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1446 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1447 | Bugs: ProtocolBugs{ |
| 1448 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1449 | }, |
| 1450 | }, |
| 1451 | shouldFail: true, |
| 1452 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1453 | }, |
| 1454 | { |
| 1455 | name: "EmptyCertificateList", |
| 1456 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1457 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1458 | Bugs: ProtocolBugs{ |
| 1459 | EmptyCertificateList: true, |
| 1460 | }, |
| 1461 | }, |
| 1462 | shouldFail: true, |
| 1463 | expectedError: ":DECODE_ERROR:", |
| 1464 | }, |
| 1465 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1466 | name: "EmptyCertificateList-TLS13", |
| 1467 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1468 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1469 | Bugs: ProtocolBugs{ |
| 1470 | EmptyCertificateList: true, |
| 1471 | }, |
| 1472 | }, |
| 1473 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1474 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1475 | }, |
| 1476 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1477 | name: "TLSFatalBadPackets", |
| 1478 | damageFirstWrite: true, |
| 1479 | shouldFail: true, |
| 1480 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1481 | }, |
| 1482 | { |
| 1483 | protocol: dtls, |
| 1484 | name: "DTLSIgnoreBadPackets", |
| 1485 | damageFirstWrite: true, |
| 1486 | }, |
| 1487 | { |
| 1488 | protocol: dtls, |
| 1489 | name: "DTLSIgnoreBadPackets-Async", |
| 1490 | damageFirstWrite: true, |
| 1491 | flags: []string{"-async"}, |
| 1492 | }, |
| 1493 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1494 | name: "AppDataBeforeHandshake", |
| 1495 | config: Config{ |
| 1496 | Bugs: ProtocolBugs{ |
| 1497 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1498 | }, |
| 1499 | }, |
| 1500 | shouldFail: true, |
| 1501 | expectedError: ":UNEXPECTED_RECORD:", |
| 1502 | }, |
| 1503 | { |
| 1504 | name: "AppDataBeforeHandshake-Empty", |
| 1505 | config: Config{ |
| 1506 | Bugs: ProtocolBugs{ |
| 1507 | AppDataBeforeHandshake: []byte{}, |
| 1508 | }, |
| 1509 | }, |
| 1510 | shouldFail: true, |
| 1511 | expectedError: ":UNEXPECTED_RECORD:", |
| 1512 | }, |
| 1513 | { |
| 1514 | protocol: dtls, |
| 1515 | name: "AppDataBeforeHandshake-DTLS", |
| 1516 | config: Config{ |
| 1517 | Bugs: ProtocolBugs{ |
| 1518 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1519 | }, |
| 1520 | }, |
| 1521 | shouldFail: true, |
| 1522 | expectedError: ":UNEXPECTED_RECORD:", |
| 1523 | }, |
| 1524 | { |
| 1525 | protocol: dtls, |
| 1526 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1527 | config: Config{ |
| 1528 | Bugs: ProtocolBugs{ |
| 1529 | AppDataBeforeHandshake: []byte{}, |
| 1530 | }, |
| 1531 | }, |
| 1532 | shouldFail: true, |
| 1533 | expectedError: ":UNEXPECTED_RECORD:", |
| 1534 | }, |
| 1535 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1536 | name: "AppDataAfterChangeCipherSpec", |
| 1537 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1538 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1539 | Bugs: ProtocolBugs{ |
| 1540 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1541 | }, |
| 1542 | }, |
| 1543 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1544 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1545 | }, |
| 1546 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1547 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1548 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1549 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1550 | Bugs: ProtocolBugs{ |
| 1551 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1552 | }, |
| 1553 | }, |
| 1554 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1555 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1556 | }, |
| 1557 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1558 | protocol: dtls, |
| 1559 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1560 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1561 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1562 | Bugs: ProtocolBugs{ |
| 1563 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1564 | }, |
| 1565 | }, |
| 1566 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1567 | // application data. |
| 1568 | }, |
| 1569 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1570 | protocol: dtls, |
| 1571 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1572 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1573 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1574 | Bugs: ProtocolBugs{ |
| 1575 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1576 | }, |
| 1577 | }, |
| 1578 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1579 | // application data. |
| 1580 | }, |
| 1581 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1582 | name: "AlertAfterChangeCipherSpec", |
| 1583 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1584 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1585 | Bugs: ProtocolBugs{ |
| 1586 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1587 | }, |
| 1588 | }, |
| 1589 | shouldFail: true, |
| 1590 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1591 | }, |
| 1592 | { |
| 1593 | protocol: dtls, |
| 1594 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1595 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1596 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1597 | Bugs: ProtocolBugs{ |
| 1598 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1599 | }, |
| 1600 | }, |
| 1601 | shouldFail: true, |
| 1602 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1603 | }, |
| 1604 | { |
| 1605 | protocol: dtls, |
| 1606 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1607 | config: Config{ |
| 1608 | Bugs: ProtocolBugs{ |
| 1609 | ReorderHandshakeFragments: true, |
| 1610 | // Small enough that every handshake message is |
| 1611 | // fragmented. |
| 1612 | MaxHandshakeRecordLength: 2, |
| 1613 | }, |
| 1614 | }, |
| 1615 | }, |
| 1616 | { |
| 1617 | protocol: dtls, |
| 1618 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1619 | config: Config{ |
| 1620 | Bugs: ProtocolBugs{ |
| 1621 | ReorderHandshakeFragments: true, |
| 1622 | // Large enough that no handshake message is |
| 1623 | // fragmented. |
| 1624 | MaxHandshakeRecordLength: 2048, |
| 1625 | }, |
| 1626 | }, |
| 1627 | }, |
| 1628 | { |
| 1629 | protocol: dtls, |
| 1630 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1631 | config: Config{ |
| 1632 | Bugs: ProtocolBugs{ |
| 1633 | ReorderHandshakeFragments: true, |
| 1634 | MixCompleteMessageWithFragments: true, |
| 1635 | MaxHandshakeRecordLength: 2, |
| 1636 | }, |
| 1637 | }, |
| 1638 | }, |
| 1639 | { |
| 1640 | name: "SendInvalidRecordType", |
| 1641 | config: Config{ |
| 1642 | Bugs: ProtocolBugs{ |
| 1643 | SendInvalidRecordType: true, |
| 1644 | }, |
| 1645 | }, |
| 1646 | shouldFail: true, |
| 1647 | expectedError: ":UNEXPECTED_RECORD:", |
| 1648 | }, |
| 1649 | { |
| 1650 | protocol: dtls, |
| 1651 | name: "SendInvalidRecordType-DTLS", |
| 1652 | config: Config{ |
| 1653 | Bugs: ProtocolBugs{ |
| 1654 | SendInvalidRecordType: true, |
| 1655 | }, |
| 1656 | }, |
| 1657 | shouldFail: true, |
| 1658 | expectedError: ":UNEXPECTED_RECORD:", |
| 1659 | }, |
| 1660 | { |
| 1661 | name: "FalseStart-SkipServerSecondLeg", |
| 1662 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1663 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1664 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1665 | NextProtos: []string{"foo"}, |
| 1666 | Bugs: ProtocolBugs{ |
| 1667 | SkipNewSessionTicket: true, |
| 1668 | SkipChangeCipherSpec: true, |
| 1669 | SkipFinished: true, |
| 1670 | ExpectFalseStart: true, |
| 1671 | }, |
| 1672 | }, |
| 1673 | flags: []string{ |
| 1674 | "-false-start", |
| 1675 | "-handshake-never-done", |
| 1676 | "-advertise-alpn", "\x03foo", |
| 1677 | }, |
| 1678 | shimWritesFirst: true, |
| 1679 | shouldFail: true, |
| 1680 | expectedError: ":UNEXPECTED_RECORD:", |
| 1681 | }, |
| 1682 | { |
| 1683 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1684 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1685 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1686 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1687 | NextProtos: []string{"foo"}, |
| 1688 | Bugs: ProtocolBugs{ |
| 1689 | SkipNewSessionTicket: true, |
| 1690 | SkipChangeCipherSpec: true, |
| 1691 | SkipFinished: true, |
| 1692 | }, |
| 1693 | }, |
| 1694 | flags: []string{ |
| 1695 | "-implicit-handshake", |
| 1696 | "-false-start", |
| 1697 | "-handshake-never-done", |
| 1698 | "-advertise-alpn", "\x03foo", |
| 1699 | }, |
| 1700 | shouldFail: true, |
| 1701 | expectedError: ":UNEXPECTED_RECORD:", |
| 1702 | }, |
| 1703 | { |
| 1704 | testType: serverTest, |
| 1705 | name: "FailEarlyCallback", |
| 1706 | flags: []string{"-fail-early-callback"}, |
| 1707 | shouldFail: true, |
| 1708 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1709 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1710 | }, |
| 1711 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame^] | 1712 | name: "FailCertCallback-Client-TLS12", |
| 1713 | config: Config{ |
| 1714 | MaxVersion: VersionTLS12, |
| 1715 | ClientAuth: RequestClientCert, |
| 1716 | }, |
| 1717 | flags: []string{"-fail-cert-callback"}, |
| 1718 | shouldFail: true, |
| 1719 | expectedError: ":CERT_CB_ERROR:", |
| 1720 | expectedLocalError: "remote error: internal error", |
| 1721 | }, |
| 1722 | { |
| 1723 | testType: serverTest, |
| 1724 | name: "FailCertCallback-Server-TLS12", |
| 1725 | config: Config{ |
| 1726 | MaxVersion: VersionTLS12, |
| 1727 | }, |
| 1728 | flags: []string{"-fail-cert-callback"}, |
| 1729 | shouldFail: true, |
| 1730 | expectedError: ":CERT_CB_ERROR:", |
| 1731 | expectedLocalError: "remote error: internal error", |
| 1732 | }, |
| 1733 | { |
| 1734 | name: "FailCertCallback-Client-TLS13", |
| 1735 | config: Config{ |
| 1736 | MaxVersion: VersionTLS13, |
| 1737 | ClientAuth: RequestClientCert, |
| 1738 | }, |
| 1739 | flags: []string{"-fail-cert-callback"}, |
| 1740 | shouldFail: true, |
| 1741 | expectedError: ":CERT_CB_ERROR:", |
| 1742 | expectedLocalError: "remote error: internal error", |
| 1743 | }, |
| 1744 | { |
| 1745 | testType: serverTest, |
| 1746 | name: "FailCertCallback-Server-TLS13", |
| 1747 | config: Config{ |
| 1748 | MaxVersion: VersionTLS13, |
| 1749 | }, |
| 1750 | flags: []string{"-fail-cert-callback"}, |
| 1751 | shouldFail: true, |
| 1752 | expectedError: ":CERT_CB_ERROR:", |
| 1753 | expectedLocalError: "remote error: internal error", |
| 1754 | }, |
| 1755 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1756 | protocol: dtls, |
| 1757 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1758 | config: Config{ |
| 1759 | Bugs: ProtocolBugs{ |
| 1760 | MaxHandshakeRecordLength: 2, |
| 1761 | FragmentMessageTypeMismatch: true, |
| 1762 | }, |
| 1763 | }, |
| 1764 | shouldFail: true, |
| 1765 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1766 | }, |
| 1767 | { |
| 1768 | protocol: dtls, |
| 1769 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1770 | config: Config{ |
| 1771 | Bugs: ProtocolBugs{ |
| 1772 | MaxHandshakeRecordLength: 2, |
| 1773 | FragmentMessageLengthMismatch: true, |
| 1774 | }, |
| 1775 | }, |
| 1776 | shouldFail: true, |
| 1777 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1778 | }, |
| 1779 | { |
| 1780 | protocol: dtls, |
| 1781 | name: "SplitFragments-Header-DTLS", |
| 1782 | config: Config{ |
| 1783 | Bugs: ProtocolBugs{ |
| 1784 | SplitFragments: 2, |
| 1785 | }, |
| 1786 | }, |
| 1787 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1788 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1789 | }, |
| 1790 | { |
| 1791 | protocol: dtls, |
| 1792 | name: "SplitFragments-Boundary-DTLS", |
| 1793 | config: Config{ |
| 1794 | Bugs: ProtocolBugs{ |
| 1795 | SplitFragments: dtlsRecordHeaderLen, |
| 1796 | }, |
| 1797 | }, |
| 1798 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1799 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1800 | }, |
| 1801 | { |
| 1802 | protocol: dtls, |
| 1803 | name: "SplitFragments-Body-DTLS", |
| 1804 | config: Config{ |
| 1805 | Bugs: ProtocolBugs{ |
| 1806 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1807 | }, |
| 1808 | }, |
| 1809 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1810 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1811 | }, |
| 1812 | { |
| 1813 | protocol: dtls, |
| 1814 | name: "SendEmptyFragments-DTLS", |
| 1815 | config: Config{ |
| 1816 | Bugs: ProtocolBugs{ |
| 1817 | SendEmptyFragments: true, |
| 1818 | }, |
| 1819 | }, |
| 1820 | }, |
| 1821 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1822 | name: "BadFinished-Client", |
| 1823 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1824 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1825 | Bugs: ProtocolBugs{ |
| 1826 | BadFinished: true, |
| 1827 | }, |
| 1828 | }, |
| 1829 | shouldFail: true, |
| 1830 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1831 | }, |
| 1832 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1833 | name: "BadFinished-Client-TLS13", |
| 1834 | config: Config{ |
| 1835 | MaxVersion: VersionTLS13, |
| 1836 | Bugs: ProtocolBugs{ |
| 1837 | BadFinished: true, |
| 1838 | }, |
| 1839 | }, |
| 1840 | shouldFail: true, |
| 1841 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1842 | }, |
| 1843 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1844 | testType: serverTest, |
| 1845 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1846 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1847 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1848 | Bugs: ProtocolBugs{ |
| 1849 | BadFinished: true, |
| 1850 | }, |
| 1851 | }, |
| 1852 | shouldFail: true, |
| 1853 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1854 | }, |
| 1855 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1856 | testType: serverTest, |
| 1857 | name: "BadFinished-Server-TLS13", |
| 1858 | config: Config{ |
| 1859 | MaxVersion: VersionTLS13, |
| 1860 | Bugs: ProtocolBugs{ |
| 1861 | BadFinished: true, |
| 1862 | }, |
| 1863 | }, |
| 1864 | shouldFail: true, |
| 1865 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1866 | }, |
| 1867 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1868 | name: "FalseStart-BadFinished", |
| 1869 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1870 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1871 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1872 | NextProtos: []string{"foo"}, |
| 1873 | Bugs: ProtocolBugs{ |
| 1874 | BadFinished: true, |
| 1875 | ExpectFalseStart: true, |
| 1876 | }, |
| 1877 | }, |
| 1878 | flags: []string{ |
| 1879 | "-false-start", |
| 1880 | "-handshake-never-done", |
| 1881 | "-advertise-alpn", "\x03foo", |
| 1882 | }, |
| 1883 | shimWritesFirst: true, |
| 1884 | shouldFail: true, |
| 1885 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1886 | }, |
| 1887 | { |
| 1888 | name: "NoFalseStart-NoALPN", |
| 1889 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1890 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1891 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1892 | Bugs: ProtocolBugs{ |
| 1893 | ExpectFalseStart: true, |
| 1894 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1895 | }, |
| 1896 | }, |
| 1897 | flags: []string{ |
| 1898 | "-false-start", |
| 1899 | }, |
| 1900 | shimWritesFirst: true, |
| 1901 | shouldFail: true, |
| 1902 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1903 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1904 | }, |
| 1905 | { |
| 1906 | name: "NoFalseStart-NoAEAD", |
| 1907 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1908 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1909 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1910 | NextProtos: []string{"foo"}, |
| 1911 | Bugs: ProtocolBugs{ |
| 1912 | ExpectFalseStart: true, |
| 1913 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1914 | }, |
| 1915 | }, |
| 1916 | flags: []string{ |
| 1917 | "-false-start", |
| 1918 | "-advertise-alpn", "\x03foo", |
| 1919 | }, |
| 1920 | shimWritesFirst: true, |
| 1921 | shouldFail: true, |
| 1922 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1923 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1924 | }, |
| 1925 | { |
| 1926 | name: "NoFalseStart-RSA", |
| 1927 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1928 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1929 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1930 | NextProtos: []string{"foo"}, |
| 1931 | Bugs: ProtocolBugs{ |
| 1932 | ExpectFalseStart: true, |
| 1933 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1934 | }, |
| 1935 | }, |
| 1936 | flags: []string{ |
| 1937 | "-false-start", |
| 1938 | "-advertise-alpn", "\x03foo", |
| 1939 | }, |
| 1940 | shimWritesFirst: true, |
| 1941 | shouldFail: true, |
| 1942 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1943 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1944 | }, |
| 1945 | { |
| 1946 | name: "NoFalseStart-DHE_RSA", |
| 1947 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1948 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1949 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1950 | NextProtos: []string{"foo"}, |
| 1951 | Bugs: ProtocolBugs{ |
| 1952 | ExpectFalseStart: true, |
| 1953 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1954 | }, |
| 1955 | }, |
| 1956 | flags: []string{ |
| 1957 | "-false-start", |
| 1958 | "-advertise-alpn", "\x03foo", |
| 1959 | }, |
| 1960 | shimWritesFirst: true, |
| 1961 | shouldFail: true, |
| 1962 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1963 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1964 | }, |
| 1965 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1966 | protocol: dtls, |
| 1967 | name: "SendSplitAlert-Sync", |
| 1968 | config: Config{ |
| 1969 | Bugs: ProtocolBugs{ |
| 1970 | SendSplitAlert: true, |
| 1971 | }, |
| 1972 | }, |
| 1973 | }, |
| 1974 | { |
| 1975 | protocol: dtls, |
| 1976 | name: "SendSplitAlert-Async", |
| 1977 | config: Config{ |
| 1978 | Bugs: ProtocolBugs{ |
| 1979 | SendSplitAlert: true, |
| 1980 | }, |
| 1981 | }, |
| 1982 | flags: []string{"-async"}, |
| 1983 | }, |
| 1984 | { |
| 1985 | protocol: dtls, |
| 1986 | name: "PackDTLSHandshake", |
| 1987 | config: Config{ |
| 1988 | Bugs: ProtocolBugs{ |
| 1989 | MaxHandshakeRecordLength: 2, |
| 1990 | PackHandshakeFragments: 20, |
| 1991 | PackHandshakeRecords: 200, |
| 1992 | }, |
| 1993 | }, |
| 1994 | }, |
| 1995 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1996 | name: "SendEmptyRecords-Pass", |
| 1997 | sendEmptyRecords: 32, |
| 1998 | }, |
| 1999 | { |
| 2000 | name: "SendEmptyRecords", |
| 2001 | sendEmptyRecords: 33, |
| 2002 | shouldFail: true, |
| 2003 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2004 | }, |
| 2005 | { |
| 2006 | name: "SendEmptyRecords-Async", |
| 2007 | sendEmptyRecords: 33, |
| 2008 | flags: []string{"-async"}, |
| 2009 | shouldFail: true, |
| 2010 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2011 | }, |
| 2012 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2013 | name: "SendWarningAlerts-Pass", |
| 2014 | config: Config{ |
| 2015 | MaxVersion: VersionTLS12, |
| 2016 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2017 | sendWarningAlerts: 4, |
| 2018 | }, |
| 2019 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2020 | protocol: dtls, |
| 2021 | name: "SendWarningAlerts-DTLS-Pass", |
| 2022 | config: Config{ |
| 2023 | MaxVersion: VersionTLS12, |
| 2024 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2025 | sendWarningAlerts: 4, |
| 2026 | }, |
| 2027 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2028 | name: "SendWarningAlerts-TLS13", |
| 2029 | config: Config{ |
| 2030 | MaxVersion: VersionTLS13, |
| 2031 | }, |
| 2032 | sendWarningAlerts: 4, |
| 2033 | shouldFail: true, |
| 2034 | expectedError: ":BAD_ALERT:", |
| 2035 | expectedLocalError: "remote error: error decoding message", |
| 2036 | }, |
| 2037 | { |
| 2038 | name: "SendWarningAlerts", |
| 2039 | config: Config{ |
| 2040 | MaxVersion: VersionTLS12, |
| 2041 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2042 | sendWarningAlerts: 5, |
| 2043 | shouldFail: true, |
| 2044 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2045 | }, |
| 2046 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2047 | name: "SendWarningAlerts-Async", |
| 2048 | config: Config{ |
| 2049 | MaxVersion: VersionTLS12, |
| 2050 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2051 | sendWarningAlerts: 5, |
| 2052 | flags: []string{"-async"}, |
| 2053 | shouldFail: true, |
| 2054 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2055 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2056 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2057 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2058 | config: Config{ |
| 2059 | MaxVersion: VersionTLS13, |
| 2060 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2061 | sendKeyUpdates: 33, |
| 2062 | keyUpdateRequest: keyUpdateNotRequested, |
| 2063 | shouldFail: true, |
| 2064 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2065 | }, |
| 2066 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2067 | name: "EmptySessionID", |
| 2068 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2069 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2070 | SessionTicketsDisabled: true, |
| 2071 | }, |
| 2072 | noSessionCache: true, |
| 2073 | flags: []string{"-expect-no-session"}, |
| 2074 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2075 | { |
| 2076 | name: "Unclean-Shutdown", |
| 2077 | config: Config{ |
| 2078 | Bugs: ProtocolBugs{ |
| 2079 | NoCloseNotify: true, |
| 2080 | ExpectCloseNotify: true, |
| 2081 | }, |
| 2082 | }, |
| 2083 | shimShutsDown: true, |
| 2084 | flags: []string{"-check-close-notify"}, |
| 2085 | shouldFail: true, |
| 2086 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2087 | }, |
| 2088 | { |
| 2089 | name: "Unclean-Shutdown-Ignored", |
| 2090 | config: Config{ |
| 2091 | Bugs: ProtocolBugs{ |
| 2092 | NoCloseNotify: true, |
| 2093 | }, |
| 2094 | }, |
| 2095 | shimShutsDown: true, |
| 2096 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2097 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2098 | name: "Unclean-Shutdown-Alert", |
| 2099 | config: Config{ |
| 2100 | Bugs: ProtocolBugs{ |
| 2101 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2102 | ExpectCloseNotify: true, |
| 2103 | }, |
| 2104 | }, |
| 2105 | shimShutsDown: true, |
| 2106 | flags: []string{"-check-close-notify"}, |
| 2107 | shouldFail: true, |
| 2108 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2109 | }, |
| 2110 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2111 | name: "LargePlaintext", |
| 2112 | config: Config{ |
| 2113 | Bugs: ProtocolBugs{ |
| 2114 | SendLargeRecords: true, |
| 2115 | }, |
| 2116 | }, |
| 2117 | messageLen: maxPlaintext + 1, |
| 2118 | shouldFail: true, |
| 2119 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2120 | }, |
| 2121 | { |
| 2122 | protocol: dtls, |
| 2123 | name: "LargePlaintext-DTLS", |
| 2124 | config: Config{ |
| 2125 | Bugs: ProtocolBugs{ |
| 2126 | SendLargeRecords: true, |
| 2127 | }, |
| 2128 | }, |
| 2129 | messageLen: maxPlaintext + 1, |
| 2130 | shouldFail: true, |
| 2131 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2132 | }, |
| 2133 | { |
| 2134 | name: "LargeCiphertext", |
| 2135 | config: Config{ |
| 2136 | Bugs: ProtocolBugs{ |
| 2137 | SendLargeRecords: true, |
| 2138 | }, |
| 2139 | }, |
| 2140 | messageLen: maxPlaintext * 2, |
| 2141 | shouldFail: true, |
| 2142 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2143 | }, |
| 2144 | { |
| 2145 | protocol: dtls, |
| 2146 | name: "LargeCiphertext-DTLS", |
| 2147 | config: Config{ |
| 2148 | Bugs: ProtocolBugs{ |
| 2149 | SendLargeRecords: true, |
| 2150 | }, |
| 2151 | }, |
| 2152 | messageLen: maxPlaintext * 2, |
| 2153 | // Unlike the other four cases, DTLS drops records which |
| 2154 | // are invalid before authentication, so the connection |
| 2155 | // does not fail. |
| 2156 | expectMessageDropped: true, |
| 2157 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2158 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2159 | name: "BadHelloRequest-1", |
| 2160 | renegotiate: 1, |
| 2161 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2162 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2163 | Bugs: ProtocolBugs{ |
| 2164 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2165 | }, |
| 2166 | }, |
| 2167 | flags: []string{ |
| 2168 | "-renegotiate-freely", |
| 2169 | "-expect-total-renegotiations", "1", |
| 2170 | }, |
| 2171 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2172 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2173 | }, |
| 2174 | { |
| 2175 | name: "BadHelloRequest-2", |
| 2176 | renegotiate: 1, |
| 2177 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2178 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2179 | Bugs: ProtocolBugs{ |
| 2180 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2181 | }, |
| 2182 | }, |
| 2183 | flags: []string{ |
| 2184 | "-renegotiate-freely", |
| 2185 | "-expect-total-renegotiations", "1", |
| 2186 | }, |
| 2187 | shouldFail: true, |
| 2188 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2189 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2190 | { |
| 2191 | testType: serverTest, |
| 2192 | name: "SupportTicketsWithSessionID", |
| 2193 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2194 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2195 | SessionTicketsDisabled: true, |
| 2196 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2197 | resumeConfig: &Config{ |
| 2198 | MaxVersion: VersionTLS12, |
| 2199 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2200 | resumeSession: true, |
| 2201 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2202 | { |
| 2203 | protocol: dtls, |
| 2204 | name: "DTLS-SendExtraFinished", |
| 2205 | config: Config{ |
| 2206 | Bugs: ProtocolBugs{ |
| 2207 | SendExtraFinished: true, |
| 2208 | }, |
| 2209 | }, |
| 2210 | shouldFail: true, |
| 2211 | expectedError: ":UNEXPECTED_RECORD:", |
| 2212 | }, |
| 2213 | { |
| 2214 | protocol: dtls, |
| 2215 | name: "DTLS-SendExtraFinished-Reordered", |
| 2216 | config: Config{ |
| 2217 | Bugs: ProtocolBugs{ |
| 2218 | MaxHandshakeRecordLength: 2, |
| 2219 | ReorderHandshakeFragments: true, |
| 2220 | SendExtraFinished: true, |
| 2221 | }, |
| 2222 | }, |
| 2223 | shouldFail: true, |
| 2224 | expectedError: ":UNEXPECTED_RECORD:", |
| 2225 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2226 | { |
| 2227 | testType: serverTest, |
| 2228 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2229 | config: Config{ |
| 2230 | // Choose a cipher suite that does not involve |
| 2231 | // elliptic curves, so no extensions are |
| 2232 | // involved. |
| 2233 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2234 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2235 | Bugs: ProtocolBugs{ |
| 2236 | SendV2ClientHello: true, |
| 2237 | }, |
| 2238 | }, |
| 2239 | sendPrefix: string([]byte{ |
| 2240 | byte(recordTypeHandshake), |
| 2241 | 3, 1, // version |
| 2242 | 0, 0, // length |
| 2243 | }), |
| 2244 | // A no-op empty record may not be sent before V2ClientHello. |
| 2245 | shouldFail: true, |
| 2246 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2247 | }, |
| 2248 | { |
| 2249 | testType: serverTest, |
| 2250 | name: "V2ClientHello-WarningAlertPrefix", |
| 2251 | config: Config{ |
| 2252 | // Choose a cipher suite that does not involve |
| 2253 | // elliptic curves, so no extensions are |
| 2254 | // involved. |
| 2255 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2256 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2257 | Bugs: ProtocolBugs{ |
| 2258 | SendV2ClientHello: true, |
| 2259 | }, |
| 2260 | }, |
| 2261 | sendPrefix: string([]byte{ |
| 2262 | byte(recordTypeAlert), |
| 2263 | 3, 1, // version |
| 2264 | 0, 2, // length |
| 2265 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2266 | }), |
| 2267 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2268 | shouldFail: true, |
| 2269 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2270 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2271 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2272 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2273 | config: Config{ |
| 2274 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2275 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2276 | sendKeyUpdates: 1, |
| 2277 | keyUpdateRequest: keyUpdateNotRequested, |
| 2278 | }, |
| 2279 | { |
| 2280 | name: "KeyUpdate-InvalidRequestMode", |
| 2281 | config: Config{ |
| 2282 | MaxVersion: VersionTLS13, |
| 2283 | }, |
| 2284 | sendKeyUpdates: 1, |
| 2285 | keyUpdateRequest: 42, |
| 2286 | shouldFail: true, |
| 2287 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2288 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2289 | { |
| 2290 | name: "SendSNIWarningAlert", |
| 2291 | config: Config{ |
| 2292 | MaxVersion: VersionTLS12, |
| 2293 | Bugs: ProtocolBugs{ |
| 2294 | SendSNIWarningAlert: true, |
| 2295 | }, |
| 2296 | }, |
| 2297 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2298 | { |
| 2299 | testType: serverTest, |
| 2300 | name: "ExtraCompressionMethods-TLS12", |
| 2301 | config: Config{ |
| 2302 | MaxVersion: VersionTLS12, |
| 2303 | Bugs: ProtocolBugs{ |
| 2304 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2305 | }, |
| 2306 | }, |
| 2307 | }, |
| 2308 | { |
| 2309 | testType: serverTest, |
| 2310 | name: "ExtraCompressionMethods-TLS13", |
| 2311 | config: Config{ |
| 2312 | MaxVersion: VersionTLS13, |
| 2313 | Bugs: ProtocolBugs{ |
| 2314 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2315 | }, |
| 2316 | }, |
| 2317 | shouldFail: true, |
| 2318 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2319 | expectedLocalError: "remote error: illegal parameter", |
| 2320 | }, |
| 2321 | { |
| 2322 | testType: serverTest, |
| 2323 | name: "NoNullCompression-TLS12", |
| 2324 | config: Config{ |
| 2325 | MaxVersion: VersionTLS12, |
| 2326 | Bugs: ProtocolBugs{ |
| 2327 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2328 | }, |
| 2329 | }, |
| 2330 | shouldFail: true, |
| 2331 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2332 | expectedLocalError: "remote error: illegal parameter", |
| 2333 | }, |
| 2334 | { |
| 2335 | testType: serverTest, |
| 2336 | name: "NoNullCompression-TLS13", |
| 2337 | config: Config{ |
| 2338 | MaxVersion: VersionTLS13, |
| 2339 | Bugs: ProtocolBugs{ |
| 2340 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2341 | }, |
| 2342 | }, |
| 2343 | shouldFail: true, |
| 2344 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2345 | expectedLocalError: "remote error: illegal parameter", |
| 2346 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2347 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2348 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2349 | config: Config{ |
| 2350 | MaxVersion: VersionTLS12, |
| 2351 | Bugs: ProtocolBugs{ |
| 2352 | ExpectGREASE: true, |
| 2353 | }, |
| 2354 | }, |
| 2355 | flags: []string{"-enable-grease"}, |
| 2356 | }, |
| 2357 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2358 | name: "GREASE-Client-TLS13", |
| 2359 | config: Config{ |
| 2360 | MaxVersion: VersionTLS13, |
| 2361 | Bugs: ProtocolBugs{ |
| 2362 | ExpectGREASE: true, |
| 2363 | }, |
| 2364 | }, |
| 2365 | flags: []string{"-enable-grease"}, |
| 2366 | }, |
| 2367 | { |
| 2368 | testType: serverTest, |
| 2369 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2370 | config: Config{ |
| 2371 | MaxVersion: VersionTLS13, |
| 2372 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2373 | // TLS 1.3 servers are expected to |
| 2374 | // always enable GREASE. TLS 1.3 is new, |
| 2375 | // so there is no existing ecosystem to |
| 2376 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2377 | ExpectGREASE: true, |
| 2378 | }, |
| 2379 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2380 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2381 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2382 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2383 | |
| 2384 | // Test that very large messages can be received. |
| 2385 | cert := rsaCertificate |
| 2386 | for i := 0; i < 50; i++ { |
| 2387 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2388 | } |
| 2389 | testCases = append(testCases, testCase{ |
| 2390 | name: "LargeMessage", |
| 2391 | config: Config{ |
| 2392 | Certificates: []Certificate{cert}, |
| 2393 | }, |
| 2394 | }) |
| 2395 | testCases = append(testCases, testCase{ |
| 2396 | protocol: dtls, |
| 2397 | name: "LargeMessage-DTLS", |
| 2398 | config: Config{ |
| 2399 | Certificates: []Certificate{cert}, |
| 2400 | }, |
| 2401 | }) |
| 2402 | |
| 2403 | // They are rejected if the maximum certificate chain length is capped. |
| 2404 | testCases = append(testCases, testCase{ |
| 2405 | name: "LargeMessage-Reject", |
| 2406 | config: Config{ |
| 2407 | Certificates: []Certificate{cert}, |
| 2408 | }, |
| 2409 | flags: []string{"-max-cert-list", "16384"}, |
| 2410 | shouldFail: true, |
| 2411 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2412 | }) |
| 2413 | testCases = append(testCases, testCase{ |
| 2414 | protocol: dtls, |
| 2415 | name: "LargeMessage-Reject-DTLS", |
| 2416 | config: Config{ |
| 2417 | Certificates: []Certificate{cert}, |
| 2418 | }, |
| 2419 | flags: []string{"-max-cert-list", "16384"}, |
| 2420 | shouldFail: true, |
| 2421 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2422 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2423 | } |
| 2424 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2425 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2426 | const bogusCipher = 0xfe00 |
| 2427 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2428 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2429 | const psk = "12345" |
| 2430 | const pskIdentity = "luggage combo" |
| 2431 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2432 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2433 | var certFile string |
| 2434 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2435 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2436 | cert = ecdsaP256Certificate |
| 2437 | certFile = ecdsaP256CertificateFile |
| 2438 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2439 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2440 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2441 | certFile = rsaCertificateFile |
| 2442 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2443 | } |
| 2444 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2445 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2446 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2447 | flags = append(flags, |
| 2448 | "-psk", psk, |
| 2449 | "-psk-identity", pskIdentity) |
| 2450 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2451 | if hasComponent(suite.name, "NULL") { |
| 2452 | // NULL ciphers must be explicitly enabled. |
| 2453 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2454 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2455 | if hasComponent(suite.name, "CECPQ1") { |
| 2456 | // CECPQ1 ciphers must be explicitly enabled. |
| 2457 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2458 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2459 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2460 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2461 | // for now. |
| 2462 | flags = append(flags, "-cipher", suite.name) |
| 2463 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2464 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2465 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2466 | for _, protocol := range []protocol{tls, dtls} { |
| 2467 | var prefix string |
| 2468 | if protocol == dtls { |
| 2469 | if !ver.hasDTLS { |
| 2470 | continue |
| 2471 | } |
| 2472 | prefix = "D" |
| 2473 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2474 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2475 | var shouldServerFail, shouldClientFail bool |
| 2476 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2477 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2478 | // a BoringSSL server will never select it |
| 2479 | // because the extension is missing. |
| 2480 | shouldServerFail = true |
| 2481 | } |
| 2482 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2483 | shouldClientFail = true |
| 2484 | shouldServerFail = true |
| 2485 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2486 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2487 | shouldClientFail = true |
| 2488 | shouldServerFail = true |
| 2489 | } |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2490 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2491 | shouldClientFail = true |
| 2492 | shouldServerFail = true |
| 2493 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2494 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2495 | shouldClientFail = true |
| 2496 | shouldServerFail = true |
| 2497 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2498 | |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2499 | var sendCipherSuite uint16 |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2500 | var expectedServerError, expectedClientError string |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2501 | serverCipherSuites := []uint16{suite.id} |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2502 | if shouldServerFail { |
| 2503 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2504 | } |
| 2505 | if shouldClientFail { |
| 2506 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2507 | // Configure the server to select ciphers as normal but |
| 2508 | // select an incompatible cipher in ServerHello. |
| 2509 | serverCipherSuites = nil |
| 2510 | sendCipherSuite = suite.id |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2511 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2512 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2513 | testCases = append(testCases, testCase{ |
| 2514 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2515 | protocol: protocol, |
| 2516 | |
| 2517 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2518 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2519 | MinVersion: ver.version, |
| 2520 | MaxVersion: ver.version, |
| 2521 | CipherSuites: []uint16{suite.id}, |
| 2522 | Certificates: []Certificate{cert}, |
| 2523 | PreSharedKey: []byte(psk), |
| 2524 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2525 | Bugs: ProtocolBugs{ |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2526 | AdvertiseAllConfiguredCiphers: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2527 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2528 | }, |
| 2529 | certFile: certFile, |
| 2530 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2531 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2532 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2533 | shouldFail: shouldServerFail, |
| 2534 | expectedError: expectedServerError, |
| 2535 | }) |
| 2536 | |
| 2537 | testCases = append(testCases, testCase{ |
| 2538 | testType: clientTest, |
| 2539 | protocol: protocol, |
| 2540 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2541 | config: Config{ |
| 2542 | MinVersion: ver.version, |
| 2543 | MaxVersion: ver.version, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2544 | CipherSuites: serverCipherSuites, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2545 | Certificates: []Certificate{cert}, |
| 2546 | PreSharedKey: []byte(psk), |
| 2547 | PreSharedKeyIdentity: pskIdentity, |
| 2548 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2549 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2550 | SendCipherSuite: sendCipherSuite, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2551 | }, |
| 2552 | }, |
| 2553 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2554 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2555 | shouldFail: shouldClientFail, |
| 2556 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2557 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2558 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2559 | if !shouldClientFail { |
| 2560 | // Ensure the maximum record size is accepted. |
| 2561 | testCases = append(testCases, testCase{ |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2562 | protocol: protocol, |
| 2563 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2564 | config: Config{ |
| 2565 | MinVersion: ver.version, |
| 2566 | MaxVersion: ver.version, |
| 2567 | CipherSuites: []uint16{suite.id}, |
| 2568 | Certificates: []Certificate{cert}, |
| 2569 | PreSharedKey: []byte(psk), |
| 2570 | PreSharedKeyIdentity: pskIdentity, |
| 2571 | }, |
| 2572 | flags: flags, |
| 2573 | messageLen: maxPlaintext, |
| 2574 | }) |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2575 | |
| 2576 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2577 | // and ignored in DTLS. |
| 2578 | var shouldFail bool |
| 2579 | var expectedError string |
| 2580 | if protocol == tls { |
| 2581 | shouldFail = true |
| 2582 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2583 | } |
| 2584 | |
| 2585 | testCases = append(testCases, testCase{ |
| 2586 | protocol: protocol, |
| 2587 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2588 | config: Config{ |
| 2589 | MinVersion: ver.version, |
| 2590 | MaxVersion: ver.version, |
| 2591 | CipherSuites: []uint16{suite.id}, |
| 2592 | Certificates: []Certificate{cert}, |
| 2593 | PreSharedKey: []byte(psk), |
| 2594 | PreSharedKeyIdentity: pskIdentity, |
| 2595 | }, |
| 2596 | flags: flags, |
| 2597 | damageFirstWrite: true, |
| 2598 | messageLen: maxPlaintext, |
| 2599 | shouldFail: shouldFail, |
| 2600 | expectedError: expectedError, |
| 2601 | }) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2602 | } |
| 2603 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2604 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2605 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2606 | |
| 2607 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2608 | name: "NoSharedCipher", |
| 2609 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2610 | MaxVersion: VersionTLS12, |
| 2611 | CipherSuites: []uint16{}, |
| 2612 | }, |
| 2613 | shouldFail: true, |
| 2614 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2615 | }) |
| 2616 | |
| 2617 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2618 | name: "NoSharedCipher-TLS13", |
| 2619 | config: Config{ |
| 2620 | MaxVersion: VersionTLS13, |
| 2621 | CipherSuites: []uint16{}, |
| 2622 | }, |
| 2623 | shouldFail: true, |
| 2624 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2625 | }) |
| 2626 | |
| 2627 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2628 | name: "UnsupportedCipherSuite", |
| 2629 | config: Config{ |
| 2630 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2631 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2632 | Bugs: ProtocolBugs{ |
| 2633 | IgnorePeerCipherPreferences: true, |
| 2634 | }, |
| 2635 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2636 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2637 | shouldFail: true, |
| 2638 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2639 | }) |
| 2640 | |
| 2641 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2642 | name: "ServerHelloBogusCipher", |
| 2643 | config: Config{ |
| 2644 | MaxVersion: VersionTLS12, |
| 2645 | Bugs: ProtocolBugs{ |
| 2646 | SendCipherSuite: bogusCipher, |
| 2647 | }, |
| 2648 | }, |
| 2649 | shouldFail: true, |
| 2650 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2651 | }) |
| 2652 | testCases = append(testCases, testCase{ |
| 2653 | name: "ServerHelloBogusCipher-TLS13", |
| 2654 | config: Config{ |
| 2655 | MaxVersion: VersionTLS13, |
| 2656 | Bugs: ProtocolBugs{ |
| 2657 | SendCipherSuite: bogusCipher, |
| 2658 | }, |
| 2659 | }, |
| 2660 | shouldFail: true, |
| 2661 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2662 | }) |
| 2663 | |
| 2664 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2665 | name: "WeakDH", |
| 2666 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2667 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2668 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2669 | Bugs: ProtocolBugs{ |
| 2670 | // This is a 1023-bit prime number, generated |
| 2671 | // with: |
| 2672 | // openssl gendh 1023 | openssl asn1parse -i |
| 2673 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2674 | }, |
| 2675 | }, |
| 2676 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2677 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2678 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2679 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2680 | testCases = append(testCases, testCase{ |
| 2681 | name: "SillyDH", |
| 2682 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2683 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2684 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2685 | Bugs: ProtocolBugs{ |
| 2686 | // This is a 4097-bit prime number, generated |
| 2687 | // with: |
| 2688 | // openssl gendh 4097 | openssl asn1parse -i |
| 2689 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2690 | }, |
| 2691 | }, |
| 2692 | shouldFail: true, |
| 2693 | expectedError: ":DH_P_TOO_LONG:", |
| 2694 | }) |
| 2695 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2696 | // This test ensures that Diffie-Hellman public values are padded with |
| 2697 | // zeros so that they're the same length as the prime. This is to avoid |
| 2698 | // hitting a bug in yaSSL. |
| 2699 | testCases = append(testCases, testCase{ |
| 2700 | testType: serverTest, |
| 2701 | name: "DHPublicValuePadded", |
| 2702 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2703 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2704 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2705 | Bugs: ProtocolBugs{ |
| 2706 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2707 | }, |
| 2708 | }, |
| 2709 | flags: []string{"-use-sparse-dh-prime"}, |
| 2710 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2711 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2712 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2713 | testCases = append(testCases, testCase{ |
| 2714 | testType: serverTest, |
| 2715 | name: "UnknownCipher", |
| 2716 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2717 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2718 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2719 | Bugs: ProtocolBugs{ |
| 2720 | AdvertiseAllConfiguredCiphers: true, |
| 2721 | }, |
| 2722 | }, |
| 2723 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2724 | |
| 2725 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2726 | testCases = append(testCases, testCase{ |
| 2727 | testType: serverTest, |
| 2728 | name: "UnknownCipher-TLS13", |
| 2729 | config: Config{ |
| 2730 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2731 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2732 | Bugs: ProtocolBugs{ |
| 2733 | AdvertiseAllConfiguredCiphers: true, |
| 2734 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2735 | }, |
| 2736 | }) |
| 2737 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2738 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2739 | testCases = append(testCases, testCase{ |
| 2740 | name: "EmptyECDHEPSKHint", |
| 2741 | config: Config{ |
| 2742 | MaxVersion: VersionTLS12, |
| 2743 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2744 | PreSharedKey: []byte("secret"), |
| 2745 | }, |
| 2746 | flags: []string{"-psk", "secret"}, |
| 2747 | }) |
| 2748 | |
| 2749 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2750 | // ServerKeyExchange is sent. |
| 2751 | testCases = append(testCases, testCase{ |
| 2752 | name: "ExplicitEmptyPSKHint", |
| 2753 | config: Config{ |
| 2754 | MaxVersion: VersionTLS12, |
| 2755 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2756 | PreSharedKey: []byte("secret"), |
| 2757 | Bugs: ProtocolBugs{ |
| 2758 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2759 | }, |
| 2760 | }, |
| 2761 | flags: []string{"-psk", "secret"}, |
| 2762 | }) |
| 2763 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2764 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2765 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2766 | // cipher lists and then a connection is made for each member of |
| 2767 | // expectations. The cipher suite that the server selects must match |
| 2768 | // the specified one. |
| 2769 | var versionSpecificCiphersTest = []struct { |
| 2770 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2771 | // expectations is a map from TLS version to cipher suite id. |
| 2772 | expectations map[uint16]uint16 |
| 2773 | }{ |
| 2774 | { |
| 2775 | // Test that the null case (where no version-specific ciphers are set) |
| 2776 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2777 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2778 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2779 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2780 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2781 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2782 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2783 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2784 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2785 | }, |
| 2786 | }, |
| 2787 | { |
| 2788 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2789 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2790 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2791 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2792 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2793 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2794 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2795 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2796 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2797 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2798 | }, |
| 2799 | }, |
| 2800 | { |
| 2801 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2802 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2803 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2804 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2805 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2806 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2807 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2808 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2809 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2810 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2811 | }, |
| 2812 | }, |
| 2813 | { |
| 2814 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2815 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2816 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2817 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2818 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2819 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2820 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2821 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2822 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2823 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2824 | }, |
| 2825 | }, |
| 2826 | } |
| 2827 | |
| 2828 | for i, test := range versionSpecificCiphersTest { |
| 2829 | for version, expectedCipherSuite := range test.expectations { |
| 2830 | flags := []string{"-cipher", test.ciphersDefault} |
| 2831 | if len(test.ciphersTLS10) > 0 { |
| 2832 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2833 | } |
| 2834 | if len(test.ciphersTLS11) > 0 { |
| 2835 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2836 | } |
| 2837 | |
| 2838 | testCases = append(testCases, testCase{ |
| 2839 | testType: serverTest, |
| 2840 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2841 | config: Config{ |
| 2842 | MaxVersion: version, |
| 2843 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2844 | 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] | 2845 | }, |
| 2846 | flags: flags, |
| 2847 | expectedCipher: expectedCipherSuite, |
| 2848 | }) |
| 2849 | } |
| 2850 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2851 | } |
| 2852 | |
| 2853 | func addBadECDSASignatureTests() { |
| 2854 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2855 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2856 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2857 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2858 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2859 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2860 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2861 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2862 | Bugs: ProtocolBugs{ |
| 2863 | BadECDSAR: badR, |
| 2864 | BadECDSAS: badS, |
| 2865 | }, |
| 2866 | }, |
| 2867 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2868 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2869 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2870 | testCases = append(testCases, testCase{ |
| 2871 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2872 | config: Config{ |
| 2873 | MaxVersion: VersionTLS13, |
| 2874 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2875 | Bugs: ProtocolBugs{ |
| 2876 | BadECDSAR: badR, |
| 2877 | BadECDSAS: badS, |
| 2878 | }, |
| 2879 | }, |
| 2880 | shouldFail: true, |
| 2881 | expectedError: ":BAD_SIGNATURE:", |
| 2882 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2883 | } |
| 2884 | } |
| 2885 | } |
| 2886 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2887 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2888 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2889 | name: "MaxCBCPadding", |
| 2890 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2891 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2892 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2893 | Bugs: ProtocolBugs{ |
| 2894 | MaxPadding: true, |
| 2895 | }, |
| 2896 | }, |
| 2897 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2898 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2899 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2900 | name: "BadCBCPadding", |
| 2901 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2902 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2903 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2904 | Bugs: ProtocolBugs{ |
| 2905 | PaddingFirstByteBad: true, |
| 2906 | }, |
| 2907 | }, |
| 2908 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2909 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2910 | }) |
| 2911 | // OpenSSL previously had an issue where the first byte of padding in |
| 2912 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2913 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2914 | name: "BadCBCPadding255", |
| 2915 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2916 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2917 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2918 | Bugs: ProtocolBugs{ |
| 2919 | MaxPadding: true, |
| 2920 | PaddingFirstByteBadIf255: true, |
| 2921 | }, |
| 2922 | }, |
| 2923 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2924 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2925 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2926 | }) |
| 2927 | } |
| 2928 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2929 | func addCBCSplittingTests() { |
| 2930 | testCases = append(testCases, testCase{ |
| 2931 | name: "CBCRecordSplitting", |
| 2932 | config: Config{ |
| 2933 | MaxVersion: VersionTLS10, |
| 2934 | MinVersion: VersionTLS10, |
| 2935 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2936 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2937 | messageLen: -1, // read until EOF |
| 2938 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2939 | flags: []string{ |
| 2940 | "-async", |
| 2941 | "-write-different-record-sizes", |
| 2942 | "-cbc-record-splitting", |
| 2943 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2944 | }) |
| 2945 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2946 | name: "CBCRecordSplittingPartialWrite", |
| 2947 | config: Config{ |
| 2948 | MaxVersion: VersionTLS10, |
| 2949 | MinVersion: VersionTLS10, |
| 2950 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2951 | }, |
| 2952 | messageLen: -1, // read until EOF |
| 2953 | flags: []string{ |
| 2954 | "-async", |
| 2955 | "-write-different-record-sizes", |
| 2956 | "-cbc-record-splitting", |
| 2957 | "-partial-write", |
| 2958 | }, |
| 2959 | }) |
| 2960 | } |
| 2961 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2962 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2963 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2964 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2965 | certPool := x509.NewCertPool() |
| 2966 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2967 | if err != nil { |
| 2968 | panic(err) |
| 2969 | } |
| 2970 | certPool.AddCert(cert) |
| 2971 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2972 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2973 | testCases = append(testCases, testCase{ |
| 2974 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2975 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2976 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2977 | MinVersion: ver.version, |
| 2978 | MaxVersion: ver.version, |
| 2979 | ClientAuth: RequireAnyClientCert, |
| 2980 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2981 | }, |
| 2982 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2983 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2984 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2985 | }, |
| 2986 | }) |
| 2987 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2988 | testType: serverTest, |
| 2989 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2990 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2991 | MinVersion: ver.version, |
| 2992 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2993 | Certificates: []Certificate{rsaCertificate}, |
| 2994 | }, |
| 2995 | flags: []string{"-require-any-client-certificate"}, |
| 2996 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2997 | if ver.version != VersionSSL30 { |
| 2998 | testCases = append(testCases, testCase{ |
| 2999 | testType: serverTest, |
| 3000 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3001 | config: Config{ |
| 3002 | MinVersion: ver.version, |
| 3003 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3004 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3005 | }, |
| 3006 | flags: []string{"-require-any-client-certificate"}, |
| 3007 | }) |
| 3008 | testCases = append(testCases, testCase{ |
| 3009 | testType: clientTest, |
| 3010 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3011 | config: Config{ |
| 3012 | MinVersion: ver.version, |
| 3013 | MaxVersion: ver.version, |
| 3014 | ClientAuth: RequireAnyClientCert, |
| 3015 | ClientCAs: certPool, |
| 3016 | }, |
| 3017 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3018 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3019 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3020 | }, |
| 3021 | }) |
| 3022 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3023 | |
| 3024 | testCases = append(testCases, testCase{ |
| 3025 | name: "NoClientCertificate-" + ver.name, |
| 3026 | config: Config{ |
| 3027 | MinVersion: ver.version, |
| 3028 | MaxVersion: ver.version, |
| 3029 | ClientAuth: RequireAnyClientCert, |
| 3030 | }, |
| 3031 | shouldFail: true, |
| 3032 | expectedLocalError: "client didn't provide a certificate", |
| 3033 | }) |
| 3034 | |
| 3035 | testCases = append(testCases, testCase{ |
| 3036 | // Even if not configured to expect a certificate, OpenSSL will |
| 3037 | // return X509_V_OK as the verify_result. |
| 3038 | testType: serverTest, |
| 3039 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3040 | config: Config{ |
| 3041 | MinVersion: ver.version, |
| 3042 | MaxVersion: ver.version, |
| 3043 | }, |
| 3044 | flags: []string{ |
| 3045 | "-expect-verify-result", |
| 3046 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3047 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3048 | }) |
| 3049 | |
| 3050 | testCases = append(testCases, testCase{ |
| 3051 | // If a client certificate is not provided, OpenSSL will still |
| 3052 | // return X509_V_OK as the verify_result. |
| 3053 | testType: serverTest, |
| 3054 | name: "NoClientCertificate-Server-" + ver.name, |
| 3055 | config: Config{ |
| 3056 | MinVersion: ver.version, |
| 3057 | MaxVersion: ver.version, |
| 3058 | }, |
| 3059 | flags: []string{ |
| 3060 | "-expect-verify-result", |
| 3061 | "-verify-peer", |
| 3062 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3063 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3064 | }) |
| 3065 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3066 | certificateRequired := "remote error: certificate required" |
| 3067 | if ver.version < VersionTLS13 { |
| 3068 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3069 | // was used. |
| 3070 | certificateRequired = "remote error: handshake failure" |
| 3071 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3072 | testCases = append(testCases, testCase{ |
| 3073 | testType: serverTest, |
| 3074 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3075 | config: Config{ |
| 3076 | MinVersion: ver.version, |
| 3077 | MaxVersion: ver.version, |
| 3078 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3079 | flags: []string{"-require-any-client-certificate"}, |
| 3080 | shouldFail: true, |
| 3081 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3082 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3083 | }) |
| 3084 | |
| 3085 | if ver.version != VersionSSL30 { |
| 3086 | testCases = append(testCases, testCase{ |
| 3087 | testType: serverTest, |
| 3088 | name: "SkipClientCertificate-" + ver.name, |
| 3089 | config: Config{ |
| 3090 | MinVersion: ver.version, |
| 3091 | MaxVersion: ver.version, |
| 3092 | Bugs: ProtocolBugs{ |
| 3093 | SkipClientCertificate: true, |
| 3094 | }, |
| 3095 | }, |
| 3096 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3097 | flags: []string{"-verify-peer"}, |
| 3098 | shouldFail: true, |
| 3099 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3100 | }) |
| 3101 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3102 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3103 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3104 | // Client auth is only legal in certificate-based ciphers. |
| 3105 | testCases = append(testCases, testCase{ |
| 3106 | testType: clientTest, |
| 3107 | name: "ClientAuth-PSK", |
| 3108 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3109 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3110 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3111 | PreSharedKey: []byte("secret"), |
| 3112 | ClientAuth: RequireAnyClientCert, |
| 3113 | }, |
| 3114 | flags: []string{ |
| 3115 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3116 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3117 | "-psk", "secret", |
| 3118 | }, |
| 3119 | shouldFail: true, |
| 3120 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3121 | }) |
| 3122 | testCases = append(testCases, testCase{ |
| 3123 | testType: clientTest, |
| 3124 | name: "ClientAuth-ECDHE_PSK", |
| 3125 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3126 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3127 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3128 | PreSharedKey: []byte("secret"), |
| 3129 | ClientAuth: RequireAnyClientCert, |
| 3130 | }, |
| 3131 | flags: []string{ |
| 3132 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3133 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3134 | "-psk", "secret", |
| 3135 | }, |
| 3136 | shouldFail: true, |
| 3137 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3138 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3139 | |
| 3140 | // Regression test for a bug where the client CA list, if explicitly |
| 3141 | // set to NULL, was mis-encoded. |
| 3142 | testCases = append(testCases, testCase{ |
| 3143 | testType: serverTest, |
| 3144 | name: "Null-Client-CA-List", |
| 3145 | config: Config{ |
| 3146 | MaxVersion: VersionTLS12, |
| 3147 | Certificates: []Certificate{rsaCertificate}, |
| 3148 | }, |
| 3149 | flags: []string{ |
| 3150 | "-require-any-client-certificate", |
| 3151 | "-use-null-client-ca-list", |
| 3152 | }, |
| 3153 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3154 | } |
| 3155 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3156 | func addExtendedMasterSecretTests() { |
| 3157 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3158 | |
| 3159 | for _, with := range []bool{false, true} { |
| 3160 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3161 | if with { |
| 3162 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | for _, isClient := range []bool{false, true} { |
| 3166 | suffix := "-Server" |
| 3167 | testType := serverTest |
| 3168 | if isClient { |
| 3169 | suffix = "-Client" |
| 3170 | testType = clientTest |
| 3171 | } |
| 3172 | |
| 3173 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3174 | // In TLS 1.3, the extension is irrelevant and |
| 3175 | // always reports as enabled. |
| 3176 | var flags []string |
| 3177 | if with || ver.version >= VersionTLS13 { |
| 3178 | flags = []string{expectEMSFlag} |
| 3179 | } |
| 3180 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3181 | test := testCase{ |
| 3182 | testType: testType, |
| 3183 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3184 | config: Config{ |
| 3185 | MinVersion: ver.version, |
| 3186 | MaxVersion: ver.version, |
| 3187 | Bugs: ProtocolBugs{ |
| 3188 | NoExtendedMasterSecret: !with, |
| 3189 | RequireExtendedMasterSecret: with, |
| 3190 | }, |
| 3191 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3192 | flags: flags, |
| 3193 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3194 | } |
| 3195 | if test.shouldFail { |
| 3196 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3197 | } |
| 3198 | testCases = append(testCases, test) |
| 3199 | } |
| 3200 | } |
| 3201 | } |
| 3202 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3203 | for _, isClient := range []bool{false, true} { |
| 3204 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3205 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3206 | boolToWord := func(b bool) string { |
| 3207 | if b { |
| 3208 | return "Yes" |
| 3209 | } |
| 3210 | return "No" |
| 3211 | } |
| 3212 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3213 | if isClient { |
| 3214 | suffix += "Client" |
| 3215 | } else { |
| 3216 | suffix += "Server" |
| 3217 | } |
| 3218 | |
| 3219 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3220 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3221 | Bugs: ProtocolBugs{ |
| 3222 | RequireExtendedMasterSecret: true, |
| 3223 | }, |
| 3224 | } |
| 3225 | |
| 3226 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3227 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3228 | Bugs: ProtocolBugs{ |
| 3229 | NoExtendedMasterSecret: true, |
| 3230 | }, |
| 3231 | } |
| 3232 | |
| 3233 | test := testCase{ |
| 3234 | name: "ExtendedMasterSecret-" + suffix, |
| 3235 | resumeSession: true, |
| 3236 | } |
| 3237 | |
| 3238 | if !isClient { |
| 3239 | test.testType = serverTest |
| 3240 | } |
| 3241 | |
| 3242 | if supportedInFirstConnection { |
| 3243 | test.config = supportedConfig |
| 3244 | } else { |
| 3245 | test.config = noSupportConfig |
| 3246 | } |
| 3247 | |
| 3248 | if supportedInResumeConnection { |
| 3249 | test.resumeConfig = &supportedConfig |
| 3250 | } else { |
| 3251 | test.resumeConfig = &noSupportConfig |
| 3252 | } |
| 3253 | |
| 3254 | switch suffix { |
| 3255 | case "YesToYes-Client", "YesToYes-Server": |
| 3256 | // When a session is resumed, it should |
| 3257 | // still be aware that its master |
| 3258 | // secret was generated via EMS and |
| 3259 | // thus it's safe to use tls-unique. |
| 3260 | test.flags = []string{expectEMSFlag} |
| 3261 | case "NoToYes-Server": |
| 3262 | // If an original connection did not |
| 3263 | // contain EMS, but a resumption |
| 3264 | // handshake does, then a server should |
| 3265 | // not resume the session. |
| 3266 | test.expectResumeRejected = true |
| 3267 | case "YesToNo-Server": |
| 3268 | // Resuming an EMS session without the |
| 3269 | // EMS extension should cause the |
| 3270 | // server to abort the connection. |
| 3271 | test.shouldFail = true |
| 3272 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3273 | case "NoToYes-Client": |
| 3274 | // A client should abort a connection |
| 3275 | // where the server resumed a non-EMS |
| 3276 | // session but echoed the EMS |
| 3277 | // extension. |
| 3278 | test.shouldFail = true |
| 3279 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3280 | case "YesToNo-Client": |
| 3281 | // A client should abort a connection |
| 3282 | // where the server didn't echo EMS |
| 3283 | // when the session used it. |
| 3284 | test.shouldFail = true |
| 3285 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3286 | } |
| 3287 | |
| 3288 | testCases = append(testCases, test) |
| 3289 | } |
| 3290 | } |
| 3291 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3292 | |
| 3293 | // Switching EMS on renegotiation is forbidden. |
| 3294 | testCases = append(testCases, testCase{ |
| 3295 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3296 | config: Config{ |
| 3297 | MaxVersion: VersionTLS12, |
| 3298 | Bugs: ProtocolBugs{ |
| 3299 | NoExtendedMasterSecret: true, |
| 3300 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3301 | }, |
| 3302 | }, |
| 3303 | renegotiate: 1, |
| 3304 | flags: []string{ |
| 3305 | "-renegotiate-freely", |
| 3306 | "-expect-total-renegotiations", "1", |
| 3307 | }, |
| 3308 | }) |
| 3309 | |
| 3310 | testCases = append(testCases, testCase{ |
| 3311 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3312 | config: Config{ |
| 3313 | MaxVersion: VersionTLS12, |
| 3314 | Bugs: ProtocolBugs{ |
| 3315 | NoExtendedMasterSecret: true, |
| 3316 | }, |
| 3317 | }, |
| 3318 | renegotiate: 1, |
| 3319 | flags: []string{ |
| 3320 | "-renegotiate-freely", |
| 3321 | "-expect-total-renegotiations", "1", |
| 3322 | }, |
| 3323 | shouldFail: true, |
| 3324 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3325 | }) |
| 3326 | |
| 3327 | testCases = append(testCases, testCase{ |
| 3328 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3329 | config: Config{ |
| 3330 | MaxVersion: VersionTLS12, |
| 3331 | Bugs: ProtocolBugs{ |
| 3332 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3333 | }, |
| 3334 | }, |
| 3335 | renegotiate: 1, |
| 3336 | flags: []string{ |
| 3337 | "-renegotiate-freely", |
| 3338 | "-expect-total-renegotiations", "1", |
| 3339 | }, |
| 3340 | shouldFail: true, |
| 3341 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3342 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3343 | } |
| 3344 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3345 | type stateMachineTestConfig struct { |
| 3346 | protocol protocol |
| 3347 | async bool |
| 3348 | splitHandshake, packHandshakeFlight bool |
| 3349 | } |
| 3350 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3351 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3352 | // various conditions. Some of these are redundant with other tests, but they |
| 3353 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3354 | func addAllStateMachineCoverageTests() { |
| 3355 | for _, async := range []bool{false, true} { |
| 3356 | for _, protocol := range []protocol{tls, dtls} { |
| 3357 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3358 | protocol: protocol, |
| 3359 | async: async, |
| 3360 | }) |
| 3361 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3362 | protocol: protocol, |
| 3363 | async: async, |
| 3364 | splitHandshake: true, |
| 3365 | }) |
| 3366 | if protocol == tls { |
| 3367 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3368 | protocol: protocol, |
| 3369 | async: async, |
| 3370 | packHandshakeFlight: true, |
| 3371 | }) |
| 3372 | } |
| 3373 | } |
| 3374 | } |
| 3375 | } |
| 3376 | |
| 3377 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3378 | var tests []testCase |
| 3379 | |
| 3380 | // Basic handshake, with resumption. Client and server, |
| 3381 | // session ID and session ticket. |
| 3382 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3383 | name: "Basic-Client", |
| 3384 | config: Config{ |
| 3385 | MaxVersion: VersionTLS12, |
| 3386 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3387 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3388 | // Ensure session tickets are used, not session IDs. |
| 3389 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3390 | }) |
| 3391 | tests = append(tests, testCase{ |
| 3392 | name: "Basic-Client-RenewTicket", |
| 3393 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3394 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3395 | Bugs: ProtocolBugs{ |
| 3396 | RenewTicketOnResume: true, |
| 3397 | }, |
| 3398 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3399 | flags: []string{"-expect-ticket-renewal"}, |
| 3400 | resumeSession: true, |
| 3401 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3402 | }) |
| 3403 | tests = append(tests, testCase{ |
| 3404 | name: "Basic-Client-NoTicket", |
| 3405 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3406 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3407 | SessionTicketsDisabled: true, |
| 3408 | }, |
| 3409 | resumeSession: true, |
| 3410 | }) |
| 3411 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3412 | name: "Basic-Client-Implicit", |
| 3413 | config: Config{ |
| 3414 | MaxVersion: VersionTLS12, |
| 3415 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3416 | flags: []string{"-implicit-handshake"}, |
| 3417 | resumeSession: true, |
| 3418 | }) |
| 3419 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3420 | testType: serverTest, |
| 3421 | name: "Basic-Server", |
| 3422 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3423 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3424 | Bugs: ProtocolBugs{ |
| 3425 | RequireSessionTickets: true, |
| 3426 | }, |
| 3427 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3428 | resumeSession: true, |
| 3429 | }) |
| 3430 | tests = append(tests, testCase{ |
| 3431 | testType: serverTest, |
| 3432 | name: "Basic-Server-NoTickets", |
| 3433 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3434 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3435 | SessionTicketsDisabled: true, |
| 3436 | }, |
| 3437 | resumeSession: true, |
| 3438 | }) |
| 3439 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3440 | testType: serverTest, |
| 3441 | name: "Basic-Server-Implicit", |
| 3442 | config: Config{ |
| 3443 | MaxVersion: VersionTLS12, |
| 3444 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3445 | flags: []string{"-implicit-handshake"}, |
| 3446 | resumeSession: true, |
| 3447 | }) |
| 3448 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3449 | testType: serverTest, |
| 3450 | name: "Basic-Server-EarlyCallback", |
| 3451 | config: Config{ |
| 3452 | MaxVersion: VersionTLS12, |
| 3453 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3454 | flags: []string{"-use-early-callback"}, |
| 3455 | resumeSession: true, |
| 3456 | }) |
| 3457 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3458 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3459 | if config.protocol == tls { |
| 3460 | tests = append(tests, testCase{ |
| 3461 | name: "TLS13-1RTT-Client", |
| 3462 | config: Config{ |
| 3463 | MaxVersion: VersionTLS13, |
| 3464 | MinVersion: VersionTLS13, |
| 3465 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3466 | resumeSession: true, |
| 3467 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3468 | }) |
| 3469 | |
| 3470 | tests = append(tests, testCase{ |
| 3471 | testType: serverTest, |
| 3472 | name: "TLS13-1RTT-Server", |
| 3473 | config: Config{ |
| 3474 | MaxVersion: VersionTLS13, |
| 3475 | MinVersion: VersionTLS13, |
| 3476 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3477 | resumeSession: true, |
| 3478 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3479 | }) |
| 3480 | |
| 3481 | tests = append(tests, testCase{ |
| 3482 | name: "TLS13-HelloRetryRequest-Client", |
| 3483 | config: Config{ |
| 3484 | MaxVersion: VersionTLS13, |
| 3485 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3486 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3487 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3488 | CurvePreferences: []CurveID{CurveP384}, |
| 3489 | Bugs: ProtocolBugs{ |
| 3490 | ExpectMissingKeyShare: true, |
| 3491 | }, |
| 3492 | }, |
| 3493 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3494 | resumeSession: true, |
| 3495 | }) |
| 3496 | |
| 3497 | tests = append(tests, testCase{ |
| 3498 | testType: serverTest, |
| 3499 | name: "TLS13-HelloRetryRequest-Server", |
| 3500 | config: Config{ |
| 3501 | MaxVersion: VersionTLS13, |
| 3502 | MinVersion: VersionTLS13, |
| 3503 | // Require a HelloRetryRequest for every curve. |
| 3504 | DefaultCurves: []CurveID{}, |
| 3505 | }, |
| 3506 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3507 | resumeSession: true, |
| 3508 | }) |
| 3509 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3510 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3511 | // TLS client auth. |
| 3512 | tests = append(tests, testCase{ |
| 3513 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3514 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3515 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3516 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3517 | ClientAuth: RequestClientCert, |
| 3518 | }, |
| 3519 | }) |
| 3520 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3521 | testType: serverTest, |
| 3522 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3523 | config: Config{ |
| 3524 | MaxVersion: VersionTLS12, |
| 3525 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3526 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3527 | flags: []string{"-verify-peer"}, |
| 3528 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3529 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3530 | tests = append(tests, testCase{ |
| 3531 | testType: clientTest, |
| 3532 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3533 | config: Config{ |
| 3534 | MaxVersion: VersionSSL30, |
| 3535 | ClientAuth: RequestClientCert, |
| 3536 | }, |
| 3537 | }) |
| 3538 | tests = append(tests, testCase{ |
| 3539 | testType: serverTest, |
| 3540 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3541 | config: Config{ |
| 3542 | MaxVersion: VersionSSL30, |
| 3543 | }, |
| 3544 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3545 | flags: []string{"-verify-peer"}, |
| 3546 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3547 | tests = append(tests, testCase{ |
| 3548 | testType: clientTest, |
| 3549 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3550 | config: Config{ |
| 3551 | MaxVersion: VersionTLS13, |
| 3552 | ClientAuth: RequestClientCert, |
| 3553 | }, |
| 3554 | }) |
| 3555 | tests = append(tests, testCase{ |
| 3556 | testType: serverTest, |
| 3557 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3558 | config: Config{ |
| 3559 | MaxVersion: VersionTLS13, |
| 3560 | }, |
| 3561 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3562 | flags: []string{"-verify-peer"}, |
| 3563 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3564 | } |
| 3565 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3566 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3567 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3568 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3569 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3570 | ClientAuth: RequireAnyClientCert, |
| 3571 | }, |
| 3572 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3573 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3574 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3575 | }, |
| 3576 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3577 | tests = append(tests, testCase{ |
| 3578 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3579 | name: "ClientAuth-RSA-Client-TLS13", |
| 3580 | config: Config{ |
| 3581 | MaxVersion: VersionTLS13, |
| 3582 | ClientAuth: RequireAnyClientCert, |
| 3583 | }, |
| 3584 | flags: []string{ |
| 3585 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3586 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3587 | }, |
| 3588 | }) |
| 3589 | tests = append(tests, testCase{ |
| 3590 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3591 | name: "ClientAuth-ECDSA-Client", |
| 3592 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3593 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3594 | ClientAuth: RequireAnyClientCert, |
| 3595 | }, |
| 3596 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3597 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3598 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3599 | }, |
| 3600 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3601 | tests = append(tests, testCase{ |
| 3602 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3603 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3604 | config: Config{ |
| 3605 | MaxVersion: VersionTLS13, |
| 3606 | ClientAuth: RequireAnyClientCert, |
| 3607 | }, |
| 3608 | flags: []string{ |
| 3609 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3610 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3611 | }, |
| 3612 | }) |
| 3613 | tests = append(tests, testCase{ |
| 3614 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3615 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3616 | config: Config{ |
| 3617 | MaxVersion: VersionTLS12, |
| 3618 | ClientAuth: RequestClientCert, |
| 3619 | }, |
| 3620 | flags: []string{"-use-old-client-cert-callback"}, |
| 3621 | }) |
| 3622 | tests = append(tests, testCase{ |
| 3623 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3624 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3625 | config: Config{ |
| 3626 | MaxVersion: VersionTLS13, |
| 3627 | ClientAuth: RequestClientCert, |
| 3628 | }, |
| 3629 | flags: []string{"-use-old-client-cert-callback"}, |
| 3630 | }) |
| 3631 | tests = append(tests, testCase{ |
| 3632 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3633 | name: "ClientAuth-OldCallback", |
| 3634 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3635 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3636 | ClientAuth: RequireAnyClientCert, |
| 3637 | }, |
| 3638 | flags: []string{ |
| 3639 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3640 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3641 | "-use-old-client-cert-callback", |
| 3642 | }, |
| 3643 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3644 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3645 | testType: clientTest, |
| 3646 | name: "ClientAuth-OldCallback-TLS13", |
| 3647 | config: Config{ |
| 3648 | MaxVersion: VersionTLS13, |
| 3649 | ClientAuth: RequireAnyClientCert, |
| 3650 | }, |
| 3651 | flags: []string{ |
| 3652 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3653 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3654 | "-use-old-client-cert-callback", |
| 3655 | }, |
| 3656 | }) |
| 3657 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3658 | testType: serverTest, |
| 3659 | name: "ClientAuth-Server", |
| 3660 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3661 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3662 | Certificates: []Certificate{rsaCertificate}, |
| 3663 | }, |
| 3664 | flags: []string{"-require-any-client-certificate"}, |
| 3665 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3666 | tests = append(tests, testCase{ |
| 3667 | testType: serverTest, |
| 3668 | name: "ClientAuth-Server-TLS13", |
| 3669 | config: Config{ |
| 3670 | MaxVersion: VersionTLS13, |
| 3671 | Certificates: []Certificate{rsaCertificate}, |
| 3672 | }, |
| 3673 | flags: []string{"-require-any-client-certificate"}, |
| 3674 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3675 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3676 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3677 | tests = append(tests, testCase{ |
| 3678 | testType: serverTest, |
| 3679 | name: "Basic-Server-RSA", |
| 3680 | config: Config{ |
| 3681 | MaxVersion: VersionTLS12, |
| 3682 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3683 | }, |
| 3684 | flags: []string{ |
| 3685 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3686 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3687 | }, |
| 3688 | }) |
| 3689 | tests = append(tests, testCase{ |
| 3690 | testType: serverTest, |
| 3691 | name: "Basic-Server-ECDHE-RSA", |
| 3692 | config: Config{ |
| 3693 | MaxVersion: VersionTLS12, |
| 3694 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3695 | }, |
| 3696 | flags: []string{ |
| 3697 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3698 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3699 | }, |
| 3700 | }) |
| 3701 | tests = append(tests, testCase{ |
| 3702 | testType: serverTest, |
| 3703 | name: "Basic-Server-ECDHE-ECDSA", |
| 3704 | config: Config{ |
| 3705 | MaxVersion: VersionTLS12, |
| 3706 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3707 | }, |
| 3708 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3709 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3710 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3711 | }, |
| 3712 | }) |
| 3713 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3714 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3715 | tests = append(tests, testCase{ |
| 3716 | name: "SessionTicketsDisabled-Client", |
| 3717 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3718 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3719 | SessionTicketsDisabled: true, |
| 3720 | }, |
| 3721 | }) |
| 3722 | tests = append(tests, testCase{ |
| 3723 | testType: serverTest, |
| 3724 | name: "SessionTicketsDisabled-Server", |
| 3725 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3726 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3727 | SessionTicketsDisabled: true, |
| 3728 | }, |
| 3729 | }) |
| 3730 | |
| 3731 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3732 | // identity hint. |
| 3733 | tests = append(tests, testCase{ |
| 3734 | name: "EmptyPSKHint-Client", |
| 3735 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3736 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3737 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3738 | PreSharedKey: []byte("secret"), |
| 3739 | }, |
| 3740 | flags: []string{"-psk", "secret"}, |
| 3741 | }) |
| 3742 | tests = append(tests, testCase{ |
| 3743 | testType: serverTest, |
| 3744 | name: "EmptyPSKHint-Server", |
| 3745 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3746 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3747 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3748 | PreSharedKey: []byte("secret"), |
| 3749 | }, |
| 3750 | flags: []string{"-psk", "secret"}, |
| 3751 | }) |
| 3752 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3753 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3754 | tests = append(tests, testCase{ |
| 3755 | testType: clientTest, |
| 3756 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3757 | config: Config{ |
| 3758 | MaxVersion: VersionTLS12, |
| 3759 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3760 | flags: []string{ |
| 3761 | "-enable-ocsp-stapling", |
| 3762 | "-expect-ocsp-response", |
| 3763 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3764 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3765 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3766 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3767 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3768 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3769 | testType: serverTest, |
| 3770 | name: "OCSPStapling-Server", |
| 3771 | config: Config{ |
| 3772 | MaxVersion: VersionTLS12, |
| 3773 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3774 | expectedOCSPResponse: testOCSPResponse, |
| 3775 | flags: []string{ |
| 3776 | "-ocsp-response", |
| 3777 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3778 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3779 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3780 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3781 | tests = append(tests, testCase{ |
| 3782 | testType: clientTest, |
| 3783 | name: "OCSPStapling-Client-TLS13", |
| 3784 | config: Config{ |
| 3785 | MaxVersion: VersionTLS13, |
| 3786 | }, |
| 3787 | flags: []string{ |
| 3788 | "-enable-ocsp-stapling", |
| 3789 | "-expect-ocsp-response", |
| 3790 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3791 | "-verify-peer", |
| 3792 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3793 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3794 | }) |
| 3795 | tests = append(tests, testCase{ |
| 3796 | testType: serverTest, |
| 3797 | name: "OCSPStapling-Server-TLS13", |
| 3798 | config: Config{ |
| 3799 | MaxVersion: VersionTLS13, |
| 3800 | }, |
| 3801 | expectedOCSPResponse: testOCSPResponse, |
| 3802 | flags: []string{ |
| 3803 | "-ocsp-response", |
| 3804 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3805 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3806 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3807 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3808 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3809 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3810 | for _, vers := range tlsVersions { |
| 3811 | if config.protocol == dtls && !vers.hasDTLS { |
| 3812 | continue |
| 3813 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3814 | for _, testType := range []testType{clientTest, serverTest} { |
| 3815 | suffix := "-Client" |
| 3816 | if testType == serverTest { |
| 3817 | suffix = "-Server" |
| 3818 | } |
| 3819 | suffix += "-" + vers.name |
| 3820 | |
| 3821 | flag := "-verify-peer" |
| 3822 | if testType == serverTest { |
| 3823 | flag = "-require-any-client-certificate" |
| 3824 | } |
| 3825 | |
| 3826 | tests = append(tests, testCase{ |
| 3827 | testType: testType, |
| 3828 | name: "CertificateVerificationSucceed" + suffix, |
| 3829 | config: Config{ |
| 3830 | MaxVersion: vers.version, |
| 3831 | Certificates: []Certificate{rsaCertificate}, |
| 3832 | }, |
| 3833 | flags: []string{ |
| 3834 | flag, |
| 3835 | "-expect-verify-result", |
| 3836 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3837 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3838 | }) |
| 3839 | tests = append(tests, testCase{ |
| 3840 | testType: testType, |
| 3841 | name: "CertificateVerificationFail" + suffix, |
| 3842 | config: Config{ |
| 3843 | MaxVersion: vers.version, |
| 3844 | Certificates: []Certificate{rsaCertificate}, |
| 3845 | }, |
| 3846 | flags: []string{ |
| 3847 | flag, |
| 3848 | "-verify-fail", |
| 3849 | }, |
| 3850 | shouldFail: true, |
| 3851 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3852 | }) |
| 3853 | } |
| 3854 | |
| 3855 | // By default, the client is in a soft fail mode where the peer |
| 3856 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3857 | tests = append(tests, testCase{ |
| 3858 | testType: clientTest, |
| 3859 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3860 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3861 | MaxVersion: vers.version, |
| 3862 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3863 | }, |
| 3864 | flags: []string{ |
| 3865 | "-verify-fail", |
| 3866 | "-expect-verify-result", |
| 3867 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3868 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3869 | }) |
| 3870 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3871 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3872 | tests = append(tests, testCase{ |
| 3873 | name: "ShimSendAlert", |
| 3874 | flags: []string{"-send-alert"}, |
| 3875 | shimWritesFirst: true, |
| 3876 | shouldFail: true, |
| 3877 | expectedLocalError: "remote error: decompression failure", |
| 3878 | }) |
| 3879 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3880 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3881 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3882 | name: "Renegotiate-Client", |
| 3883 | config: Config{ |
| 3884 | MaxVersion: VersionTLS12, |
| 3885 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3886 | renegotiate: 1, |
| 3887 | flags: []string{ |
| 3888 | "-renegotiate-freely", |
| 3889 | "-expect-total-renegotiations", "1", |
| 3890 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3891 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3892 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3893 | tests = append(tests, testCase{ |
| 3894 | name: "SendHalfHelloRequest", |
| 3895 | config: Config{ |
| 3896 | MaxVersion: VersionTLS12, |
| 3897 | Bugs: ProtocolBugs{ |
| 3898 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3899 | }, |
| 3900 | }, |
| 3901 | sendHalfHelloRequest: true, |
| 3902 | flags: []string{"-renegotiate-ignore"}, |
| 3903 | shouldFail: true, |
| 3904 | expectedError: ":UNEXPECTED_RECORD:", |
| 3905 | }) |
| 3906 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3907 | // NPN on client and server; results in post-handshake message. |
| 3908 | tests = append(tests, testCase{ |
| 3909 | name: "NPN-Client", |
| 3910 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3911 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3912 | NextProtos: []string{"foo"}, |
| 3913 | }, |
| 3914 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3915 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3916 | expectedNextProto: "foo", |
| 3917 | expectedNextProtoType: npn, |
| 3918 | }) |
| 3919 | tests = append(tests, testCase{ |
| 3920 | testType: serverTest, |
| 3921 | name: "NPN-Server", |
| 3922 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3923 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3924 | NextProtos: []string{"bar"}, |
| 3925 | }, |
| 3926 | flags: []string{ |
| 3927 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3928 | "-expect-next-proto", "bar", |
| 3929 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3930 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3931 | expectedNextProto: "bar", |
| 3932 | expectedNextProtoType: npn, |
| 3933 | }) |
| 3934 | |
| 3935 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3936 | |
| 3937 | // Client does False Start and negotiates NPN. |
| 3938 | tests = append(tests, testCase{ |
| 3939 | name: "FalseStart", |
| 3940 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3941 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3942 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3943 | NextProtos: []string{"foo"}, |
| 3944 | Bugs: ProtocolBugs{ |
| 3945 | ExpectFalseStart: true, |
| 3946 | }, |
| 3947 | }, |
| 3948 | flags: []string{ |
| 3949 | "-false-start", |
| 3950 | "-select-next-proto", "foo", |
| 3951 | }, |
| 3952 | shimWritesFirst: true, |
| 3953 | resumeSession: true, |
| 3954 | }) |
| 3955 | |
| 3956 | // Client does False Start and negotiates ALPN. |
| 3957 | tests = append(tests, testCase{ |
| 3958 | name: "FalseStart-ALPN", |
| 3959 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3960 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3961 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3962 | NextProtos: []string{"foo"}, |
| 3963 | Bugs: ProtocolBugs{ |
| 3964 | ExpectFalseStart: true, |
| 3965 | }, |
| 3966 | }, |
| 3967 | flags: []string{ |
| 3968 | "-false-start", |
| 3969 | "-advertise-alpn", "\x03foo", |
| 3970 | }, |
| 3971 | shimWritesFirst: true, |
| 3972 | resumeSession: true, |
| 3973 | }) |
| 3974 | |
| 3975 | // Client does False Start but doesn't explicitly call |
| 3976 | // SSL_connect. |
| 3977 | tests = append(tests, testCase{ |
| 3978 | name: "FalseStart-Implicit", |
| 3979 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3980 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3981 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3982 | NextProtos: []string{"foo"}, |
| 3983 | }, |
| 3984 | flags: []string{ |
| 3985 | "-implicit-handshake", |
| 3986 | "-false-start", |
| 3987 | "-advertise-alpn", "\x03foo", |
| 3988 | }, |
| 3989 | }) |
| 3990 | |
| 3991 | // False Start without session tickets. |
| 3992 | tests = append(tests, testCase{ |
| 3993 | name: "FalseStart-SessionTicketsDisabled", |
| 3994 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3995 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3996 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3997 | NextProtos: []string{"foo"}, |
| 3998 | SessionTicketsDisabled: true, |
| 3999 | Bugs: ProtocolBugs{ |
| 4000 | ExpectFalseStart: true, |
| 4001 | }, |
| 4002 | }, |
| 4003 | flags: []string{ |
| 4004 | "-false-start", |
| 4005 | "-select-next-proto", "foo", |
| 4006 | }, |
| 4007 | shimWritesFirst: true, |
| 4008 | }) |
| 4009 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 4010 | tests = append(tests, testCase{ |
| 4011 | name: "FalseStart-CECPQ1", |
| 4012 | config: Config{ |
| 4013 | MaxVersion: VersionTLS12, |
| 4014 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 4015 | NextProtos: []string{"foo"}, |
| 4016 | Bugs: ProtocolBugs{ |
| 4017 | ExpectFalseStart: true, |
| 4018 | }, |
| 4019 | }, |
| 4020 | flags: []string{ |
| 4021 | "-false-start", |
| 4022 | "-cipher", "DEFAULT:kCECPQ1", |
| 4023 | "-select-next-proto", "foo", |
| 4024 | }, |
| 4025 | shimWritesFirst: true, |
| 4026 | resumeSession: true, |
| 4027 | }) |
| 4028 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4029 | // Server parses a V2ClientHello. |
| 4030 | tests = append(tests, testCase{ |
| 4031 | testType: serverTest, |
| 4032 | name: "SendV2ClientHello", |
| 4033 | config: Config{ |
| 4034 | // Choose a cipher suite that does not involve |
| 4035 | // elliptic curves, so no extensions are |
| 4036 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4037 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4038 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4039 | Bugs: ProtocolBugs{ |
| 4040 | SendV2ClientHello: true, |
| 4041 | }, |
| 4042 | }, |
| 4043 | }) |
| 4044 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4045 | // Test Channel ID |
| 4046 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4047 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4048 | continue |
| 4049 | } |
| 4050 | // Client sends a Channel ID. |
| 4051 | tests = append(tests, testCase{ |
| 4052 | name: "ChannelID-Client-" + ver.name, |
| 4053 | config: Config{ |
| 4054 | MaxVersion: ver.version, |
| 4055 | RequestChannelID: true, |
| 4056 | }, |
| 4057 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4058 | resumeSession: true, |
| 4059 | expectChannelID: true, |
| 4060 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4061 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4062 | // Server accepts a Channel ID. |
| 4063 | tests = append(tests, testCase{ |
| 4064 | testType: serverTest, |
| 4065 | name: "ChannelID-Server-" + ver.name, |
| 4066 | config: Config{ |
| 4067 | MaxVersion: ver.version, |
| 4068 | ChannelID: channelIDKey, |
| 4069 | }, |
| 4070 | flags: []string{ |
| 4071 | "-expect-channel-id", |
| 4072 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4073 | }, |
| 4074 | resumeSession: true, |
| 4075 | expectChannelID: true, |
| 4076 | }) |
| 4077 | |
| 4078 | tests = append(tests, testCase{ |
| 4079 | testType: serverTest, |
| 4080 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4081 | config: Config{ |
| 4082 | MaxVersion: ver.version, |
| 4083 | ChannelID: channelIDKey, |
| 4084 | Bugs: ProtocolBugs{ |
| 4085 | InvalidChannelIDSignature: true, |
| 4086 | }, |
| 4087 | }, |
| 4088 | flags: []string{"-enable-channel-id"}, |
| 4089 | shouldFail: true, |
| 4090 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4091 | }) |
| 4092 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4093 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4094 | // Channel ID and NPN at the same time, to ensure their relative |
| 4095 | // ordering is correct. |
| 4096 | tests = append(tests, testCase{ |
| 4097 | name: "ChannelID-NPN-Client", |
| 4098 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4099 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4100 | RequestChannelID: true, |
| 4101 | NextProtos: []string{"foo"}, |
| 4102 | }, |
| 4103 | flags: []string{ |
| 4104 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4105 | "-select-next-proto", "foo", |
| 4106 | }, |
| 4107 | resumeSession: true, |
| 4108 | expectChannelID: true, |
| 4109 | expectedNextProto: "foo", |
| 4110 | expectedNextProtoType: npn, |
| 4111 | }) |
| 4112 | tests = append(tests, testCase{ |
| 4113 | testType: serverTest, |
| 4114 | name: "ChannelID-NPN-Server", |
| 4115 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4116 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4117 | ChannelID: channelIDKey, |
| 4118 | NextProtos: []string{"bar"}, |
| 4119 | }, |
| 4120 | flags: []string{ |
| 4121 | "-expect-channel-id", |
| 4122 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4123 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4124 | "-expect-next-proto", "bar", |
| 4125 | }, |
| 4126 | resumeSession: true, |
| 4127 | expectChannelID: true, |
| 4128 | expectedNextProto: "bar", |
| 4129 | expectedNextProtoType: npn, |
| 4130 | }) |
| 4131 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4132 | // Bidirectional shutdown with the runner initiating. |
| 4133 | tests = append(tests, testCase{ |
| 4134 | name: "Shutdown-Runner", |
| 4135 | config: Config{ |
| 4136 | Bugs: ProtocolBugs{ |
| 4137 | ExpectCloseNotify: true, |
| 4138 | }, |
| 4139 | }, |
| 4140 | flags: []string{"-check-close-notify"}, |
| 4141 | }) |
| 4142 | |
| 4143 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4144 | // in the meantime, sends garbage before the close_notify which |
| 4145 | // the shim must ignore. |
| 4146 | tests = append(tests, testCase{ |
| 4147 | name: "Shutdown-Shim", |
| 4148 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4149 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4150 | Bugs: ProtocolBugs{ |
| 4151 | ExpectCloseNotify: true, |
| 4152 | }, |
| 4153 | }, |
| 4154 | shimShutsDown: true, |
| 4155 | sendEmptyRecords: 1, |
| 4156 | sendWarningAlerts: 1, |
| 4157 | flags: []string{"-check-close-notify"}, |
| 4158 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4159 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4160 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4161 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4162 | tests = append(tests, testCase{ |
| 4163 | name: "SkipHelloVerifyRequest", |
| 4164 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4165 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4166 | Bugs: ProtocolBugs{ |
| 4167 | SkipHelloVerifyRequest: true, |
| 4168 | }, |
| 4169 | }, |
| 4170 | }) |
| 4171 | } |
| 4172 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4173 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4174 | test.protocol = config.protocol |
| 4175 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4176 | test.name += "-DTLS" |
| 4177 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4178 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4179 | test.name += "-Async" |
| 4180 | test.flags = append(test.flags, "-async") |
| 4181 | } else { |
| 4182 | test.name += "-Sync" |
| 4183 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4184 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4185 | test.name += "-SplitHandshakeRecords" |
| 4186 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4187 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4188 | test.config.Bugs.MaxPacketLength = 256 |
| 4189 | test.flags = append(test.flags, "-mtu", "256") |
| 4190 | } |
| 4191 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4192 | if config.packHandshakeFlight { |
| 4193 | test.name += "-PackHandshakeFlight" |
| 4194 | test.config.Bugs.PackHandshakeFlight = true |
| 4195 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4196 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4197 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4198 | } |
| 4199 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4200 | func addDDoSCallbackTests() { |
| 4201 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4202 | for _, resume := range []bool{false, true} { |
| 4203 | suffix := "Resume" |
| 4204 | if resume { |
| 4205 | suffix = "No" + suffix |
| 4206 | } |
| 4207 | |
| 4208 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4209 | testType: serverTest, |
| 4210 | name: "Server-DDoS-OK-" + suffix, |
| 4211 | config: Config{ |
| 4212 | MaxVersion: VersionTLS12, |
| 4213 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4214 | flags: []string{"-install-ddos-callback"}, |
| 4215 | resumeSession: resume, |
| 4216 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4217 | testCases = append(testCases, testCase{ |
| 4218 | testType: serverTest, |
| 4219 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4220 | config: Config{ |
| 4221 | MaxVersion: VersionTLS13, |
| 4222 | }, |
| 4223 | flags: []string{"-install-ddos-callback"}, |
| 4224 | resumeSession: resume, |
| 4225 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4226 | |
| 4227 | failFlag := "-fail-ddos-callback" |
| 4228 | if resume { |
| 4229 | failFlag = "-fail-second-ddos-callback" |
| 4230 | } |
| 4231 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4232 | testType: serverTest, |
| 4233 | name: "Server-DDoS-Reject-" + suffix, |
| 4234 | config: Config{ |
| 4235 | MaxVersion: VersionTLS12, |
| 4236 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4237 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4238 | resumeSession: resume, |
| 4239 | shouldFail: true, |
| 4240 | expectedError: ":CONNECTION_REJECTED:", |
| 4241 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4242 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4243 | testCases = append(testCases, testCase{ |
| 4244 | testType: serverTest, |
| 4245 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4246 | config: Config{ |
| 4247 | MaxVersion: VersionTLS13, |
| 4248 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4249 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4250 | resumeSession: resume, |
| 4251 | shouldFail: true, |
| 4252 | expectedError: ":CONNECTION_REJECTED:", |
| 4253 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4254 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4255 | } |
| 4256 | } |
| 4257 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4258 | func addVersionNegotiationTests() { |
| 4259 | for i, shimVers := range tlsVersions { |
| 4260 | // Assemble flags to disable all newer versions on the shim. |
| 4261 | var flags []string |
| 4262 | for _, vers := range tlsVersions[i+1:] { |
| 4263 | flags = append(flags, vers.flag) |
| 4264 | } |
| 4265 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4266 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4267 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4268 | protocols := []protocol{tls} |
| 4269 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4270 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4271 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4272 | for _, protocol := range protocols { |
| 4273 | expectedVersion := shimVers.version |
| 4274 | if runnerVers.version < shimVers.version { |
| 4275 | expectedVersion = runnerVers.version |
| 4276 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4277 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4278 | suffix := shimVers.name + "-" + runnerVers.name |
| 4279 | if protocol == dtls { |
| 4280 | suffix += "-DTLS" |
| 4281 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4282 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4283 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4284 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4285 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4286 | clientVers := shimVers.version |
| 4287 | if clientVers > VersionTLS10 { |
| 4288 | clientVers = VersionTLS10 |
| 4289 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4290 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4291 | serverVers := expectedVersion |
| 4292 | if expectedVersion >= VersionTLS13 { |
| 4293 | serverVers = VersionTLS10 |
| 4294 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4295 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4296 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4297 | testCases = append(testCases, testCase{ |
| 4298 | protocol: protocol, |
| 4299 | testType: clientTest, |
| 4300 | name: "VersionNegotiation-Client-" + suffix, |
| 4301 | config: Config{ |
| 4302 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4303 | Bugs: ProtocolBugs{ |
| 4304 | ExpectInitialRecordVersion: clientVers, |
| 4305 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4306 | }, |
| 4307 | flags: flags, |
| 4308 | expectedVersion: expectedVersion, |
| 4309 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4310 | testCases = append(testCases, testCase{ |
| 4311 | protocol: protocol, |
| 4312 | testType: clientTest, |
| 4313 | name: "VersionNegotiation-Client2-" + suffix, |
| 4314 | config: Config{ |
| 4315 | MaxVersion: runnerVers.version, |
| 4316 | Bugs: ProtocolBugs{ |
| 4317 | ExpectInitialRecordVersion: clientVers, |
| 4318 | }, |
| 4319 | }, |
| 4320 | flags: []string{"-max-version", shimVersFlag}, |
| 4321 | expectedVersion: expectedVersion, |
| 4322 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4323 | |
| 4324 | testCases = append(testCases, testCase{ |
| 4325 | protocol: protocol, |
| 4326 | testType: serverTest, |
| 4327 | name: "VersionNegotiation-Server-" + suffix, |
| 4328 | config: Config{ |
| 4329 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4330 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4331 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4332 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4333 | }, |
| 4334 | flags: flags, |
| 4335 | expectedVersion: expectedVersion, |
| 4336 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4337 | testCases = append(testCases, testCase{ |
| 4338 | protocol: protocol, |
| 4339 | testType: serverTest, |
| 4340 | name: "VersionNegotiation-Server2-" + suffix, |
| 4341 | config: Config{ |
| 4342 | MaxVersion: runnerVers.version, |
| 4343 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4344 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4345 | }, |
| 4346 | }, |
| 4347 | flags: []string{"-max-version", shimVersFlag}, |
| 4348 | expectedVersion: expectedVersion, |
| 4349 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4350 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4351 | } |
| 4352 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4353 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4354 | // Test the version extension at all versions. |
| 4355 | for _, vers := range tlsVersions { |
| 4356 | protocols := []protocol{tls} |
| 4357 | if vers.hasDTLS { |
| 4358 | protocols = append(protocols, dtls) |
| 4359 | } |
| 4360 | for _, protocol := range protocols { |
| 4361 | suffix := vers.name |
| 4362 | if protocol == dtls { |
| 4363 | suffix += "-DTLS" |
| 4364 | } |
| 4365 | |
| 4366 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4367 | testCases = append(testCases, testCase{ |
| 4368 | protocol: protocol, |
| 4369 | testType: serverTest, |
| 4370 | name: "VersionNegotiationExtension-" + suffix, |
| 4371 | config: Config{ |
| 4372 | Bugs: ProtocolBugs{ |
| 4373 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4374 | }, |
| 4375 | }, |
| 4376 | expectedVersion: vers.version, |
| 4377 | }) |
| 4378 | } |
| 4379 | |
| 4380 | } |
| 4381 | |
| 4382 | // If all versions are unknown, negotiation fails. |
| 4383 | testCases = append(testCases, testCase{ |
| 4384 | testType: serverTest, |
| 4385 | name: "NoSupportedVersions", |
| 4386 | config: Config{ |
| 4387 | Bugs: ProtocolBugs{ |
| 4388 | SendSupportedVersions: []uint16{0x1111}, |
| 4389 | }, |
| 4390 | }, |
| 4391 | shouldFail: true, |
| 4392 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4393 | }) |
| 4394 | testCases = append(testCases, testCase{ |
| 4395 | protocol: dtls, |
| 4396 | testType: serverTest, |
| 4397 | name: "NoSupportedVersions-DTLS", |
| 4398 | config: Config{ |
| 4399 | Bugs: ProtocolBugs{ |
| 4400 | SendSupportedVersions: []uint16{0x1111}, |
| 4401 | }, |
| 4402 | }, |
| 4403 | shouldFail: true, |
| 4404 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4405 | }) |
| 4406 | |
| 4407 | testCases = append(testCases, testCase{ |
| 4408 | testType: serverTest, |
| 4409 | name: "ClientHelloVersionTooHigh", |
| 4410 | config: Config{ |
| 4411 | MaxVersion: VersionTLS13, |
| 4412 | Bugs: ProtocolBugs{ |
| 4413 | SendClientVersion: 0x0304, |
| 4414 | OmitSupportedVersions: true, |
| 4415 | }, |
| 4416 | }, |
| 4417 | expectedVersion: VersionTLS12, |
| 4418 | }) |
| 4419 | |
| 4420 | testCases = append(testCases, testCase{ |
| 4421 | testType: serverTest, |
| 4422 | name: "ConflictingVersionNegotiation", |
| 4423 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4424 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4425 | SendClientVersion: VersionTLS12, |
| 4426 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4427 | }, |
| 4428 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4429 | // The extension takes precedence over the ClientHello version. |
| 4430 | expectedVersion: VersionTLS11, |
| 4431 | }) |
| 4432 | |
| 4433 | testCases = append(testCases, testCase{ |
| 4434 | testType: serverTest, |
| 4435 | name: "ConflictingVersionNegotiation-2", |
| 4436 | config: Config{ |
| 4437 | Bugs: ProtocolBugs{ |
| 4438 | SendClientVersion: VersionTLS11, |
| 4439 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4440 | }, |
| 4441 | }, |
| 4442 | // The extension takes precedence over the ClientHello version. |
| 4443 | expectedVersion: VersionTLS12, |
| 4444 | }) |
| 4445 | |
| 4446 | testCases = append(testCases, testCase{ |
| 4447 | testType: serverTest, |
| 4448 | name: "RejectFinalTLS13", |
| 4449 | config: Config{ |
| 4450 | Bugs: ProtocolBugs{ |
| 4451 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4452 | }, |
| 4453 | }, |
| 4454 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4455 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4456 | expectedVersion: VersionTLS12, |
| 4457 | }) |
| 4458 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4459 | // Test that the maximum version is selected regardless of the |
| 4460 | // client-sent order. |
| 4461 | testCases = append(testCases, testCase{ |
| 4462 | testType: serverTest, |
| 4463 | name: "IgnoreClientVersionOrder", |
| 4464 | config: Config{ |
| 4465 | Bugs: ProtocolBugs{ |
| 4466 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4467 | }, |
| 4468 | }, |
| 4469 | expectedVersion: VersionTLS13, |
| 4470 | }) |
| 4471 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4472 | // Test for version tolerance. |
| 4473 | testCases = append(testCases, testCase{ |
| 4474 | testType: serverTest, |
| 4475 | name: "MinorVersionTolerance", |
| 4476 | config: Config{ |
| 4477 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4478 | SendClientVersion: 0x03ff, |
| 4479 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4480 | }, |
| 4481 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4482 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4483 | }) |
| 4484 | testCases = append(testCases, testCase{ |
| 4485 | testType: serverTest, |
| 4486 | name: "MajorVersionTolerance", |
| 4487 | config: Config{ |
| 4488 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4489 | SendClientVersion: 0x0400, |
| 4490 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4491 | }, |
| 4492 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4493 | // TLS 1.3 must be negotiated with the supported_versions |
| 4494 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4495 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4496 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4497 | testCases = append(testCases, testCase{ |
| 4498 | testType: serverTest, |
| 4499 | name: "VersionTolerance-TLS13", |
| 4500 | config: Config{ |
| 4501 | Bugs: ProtocolBugs{ |
| 4502 | // Although TLS 1.3 does not use |
| 4503 | // ClientHello.version, it still tolerates high |
| 4504 | // values there. |
| 4505 | SendClientVersion: 0x0400, |
| 4506 | }, |
| 4507 | }, |
| 4508 | expectedVersion: VersionTLS13, |
| 4509 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4510 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4511 | testCases = append(testCases, testCase{ |
| 4512 | protocol: dtls, |
| 4513 | testType: serverTest, |
| 4514 | name: "MinorVersionTolerance-DTLS", |
| 4515 | config: Config{ |
| 4516 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4517 | SendClientVersion: 0xfe00, |
| 4518 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4519 | }, |
| 4520 | }, |
| 4521 | expectedVersion: VersionTLS12, |
| 4522 | }) |
| 4523 | testCases = append(testCases, testCase{ |
| 4524 | protocol: dtls, |
| 4525 | testType: serverTest, |
| 4526 | name: "MajorVersionTolerance-DTLS", |
| 4527 | config: Config{ |
| 4528 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4529 | SendClientVersion: 0xfdff, |
| 4530 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4531 | }, |
| 4532 | }, |
| 4533 | expectedVersion: VersionTLS12, |
| 4534 | }) |
| 4535 | |
| 4536 | // Test that versions below 3.0 are rejected. |
| 4537 | testCases = append(testCases, testCase{ |
| 4538 | testType: serverTest, |
| 4539 | name: "VersionTooLow", |
| 4540 | config: Config{ |
| 4541 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4542 | SendClientVersion: 0x0200, |
| 4543 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4544 | }, |
| 4545 | }, |
| 4546 | shouldFail: true, |
| 4547 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4548 | }) |
| 4549 | testCases = append(testCases, testCase{ |
| 4550 | protocol: dtls, |
| 4551 | testType: serverTest, |
| 4552 | name: "VersionTooLow-DTLS", |
| 4553 | config: Config{ |
| 4554 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4555 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4556 | }, |
| 4557 | }, |
| 4558 | shouldFail: true, |
| 4559 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4560 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4561 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4562 | testCases = append(testCases, testCase{ |
| 4563 | name: "ServerBogusVersion", |
| 4564 | config: Config{ |
| 4565 | Bugs: ProtocolBugs{ |
| 4566 | SendServerHelloVersion: 0x1234, |
| 4567 | }, |
| 4568 | }, |
| 4569 | shouldFail: true, |
| 4570 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4571 | }) |
| 4572 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4573 | // Test TLS 1.3's downgrade signal. |
| 4574 | testCases = append(testCases, testCase{ |
| 4575 | name: "Downgrade-TLS12-Client", |
| 4576 | config: Config{ |
| 4577 | Bugs: ProtocolBugs{ |
| 4578 | NegotiateVersion: VersionTLS12, |
| 4579 | }, |
| 4580 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4581 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4582 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4583 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4584 | }) |
| 4585 | testCases = append(testCases, testCase{ |
| 4586 | testType: serverTest, |
| 4587 | name: "Downgrade-TLS12-Server", |
| 4588 | config: Config{ |
| 4589 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4590 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4591 | }, |
| 4592 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4593 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4594 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4595 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4596 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4597 | } |
| 4598 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4599 | func addMinimumVersionTests() { |
| 4600 | for i, shimVers := range tlsVersions { |
| 4601 | // Assemble flags to disable all older versions on the shim. |
| 4602 | var flags []string |
| 4603 | for _, vers := range tlsVersions[:i] { |
| 4604 | flags = append(flags, vers.flag) |
| 4605 | } |
| 4606 | |
| 4607 | for _, runnerVers := range tlsVersions { |
| 4608 | protocols := []protocol{tls} |
| 4609 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4610 | protocols = append(protocols, dtls) |
| 4611 | } |
| 4612 | for _, protocol := range protocols { |
| 4613 | suffix := shimVers.name + "-" + runnerVers.name |
| 4614 | if protocol == dtls { |
| 4615 | suffix += "-DTLS" |
| 4616 | } |
| 4617 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4618 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4619 | var expectedVersion uint16 |
| 4620 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4621 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4622 | if runnerVers.version >= shimVers.version { |
| 4623 | expectedVersion = runnerVers.version |
| 4624 | } else { |
| 4625 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4626 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4627 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4628 | } |
| 4629 | |
| 4630 | testCases = append(testCases, testCase{ |
| 4631 | protocol: protocol, |
| 4632 | testType: clientTest, |
| 4633 | name: "MinimumVersion-Client-" + suffix, |
| 4634 | config: Config{ |
| 4635 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4636 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4637 | // Ensure the server does not decline to |
| 4638 | // select a version (versions extension) or |
| 4639 | // cipher (some ciphers depend on versions). |
| 4640 | NegotiateVersion: runnerVers.version, |
| 4641 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4642 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4643 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4644 | flags: flags, |
| 4645 | expectedVersion: expectedVersion, |
| 4646 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4647 | expectedError: expectedError, |
| 4648 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4649 | }) |
| 4650 | testCases = append(testCases, testCase{ |
| 4651 | protocol: protocol, |
| 4652 | testType: clientTest, |
| 4653 | name: "MinimumVersion-Client2-" + suffix, |
| 4654 | config: Config{ |
| 4655 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4656 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4657 | // Ensure the server does not decline to |
| 4658 | // select a version (versions extension) or |
| 4659 | // cipher (some ciphers depend on versions). |
| 4660 | NegotiateVersion: runnerVers.version, |
| 4661 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4662 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4663 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4664 | flags: []string{"-min-version", shimVersFlag}, |
| 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 | |
| 4671 | testCases = append(testCases, testCase{ |
| 4672 | protocol: protocol, |
| 4673 | testType: serverTest, |
| 4674 | name: "MinimumVersion-Server-" + suffix, |
| 4675 | config: Config{ |
| 4676 | MaxVersion: runnerVers.version, |
| 4677 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4678 | flags: flags, |
| 4679 | expectedVersion: expectedVersion, |
| 4680 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4681 | expectedError: expectedError, |
| 4682 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4683 | }) |
| 4684 | testCases = append(testCases, testCase{ |
| 4685 | protocol: protocol, |
| 4686 | testType: serverTest, |
| 4687 | name: "MinimumVersion-Server2-" + suffix, |
| 4688 | config: Config{ |
| 4689 | MaxVersion: runnerVers.version, |
| 4690 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4691 | flags: []string{"-min-version", shimVersFlag}, |
| 4692 | expectedVersion: expectedVersion, |
| 4693 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4694 | expectedError: expectedError, |
| 4695 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4696 | }) |
| 4697 | } |
| 4698 | } |
| 4699 | } |
| 4700 | } |
| 4701 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4702 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4703 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4704 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4705 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4706 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4707 | // Repeat extensions tests all versions except SSL 3.0. |
| 4708 | for _, ver := range tlsVersions { |
| 4709 | if ver.version == VersionSSL30 { |
| 4710 | continue |
| 4711 | } |
| 4712 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4713 | // Test that duplicate extensions are rejected. |
| 4714 | testCases = append(testCases, testCase{ |
| 4715 | testType: clientTest, |
| 4716 | name: "DuplicateExtensionClient-" + ver.name, |
| 4717 | config: Config{ |
| 4718 | MaxVersion: ver.version, |
| 4719 | Bugs: ProtocolBugs{ |
| 4720 | DuplicateExtension: true, |
| 4721 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4722 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4723 | shouldFail: true, |
| 4724 | expectedLocalError: "remote error: error decoding message", |
| 4725 | }) |
| 4726 | testCases = append(testCases, testCase{ |
| 4727 | testType: serverTest, |
| 4728 | name: "DuplicateExtensionServer-" + ver.name, |
| 4729 | config: Config{ |
| 4730 | MaxVersion: ver.version, |
| 4731 | Bugs: ProtocolBugs{ |
| 4732 | DuplicateExtension: true, |
| 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 | shouldFail: true, |
| 4736 | expectedLocalError: "remote error: error decoding message", |
| 4737 | }) |
| 4738 | |
| 4739 | // Test SNI. |
| 4740 | testCases = append(testCases, testCase{ |
| 4741 | testType: clientTest, |
| 4742 | name: "ServerNameExtensionClient-" + ver.name, |
| 4743 | config: Config{ |
| 4744 | MaxVersion: ver.version, |
| 4745 | Bugs: ProtocolBugs{ |
| 4746 | ExpectServerName: "example.com", |
| 4747 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4748 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4749 | flags: []string{"-host-name", "example.com"}, |
| 4750 | }) |
| 4751 | testCases = append(testCases, testCase{ |
| 4752 | testType: clientTest, |
| 4753 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4754 | config: Config{ |
| 4755 | MaxVersion: ver.version, |
| 4756 | Bugs: ProtocolBugs{ |
| 4757 | ExpectServerName: "mismatch.com", |
| 4758 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4759 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4760 | flags: []string{"-host-name", "example.com"}, |
| 4761 | shouldFail: true, |
| 4762 | expectedLocalError: "tls: unexpected server name", |
| 4763 | }) |
| 4764 | testCases = append(testCases, testCase{ |
| 4765 | testType: clientTest, |
| 4766 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4767 | config: Config{ |
| 4768 | MaxVersion: ver.version, |
| 4769 | Bugs: ProtocolBugs{ |
| 4770 | ExpectServerName: "missing.com", |
| 4771 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4772 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4773 | shouldFail: true, |
| 4774 | expectedLocalError: "tls: unexpected server name", |
| 4775 | }) |
| 4776 | testCases = append(testCases, testCase{ |
| 4777 | testType: serverTest, |
| 4778 | name: "ServerNameExtensionServer-" + ver.name, |
| 4779 | config: Config{ |
| 4780 | MaxVersion: ver.version, |
| 4781 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4782 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4783 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4784 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4785 | }) |
| 4786 | |
| 4787 | // Test ALPN. |
| 4788 | testCases = append(testCases, testCase{ |
| 4789 | testType: clientTest, |
| 4790 | name: "ALPNClient-" + ver.name, |
| 4791 | config: Config{ |
| 4792 | MaxVersion: ver.version, |
| 4793 | NextProtos: []string{"foo"}, |
| 4794 | }, |
| 4795 | flags: []string{ |
| 4796 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4797 | "-expect-alpn", "foo", |
| 4798 | }, |
| 4799 | expectedNextProto: "foo", |
| 4800 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4801 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4802 | }) |
| 4803 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4804 | testType: clientTest, |
| 4805 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4806 | config: Config{ |
| 4807 | MaxVersion: ver.version, |
| 4808 | Bugs: ProtocolBugs{ |
| 4809 | SendALPN: "baz", |
| 4810 | }, |
| 4811 | }, |
| 4812 | flags: []string{ |
| 4813 | "-advertise-alpn", "\x03foo\x03bar", |
| 4814 | }, |
| 4815 | shouldFail: true, |
| 4816 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4817 | expectedLocalError: "remote error: illegal parameter", |
| 4818 | }) |
| 4819 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4820 | testType: serverTest, |
| 4821 | name: "ALPNServer-" + ver.name, |
| 4822 | config: Config{ |
| 4823 | MaxVersion: ver.version, |
| 4824 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4825 | }, |
| 4826 | flags: []string{ |
| 4827 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4828 | "-select-alpn", "foo", |
| 4829 | }, |
| 4830 | expectedNextProto: "foo", |
| 4831 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4832 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4833 | }) |
| 4834 | testCases = append(testCases, testCase{ |
| 4835 | testType: serverTest, |
| 4836 | name: "ALPNServer-Decline-" + ver.name, |
| 4837 | config: Config{ |
| 4838 | MaxVersion: ver.version, |
| 4839 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4840 | }, |
| 4841 | flags: []string{"-decline-alpn"}, |
| 4842 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4843 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4844 | }) |
| 4845 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4846 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4847 | // called once. |
| 4848 | testCases = append(testCases, testCase{ |
| 4849 | testType: serverTest, |
| 4850 | name: "ALPNServer-Async-" + ver.name, |
| 4851 | config: Config{ |
| 4852 | MaxVersion: ver.version, |
| 4853 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4854 | }, |
| 4855 | flags: []string{ |
| 4856 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4857 | "-select-alpn", "foo", |
| 4858 | "-async", |
| 4859 | }, |
| 4860 | expectedNextProto: "foo", |
| 4861 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4862 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4863 | }) |
| 4864 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4865 | var emptyString string |
| 4866 | testCases = append(testCases, testCase{ |
| 4867 | testType: clientTest, |
| 4868 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4869 | config: Config{ |
| 4870 | MaxVersion: ver.version, |
| 4871 | NextProtos: []string{""}, |
| 4872 | Bugs: ProtocolBugs{ |
| 4873 | // A server returning an empty ALPN protocol |
| 4874 | // should be rejected. |
| 4875 | ALPNProtocol: &emptyString, |
| 4876 | }, |
| 4877 | }, |
| 4878 | flags: []string{ |
| 4879 | "-advertise-alpn", "\x03foo", |
| 4880 | }, |
| 4881 | shouldFail: true, |
| 4882 | expectedError: ":PARSE_TLSEXT:", |
| 4883 | }) |
| 4884 | testCases = append(testCases, testCase{ |
| 4885 | testType: serverTest, |
| 4886 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4887 | config: Config{ |
| 4888 | MaxVersion: ver.version, |
| 4889 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4890 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4891 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4892 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4893 | flags: []string{ |
| 4894 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4895 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4896 | shouldFail: true, |
| 4897 | expectedError: ":PARSE_TLSEXT:", |
| 4898 | }) |
| 4899 | |
| 4900 | // Test NPN and the interaction with ALPN. |
| 4901 | if ver.version < VersionTLS13 { |
| 4902 | // Test that the server prefers ALPN over NPN. |
| 4903 | testCases = append(testCases, testCase{ |
| 4904 | testType: serverTest, |
| 4905 | name: "ALPNServer-Preferred-" + ver.name, |
| 4906 | config: Config{ |
| 4907 | MaxVersion: ver.version, |
| 4908 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4909 | }, |
| 4910 | flags: []string{ |
| 4911 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4912 | "-select-alpn", "foo", |
| 4913 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4914 | }, |
| 4915 | expectedNextProto: "foo", |
| 4916 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4917 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4918 | }) |
| 4919 | testCases = append(testCases, testCase{ |
| 4920 | testType: serverTest, |
| 4921 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4922 | config: Config{ |
| 4923 | MaxVersion: ver.version, |
| 4924 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4925 | Bugs: ProtocolBugs{ |
| 4926 | SwapNPNAndALPN: true, |
| 4927 | }, |
| 4928 | }, |
| 4929 | flags: []string{ |
| 4930 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4931 | "-select-alpn", "foo", |
| 4932 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4933 | }, |
| 4934 | expectedNextProto: "foo", |
| 4935 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4936 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4937 | }) |
| 4938 | |
| 4939 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4940 | testCases = append(testCases, testCase{ |
| 4941 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4942 | config: Config{ |
| 4943 | MaxVersion: ver.version, |
| 4944 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4945 | Bugs: ProtocolBugs{ |
| 4946 | NegotiateALPNAndNPN: true, |
| 4947 | }, |
| 4948 | }, |
| 4949 | flags: []string{ |
| 4950 | "-advertise-alpn", "\x03foo", |
| 4951 | "-select-next-proto", "foo", |
| 4952 | }, |
| 4953 | shouldFail: true, |
| 4954 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4955 | }) |
| 4956 | testCases = append(testCases, testCase{ |
| 4957 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4958 | config: Config{ |
| 4959 | MaxVersion: ver.version, |
| 4960 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4961 | Bugs: ProtocolBugs{ |
| 4962 | NegotiateALPNAndNPN: true, |
| 4963 | SwapNPNAndALPN: true, |
| 4964 | }, |
| 4965 | }, |
| 4966 | flags: []string{ |
| 4967 | "-advertise-alpn", "\x03foo", |
| 4968 | "-select-next-proto", "foo", |
| 4969 | }, |
| 4970 | shouldFail: true, |
| 4971 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4972 | }) |
| 4973 | |
| 4974 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4975 | testCases = append(testCases, testCase{ |
| 4976 | name: "DisableNPN-" + ver.name, |
| 4977 | config: Config{ |
| 4978 | MaxVersion: ver.version, |
| 4979 | NextProtos: []string{"foo"}, |
| 4980 | }, |
| 4981 | flags: []string{ |
| 4982 | "-select-next-proto", "foo", |
| 4983 | "-disable-npn", |
| 4984 | }, |
| 4985 | expectNoNextProto: true, |
| 4986 | }) |
| 4987 | } |
| 4988 | |
| 4989 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4990 | |
| 4991 | // Resume with a corrupt ticket. |
| 4992 | testCases = append(testCases, testCase{ |
| 4993 | testType: serverTest, |
| 4994 | name: "CorruptTicket-" + ver.name, |
| 4995 | config: Config{ |
| 4996 | MaxVersion: ver.version, |
| 4997 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 4998 | FilterTicket: func(in []byte) ([]byte, error) { |
| 4999 | in[len(in)-1] ^= 1 |
| 5000 | return in, nil |
| 5001 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5002 | }, |
| 5003 | }, |
| 5004 | resumeSession: true, |
| 5005 | expectResumeRejected: true, |
| 5006 | }) |
| 5007 | // Test the ticket callback, with and without renewal. |
| 5008 | testCases = append(testCases, testCase{ |
| 5009 | testType: serverTest, |
| 5010 | name: "TicketCallback-" + ver.name, |
| 5011 | config: Config{ |
| 5012 | MaxVersion: ver.version, |
| 5013 | }, |
| 5014 | resumeSession: true, |
| 5015 | flags: []string{"-use-ticket-callback"}, |
| 5016 | }) |
| 5017 | testCases = append(testCases, testCase{ |
| 5018 | testType: serverTest, |
| 5019 | name: "TicketCallback-Renew-" + ver.name, |
| 5020 | config: Config{ |
| 5021 | MaxVersion: ver.version, |
| 5022 | Bugs: ProtocolBugs{ |
| 5023 | ExpectNewTicket: true, |
| 5024 | }, |
| 5025 | }, |
| 5026 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5027 | resumeSession: true, |
| 5028 | }) |
| 5029 | |
| 5030 | // Test that the ticket callback is only called once when everything before |
| 5031 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5032 | // certificate selection callbacks run. |
| 5033 | testCases = append(testCases, testCase{ |
| 5034 | testType: serverTest, |
| 5035 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5036 | config: Config{ |
| 5037 | MaxVersion: ver.version, |
| 5038 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5039 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5040 | in[len(in)-1] ^= 1 |
| 5041 | return in, nil |
| 5042 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5043 | }, |
| 5044 | }, |
| 5045 | resumeSession: true, |
| 5046 | expectResumeRejected: true, |
| 5047 | flags: []string{ |
| 5048 | "-use-ticket-callback", |
| 5049 | "-async", |
| 5050 | }, |
| 5051 | }) |
| 5052 | |
| 5053 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5054 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5055 | testCases = append(testCases, testCase{ |
| 5056 | testType: serverTest, |
| 5057 | name: "OversizedSessionId-" + ver.name, |
| 5058 | config: Config{ |
| 5059 | MaxVersion: ver.version, |
| 5060 | Bugs: ProtocolBugs{ |
| 5061 | OversizedSessionId: true, |
| 5062 | }, |
| 5063 | }, |
| 5064 | resumeSession: true, |
| 5065 | shouldFail: true, |
| 5066 | expectedError: ":DECODE_ERROR:", |
| 5067 | }) |
| 5068 | } |
| 5069 | |
| 5070 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5071 | // are ignored. |
| 5072 | if ver.hasDTLS { |
| 5073 | testCases = append(testCases, testCase{ |
| 5074 | protocol: dtls, |
| 5075 | name: "SRTP-Client-" + ver.name, |
| 5076 | config: Config{ |
| 5077 | MaxVersion: ver.version, |
| 5078 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5079 | }, |
| 5080 | flags: []string{ |
| 5081 | "-srtp-profiles", |
| 5082 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5083 | }, |
| 5084 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5085 | }) |
| 5086 | testCases = append(testCases, testCase{ |
| 5087 | protocol: dtls, |
| 5088 | testType: serverTest, |
| 5089 | name: "SRTP-Server-" + ver.name, |
| 5090 | config: Config{ |
| 5091 | MaxVersion: ver.version, |
| 5092 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5093 | }, |
| 5094 | flags: []string{ |
| 5095 | "-srtp-profiles", |
| 5096 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5097 | }, |
| 5098 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5099 | }) |
| 5100 | // Test that the MKI is ignored. |
| 5101 | testCases = append(testCases, testCase{ |
| 5102 | protocol: dtls, |
| 5103 | testType: serverTest, |
| 5104 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5105 | config: Config{ |
| 5106 | MaxVersion: ver.version, |
| 5107 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5108 | Bugs: ProtocolBugs{ |
| 5109 | SRTPMasterKeyIdentifer: "bogus", |
| 5110 | }, |
| 5111 | }, |
| 5112 | flags: []string{ |
| 5113 | "-srtp-profiles", |
| 5114 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5115 | }, |
| 5116 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5117 | }) |
| 5118 | // Test that SRTP isn't negotiated on the server if there were |
| 5119 | // no matching profiles. |
| 5120 | testCases = append(testCases, testCase{ |
| 5121 | protocol: dtls, |
| 5122 | testType: serverTest, |
| 5123 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5124 | config: Config{ |
| 5125 | MaxVersion: ver.version, |
| 5126 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5127 | }, |
| 5128 | flags: []string{ |
| 5129 | "-srtp-profiles", |
| 5130 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5131 | }, |
| 5132 | expectedSRTPProtectionProfile: 0, |
| 5133 | }) |
| 5134 | // Test that the server returning an invalid SRTP profile is |
| 5135 | // flagged as an error by the client. |
| 5136 | testCases = append(testCases, testCase{ |
| 5137 | protocol: dtls, |
| 5138 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5139 | config: Config{ |
| 5140 | MaxVersion: ver.version, |
| 5141 | Bugs: ProtocolBugs{ |
| 5142 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5143 | }, |
| 5144 | }, |
| 5145 | flags: []string{ |
| 5146 | "-srtp-profiles", |
| 5147 | "SRTP_AES128_CM_SHA1_80", |
| 5148 | }, |
| 5149 | shouldFail: true, |
| 5150 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5151 | }) |
| 5152 | } |
| 5153 | |
| 5154 | // Test SCT list. |
| 5155 | testCases = append(testCases, testCase{ |
| 5156 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5157 | testType: clientTest, |
| 5158 | config: Config{ |
| 5159 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5160 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5161 | flags: []string{ |
| 5162 | "-enable-signed-cert-timestamps", |
| 5163 | "-expect-signed-cert-timestamps", |
| 5164 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5165 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5166 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5167 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5168 | |
| 5169 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5170 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5171 | testCases = append(testCases, testCase{ |
| 5172 | name: "SendSCTListOnResume-" + ver.name, |
| 5173 | config: Config{ |
| 5174 | MaxVersion: ver.version, |
| 5175 | Bugs: ProtocolBugs{ |
| 5176 | SendSCTListOnResume: []byte("bogus"), |
| 5177 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5178 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5179 | flags: []string{ |
| 5180 | "-enable-signed-cert-timestamps", |
| 5181 | "-expect-signed-cert-timestamps", |
| 5182 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5183 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5184 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5185 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5186 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5187 | testCases = append(testCases, testCase{ |
| 5188 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5189 | testType: serverTest, |
| 5190 | config: Config{ |
| 5191 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5192 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5193 | flags: []string{ |
| 5194 | "-signed-cert-timestamps", |
| 5195 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5196 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5197 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5198 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5199 | }) |
| 5200 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5201 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5202 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5203 | testType: clientTest, |
| 5204 | name: "ClientHelloPadding", |
| 5205 | config: Config{ |
| 5206 | Bugs: ProtocolBugs{ |
| 5207 | RequireClientHelloSize: 512, |
| 5208 | }, |
| 5209 | }, |
| 5210 | // This hostname just needs to be long enough to push the |
| 5211 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5212 | // long. |
| 5213 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5214 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5215 | |
| 5216 | // Extensions should not function in SSL 3.0. |
| 5217 | testCases = append(testCases, testCase{ |
| 5218 | testType: serverTest, |
| 5219 | name: "SSLv3Extensions-NoALPN", |
| 5220 | config: Config{ |
| 5221 | MaxVersion: VersionSSL30, |
| 5222 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5223 | }, |
| 5224 | flags: []string{ |
| 5225 | "-select-alpn", "foo", |
| 5226 | }, |
| 5227 | expectNoNextProto: true, |
| 5228 | }) |
| 5229 | |
| 5230 | // Test session tickets separately as they follow a different codepath. |
| 5231 | testCases = append(testCases, testCase{ |
| 5232 | testType: serverTest, |
| 5233 | name: "SSLv3Extensions-NoTickets", |
| 5234 | config: Config{ |
| 5235 | MaxVersion: VersionSSL30, |
| 5236 | Bugs: ProtocolBugs{ |
| 5237 | // Historically, session tickets in SSL 3.0 |
| 5238 | // failed in different ways depending on whether |
| 5239 | // the client supported renegotiation_info. |
| 5240 | NoRenegotiationInfo: true, |
| 5241 | }, |
| 5242 | }, |
| 5243 | resumeSession: true, |
| 5244 | }) |
| 5245 | testCases = append(testCases, testCase{ |
| 5246 | testType: serverTest, |
| 5247 | name: "SSLv3Extensions-NoTickets2", |
| 5248 | config: Config{ |
| 5249 | MaxVersion: VersionSSL30, |
| 5250 | }, |
| 5251 | resumeSession: true, |
| 5252 | }) |
| 5253 | |
| 5254 | // But SSL 3.0 does send and process renegotiation_info. |
| 5255 | testCases = append(testCases, testCase{ |
| 5256 | testType: serverTest, |
| 5257 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5258 | config: Config{ |
| 5259 | MaxVersion: VersionSSL30, |
| 5260 | Bugs: ProtocolBugs{ |
| 5261 | RequireRenegotiationInfo: true, |
| 5262 | }, |
| 5263 | }, |
| 5264 | }) |
| 5265 | testCases = append(testCases, testCase{ |
| 5266 | testType: serverTest, |
| 5267 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5268 | config: Config{ |
| 5269 | MaxVersion: VersionSSL30, |
| 5270 | Bugs: ProtocolBugs{ |
| 5271 | NoRenegotiationInfo: true, |
| 5272 | SendRenegotiationSCSV: true, |
| 5273 | RequireRenegotiationInfo: true, |
| 5274 | }, |
| 5275 | }, |
| 5276 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5277 | |
| 5278 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5279 | // in ServerHello. |
| 5280 | testCases = append(testCases, testCase{ |
| 5281 | name: "NPN-Forbidden-TLS13", |
| 5282 | config: Config{ |
| 5283 | MaxVersion: VersionTLS13, |
| 5284 | NextProtos: []string{"foo"}, |
| 5285 | Bugs: ProtocolBugs{ |
| 5286 | NegotiateNPNAtAllVersions: true, |
| 5287 | }, |
| 5288 | }, |
| 5289 | flags: []string{"-select-next-proto", "foo"}, |
| 5290 | shouldFail: true, |
| 5291 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5292 | }) |
| 5293 | testCases = append(testCases, testCase{ |
| 5294 | name: "EMS-Forbidden-TLS13", |
| 5295 | config: Config{ |
| 5296 | MaxVersion: VersionTLS13, |
| 5297 | Bugs: ProtocolBugs{ |
| 5298 | NegotiateEMSAtAllVersions: true, |
| 5299 | }, |
| 5300 | }, |
| 5301 | shouldFail: true, |
| 5302 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5303 | }) |
| 5304 | testCases = append(testCases, testCase{ |
| 5305 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5306 | config: Config{ |
| 5307 | MaxVersion: VersionTLS13, |
| 5308 | Bugs: ProtocolBugs{ |
| 5309 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5310 | }, |
| 5311 | }, |
| 5312 | shouldFail: true, |
| 5313 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5314 | }) |
| 5315 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5316 | name: "Ticket-Forbidden-TLS13", |
| 5317 | config: Config{ |
| 5318 | MaxVersion: VersionTLS12, |
| 5319 | }, |
| 5320 | resumeConfig: &Config{ |
| 5321 | MaxVersion: VersionTLS13, |
| 5322 | Bugs: ProtocolBugs{ |
| 5323 | AdvertiseTicketExtension: true, |
| 5324 | }, |
| 5325 | }, |
| 5326 | resumeSession: true, |
| 5327 | shouldFail: true, |
| 5328 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5329 | }) |
| 5330 | |
| 5331 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5332 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5333 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5334 | // implicit in every test.) |
| 5335 | testCases = append(testCases, testCase{ |
| 5336 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5337 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5338 | config: Config{ |
| 5339 | MaxVersion: VersionTLS13, |
| 5340 | NextProtos: []string{"bar"}, |
| 5341 | }, |
| 5342 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5343 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5344 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5345 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5346 | // tolerated. |
| 5347 | testCases = append(testCases, testCase{ |
| 5348 | name: "SendOCSPResponseOnResume-TLS12", |
| 5349 | config: Config{ |
| 5350 | MaxVersion: VersionTLS12, |
| 5351 | Bugs: ProtocolBugs{ |
| 5352 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5353 | }, |
| 5354 | }, |
| 5355 | flags: []string{ |
| 5356 | "-enable-ocsp-stapling", |
| 5357 | "-expect-ocsp-response", |
| 5358 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5359 | }, |
| 5360 | resumeSession: true, |
| 5361 | }) |
| 5362 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5363 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5364 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5365 | config: Config{ |
| 5366 | MaxVersion: VersionTLS13, |
| 5367 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5368 | SendExtensionOnCertificate: testOCSPExtension, |
| 5369 | }, |
| 5370 | }, |
| 5371 | shouldFail: true, |
| 5372 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5373 | }) |
| 5374 | |
| 5375 | testCases = append(testCases, testCase{ |
| 5376 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5377 | config: Config{ |
| 5378 | MaxVersion: VersionTLS13, |
| 5379 | Bugs: ProtocolBugs{ |
| 5380 | SendExtensionOnCertificate: testSCTExtension, |
| 5381 | }, |
| 5382 | }, |
| 5383 | shouldFail: true, |
| 5384 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5385 | }) |
| 5386 | |
| 5387 | // Test that extensions on client certificates are never accepted. |
| 5388 | testCases = append(testCases, testCase{ |
| 5389 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5390 | testType: serverTest, |
| 5391 | config: Config{ |
| 5392 | MaxVersion: VersionTLS13, |
| 5393 | Certificates: []Certificate{rsaCertificate}, |
| 5394 | Bugs: ProtocolBugs{ |
| 5395 | SendExtensionOnCertificate: testOCSPExtension, |
| 5396 | }, |
| 5397 | }, |
| 5398 | flags: []string{ |
| 5399 | "-enable-ocsp-stapling", |
| 5400 | "-require-any-client-certificate", |
| 5401 | }, |
| 5402 | shouldFail: true, |
| 5403 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5404 | }) |
| 5405 | |
| 5406 | testCases = append(testCases, testCase{ |
| 5407 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5408 | config: Config{ |
| 5409 | MaxVersion: VersionTLS13, |
| 5410 | Bugs: ProtocolBugs{ |
| 5411 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5412 | }, |
| 5413 | }, |
| 5414 | shouldFail: true, |
| 5415 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5416 | }) |
| 5417 | |
| 5418 | // Test that extensions on intermediates are allowed but ignored. |
| 5419 | testCases = append(testCases, testCase{ |
| 5420 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5421 | config: Config{ |
| 5422 | MaxVersion: VersionTLS13, |
| 5423 | Certificates: []Certificate{rsaChainCertificate}, |
| 5424 | Bugs: ProtocolBugs{ |
| 5425 | // Send different values on the intermediate. This tests |
| 5426 | // the intermediate's extensions do not override the |
| 5427 | // leaf's. |
| 5428 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
| 5429 | SendSCTOnIntermediates: []byte{1, 3, 3, 7}, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5430 | }, |
| 5431 | }, |
| 5432 | flags: []string{ |
| 5433 | "-enable-ocsp-stapling", |
| 5434 | "-expect-ocsp-response", |
| 5435 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5436 | "-enable-signed-cert-timestamps", |
| 5437 | "-expect-signed-cert-timestamps", |
| 5438 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5439 | }, |
| 5440 | resumeSession: true, |
| 5441 | }) |
| 5442 | |
| 5443 | // Test that extensions are not sent on intermediates when configured |
| 5444 | // only for a leaf. |
| 5445 | testCases = append(testCases, testCase{ |
| 5446 | testType: serverTest, |
| 5447 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5448 | config: Config{ |
| 5449 | MaxVersion: VersionTLS13, |
| 5450 | Bugs: ProtocolBugs{ |
| 5451 | ExpectNoExtensionsOnIntermediate: true, |
| 5452 | }, |
| 5453 | }, |
| 5454 | flags: []string{ |
| 5455 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5456 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5457 | "-ocsp-response", |
| 5458 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5459 | "-signed-cert-timestamps", |
| 5460 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5461 | }, |
| 5462 | }) |
| 5463 | |
| 5464 | // Test that extensions are not sent on client certificates. |
| 5465 | testCases = append(testCases, testCase{ |
| 5466 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5467 | config: Config{ |
| 5468 | MaxVersion: VersionTLS13, |
| 5469 | ClientAuth: RequireAnyClientCert, |
| 5470 | }, |
| 5471 | flags: []string{ |
| 5472 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5473 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5474 | "-ocsp-response", |
| 5475 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5476 | "-signed-cert-timestamps", |
| 5477 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5478 | }, |
| 5479 | }) |
| 5480 | |
| 5481 | testCases = append(testCases, testCase{ |
| 5482 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5483 | config: Config{ |
| 5484 | MaxVersion: VersionTLS13, |
| 5485 | Bugs: ProtocolBugs{ |
| 5486 | SendDuplicateCertExtensions: true, |
| 5487 | }, |
| 5488 | }, |
| 5489 | flags: []string{ |
| 5490 | "-enable-ocsp-stapling", |
| 5491 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5492 | }, |
| 5493 | resumeSession: true, |
| 5494 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5495 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5496 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5497 | } |
| 5498 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5499 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5500 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5501 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5502 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5503 | // have session IDs, so skip their cross-resumption |
| 5504 | // tests. |
| 5505 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5506 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5507 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5508 | } |
| 5509 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5510 | protocols := []protocol{tls} |
| 5511 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5512 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5513 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5514 | for _, protocol := range protocols { |
| 5515 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5516 | if protocol == dtls { |
| 5517 | suffix += "-DTLS" |
| 5518 | } |
| 5519 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5520 | if sessionVers.version == resumeVers.version { |
| 5521 | testCases = append(testCases, testCase{ |
| 5522 | protocol: protocol, |
| 5523 | name: "Resume-Client" + suffix, |
| 5524 | resumeSession: true, |
| 5525 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5526 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5527 | Bugs: ProtocolBugs{ |
| 5528 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5529 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5530 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5531 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5532 | expectedVersion: sessionVers.version, |
| 5533 | expectedResumeVersion: resumeVers.version, |
| 5534 | }) |
| 5535 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5536 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5537 | |
| 5538 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5539 | // there is no way to convince a non-lookahead client the |
| 5540 | // session was resumed. It will appear to the client that a |
| 5541 | // stray ChangeCipherSpec was sent. |
| 5542 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5543 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5544 | } |
| 5545 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5546 | testCases = append(testCases, testCase{ |
| 5547 | protocol: protocol, |
| 5548 | name: "Resume-Client-Mismatch" + suffix, |
| 5549 | resumeSession: true, |
| 5550 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5551 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5552 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5553 | expectedVersion: sessionVers.version, |
| 5554 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5555 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5556 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5557 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5558 | }, |
| 5559 | }, |
| 5560 | expectedResumeVersion: resumeVers.version, |
| 5561 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5562 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5563 | }) |
| 5564 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5565 | |
| 5566 | testCases = append(testCases, testCase{ |
| 5567 | protocol: protocol, |
| 5568 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5569 | resumeSession: true, |
| 5570 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5571 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5572 | }, |
| 5573 | expectedVersion: sessionVers.version, |
| 5574 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5575 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5576 | }, |
| 5577 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5578 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5579 | expectedResumeVersion: resumeVers.version, |
| 5580 | }) |
| 5581 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5582 | testCases = append(testCases, testCase{ |
| 5583 | protocol: protocol, |
| 5584 | testType: serverTest, |
| 5585 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5586 | resumeSession: true, |
| 5587 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5588 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5589 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5590 | expectedVersion: sessionVers.version, |
| 5591 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5592 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5593 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5594 | Bugs: ProtocolBugs{ |
| 5595 | SendBothTickets: true, |
| 5596 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5597 | }, |
| 5598 | expectedResumeVersion: resumeVers.version, |
| 5599 | }) |
| 5600 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5601 | } |
| 5602 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5603 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5604 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5605 | testCases = append(testCases, testCase{ |
| 5606 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5607 | name: "ShimTicketRewritable", |
| 5608 | resumeSession: true, |
| 5609 | config: Config{ |
| 5610 | MaxVersion: VersionTLS12, |
| 5611 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5612 | Bugs: ProtocolBugs{ |
| 5613 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5614 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5615 | if err != nil { |
| 5616 | return nil, err |
| 5617 | } |
| 5618 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5619 | }, |
| 5620 | }, |
| 5621 | }, |
| 5622 | flags: []string{ |
| 5623 | "-ticket-key", |
| 5624 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5625 | }, |
| 5626 | }) |
| 5627 | |
| 5628 | // Resumptions are declined if the version does not match. |
| 5629 | testCases = append(testCases, testCase{ |
| 5630 | testType: serverTest, |
| 5631 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5632 | resumeSession: true, |
| 5633 | config: Config{ |
| 5634 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5635 | Bugs: ProtocolBugs{ |
| 5636 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5637 | return SetShimTicketVersion(in, VersionTLS13) |
| 5638 | }, |
| 5639 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5640 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5641 | flags: []string{ |
| 5642 | "-ticket-key", |
| 5643 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5644 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5645 | expectResumeRejected: true, |
| 5646 | }) |
| 5647 | |
| 5648 | testCases = append(testCases, testCase{ |
| 5649 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5650 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5651 | resumeSession: true, |
| 5652 | config: Config{ |
| 5653 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5654 | Bugs: ProtocolBugs{ |
| 5655 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5656 | return SetShimTicketVersion(in, VersionTLS12) |
| 5657 | }, |
| 5658 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5659 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5660 | flags: []string{ |
| 5661 | "-ticket-key", |
| 5662 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5663 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5664 | expectResumeRejected: true, |
| 5665 | }) |
| 5666 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5667 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5668 | testCases = append(testCases, testCase{ |
| 5669 | testType: serverTest, |
| 5670 | name: "Resume-Server-DeclineBadCipher", |
| 5671 | resumeSession: true, |
| 5672 | config: Config{ |
| 5673 | MaxVersion: VersionTLS12, |
| 5674 | Bugs: ProtocolBugs{ |
| 5675 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5676 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5677 | }, |
| 5678 | }, |
| 5679 | }, |
| 5680 | flags: []string{ |
| 5681 | "-ticket-key", |
| 5682 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5683 | }, |
| 5684 | expectResumeRejected: true, |
| 5685 | }) |
| 5686 | |
| 5687 | testCases = append(testCases, testCase{ |
| 5688 | testType: serverTest, |
| 5689 | name: "Resume-Server-DeclineBadCipher-2", |
| 5690 | resumeSession: true, |
| 5691 | config: Config{ |
| 5692 | MaxVersion: VersionTLS12, |
| 5693 | Bugs: ProtocolBugs{ |
| 5694 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5695 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5696 | }, |
| 5697 | }, |
| 5698 | }, |
| 5699 | flags: []string{ |
| 5700 | "-cipher", "AES128", |
| 5701 | "-ticket-key", |
| 5702 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5703 | }, |
| 5704 | expectResumeRejected: true, |
| 5705 | }) |
| 5706 | |
| 5707 | testCases = append(testCases, testCase{ |
| 5708 | testType: serverTest, |
| 5709 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5710 | resumeSession: true, |
| 5711 | config: Config{ |
| 5712 | MaxVersion: VersionTLS13, |
| 5713 | Bugs: ProtocolBugs{ |
| 5714 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5715 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5716 | }, |
| 5717 | }, |
| 5718 | }, |
| 5719 | flags: []string{ |
| 5720 | "-ticket-key", |
| 5721 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5722 | }, |
| 5723 | expectResumeRejected: true, |
| 5724 | }) |
| 5725 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5726 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5727 | testCases = append(testCases, testCase{ |
| 5728 | name: "Resume-Client-CipherMismatch", |
| 5729 | resumeSession: true, |
| 5730 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5731 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5732 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5733 | }, |
| 5734 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5735 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5736 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5737 | Bugs: ProtocolBugs{ |
| 5738 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5739 | }, |
| 5740 | }, |
| 5741 | shouldFail: true, |
| 5742 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5743 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5744 | |
| 5745 | testCases = append(testCases, testCase{ |
| 5746 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5747 | resumeSession: true, |
| 5748 | config: Config{ |
| 5749 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5750 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5751 | }, |
| 5752 | resumeConfig: &Config{ |
| 5753 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5754 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5755 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5756 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5757 | }, |
| 5758 | }, |
| 5759 | shouldFail: true, |
| 5760 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5761 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5762 | |
| 5763 | testCases = append(testCases, testCase{ |
| 5764 | testType: serverTest, |
| 5765 | name: "Resume-Server-BinderWrongLength", |
| 5766 | resumeSession: true, |
| 5767 | config: Config{ |
| 5768 | MaxVersion: VersionTLS13, |
| 5769 | Bugs: ProtocolBugs{ |
| 5770 | SendShortPSKBinder: true, |
| 5771 | }, |
| 5772 | }, |
| 5773 | shouldFail: true, |
| 5774 | expectedLocalError: "remote error: error decrypting message", |
| 5775 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5776 | }) |
| 5777 | |
| 5778 | testCases = append(testCases, testCase{ |
| 5779 | testType: serverTest, |
| 5780 | name: "Resume-Server-NoPSKBinder", |
| 5781 | resumeSession: true, |
| 5782 | config: Config{ |
| 5783 | MaxVersion: VersionTLS13, |
| 5784 | Bugs: ProtocolBugs{ |
| 5785 | SendNoPSKBinder: true, |
| 5786 | }, |
| 5787 | }, |
| 5788 | shouldFail: true, |
| 5789 | expectedLocalError: "remote error: error decoding message", |
| 5790 | expectedError: ":DECODE_ERROR:", |
| 5791 | }) |
| 5792 | |
| 5793 | testCases = append(testCases, testCase{ |
| 5794 | testType: serverTest, |
| 5795 | name: "Resume-Server-InvalidPSKBinder", |
| 5796 | resumeSession: true, |
| 5797 | config: Config{ |
| 5798 | MaxVersion: VersionTLS13, |
| 5799 | Bugs: ProtocolBugs{ |
| 5800 | SendInvalidPSKBinder: true, |
| 5801 | }, |
| 5802 | }, |
| 5803 | shouldFail: true, |
| 5804 | expectedLocalError: "remote error: error decrypting message", |
| 5805 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5806 | }) |
| 5807 | |
| 5808 | testCases = append(testCases, testCase{ |
| 5809 | testType: serverTest, |
| 5810 | name: "Resume-Server-PSKBinderFirstExtension", |
| 5811 | resumeSession: true, |
| 5812 | config: Config{ |
| 5813 | MaxVersion: VersionTLS13, |
| 5814 | Bugs: ProtocolBugs{ |
| 5815 | PSKBinderFirst: true, |
| 5816 | }, |
| 5817 | }, |
| 5818 | shouldFail: true, |
| 5819 | expectedLocalError: "remote error: illegal parameter", |
| 5820 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 5821 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5822 | } |
| 5823 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5824 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 5825 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5826 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5827 | testType: serverTest, |
| 5828 | name: "Renegotiate-Server-Forbidden", |
| 5829 | config: Config{ |
| 5830 | MaxVersion: VersionTLS12, |
| 5831 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5832 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5833 | shouldFail: true, |
| 5834 | expectedError: ":NO_RENEGOTIATION:", |
| 5835 | expectedLocalError: "remote error: no renegotiation", |
| 5836 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5837 | // The server shouldn't echo the renegotiation extension unless |
| 5838 | // requested by the client. |
| 5839 | testCases = append(testCases, testCase{ |
| 5840 | testType: serverTest, |
| 5841 | name: "Renegotiate-Server-NoExt", |
| 5842 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5843 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5844 | Bugs: ProtocolBugs{ |
| 5845 | NoRenegotiationInfo: true, |
| 5846 | RequireRenegotiationInfo: true, |
| 5847 | }, |
| 5848 | }, |
| 5849 | shouldFail: true, |
| 5850 | expectedLocalError: "renegotiation extension missing", |
| 5851 | }) |
| 5852 | // The renegotiation SCSV should be sufficient for the server to echo |
| 5853 | // the extension. |
| 5854 | testCases = append(testCases, testCase{ |
| 5855 | testType: serverTest, |
| 5856 | name: "Renegotiate-Server-NoExt-SCSV", |
| 5857 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5858 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5859 | Bugs: ProtocolBugs{ |
| 5860 | NoRenegotiationInfo: true, |
| 5861 | SendRenegotiationSCSV: true, |
| 5862 | RequireRenegotiationInfo: true, |
| 5863 | }, |
| 5864 | }, |
| 5865 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5866 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5867 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5868 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5869 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5870 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5871 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5872 | }, |
| 5873 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5874 | renegotiate: 1, |
| 5875 | flags: []string{ |
| 5876 | "-renegotiate-freely", |
| 5877 | "-expect-total-renegotiations", "1", |
| 5878 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5879 | }) |
| 5880 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5881 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5882 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5883 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5884 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5885 | Bugs: ProtocolBugs{ |
| 5886 | EmptyRenegotiationInfo: true, |
| 5887 | }, |
| 5888 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5889 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5890 | shouldFail: true, |
| 5891 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5892 | }) |
| 5893 | testCases = append(testCases, testCase{ |
| 5894 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5895 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5896 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5897 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5898 | Bugs: ProtocolBugs{ |
| 5899 | BadRenegotiationInfo: true, |
| 5900 | }, |
| 5901 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5902 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5903 | shouldFail: true, |
| 5904 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5905 | }) |
| 5906 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5907 | name: "Renegotiate-Client-Downgrade", |
| 5908 | renegotiate: 1, |
| 5909 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5910 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5911 | Bugs: ProtocolBugs{ |
| 5912 | NoRenegotiationInfoAfterInitial: true, |
| 5913 | }, |
| 5914 | }, |
| 5915 | flags: []string{"-renegotiate-freely"}, |
| 5916 | shouldFail: true, |
| 5917 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5918 | }) |
| 5919 | testCases = append(testCases, testCase{ |
| 5920 | name: "Renegotiate-Client-Upgrade", |
| 5921 | renegotiate: 1, |
| 5922 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5923 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5924 | Bugs: ProtocolBugs{ |
| 5925 | NoRenegotiationInfoInInitial: true, |
| 5926 | }, |
| 5927 | }, |
| 5928 | flags: []string{"-renegotiate-freely"}, |
| 5929 | shouldFail: true, |
| 5930 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5931 | }) |
| 5932 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5933 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5934 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5935 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5936 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5937 | Bugs: ProtocolBugs{ |
| 5938 | NoRenegotiationInfo: true, |
| 5939 | }, |
| 5940 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5941 | flags: []string{ |
| 5942 | "-renegotiate-freely", |
| 5943 | "-expect-total-renegotiations", "1", |
| 5944 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5945 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5946 | |
| 5947 | // Test that the server may switch ciphers on renegotiation without |
| 5948 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5949 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5950 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5951 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5952 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5953 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5954 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5955 | }, |
| 5956 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5957 | flags: []string{ |
| 5958 | "-renegotiate-freely", |
| 5959 | "-expect-total-renegotiations", "1", |
| 5960 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5961 | }) |
| 5962 | testCases = append(testCases, testCase{ |
| 5963 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5964 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5965 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5966 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5967 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5968 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5969 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5970 | flags: []string{ |
| 5971 | "-renegotiate-freely", |
| 5972 | "-expect-total-renegotiations", "1", |
| 5973 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5974 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5975 | |
| 5976 | // Test that the server may not switch versions on renegotiation. |
| 5977 | testCases = append(testCases, testCase{ |
| 5978 | name: "Renegotiate-Client-SwitchVersion", |
| 5979 | config: Config{ |
| 5980 | MaxVersion: VersionTLS12, |
| 5981 | // Pick a cipher which exists at both versions. |
| 5982 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 5983 | Bugs: ProtocolBugs{ |
| 5984 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 5985 | // Avoid failing early at the record layer. |
| 5986 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5987 | }, |
| 5988 | }, |
| 5989 | renegotiate: 1, |
| 5990 | flags: []string{ |
| 5991 | "-renegotiate-freely", |
| 5992 | "-expect-total-renegotiations", "1", |
| 5993 | }, |
| 5994 | shouldFail: true, |
| 5995 | expectedError: ":WRONG_SSL_VERSION:", |
| 5996 | }) |
| 5997 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5998 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5999 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6000 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6001 | config: Config{ |
| 6002 | MaxVersion: VersionTLS10, |
| 6003 | Bugs: ProtocolBugs{ |
| 6004 | RequireSameRenegoClientVersion: true, |
| 6005 | }, |
| 6006 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6007 | flags: []string{ |
| 6008 | "-renegotiate-freely", |
| 6009 | "-expect-total-renegotiations", "1", |
| 6010 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6011 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6012 | testCases = append(testCases, testCase{ |
| 6013 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6014 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6015 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6016 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6017 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6018 | NextProtos: []string{"foo"}, |
| 6019 | }, |
| 6020 | flags: []string{ |
| 6021 | "-false-start", |
| 6022 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6023 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6024 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6025 | }, |
| 6026 | shimWritesFirst: true, |
| 6027 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6028 | |
| 6029 | // Client-side renegotiation controls. |
| 6030 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6031 | name: "Renegotiate-Client-Forbidden-1", |
| 6032 | config: Config{ |
| 6033 | MaxVersion: VersionTLS12, |
| 6034 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6035 | renegotiate: 1, |
| 6036 | shouldFail: true, |
| 6037 | expectedError: ":NO_RENEGOTIATION:", |
| 6038 | expectedLocalError: "remote error: no renegotiation", |
| 6039 | }) |
| 6040 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6041 | name: "Renegotiate-Client-Once-1", |
| 6042 | config: Config{ |
| 6043 | MaxVersion: VersionTLS12, |
| 6044 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6045 | renegotiate: 1, |
| 6046 | flags: []string{ |
| 6047 | "-renegotiate-once", |
| 6048 | "-expect-total-renegotiations", "1", |
| 6049 | }, |
| 6050 | }) |
| 6051 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6052 | name: "Renegotiate-Client-Freely-1", |
| 6053 | config: Config{ |
| 6054 | MaxVersion: VersionTLS12, |
| 6055 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6056 | renegotiate: 1, |
| 6057 | flags: []string{ |
| 6058 | "-renegotiate-freely", |
| 6059 | "-expect-total-renegotiations", "1", |
| 6060 | }, |
| 6061 | }) |
| 6062 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6063 | name: "Renegotiate-Client-Once-2", |
| 6064 | config: Config{ |
| 6065 | MaxVersion: VersionTLS12, |
| 6066 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6067 | renegotiate: 2, |
| 6068 | flags: []string{"-renegotiate-once"}, |
| 6069 | shouldFail: true, |
| 6070 | expectedError: ":NO_RENEGOTIATION:", |
| 6071 | expectedLocalError: "remote error: no renegotiation", |
| 6072 | }) |
| 6073 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6074 | name: "Renegotiate-Client-Freely-2", |
| 6075 | config: Config{ |
| 6076 | MaxVersion: VersionTLS12, |
| 6077 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6078 | renegotiate: 2, |
| 6079 | flags: []string{ |
| 6080 | "-renegotiate-freely", |
| 6081 | "-expect-total-renegotiations", "2", |
| 6082 | }, |
| 6083 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6084 | testCases = append(testCases, testCase{ |
| 6085 | name: "Renegotiate-Client-NoIgnore", |
| 6086 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6087 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6088 | Bugs: ProtocolBugs{ |
| 6089 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6090 | }, |
| 6091 | }, |
| 6092 | shouldFail: true, |
| 6093 | expectedError: ":NO_RENEGOTIATION:", |
| 6094 | }) |
| 6095 | testCases = append(testCases, testCase{ |
| 6096 | name: "Renegotiate-Client-Ignore", |
| 6097 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6098 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6099 | Bugs: ProtocolBugs{ |
| 6100 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6101 | }, |
| 6102 | }, |
| 6103 | flags: []string{ |
| 6104 | "-renegotiate-ignore", |
| 6105 | "-expect-total-renegotiations", "0", |
| 6106 | }, |
| 6107 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6108 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6109 | // Renegotiation is not allowed at SSL 3.0. |
| 6110 | testCases = append(testCases, testCase{ |
| 6111 | name: "Renegotiate-Client-SSL3", |
| 6112 | config: Config{ |
| 6113 | MaxVersion: VersionSSL30, |
| 6114 | }, |
| 6115 | renegotiate: 1, |
| 6116 | flags: []string{ |
| 6117 | "-renegotiate-freely", |
| 6118 | "-expect-total-renegotiations", "1", |
| 6119 | }, |
| 6120 | shouldFail: true, |
| 6121 | expectedError: ":NO_RENEGOTIATION:", |
| 6122 | expectedLocalError: "remote error: no renegotiation", |
| 6123 | }) |
| 6124 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6125 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6126 | testCases = append(testCases, testCase{ |
| 6127 | name: "StrayHelloRequest", |
| 6128 | config: Config{ |
| 6129 | MaxVersion: VersionTLS12, |
| 6130 | Bugs: ProtocolBugs{ |
| 6131 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6132 | }, |
| 6133 | }, |
| 6134 | }) |
| 6135 | testCases = append(testCases, testCase{ |
| 6136 | name: "StrayHelloRequest-Packed", |
| 6137 | config: Config{ |
| 6138 | MaxVersion: VersionTLS12, |
| 6139 | Bugs: ProtocolBugs{ |
| 6140 | PackHandshakeFlight: true, |
| 6141 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6142 | }, |
| 6143 | }, |
| 6144 | }) |
| 6145 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6146 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6147 | // the same record. |
| 6148 | testCases = append(testCases, testCase{ |
| 6149 | name: "Renegotiate-Client-Packed", |
| 6150 | config: Config{ |
| 6151 | MaxVersion: VersionTLS12, |
| 6152 | Bugs: ProtocolBugs{ |
| 6153 | PackHandshakeFlight: true, |
| 6154 | PackHelloRequestWithFinished: true, |
| 6155 | }, |
| 6156 | }, |
| 6157 | renegotiate: 1, |
| 6158 | flags: []string{ |
| 6159 | "-renegotiate-freely", |
| 6160 | "-expect-total-renegotiations", "1", |
| 6161 | }, |
| 6162 | }) |
| 6163 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6164 | // Renegotiation is forbidden in TLS 1.3. |
| 6165 | testCases = append(testCases, testCase{ |
| 6166 | name: "Renegotiate-Client-TLS13", |
| 6167 | config: Config{ |
| 6168 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6169 | Bugs: ProtocolBugs{ |
| 6170 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6171 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6172 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6173 | flags: []string{ |
| 6174 | "-renegotiate-freely", |
| 6175 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6176 | shouldFail: true, |
| 6177 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6178 | }) |
| 6179 | |
| 6180 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6181 | testCases = append(testCases, testCase{ |
| 6182 | name: "StrayHelloRequest-TLS13", |
| 6183 | config: Config{ |
| 6184 | MaxVersion: VersionTLS13, |
| 6185 | Bugs: ProtocolBugs{ |
| 6186 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6187 | }, |
| 6188 | }, |
| 6189 | shouldFail: true, |
| 6190 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6191 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6192 | } |
| 6193 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6194 | func addDTLSReplayTests() { |
| 6195 | // Test that sequence number replays are detected. |
| 6196 | testCases = append(testCases, testCase{ |
| 6197 | protocol: dtls, |
| 6198 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6199 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6200 | replayWrites: true, |
| 6201 | }) |
| 6202 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6203 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6204 | // than the retransmit window. |
| 6205 | testCases = append(testCases, testCase{ |
| 6206 | protocol: dtls, |
| 6207 | name: "DTLS-Replay-LargeGaps", |
| 6208 | config: Config{ |
| 6209 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6210 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6211 | return in * 127 |
| 6212 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6213 | }, |
| 6214 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6215 | messageCount: 200, |
| 6216 | replayWrites: true, |
| 6217 | }) |
| 6218 | |
| 6219 | // Test the incoming sequence number changing non-monotonically. |
| 6220 | testCases = append(testCases, testCase{ |
| 6221 | protocol: dtls, |
| 6222 | name: "DTLS-Replay-NonMonotonic", |
| 6223 | config: Config{ |
| 6224 | Bugs: ProtocolBugs{ |
| 6225 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6226 | return in ^ 31 |
| 6227 | }, |
| 6228 | }, |
| 6229 | }, |
| 6230 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6231 | replayWrites: true, |
| 6232 | }) |
| 6233 | } |
| 6234 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6235 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6236 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6237 | id signatureAlgorithm |
| 6238 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6239 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6240 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6241 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6242 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6243 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6244 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6245 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6246 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6247 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6248 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6249 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6250 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6251 | // Tests for key types prior to TLS 1.2. |
| 6252 | {"RSA", 0, testCertRSA}, |
| 6253 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6254 | } |
| 6255 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6256 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6257 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6258 | |
| 6259 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6260 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6261 | // versions a signing cipher. |
| 6262 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6263 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6264 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6265 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6266 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6267 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6268 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6269 | } |
| 6270 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6271 | var allAlgorithms []signatureAlgorithm |
| 6272 | for _, alg := range testSignatureAlgorithms { |
| 6273 | if alg.id != 0 { |
| 6274 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6275 | } |
| 6276 | } |
| 6277 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6278 | // Make sure each signature algorithm works. Include some fake values in |
| 6279 | // the list and ensure they're ignored. |
| 6280 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6281 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6282 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6283 | continue |
| 6284 | } |
| 6285 | |
| 6286 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6287 | // or remove it in C. |
| 6288 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6289 | continue |
| 6290 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6291 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6292 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6293 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6294 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6295 | shouldSignFail = true |
| 6296 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6297 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6298 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6299 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6300 | shouldSignFail = true |
| 6301 | shouldVerifyFail = true |
| 6302 | } |
| 6303 | |
| 6304 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6305 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6306 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6307 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6308 | |
| 6309 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6310 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6311 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6312 | } |
| 6313 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6314 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6315 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6316 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6317 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6318 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6319 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6320 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6321 | config: Config{ |
| 6322 | MaxVersion: ver.version, |
| 6323 | ClientAuth: RequireAnyClientCert, |
| 6324 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6325 | fakeSigAlg1, |
| 6326 | alg.id, |
| 6327 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6328 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6329 | }, |
| 6330 | flags: []string{ |
| 6331 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6332 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6333 | "-enable-all-curves", |
| 6334 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6335 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6336 | expectedError: signError, |
| 6337 | expectedPeerSignatureAlgorithm: alg.id, |
| 6338 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6339 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6340 | testCases = append(testCases, testCase{ |
| 6341 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6342 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6343 | config: Config{ |
| 6344 | MaxVersion: ver.version, |
| 6345 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6346 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6347 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6348 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6349 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6350 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6351 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6352 | // Some signature algorithms may not be advertised. |
| 6353 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6354 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6355 | }, |
| 6356 | flags: []string{ |
| 6357 | "-require-any-client-certificate", |
| 6358 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6359 | "-enable-all-curves", |
| 6360 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6361 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6362 | expectedError: verifyError, |
| 6363 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6364 | |
| 6365 | testCases = append(testCases, testCase{ |
| 6366 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6367 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6368 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6369 | MaxVersion: ver.version, |
| 6370 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6371 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6372 | fakeSigAlg1, |
| 6373 | alg.id, |
| 6374 | fakeSigAlg2, |
| 6375 | }, |
| 6376 | }, |
| 6377 | flags: []string{ |
| 6378 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6379 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6380 | "-enable-all-curves", |
| 6381 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6382 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6383 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6384 | expectedPeerSignatureAlgorithm: alg.id, |
| 6385 | }) |
| 6386 | |
| 6387 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6388 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6389 | config: Config{ |
| 6390 | MaxVersion: ver.version, |
| 6391 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6392 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6393 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6394 | alg.id, |
| 6395 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6396 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6397 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6398 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6399 | // Some signature algorithms may not be advertised. |
| 6400 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6401 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6402 | }, |
| 6403 | flags: []string{ |
| 6404 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6405 | "-enable-all-curves", |
| 6406 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6407 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6408 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6409 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6410 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6411 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6412 | testCases = append(testCases, testCase{ |
| 6413 | testType: serverTest, |
| 6414 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6415 | config: Config{ |
| 6416 | MaxVersion: ver.version, |
| 6417 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6418 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6419 | alg.id, |
| 6420 | }, |
| 6421 | Bugs: ProtocolBugs{ |
| 6422 | InvalidSignature: true, |
| 6423 | }, |
| 6424 | }, |
| 6425 | flags: []string{ |
| 6426 | "-require-any-client-certificate", |
| 6427 | "-enable-all-curves", |
| 6428 | }, |
| 6429 | shouldFail: true, |
| 6430 | expectedError: ":BAD_SIGNATURE:", |
| 6431 | }) |
| 6432 | |
| 6433 | testCases = append(testCases, testCase{ |
| 6434 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6435 | config: Config{ |
| 6436 | MaxVersion: ver.version, |
| 6437 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6438 | CipherSuites: signingCiphers, |
| 6439 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6440 | alg.id, |
| 6441 | }, |
| 6442 | Bugs: ProtocolBugs{ |
| 6443 | InvalidSignature: true, |
| 6444 | }, |
| 6445 | }, |
| 6446 | flags: []string{"-enable-all-curves"}, |
| 6447 | shouldFail: true, |
| 6448 | expectedError: ":BAD_SIGNATURE:", |
| 6449 | }) |
| 6450 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6451 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6452 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6453 | testCases = append(testCases, testCase{ |
| 6454 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6455 | config: Config{ |
| 6456 | MaxVersion: ver.version, |
| 6457 | ClientAuth: RequireAnyClientCert, |
| 6458 | VerifySignatureAlgorithms: allAlgorithms, |
| 6459 | }, |
| 6460 | flags: []string{ |
| 6461 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6462 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6463 | "-enable-all-curves", |
| 6464 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6465 | }, |
| 6466 | expectedPeerSignatureAlgorithm: alg.id, |
| 6467 | }) |
| 6468 | |
| 6469 | testCases = append(testCases, testCase{ |
| 6470 | testType: serverTest, |
| 6471 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6472 | config: Config{ |
| 6473 | MaxVersion: ver.version, |
| 6474 | CipherSuites: signingCiphers, |
| 6475 | VerifySignatureAlgorithms: allAlgorithms, |
| 6476 | }, |
| 6477 | flags: []string{ |
| 6478 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6479 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6480 | "-enable-all-curves", |
| 6481 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6482 | }, |
| 6483 | expectedPeerSignatureAlgorithm: alg.id, |
| 6484 | }) |
| 6485 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6486 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6487 | } |
| 6488 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6489 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6490 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6491 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6492 | config: Config{ |
| 6493 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6494 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6495 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6496 | signatureECDSAWithP521AndSHA512, |
| 6497 | signatureRSAPKCS1WithSHA384, |
| 6498 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6499 | }, |
| 6500 | }, |
| 6501 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6502 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6503 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6504 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6505 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6506 | }) |
| 6507 | |
| 6508 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6509 | name: "ClientAuth-SignatureType-TLS13", |
| 6510 | config: Config{ |
| 6511 | ClientAuth: RequireAnyClientCert, |
| 6512 | MaxVersion: VersionTLS13, |
| 6513 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6514 | signatureECDSAWithP521AndSHA512, |
| 6515 | signatureRSAPKCS1WithSHA384, |
| 6516 | signatureRSAPSSWithSHA384, |
| 6517 | signatureECDSAWithSHA1, |
| 6518 | }, |
| 6519 | }, |
| 6520 | flags: []string{ |
| 6521 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6522 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6523 | }, |
| 6524 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6525 | }) |
| 6526 | |
| 6527 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6528 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6529 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6530 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6531 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6532 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6533 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6534 | signatureECDSAWithP521AndSHA512, |
| 6535 | signatureRSAPKCS1WithSHA384, |
| 6536 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6537 | }, |
| 6538 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6539 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6540 | }) |
| 6541 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6542 | testCases = append(testCases, testCase{ |
| 6543 | testType: serverTest, |
| 6544 | name: "ServerAuth-SignatureType-TLS13", |
| 6545 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6546 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6547 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6548 | signatureECDSAWithP521AndSHA512, |
| 6549 | signatureRSAPKCS1WithSHA384, |
| 6550 | signatureRSAPSSWithSHA384, |
| 6551 | signatureECDSAWithSHA1, |
| 6552 | }, |
| 6553 | }, |
| 6554 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6555 | }) |
| 6556 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6557 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6558 | testCases = append(testCases, testCase{ |
| 6559 | testType: serverTest, |
| 6560 | name: "Verify-ClientAuth-SignatureType", |
| 6561 | config: Config{ |
| 6562 | MaxVersion: VersionTLS12, |
| 6563 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6564 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6565 | signatureRSAPKCS1WithSHA256, |
| 6566 | }, |
| 6567 | Bugs: ProtocolBugs{ |
| 6568 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6569 | }, |
| 6570 | }, |
| 6571 | flags: []string{ |
| 6572 | "-require-any-client-certificate", |
| 6573 | }, |
| 6574 | shouldFail: true, |
| 6575 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6576 | }) |
| 6577 | |
| 6578 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6579 | testType: serverTest, |
| 6580 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6581 | config: Config{ |
| 6582 | MaxVersion: VersionTLS13, |
| 6583 | Certificates: []Certificate{rsaCertificate}, |
| 6584 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6585 | signatureRSAPSSWithSHA256, |
| 6586 | }, |
| 6587 | Bugs: ProtocolBugs{ |
| 6588 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6589 | }, |
| 6590 | }, |
| 6591 | flags: []string{ |
| 6592 | "-require-any-client-certificate", |
| 6593 | }, |
| 6594 | shouldFail: true, |
| 6595 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6596 | }) |
| 6597 | |
| 6598 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6599 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6600 | config: Config{ |
| 6601 | MaxVersion: VersionTLS12, |
| 6602 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6603 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6604 | signatureRSAPKCS1WithSHA256, |
| 6605 | }, |
| 6606 | Bugs: ProtocolBugs{ |
| 6607 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6608 | }, |
| 6609 | }, |
| 6610 | shouldFail: true, |
| 6611 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6612 | }) |
| 6613 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6614 | testCases = append(testCases, testCase{ |
| 6615 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6616 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6617 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6618 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6619 | signatureRSAPSSWithSHA256, |
| 6620 | }, |
| 6621 | Bugs: ProtocolBugs{ |
| 6622 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6623 | }, |
| 6624 | }, |
| 6625 | shouldFail: true, |
| 6626 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6627 | }) |
| 6628 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6629 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6630 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6631 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6632 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6633 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6634 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6635 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6636 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6637 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6638 | }, |
| 6639 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6640 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6641 | }, |
| 6642 | }, |
| 6643 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6644 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6645 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6646 | }, |
| 6647 | }) |
| 6648 | |
| 6649 | testCases = append(testCases, testCase{ |
| 6650 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6651 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6652 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6653 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6654 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6655 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6656 | }, |
| 6657 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6658 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6659 | }, |
| 6660 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6661 | flags: []string{ |
| 6662 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6663 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6664 | }, |
| 6665 | }) |
| 6666 | |
| 6667 | testCases = append(testCases, testCase{ |
| 6668 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6669 | config: Config{ |
| 6670 | MaxVersion: VersionTLS12, |
| 6671 | ClientAuth: RequireAnyClientCert, |
| 6672 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6673 | signatureECDSAWithSHA1, |
| 6674 | }, |
| 6675 | Bugs: ProtocolBugs{ |
| 6676 | NoSignatureAlgorithms: true, |
| 6677 | }, |
| 6678 | }, |
| 6679 | flags: []string{ |
| 6680 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6681 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6682 | }, |
| 6683 | }) |
| 6684 | |
| 6685 | testCases = append(testCases, testCase{ |
| 6686 | testType: serverTest, |
| 6687 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6688 | config: Config{ |
| 6689 | MaxVersion: VersionTLS12, |
| 6690 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6691 | signatureECDSAWithSHA1, |
| 6692 | }, |
| 6693 | Bugs: ProtocolBugs{ |
| 6694 | NoSignatureAlgorithms: true, |
| 6695 | }, |
| 6696 | }, |
| 6697 | flags: []string{ |
| 6698 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6699 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6700 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6701 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6702 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6703 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6704 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6705 | config: Config{ |
| 6706 | MaxVersion: VersionTLS13, |
| 6707 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6708 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6709 | signatureRSAPKCS1WithSHA1, |
| 6710 | }, |
| 6711 | Bugs: ProtocolBugs{ |
| 6712 | NoSignatureAlgorithms: true, |
| 6713 | }, |
| 6714 | }, |
| 6715 | flags: []string{ |
| 6716 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6717 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6718 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6719 | shouldFail: true, |
| 6720 | // An empty CertificateRequest signature algorithm list is a |
| 6721 | // syntax error in TLS 1.3. |
| 6722 | expectedError: ":DECODE_ERROR:", |
| 6723 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6724 | }) |
| 6725 | |
| 6726 | testCases = append(testCases, testCase{ |
| 6727 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6728 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6729 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6730 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6731 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6732 | signatureRSAPKCS1WithSHA1, |
| 6733 | }, |
| 6734 | Bugs: ProtocolBugs{ |
| 6735 | NoSignatureAlgorithms: true, |
| 6736 | }, |
| 6737 | }, |
| 6738 | shouldFail: true, |
| 6739 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6740 | }) |
| 6741 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6742 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6743 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6744 | testCases = append(testCases, testCase{ |
| 6745 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6746 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6747 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6748 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6749 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6750 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6751 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6752 | }, |
| 6753 | Bugs: ProtocolBugs{ |
| 6754 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6755 | }, |
| 6756 | }, |
| 6757 | flags: []string{"-require-any-client-certificate"}, |
| 6758 | shouldFail: true, |
| 6759 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6760 | }) |
| 6761 | |
| 6762 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6763 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6764 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6765 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6766 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6767 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6768 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6769 | }, |
| 6770 | Bugs: ProtocolBugs{ |
| 6771 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6772 | }, |
| 6773 | }, |
| 6774 | shouldFail: true, |
| 6775 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6776 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6777 | testCases = append(testCases, testCase{ |
| 6778 | testType: serverTest, |
| 6779 | name: "ClientAuth-Enforced-TLS13", |
| 6780 | config: Config{ |
| 6781 | MaxVersion: VersionTLS13, |
| 6782 | Certificates: []Certificate{rsaCertificate}, |
| 6783 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6784 | signatureRSAPKCS1WithMD5, |
| 6785 | }, |
| 6786 | Bugs: ProtocolBugs{ |
| 6787 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6788 | IgnoreSignatureVersionChecks: true, |
| 6789 | }, |
| 6790 | }, |
| 6791 | flags: []string{"-require-any-client-certificate"}, |
| 6792 | shouldFail: true, |
| 6793 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6794 | }) |
| 6795 | |
| 6796 | testCases = append(testCases, testCase{ |
| 6797 | name: "ServerAuth-Enforced-TLS13", |
| 6798 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6799 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6800 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6801 | signatureRSAPKCS1WithMD5, |
| 6802 | }, |
| 6803 | Bugs: ProtocolBugs{ |
| 6804 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6805 | IgnoreSignatureVersionChecks: true, |
| 6806 | }, |
| 6807 | }, |
| 6808 | shouldFail: true, |
| 6809 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6810 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6811 | |
| 6812 | // Test that the agreed upon digest respects the client preferences and |
| 6813 | // the server digests. |
| 6814 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6815 | name: "NoCommonAlgorithms-Digests", |
| 6816 | config: Config{ |
| 6817 | MaxVersion: VersionTLS12, |
| 6818 | ClientAuth: RequireAnyClientCert, |
| 6819 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6820 | signatureRSAPKCS1WithSHA512, |
| 6821 | signatureRSAPKCS1WithSHA1, |
| 6822 | }, |
| 6823 | }, |
| 6824 | flags: []string{ |
| 6825 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6826 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6827 | "-digest-prefs", "SHA256", |
| 6828 | }, |
| 6829 | shouldFail: true, |
| 6830 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6831 | }) |
| 6832 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6833 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6834 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6835 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6836 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6837 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6838 | signatureRSAPKCS1WithSHA512, |
| 6839 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6840 | }, |
| 6841 | }, |
| 6842 | flags: []string{ |
| 6843 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6844 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6845 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6846 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6847 | shouldFail: true, |
| 6848 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6849 | }) |
| 6850 | testCases = append(testCases, testCase{ |
| 6851 | name: "NoCommonAlgorithms-TLS13", |
| 6852 | config: Config{ |
| 6853 | MaxVersion: VersionTLS13, |
| 6854 | ClientAuth: RequireAnyClientCert, |
| 6855 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6856 | signatureRSAPSSWithSHA512, |
| 6857 | signatureRSAPSSWithSHA384, |
| 6858 | }, |
| 6859 | }, |
| 6860 | flags: []string{ |
| 6861 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6862 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6863 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 6864 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6865 | shouldFail: true, |
| 6866 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6867 | }) |
| 6868 | testCases = append(testCases, testCase{ |
| 6869 | name: "Agree-Digest-SHA256", |
| 6870 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6871 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6872 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6873 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6874 | signatureRSAPKCS1WithSHA1, |
| 6875 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6876 | }, |
| 6877 | }, |
| 6878 | flags: []string{ |
| 6879 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6880 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6881 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6882 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6883 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6884 | }) |
| 6885 | testCases = append(testCases, testCase{ |
| 6886 | name: "Agree-Digest-SHA1", |
| 6887 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6888 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6889 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6890 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6891 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6892 | }, |
| 6893 | }, |
| 6894 | flags: []string{ |
| 6895 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6896 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6897 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6898 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6899 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6900 | }) |
| 6901 | testCases = append(testCases, testCase{ |
| 6902 | name: "Agree-Digest-Default", |
| 6903 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6904 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6905 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6906 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6907 | signatureRSAPKCS1WithSHA256, |
| 6908 | signatureECDSAWithP256AndSHA256, |
| 6909 | signatureRSAPKCS1WithSHA1, |
| 6910 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6911 | }, |
| 6912 | }, |
| 6913 | flags: []string{ |
| 6914 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6915 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6916 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6917 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6918 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6919 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6920 | // Test that the signing preference list may include extra algorithms |
| 6921 | // without negotiation problems. |
| 6922 | testCases = append(testCases, testCase{ |
| 6923 | testType: serverTest, |
| 6924 | name: "FilterExtraAlgorithms", |
| 6925 | config: Config{ |
| 6926 | MaxVersion: VersionTLS12, |
| 6927 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6928 | signatureRSAPKCS1WithSHA256, |
| 6929 | }, |
| 6930 | }, |
| 6931 | flags: []string{ |
| 6932 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6933 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6934 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 6935 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 6936 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 6937 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 6938 | }, |
| 6939 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 6940 | }) |
| 6941 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6942 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 6943 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6944 | testCases = append(testCases, testCase{ |
| 6945 | name: "CheckLeafCurve", |
| 6946 | config: Config{ |
| 6947 | MaxVersion: VersionTLS12, |
| 6948 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6949 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6950 | }, |
| 6951 | flags: []string{"-p384-only"}, |
| 6952 | shouldFail: true, |
| 6953 | expectedError: ":BAD_ECC_CERT:", |
| 6954 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 6955 | |
| 6956 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 6957 | testCases = append(testCases, testCase{ |
| 6958 | name: "CheckLeafCurve-TLS13", |
| 6959 | config: Config{ |
| 6960 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 6961 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 6962 | }, |
| 6963 | flags: []string{"-p384-only"}, |
| 6964 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6965 | |
| 6966 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 6967 | testCases = append(testCases, testCase{ |
| 6968 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 6969 | config: Config{ |
| 6970 | MaxVersion: VersionTLS12, |
| 6971 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6972 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6973 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6974 | signatureECDSAWithP384AndSHA384, |
| 6975 | }, |
| 6976 | }, |
| 6977 | }) |
| 6978 | |
| 6979 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 6980 | testCases = append(testCases, testCase{ |
| 6981 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 6982 | config: Config{ |
| 6983 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6984 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6985 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6986 | signatureECDSAWithP384AndSHA384, |
| 6987 | }, |
| 6988 | Bugs: ProtocolBugs{ |
| 6989 | SkipECDSACurveCheck: true, |
| 6990 | }, |
| 6991 | }, |
| 6992 | shouldFail: true, |
| 6993 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6994 | }) |
| 6995 | |
| 6996 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 6997 | // account. |
| 6998 | testCases = append(testCases, testCase{ |
| 6999 | testType: serverTest, |
| 7000 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7001 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7002 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7003 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7004 | signatureECDSAWithP384AndSHA384, |
| 7005 | signatureECDSAWithP256AndSHA256, |
| 7006 | }, |
| 7007 | }, |
| 7008 | flags: []string{ |
| 7009 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7010 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7011 | }, |
| 7012 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7013 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7014 | |
| 7015 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7016 | // server does not attempt to sign in that case. |
| 7017 | testCases = append(testCases, testCase{ |
| 7018 | testType: serverTest, |
| 7019 | name: "RSA-PSS-Large", |
| 7020 | config: Config{ |
| 7021 | MaxVersion: VersionTLS13, |
| 7022 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7023 | signatureRSAPSSWithSHA512, |
| 7024 | }, |
| 7025 | }, |
| 7026 | flags: []string{ |
| 7027 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7028 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7029 | }, |
| 7030 | shouldFail: true, |
| 7031 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7032 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7033 | |
| 7034 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7035 | testCases = append(testCases, testCase{ |
| 7036 | testType: clientTest, |
| 7037 | name: "RSA-PSS-Default-Verify", |
| 7038 | config: Config{ |
| 7039 | MaxVersion: VersionTLS12, |
| 7040 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7041 | signatureRSAPSSWithSHA256, |
| 7042 | }, |
| 7043 | }, |
| 7044 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7045 | }) |
| 7046 | |
| 7047 | testCases = append(testCases, testCase{ |
| 7048 | testType: serverTest, |
| 7049 | name: "RSA-PSS-Default-Sign", |
| 7050 | config: Config{ |
| 7051 | MaxVersion: VersionTLS12, |
| 7052 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7053 | signatureRSAPSSWithSHA256, |
| 7054 | }, |
| 7055 | }, |
| 7056 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7057 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7058 | } |
| 7059 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7060 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7061 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7062 | var timeouts = []time.Duration{ |
| 7063 | 1 * time.Second, |
| 7064 | 2 * time.Second, |
| 7065 | 4 * time.Second, |
| 7066 | 8 * time.Second, |
| 7067 | 16 * time.Second, |
| 7068 | 32 * time.Second, |
| 7069 | 60 * time.Second, |
| 7070 | 60 * time.Second, |
| 7071 | 60 * time.Second, |
| 7072 | 60 * time.Second, |
| 7073 | 60 * time.Second, |
| 7074 | 60 * time.Second, |
| 7075 | 60 * time.Second, |
| 7076 | } |
| 7077 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7078 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7079 | // initial timeout duration was set to 250ms. |
| 7080 | var shortTimeouts = []time.Duration{ |
| 7081 | 250 * time.Millisecond, |
| 7082 | 500 * time.Millisecond, |
| 7083 | 1 * time.Second, |
| 7084 | 2 * time.Second, |
| 7085 | 4 * time.Second, |
| 7086 | 8 * time.Second, |
| 7087 | 16 * time.Second, |
| 7088 | 32 * time.Second, |
| 7089 | 60 * time.Second, |
| 7090 | 60 * time.Second, |
| 7091 | 60 * time.Second, |
| 7092 | 60 * time.Second, |
| 7093 | 60 * time.Second, |
| 7094 | } |
| 7095 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7096 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7097 | // These tests work by coordinating some behavior on both the shim and |
| 7098 | // the runner. |
| 7099 | // |
| 7100 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7101 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7102 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7103 | // timeout in the shim and acts as a synchronization point to help the |
| 7104 | // runner bracket each handshake flight. |
| 7105 | // |
| 7106 | // We assume the shim does not read from the channel eagerly. It must |
| 7107 | // first wait until it has sent flight N and is ready to receive |
| 7108 | // handshake flight N+1. At this point, it will process the timeout |
| 7109 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7110 | // as if the shim was idle for the specified amount of time. |
| 7111 | // |
| 7112 | // The runner then drops all packets received before the ACK and |
| 7113 | // continues waiting for flight N. This ordering results in one attempt |
| 7114 | // at sending flight N to be dropped. For the test to complete, the |
| 7115 | // shim must send flight N again, testing that the shim implements DTLS |
| 7116 | // retransmit on a timeout. |
| 7117 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7118 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7119 | // likely be more epochs to cross and the final message's retransmit may |
| 7120 | // be more complex. |
| 7121 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7122 | for _, async := range []bool{true, false} { |
| 7123 | var tests []testCase |
| 7124 | |
| 7125 | // Test that this is indeed the timeout schedule. Stress all |
| 7126 | // four patterns of handshake. |
| 7127 | for i := 1; i < len(timeouts); i++ { |
| 7128 | number := strconv.Itoa(i) |
| 7129 | tests = append(tests, testCase{ |
| 7130 | protocol: dtls, |
| 7131 | name: "DTLS-Retransmit-Client-" + number, |
| 7132 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7133 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7134 | Bugs: ProtocolBugs{ |
| 7135 | TimeoutSchedule: timeouts[:i], |
| 7136 | }, |
| 7137 | }, |
| 7138 | resumeSession: true, |
| 7139 | }) |
| 7140 | tests = append(tests, testCase{ |
| 7141 | protocol: dtls, |
| 7142 | testType: serverTest, |
| 7143 | name: "DTLS-Retransmit-Server-" + number, |
| 7144 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7145 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7146 | Bugs: ProtocolBugs{ |
| 7147 | TimeoutSchedule: timeouts[:i], |
| 7148 | }, |
| 7149 | }, |
| 7150 | resumeSession: true, |
| 7151 | }) |
| 7152 | } |
| 7153 | |
| 7154 | // Test that exceeding the timeout schedule hits a read |
| 7155 | // timeout. |
| 7156 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7157 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7158 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7159 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7160 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7161 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7162 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7163 | }, |
| 7164 | }, |
| 7165 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7166 | shouldFail: true, |
| 7167 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7168 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7169 | |
| 7170 | if async { |
| 7171 | // Test that timeout handling has a fudge factor, due to API |
| 7172 | // problems. |
| 7173 | tests = append(tests, testCase{ |
| 7174 | protocol: dtls, |
| 7175 | name: "DTLS-Retransmit-Fudge", |
| 7176 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7177 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7178 | Bugs: ProtocolBugs{ |
| 7179 | TimeoutSchedule: []time.Duration{ |
| 7180 | timeouts[0] - 10*time.Millisecond, |
| 7181 | }, |
| 7182 | }, |
| 7183 | }, |
| 7184 | resumeSession: true, |
| 7185 | }) |
| 7186 | } |
| 7187 | |
| 7188 | // Test that the final Finished retransmitting isn't |
| 7189 | // duplicated if the peer badly fragments everything. |
| 7190 | tests = append(tests, testCase{ |
| 7191 | testType: serverTest, |
| 7192 | protocol: dtls, |
| 7193 | name: "DTLS-Retransmit-Fragmented", |
| 7194 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7195 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7196 | Bugs: ProtocolBugs{ |
| 7197 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7198 | MaxHandshakeRecordLength: 2, |
| 7199 | }, |
| 7200 | }, |
| 7201 | }) |
| 7202 | |
| 7203 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7204 | tests = append(tests, testCase{ |
| 7205 | protocol: dtls, |
| 7206 | name: "DTLS-Retransmit-Short-Client", |
| 7207 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7208 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7209 | Bugs: ProtocolBugs{ |
| 7210 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7211 | }, |
| 7212 | }, |
| 7213 | resumeSession: true, |
| 7214 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 7215 | }) |
| 7216 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7217 | protocol: dtls, |
| 7218 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7219 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7220 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7221 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7222 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7223 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7224 | }, |
| 7225 | }, |
| 7226 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7227 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7228 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7229 | |
| 7230 | for _, test := range tests { |
| 7231 | if async { |
| 7232 | test.name += "-Async" |
| 7233 | test.flags = append(test.flags, "-async") |
| 7234 | } |
| 7235 | |
| 7236 | testCases = append(testCases, test) |
| 7237 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7238 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7239 | } |
| 7240 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7241 | func addExportKeyingMaterialTests() { |
| 7242 | for _, vers := range tlsVersions { |
| 7243 | if vers.version == VersionSSL30 { |
| 7244 | continue |
| 7245 | } |
| 7246 | testCases = append(testCases, testCase{ |
| 7247 | name: "ExportKeyingMaterial-" + vers.name, |
| 7248 | config: Config{ |
| 7249 | MaxVersion: vers.version, |
| 7250 | }, |
| 7251 | exportKeyingMaterial: 1024, |
| 7252 | exportLabel: "label", |
| 7253 | exportContext: "context", |
| 7254 | useExportContext: true, |
| 7255 | }) |
| 7256 | testCases = append(testCases, testCase{ |
| 7257 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7258 | config: Config{ |
| 7259 | MaxVersion: vers.version, |
| 7260 | }, |
| 7261 | exportKeyingMaterial: 1024, |
| 7262 | }) |
| 7263 | testCases = append(testCases, testCase{ |
| 7264 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7265 | config: Config{ |
| 7266 | MaxVersion: vers.version, |
| 7267 | }, |
| 7268 | exportKeyingMaterial: 1024, |
| 7269 | useExportContext: true, |
| 7270 | }) |
| 7271 | testCases = append(testCases, testCase{ |
| 7272 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7273 | config: Config{ |
| 7274 | MaxVersion: vers.version, |
| 7275 | }, |
| 7276 | exportKeyingMaterial: 1, |
| 7277 | exportLabel: "label", |
| 7278 | exportContext: "context", |
| 7279 | useExportContext: true, |
| 7280 | }) |
| 7281 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7282 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7283 | testCases = append(testCases, testCase{ |
| 7284 | name: "ExportKeyingMaterial-SSL3", |
| 7285 | config: Config{ |
| 7286 | MaxVersion: VersionSSL30, |
| 7287 | }, |
| 7288 | exportKeyingMaterial: 1024, |
| 7289 | exportLabel: "label", |
| 7290 | exportContext: "context", |
| 7291 | useExportContext: true, |
| 7292 | shouldFail: true, |
| 7293 | expectedError: "failed to export keying material", |
| 7294 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7295 | |
| 7296 | // Exporters work during a False Start. |
| 7297 | testCases = append(testCases, testCase{ |
| 7298 | name: "ExportKeyingMaterial-FalseStart", |
| 7299 | config: Config{ |
| 7300 | MaxVersion: VersionTLS12, |
| 7301 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7302 | NextProtos: []string{"foo"}, |
| 7303 | Bugs: ProtocolBugs{ |
| 7304 | ExpectFalseStart: true, |
| 7305 | }, |
| 7306 | }, |
| 7307 | flags: []string{ |
| 7308 | "-false-start", |
| 7309 | "-advertise-alpn", "\x03foo", |
| 7310 | }, |
| 7311 | shimWritesFirst: true, |
| 7312 | exportKeyingMaterial: 1024, |
| 7313 | exportLabel: "label", |
| 7314 | exportContext: "context", |
| 7315 | useExportContext: true, |
| 7316 | }) |
| 7317 | |
| 7318 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7319 | // triggering the exporter after every SSL_read call and configuring the |
| 7320 | // shim to run asynchronously. |
| 7321 | testCases = append(testCases, testCase{ |
| 7322 | name: "ExportKeyingMaterial-Renegotiate", |
| 7323 | config: Config{ |
| 7324 | MaxVersion: VersionTLS12, |
| 7325 | }, |
| 7326 | renegotiate: 1, |
| 7327 | flags: []string{ |
| 7328 | "-async", |
| 7329 | "-use-exporter-between-reads", |
| 7330 | "-renegotiate-freely", |
| 7331 | "-expect-total-renegotiations", "1", |
| 7332 | }, |
| 7333 | shouldFail: true, |
| 7334 | expectedError: "failed to export keying material", |
| 7335 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7336 | } |
| 7337 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7338 | func addTLSUniqueTests() { |
| 7339 | for _, isClient := range []bool{false, true} { |
| 7340 | for _, isResumption := range []bool{false, true} { |
| 7341 | for _, hasEMS := range []bool{false, true} { |
| 7342 | var suffix string |
| 7343 | if isResumption { |
| 7344 | suffix = "Resume-" |
| 7345 | } else { |
| 7346 | suffix = "Full-" |
| 7347 | } |
| 7348 | |
| 7349 | if hasEMS { |
| 7350 | suffix += "EMS-" |
| 7351 | } else { |
| 7352 | suffix += "NoEMS-" |
| 7353 | } |
| 7354 | |
| 7355 | if isClient { |
| 7356 | suffix += "Client" |
| 7357 | } else { |
| 7358 | suffix += "Server" |
| 7359 | } |
| 7360 | |
| 7361 | test := testCase{ |
| 7362 | name: "TLSUnique-" + suffix, |
| 7363 | testTLSUnique: true, |
| 7364 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7365 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7366 | Bugs: ProtocolBugs{ |
| 7367 | NoExtendedMasterSecret: !hasEMS, |
| 7368 | }, |
| 7369 | }, |
| 7370 | } |
| 7371 | |
| 7372 | if isResumption { |
| 7373 | test.resumeSession = true |
| 7374 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7375 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7376 | Bugs: ProtocolBugs{ |
| 7377 | NoExtendedMasterSecret: !hasEMS, |
| 7378 | }, |
| 7379 | } |
| 7380 | } |
| 7381 | |
| 7382 | if isResumption && !hasEMS { |
| 7383 | test.shouldFail = true |
| 7384 | test.expectedError = "failed to get tls-unique" |
| 7385 | } |
| 7386 | |
| 7387 | testCases = append(testCases, test) |
| 7388 | } |
| 7389 | } |
| 7390 | } |
| 7391 | } |
| 7392 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7393 | func addCustomExtensionTests() { |
| 7394 | expectedContents := "custom extension" |
| 7395 | emptyString := "" |
| 7396 | |
| 7397 | for _, isClient := range []bool{false, true} { |
| 7398 | suffix := "Server" |
| 7399 | flag := "-enable-server-custom-extension" |
| 7400 | testType := serverTest |
| 7401 | if isClient { |
| 7402 | suffix = "Client" |
| 7403 | flag = "-enable-client-custom-extension" |
| 7404 | testType = clientTest |
| 7405 | } |
| 7406 | |
| 7407 | testCases = append(testCases, testCase{ |
| 7408 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7409 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7411 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7412 | Bugs: ProtocolBugs{ |
| 7413 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7414 | ExpectedCustomExtension: &expectedContents, |
| 7415 | }, |
| 7416 | }, |
| 7417 | flags: []string{flag}, |
| 7418 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7419 | testCases = append(testCases, testCase{ |
| 7420 | testType: testType, |
| 7421 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7422 | config: Config{ |
| 7423 | MaxVersion: VersionTLS13, |
| 7424 | Bugs: ProtocolBugs{ |
| 7425 | CustomExtension: expectedContents, |
| 7426 | ExpectedCustomExtension: &expectedContents, |
| 7427 | }, |
| 7428 | }, |
| 7429 | flags: []string{flag}, |
| 7430 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7431 | |
| 7432 | // If the parse callback fails, the handshake should also fail. |
| 7433 | testCases = append(testCases, testCase{ |
| 7434 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7435 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7436 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7437 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7438 | Bugs: ProtocolBugs{ |
| 7439 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7440 | ExpectedCustomExtension: &expectedContents, |
| 7441 | }, |
| 7442 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7443 | flags: []string{flag}, |
| 7444 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7445 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7446 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7447 | testCases = append(testCases, testCase{ |
| 7448 | testType: testType, |
| 7449 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7450 | config: Config{ |
| 7451 | MaxVersion: VersionTLS13, |
| 7452 | Bugs: ProtocolBugs{ |
| 7453 | CustomExtension: expectedContents + "foo", |
| 7454 | ExpectedCustomExtension: &expectedContents, |
| 7455 | }, |
| 7456 | }, |
| 7457 | flags: []string{flag}, |
| 7458 | shouldFail: true, |
| 7459 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7460 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7461 | |
| 7462 | // If the add callback fails, the handshake should also fail. |
| 7463 | testCases = append(testCases, testCase{ |
| 7464 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7465 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7466 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7467 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7468 | Bugs: ProtocolBugs{ |
| 7469 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7470 | ExpectedCustomExtension: &expectedContents, |
| 7471 | }, |
| 7472 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7473 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7474 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7475 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7476 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7477 | testCases = append(testCases, testCase{ |
| 7478 | testType: testType, |
| 7479 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7480 | config: Config{ |
| 7481 | MaxVersion: VersionTLS13, |
| 7482 | Bugs: ProtocolBugs{ |
| 7483 | CustomExtension: expectedContents, |
| 7484 | ExpectedCustomExtension: &expectedContents, |
| 7485 | }, |
| 7486 | }, |
| 7487 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7488 | shouldFail: true, |
| 7489 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7490 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7491 | |
| 7492 | // If the add callback returns zero, no extension should be |
| 7493 | // added. |
| 7494 | skipCustomExtension := expectedContents |
| 7495 | if isClient { |
| 7496 | // For the case where the client skips sending the |
| 7497 | // custom extension, the server must not “echo” it. |
| 7498 | skipCustomExtension = "" |
| 7499 | } |
| 7500 | testCases = append(testCases, testCase{ |
| 7501 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7502 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7503 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7504 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7505 | Bugs: ProtocolBugs{ |
| 7506 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7507 | ExpectedCustomExtension: &emptyString, |
| 7508 | }, |
| 7509 | }, |
| 7510 | flags: []string{flag, "-custom-extension-skip"}, |
| 7511 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7512 | testCases = append(testCases, testCase{ |
| 7513 | testType: testType, |
| 7514 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7515 | config: Config{ |
| 7516 | MaxVersion: VersionTLS13, |
| 7517 | Bugs: ProtocolBugs{ |
| 7518 | CustomExtension: skipCustomExtension, |
| 7519 | ExpectedCustomExtension: &emptyString, |
| 7520 | }, |
| 7521 | }, |
| 7522 | flags: []string{flag, "-custom-extension-skip"}, |
| 7523 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7524 | } |
| 7525 | |
| 7526 | // The custom extension add callback should not be called if the client |
| 7527 | // doesn't send the extension. |
| 7528 | testCases = append(testCases, testCase{ |
| 7529 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7530 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7531 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7532 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7533 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7534 | ExpectedCustomExtension: &emptyString, |
| 7535 | }, |
| 7536 | }, |
| 7537 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7538 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7539 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7540 | testCases = append(testCases, testCase{ |
| 7541 | testType: serverTest, |
| 7542 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7543 | config: Config{ |
| 7544 | MaxVersion: VersionTLS13, |
| 7545 | Bugs: ProtocolBugs{ |
| 7546 | ExpectedCustomExtension: &emptyString, |
| 7547 | }, |
| 7548 | }, |
| 7549 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7550 | }) |
| 7551 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7552 | // Test an unknown extension from the server. |
| 7553 | testCases = append(testCases, testCase{ |
| 7554 | testType: clientTest, |
| 7555 | name: "UnknownExtension-Client", |
| 7556 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7557 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7558 | Bugs: ProtocolBugs{ |
| 7559 | CustomExtension: expectedContents, |
| 7560 | }, |
| 7561 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7562 | shouldFail: true, |
| 7563 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7564 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7565 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7566 | testCases = append(testCases, testCase{ |
| 7567 | testType: clientTest, |
| 7568 | name: "UnknownExtension-Client-TLS13", |
| 7569 | config: Config{ |
| 7570 | MaxVersion: VersionTLS13, |
| 7571 | Bugs: ProtocolBugs{ |
| 7572 | CustomExtension: expectedContents, |
| 7573 | }, |
| 7574 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7575 | shouldFail: true, |
| 7576 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7577 | expectedLocalError: "remote error: unsupported extension", |
| 7578 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7579 | testCases = append(testCases, testCase{ |
| 7580 | testType: clientTest, |
| 7581 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7582 | config: Config{ |
| 7583 | MaxVersion: VersionTLS13, |
| 7584 | Bugs: ProtocolBugs{ |
| 7585 | CustomUnencryptedExtension: expectedContents, |
| 7586 | }, |
| 7587 | }, |
| 7588 | shouldFail: true, |
| 7589 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7590 | // The shim must send an alert, but alerts at this point do not |
| 7591 | // get successfully decrypted by the runner. |
| 7592 | expectedLocalError: "local error: bad record MAC", |
| 7593 | }) |
| 7594 | testCases = append(testCases, testCase{ |
| 7595 | testType: clientTest, |
| 7596 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7597 | config: Config{ |
| 7598 | MaxVersion: VersionTLS13, |
| 7599 | Bugs: ProtocolBugs{ |
| 7600 | SendUnencryptedALPN: "foo", |
| 7601 | }, |
| 7602 | }, |
| 7603 | flags: []string{ |
| 7604 | "-advertise-alpn", "\x03foo\x03bar", |
| 7605 | }, |
| 7606 | shouldFail: true, |
| 7607 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7608 | // The shim must send an alert, but alerts at this point do not |
| 7609 | // get successfully decrypted by the runner. |
| 7610 | expectedLocalError: "local error: bad record MAC", |
| 7611 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7612 | |
| 7613 | // Test a known but unoffered extension from the server. |
| 7614 | testCases = append(testCases, testCase{ |
| 7615 | testType: clientTest, |
| 7616 | name: "UnofferedExtension-Client", |
| 7617 | config: Config{ |
| 7618 | MaxVersion: VersionTLS12, |
| 7619 | Bugs: ProtocolBugs{ |
| 7620 | SendALPN: "alpn", |
| 7621 | }, |
| 7622 | }, |
| 7623 | shouldFail: true, |
| 7624 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7625 | expectedLocalError: "remote error: unsupported extension", |
| 7626 | }) |
| 7627 | testCases = append(testCases, testCase{ |
| 7628 | testType: clientTest, |
| 7629 | name: "UnofferedExtension-Client-TLS13", |
| 7630 | config: Config{ |
| 7631 | MaxVersion: VersionTLS13, |
| 7632 | Bugs: ProtocolBugs{ |
| 7633 | SendALPN: "alpn", |
| 7634 | }, |
| 7635 | }, |
| 7636 | shouldFail: true, |
| 7637 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7638 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7639 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7640 | } |
| 7641 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7642 | func addRSAClientKeyExchangeTests() { |
| 7643 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7644 | testCases = append(testCases, testCase{ |
| 7645 | testType: serverTest, |
| 7646 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7647 | config: Config{ |
| 7648 | // Ensure the ClientHello version and final |
| 7649 | // version are different, to detect if the |
| 7650 | // server uses the wrong one. |
| 7651 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7652 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7653 | Bugs: ProtocolBugs{ |
| 7654 | BadRSAClientKeyExchange: bad, |
| 7655 | }, |
| 7656 | }, |
| 7657 | shouldFail: true, |
| 7658 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7659 | }) |
| 7660 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7661 | |
| 7662 | // The server must compare whatever was in ClientHello.version for the |
| 7663 | // RSA premaster. |
| 7664 | testCases = append(testCases, testCase{ |
| 7665 | testType: serverTest, |
| 7666 | name: "SendClientVersion-RSA", |
| 7667 | config: Config{ |
| 7668 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7669 | Bugs: ProtocolBugs{ |
| 7670 | SendClientVersion: 0x1234, |
| 7671 | }, |
| 7672 | }, |
| 7673 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7674 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7675 | } |
| 7676 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7677 | var testCurves = []struct { |
| 7678 | name string |
| 7679 | id CurveID |
| 7680 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7681 | {"P-256", CurveP256}, |
| 7682 | {"P-384", CurveP384}, |
| 7683 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7684 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7685 | } |
| 7686 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7687 | const bogusCurve = 0x1234 |
| 7688 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7689 | func addCurveTests() { |
| 7690 | for _, curve := range testCurves { |
| 7691 | testCases = append(testCases, testCase{ |
| 7692 | name: "CurveTest-Client-" + curve.name, |
| 7693 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7694 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7695 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7696 | CurvePreferences: []CurveID{curve.id}, |
| 7697 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7698 | flags: []string{ |
| 7699 | "-enable-all-curves", |
| 7700 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7701 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7702 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7703 | }) |
| 7704 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7705 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7706 | config: Config{ |
| 7707 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7708 | CurvePreferences: []CurveID{curve.id}, |
| 7709 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7710 | flags: []string{ |
| 7711 | "-enable-all-curves", |
| 7712 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7713 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7714 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7715 | }) |
| 7716 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7717 | testType: serverTest, |
| 7718 | name: "CurveTest-Server-" + curve.name, |
| 7719 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7720 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7721 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7722 | CurvePreferences: []CurveID{curve.id}, |
| 7723 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7724 | flags: []string{ |
| 7725 | "-enable-all-curves", |
| 7726 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7727 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7728 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7729 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7730 | testCases = append(testCases, testCase{ |
| 7731 | testType: serverTest, |
| 7732 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7733 | config: Config{ |
| 7734 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7735 | CurvePreferences: []CurveID{curve.id}, |
| 7736 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7737 | flags: []string{ |
| 7738 | "-enable-all-curves", |
| 7739 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7740 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7741 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7742 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7743 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7744 | |
| 7745 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7746 | testCases = append(testCases, testCase{ |
| 7747 | testType: serverTest, |
| 7748 | name: "UnknownCurve", |
| 7749 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7750 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7751 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7752 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7753 | }, |
| 7754 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7755 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7756 | // The server must be tolerant to bogus curves. |
| 7757 | testCases = append(testCases, testCase{ |
| 7758 | testType: serverTest, |
| 7759 | name: "UnknownCurve-TLS13", |
| 7760 | config: Config{ |
| 7761 | MaxVersion: VersionTLS13, |
| 7762 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7763 | }, |
| 7764 | }) |
| 7765 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7766 | // The server must not consider ECDHE ciphers when there are no |
| 7767 | // supported curves. |
| 7768 | testCases = append(testCases, testCase{ |
| 7769 | testType: serverTest, |
| 7770 | name: "NoSupportedCurves", |
| 7771 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7772 | MaxVersion: VersionTLS12, |
| 7773 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7774 | Bugs: ProtocolBugs{ |
| 7775 | NoSupportedCurves: true, |
| 7776 | }, |
| 7777 | }, |
| 7778 | shouldFail: true, |
| 7779 | expectedError: ":NO_SHARED_CIPHER:", |
| 7780 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7781 | testCases = append(testCases, testCase{ |
| 7782 | testType: serverTest, |
| 7783 | name: "NoSupportedCurves-TLS13", |
| 7784 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7785 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7786 | Bugs: ProtocolBugs{ |
| 7787 | NoSupportedCurves: true, |
| 7788 | }, |
| 7789 | }, |
| 7790 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7791 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7792 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7793 | |
| 7794 | // The server must fall back to another cipher when there are no |
| 7795 | // supported curves. |
| 7796 | testCases = append(testCases, testCase{ |
| 7797 | testType: serverTest, |
| 7798 | name: "NoCommonCurves", |
| 7799 | config: Config{ |
| 7800 | MaxVersion: VersionTLS12, |
| 7801 | CipherSuites: []uint16{ |
| 7802 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7803 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7804 | }, |
| 7805 | CurvePreferences: []CurveID{CurveP224}, |
| 7806 | }, |
| 7807 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7808 | }) |
| 7809 | |
| 7810 | // The client must reject bogus curves and disabled curves. |
| 7811 | testCases = append(testCases, testCase{ |
| 7812 | name: "BadECDHECurve", |
| 7813 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7814 | MaxVersion: VersionTLS12, |
| 7815 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7816 | Bugs: ProtocolBugs{ |
| 7817 | SendCurve: bogusCurve, |
| 7818 | }, |
| 7819 | }, |
| 7820 | shouldFail: true, |
| 7821 | expectedError: ":WRONG_CURVE:", |
| 7822 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7823 | testCases = append(testCases, testCase{ |
| 7824 | name: "BadECDHECurve-TLS13", |
| 7825 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7826 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7827 | Bugs: ProtocolBugs{ |
| 7828 | SendCurve: bogusCurve, |
| 7829 | }, |
| 7830 | }, |
| 7831 | shouldFail: true, |
| 7832 | expectedError: ":WRONG_CURVE:", |
| 7833 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7834 | |
| 7835 | testCases = append(testCases, testCase{ |
| 7836 | name: "UnsupportedCurve", |
| 7837 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7838 | MaxVersion: VersionTLS12, |
| 7839 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7840 | CurvePreferences: []CurveID{CurveP256}, |
| 7841 | Bugs: ProtocolBugs{ |
| 7842 | IgnorePeerCurvePreferences: true, |
| 7843 | }, |
| 7844 | }, |
| 7845 | flags: []string{"-p384-only"}, |
| 7846 | shouldFail: true, |
| 7847 | expectedError: ":WRONG_CURVE:", |
| 7848 | }) |
| 7849 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7850 | testCases = append(testCases, testCase{ |
| 7851 | // TODO(davidben): Add a TLS 1.3 version where |
| 7852 | // HelloRetryRequest requests an unsupported curve. |
| 7853 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 7854 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7855 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7856 | CurvePreferences: []CurveID{CurveP384}, |
| 7857 | Bugs: ProtocolBugs{ |
| 7858 | SendCurve: CurveP256, |
| 7859 | }, |
| 7860 | }, |
| 7861 | flags: []string{"-p384-only"}, |
| 7862 | shouldFail: true, |
| 7863 | expectedError: ":WRONG_CURVE:", |
| 7864 | }) |
| 7865 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7866 | // Test invalid curve points. |
| 7867 | testCases = append(testCases, testCase{ |
| 7868 | name: "InvalidECDHPoint-Client", |
| 7869 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7870 | MaxVersion: VersionTLS12, |
| 7871 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7872 | CurvePreferences: []CurveID{CurveP256}, |
| 7873 | Bugs: ProtocolBugs{ |
| 7874 | InvalidECDHPoint: true, |
| 7875 | }, |
| 7876 | }, |
| 7877 | shouldFail: true, |
| 7878 | expectedError: ":INVALID_ENCODING:", |
| 7879 | }) |
| 7880 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7881 | name: "InvalidECDHPoint-Client-TLS13", |
| 7882 | config: Config{ |
| 7883 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7884 | CurvePreferences: []CurveID{CurveP256}, |
| 7885 | Bugs: ProtocolBugs{ |
| 7886 | InvalidECDHPoint: true, |
| 7887 | }, |
| 7888 | }, |
| 7889 | shouldFail: true, |
| 7890 | expectedError: ":INVALID_ENCODING:", |
| 7891 | }) |
| 7892 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7893 | testType: serverTest, |
| 7894 | name: "InvalidECDHPoint-Server", |
| 7895 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7896 | MaxVersion: VersionTLS12, |
| 7897 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7898 | CurvePreferences: []CurveID{CurveP256}, |
| 7899 | Bugs: ProtocolBugs{ |
| 7900 | InvalidECDHPoint: true, |
| 7901 | }, |
| 7902 | }, |
| 7903 | shouldFail: true, |
| 7904 | expectedError: ":INVALID_ENCODING:", |
| 7905 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7906 | testCases = append(testCases, testCase{ |
| 7907 | testType: serverTest, |
| 7908 | name: "InvalidECDHPoint-Server-TLS13", |
| 7909 | config: Config{ |
| 7910 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7911 | CurvePreferences: []CurveID{CurveP256}, |
| 7912 | Bugs: ProtocolBugs{ |
| 7913 | InvalidECDHPoint: true, |
| 7914 | }, |
| 7915 | }, |
| 7916 | shouldFail: true, |
| 7917 | expectedError: ":INVALID_ENCODING:", |
| 7918 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7919 | } |
| 7920 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7921 | func addCECPQ1Tests() { |
| 7922 | testCases = append(testCases, testCase{ |
| 7923 | testType: clientTest, |
| 7924 | name: "CECPQ1-Client-BadX25519Part", |
| 7925 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7926 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7927 | MinVersion: VersionTLS12, |
| 7928 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7929 | Bugs: ProtocolBugs{ |
| 7930 | CECPQ1BadX25519Part: true, |
| 7931 | }, |
| 7932 | }, |
| 7933 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7934 | shouldFail: true, |
| 7935 | expectedLocalError: "local error: bad record MAC", |
| 7936 | }) |
| 7937 | testCases = append(testCases, testCase{ |
| 7938 | testType: clientTest, |
| 7939 | name: "CECPQ1-Client-BadNewhopePart", |
| 7940 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7941 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7942 | MinVersion: VersionTLS12, |
| 7943 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7944 | Bugs: ProtocolBugs{ |
| 7945 | CECPQ1BadNewhopePart: true, |
| 7946 | }, |
| 7947 | }, |
| 7948 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7949 | shouldFail: true, |
| 7950 | expectedLocalError: "local error: bad record MAC", |
| 7951 | }) |
| 7952 | testCases = append(testCases, testCase{ |
| 7953 | testType: serverTest, |
| 7954 | name: "CECPQ1-Server-BadX25519Part", |
| 7955 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7956 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7957 | MinVersion: VersionTLS12, |
| 7958 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7959 | Bugs: ProtocolBugs{ |
| 7960 | CECPQ1BadX25519Part: true, |
| 7961 | }, |
| 7962 | }, |
| 7963 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7964 | shouldFail: true, |
| 7965 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7966 | }) |
| 7967 | testCases = append(testCases, testCase{ |
| 7968 | testType: serverTest, |
| 7969 | name: "CECPQ1-Server-BadNewhopePart", |
| 7970 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7971 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7972 | MinVersion: VersionTLS12, |
| 7973 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7974 | Bugs: ProtocolBugs{ |
| 7975 | CECPQ1BadNewhopePart: true, |
| 7976 | }, |
| 7977 | }, |
| 7978 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7979 | shouldFail: true, |
| 7980 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7981 | }) |
| 7982 | } |
| 7983 | |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7984 | func addDHEGroupSizeTests() { |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7985 | testCases = append(testCases, testCase{ |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7986 | name: "DHEGroupSize-Client", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7987 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7988 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7989 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7990 | Bugs: ProtocolBugs{ |
| 7991 | // This is a 1234-bit prime number, generated |
| 7992 | // with: |
| 7993 | // openssl gendh 1234 | openssl asn1parse -i |
| 7994 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 7995 | }, |
| 7996 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7997 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7998 | }) |
| 7999 | testCases = append(testCases, testCase{ |
| 8000 | testType: serverTest, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8001 | name: "DHEGroupSize-Server", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8002 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8003 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8004 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8005 | }, |
| 8006 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 8007 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8008 | }) |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8009 | } |
| 8010 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8011 | func addTLS13RecordTests() { |
| 8012 | testCases = append(testCases, testCase{ |
| 8013 | name: "TLS13-RecordPadding", |
| 8014 | config: Config{ |
| 8015 | MaxVersion: VersionTLS13, |
| 8016 | MinVersion: VersionTLS13, |
| 8017 | Bugs: ProtocolBugs{ |
| 8018 | RecordPadding: 10, |
| 8019 | }, |
| 8020 | }, |
| 8021 | }) |
| 8022 | |
| 8023 | testCases = append(testCases, testCase{ |
| 8024 | name: "TLS13-EmptyRecords", |
| 8025 | config: Config{ |
| 8026 | MaxVersion: VersionTLS13, |
| 8027 | MinVersion: VersionTLS13, |
| 8028 | Bugs: ProtocolBugs{ |
| 8029 | OmitRecordContents: true, |
| 8030 | }, |
| 8031 | }, |
| 8032 | shouldFail: true, |
| 8033 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8034 | }) |
| 8035 | |
| 8036 | testCases = append(testCases, testCase{ |
| 8037 | name: "TLS13-OnlyPadding", |
| 8038 | config: Config{ |
| 8039 | MaxVersion: VersionTLS13, |
| 8040 | MinVersion: VersionTLS13, |
| 8041 | Bugs: ProtocolBugs{ |
| 8042 | OmitRecordContents: true, |
| 8043 | RecordPadding: 10, |
| 8044 | }, |
| 8045 | }, |
| 8046 | shouldFail: true, |
| 8047 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8048 | }) |
| 8049 | |
| 8050 | testCases = append(testCases, testCase{ |
| 8051 | name: "TLS13-WrongOuterRecord", |
| 8052 | config: Config{ |
| 8053 | MaxVersion: VersionTLS13, |
| 8054 | MinVersion: VersionTLS13, |
| 8055 | Bugs: ProtocolBugs{ |
| 8056 | OuterRecordType: recordTypeHandshake, |
| 8057 | }, |
| 8058 | }, |
| 8059 | shouldFail: true, |
| 8060 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8061 | }) |
| 8062 | } |
| 8063 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8064 | func addSessionTicketTests() { |
| 8065 | testCases = append(testCases, testCase{ |
| 8066 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8067 | // mean the server changed its mind on sending a ticket. |
| 8068 | name: "SendEmptySessionTicket", |
| 8069 | config: Config{ |
| 8070 | MaxVersion: VersionTLS12, |
| 8071 | Bugs: ProtocolBugs{ |
| 8072 | SendEmptySessionTicket: true, |
| 8073 | }, |
| 8074 | }, |
| 8075 | flags: []string{"-expect-no-session"}, |
| 8076 | }) |
| 8077 | |
| 8078 | // Test that the server ignores unknown PSK modes. |
| 8079 | testCases = append(testCases, testCase{ |
| 8080 | testType: serverTest, |
| 8081 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8082 | config: Config{ |
| 8083 | MaxVersion: VersionTLS13, |
| 8084 | Bugs: ProtocolBugs{ |
| 8085 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8086 | }, |
| 8087 | }, |
| 8088 | resumeSession: true, |
| 8089 | expectedResumeVersion: VersionTLS13, |
| 8090 | }) |
| 8091 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8092 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8093 | testCases = append(testCases, testCase{ |
| 8094 | testType: serverTest, |
| 8095 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8096 | config: Config{ |
| 8097 | MaxVersion: VersionTLS13, |
| 8098 | Bugs: ProtocolBugs{ |
| 8099 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8100 | ExpectNoNewSessionTicket: true, |
| 8101 | }, |
| 8102 | }, |
| 8103 | }) |
| 8104 | |
| 8105 | // 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] | 8106 | testCases = append(testCases, testCase{ |
| 8107 | testType: serverTest, |
| 8108 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8109 | config: Config{ |
| 8110 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8111 | }, |
| 8112 | resumeConfig: &Config{ |
| 8113 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8114 | Bugs: ProtocolBugs{ |
| 8115 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8116 | }, |
| 8117 | }, |
| 8118 | resumeSession: true, |
| 8119 | expectResumeRejected: true, |
| 8120 | }) |
| 8121 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8122 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8123 | testCases = append(testCases, testCase{ |
| 8124 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8125 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8126 | config: Config{ |
| 8127 | MaxVersion: VersionTLS13, |
| 8128 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8129 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8130 | }, |
| 8131 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8132 | resumeSession: true, |
| 8133 | flags: []string{ |
| 8134 | "-resumption-delay", "10", |
| 8135 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8136 | }) |
| 8137 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8138 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8139 | testCases = append(testCases, testCase{ |
| 8140 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8141 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8142 | config: Config{ |
| 8143 | MaxVersion: VersionTLS13, |
| 8144 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8145 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8146 | }, |
| 8147 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8148 | resumeSession: true, |
| 8149 | shouldFail: true, |
| 8150 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8151 | }) |
| 8152 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8153 | } |
| 8154 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8155 | func addChangeCipherSpecTests() { |
| 8156 | // Test missing ChangeCipherSpecs. |
| 8157 | testCases = append(testCases, testCase{ |
| 8158 | name: "SkipChangeCipherSpec-Client", |
| 8159 | config: Config{ |
| 8160 | MaxVersion: VersionTLS12, |
| 8161 | Bugs: ProtocolBugs{ |
| 8162 | SkipChangeCipherSpec: true, |
| 8163 | }, |
| 8164 | }, |
| 8165 | shouldFail: true, |
| 8166 | expectedError: ":UNEXPECTED_RECORD:", |
| 8167 | }) |
| 8168 | testCases = append(testCases, testCase{ |
| 8169 | testType: serverTest, |
| 8170 | name: "SkipChangeCipherSpec-Server", |
| 8171 | config: Config{ |
| 8172 | MaxVersion: VersionTLS12, |
| 8173 | Bugs: ProtocolBugs{ |
| 8174 | SkipChangeCipherSpec: true, |
| 8175 | }, |
| 8176 | }, |
| 8177 | shouldFail: true, |
| 8178 | expectedError: ":UNEXPECTED_RECORD:", |
| 8179 | }) |
| 8180 | testCases = append(testCases, testCase{ |
| 8181 | testType: serverTest, |
| 8182 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8183 | config: Config{ |
| 8184 | MaxVersion: VersionTLS12, |
| 8185 | NextProtos: []string{"bar"}, |
| 8186 | Bugs: ProtocolBugs{ |
| 8187 | SkipChangeCipherSpec: true, |
| 8188 | }, |
| 8189 | }, |
| 8190 | flags: []string{ |
| 8191 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8192 | }, |
| 8193 | shouldFail: true, |
| 8194 | expectedError: ":UNEXPECTED_RECORD:", |
| 8195 | }) |
| 8196 | |
| 8197 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8198 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8199 | // rejected. Test both with and without handshake packing to handle both |
| 8200 | // when the partial post-CCS message is in its own record and when it is |
| 8201 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8202 | for _, packed := range []bool{false, true} { |
| 8203 | var suffix string |
| 8204 | if packed { |
| 8205 | suffix = "-Packed" |
| 8206 | } |
| 8207 | |
| 8208 | testCases = append(testCases, testCase{ |
| 8209 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8210 | config: Config{ |
| 8211 | MaxVersion: VersionTLS12, |
| 8212 | Bugs: ProtocolBugs{ |
| 8213 | FragmentAcrossChangeCipherSpec: true, |
| 8214 | PackHandshakeFlight: packed, |
| 8215 | }, |
| 8216 | }, |
| 8217 | shouldFail: true, |
| 8218 | expectedError: ":UNEXPECTED_RECORD:", |
| 8219 | }) |
| 8220 | testCases = append(testCases, testCase{ |
| 8221 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8222 | config: Config{ |
| 8223 | MaxVersion: VersionTLS12, |
| 8224 | }, |
| 8225 | resumeSession: true, |
| 8226 | resumeConfig: &Config{ |
| 8227 | MaxVersion: VersionTLS12, |
| 8228 | Bugs: ProtocolBugs{ |
| 8229 | FragmentAcrossChangeCipherSpec: true, |
| 8230 | PackHandshakeFlight: packed, |
| 8231 | }, |
| 8232 | }, |
| 8233 | shouldFail: true, |
| 8234 | expectedError: ":UNEXPECTED_RECORD:", |
| 8235 | }) |
| 8236 | testCases = append(testCases, testCase{ |
| 8237 | testType: serverTest, |
| 8238 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8239 | config: Config{ |
| 8240 | MaxVersion: VersionTLS12, |
| 8241 | Bugs: ProtocolBugs{ |
| 8242 | FragmentAcrossChangeCipherSpec: true, |
| 8243 | PackHandshakeFlight: packed, |
| 8244 | }, |
| 8245 | }, |
| 8246 | shouldFail: true, |
| 8247 | expectedError: ":UNEXPECTED_RECORD:", |
| 8248 | }) |
| 8249 | testCases = append(testCases, testCase{ |
| 8250 | testType: serverTest, |
| 8251 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8252 | config: Config{ |
| 8253 | MaxVersion: VersionTLS12, |
| 8254 | }, |
| 8255 | resumeSession: true, |
| 8256 | resumeConfig: &Config{ |
| 8257 | MaxVersion: VersionTLS12, |
| 8258 | Bugs: ProtocolBugs{ |
| 8259 | FragmentAcrossChangeCipherSpec: true, |
| 8260 | PackHandshakeFlight: packed, |
| 8261 | }, |
| 8262 | }, |
| 8263 | shouldFail: true, |
| 8264 | expectedError: ":UNEXPECTED_RECORD:", |
| 8265 | }) |
| 8266 | testCases = append(testCases, testCase{ |
| 8267 | testType: serverTest, |
| 8268 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8269 | config: Config{ |
| 8270 | MaxVersion: VersionTLS12, |
| 8271 | NextProtos: []string{"bar"}, |
| 8272 | Bugs: ProtocolBugs{ |
| 8273 | FragmentAcrossChangeCipherSpec: true, |
| 8274 | PackHandshakeFlight: packed, |
| 8275 | }, |
| 8276 | }, |
| 8277 | flags: []string{ |
| 8278 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8279 | }, |
| 8280 | shouldFail: true, |
| 8281 | expectedError: ":UNEXPECTED_RECORD:", |
| 8282 | }) |
| 8283 | } |
| 8284 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8285 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8286 | // messages in the handshake queue. Do this by testing the server |
| 8287 | // reading the client Finished, reversing the flight so Finished comes |
| 8288 | // first. |
| 8289 | testCases = append(testCases, testCase{ |
| 8290 | protocol: dtls, |
| 8291 | testType: serverTest, |
| 8292 | name: "SendUnencryptedFinished-DTLS", |
| 8293 | config: Config{ |
| 8294 | MaxVersion: VersionTLS12, |
| 8295 | Bugs: ProtocolBugs{ |
| 8296 | SendUnencryptedFinished: true, |
| 8297 | ReverseHandshakeFragments: true, |
| 8298 | }, |
| 8299 | }, |
| 8300 | shouldFail: true, |
| 8301 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8302 | }) |
| 8303 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8304 | // Test synchronization between encryption changes and the handshake in |
| 8305 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8306 | testCases = append(testCases, testCase{ |
| 8307 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8308 | config: Config{ |
| 8309 | MaxVersion: VersionTLS13, |
| 8310 | Bugs: ProtocolBugs{ |
| 8311 | PartialEncryptedExtensionsWithServerHello: true, |
| 8312 | }, |
| 8313 | }, |
| 8314 | shouldFail: true, |
| 8315 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8316 | }) |
| 8317 | testCases = append(testCases, testCase{ |
| 8318 | testType: serverTest, |
| 8319 | name: "PartialClientFinishedWithClientHello", |
| 8320 | config: Config{ |
| 8321 | MaxVersion: VersionTLS13, |
| 8322 | Bugs: ProtocolBugs{ |
| 8323 | PartialClientFinishedWithClientHello: true, |
| 8324 | }, |
| 8325 | }, |
| 8326 | shouldFail: true, |
| 8327 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8328 | }) |
| 8329 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8330 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8331 | testCases = append(testCases, testCase{ |
| 8332 | testType: serverTest, |
| 8333 | name: "EarlyChangeCipherSpec-server-1", |
| 8334 | config: Config{ |
| 8335 | MaxVersion: VersionTLS12, |
| 8336 | Bugs: ProtocolBugs{ |
| 8337 | EarlyChangeCipherSpec: 1, |
| 8338 | }, |
| 8339 | }, |
| 8340 | shouldFail: true, |
| 8341 | expectedError: ":UNEXPECTED_RECORD:", |
| 8342 | }) |
| 8343 | testCases = append(testCases, testCase{ |
| 8344 | testType: serverTest, |
| 8345 | name: "EarlyChangeCipherSpec-server-2", |
| 8346 | config: Config{ |
| 8347 | MaxVersion: VersionTLS12, |
| 8348 | Bugs: ProtocolBugs{ |
| 8349 | EarlyChangeCipherSpec: 2, |
| 8350 | }, |
| 8351 | }, |
| 8352 | shouldFail: true, |
| 8353 | expectedError: ":UNEXPECTED_RECORD:", |
| 8354 | }) |
| 8355 | testCases = append(testCases, testCase{ |
| 8356 | protocol: dtls, |
| 8357 | name: "StrayChangeCipherSpec", |
| 8358 | config: Config{ |
| 8359 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8360 | // that stray ChangeCipherSpec messages are |
| 8361 | // rejected. |
| 8362 | MaxVersion: VersionTLS12, |
| 8363 | Bugs: ProtocolBugs{ |
| 8364 | StrayChangeCipherSpec: true, |
| 8365 | }, |
| 8366 | }, |
| 8367 | }) |
| 8368 | |
| 8369 | // Test that the contents of ChangeCipherSpec are checked. |
| 8370 | testCases = append(testCases, testCase{ |
| 8371 | name: "BadChangeCipherSpec-1", |
| 8372 | config: Config{ |
| 8373 | MaxVersion: VersionTLS12, |
| 8374 | Bugs: ProtocolBugs{ |
| 8375 | BadChangeCipherSpec: []byte{2}, |
| 8376 | }, |
| 8377 | }, |
| 8378 | shouldFail: true, |
| 8379 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8380 | }) |
| 8381 | testCases = append(testCases, testCase{ |
| 8382 | name: "BadChangeCipherSpec-2", |
| 8383 | config: Config{ |
| 8384 | MaxVersion: VersionTLS12, |
| 8385 | Bugs: ProtocolBugs{ |
| 8386 | BadChangeCipherSpec: []byte{1, 1}, |
| 8387 | }, |
| 8388 | }, |
| 8389 | shouldFail: true, |
| 8390 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8391 | }) |
| 8392 | testCases = append(testCases, testCase{ |
| 8393 | protocol: dtls, |
| 8394 | name: "BadChangeCipherSpec-DTLS-1", |
| 8395 | config: Config{ |
| 8396 | MaxVersion: VersionTLS12, |
| 8397 | Bugs: ProtocolBugs{ |
| 8398 | BadChangeCipherSpec: []byte{2}, |
| 8399 | }, |
| 8400 | }, |
| 8401 | shouldFail: true, |
| 8402 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8403 | }) |
| 8404 | testCases = append(testCases, testCase{ |
| 8405 | protocol: dtls, |
| 8406 | name: "BadChangeCipherSpec-DTLS-2", |
| 8407 | config: Config{ |
| 8408 | MaxVersion: VersionTLS12, |
| 8409 | Bugs: ProtocolBugs{ |
| 8410 | BadChangeCipherSpec: []byte{1, 1}, |
| 8411 | }, |
| 8412 | }, |
| 8413 | shouldFail: true, |
| 8414 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8415 | }) |
| 8416 | } |
| 8417 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8418 | type perMessageTest struct { |
| 8419 | messageType uint8 |
| 8420 | test testCase |
| 8421 | } |
| 8422 | |
| 8423 | // makePerMessageTests returns a series of test templates which cover each |
| 8424 | // message in the TLS handshake. These may be used with bugs like |
| 8425 | // WrongMessageType to fully test a per-message bug. |
| 8426 | func makePerMessageTests() []perMessageTest { |
| 8427 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8428 | for _, protocol := range []protocol{tls, dtls} { |
| 8429 | var suffix string |
| 8430 | if protocol == dtls { |
| 8431 | suffix = "-DTLS" |
| 8432 | } |
| 8433 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8434 | ret = append(ret, perMessageTest{ |
| 8435 | messageType: typeClientHello, |
| 8436 | test: testCase{ |
| 8437 | protocol: protocol, |
| 8438 | testType: serverTest, |
| 8439 | name: "ClientHello" + suffix, |
| 8440 | config: Config{ |
| 8441 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8442 | }, |
| 8443 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8444 | }) |
| 8445 | |
| 8446 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8447 | ret = append(ret, perMessageTest{ |
| 8448 | messageType: typeHelloVerifyRequest, |
| 8449 | test: testCase{ |
| 8450 | protocol: protocol, |
| 8451 | name: "HelloVerifyRequest" + suffix, |
| 8452 | config: Config{ |
| 8453 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8454 | }, |
| 8455 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8456 | }) |
| 8457 | } |
| 8458 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8459 | ret = append(ret, perMessageTest{ |
| 8460 | messageType: typeServerHello, |
| 8461 | test: testCase{ |
| 8462 | protocol: protocol, |
| 8463 | name: "ServerHello" + suffix, |
| 8464 | config: Config{ |
| 8465 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8466 | }, |
| 8467 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8468 | }) |
| 8469 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8470 | ret = append(ret, perMessageTest{ |
| 8471 | messageType: typeCertificate, |
| 8472 | test: testCase{ |
| 8473 | protocol: protocol, |
| 8474 | name: "ServerCertificate" + suffix, |
| 8475 | config: Config{ |
| 8476 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8477 | }, |
| 8478 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8479 | }) |
| 8480 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8481 | ret = append(ret, perMessageTest{ |
| 8482 | messageType: typeCertificateStatus, |
| 8483 | test: testCase{ |
| 8484 | protocol: protocol, |
| 8485 | name: "CertificateStatus" + suffix, |
| 8486 | config: Config{ |
| 8487 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8488 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8489 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8490 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8491 | }) |
| 8492 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8493 | ret = append(ret, perMessageTest{ |
| 8494 | messageType: typeServerKeyExchange, |
| 8495 | test: testCase{ |
| 8496 | protocol: protocol, |
| 8497 | name: "ServerKeyExchange" + suffix, |
| 8498 | config: Config{ |
| 8499 | MaxVersion: VersionTLS12, |
| 8500 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8501 | }, |
| 8502 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8503 | }) |
| 8504 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8505 | ret = append(ret, perMessageTest{ |
| 8506 | messageType: typeCertificateRequest, |
| 8507 | test: testCase{ |
| 8508 | protocol: protocol, |
| 8509 | name: "CertificateRequest" + suffix, |
| 8510 | config: Config{ |
| 8511 | MaxVersion: VersionTLS12, |
| 8512 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8513 | }, |
| 8514 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8515 | }) |
| 8516 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8517 | ret = append(ret, perMessageTest{ |
| 8518 | messageType: typeServerHelloDone, |
| 8519 | test: testCase{ |
| 8520 | protocol: protocol, |
| 8521 | name: "ServerHelloDone" + suffix, |
| 8522 | config: Config{ |
| 8523 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8524 | }, |
| 8525 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8526 | }) |
| 8527 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8528 | ret = append(ret, perMessageTest{ |
| 8529 | messageType: typeCertificate, |
| 8530 | test: testCase{ |
| 8531 | testType: serverTest, |
| 8532 | protocol: protocol, |
| 8533 | name: "ClientCertificate" + suffix, |
| 8534 | config: Config{ |
| 8535 | Certificates: []Certificate{rsaCertificate}, |
| 8536 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8537 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8538 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8539 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8540 | }) |
| 8541 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8542 | ret = append(ret, perMessageTest{ |
| 8543 | messageType: typeCertificateVerify, |
| 8544 | test: testCase{ |
| 8545 | testType: serverTest, |
| 8546 | protocol: protocol, |
| 8547 | name: "CertificateVerify" + suffix, |
| 8548 | config: Config{ |
| 8549 | Certificates: []Certificate{rsaCertificate}, |
| 8550 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8551 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8552 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8553 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8554 | }) |
| 8555 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8556 | ret = append(ret, perMessageTest{ |
| 8557 | messageType: typeClientKeyExchange, |
| 8558 | test: testCase{ |
| 8559 | testType: serverTest, |
| 8560 | protocol: protocol, |
| 8561 | name: "ClientKeyExchange" + suffix, |
| 8562 | config: Config{ |
| 8563 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8564 | }, |
| 8565 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8566 | }) |
| 8567 | |
| 8568 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8569 | ret = append(ret, perMessageTest{ |
| 8570 | messageType: typeNextProtocol, |
| 8571 | test: testCase{ |
| 8572 | testType: serverTest, |
| 8573 | protocol: protocol, |
| 8574 | name: "NextProtocol" + suffix, |
| 8575 | config: Config{ |
| 8576 | MaxVersion: VersionTLS12, |
| 8577 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8578 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8579 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8580 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8581 | }) |
| 8582 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8583 | ret = append(ret, perMessageTest{ |
| 8584 | messageType: typeChannelID, |
| 8585 | test: testCase{ |
| 8586 | testType: serverTest, |
| 8587 | protocol: protocol, |
| 8588 | name: "ChannelID" + suffix, |
| 8589 | config: Config{ |
| 8590 | MaxVersion: VersionTLS12, |
| 8591 | ChannelID: channelIDKey, |
| 8592 | }, |
| 8593 | flags: []string{ |
| 8594 | "-expect-channel-id", |
| 8595 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8596 | }, |
| 8597 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8598 | }) |
| 8599 | } |
| 8600 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8601 | ret = append(ret, perMessageTest{ |
| 8602 | messageType: typeFinished, |
| 8603 | test: testCase{ |
| 8604 | testType: serverTest, |
| 8605 | protocol: protocol, |
| 8606 | name: "ClientFinished" + suffix, |
| 8607 | config: Config{ |
| 8608 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8609 | }, |
| 8610 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8611 | }) |
| 8612 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8613 | ret = append(ret, perMessageTest{ |
| 8614 | messageType: typeNewSessionTicket, |
| 8615 | test: testCase{ |
| 8616 | protocol: protocol, |
| 8617 | name: "NewSessionTicket" + suffix, |
| 8618 | config: Config{ |
| 8619 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8620 | }, |
| 8621 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8622 | }) |
| 8623 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8624 | ret = append(ret, perMessageTest{ |
| 8625 | messageType: typeFinished, |
| 8626 | test: testCase{ |
| 8627 | protocol: protocol, |
| 8628 | name: "ServerFinished" + suffix, |
| 8629 | config: Config{ |
| 8630 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8631 | }, |
| 8632 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8633 | }) |
| 8634 | |
| 8635 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8636 | |
| 8637 | ret = append(ret, perMessageTest{ |
| 8638 | messageType: typeClientHello, |
| 8639 | test: testCase{ |
| 8640 | testType: serverTest, |
| 8641 | name: "TLS13-ClientHello", |
| 8642 | config: Config{ |
| 8643 | MaxVersion: VersionTLS13, |
| 8644 | }, |
| 8645 | }, |
| 8646 | }) |
| 8647 | |
| 8648 | ret = append(ret, perMessageTest{ |
| 8649 | messageType: typeServerHello, |
| 8650 | test: testCase{ |
| 8651 | name: "TLS13-ServerHello", |
| 8652 | config: Config{ |
| 8653 | MaxVersion: VersionTLS13, |
| 8654 | }, |
| 8655 | }, |
| 8656 | }) |
| 8657 | |
| 8658 | ret = append(ret, perMessageTest{ |
| 8659 | messageType: typeEncryptedExtensions, |
| 8660 | test: testCase{ |
| 8661 | name: "TLS13-EncryptedExtensions", |
| 8662 | config: Config{ |
| 8663 | MaxVersion: VersionTLS13, |
| 8664 | }, |
| 8665 | }, |
| 8666 | }) |
| 8667 | |
| 8668 | ret = append(ret, perMessageTest{ |
| 8669 | messageType: typeCertificateRequest, |
| 8670 | test: testCase{ |
| 8671 | name: "TLS13-CertificateRequest", |
| 8672 | config: Config{ |
| 8673 | MaxVersion: VersionTLS13, |
| 8674 | ClientAuth: RequireAnyClientCert, |
| 8675 | }, |
| 8676 | }, |
| 8677 | }) |
| 8678 | |
| 8679 | ret = append(ret, perMessageTest{ |
| 8680 | messageType: typeCertificate, |
| 8681 | test: testCase{ |
| 8682 | name: "TLS13-ServerCertificate", |
| 8683 | config: Config{ |
| 8684 | MaxVersion: VersionTLS13, |
| 8685 | }, |
| 8686 | }, |
| 8687 | }) |
| 8688 | |
| 8689 | ret = append(ret, perMessageTest{ |
| 8690 | messageType: typeCertificateVerify, |
| 8691 | test: testCase{ |
| 8692 | name: "TLS13-ServerCertificateVerify", |
| 8693 | config: Config{ |
| 8694 | MaxVersion: VersionTLS13, |
| 8695 | }, |
| 8696 | }, |
| 8697 | }) |
| 8698 | |
| 8699 | ret = append(ret, perMessageTest{ |
| 8700 | messageType: typeFinished, |
| 8701 | test: testCase{ |
| 8702 | name: "TLS13-ServerFinished", |
| 8703 | config: Config{ |
| 8704 | MaxVersion: VersionTLS13, |
| 8705 | }, |
| 8706 | }, |
| 8707 | }) |
| 8708 | |
| 8709 | ret = append(ret, perMessageTest{ |
| 8710 | messageType: typeCertificate, |
| 8711 | test: testCase{ |
| 8712 | testType: serverTest, |
| 8713 | name: "TLS13-ClientCertificate", |
| 8714 | config: Config{ |
| 8715 | Certificates: []Certificate{rsaCertificate}, |
| 8716 | MaxVersion: VersionTLS13, |
| 8717 | }, |
| 8718 | flags: []string{"-require-any-client-certificate"}, |
| 8719 | }, |
| 8720 | }) |
| 8721 | |
| 8722 | ret = append(ret, perMessageTest{ |
| 8723 | messageType: typeCertificateVerify, |
| 8724 | test: testCase{ |
| 8725 | testType: serverTest, |
| 8726 | name: "TLS13-ClientCertificateVerify", |
| 8727 | config: Config{ |
| 8728 | Certificates: []Certificate{rsaCertificate}, |
| 8729 | MaxVersion: VersionTLS13, |
| 8730 | }, |
| 8731 | flags: []string{"-require-any-client-certificate"}, |
| 8732 | }, |
| 8733 | }) |
| 8734 | |
| 8735 | ret = append(ret, perMessageTest{ |
| 8736 | messageType: typeFinished, |
| 8737 | test: testCase{ |
| 8738 | testType: serverTest, |
| 8739 | name: "TLS13-ClientFinished", |
| 8740 | config: Config{ |
| 8741 | MaxVersion: VersionTLS13, |
| 8742 | }, |
| 8743 | }, |
| 8744 | }) |
| 8745 | |
| 8746 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8747 | } |
| 8748 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8749 | func addWrongMessageTypeTests() { |
| 8750 | for _, t := range makePerMessageTests() { |
| 8751 | t.test.name = "WrongMessageType-" + t.test.name |
| 8752 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 8753 | t.test.shouldFail = true |
| 8754 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 8755 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8756 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8757 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8758 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8759 | // an unencrypted alert while the server expects |
| 8760 | // encryption, so the alert is not readable by runner. |
| 8761 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8762 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8763 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8764 | testCases = append(testCases, t.test) |
| 8765 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8766 | } |
| 8767 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8768 | func addTrailingMessageDataTests() { |
| 8769 | for _, t := range makePerMessageTests() { |
| 8770 | t.test.name = "TrailingMessageData-" + t.test.name |
| 8771 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 8772 | t.test.shouldFail = true |
| 8773 | t.test.expectedError = ":DECODE_ERROR:" |
| 8774 | t.test.expectedLocalError = "remote error: error decoding message" |
| 8775 | |
| 8776 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8777 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8778 | // an unencrypted alert while the server expects |
| 8779 | // encryption, so the alert is not readable by runner. |
| 8780 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8781 | } |
| 8782 | |
| 8783 | if t.messageType == typeFinished { |
| 8784 | // Bad Finished messages read as the verify data having |
| 8785 | // the wrong length. |
| 8786 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 8787 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 8788 | } |
| 8789 | |
| 8790 | testCases = append(testCases, t.test) |
| 8791 | } |
| 8792 | } |
| 8793 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8794 | func addTLS13HandshakeTests() { |
| 8795 | testCases = append(testCases, testCase{ |
| 8796 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8797 | name: "NegotiatePSKResumption-TLS13", |
| 8798 | config: Config{ |
| 8799 | MaxVersion: VersionTLS13, |
| 8800 | Bugs: ProtocolBugs{ |
| 8801 | NegotiatePSKResumption: true, |
| 8802 | }, |
| 8803 | }, |
| 8804 | resumeSession: true, |
| 8805 | shouldFail: true, |
| 8806 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8807 | }) |
| 8808 | |
| 8809 | testCases = append(testCases, testCase{ |
| 8810 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8811 | name: "MissingKeyShare-Client", |
| 8812 | config: Config{ |
| 8813 | MaxVersion: VersionTLS13, |
| 8814 | Bugs: ProtocolBugs{ |
| 8815 | MissingKeyShare: true, |
| 8816 | }, |
| 8817 | }, |
| 8818 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8819 | expectedError: ":UNEXPECTED_EXTENSION:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8820 | }) |
| 8821 | |
| 8822 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8823 | testType: serverTest, |
| 8824 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8825 | config: Config{ |
| 8826 | MaxVersion: VersionTLS13, |
| 8827 | Bugs: ProtocolBugs{ |
| 8828 | MissingKeyShare: true, |
| 8829 | }, |
| 8830 | }, |
| 8831 | shouldFail: true, |
| 8832 | expectedError: ":MISSING_KEY_SHARE:", |
| 8833 | }) |
| 8834 | |
| 8835 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8836 | testType: serverTest, |
| 8837 | name: "DuplicateKeyShares", |
| 8838 | config: Config{ |
| 8839 | MaxVersion: VersionTLS13, |
| 8840 | Bugs: ProtocolBugs{ |
| 8841 | DuplicateKeyShares: true, |
| 8842 | }, |
| 8843 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 8844 | shouldFail: true, |
| 8845 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8846 | }) |
| 8847 | |
| 8848 | testCases = append(testCases, testCase{ |
| 8849 | testType: clientTest, |
| 8850 | name: "EmptyEncryptedExtensions", |
| 8851 | config: Config{ |
| 8852 | MaxVersion: VersionTLS13, |
| 8853 | Bugs: ProtocolBugs{ |
| 8854 | EmptyEncryptedExtensions: true, |
| 8855 | }, |
| 8856 | }, |
| 8857 | shouldFail: true, |
| 8858 | expectedLocalError: "remote error: error decoding message", |
| 8859 | }) |
| 8860 | |
| 8861 | testCases = append(testCases, testCase{ |
| 8862 | testType: clientTest, |
| 8863 | name: "EncryptedExtensionsWithKeyShare", |
| 8864 | config: Config{ |
| 8865 | MaxVersion: VersionTLS13, |
| 8866 | Bugs: ProtocolBugs{ |
| 8867 | EncryptedExtensionsWithKeyShare: true, |
| 8868 | }, |
| 8869 | }, |
| 8870 | shouldFail: true, |
| 8871 | expectedLocalError: "remote error: unsupported extension", |
| 8872 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8873 | |
| 8874 | testCases = append(testCases, testCase{ |
| 8875 | testType: serverTest, |
| 8876 | name: "SendHelloRetryRequest", |
| 8877 | config: Config{ |
| 8878 | MaxVersion: VersionTLS13, |
| 8879 | // Require a HelloRetryRequest for every curve. |
| 8880 | DefaultCurves: []CurveID{}, |
| 8881 | }, |
| 8882 | expectedCurveID: CurveX25519, |
| 8883 | }) |
| 8884 | |
| 8885 | testCases = append(testCases, testCase{ |
| 8886 | testType: serverTest, |
| 8887 | name: "SendHelloRetryRequest-2", |
| 8888 | config: Config{ |
| 8889 | MaxVersion: VersionTLS13, |
| 8890 | DefaultCurves: []CurveID{CurveP384}, |
| 8891 | }, |
| 8892 | // Although the ClientHello did not predict our preferred curve, |
| 8893 | // we always select it whether it is predicted or not. |
| 8894 | expectedCurveID: CurveX25519, |
| 8895 | }) |
| 8896 | |
| 8897 | testCases = append(testCases, testCase{ |
| 8898 | name: "UnknownCurve-HelloRetryRequest", |
| 8899 | config: Config{ |
| 8900 | MaxVersion: VersionTLS13, |
| 8901 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8902 | CurvePreferences: []CurveID{CurveP384}, |
| 8903 | Bugs: ProtocolBugs{ |
| 8904 | SendHelloRetryRequestCurve: bogusCurve, |
| 8905 | }, |
| 8906 | }, |
| 8907 | shouldFail: true, |
| 8908 | expectedError: ":WRONG_CURVE:", |
| 8909 | }) |
| 8910 | |
| 8911 | testCases = append(testCases, testCase{ |
| 8912 | name: "DisabledCurve-HelloRetryRequest", |
| 8913 | config: Config{ |
| 8914 | MaxVersion: VersionTLS13, |
| 8915 | CurvePreferences: []CurveID{CurveP256}, |
| 8916 | Bugs: ProtocolBugs{ |
| 8917 | IgnorePeerCurvePreferences: true, |
| 8918 | }, |
| 8919 | }, |
| 8920 | flags: []string{"-p384-only"}, |
| 8921 | shouldFail: true, |
| 8922 | expectedError: ":WRONG_CURVE:", |
| 8923 | }) |
| 8924 | |
| 8925 | testCases = append(testCases, testCase{ |
| 8926 | name: "UnnecessaryHelloRetryRequest", |
| 8927 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 8928 | MaxVersion: VersionTLS13, |
| 8929 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8930 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 8931 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8932 | }, |
| 8933 | }, |
| 8934 | shouldFail: true, |
| 8935 | expectedError: ":WRONG_CURVE:", |
| 8936 | }) |
| 8937 | |
| 8938 | testCases = append(testCases, testCase{ |
| 8939 | name: "SecondHelloRetryRequest", |
| 8940 | config: Config{ |
| 8941 | MaxVersion: VersionTLS13, |
| 8942 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8943 | CurvePreferences: []CurveID{CurveP384}, |
| 8944 | Bugs: ProtocolBugs{ |
| 8945 | SecondHelloRetryRequest: true, |
| 8946 | }, |
| 8947 | }, |
| 8948 | shouldFail: true, |
| 8949 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 8950 | }) |
| 8951 | |
| 8952 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 8953 | name: "HelloRetryRequest-Empty", |
| 8954 | config: Config{ |
| 8955 | MaxVersion: VersionTLS13, |
| 8956 | Bugs: ProtocolBugs{ |
| 8957 | AlwaysSendHelloRetryRequest: true, |
| 8958 | }, |
| 8959 | }, |
| 8960 | shouldFail: true, |
| 8961 | expectedError: ":DECODE_ERROR:", |
| 8962 | }) |
| 8963 | |
| 8964 | testCases = append(testCases, testCase{ |
| 8965 | name: "HelloRetryRequest-DuplicateCurve", |
| 8966 | config: Config{ |
| 8967 | MaxVersion: VersionTLS13, |
| 8968 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 8969 | // configuration. Assert this ExpectMissingKeyShare. |
| 8970 | CurvePreferences: []CurveID{CurveP384}, |
| 8971 | Bugs: ProtocolBugs{ |
| 8972 | ExpectMissingKeyShare: true, |
| 8973 | DuplicateHelloRetryRequestExtensions: true, |
| 8974 | }, |
| 8975 | }, |
| 8976 | shouldFail: true, |
| 8977 | expectedError: ":DUPLICATE_EXTENSION:", |
| 8978 | expectedLocalError: "remote error: illegal parameter", |
| 8979 | }) |
| 8980 | |
| 8981 | testCases = append(testCases, testCase{ |
| 8982 | name: "HelloRetryRequest-Cookie", |
| 8983 | config: Config{ |
| 8984 | MaxVersion: VersionTLS13, |
| 8985 | Bugs: ProtocolBugs{ |
| 8986 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 8987 | }, |
| 8988 | }, |
| 8989 | }) |
| 8990 | |
| 8991 | testCases = append(testCases, testCase{ |
| 8992 | name: "HelloRetryRequest-DuplicateCookie", |
| 8993 | config: Config{ |
| 8994 | MaxVersion: VersionTLS13, |
| 8995 | Bugs: ProtocolBugs{ |
| 8996 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 8997 | DuplicateHelloRetryRequestExtensions: true, |
| 8998 | }, |
| 8999 | }, |
| 9000 | shouldFail: true, |
| 9001 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9002 | expectedLocalError: "remote error: illegal parameter", |
| 9003 | }) |
| 9004 | |
| 9005 | testCases = append(testCases, testCase{ |
| 9006 | name: "HelloRetryRequest-EmptyCookie", |
| 9007 | config: Config{ |
| 9008 | MaxVersion: VersionTLS13, |
| 9009 | Bugs: ProtocolBugs{ |
| 9010 | SendHelloRetryRequestCookie: []byte{}, |
| 9011 | }, |
| 9012 | }, |
| 9013 | shouldFail: true, |
| 9014 | expectedError: ":DECODE_ERROR:", |
| 9015 | }) |
| 9016 | |
| 9017 | testCases = append(testCases, testCase{ |
| 9018 | name: "HelloRetryRequest-Cookie-Curve", |
| 9019 | config: Config{ |
| 9020 | MaxVersion: VersionTLS13, |
| 9021 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9022 | CurvePreferences: []CurveID{CurveP384}, |
| 9023 | Bugs: ProtocolBugs{ |
| 9024 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9025 | ExpectMissingKeyShare: true, |
| 9026 | }, |
| 9027 | }, |
| 9028 | }) |
| 9029 | |
| 9030 | testCases = append(testCases, testCase{ |
| 9031 | name: "HelloRetryRequest-Unknown", |
| 9032 | config: Config{ |
| 9033 | MaxVersion: VersionTLS13, |
| 9034 | Bugs: ProtocolBugs{ |
| 9035 | CustomHelloRetryRequestExtension: "extension", |
| 9036 | }, |
| 9037 | }, |
| 9038 | shouldFail: true, |
| 9039 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9040 | expectedLocalError: "remote error: unsupported extension", |
| 9041 | }) |
| 9042 | |
| 9043 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9044 | testType: serverTest, |
| 9045 | name: "SecondClientHelloMissingKeyShare", |
| 9046 | config: Config{ |
| 9047 | MaxVersion: VersionTLS13, |
| 9048 | DefaultCurves: []CurveID{}, |
| 9049 | Bugs: ProtocolBugs{ |
| 9050 | SecondClientHelloMissingKeyShare: true, |
| 9051 | }, |
| 9052 | }, |
| 9053 | shouldFail: true, |
| 9054 | expectedError: ":MISSING_KEY_SHARE:", |
| 9055 | }) |
| 9056 | |
| 9057 | testCases = append(testCases, testCase{ |
| 9058 | testType: serverTest, |
| 9059 | name: "SecondClientHelloWrongCurve", |
| 9060 | config: Config{ |
| 9061 | MaxVersion: VersionTLS13, |
| 9062 | DefaultCurves: []CurveID{}, |
| 9063 | Bugs: ProtocolBugs{ |
| 9064 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9065 | }, |
| 9066 | }, |
| 9067 | shouldFail: true, |
| 9068 | expectedError: ":WRONG_CURVE:", |
| 9069 | }) |
| 9070 | |
| 9071 | testCases = append(testCases, testCase{ |
| 9072 | name: "HelloRetryRequestVersionMismatch", |
| 9073 | config: Config{ |
| 9074 | MaxVersion: VersionTLS13, |
| 9075 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9076 | CurvePreferences: []CurveID{CurveP384}, |
| 9077 | Bugs: ProtocolBugs{ |
| 9078 | SendServerHelloVersion: 0x0305, |
| 9079 | }, |
| 9080 | }, |
| 9081 | shouldFail: true, |
| 9082 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9083 | }) |
| 9084 | |
| 9085 | testCases = append(testCases, testCase{ |
| 9086 | name: "HelloRetryRequestCurveMismatch", |
| 9087 | config: Config{ |
| 9088 | MaxVersion: VersionTLS13, |
| 9089 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9090 | CurvePreferences: []CurveID{CurveP384}, |
| 9091 | Bugs: ProtocolBugs{ |
| 9092 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9093 | SendHelloRetryRequestCurve: CurveP384, |
| 9094 | // But send P-256 in the ServerHello. |
| 9095 | SendCurve: CurveP256, |
| 9096 | }, |
| 9097 | }, |
| 9098 | shouldFail: true, |
| 9099 | expectedError: ":WRONG_CURVE:", |
| 9100 | }) |
| 9101 | |
| 9102 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9103 | // without sending it. |
| 9104 | testCases = append(testCases, testCase{ |
| 9105 | name: "SkipHelloRetryRequest", |
| 9106 | config: Config{ |
| 9107 | MaxVersion: VersionTLS13, |
| 9108 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9109 | CurvePreferences: []CurveID{CurveP384}, |
| 9110 | Bugs: ProtocolBugs{ |
| 9111 | SkipHelloRetryRequest: true, |
| 9112 | }, |
| 9113 | }, |
| 9114 | shouldFail: true, |
| 9115 | expectedError: ":WRONG_CURVE:", |
| 9116 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9117 | |
| 9118 | testCases = append(testCases, testCase{ |
| 9119 | name: "TLS13-RequestContextInHandshake", |
| 9120 | config: Config{ |
| 9121 | MaxVersion: VersionTLS13, |
| 9122 | MinVersion: VersionTLS13, |
| 9123 | ClientAuth: RequireAnyClientCert, |
| 9124 | Bugs: ProtocolBugs{ |
| 9125 | SendRequestContext: []byte("request context"), |
| 9126 | }, |
| 9127 | }, |
| 9128 | flags: []string{ |
| 9129 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9130 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9131 | }, |
| 9132 | shouldFail: true, |
| 9133 | expectedError: ":DECODE_ERROR:", |
| 9134 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9135 | |
| 9136 | testCases = append(testCases, testCase{ |
| 9137 | testType: serverTest, |
| 9138 | name: "TLS13-TrailingKeyShareData", |
| 9139 | config: Config{ |
| 9140 | MaxVersion: VersionTLS13, |
| 9141 | Bugs: ProtocolBugs{ |
| 9142 | TrailingKeyShareData: true, |
| 9143 | }, |
| 9144 | }, |
| 9145 | shouldFail: true, |
| 9146 | expectedError: ":DECODE_ERROR:", |
| 9147 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9148 | |
| 9149 | testCases = append(testCases, testCase{ |
| 9150 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9151 | config: Config{ |
| 9152 | MaxVersion: VersionTLS13, |
| 9153 | Bugs: ProtocolBugs{ |
| 9154 | AlwaysSelectPSKIdentity: true, |
| 9155 | }, |
| 9156 | }, |
| 9157 | shouldFail: true, |
| 9158 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9159 | }) |
| 9160 | |
| 9161 | testCases = append(testCases, testCase{ |
| 9162 | name: "TLS13-InvalidPSKIdentity", |
| 9163 | config: Config{ |
| 9164 | MaxVersion: VersionTLS13, |
| 9165 | Bugs: ProtocolBugs{ |
| 9166 | SelectPSKIdentityOnResume: 1, |
| 9167 | }, |
| 9168 | }, |
| 9169 | resumeSession: true, |
| 9170 | shouldFail: true, |
| 9171 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9172 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9173 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9174 | testCases = append(testCases, testCase{ |
| 9175 | testType: serverTest, |
| 9176 | name: "TLS13-ExtraPSKIdentity", |
| 9177 | config: Config{ |
| 9178 | MaxVersion: VersionTLS13, |
| 9179 | Bugs: ProtocolBugs{ |
| 9180 | ExtraPSKIdentity: true, |
| 9181 | }, |
| 9182 | }, |
| 9183 | resumeSession: true, |
| 9184 | }) |
| 9185 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9186 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9187 | testCases = append(testCases, testCase{ |
| 9188 | name: "TLS13-CustomTicketExtension", |
| 9189 | config: Config{ |
| 9190 | MaxVersion: VersionTLS13, |
| 9191 | Bugs: ProtocolBugs{ |
| 9192 | CustomTicketExtension: "1234", |
| 9193 | }, |
| 9194 | }, |
| 9195 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9196 | } |
| 9197 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9198 | func addTLS13CipherPreferenceTests() { |
| 9199 | // Test that client preference is honored if the shim has AES hardware |
| 9200 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9201 | testCases = append(testCases, testCase{ |
| 9202 | testType: serverTest, |
| 9203 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9204 | config: Config{ |
| 9205 | MaxVersion: VersionTLS13, |
| 9206 | CipherSuites: []uint16{ |
| 9207 | TLS_CHACHA20_POLY1305_SHA256, |
| 9208 | TLS_AES_128_GCM_SHA256, |
| 9209 | }, |
| 9210 | }, |
| 9211 | flags: []string{ |
| 9212 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9213 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9214 | }, |
| 9215 | }) |
| 9216 | |
| 9217 | testCases = append(testCases, testCase{ |
| 9218 | testType: serverTest, |
| 9219 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9220 | config: Config{ |
| 9221 | MaxVersion: VersionTLS13, |
| 9222 | CipherSuites: []uint16{ |
| 9223 | TLS_AES_128_GCM_SHA256, |
| 9224 | TLS_CHACHA20_POLY1305_SHA256, |
| 9225 | }, |
| 9226 | }, |
| 9227 | flags: []string{ |
| 9228 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9229 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9230 | }, |
| 9231 | }) |
| 9232 | |
| 9233 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9234 | // whether it has AES hardware. |
| 9235 | testCases = append(testCases, testCase{ |
| 9236 | name: "TLS13-CipherPreference-Client", |
| 9237 | config: Config{ |
| 9238 | MaxVersion: VersionTLS13, |
| 9239 | // Use the client cipher order. (This is the default but |
| 9240 | // is listed to be explicit.) |
| 9241 | PreferServerCipherSuites: false, |
| 9242 | }, |
| 9243 | flags: []string{ |
| 9244 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9245 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9246 | }, |
| 9247 | }) |
| 9248 | } |
| 9249 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9250 | func addPeekTests() { |
| 9251 | // Test SSL_peek works, including on empty records. |
| 9252 | testCases = append(testCases, testCase{ |
| 9253 | name: "Peek-Basic", |
| 9254 | sendEmptyRecords: 1, |
| 9255 | flags: []string{"-peek-then-read"}, |
| 9256 | }) |
| 9257 | |
| 9258 | // Test SSL_peek can drive the initial handshake. |
| 9259 | testCases = append(testCases, testCase{ |
| 9260 | name: "Peek-ImplicitHandshake", |
| 9261 | flags: []string{ |
| 9262 | "-peek-then-read", |
| 9263 | "-implicit-handshake", |
| 9264 | }, |
| 9265 | }) |
| 9266 | |
| 9267 | // Test SSL_peek can discover and drive a renegotiation. |
| 9268 | testCases = append(testCases, testCase{ |
| 9269 | name: "Peek-Renegotiate", |
| 9270 | config: Config{ |
| 9271 | MaxVersion: VersionTLS12, |
| 9272 | }, |
| 9273 | renegotiate: 1, |
| 9274 | flags: []string{ |
| 9275 | "-peek-then-read", |
| 9276 | "-renegotiate-freely", |
| 9277 | "-expect-total-renegotiations", "1", |
| 9278 | }, |
| 9279 | }) |
| 9280 | |
| 9281 | // Test SSL_peek can discover a close_notify. |
| 9282 | testCases = append(testCases, testCase{ |
| 9283 | name: "Peek-Shutdown", |
| 9284 | config: Config{ |
| 9285 | Bugs: ProtocolBugs{ |
| 9286 | ExpectCloseNotify: true, |
| 9287 | }, |
| 9288 | }, |
| 9289 | flags: []string{ |
| 9290 | "-peek-then-read", |
| 9291 | "-check-close-notify", |
| 9292 | }, |
| 9293 | }) |
| 9294 | |
| 9295 | // Test SSL_peek can discover an alert. |
| 9296 | testCases = append(testCases, testCase{ |
| 9297 | name: "Peek-Alert", |
| 9298 | config: Config{ |
| 9299 | Bugs: ProtocolBugs{ |
| 9300 | SendSpuriousAlert: alertRecordOverflow, |
| 9301 | }, |
| 9302 | }, |
| 9303 | flags: []string{"-peek-then-read"}, |
| 9304 | shouldFail: true, |
| 9305 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9306 | }) |
| 9307 | |
| 9308 | // Test SSL_peek can handle KeyUpdate. |
| 9309 | testCases = append(testCases, testCase{ |
| 9310 | name: "Peek-KeyUpdate", |
| 9311 | config: Config{ |
| 9312 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9313 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9314 | sendKeyUpdates: 1, |
| 9315 | keyUpdateRequest: keyUpdateNotRequested, |
| 9316 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9317 | }) |
| 9318 | } |
| 9319 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9320 | func addRecordVersionTests() { |
| 9321 | for _, ver := range tlsVersions { |
| 9322 | // Test that the record version is enforced. |
| 9323 | testCases = append(testCases, testCase{ |
| 9324 | name: "CheckRecordVersion-" + ver.name, |
| 9325 | config: Config{ |
| 9326 | MinVersion: ver.version, |
| 9327 | MaxVersion: ver.version, |
| 9328 | Bugs: ProtocolBugs{ |
| 9329 | SendRecordVersion: 0x03ff, |
| 9330 | }, |
| 9331 | }, |
| 9332 | shouldFail: true, |
| 9333 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9334 | }) |
| 9335 | |
| 9336 | // Test that the ClientHello may use any record version, for |
| 9337 | // compatibility reasons. |
| 9338 | testCases = append(testCases, testCase{ |
| 9339 | testType: serverTest, |
| 9340 | name: "LooseInitialRecordVersion-" + ver.name, |
| 9341 | config: Config{ |
| 9342 | MinVersion: ver.version, |
| 9343 | MaxVersion: ver.version, |
| 9344 | Bugs: ProtocolBugs{ |
| 9345 | SendInitialRecordVersion: 0x03ff, |
| 9346 | }, |
| 9347 | }, |
| 9348 | }) |
| 9349 | |
| 9350 | // Test that garbage ClientHello record versions are rejected. |
| 9351 | testCases = append(testCases, testCase{ |
| 9352 | testType: serverTest, |
| 9353 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 9354 | config: Config{ |
| 9355 | MinVersion: ver.version, |
| 9356 | MaxVersion: ver.version, |
| 9357 | Bugs: ProtocolBugs{ |
| 9358 | SendInitialRecordVersion: 0xffff, |
| 9359 | }, |
| 9360 | }, |
| 9361 | shouldFail: true, |
| 9362 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9363 | }) |
| 9364 | } |
| 9365 | } |
| 9366 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9367 | func addCertificateTests() { |
| 9368 | // Test that a certificate chain with intermediate may be sent and |
| 9369 | // received as both client and server. |
| 9370 | for _, ver := range tlsVersions { |
| 9371 | testCases = append(testCases, testCase{ |
| 9372 | testType: clientTest, |
| 9373 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 9374 | config: Config{ |
| 9375 | Certificates: []Certificate{rsaChainCertificate}, |
| 9376 | ClientAuth: RequireAnyClientCert, |
| 9377 | }, |
| 9378 | expectPeerCertificate: &rsaChainCertificate, |
| 9379 | flags: []string{ |
| 9380 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9381 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9382 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9383 | }, |
| 9384 | }) |
| 9385 | |
| 9386 | testCases = append(testCases, testCase{ |
| 9387 | testType: serverTest, |
| 9388 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 9389 | config: Config{ |
| 9390 | Certificates: []Certificate{rsaChainCertificate}, |
| 9391 | }, |
| 9392 | expectPeerCertificate: &rsaChainCertificate, |
| 9393 | flags: []string{ |
| 9394 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9395 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9396 | "-require-any-client-certificate", |
| 9397 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9398 | }, |
| 9399 | }) |
| 9400 | } |
| 9401 | } |
| 9402 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9403 | 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] | 9404 | defer wg.Done() |
| 9405 | |
| 9406 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9407 | var err error |
| 9408 | |
| 9409 | if *mallocTest < 0 { |
| 9410 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9411 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9412 | } else { |
| 9413 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 9414 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9415 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9416 | if err != nil { |
| 9417 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 9418 | } |
| 9419 | break |
| 9420 | } |
| 9421 | } |
| 9422 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9423 | statusChan <- statusMsg{test: test, err: err} |
| 9424 | } |
| 9425 | } |
| 9426 | |
| 9427 | type statusMsg struct { |
| 9428 | test *testCase |
| 9429 | started bool |
| 9430 | err error |
| 9431 | } |
| 9432 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9433 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9434 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9435 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9436 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9437 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9438 | if !*pipe { |
| 9439 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 9440 | var erase string |
| 9441 | for i := 0; i < lineLen; i++ { |
| 9442 | erase += "\b \b" |
| 9443 | } |
| 9444 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9445 | } |
| 9446 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9447 | if msg.started { |
| 9448 | started++ |
| 9449 | } else { |
| 9450 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9451 | |
| 9452 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9453 | if msg.err == errUnimplemented { |
| 9454 | if *pipe { |
| 9455 | // Print each test instead of a status line. |
| 9456 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 9457 | } |
| 9458 | unimplemented++ |
| 9459 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 9460 | } else { |
| 9461 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 9462 | failed++ |
| 9463 | testOutput.addResult(msg.test.name, "FAIL") |
| 9464 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9465 | } else { |
| 9466 | if *pipe { |
| 9467 | // Print each test instead of a status line. |
| 9468 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 9469 | } |
| 9470 | testOutput.addResult(msg.test.name, "PASS") |
| 9471 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9472 | } |
| 9473 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9474 | if !*pipe { |
| 9475 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9476 | 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] | 9477 | lineLen = len(line) |
| 9478 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9479 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9480 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9481 | |
| 9482 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9483 | } |
| 9484 | |
| 9485 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9486 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9487 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 9488 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9489 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9490 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9491 | addCipherSuiteTests() |
| 9492 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9493 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 9494 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 9495 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 9496 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 9497 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 9498 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 9499 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 9500 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 9501 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 9502 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 9503 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 9504 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 9505 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 9506 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 9507 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9508 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9509 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9510 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 9511 | addCECPQ1Tests() |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9512 | addDHEGroupSizeTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9513 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9514 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 9515 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9516 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9517 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9518 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9519 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9520 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9521 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9522 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9523 | addCertificateTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9524 | |
| 9525 | var wg sync.WaitGroup |
| 9526 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9527 | statusChan := make(chan statusMsg, *numWorkers) |
| 9528 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9529 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9530 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9531 | if len(*shimConfigFile) != 0 { |
| 9532 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 9533 | if err != nil { |
| 9534 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 9535 | os.Exit(1) |
| 9536 | } |
| 9537 | |
| 9538 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 9539 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 9540 | os.Exit(1) |
| 9541 | } |
| 9542 | } |
| 9543 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9544 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9545 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9546 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9547 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9548 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9549 | } |
| 9550 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9551 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9552 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9553 | matched := true |
| 9554 | if len(*testToRun) != 0 { |
| 9555 | var err error |
| 9556 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 9557 | if err != nil { |
| 9558 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 9559 | os.Exit(1) |
| 9560 | } |
| 9561 | } |
| 9562 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9563 | if !*includeDisabled { |
| 9564 | for pattern := range shimConfig.DisabledTests { |
| 9565 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 9566 | if err != nil { |
| 9567 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 9568 | os.Exit(1) |
| 9569 | } |
| 9570 | |
| 9571 | if isDisabled { |
| 9572 | matched = false |
| 9573 | break |
| 9574 | } |
| 9575 | } |
| 9576 | } |
| 9577 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9578 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9579 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9580 | testChan <- &testCases[i] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9581 | } |
| 9582 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9583 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9584 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9585 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9586 | os.Exit(1) |
| 9587 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9588 | |
| 9589 | close(testChan) |
| 9590 | wg.Wait() |
| 9591 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9592 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9593 | |
| 9594 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9595 | |
| 9596 | if *jsonOutput != "" { |
| 9597 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 9598 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 9599 | } |
| 9600 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9601 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9602 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 9603 | os.Exit(1) |
| 9604 | } |
| 9605 | |
| 9606 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9607 | os.Exit(1) |
| 9608 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9609 | } |