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 | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 90 | testCertECDSAP256 |
| 91 | testCertECDSAP384 |
| 92 | testCertECDSAP521 |
| 93 | ) |
| 94 | |
| 95 | const ( |
| 96 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 97 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 98 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 99 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 100 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 101 | ) |
| 102 | |
| 103 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 104 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 105 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 106 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 107 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 108 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 109 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 110 | ) |
| 111 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 112 | var ( |
| 113 | rsaCertificate Certificate |
| 114 | rsa1024Certificate Certificate |
| 115 | ecdsaP256Certificate Certificate |
| 116 | ecdsaP384Certificate Certificate |
| 117 | ecdsaP521Certificate Certificate |
| 118 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 119 | |
| 120 | var testCerts = []struct { |
| 121 | id testCert |
| 122 | certFile, keyFile string |
| 123 | cert *Certificate |
| 124 | }{ |
| 125 | { |
| 126 | id: testCertRSA, |
| 127 | certFile: rsaCertificateFile, |
| 128 | keyFile: rsaKeyFile, |
| 129 | cert: &rsaCertificate, |
| 130 | }, |
| 131 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 132 | id: testCertRSA1024, |
| 133 | certFile: rsa1024CertificateFile, |
| 134 | keyFile: rsa1024KeyFile, |
| 135 | cert: &rsa1024Certificate, |
| 136 | }, |
| 137 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 138 | id: testCertECDSAP256, |
| 139 | certFile: ecdsaP256CertificateFile, |
| 140 | keyFile: ecdsaP256KeyFile, |
| 141 | cert: &ecdsaP256Certificate, |
| 142 | }, |
| 143 | { |
| 144 | id: testCertECDSAP384, |
| 145 | certFile: ecdsaP384CertificateFile, |
| 146 | keyFile: ecdsaP384KeyFile, |
| 147 | cert: &ecdsaP384Certificate, |
| 148 | }, |
| 149 | { |
| 150 | id: testCertECDSAP521, |
| 151 | certFile: ecdsaP521CertificateFile, |
| 152 | keyFile: ecdsaP521KeyFile, |
| 153 | cert: &ecdsaP521Certificate, |
| 154 | }, |
| 155 | } |
| 156 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 157 | var channelIDKey *ecdsa.PrivateKey |
| 158 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 159 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 160 | var testOCSPResponse = []byte{1, 2, 3, 4} |
| 161 | var testSCTList = []byte{5, 6, 7, 8} |
| 162 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 163 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 164 | for i := range testCerts { |
| 165 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 166 | if err != nil { |
| 167 | panic(err) |
| 168 | } |
| 169 | cert.OCSPStaple = testOCSPResponse |
| 170 | cert.SignedCertificateTimestampList = testSCTList |
| 171 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 172 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 173 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 174 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 175 | if err != nil { |
| 176 | panic(err) |
| 177 | } |
| 178 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 179 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 180 | panic("bad key type") |
| 181 | } |
| 182 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 183 | if err != nil { |
| 184 | panic(err) |
| 185 | } |
| 186 | if channelIDKey.Curve != elliptic.P256() { |
| 187 | panic("bad curve") |
| 188 | } |
| 189 | |
| 190 | channelIDBytes = make([]byte, 64) |
| 191 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 192 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 193 | } |
| 194 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 195 | func getRunnerCertificate(t testCert) Certificate { |
| 196 | for _, cert := range testCerts { |
| 197 | if cert.id == t { |
| 198 | return *cert.cert |
| 199 | } |
| 200 | } |
| 201 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 202 | } |
| 203 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 204 | func getShimCertificate(t testCert) string { |
| 205 | for _, cert := range testCerts { |
| 206 | if cert.id == t { |
| 207 | return cert.certFile |
| 208 | } |
| 209 | } |
| 210 | panic("Unknown test certificate") |
| 211 | } |
| 212 | |
| 213 | func getShimKey(t testCert) string { |
| 214 | for _, cert := range testCerts { |
| 215 | if cert.id == t { |
| 216 | return cert.keyFile |
| 217 | } |
| 218 | } |
| 219 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 220 | } |
| 221 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 222 | type testType int |
| 223 | |
| 224 | const ( |
| 225 | clientTest testType = iota |
| 226 | serverTest |
| 227 | ) |
| 228 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 229 | type protocol int |
| 230 | |
| 231 | const ( |
| 232 | tls protocol = iota |
| 233 | dtls |
| 234 | ) |
| 235 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 236 | const ( |
| 237 | alpn = 1 |
| 238 | npn = 2 |
| 239 | ) |
| 240 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 241 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 242 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 243 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 244 | name string |
| 245 | config Config |
| 246 | shouldFail bool |
| 247 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 248 | // expectedLocalError, if not empty, contains a substring that must be |
| 249 | // found in the local error. |
| 250 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 251 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 252 | // negotiated. |
| 253 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 254 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 255 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 256 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 257 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 258 | // should be negotiated. |
| 259 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 260 | // expectChannelID controls whether the connection should have |
| 261 | // negotiated a Channel ID with channelIDKey. |
| 262 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 263 | // expectedNextProto controls whether the connection should |
| 264 | // negotiate a next protocol via NPN or ALPN. |
| 265 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 266 | // expectNoNextProto, if true, means that no next protocol should be |
| 267 | // negotiated. |
| 268 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 269 | // expectedNextProtoType, if non-zero, is the expected next |
| 270 | // protocol negotiation mechanism. |
| 271 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 272 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 273 | // should be negotiated. If zero, none should be negotiated. |
| 274 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 275 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 276 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 277 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 278 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 279 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 280 | // algorithm that the peer should have used in the handshake. |
| 281 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 282 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 283 | // have used. |
| 284 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 285 | // messageLen is the length, in bytes, of the test message that will be |
| 286 | // sent. |
| 287 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 288 | // messageCount is the number of test messages that will be sent. |
| 289 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 290 | // certFile is the path to the certificate to use for the server. |
| 291 | certFile string |
| 292 | // keyFile is the path to the private key to use for the server. |
| 293 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 294 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 295 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 296 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 297 | // resumeRenewedSession controls whether a third connection should be |
| 298 | // tested which attempts to resume the second connection's session. |
| 299 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 300 | // expectResumeRejected, if true, specifies that the attempted |
| 301 | // resumption must be rejected by the client. This is only valid for a |
| 302 | // serverTest. |
| 303 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 304 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 305 | // resumption. Unless newSessionsOnResume is set, |
| 306 | // SessionTicketKey, ServerSessionCache, and |
| 307 | // ClientSessionCache are copied from the initial connection's |
| 308 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 309 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 310 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 311 | // use a different session resumption context. |
| 312 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 313 | // noSessionCache, if true, will cause the server to run without a |
| 314 | // session cache. |
| 315 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 316 | // sendPrefix sends a prefix on the socket before actually performing a |
| 317 | // handshake. |
| 318 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 319 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 320 | // message before doing a roundtrip with the runner. |
| 321 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 322 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 323 | // connection immediately after the handshake rather than echoing |
| 324 | // messages from the runner. |
| 325 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 326 | // renegotiate indicates the number of times the connection should be |
| 327 | // renegotiated during the exchange. |
| 328 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 329 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 330 | // HelloRequest when the handshake completes. |
| 331 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 332 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 333 | // switched in just before renegotiation. |
| 334 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 335 | // replayWrites, if true, configures the underlying transport |
| 336 | // to replay every write it makes in DTLS tests. |
| 337 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 338 | // damageFirstWrite, if true, configures the underlying transport to |
| 339 | // damage the final byte of the first application data write. |
| 340 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 341 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 342 | // keying material and verify they match. |
| 343 | exportKeyingMaterial int |
| 344 | exportLabel string |
| 345 | exportContext string |
| 346 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 347 | // flags, if not empty, contains a list of command-line flags that will |
| 348 | // be passed to the shim program. |
| 349 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 350 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 351 | // which will be compared against the expected value. |
| 352 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 353 | // sendEmptyRecords is the number of consecutive empty records to send |
| 354 | // before and after the test message. |
| 355 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 356 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 357 | // before and after the test message. |
| 358 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 359 | // sendKeyUpdates is the number of consecutive key updates to send |
| 360 | // before and after the test message. |
| 361 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 362 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 363 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 364 | // expectMessageDropped, if true, means the test message is expected to |
| 365 | // be dropped by the client rather than echoed back. |
| 366 | expectMessageDropped bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 369 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 370 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 371 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 372 | if len(data) == 0 { |
| 373 | return |
| 374 | } |
| 375 | |
| 376 | protocol := "tls" |
| 377 | if test.protocol == dtls { |
| 378 | protocol = "dtls" |
| 379 | } |
| 380 | |
| 381 | side := "client" |
| 382 | if test.testType == serverTest { |
| 383 | side = "server" |
| 384 | } |
| 385 | |
| 386 | dir := path.Join(*transcriptDir, protocol, side) |
| 387 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 388 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 389 | return |
| 390 | } |
| 391 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 392 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 393 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 394 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 395 | } |
| 396 | } |
| 397 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 398 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 399 | type timeoutConn struct { |
| 400 | net.Conn |
| 401 | timeout time.Duration |
| 402 | } |
| 403 | |
| 404 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 405 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 406 | return 0, err |
| 407 | } |
| 408 | return t.Conn.Read(b) |
| 409 | } |
| 410 | |
| 411 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 412 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 413 | return 0, err |
| 414 | } |
| 415 | return t.Conn.Write(b) |
| 416 | } |
| 417 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 418 | 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] | 419 | if !test.noSessionCache { |
| 420 | if config.ClientSessionCache == nil { |
| 421 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 422 | } |
| 423 | if config.ServerSessionCache == nil { |
| 424 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 425 | } |
| 426 | } |
| 427 | if test.testType == clientTest { |
| 428 | if len(config.Certificates) == 0 { |
| 429 | config.Certificates = []Certificate{rsaCertificate} |
| 430 | } |
| 431 | } else { |
| 432 | // Supply a ServerName to ensure a constant session cache key, |
| 433 | // rather than falling back to net.Conn.RemoteAddr. |
| 434 | if len(config.ServerName) == 0 { |
| 435 | config.ServerName = "test" |
| 436 | } |
| 437 | } |
| 438 | if *fuzzer { |
| 439 | config.Bugs.NullAllCiphers = true |
| 440 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 441 | if *deterministic { |
| 442 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 443 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 444 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 445 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 446 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 447 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 448 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 449 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 450 | } |
| 451 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 452 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 453 | local, peer := "client", "server" |
| 454 | if test.testType == clientTest { |
| 455 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 456 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 457 | connDebug := &recordingConn{ |
| 458 | Conn: conn, |
| 459 | isDatagram: test.protocol == dtls, |
| 460 | local: local, |
| 461 | peer: peer, |
| 462 | } |
| 463 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 464 | if *flagDebug { |
| 465 | defer connDebug.WriteTo(os.Stdout) |
| 466 | } |
| 467 | if len(*transcriptDir) != 0 { |
| 468 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 469 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 470 | }() |
| 471 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 472 | |
| 473 | if config.Bugs.PacketAdaptor != nil { |
| 474 | config.Bugs.PacketAdaptor.debug = connDebug |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | if test.replayWrites { |
| 479 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 480 | } |
| 481 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 482 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 483 | if test.damageFirstWrite { |
| 484 | connDamage = newDamageAdaptor(conn) |
| 485 | conn = connDamage |
| 486 | } |
| 487 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 488 | if test.sendPrefix != "" { |
| 489 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 490 | return err |
| 491 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 492 | } |
| 493 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 494 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 495 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 496 | if test.protocol == dtls { |
| 497 | tlsConn = DTLSServer(conn, config) |
| 498 | } else { |
| 499 | tlsConn = Server(conn, config) |
| 500 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 501 | } else { |
| 502 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 503 | if test.protocol == dtls { |
| 504 | tlsConn = DTLSClient(conn, config) |
| 505 | } else { |
| 506 | tlsConn = Client(conn, config) |
| 507 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 508 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 509 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 510 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 511 | if err := tlsConn.Handshake(); err != nil { |
| 512 | return err |
| 513 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 514 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 515 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 516 | // expectations struct that can be specified separately for the two |
| 517 | // legs. |
| 518 | expectedVersion := test.expectedVersion |
| 519 | if isResume && test.expectedResumeVersion != 0 { |
| 520 | expectedVersion = test.expectedResumeVersion |
| 521 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 522 | connState := tlsConn.ConnectionState() |
| 523 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 524 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 525 | } |
| 526 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 527 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 528 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 529 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 530 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 531 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 532 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 533 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 534 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 535 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 536 | if channelID == nil { |
| 537 | return fmt.Errorf("no channel ID negotiated") |
| 538 | } |
| 539 | if channelID.Curve != channelIDKey.Curve || |
| 540 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 541 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 542 | return fmt.Errorf("incorrect channel ID") |
| 543 | } |
| 544 | } |
| 545 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 546 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 547 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 548 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 549 | } |
| 550 | } |
| 551 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 552 | if test.expectNoNextProto { |
| 553 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 554 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 555 | } |
| 556 | } |
| 557 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 558 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 559 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 560 | return fmt.Errorf("next proto type mismatch") |
| 561 | } |
| 562 | } |
| 563 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 564 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 565 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 566 | } |
| 567 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 568 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 569 | 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] | 570 | } |
| 571 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 572 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 573 | return fmt.Errorf("SCT list mismatch") |
| 574 | } |
| 575 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 576 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 577 | 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] | 578 | } |
| 579 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 580 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 581 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 582 | } |
| 583 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 584 | if test.exportKeyingMaterial > 0 { |
| 585 | actual := make([]byte, test.exportKeyingMaterial) |
| 586 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 587 | return err |
| 588 | } |
| 589 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 590 | if err != nil { |
| 591 | return err |
| 592 | } |
| 593 | if !bytes.Equal(actual, expected) { |
| 594 | return fmt.Errorf("keying material mismatch") |
| 595 | } |
| 596 | } |
| 597 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 598 | if test.testTLSUnique { |
| 599 | var peersValue [12]byte |
| 600 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 601 | return err |
| 602 | } |
| 603 | expected := tlsConn.ConnectionState().TLSUnique |
| 604 | if !bytes.Equal(peersValue[:], expected) { |
| 605 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 606 | } |
| 607 | } |
| 608 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 609 | if test.shimWritesFirst { |
| 610 | var buf [5]byte |
| 611 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 612 | if err != nil { |
| 613 | return err |
| 614 | } |
| 615 | if string(buf[:]) != "hello" { |
| 616 | return fmt.Errorf("bad initial message") |
| 617 | } |
| 618 | } |
| 619 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 620 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 621 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 622 | return err |
| 623 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 624 | } |
| 625 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 626 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 627 | tlsConn.Write(nil) |
| 628 | } |
| 629 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 630 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 631 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 632 | } |
| 633 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 634 | if test.sendHalfHelloRequest { |
| 635 | tlsConn.SendHalfHelloRequest() |
| 636 | } |
| 637 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 638 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 639 | if test.renegotiateCiphers != nil { |
| 640 | config.CipherSuites = test.renegotiateCiphers |
| 641 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 642 | for i := 0; i < test.renegotiate; i++ { |
| 643 | if err := tlsConn.Renegotiate(); err != nil { |
| 644 | return err |
| 645 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 646 | } |
| 647 | } else if test.renegotiateCiphers != nil { |
| 648 | panic("renegotiateCiphers without renegotiate") |
| 649 | } |
| 650 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 651 | if test.damageFirstWrite { |
| 652 | connDamage.setDamage(true) |
| 653 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 654 | connDamage.setDamage(false) |
| 655 | } |
| 656 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 657 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 658 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 659 | if test.protocol == dtls { |
| 660 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 661 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 662 | // Read until EOF. |
| 663 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 664 | return err |
| 665 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 666 | if messageLen == 0 { |
| 667 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 668 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 669 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 670 | messageCount := test.messageCount |
| 671 | if messageCount == 0 { |
| 672 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 673 | } |
| 674 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 675 | for j := 0; j < messageCount; j++ { |
| 676 | testMessage := make([]byte, messageLen) |
| 677 | for i := range testMessage { |
| 678 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 679 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 680 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 681 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 682 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 683 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 684 | } |
| 685 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 686 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 687 | tlsConn.Write(nil) |
| 688 | } |
| 689 | |
| 690 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 691 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 692 | } |
| 693 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 694 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 695 | // The shim will not respond. |
| 696 | continue |
| 697 | } |
| 698 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 699 | buf := make([]byte, len(testMessage)) |
| 700 | if test.protocol == dtls { |
| 701 | bufTmp := make([]byte, len(buf)+1) |
| 702 | n, err := tlsConn.Read(bufTmp) |
| 703 | if err != nil { |
| 704 | return err |
| 705 | } |
| 706 | if n != len(buf) { |
| 707 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 708 | } |
| 709 | copy(buf, bufTmp) |
| 710 | } else { |
| 711 | _, err := io.ReadFull(tlsConn, buf) |
| 712 | if err != nil { |
| 713 | return err |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | for i, v := range buf { |
| 718 | if v != testMessage[i]^0xff { |
| 719 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 720 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 721 | } |
| 722 | } |
| 723 | |
| 724 | return nil |
| 725 | } |
| 726 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 727 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 728 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 729 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 730 | 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] | 731 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 732 | valgrindArgs = append(valgrindArgs, path) |
| 733 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 734 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 735 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 736 | } |
| 737 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 738 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 739 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 740 | xtermArgs = append(xtermArgs, path) |
| 741 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 742 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 743 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 744 | } |
| 745 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 746 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 747 | xtermArgs := []string{"-e", "lldb", "--"} |
| 748 | xtermArgs = append(xtermArgs, path) |
| 749 | xtermArgs = append(xtermArgs, args...) |
| 750 | |
| 751 | return exec.Command("xterm", xtermArgs...) |
| 752 | } |
| 753 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 754 | var ( |
| 755 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 756 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 757 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 758 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 759 | // accept accepts a connection from listener, unless waitChan signals a process |
| 760 | // exit first. |
| 761 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 762 | type connOrError struct { |
| 763 | conn net.Conn |
| 764 | err error |
| 765 | } |
| 766 | connChan := make(chan connOrError, 1) |
| 767 | go func() { |
| 768 | conn, err := listener.Accept() |
| 769 | connChan <- connOrError{conn, err} |
| 770 | close(connChan) |
| 771 | }() |
| 772 | select { |
| 773 | case result := <-connChan: |
| 774 | return result.conn, result.err |
| 775 | case childErr := <-waitChan: |
| 776 | waitChan <- childErr |
| 777 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 778 | } |
| 779 | } |
| 780 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 781 | func translateExpectedError(errorStr string) string { |
| 782 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 783 | return translated |
| 784 | } |
| 785 | |
| 786 | if *looseErrors { |
| 787 | return "" |
| 788 | } |
| 789 | |
| 790 | return errorStr |
| 791 | } |
| 792 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 793 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 794 | // Help debugging panics on the Go side. |
| 795 | defer func() { |
| 796 | if r := recover(); r != nil { |
| 797 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 798 | panic(r) |
| 799 | } |
| 800 | }() |
| 801 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 802 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 803 | panic("Error expected without shouldFail in " + test.name) |
| 804 | } |
| 805 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 806 | if test.expectResumeRejected && !test.resumeSession { |
| 807 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 808 | } |
| 809 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 810 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 811 | if err != nil { |
| 812 | panic(err) |
| 813 | } |
| 814 | defer func() { |
| 815 | if listener != nil { |
| 816 | listener.Close() |
| 817 | } |
| 818 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 819 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 820 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 821 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 822 | flags = append(flags, "-server") |
| 823 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 824 | flags = append(flags, "-key-file") |
| 825 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 826 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 827 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 828 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | flags = append(flags, "-cert-file") |
| 832 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 833 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 834 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 835 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 836 | } |
| 837 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 838 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 839 | if test.protocol == dtls { |
| 840 | flags = append(flags, "-dtls") |
| 841 | } |
| 842 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 843 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 844 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 845 | resumeCount++ |
| 846 | if test.resumeRenewedSession { |
| 847 | resumeCount++ |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | if resumeCount > 0 { |
| 852 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 853 | } |
| 854 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 855 | if test.shimWritesFirst { |
| 856 | flags = append(flags, "-shim-writes-first") |
| 857 | } |
| 858 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 859 | if test.shimShutsDown { |
| 860 | flags = append(flags, "-shim-shuts-down") |
| 861 | } |
| 862 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 863 | if test.exportKeyingMaterial > 0 { |
| 864 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 865 | flags = append(flags, "-export-label", test.exportLabel) |
| 866 | flags = append(flags, "-export-context", test.exportContext) |
| 867 | if test.useExportContext { |
| 868 | flags = append(flags, "-use-export-context") |
| 869 | } |
| 870 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 871 | if test.expectResumeRejected { |
| 872 | flags = append(flags, "-expect-session-miss") |
| 873 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 874 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 875 | if test.testTLSUnique { |
| 876 | flags = append(flags, "-tls-unique") |
| 877 | } |
| 878 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 879 | flags = append(flags, test.flags...) |
| 880 | |
| 881 | var shim *exec.Cmd |
| 882 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 883 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 884 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 885 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 886 | } else if *useLLDB { |
| 887 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 888 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 889 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 890 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 891 | shim.Stdin = os.Stdin |
| 892 | var stdoutBuf, stderrBuf bytes.Buffer |
| 893 | shim.Stdout = &stdoutBuf |
| 894 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 895 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 896 | shim.Env = os.Environ() |
| 897 | 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] | 898 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 899 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 900 | } |
| 901 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 902 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 903 | |
| 904 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 905 | panic(err) |
| 906 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 907 | waitChan := make(chan error, 1) |
| 908 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 909 | |
| 910 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 911 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 912 | if *deterministic { |
| 913 | config.Rand = &deterministicRand{} |
| 914 | } |
| 915 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 916 | conn, err := acceptOrWait(listener, waitChan) |
| 917 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 918 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 919 | conn.Close() |
| 920 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 921 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 922 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 923 | var resumeConfig Config |
| 924 | if test.resumeConfig != nil { |
| 925 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 926 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 927 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 928 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 929 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 930 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 931 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 932 | } else { |
| 933 | resumeConfig = config |
| 934 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 935 | var connResume net.Conn |
| 936 | connResume, err = acceptOrWait(listener, waitChan) |
| 937 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 938 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 939 | connResume.Close() |
| 940 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 941 | } |
| 942 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 943 | // Close the listener now. This is to avoid hangs should the shim try to |
| 944 | // open more connections than expected. |
| 945 | listener.Close() |
| 946 | listener = nil |
| 947 | |
| 948 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 949 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 950 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 951 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 952 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 953 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 954 | case 89: |
| 955 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 956 | case 99: |
| 957 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 958 | } |
| 959 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 960 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 961 | // Account for Windows line endings. |
| 962 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 963 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 964 | |
| 965 | // Separate the errors from the shim and those from tools like |
| 966 | // AddressSanitizer. |
| 967 | var extraStderr string |
| 968 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 969 | stderr = stderrParts[0] |
| 970 | extraStderr = stderrParts[1] |
| 971 | } |
| 972 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 973 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 974 | expectedError := translateExpectedError(test.expectedError) |
| 975 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 976 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 977 | localError := "none" |
| 978 | if err != nil { |
| 979 | localError = err.Error() |
| 980 | } |
| 981 | if len(test.expectedLocalError) != 0 { |
| 982 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 983 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 984 | |
| 985 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 986 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 987 | if childErr != nil { |
| 988 | childError = childErr.Error() |
| 989 | } |
| 990 | |
| 991 | var msg string |
| 992 | switch { |
| 993 | case failed && !test.shouldFail: |
| 994 | msg = "unexpected failure" |
| 995 | case !failed && test.shouldFail: |
| 996 | msg = "unexpected success" |
| 997 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 998 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 999 | default: |
| 1000 | panic("internal error") |
| 1001 | } |
| 1002 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1003 | 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] | 1004 | } |
| 1005 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1006 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1007 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1010 | if *useValgrind && isValgrindError { |
| 1011 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1012 | } |
| 1013 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1014 | return nil |
| 1015 | } |
| 1016 | |
| 1017 | var tlsVersions = []struct { |
| 1018 | name string |
| 1019 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1020 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1021 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1022 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1023 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1024 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1025 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1026 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1027 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | var testCipherSuites = []struct { |
| 1031 | name string |
| 1032 | id uint16 |
| 1033 | }{ |
| 1034 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1035 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1036 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1037 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1038 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1039 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1040 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1041 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1042 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1043 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1044 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1045 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1046 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1047 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1048 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1049 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1050 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1051 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1052 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1053 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1054 | {"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] | 1055 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1056 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1057 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1058 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1059 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1060 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1061 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1062 | {"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] | 1063 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1064 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1065 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1066 | {"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] | 1067 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1068 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1069 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1070 | {"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] | 1071 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1072 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1073 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1074 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1075 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1078 | func hasComponent(suiteName, component string) bool { |
| 1079 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1080 | } |
| 1081 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1082 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1083 | return hasComponent(suiteName, "GCM") || |
| 1084 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1085 | hasComponent(suiteName, "SHA384") || |
| 1086 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1087 | } |
| 1088 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1089 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1090 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1091 | } |
| 1092 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1093 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1094 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1095 | } |
| 1096 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1097 | func bigFromHex(hex string) *big.Int { |
| 1098 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1099 | if !ok { |
| 1100 | panic("failed to parse hex number 0x" + hex) |
| 1101 | } |
| 1102 | return ret |
| 1103 | } |
| 1104 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1105 | func addBasicTests() { |
| 1106 | basicTests := []testCase{ |
| 1107 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1108 | name: "NoFallbackSCSV", |
| 1109 | config: Config{ |
| 1110 | Bugs: ProtocolBugs{ |
| 1111 | FailIfNotFallbackSCSV: true, |
| 1112 | }, |
| 1113 | }, |
| 1114 | shouldFail: true, |
| 1115 | expectedLocalError: "no fallback SCSV found", |
| 1116 | }, |
| 1117 | { |
| 1118 | name: "SendFallbackSCSV", |
| 1119 | config: Config{ |
| 1120 | Bugs: ProtocolBugs{ |
| 1121 | FailIfNotFallbackSCSV: true, |
| 1122 | }, |
| 1123 | }, |
| 1124 | flags: []string{"-fallback-scsv"}, |
| 1125 | }, |
| 1126 | { |
| 1127 | name: "ClientCertificateTypes", |
| 1128 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1129 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1130 | ClientAuth: RequestClientCert, |
| 1131 | ClientCertificateTypes: []byte{ |
| 1132 | CertTypeDSSSign, |
| 1133 | CertTypeRSASign, |
| 1134 | CertTypeECDSASign, |
| 1135 | }, |
| 1136 | }, |
| 1137 | flags: []string{ |
| 1138 | "-expect-certificate-types", |
| 1139 | base64.StdEncoding.EncodeToString([]byte{ |
| 1140 | CertTypeDSSSign, |
| 1141 | CertTypeRSASign, |
| 1142 | CertTypeECDSASign, |
| 1143 | }), |
| 1144 | }, |
| 1145 | }, |
| 1146 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1147 | name: "UnauthenticatedECDH", |
| 1148 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1149 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1150 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1151 | Bugs: ProtocolBugs{ |
| 1152 | UnauthenticatedECDH: true, |
| 1153 | }, |
| 1154 | }, |
| 1155 | shouldFail: true, |
| 1156 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1157 | }, |
| 1158 | { |
| 1159 | name: "SkipCertificateStatus", |
| 1160 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1161 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1162 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1163 | Bugs: ProtocolBugs{ |
| 1164 | SkipCertificateStatus: true, |
| 1165 | }, |
| 1166 | }, |
| 1167 | flags: []string{ |
| 1168 | "-enable-ocsp-stapling", |
| 1169 | }, |
| 1170 | }, |
| 1171 | { |
| 1172 | name: "SkipServerKeyExchange", |
| 1173 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1174 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1175 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1176 | Bugs: ProtocolBugs{ |
| 1177 | SkipServerKeyExchange: true, |
| 1178 | }, |
| 1179 | }, |
| 1180 | shouldFail: true, |
| 1181 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1182 | }, |
| 1183 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1184 | testType: serverTest, |
| 1185 | name: "Alert", |
| 1186 | config: Config{ |
| 1187 | Bugs: ProtocolBugs{ |
| 1188 | SendSpuriousAlert: alertRecordOverflow, |
| 1189 | }, |
| 1190 | }, |
| 1191 | shouldFail: true, |
| 1192 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1193 | }, |
| 1194 | { |
| 1195 | protocol: dtls, |
| 1196 | testType: serverTest, |
| 1197 | name: "Alert-DTLS", |
| 1198 | config: Config{ |
| 1199 | Bugs: ProtocolBugs{ |
| 1200 | SendSpuriousAlert: alertRecordOverflow, |
| 1201 | }, |
| 1202 | }, |
| 1203 | shouldFail: true, |
| 1204 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1205 | }, |
| 1206 | { |
| 1207 | testType: serverTest, |
| 1208 | name: "FragmentAlert", |
| 1209 | config: Config{ |
| 1210 | Bugs: ProtocolBugs{ |
| 1211 | FragmentAlert: true, |
| 1212 | SendSpuriousAlert: alertRecordOverflow, |
| 1213 | }, |
| 1214 | }, |
| 1215 | shouldFail: true, |
| 1216 | expectedError: ":BAD_ALERT:", |
| 1217 | }, |
| 1218 | { |
| 1219 | protocol: dtls, |
| 1220 | testType: serverTest, |
| 1221 | name: "FragmentAlert-DTLS", |
| 1222 | config: Config{ |
| 1223 | Bugs: ProtocolBugs{ |
| 1224 | FragmentAlert: true, |
| 1225 | SendSpuriousAlert: alertRecordOverflow, |
| 1226 | }, |
| 1227 | }, |
| 1228 | shouldFail: true, |
| 1229 | expectedError: ":BAD_ALERT:", |
| 1230 | }, |
| 1231 | { |
| 1232 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1233 | name: "DoubleAlert", |
| 1234 | config: Config{ |
| 1235 | Bugs: ProtocolBugs{ |
| 1236 | DoubleAlert: true, |
| 1237 | SendSpuriousAlert: alertRecordOverflow, |
| 1238 | }, |
| 1239 | }, |
| 1240 | shouldFail: true, |
| 1241 | expectedError: ":BAD_ALERT:", |
| 1242 | }, |
| 1243 | { |
| 1244 | protocol: dtls, |
| 1245 | testType: serverTest, |
| 1246 | name: "DoubleAlert-DTLS", |
| 1247 | config: Config{ |
| 1248 | Bugs: ProtocolBugs{ |
| 1249 | DoubleAlert: true, |
| 1250 | SendSpuriousAlert: alertRecordOverflow, |
| 1251 | }, |
| 1252 | }, |
| 1253 | shouldFail: true, |
| 1254 | expectedError: ":BAD_ALERT:", |
| 1255 | }, |
| 1256 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1257 | name: "SkipNewSessionTicket", |
| 1258 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1259 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1260 | Bugs: ProtocolBugs{ |
| 1261 | SkipNewSessionTicket: true, |
| 1262 | }, |
| 1263 | }, |
| 1264 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1265 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1266 | }, |
| 1267 | { |
| 1268 | testType: serverTest, |
| 1269 | name: "FallbackSCSV", |
| 1270 | config: Config{ |
| 1271 | MaxVersion: VersionTLS11, |
| 1272 | Bugs: ProtocolBugs{ |
| 1273 | SendFallbackSCSV: true, |
| 1274 | }, |
| 1275 | }, |
| 1276 | shouldFail: true, |
| 1277 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1278 | }, |
| 1279 | { |
| 1280 | testType: serverTest, |
| 1281 | name: "FallbackSCSV-VersionMatch", |
| 1282 | config: Config{ |
| 1283 | Bugs: ProtocolBugs{ |
| 1284 | SendFallbackSCSV: true, |
| 1285 | }, |
| 1286 | }, |
| 1287 | }, |
| 1288 | { |
| 1289 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1290 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1291 | config: Config{ |
| 1292 | MaxVersion: VersionTLS12, |
| 1293 | Bugs: ProtocolBugs{ |
| 1294 | SendFallbackSCSV: true, |
| 1295 | }, |
| 1296 | }, |
| 1297 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1298 | }, |
| 1299 | { |
| 1300 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1301 | name: "FragmentedClientVersion", |
| 1302 | config: Config{ |
| 1303 | Bugs: ProtocolBugs{ |
| 1304 | MaxHandshakeRecordLength: 1, |
| 1305 | FragmentClientVersion: true, |
| 1306 | }, |
| 1307 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1308 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1309 | }, |
| 1310 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1311 | testType: serverTest, |
| 1312 | name: "HttpGET", |
| 1313 | sendPrefix: "GET / HTTP/1.0\n", |
| 1314 | shouldFail: true, |
| 1315 | expectedError: ":HTTP_REQUEST:", |
| 1316 | }, |
| 1317 | { |
| 1318 | testType: serverTest, |
| 1319 | name: "HttpPOST", |
| 1320 | sendPrefix: "POST / HTTP/1.0\n", |
| 1321 | shouldFail: true, |
| 1322 | expectedError: ":HTTP_REQUEST:", |
| 1323 | }, |
| 1324 | { |
| 1325 | testType: serverTest, |
| 1326 | name: "HttpHEAD", |
| 1327 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1328 | shouldFail: true, |
| 1329 | expectedError: ":HTTP_REQUEST:", |
| 1330 | }, |
| 1331 | { |
| 1332 | testType: serverTest, |
| 1333 | name: "HttpPUT", |
| 1334 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1335 | shouldFail: true, |
| 1336 | expectedError: ":HTTP_REQUEST:", |
| 1337 | }, |
| 1338 | { |
| 1339 | testType: serverTest, |
| 1340 | name: "HttpCONNECT", |
| 1341 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1342 | shouldFail: true, |
| 1343 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1344 | }, |
| 1345 | { |
| 1346 | testType: serverTest, |
| 1347 | name: "Garbage", |
| 1348 | sendPrefix: "blah", |
| 1349 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1350 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1351 | }, |
| 1352 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1353 | name: "RSAEphemeralKey", |
| 1354 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1355 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1356 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1357 | Bugs: ProtocolBugs{ |
| 1358 | RSAEphemeralKey: true, |
| 1359 | }, |
| 1360 | }, |
| 1361 | shouldFail: true, |
| 1362 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1363 | }, |
| 1364 | { |
| 1365 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1366 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1367 | shouldFail: true, |
| 1368 | expectedError: ":WRONG_SSL_VERSION:", |
| 1369 | }, |
| 1370 | { |
| 1371 | protocol: dtls, |
| 1372 | name: "DisableEverything-DTLS", |
| 1373 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1374 | shouldFail: true, |
| 1375 | expectedError: ":WRONG_SSL_VERSION:", |
| 1376 | }, |
| 1377 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1378 | protocol: dtls, |
| 1379 | testType: serverTest, |
| 1380 | name: "MTU", |
| 1381 | config: Config{ |
| 1382 | Bugs: ProtocolBugs{ |
| 1383 | MaxPacketLength: 256, |
| 1384 | }, |
| 1385 | }, |
| 1386 | flags: []string{"-mtu", "256"}, |
| 1387 | }, |
| 1388 | { |
| 1389 | protocol: dtls, |
| 1390 | testType: serverTest, |
| 1391 | name: "MTUExceeded", |
| 1392 | config: Config{ |
| 1393 | Bugs: ProtocolBugs{ |
| 1394 | MaxPacketLength: 255, |
| 1395 | }, |
| 1396 | }, |
| 1397 | flags: []string{"-mtu", "256"}, |
| 1398 | shouldFail: true, |
| 1399 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1400 | }, |
| 1401 | { |
| 1402 | name: "CertMismatchRSA", |
| 1403 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1404 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1405 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1406 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1407 | Bugs: ProtocolBugs{ |
| 1408 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1409 | }, |
| 1410 | }, |
| 1411 | shouldFail: true, |
| 1412 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1413 | }, |
| 1414 | { |
| 1415 | name: "CertMismatchECDSA", |
| 1416 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1417 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1418 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1419 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1420 | Bugs: ProtocolBugs{ |
| 1421 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1422 | }, |
| 1423 | }, |
| 1424 | shouldFail: true, |
| 1425 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1426 | }, |
| 1427 | { |
| 1428 | name: "EmptyCertificateList", |
| 1429 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1430 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1431 | Bugs: ProtocolBugs{ |
| 1432 | EmptyCertificateList: true, |
| 1433 | }, |
| 1434 | }, |
| 1435 | shouldFail: true, |
| 1436 | expectedError: ":DECODE_ERROR:", |
| 1437 | }, |
| 1438 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1439 | name: "EmptyCertificateList-TLS13", |
| 1440 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1441 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1442 | Bugs: ProtocolBugs{ |
| 1443 | EmptyCertificateList: true, |
| 1444 | }, |
| 1445 | }, |
| 1446 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1447 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1448 | }, |
| 1449 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1450 | name: "TLSFatalBadPackets", |
| 1451 | damageFirstWrite: true, |
| 1452 | shouldFail: true, |
| 1453 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1454 | }, |
| 1455 | { |
| 1456 | protocol: dtls, |
| 1457 | name: "DTLSIgnoreBadPackets", |
| 1458 | damageFirstWrite: true, |
| 1459 | }, |
| 1460 | { |
| 1461 | protocol: dtls, |
| 1462 | name: "DTLSIgnoreBadPackets-Async", |
| 1463 | damageFirstWrite: true, |
| 1464 | flags: []string{"-async"}, |
| 1465 | }, |
| 1466 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1467 | name: "AppDataBeforeHandshake", |
| 1468 | config: Config{ |
| 1469 | Bugs: ProtocolBugs{ |
| 1470 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1471 | }, |
| 1472 | }, |
| 1473 | shouldFail: true, |
| 1474 | expectedError: ":UNEXPECTED_RECORD:", |
| 1475 | }, |
| 1476 | { |
| 1477 | name: "AppDataBeforeHandshake-Empty", |
| 1478 | config: Config{ |
| 1479 | Bugs: ProtocolBugs{ |
| 1480 | AppDataBeforeHandshake: []byte{}, |
| 1481 | }, |
| 1482 | }, |
| 1483 | shouldFail: true, |
| 1484 | expectedError: ":UNEXPECTED_RECORD:", |
| 1485 | }, |
| 1486 | { |
| 1487 | protocol: dtls, |
| 1488 | name: "AppDataBeforeHandshake-DTLS", |
| 1489 | config: Config{ |
| 1490 | Bugs: ProtocolBugs{ |
| 1491 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1492 | }, |
| 1493 | }, |
| 1494 | shouldFail: true, |
| 1495 | expectedError: ":UNEXPECTED_RECORD:", |
| 1496 | }, |
| 1497 | { |
| 1498 | protocol: dtls, |
| 1499 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1500 | config: Config{ |
| 1501 | Bugs: ProtocolBugs{ |
| 1502 | AppDataBeforeHandshake: []byte{}, |
| 1503 | }, |
| 1504 | }, |
| 1505 | shouldFail: true, |
| 1506 | expectedError: ":UNEXPECTED_RECORD:", |
| 1507 | }, |
| 1508 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1509 | name: "AppDataAfterChangeCipherSpec", |
| 1510 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1511 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1512 | Bugs: ProtocolBugs{ |
| 1513 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1514 | }, |
| 1515 | }, |
| 1516 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1517 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1518 | }, |
| 1519 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1520 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1521 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1522 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1523 | Bugs: ProtocolBugs{ |
| 1524 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1525 | }, |
| 1526 | }, |
| 1527 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1528 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1529 | }, |
| 1530 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1531 | protocol: dtls, |
| 1532 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1533 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1534 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1535 | Bugs: ProtocolBugs{ |
| 1536 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1537 | }, |
| 1538 | }, |
| 1539 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1540 | // application data. |
| 1541 | }, |
| 1542 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1543 | protocol: dtls, |
| 1544 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1545 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1546 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1547 | Bugs: ProtocolBugs{ |
| 1548 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1549 | }, |
| 1550 | }, |
| 1551 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1552 | // application data. |
| 1553 | }, |
| 1554 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1555 | name: "AlertAfterChangeCipherSpec", |
| 1556 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1557 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1558 | Bugs: ProtocolBugs{ |
| 1559 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1560 | }, |
| 1561 | }, |
| 1562 | shouldFail: true, |
| 1563 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1564 | }, |
| 1565 | { |
| 1566 | protocol: dtls, |
| 1567 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1568 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1569 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1570 | Bugs: ProtocolBugs{ |
| 1571 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1572 | }, |
| 1573 | }, |
| 1574 | shouldFail: true, |
| 1575 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1576 | }, |
| 1577 | { |
| 1578 | protocol: dtls, |
| 1579 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1580 | config: Config{ |
| 1581 | Bugs: ProtocolBugs{ |
| 1582 | ReorderHandshakeFragments: true, |
| 1583 | // Small enough that every handshake message is |
| 1584 | // fragmented. |
| 1585 | MaxHandshakeRecordLength: 2, |
| 1586 | }, |
| 1587 | }, |
| 1588 | }, |
| 1589 | { |
| 1590 | protocol: dtls, |
| 1591 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1592 | config: Config{ |
| 1593 | Bugs: ProtocolBugs{ |
| 1594 | ReorderHandshakeFragments: true, |
| 1595 | // Large enough that no handshake message is |
| 1596 | // fragmented. |
| 1597 | MaxHandshakeRecordLength: 2048, |
| 1598 | }, |
| 1599 | }, |
| 1600 | }, |
| 1601 | { |
| 1602 | protocol: dtls, |
| 1603 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1604 | config: Config{ |
| 1605 | Bugs: ProtocolBugs{ |
| 1606 | ReorderHandshakeFragments: true, |
| 1607 | MixCompleteMessageWithFragments: true, |
| 1608 | MaxHandshakeRecordLength: 2, |
| 1609 | }, |
| 1610 | }, |
| 1611 | }, |
| 1612 | { |
| 1613 | name: "SendInvalidRecordType", |
| 1614 | config: Config{ |
| 1615 | Bugs: ProtocolBugs{ |
| 1616 | SendInvalidRecordType: true, |
| 1617 | }, |
| 1618 | }, |
| 1619 | shouldFail: true, |
| 1620 | expectedError: ":UNEXPECTED_RECORD:", |
| 1621 | }, |
| 1622 | { |
| 1623 | protocol: dtls, |
| 1624 | name: "SendInvalidRecordType-DTLS", |
| 1625 | config: Config{ |
| 1626 | Bugs: ProtocolBugs{ |
| 1627 | SendInvalidRecordType: true, |
| 1628 | }, |
| 1629 | }, |
| 1630 | shouldFail: true, |
| 1631 | expectedError: ":UNEXPECTED_RECORD:", |
| 1632 | }, |
| 1633 | { |
| 1634 | name: "FalseStart-SkipServerSecondLeg", |
| 1635 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1636 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1637 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1638 | NextProtos: []string{"foo"}, |
| 1639 | Bugs: ProtocolBugs{ |
| 1640 | SkipNewSessionTicket: true, |
| 1641 | SkipChangeCipherSpec: true, |
| 1642 | SkipFinished: true, |
| 1643 | ExpectFalseStart: true, |
| 1644 | }, |
| 1645 | }, |
| 1646 | flags: []string{ |
| 1647 | "-false-start", |
| 1648 | "-handshake-never-done", |
| 1649 | "-advertise-alpn", "\x03foo", |
| 1650 | }, |
| 1651 | shimWritesFirst: true, |
| 1652 | shouldFail: true, |
| 1653 | expectedError: ":UNEXPECTED_RECORD:", |
| 1654 | }, |
| 1655 | { |
| 1656 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1657 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1658 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1659 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1660 | NextProtos: []string{"foo"}, |
| 1661 | Bugs: ProtocolBugs{ |
| 1662 | SkipNewSessionTicket: true, |
| 1663 | SkipChangeCipherSpec: true, |
| 1664 | SkipFinished: true, |
| 1665 | }, |
| 1666 | }, |
| 1667 | flags: []string{ |
| 1668 | "-implicit-handshake", |
| 1669 | "-false-start", |
| 1670 | "-handshake-never-done", |
| 1671 | "-advertise-alpn", "\x03foo", |
| 1672 | }, |
| 1673 | shouldFail: true, |
| 1674 | expectedError: ":UNEXPECTED_RECORD:", |
| 1675 | }, |
| 1676 | { |
| 1677 | testType: serverTest, |
| 1678 | name: "FailEarlyCallback", |
| 1679 | flags: []string{"-fail-early-callback"}, |
| 1680 | shouldFail: true, |
| 1681 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1682 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1683 | }, |
| 1684 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1685 | protocol: dtls, |
| 1686 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1687 | config: Config{ |
| 1688 | Bugs: ProtocolBugs{ |
| 1689 | MaxHandshakeRecordLength: 2, |
| 1690 | FragmentMessageTypeMismatch: true, |
| 1691 | }, |
| 1692 | }, |
| 1693 | shouldFail: true, |
| 1694 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1695 | }, |
| 1696 | { |
| 1697 | protocol: dtls, |
| 1698 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1699 | config: Config{ |
| 1700 | Bugs: ProtocolBugs{ |
| 1701 | MaxHandshakeRecordLength: 2, |
| 1702 | FragmentMessageLengthMismatch: true, |
| 1703 | }, |
| 1704 | }, |
| 1705 | shouldFail: true, |
| 1706 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1707 | }, |
| 1708 | { |
| 1709 | protocol: dtls, |
| 1710 | name: "SplitFragments-Header-DTLS", |
| 1711 | config: Config{ |
| 1712 | Bugs: ProtocolBugs{ |
| 1713 | SplitFragments: 2, |
| 1714 | }, |
| 1715 | }, |
| 1716 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1717 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1718 | }, |
| 1719 | { |
| 1720 | protocol: dtls, |
| 1721 | name: "SplitFragments-Boundary-DTLS", |
| 1722 | config: Config{ |
| 1723 | Bugs: ProtocolBugs{ |
| 1724 | SplitFragments: dtlsRecordHeaderLen, |
| 1725 | }, |
| 1726 | }, |
| 1727 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1728 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1729 | }, |
| 1730 | { |
| 1731 | protocol: dtls, |
| 1732 | name: "SplitFragments-Body-DTLS", |
| 1733 | config: Config{ |
| 1734 | Bugs: ProtocolBugs{ |
| 1735 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1736 | }, |
| 1737 | }, |
| 1738 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1739 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1740 | }, |
| 1741 | { |
| 1742 | protocol: dtls, |
| 1743 | name: "SendEmptyFragments-DTLS", |
| 1744 | config: Config{ |
| 1745 | Bugs: ProtocolBugs{ |
| 1746 | SendEmptyFragments: true, |
| 1747 | }, |
| 1748 | }, |
| 1749 | }, |
| 1750 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1751 | name: "BadFinished-Client", |
| 1752 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1753 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1754 | Bugs: ProtocolBugs{ |
| 1755 | BadFinished: true, |
| 1756 | }, |
| 1757 | }, |
| 1758 | shouldFail: true, |
| 1759 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1760 | }, |
| 1761 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1762 | name: "BadFinished-Client-TLS13", |
| 1763 | config: Config{ |
| 1764 | MaxVersion: VersionTLS13, |
| 1765 | Bugs: ProtocolBugs{ |
| 1766 | BadFinished: true, |
| 1767 | }, |
| 1768 | }, |
| 1769 | shouldFail: true, |
| 1770 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1771 | }, |
| 1772 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1773 | testType: serverTest, |
| 1774 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1775 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1776 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1777 | Bugs: ProtocolBugs{ |
| 1778 | BadFinished: true, |
| 1779 | }, |
| 1780 | }, |
| 1781 | shouldFail: true, |
| 1782 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1783 | }, |
| 1784 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1785 | testType: serverTest, |
| 1786 | name: "BadFinished-Server-TLS13", |
| 1787 | config: Config{ |
| 1788 | MaxVersion: VersionTLS13, |
| 1789 | Bugs: ProtocolBugs{ |
| 1790 | BadFinished: true, |
| 1791 | }, |
| 1792 | }, |
| 1793 | shouldFail: true, |
| 1794 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1795 | }, |
| 1796 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1797 | name: "FalseStart-BadFinished", |
| 1798 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1799 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1800 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1801 | NextProtos: []string{"foo"}, |
| 1802 | Bugs: ProtocolBugs{ |
| 1803 | BadFinished: true, |
| 1804 | ExpectFalseStart: true, |
| 1805 | }, |
| 1806 | }, |
| 1807 | flags: []string{ |
| 1808 | "-false-start", |
| 1809 | "-handshake-never-done", |
| 1810 | "-advertise-alpn", "\x03foo", |
| 1811 | }, |
| 1812 | shimWritesFirst: true, |
| 1813 | shouldFail: true, |
| 1814 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1815 | }, |
| 1816 | { |
| 1817 | name: "NoFalseStart-NoALPN", |
| 1818 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1819 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1820 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1821 | Bugs: ProtocolBugs{ |
| 1822 | ExpectFalseStart: true, |
| 1823 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1824 | }, |
| 1825 | }, |
| 1826 | flags: []string{ |
| 1827 | "-false-start", |
| 1828 | }, |
| 1829 | shimWritesFirst: true, |
| 1830 | shouldFail: true, |
| 1831 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1832 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1833 | }, |
| 1834 | { |
| 1835 | name: "NoFalseStart-NoAEAD", |
| 1836 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1837 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1838 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1839 | NextProtos: []string{"foo"}, |
| 1840 | Bugs: ProtocolBugs{ |
| 1841 | ExpectFalseStart: true, |
| 1842 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1843 | }, |
| 1844 | }, |
| 1845 | flags: []string{ |
| 1846 | "-false-start", |
| 1847 | "-advertise-alpn", "\x03foo", |
| 1848 | }, |
| 1849 | shimWritesFirst: true, |
| 1850 | shouldFail: true, |
| 1851 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1852 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1853 | }, |
| 1854 | { |
| 1855 | name: "NoFalseStart-RSA", |
| 1856 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1857 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1858 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1859 | NextProtos: []string{"foo"}, |
| 1860 | Bugs: ProtocolBugs{ |
| 1861 | ExpectFalseStart: true, |
| 1862 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1863 | }, |
| 1864 | }, |
| 1865 | flags: []string{ |
| 1866 | "-false-start", |
| 1867 | "-advertise-alpn", "\x03foo", |
| 1868 | }, |
| 1869 | shimWritesFirst: true, |
| 1870 | shouldFail: true, |
| 1871 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1872 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1873 | }, |
| 1874 | { |
| 1875 | name: "NoFalseStart-DHE_RSA", |
| 1876 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1877 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1878 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1879 | NextProtos: []string{"foo"}, |
| 1880 | Bugs: ProtocolBugs{ |
| 1881 | ExpectFalseStart: true, |
| 1882 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1883 | }, |
| 1884 | }, |
| 1885 | flags: []string{ |
| 1886 | "-false-start", |
| 1887 | "-advertise-alpn", "\x03foo", |
| 1888 | }, |
| 1889 | shimWritesFirst: true, |
| 1890 | shouldFail: true, |
| 1891 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1892 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1893 | }, |
| 1894 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1895 | protocol: dtls, |
| 1896 | name: "SendSplitAlert-Sync", |
| 1897 | config: Config{ |
| 1898 | Bugs: ProtocolBugs{ |
| 1899 | SendSplitAlert: true, |
| 1900 | }, |
| 1901 | }, |
| 1902 | }, |
| 1903 | { |
| 1904 | protocol: dtls, |
| 1905 | name: "SendSplitAlert-Async", |
| 1906 | config: Config{ |
| 1907 | Bugs: ProtocolBugs{ |
| 1908 | SendSplitAlert: true, |
| 1909 | }, |
| 1910 | }, |
| 1911 | flags: []string{"-async"}, |
| 1912 | }, |
| 1913 | { |
| 1914 | protocol: dtls, |
| 1915 | name: "PackDTLSHandshake", |
| 1916 | config: Config{ |
| 1917 | Bugs: ProtocolBugs{ |
| 1918 | MaxHandshakeRecordLength: 2, |
| 1919 | PackHandshakeFragments: 20, |
| 1920 | PackHandshakeRecords: 200, |
| 1921 | }, |
| 1922 | }, |
| 1923 | }, |
| 1924 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1925 | name: "SendEmptyRecords-Pass", |
| 1926 | sendEmptyRecords: 32, |
| 1927 | }, |
| 1928 | { |
| 1929 | name: "SendEmptyRecords", |
| 1930 | sendEmptyRecords: 33, |
| 1931 | shouldFail: true, |
| 1932 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1933 | }, |
| 1934 | { |
| 1935 | name: "SendEmptyRecords-Async", |
| 1936 | sendEmptyRecords: 33, |
| 1937 | flags: []string{"-async"}, |
| 1938 | shouldFail: true, |
| 1939 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1940 | }, |
| 1941 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1942 | name: "SendWarningAlerts-Pass", |
| 1943 | config: Config{ |
| 1944 | MaxVersion: VersionTLS12, |
| 1945 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1946 | sendWarningAlerts: 4, |
| 1947 | }, |
| 1948 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1949 | protocol: dtls, |
| 1950 | name: "SendWarningAlerts-DTLS-Pass", |
| 1951 | config: Config{ |
| 1952 | MaxVersion: VersionTLS12, |
| 1953 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1954 | sendWarningAlerts: 4, |
| 1955 | }, |
| 1956 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1957 | name: "SendWarningAlerts-TLS13", |
| 1958 | config: Config{ |
| 1959 | MaxVersion: VersionTLS13, |
| 1960 | }, |
| 1961 | sendWarningAlerts: 4, |
| 1962 | shouldFail: true, |
| 1963 | expectedError: ":BAD_ALERT:", |
| 1964 | expectedLocalError: "remote error: error decoding message", |
| 1965 | }, |
| 1966 | { |
| 1967 | name: "SendWarningAlerts", |
| 1968 | config: Config{ |
| 1969 | MaxVersion: VersionTLS12, |
| 1970 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1971 | sendWarningAlerts: 5, |
| 1972 | shouldFail: true, |
| 1973 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 1974 | }, |
| 1975 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1976 | name: "SendWarningAlerts-Async", |
| 1977 | config: Config{ |
| 1978 | MaxVersion: VersionTLS12, |
| 1979 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1980 | sendWarningAlerts: 5, |
| 1981 | flags: []string{"-async"}, |
| 1982 | shouldFail: true, |
| 1983 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 1984 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1985 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 1986 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 1987 | config: Config{ |
| 1988 | MaxVersion: VersionTLS13, |
| 1989 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 1990 | sendKeyUpdates: 33, |
| 1991 | keyUpdateRequest: keyUpdateNotRequested, |
| 1992 | shouldFail: true, |
| 1993 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 1994 | }, |
| 1995 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1996 | name: "EmptySessionID", |
| 1997 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1998 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1999 | SessionTicketsDisabled: true, |
| 2000 | }, |
| 2001 | noSessionCache: true, |
| 2002 | flags: []string{"-expect-no-session"}, |
| 2003 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2004 | { |
| 2005 | name: "Unclean-Shutdown", |
| 2006 | config: Config{ |
| 2007 | Bugs: ProtocolBugs{ |
| 2008 | NoCloseNotify: true, |
| 2009 | ExpectCloseNotify: true, |
| 2010 | }, |
| 2011 | }, |
| 2012 | shimShutsDown: true, |
| 2013 | flags: []string{"-check-close-notify"}, |
| 2014 | shouldFail: true, |
| 2015 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2016 | }, |
| 2017 | { |
| 2018 | name: "Unclean-Shutdown-Ignored", |
| 2019 | config: Config{ |
| 2020 | Bugs: ProtocolBugs{ |
| 2021 | NoCloseNotify: true, |
| 2022 | }, |
| 2023 | }, |
| 2024 | shimShutsDown: true, |
| 2025 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2026 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2027 | name: "Unclean-Shutdown-Alert", |
| 2028 | config: Config{ |
| 2029 | Bugs: ProtocolBugs{ |
| 2030 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2031 | ExpectCloseNotify: true, |
| 2032 | }, |
| 2033 | }, |
| 2034 | shimShutsDown: true, |
| 2035 | flags: []string{"-check-close-notify"}, |
| 2036 | shouldFail: true, |
| 2037 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2038 | }, |
| 2039 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2040 | name: "LargePlaintext", |
| 2041 | config: Config{ |
| 2042 | Bugs: ProtocolBugs{ |
| 2043 | SendLargeRecords: true, |
| 2044 | }, |
| 2045 | }, |
| 2046 | messageLen: maxPlaintext + 1, |
| 2047 | shouldFail: true, |
| 2048 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2049 | }, |
| 2050 | { |
| 2051 | protocol: dtls, |
| 2052 | name: "LargePlaintext-DTLS", |
| 2053 | config: Config{ |
| 2054 | Bugs: ProtocolBugs{ |
| 2055 | SendLargeRecords: true, |
| 2056 | }, |
| 2057 | }, |
| 2058 | messageLen: maxPlaintext + 1, |
| 2059 | shouldFail: true, |
| 2060 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2061 | }, |
| 2062 | { |
| 2063 | name: "LargeCiphertext", |
| 2064 | config: Config{ |
| 2065 | Bugs: ProtocolBugs{ |
| 2066 | SendLargeRecords: true, |
| 2067 | }, |
| 2068 | }, |
| 2069 | messageLen: maxPlaintext * 2, |
| 2070 | shouldFail: true, |
| 2071 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2072 | }, |
| 2073 | { |
| 2074 | protocol: dtls, |
| 2075 | name: "LargeCiphertext-DTLS", |
| 2076 | config: Config{ |
| 2077 | Bugs: ProtocolBugs{ |
| 2078 | SendLargeRecords: true, |
| 2079 | }, |
| 2080 | }, |
| 2081 | messageLen: maxPlaintext * 2, |
| 2082 | // Unlike the other four cases, DTLS drops records which |
| 2083 | // are invalid before authentication, so the connection |
| 2084 | // does not fail. |
| 2085 | expectMessageDropped: true, |
| 2086 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2087 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2088 | name: "BadHelloRequest-1", |
| 2089 | renegotiate: 1, |
| 2090 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2091 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2092 | Bugs: ProtocolBugs{ |
| 2093 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2094 | }, |
| 2095 | }, |
| 2096 | flags: []string{ |
| 2097 | "-renegotiate-freely", |
| 2098 | "-expect-total-renegotiations", "1", |
| 2099 | }, |
| 2100 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2101 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2102 | }, |
| 2103 | { |
| 2104 | name: "BadHelloRequest-2", |
| 2105 | renegotiate: 1, |
| 2106 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2107 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2108 | Bugs: ProtocolBugs{ |
| 2109 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2110 | }, |
| 2111 | }, |
| 2112 | flags: []string{ |
| 2113 | "-renegotiate-freely", |
| 2114 | "-expect-total-renegotiations", "1", |
| 2115 | }, |
| 2116 | shouldFail: true, |
| 2117 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2118 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2119 | { |
| 2120 | testType: serverTest, |
| 2121 | name: "SupportTicketsWithSessionID", |
| 2122 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2123 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2124 | SessionTicketsDisabled: true, |
| 2125 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2126 | resumeConfig: &Config{ |
| 2127 | MaxVersion: VersionTLS12, |
| 2128 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2129 | resumeSession: true, |
| 2130 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2131 | { |
| 2132 | protocol: dtls, |
| 2133 | name: "DTLS-SendExtraFinished", |
| 2134 | config: Config{ |
| 2135 | Bugs: ProtocolBugs{ |
| 2136 | SendExtraFinished: true, |
| 2137 | }, |
| 2138 | }, |
| 2139 | shouldFail: true, |
| 2140 | expectedError: ":UNEXPECTED_RECORD:", |
| 2141 | }, |
| 2142 | { |
| 2143 | protocol: dtls, |
| 2144 | name: "DTLS-SendExtraFinished-Reordered", |
| 2145 | config: Config{ |
| 2146 | Bugs: ProtocolBugs{ |
| 2147 | MaxHandshakeRecordLength: 2, |
| 2148 | ReorderHandshakeFragments: true, |
| 2149 | SendExtraFinished: true, |
| 2150 | }, |
| 2151 | }, |
| 2152 | shouldFail: true, |
| 2153 | expectedError: ":UNEXPECTED_RECORD:", |
| 2154 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2155 | { |
| 2156 | testType: serverTest, |
| 2157 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2158 | config: Config{ |
| 2159 | // Choose a cipher suite that does not involve |
| 2160 | // elliptic curves, so no extensions are |
| 2161 | // involved. |
| 2162 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2163 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2164 | Bugs: ProtocolBugs{ |
| 2165 | SendV2ClientHello: true, |
| 2166 | }, |
| 2167 | }, |
| 2168 | sendPrefix: string([]byte{ |
| 2169 | byte(recordTypeHandshake), |
| 2170 | 3, 1, // version |
| 2171 | 0, 0, // length |
| 2172 | }), |
| 2173 | // A no-op empty record may not be sent before V2ClientHello. |
| 2174 | shouldFail: true, |
| 2175 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2176 | }, |
| 2177 | { |
| 2178 | testType: serverTest, |
| 2179 | name: "V2ClientHello-WarningAlertPrefix", |
| 2180 | config: Config{ |
| 2181 | // Choose a cipher suite that does not involve |
| 2182 | // elliptic curves, so no extensions are |
| 2183 | // involved. |
| 2184 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2185 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2186 | Bugs: ProtocolBugs{ |
| 2187 | SendV2ClientHello: true, |
| 2188 | }, |
| 2189 | }, |
| 2190 | sendPrefix: string([]byte{ |
| 2191 | byte(recordTypeAlert), |
| 2192 | 3, 1, // version |
| 2193 | 0, 2, // length |
| 2194 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2195 | }), |
| 2196 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2197 | shouldFail: true, |
| 2198 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2199 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2200 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2201 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2202 | config: Config{ |
| 2203 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2204 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2205 | sendKeyUpdates: 1, |
| 2206 | keyUpdateRequest: keyUpdateNotRequested, |
| 2207 | }, |
| 2208 | { |
| 2209 | name: "KeyUpdate-InvalidRequestMode", |
| 2210 | config: Config{ |
| 2211 | MaxVersion: VersionTLS13, |
| 2212 | }, |
| 2213 | sendKeyUpdates: 1, |
| 2214 | keyUpdateRequest: 42, |
| 2215 | shouldFail: true, |
| 2216 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2217 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2218 | { |
| 2219 | name: "SendSNIWarningAlert", |
| 2220 | config: Config{ |
| 2221 | MaxVersion: VersionTLS12, |
| 2222 | Bugs: ProtocolBugs{ |
| 2223 | SendSNIWarningAlert: true, |
| 2224 | }, |
| 2225 | }, |
| 2226 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2227 | { |
| 2228 | testType: serverTest, |
| 2229 | name: "ExtraCompressionMethods-TLS12", |
| 2230 | config: Config{ |
| 2231 | MaxVersion: VersionTLS12, |
| 2232 | Bugs: ProtocolBugs{ |
| 2233 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2234 | }, |
| 2235 | }, |
| 2236 | }, |
| 2237 | { |
| 2238 | testType: serverTest, |
| 2239 | name: "ExtraCompressionMethods-TLS13", |
| 2240 | config: Config{ |
| 2241 | MaxVersion: VersionTLS13, |
| 2242 | Bugs: ProtocolBugs{ |
| 2243 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2244 | }, |
| 2245 | }, |
| 2246 | shouldFail: true, |
| 2247 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2248 | expectedLocalError: "remote error: illegal parameter", |
| 2249 | }, |
| 2250 | { |
| 2251 | testType: serverTest, |
| 2252 | name: "NoNullCompression-TLS12", |
| 2253 | config: Config{ |
| 2254 | MaxVersion: VersionTLS12, |
| 2255 | Bugs: ProtocolBugs{ |
| 2256 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2257 | }, |
| 2258 | }, |
| 2259 | shouldFail: true, |
| 2260 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2261 | expectedLocalError: "remote error: illegal parameter", |
| 2262 | }, |
| 2263 | { |
| 2264 | testType: serverTest, |
| 2265 | name: "NoNullCompression-TLS13", |
| 2266 | config: Config{ |
| 2267 | MaxVersion: VersionTLS13, |
| 2268 | Bugs: ProtocolBugs{ |
| 2269 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2270 | }, |
| 2271 | }, |
| 2272 | shouldFail: true, |
| 2273 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2274 | expectedLocalError: "remote error: illegal parameter", |
| 2275 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2276 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2277 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2278 | config: Config{ |
| 2279 | MaxVersion: VersionTLS12, |
| 2280 | Bugs: ProtocolBugs{ |
| 2281 | ExpectGREASE: true, |
| 2282 | }, |
| 2283 | }, |
| 2284 | flags: []string{"-enable-grease"}, |
| 2285 | }, |
| 2286 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2287 | name: "GREASE-Client-TLS13", |
| 2288 | config: Config{ |
| 2289 | MaxVersion: VersionTLS13, |
| 2290 | Bugs: ProtocolBugs{ |
| 2291 | ExpectGREASE: true, |
| 2292 | }, |
| 2293 | }, |
| 2294 | flags: []string{"-enable-grease"}, |
| 2295 | }, |
| 2296 | { |
| 2297 | testType: serverTest, |
| 2298 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2299 | config: Config{ |
| 2300 | MaxVersion: VersionTLS13, |
| 2301 | Bugs: ProtocolBugs{ |
| 2302 | ExpectGREASE: true, |
| 2303 | }, |
| 2304 | }, |
| 2305 | flags: []string{"-enable-grease"}, |
| 2306 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2307 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2308 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2309 | |
| 2310 | // Test that very large messages can be received. |
| 2311 | cert := rsaCertificate |
| 2312 | for i := 0; i < 50; i++ { |
| 2313 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2314 | } |
| 2315 | testCases = append(testCases, testCase{ |
| 2316 | name: "LargeMessage", |
| 2317 | config: Config{ |
| 2318 | Certificates: []Certificate{cert}, |
| 2319 | }, |
| 2320 | }) |
| 2321 | testCases = append(testCases, testCase{ |
| 2322 | protocol: dtls, |
| 2323 | name: "LargeMessage-DTLS", |
| 2324 | config: Config{ |
| 2325 | Certificates: []Certificate{cert}, |
| 2326 | }, |
| 2327 | }) |
| 2328 | |
| 2329 | // They are rejected if the maximum certificate chain length is capped. |
| 2330 | testCases = append(testCases, testCase{ |
| 2331 | name: "LargeMessage-Reject", |
| 2332 | config: Config{ |
| 2333 | Certificates: []Certificate{cert}, |
| 2334 | }, |
| 2335 | flags: []string{"-max-cert-list", "16384"}, |
| 2336 | shouldFail: true, |
| 2337 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2338 | }) |
| 2339 | testCases = append(testCases, testCase{ |
| 2340 | protocol: dtls, |
| 2341 | name: "LargeMessage-Reject-DTLS", |
| 2342 | config: Config{ |
| 2343 | Certificates: []Certificate{cert}, |
| 2344 | }, |
| 2345 | flags: []string{"-max-cert-list", "16384"}, |
| 2346 | shouldFail: true, |
| 2347 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2348 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2349 | } |
| 2350 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2351 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2352 | const bogusCipher = 0xfe00 |
| 2353 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2354 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2355 | const psk = "12345" |
| 2356 | const pskIdentity = "luggage combo" |
| 2357 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2358 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2359 | var certFile string |
| 2360 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2361 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2362 | cert = ecdsaP256Certificate |
| 2363 | certFile = ecdsaP256CertificateFile |
| 2364 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2365 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2366 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2367 | certFile = rsaCertificateFile |
| 2368 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2369 | } |
| 2370 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2371 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2372 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2373 | flags = append(flags, |
| 2374 | "-psk", psk, |
| 2375 | "-psk-identity", pskIdentity) |
| 2376 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2377 | if hasComponent(suite.name, "NULL") { |
| 2378 | // NULL ciphers must be explicitly enabled. |
| 2379 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2380 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2381 | if hasComponent(suite.name, "CECPQ1") { |
| 2382 | // CECPQ1 ciphers must be explicitly enabled. |
| 2383 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2384 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2385 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2386 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2387 | // for now. |
| 2388 | flags = append(flags, "-cipher", suite.name) |
| 2389 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2390 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2391 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2392 | for _, protocol := range []protocol{tls, dtls} { |
| 2393 | var prefix string |
| 2394 | if protocol == dtls { |
| 2395 | if !ver.hasDTLS { |
| 2396 | continue |
| 2397 | } |
| 2398 | prefix = "D" |
| 2399 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2400 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2401 | var shouldServerFail, shouldClientFail bool |
| 2402 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2403 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2404 | // a BoringSSL server will never select it |
| 2405 | // because the extension is missing. |
| 2406 | shouldServerFail = true |
| 2407 | } |
| 2408 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2409 | shouldClientFail = true |
| 2410 | shouldServerFail = true |
| 2411 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2412 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2413 | shouldClientFail = true |
| 2414 | shouldServerFail = true |
| 2415 | } |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2416 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2417 | shouldClientFail = true |
| 2418 | shouldServerFail = true |
| 2419 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2420 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2421 | shouldClientFail = true |
| 2422 | shouldServerFail = true |
| 2423 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2424 | |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2425 | var sendCipherSuite uint16 |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2426 | var expectedServerError, expectedClientError string |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2427 | serverCipherSuites := []uint16{suite.id} |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2428 | if shouldServerFail { |
| 2429 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2430 | } |
| 2431 | if shouldClientFail { |
| 2432 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2433 | // Configure the server to select ciphers as normal but |
| 2434 | // select an incompatible cipher in ServerHello. |
| 2435 | serverCipherSuites = nil |
| 2436 | sendCipherSuite = suite.id |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2437 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2438 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2439 | testCases = append(testCases, testCase{ |
| 2440 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2441 | protocol: protocol, |
| 2442 | |
| 2443 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2444 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2445 | MinVersion: ver.version, |
| 2446 | MaxVersion: ver.version, |
| 2447 | CipherSuites: []uint16{suite.id}, |
| 2448 | Certificates: []Certificate{cert}, |
| 2449 | PreSharedKey: []byte(psk), |
| 2450 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2451 | Bugs: ProtocolBugs{ |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2452 | AdvertiseAllConfiguredCiphers: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2453 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2454 | }, |
| 2455 | certFile: certFile, |
| 2456 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2457 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2458 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2459 | shouldFail: shouldServerFail, |
| 2460 | expectedError: expectedServerError, |
| 2461 | }) |
| 2462 | |
| 2463 | testCases = append(testCases, testCase{ |
| 2464 | testType: clientTest, |
| 2465 | protocol: protocol, |
| 2466 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2467 | config: Config{ |
| 2468 | MinVersion: ver.version, |
| 2469 | MaxVersion: ver.version, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2470 | CipherSuites: serverCipherSuites, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2471 | Certificates: []Certificate{cert}, |
| 2472 | PreSharedKey: []byte(psk), |
| 2473 | PreSharedKeyIdentity: pskIdentity, |
| 2474 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2475 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2476 | SendCipherSuite: sendCipherSuite, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2477 | }, |
| 2478 | }, |
| 2479 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2480 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2481 | shouldFail: shouldClientFail, |
| 2482 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2483 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2484 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2485 | if !shouldClientFail { |
| 2486 | // Ensure the maximum record size is accepted. |
| 2487 | testCases = append(testCases, testCase{ |
| 2488 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2489 | config: Config{ |
| 2490 | MinVersion: ver.version, |
| 2491 | MaxVersion: ver.version, |
| 2492 | CipherSuites: []uint16{suite.id}, |
| 2493 | Certificates: []Certificate{cert}, |
| 2494 | PreSharedKey: []byte(psk), |
| 2495 | PreSharedKeyIdentity: pskIdentity, |
| 2496 | }, |
| 2497 | flags: flags, |
| 2498 | messageLen: maxPlaintext, |
| 2499 | }) |
| 2500 | } |
| 2501 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2502 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2503 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2504 | |
| 2505 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2506 | name: "NoSharedCipher", |
| 2507 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2508 | MaxVersion: VersionTLS12, |
| 2509 | CipherSuites: []uint16{}, |
| 2510 | }, |
| 2511 | shouldFail: true, |
| 2512 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2513 | }) |
| 2514 | |
| 2515 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2516 | name: "NoSharedCipher-TLS13", |
| 2517 | config: Config{ |
| 2518 | MaxVersion: VersionTLS13, |
| 2519 | CipherSuites: []uint16{}, |
| 2520 | }, |
| 2521 | shouldFail: true, |
| 2522 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2523 | }) |
| 2524 | |
| 2525 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2526 | name: "UnsupportedCipherSuite", |
| 2527 | config: Config{ |
| 2528 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2529 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2530 | Bugs: ProtocolBugs{ |
| 2531 | IgnorePeerCipherPreferences: true, |
| 2532 | }, |
| 2533 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2534 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2535 | shouldFail: true, |
| 2536 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2537 | }) |
| 2538 | |
| 2539 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2540 | name: "ServerHelloBogusCipher", |
| 2541 | config: Config{ |
| 2542 | MaxVersion: VersionTLS12, |
| 2543 | Bugs: ProtocolBugs{ |
| 2544 | SendCipherSuite: bogusCipher, |
| 2545 | }, |
| 2546 | }, |
| 2547 | shouldFail: true, |
| 2548 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2549 | }) |
| 2550 | testCases = append(testCases, testCase{ |
| 2551 | name: "ServerHelloBogusCipher-TLS13", |
| 2552 | config: Config{ |
| 2553 | MaxVersion: VersionTLS13, |
| 2554 | Bugs: ProtocolBugs{ |
| 2555 | SendCipherSuite: bogusCipher, |
| 2556 | }, |
| 2557 | }, |
| 2558 | shouldFail: true, |
| 2559 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2560 | }) |
| 2561 | |
| 2562 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2563 | name: "WeakDH", |
| 2564 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2565 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2566 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2567 | Bugs: ProtocolBugs{ |
| 2568 | // This is a 1023-bit prime number, generated |
| 2569 | // with: |
| 2570 | // openssl gendh 1023 | openssl asn1parse -i |
| 2571 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2572 | }, |
| 2573 | }, |
| 2574 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2575 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2576 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2577 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2578 | testCases = append(testCases, testCase{ |
| 2579 | name: "SillyDH", |
| 2580 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2581 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2582 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2583 | Bugs: ProtocolBugs{ |
| 2584 | // This is a 4097-bit prime number, generated |
| 2585 | // with: |
| 2586 | // openssl gendh 4097 | openssl asn1parse -i |
| 2587 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2588 | }, |
| 2589 | }, |
| 2590 | shouldFail: true, |
| 2591 | expectedError: ":DH_P_TOO_LONG:", |
| 2592 | }) |
| 2593 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2594 | // This test ensures that Diffie-Hellman public values are padded with |
| 2595 | // zeros so that they're the same length as the prime. This is to avoid |
| 2596 | // hitting a bug in yaSSL. |
| 2597 | testCases = append(testCases, testCase{ |
| 2598 | testType: serverTest, |
| 2599 | name: "DHPublicValuePadded", |
| 2600 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2601 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2602 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2603 | Bugs: ProtocolBugs{ |
| 2604 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2605 | }, |
| 2606 | }, |
| 2607 | flags: []string{"-use-sparse-dh-prime"}, |
| 2608 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2609 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2610 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2611 | testCases = append(testCases, testCase{ |
| 2612 | testType: serverTest, |
| 2613 | name: "UnknownCipher", |
| 2614 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2615 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2616 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2617 | Bugs: ProtocolBugs{ |
| 2618 | AdvertiseAllConfiguredCiphers: true, |
| 2619 | }, |
| 2620 | }, |
| 2621 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2622 | |
| 2623 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2624 | testCases = append(testCases, testCase{ |
| 2625 | testType: serverTest, |
| 2626 | name: "UnknownCipher-TLS13", |
| 2627 | config: Config{ |
| 2628 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2629 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2630 | Bugs: ProtocolBugs{ |
| 2631 | AdvertiseAllConfiguredCiphers: true, |
| 2632 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2633 | }, |
| 2634 | }) |
| 2635 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2636 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2637 | testCases = append(testCases, testCase{ |
| 2638 | name: "EmptyECDHEPSKHint", |
| 2639 | config: Config{ |
| 2640 | MaxVersion: VersionTLS12, |
| 2641 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2642 | PreSharedKey: []byte("secret"), |
| 2643 | }, |
| 2644 | flags: []string{"-psk", "secret"}, |
| 2645 | }) |
| 2646 | |
| 2647 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2648 | // ServerKeyExchange is sent. |
| 2649 | testCases = append(testCases, testCase{ |
| 2650 | name: "ExplicitEmptyPSKHint", |
| 2651 | config: Config{ |
| 2652 | MaxVersion: VersionTLS12, |
| 2653 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2654 | PreSharedKey: []byte("secret"), |
| 2655 | Bugs: ProtocolBugs{ |
| 2656 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2657 | }, |
| 2658 | }, |
| 2659 | flags: []string{"-psk", "secret"}, |
| 2660 | }) |
| 2661 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2662 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2663 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2664 | // cipher lists and then a connection is made for each member of |
| 2665 | // expectations. The cipher suite that the server selects must match |
| 2666 | // the specified one. |
| 2667 | var versionSpecificCiphersTest = []struct { |
| 2668 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2669 | // expectations is a map from TLS version to cipher suite id. |
| 2670 | expectations map[uint16]uint16 |
| 2671 | }{ |
| 2672 | { |
| 2673 | // Test that the null case (where no version-specific ciphers are set) |
| 2674 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2675 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2676 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2677 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2678 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2679 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2680 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2681 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2682 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2683 | }, |
| 2684 | }, |
| 2685 | { |
| 2686 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2687 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2688 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2689 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2690 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2691 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2692 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2693 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2694 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2695 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2696 | }, |
| 2697 | }, |
| 2698 | { |
| 2699 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2700 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2701 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2702 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2703 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2704 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2705 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2706 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2707 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2708 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2709 | }, |
| 2710 | }, |
| 2711 | { |
| 2712 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2713 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2714 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2715 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2716 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2717 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2718 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2719 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2720 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2721 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2722 | }, |
| 2723 | }, |
| 2724 | } |
| 2725 | |
| 2726 | for i, test := range versionSpecificCiphersTest { |
| 2727 | for version, expectedCipherSuite := range test.expectations { |
| 2728 | flags := []string{"-cipher", test.ciphersDefault} |
| 2729 | if len(test.ciphersTLS10) > 0 { |
| 2730 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2731 | } |
| 2732 | if len(test.ciphersTLS11) > 0 { |
| 2733 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2734 | } |
| 2735 | |
| 2736 | testCases = append(testCases, testCase{ |
| 2737 | testType: serverTest, |
| 2738 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2739 | config: Config{ |
| 2740 | MaxVersion: version, |
| 2741 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2742 | 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] | 2743 | }, |
| 2744 | flags: flags, |
| 2745 | expectedCipher: expectedCipherSuite, |
| 2746 | }) |
| 2747 | } |
| 2748 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2749 | } |
| 2750 | |
| 2751 | func addBadECDSASignatureTests() { |
| 2752 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2753 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2754 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2755 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2756 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2757 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2758 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2759 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2760 | Bugs: ProtocolBugs{ |
| 2761 | BadECDSAR: badR, |
| 2762 | BadECDSAS: badS, |
| 2763 | }, |
| 2764 | }, |
| 2765 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2766 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2767 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2768 | testCases = append(testCases, testCase{ |
| 2769 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2770 | config: Config{ |
| 2771 | MaxVersion: VersionTLS13, |
| 2772 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2773 | Bugs: ProtocolBugs{ |
| 2774 | BadECDSAR: badR, |
| 2775 | BadECDSAS: badS, |
| 2776 | }, |
| 2777 | }, |
| 2778 | shouldFail: true, |
| 2779 | expectedError: ":BAD_SIGNATURE:", |
| 2780 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2781 | } |
| 2782 | } |
| 2783 | } |
| 2784 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2785 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2786 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2787 | name: "MaxCBCPadding", |
| 2788 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2789 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2790 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2791 | Bugs: ProtocolBugs{ |
| 2792 | MaxPadding: true, |
| 2793 | }, |
| 2794 | }, |
| 2795 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2796 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2797 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2798 | name: "BadCBCPadding", |
| 2799 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2800 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2801 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2802 | Bugs: ProtocolBugs{ |
| 2803 | PaddingFirstByteBad: true, |
| 2804 | }, |
| 2805 | }, |
| 2806 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2807 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2808 | }) |
| 2809 | // OpenSSL previously had an issue where the first byte of padding in |
| 2810 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2811 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2812 | name: "BadCBCPadding255", |
| 2813 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2814 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2815 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2816 | Bugs: ProtocolBugs{ |
| 2817 | MaxPadding: true, |
| 2818 | PaddingFirstByteBadIf255: true, |
| 2819 | }, |
| 2820 | }, |
| 2821 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2822 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2823 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2824 | }) |
| 2825 | } |
| 2826 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2827 | func addCBCSplittingTests() { |
| 2828 | testCases = append(testCases, testCase{ |
| 2829 | name: "CBCRecordSplitting", |
| 2830 | config: Config{ |
| 2831 | MaxVersion: VersionTLS10, |
| 2832 | MinVersion: VersionTLS10, |
| 2833 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2834 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2835 | messageLen: -1, // read until EOF |
| 2836 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2837 | flags: []string{ |
| 2838 | "-async", |
| 2839 | "-write-different-record-sizes", |
| 2840 | "-cbc-record-splitting", |
| 2841 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2842 | }) |
| 2843 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2844 | name: "CBCRecordSplittingPartialWrite", |
| 2845 | config: Config{ |
| 2846 | MaxVersion: VersionTLS10, |
| 2847 | MinVersion: VersionTLS10, |
| 2848 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2849 | }, |
| 2850 | messageLen: -1, // read until EOF |
| 2851 | flags: []string{ |
| 2852 | "-async", |
| 2853 | "-write-different-record-sizes", |
| 2854 | "-cbc-record-splitting", |
| 2855 | "-partial-write", |
| 2856 | }, |
| 2857 | }) |
| 2858 | } |
| 2859 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2860 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2861 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2862 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2863 | certPool := x509.NewCertPool() |
| 2864 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2865 | if err != nil { |
| 2866 | panic(err) |
| 2867 | } |
| 2868 | certPool.AddCert(cert) |
| 2869 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2870 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2871 | testCases = append(testCases, testCase{ |
| 2872 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2873 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2874 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2875 | MinVersion: ver.version, |
| 2876 | MaxVersion: ver.version, |
| 2877 | ClientAuth: RequireAnyClientCert, |
| 2878 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2879 | }, |
| 2880 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2881 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2882 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2883 | }, |
| 2884 | }) |
| 2885 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2886 | testType: serverTest, |
| 2887 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2888 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2889 | MinVersion: ver.version, |
| 2890 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2891 | Certificates: []Certificate{rsaCertificate}, |
| 2892 | }, |
| 2893 | flags: []string{"-require-any-client-certificate"}, |
| 2894 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2895 | if ver.version != VersionSSL30 { |
| 2896 | testCases = append(testCases, testCase{ |
| 2897 | testType: serverTest, |
| 2898 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 2899 | config: Config{ |
| 2900 | MinVersion: ver.version, |
| 2901 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2902 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2903 | }, |
| 2904 | flags: []string{"-require-any-client-certificate"}, |
| 2905 | }) |
| 2906 | testCases = append(testCases, testCase{ |
| 2907 | testType: clientTest, |
| 2908 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 2909 | config: Config{ |
| 2910 | MinVersion: ver.version, |
| 2911 | MaxVersion: ver.version, |
| 2912 | ClientAuth: RequireAnyClientCert, |
| 2913 | ClientCAs: certPool, |
| 2914 | }, |
| 2915 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2916 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2917 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2918 | }, |
| 2919 | }) |
| 2920 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2921 | |
| 2922 | testCases = append(testCases, testCase{ |
| 2923 | name: "NoClientCertificate-" + ver.name, |
| 2924 | config: Config{ |
| 2925 | MinVersion: ver.version, |
| 2926 | MaxVersion: ver.version, |
| 2927 | ClientAuth: RequireAnyClientCert, |
| 2928 | }, |
| 2929 | shouldFail: true, |
| 2930 | expectedLocalError: "client didn't provide a certificate", |
| 2931 | }) |
| 2932 | |
| 2933 | testCases = append(testCases, testCase{ |
| 2934 | // Even if not configured to expect a certificate, OpenSSL will |
| 2935 | // return X509_V_OK as the verify_result. |
| 2936 | testType: serverTest, |
| 2937 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 2938 | config: Config{ |
| 2939 | MinVersion: ver.version, |
| 2940 | MaxVersion: ver.version, |
| 2941 | }, |
| 2942 | flags: []string{ |
| 2943 | "-expect-verify-result", |
| 2944 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 2945 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2946 | }) |
| 2947 | |
| 2948 | testCases = append(testCases, testCase{ |
| 2949 | // If a client certificate is not provided, OpenSSL will still |
| 2950 | // return X509_V_OK as the verify_result. |
| 2951 | testType: serverTest, |
| 2952 | name: "NoClientCertificate-Server-" + ver.name, |
| 2953 | config: Config{ |
| 2954 | MinVersion: ver.version, |
| 2955 | MaxVersion: ver.version, |
| 2956 | }, |
| 2957 | flags: []string{ |
| 2958 | "-expect-verify-result", |
| 2959 | "-verify-peer", |
| 2960 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 2961 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2962 | }) |
| 2963 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 2964 | certificateRequired := "remote error: certificate required" |
| 2965 | if ver.version < VersionTLS13 { |
| 2966 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 2967 | // was used. |
| 2968 | certificateRequired = "remote error: handshake failure" |
| 2969 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2970 | testCases = append(testCases, testCase{ |
| 2971 | testType: serverTest, |
| 2972 | name: "RequireAnyClientCertificate-" + ver.name, |
| 2973 | config: Config{ |
| 2974 | MinVersion: ver.version, |
| 2975 | MaxVersion: ver.version, |
| 2976 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 2977 | flags: []string{"-require-any-client-certificate"}, |
| 2978 | shouldFail: true, |
| 2979 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2980 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2981 | }) |
| 2982 | |
| 2983 | if ver.version != VersionSSL30 { |
| 2984 | testCases = append(testCases, testCase{ |
| 2985 | testType: serverTest, |
| 2986 | name: "SkipClientCertificate-" + ver.name, |
| 2987 | config: Config{ |
| 2988 | MinVersion: ver.version, |
| 2989 | MaxVersion: ver.version, |
| 2990 | Bugs: ProtocolBugs{ |
| 2991 | SkipClientCertificate: true, |
| 2992 | }, |
| 2993 | }, |
| 2994 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2995 | flags: []string{"-verify-peer"}, |
| 2996 | shouldFail: true, |
| 2997 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2998 | }) |
| 2999 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3000 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3001 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3002 | // Client auth is only legal in certificate-based ciphers. |
| 3003 | testCases = append(testCases, testCase{ |
| 3004 | testType: clientTest, |
| 3005 | name: "ClientAuth-PSK", |
| 3006 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3007 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3008 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3009 | PreSharedKey: []byte("secret"), |
| 3010 | ClientAuth: RequireAnyClientCert, |
| 3011 | }, |
| 3012 | flags: []string{ |
| 3013 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3014 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3015 | "-psk", "secret", |
| 3016 | }, |
| 3017 | shouldFail: true, |
| 3018 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3019 | }) |
| 3020 | testCases = append(testCases, testCase{ |
| 3021 | testType: clientTest, |
| 3022 | name: "ClientAuth-ECDHE_PSK", |
| 3023 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3024 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3025 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3026 | PreSharedKey: []byte("secret"), |
| 3027 | ClientAuth: RequireAnyClientCert, |
| 3028 | }, |
| 3029 | flags: []string{ |
| 3030 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3031 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3032 | "-psk", "secret", |
| 3033 | }, |
| 3034 | shouldFail: true, |
| 3035 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3036 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3037 | |
| 3038 | // Regression test for a bug where the client CA list, if explicitly |
| 3039 | // set to NULL, was mis-encoded. |
| 3040 | testCases = append(testCases, testCase{ |
| 3041 | testType: serverTest, |
| 3042 | name: "Null-Client-CA-List", |
| 3043 | config: Config{ |
| 3044 | MaxVersion: VersionTLS12, |
| 3045 | Certificates: []Certificate{rsaCertificate}, |
| 3046 | }, |
| 3047 | flags: []string{ |
| 3048 | "-require-any-client-certificate", |
| 3049 | "-use-null-client-ca-list", |
| 3050 | }, |
| 3051 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3052 | } |
| 3053 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3054 | func addExtendedMasterSecretTests() { |
| 3055 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3056 | |
| 3057 | for _, with := range []bool{false, true} { |
| 3058 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3059 | if with { |
| 3060 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3061 | } |
| 3062 | |
| 3063 | for _, isClient := range []bool{false, true} { |
| 3064 | suffix := "-Server" |
| 3065 | testType := serverTest |
| 3066 | if isClient { |
| 3067 | suffix = "-Client" |
| 3068 | testType = clientTest |
| 3069 | } |
| 3070 | |
| 3071 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3072 | // In TLS 1.3, the extension is irrelevant and |
| 3073 | // always reports as enabled. |
| 3074 | var flags []string |
| 3075 | if with || ver.version >= VersionTLS13 { |
| 3076 | flags = []string{expectEMSFlag} |
| 3077 | } |
| 3078 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3079 | test := testCase{ |
| 3080 | testType: testType, |
| 3081 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3082 | config: Config{ |
| 3083 | MinVersion: ver.version, |
| 3084 | MaxVersion: ver.version, |
| 3085 | Bugs: ProtocolBugs{ |
| 3086 | NoExtendedMasterSecret: !with, |
| 3087 | RequireExtendedMasterSecret: with, |
| 3088 | }, |
| 3089 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3090 | flags: flags, |
| 3091 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3092 | } |
| 3093 | if test.shouldFail { |
| 3094 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3095 | } |
| 3096 | testCases = append(testCases, test) |
| 3097 | } |
| 3098 | } |
| 3099 | } |
| 3100 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3101 | for _, isClient := range []bool{false, true} { |
| 3102 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3103 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3104 | boolToWord := func(b bool) string { |
| 3105 | if b { |
| 3106 | return "Yes" |
| 3107 | } |
| 3108 | return "No" |
| 3109 | } |
| 3110 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3111 | if isClient { |
| 3112 | suffix += "Client" |
| 3113 | } else { |
| 3114 | suffix += "Server" |
| 3115 | } |
| 3116 | |
| 3117 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3118 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3119 | Bugs: ProtocolBugs{ |
| 3120 | RequireExtendedMasterSecret: true, |
| 3121 | }, |
| 3122 | } |
| 3123 | |
| 3124 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3125 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3126 | Bugs: ProtocolBugs{ |
| 3127 | NoExtendedMasterSecret: true, |
| 3128 | }, |
| 3129 | } |
| 3130 | |
| 3131 | test := testCase{ |
| 3132 | name: "ExtendedMasterSecret-" + suffix, |
| 3133 | resumeSession: true, |
| 3134 | } |
| 3135 | |
| 3136 | if !isClient { |
| 3137 | test.testType = serverTest |
| 3138 | } |
| 3139 | |
| 3140 | if supportedInFirstConnection { |
| 3141 | test.config = supportedConfig |
| 3142 | } else { |
| 3143 | test.config = noSupportConfig |
| 3144 | } |
| 3145 | |
| 3146 | if supportedInResumeConnection { |
| 3147 | test.resumeConfig = &supportedConfig |
| 3148 | } else { |
| 3149 | test.resumeConfig = &noSupportConfig |
| 3150 | } |
| 3151 | |
| 3152 | switch suffix { |
| 3153 | case "YesToYes-Client", "YesToYes-Server": |
| 3154 | // When a session is resumed, it should |
| 3155 | // still be aware that its master |
| 3156 | // secret was generated via EMS and |
| 3157 | // thus it's safe to use tls-unique. |
| 3158 | test.flags = []string{expectEMSFlag} |
| 3159 | case "NoToYes-Server": |
| 3160 | // If an original connection did not |
| 3161 | // contain EMS, but a resumption |
| 3162 | // handshake does, then a server should |
| 3163 | // not resume the session. |
| 3164 | test.expectResumeRejected = true |
| 3165 | case "YesToNo-Server": |
| 3166 | // Resuming an EMS session without the |
| 3167 | // EMS extension should cause the |
| 3168 | // server to abort the connection. |
| 3169 | test.shouldFail = true |
| 3170 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3171 | case "NoToYes-Client": |
| 3172 | // A client should abort a connection |
| 3173 | // where the server resumed a non-EMS |
| 3174 | // session but echoed the EMS |
| 3175 | // extension. |
| 3176 | test.shouldFail = true |
| 3177 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3178 | case "YesToNo-Client": |
| 3179 | // A client should abort a connection |
| 3180 | // where the server didn't echo EMS |
| 3181 | // when the session used it. |
| 3182 | test.shouldFail = true |
| 3183 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3184 | } |
| 3185 | |
| 3186 | testCases = append(testCases, test) |
| 3187 | } |
| 3188 | } |
| 3189 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3190 | |
| 3191 | // Switching EMS on renegotiation is forbidden. |
| 3192 | testCases = append(testCases, testCase{ |
| 3193 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3194 | config: Config{ |
| 3195 | MaxVersion: VersionTLS12, |
| 3196 | Bugs: ProtocolBugs{ |
| 3197 | NoExtendedMasterSecret: true, |
| 3198 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3199 | }, |
| 3200 | }, |
| 3201 | renegotiate: 1, |
| 3202 | flags: []string{ |
| 3203 | "-renegotiate-freely", |
| 3204 | "-expect-total-renegotiations", "1", |
| 3205 | }, |
| 3206 | }) |
| 3207 | |
| 3208 | testCases = append(testCases, testCase{ |
| 3209 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3210 | config: Config{ |
| 3211 | MaxVersion: VersionTLS12, |
| 3212 | Bugs: ProtocolBugs{ |
| 3213 | NoExtendedMasterSecret: true, |
| 3214 | }, |
| 3215 | }, |
| 3216 | renegotiate: 1, |
| 3217 | flags: []string{ |
| 3218 | "-renegotiate-freely", |
| 3219 | "-expect-total-renegotiations", "1", |
| 3220 | }, |
| 3221 | shouldFail: true, |
| 3222 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3223 | }) |
| 3224 | |
| 3225 | testCases = append(testCases, testCase{ |
| 3226 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3227 | config: Config{ |
| 3228 | MaxVersion: VersionTLS12, |
| 3229 | Bugs: ProtocolBugs{ |
| 3230 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3231 | }, |
| 3232 | }, |
| 3233 | renegotiate: 1, |
| 3234 | flags: []string{ |
| 3235 | "-renegotiate-freely", |
| 3236 | "-expect-total-renegotiations", "1", |
| 3237 | }, |
| 3238 | shouldFail: true, |
| 3239 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3240 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3241 | } |
| 3242 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3243 | type stateMachineTestConfig struct { |
| 3244 | protocol protocol |
| 3245 | async bool |
| 3246 | splitHandshake, packHandshakeFlight bool |
| 3247 | } |
| 3248 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3249 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3250 | // various conditions. Some of these are redundant with other tests, but they |
| 3251 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3252 | func addAllStateMachineCoverageTests() { |
| 3253 | for _, async := range []bool{false, true} { |
| 3254 | for _, protocol := range []protocol{tls, dtls} { |
| 3255 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3256 | protocol: protocol, |
| 3257 | async: async, |
| 3258 | }) |
| 3259 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3260 | protocol: protocol, |
| 3261 | async: async, |
| 3262 | splitHandshake: true, |
| 3263 | }) |
| 3264 | if protocol == tls { |
| 3265 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3266 | protocol: protocol, |
| 3267 | async: async, |
| 3268 | packHandshakeFlight: true, |
| 3269 | }) |
| 3270 | } |
| 3271 | } |
| 3272 | } |
| 3273 | } |
| 3274 | |
| 3275 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3276 | var tests []testCase |
| 3277 | |
| 3278 | // Basic handshake, with resumption. Client and server, |
| 3279 | // session ID and session ticket. |
| 3280 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3281 | name: "Basic-Client", |
| 3282 | config: Config{ |
| 3283 | MaxVersion: VersionTLS12, |
| 3284 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3285 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3286 | // Ensure session tickets are used, not session IDs. |
| 3287 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3288 | }) |
| 3289 | tests = append(tests, testCase{ |
| 3290 | name: "Basic-Client-RenewTicket", |
| 3291 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3292 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3293 | Bugs: ProtocolBugs{ |
| 3294 | RenewTicketOnResume: true, |
| 3295 | }, |
| 3296 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3297 | flags: []string{"-expect-ticket-renewal"}, |
| 3298 | resumeSession: true, |
| 3299 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3300 | }) |
| 3301 | tests = append(tests, testCase{ |
| 3302 | name: "Basic-Client-NoTicket", |
| 3303 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3304 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3305 | SessionTicketsDisabled: true, |
| 3306 | }, |
| 3307 | resumeSession: true, |
| 3308 | }) |
| 3309 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3310 | name: "Basic-Client-Implicit", |
| 3311 | config: Config{ |
| 3312 | MaxVersion: VersionTLS12, |
| 3313 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3314 | flags: []string{"-implicit-handshake"}, |
| 3315 | resumeSession: true, |
| 3316 | }) |
| 3317 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3318 | testType: serverTest, |
| 3319 | name: "Basic-Server", |
| 3320 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3321 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3322 | Bugs: ProtocolBugs{ |
| 3323 | RequireSessionTickets: true, |
| 3324 | }, |
| 3325 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3326 | resumeSession: true, |
| 3327 | }) |
| 3328 | tests = append(tests, testCase{ |
| 3329 | testType: serverTest, |
| 3330 | name: "Basic-Server-NoTickets", |
| 3331 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3332 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3333 | SessionTicketsDisabled: true, |
| 3334 | }, |
| 3335 | resumeSession: true, |
| 3336 | }) |
| 3337 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3338 | testType: serverTest, |
| 3339 | name: "Basic-Server-Implicit", |
| 3340 | config: Config{ |
| 3341 | MaxVersion: VersionTLS12, |
| 3342 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3343 | flags: []string{"-implicit-handshake"}, |
| 3344 | resumeSession: true, |
| 3345 | }) |
| 3346 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3347 | testType: serverTest, |
| 3348 | name: "Basic-Server-EarlyCallback", |
| 3349 | config: Config{ |
| 3350 | MaxVersion: VersionTLS12, |
| 3351 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3352 | flags: []string{"-use-early-callback"}, |
| 3353 | resumeSession: true, |
| 3354 | }) |
| 3355 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3356 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3357 | if config.protocol == tls { |
| 3358 | tests = append(tests, testCase{ |
| 3359 | name: "TLS13-1RTT-Client", |
| 3360 | config: Config{ |
| 3361 | MaxVersion: VersionTLS13, |
| 3362 | MinVersion: VersionTLS13, |
| 3363 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3364 | resumeSession: true, |
| 3365 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3366 | }) |
| 3367 | |
| 3368 | tests = append(tests, testCase{ |
| 3369 | testType: serverTest, |
| 3370 | name: "TLS13-1RTT-Server", |
| 3371 | config: Config{ |
| 3372 | MaxVersion: VersionTLS13, |
| 3373 | MinVersion: VersionTLS13, |
| 3374 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3375 | resumeSession: true, |
| 3376 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3377 | }) |
| 3378 | |
| 3379 | tests = append(tests, testCase{ |
| 3380 | name: "TLS13-HelloRetryRequest-Client", |
| 3381 | config: Config{ |
| 3382 | MaxVersion: VersionTLS13, |
| 3383 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame^] | 3384 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3385 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3386 | CurvePreferences: []CurveID{CurveP384}, |
| 3387 | Bugs: ProtocolBugs{ |
| 3388 | ExpectMissingKeyShare: true, |
| 3389 | }, |
| 3390 | }, |
| 3391 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3392 | resumeSession: true, |
| 3393 | }) |
| 3394 | |
| 3395 | tests = append(tests, testCase{ |
| 3396 | testType: serverTest, |
| 3397 | name: "TLS13-HelloRetryRequest-Server", |
| 3398 | config: Config{ |
| 3399 | MaxVersion: VersionTLS13, |
| 3400 | MinVersion: VersionTLS13, |
| 3401 | // Require a HelloRetryRequest for every curve. |
| 3402 | DefaultCurves: []CurveID{}, |
| 3403 | }, |
| 3404 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3405 | resumeSession: true, |
| 3406 | }) |
| 3407 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3408 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3409 | // TLS client auth. |
| 3410 | tests = append(tests, testCase{ |
| 3411 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3412 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3413 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3414 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3415 | ClientAuth: RequestClientCert, |
| 3416 | }, |
| 3417 | }) |
| 3418 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3419 | testType: serverTest, |
| 3420 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3421 | config: Config{ |
| 3422 | MaxVersion: VersionTLS12, |
| 3423 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3424 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3425 | flags: []string{"-verify-peer"}, |
| 3426 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3427 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3428 | tests = append(tests, testCase{ |
| 3429 | testType: clientTest, |
| 3430 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3431 | config: Config{ |
| 3432 | MaxVersion: VersionSSL30, |
| 3433 | ClientAuth: RequestClientCert, |
| 3434 | }, |
| 3435 | }) |
| 3436 | tests = append(tests, testCase{ |
| 3437 | testType: serverTest, |
| 3438 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3439 | config: Config{ |
| 3440 | MaxVersion: VersionSSL30, |
| 3441 | }, |
| 3442 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3443 | flags: []string{"-verify-peer"}, |
| 3444 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3445 | tests = append(tests, testCase{ |
| 3446 | testType: clientTest, |
| 3447 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3448 | config: Config{ |
| 3449 | MaxVersion: VersionTLS13, |
| 3450 | ClientAuth: RequestClientCert, |
| 3451 | }, |
| 3452 | }) |
| 3453 | tests = append(tests, testCase{ |
| 3454 | testType: serverTest, |
| 3455 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3456 | config: Config{ |
| 3457 | MaxVersion: VersionTLS13, |
| 3458 | }, |
| 3459 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3460 | flags: []string{"-verify-peer"}, |
| 3461 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3462 | } |
| 3463 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3464 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3465 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3466 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3467 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3468 | ClientAuth: RequireAnyClientCert, |
| 3469 | }, |
| 3470 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3471 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3472 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3473 | }, |
| 3474 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3475 | tests = append(tests, testCase{ |
| 3476 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3477 | name: "ClientAuth-RSA-Client-TLS13", |
| 3478 | config: Config{ |
| 3479 | MaxVersion: VersionTLS13, |
| 3480 | ClientAuth: RequireAnyClientCert, |
| 3481 | }, |
| 3482 | flags: []string{ |
| 3483 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3484 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3485 | }, |
| 3486 | }) |
| 3487 | tests = append(tests, testCase{ |
| 3488 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3489 | name: "ClientAuth-ECDSA-Client", |
| 3490 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3491 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3492 | ClientAuth: RequireAnyClientCert, |
| 3493 | }, |
| 3494 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3495 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3496 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3497 | }, |
| 3498 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3499 | tests = append(tests, testCase{ |
| 3500 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3501 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3502 | config: Config{ |
| 3503 | MaxVersion: VersionTLS13, |
| 3504 | ClientAuth: RequireAnyClientCert, |
| 3505 | }, |
| 3506 | flags: []string{ |
| 3507 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3508 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3509 | }, |
| 3510 | }) |
| 3511 | tests = append(tests, testCase{ |
| 3512 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3513 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3514 | config: Config{ |
| 3515 | MaxVersion: VersionTLS12, |
| 3516 | ClientAuth: RequestClientCert, |
| 3517 | }, |
| 3518 | flags: []string{"-use-old-client-cert-callback"}, |
| 3519 | }) |
| 3520 | tests = append(tests, testCase{ |
| 3521 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3522 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3523 | config: Config{ |
| 3524 | MaxVersion: VersionTLS13, |
| 3525 | ClientAuth: RequestClientCert, |
| 3526 | }, |
| 3527 | flags: []string{"-use-old-client-cert-callback"}, |
| 3528 | }) |
| 3529 | tests = append(tests, testCase{ |
| 3530 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3531 | name: "ClientAuth-OldCallback", |
| 3532 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3533 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3534 | ClientAuth: RequireAnyClientCert, |
| 3535 | }, |
| 3536 | flags: []string{ |
| 3537 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3538 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3539 | "-use-old-client-cert-callback", |
| 3540 | }, |
| 3541 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3542 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3543 | testType: clientTest, |
| 3544 | name: "ClientAuth-OldCallback-TLS13", |
| 3545 | config: Config{ |
| 3546 | MaxVersion: VersionTLS13, |
| 3547 | ClientAuth: RequireAnyClientCert, |
| 3548 | }, |
| 3549 | flags: []string{ |
| 3550 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3551 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3552 | "-use-old-client-cert-callback", |
| 3553 | }, |
| 3554 | }) |
| 3555 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3556 | testType: serverTest, |
| 3557 | name: "ClientAuth-Server", |
| 3558 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3559 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3560 | Certificates: []Certificate{rsaCertificate}, |
| 3561 | }, |
| 3562 | flags: []string{"-require-any-client-certificate"}, |
| 3563 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3564 | tests = append(tests, testCase{ |
| 3565 | testType: serverTest, |
| 3566 | name: "ClientAuth-Server-TLS13", |
| 3567 | config: Config{ |
| 3568 | MaxVersion: VersionTLS13, |
| 3569 | Certificates: []Certificate{rsaCertificate}, |
| 3570 | }, |
| 3571 | flags: []string{"-require-any-client-certificate"}, |
| 3572 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3573 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3574 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3575 | tests = append(tests, testCase{ |
| 3576 | testType: serverTest, |
| 3577 | name: "Basic-Server-RSA", |
| 3578 | config: Config{ |
| 3579 | MaxVersion: VersionTLS12, |
| 3580 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3581 | }, |
| 3582 | flags: []string{ |
| 3583 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3584 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3585 | }, |
| 3586 | }) |
| 3587 | tests = append(tests, testCase{ |
| 3588 | testType: serverTest, |
| 3589 | name: "Basic-Server-ECDHE-RSA", |
| 3590 | config: Config{ |
| 3591 | MaxVersion: VersionTLS12, |
| 3592 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3593 | }, |
| 3594 | flags: []string{ |
| 3595 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3596 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3597 | }, |
| 3598 | }) |
| 3599 | tests = append(tests, testCase{ |
| 3600 | testType: serverTest, |
| 3601 | name: "Basic-Server-ECDHE-ECDSA", |
| 3602 | config: Config{ |
| 3603 | MaxVersion: VersionTLS12, |
| 3604 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3605 | }, |
| 3606 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3607 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3608 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3609 | }, |
| 3610 | }) |
| 3611 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3612 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3613 | tests = append(tests, testCase{ |
| 3614 | name: "SessionTicketsDisabled-Client", |
| 3615 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3616 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3617 | SessionTicketsDisabled: true, |
| 3618 | }, |
| 3619 | }) |
| 3620 | tests = append(tests, testCase{ |
| 3621 | testType: serverTest, |
| 3622 | name: "SessionTicketsDisabled-Server", |
| 3623 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3624 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3625 | SessionTicketsDisabled: true, |
| 3626 | }, |
| 3627 | }) |
| 3628 | |
| 3629 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3630 | // identity hint. |
| 3631 | tests = append(tests, testCase{ |
| 3632 | name: "EmptyPSKHint-Client", |
| 3633 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3634 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3635 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3636 | PreSharedKey: []byte("secret"), |
| 3637 | }, |
| 3638 | flags: []string{"-psk", "secret"}, |
| 3639 | }) |
| 3640 | tests = append(tests, testCase{ |
| 3641 | testType: serverTest, |
| 3642 | name: "EmptyPSKHint-Server", |
| 3643 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3644 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3645 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3646 | PreSharedKey: []byte("secret"), |
| 3647 | }, |
| 3648 | flags: []string{"-psk", "secret"}, |
| 3649 | }) |
| 3650 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3651 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3652 | tests = append(tests, testCase{ |
| 3653 | testType: clientTest, |
| 3654 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3655 | config: Config{ |
| 3656 | MaxVersion: VersionTLS12, |
| 3657 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3658 | flags: []string{ |
| 3659 | "-enable-ocsp-stapling", |
| 3660 | "-expect-ocsp-response", |
| 3661 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3662 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3663 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3664 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3665 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3666 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3667 | testType: serverTest, |
| 3668 | name: "OCSPStapling-Server", |
| 3669 | config: Config{ |
| 3670 | MaxVersion: VersionTLS12, |
| 3671 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3672 | expectedOCSPResponse: testOCSPResponse, |
| 3673 | flags: []string{ |
| 3674 | "-ocsp-response", |
| 3675 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3676 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3677 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3678 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3679 | tests = append(tests, testCase{ |
| 3680 | testType: clientTest, |
| 3681 | name: "OCSPStapling-Client-TLS13", |
| 3682 | config: Config{ |
| 3683 | MaxVersion: VersionTLS13, |
| 3684 | }, |
| 3685 | flags: []string{ |
| 3686 | "-enable-ocsp-stapling", |
| 3687 | "-expect-ocsp-response", |
| 3688 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3689 | "-verify-peer", |
| 3690 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3691 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3692 | }) |
| 3693 | tests = append(tests, testCase{ |
| 3694 | testType: serverTest, |
| 3695 | name: "OCSPStapling-Server-TLS13", |
| 3696 | config: Config{ |
| 3697 | MaxVersion: VersionTLS13, |
| 3698 | }, |
| 3699 | expectedOCSPResponse: testOCSPResponse, |
| 3700 | flags: []string{ |
| 3701 | "-ocsp-response", |
| 3702 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3703 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3704 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3705 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3706 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3707 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3708 | for _, vers := range tlsVersions { |
| 3709 | if config.protocol == dtls && !vers.hasDTLS { |
| 3710 | continue |
| 3711 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3712 | for _, testType := range []testType{clientTest, serverTest} { |
| 3713 | suffix := "-Client" |
| 3714 | if testType == serverTest { |
| 3715 | suffix = "-Server" |
| 3716 | } |
| 3717 | suffix += "-" + vers.name |
| 3718 | |
| 3719 | flag := "-verify-peer" |
| 3720 | if testType == serverTest { |
| 3721 | flag = "-require-any-client-certificate" |
| 3722 | } |
| 3723 | |
| 3724 | tests = append(tests, testCase{ |
| 3725 | testType: testType, |
| 3726 | name: "CertificateVerificationSucceed" + suffix, |
| 3727 | config: Config{ |
| 3728 | MaxVersion: vers.version, |
| 3729 | Certificates: []Certificate{rsaCertificate}, |
| 3730 | }, |
| 3731 | flags: []string{ |
| 3732 | flag, |
| 3733 | "-expect-verify-result", |
| 3734 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3735 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3736 | }) |
| 3737 | tests = append(tests, testCase{ |
| 3738 | testType: testType, |
| 3739 | name: "CertificateVerificationFail" + suffix, |
| 3740 | config: Config{ |
| 3741 | MaxVersion: vers.version, |
| 3742 | Certificates: []Certificate{rsaCertificate}, |
| 3743 | }, |
| 3744 | flags: []string{ |
| 3745 | flag, |
| 3746 | "-verify-fail", |
| 3747 | }, |
| 3748 | shouldFail: true, |
| 3749 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3750 | }) |
| 3751 | } |
| 3752 | |
| 3753 | // By default, the client is in a soft fail mode where the peer |
| 3754 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3755 | tests = append(tests, testCase{ |
| 3756 | testType: clientTest, |
| 3757 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3758 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3759 | MaxVersion: vers.version, |
| 3760 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3761 | }, |
| 3762 | flags: []string{ |
| 3763 | "-verify-fail", |
| 3764 | "-expect-verify-result", |
| 3765 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3766 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3767 | }) |
| 3768 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3769 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3770 | tests = append(tests, testCase{ |
| 3771 | name: "ShimSendAlert", |
| 3772 | flags: []string{"-send-alert"}, |
| 3773 | shimWritesFirst: true, |
| 3774 | shouldFail: true, |
| 3775 | expectedLocalError: "remote error: decompression failure", |
| 3776 | }) |
| 3777 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3778 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3779 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3780 | name: "Renegotiate-Client", |
| 3781 | config: Config{ |
| 3782 | MaxVersion: VersionTLS12, |
| 3783 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3784 | renegotiate: 1, |
| 3785 | flags: []string{ |
| 3786 | "-renegotiate-freely", |
| 3787 | "-expect-total-renegotiations", "1", |
| 3788 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3789 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3790 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3791 | tests = append(tests, testCase{ |
| 3792 | name: "SendHalfHelloRequest", |
| 3793 | config: Config{ |
| 3794 | MaxVersion: VersionTLS12, |
| 3795 | Bugs: ProtocolBugs{ |
| 3796 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3797 | }, |
| 3798 | }, |
| 3799 | sendHalfHelloRequest: true, |
| 3800 | flags: []string{"-renegotiate-ignore"}, |
| 3801 | shouldFail: true, |
| 3802 | expectedError: ":UNEXPECTED_RECORD:", |
| 3803 | }) |
| 3804 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3805 | // NPN on client and server; results in post-handshake message. |
| 3806 | tests = append(tests, testCase{ |
| 3807 | name: "NPN-Client", |
| 3808 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3809 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3810 | NextProtos: []string{"foo"}, |
| 3811 | }, |
| 3812 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3813 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3814 | expectedNextProto: "foo", |
| 3815 | expectedNextProtoType: npn, |
| 3816 | }) |
| 3817 | tests = append(tests, testCase{ |
| 3818 | testType: serverTest, |
| 3819 | name: "NPN-Server", |
| 3820 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3821 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3822 | NextProtos: []string{"bar"}, |
| 3823 | }, |
| 3824 | flags: []string{ |
| 3825 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3826 | "-expect-next-proto", "bar", |
| 3827 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3828 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3829 | expectedNextProto: "bar", |
| 3830 | expectedNextProtoType: npn, |
| 3831 | }) |
| 3832 | |
| 3833 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3834 | |
| 3835 | // Client does False Start and negotiates NPN. |
| 3836 | tests = append(tests, testCase{ |
| 3837 | name: "FalseStart", |
| 3838 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3839 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3840 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3841 | NextProtos: []string{"foo"}, |
| 3842 | Bugs: ProtocolBugs{ |
| 3843 | ExpectFalseStart: true, |
| 3844 | }, |
| 3845 | }, |
| 3846 | flags: []string{ |
| 3847 | "-false-start", |
| 3848 | "-select-next-proto", "foo", |
| 3849 | }, |
| 3850 | shimWritesFirst: true, |
| 3851 | resumeSession: true, |
| 3852 | }) |
| 3853 | |
| 3854 | // Client does False Start and negotiates ALPN. |
| 3855 | tests = append(tests, testCase{ |
| 3856 | name: "FalseStart-ALPN", |
| 3857 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3858 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3859 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3860 | NextProtos: []string{"foo"}, |
| 3861 | Bugs: ProtocolBugs{ |
| 3862 | ExpectFalseStart: true, |
| 3863 | }, |
| 3864 | }, |
| 3865 | flags: []string{ |
| 3866 | "-false-start", |
| 3867 | "-advertise-alpn", "\x03foo", |
| 3868 | }, |
| 3869 | shimWritesFirst: true, |
| 3870 | resumeSession: true, |
| 3871 | }) |
| 3872 | |
| 3873 | // Client does False Start but doesn't explicitly call |
| 3874 | // SSL_connect. |
| 3875 | tests = append(tests, testCase{ |
| 3876 | name: "FalseStart-Implicit", |
| 3877 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3878 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3879 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3880 | NextProtos: []string{"foo"}, |
| 3881 | }, |
| 3882 | flags: []string{ |
| 3883 | "-implicit-handshake", |
| 3884 | "-false-start", |
| 3885 | "-advertise-alpn", "\x03foo", |
| 3886 | }, |
| 3887 | }) |
| 3888 | |
| 3889 | // False Start without session tickets. |
| 3890 | tests = append(tests, testCase{ |
| 3891 | name: "FalseStart-SessionTicketsDisabled", |
| 3892 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3893 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3894 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3895 | NextProtos: []string{"foo"}, |
| 3896 | SessionTicketsDisabled: true, |
| 3897 | Bugs: ProtocolBugs{ |
| 3898 | ExpectFalseStart: true, |
| 3899 | }, |
| 3900 | }, |
| 3901 | flags: []string{ |
| 3902 | "-false-start", |
| 3903 | "-select-next-proto", "foo", |
| 3904 | }, |
| 3905 | shimWritesFirst: true, |
| 3906 | }) |
| 3907 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 3908 | tests = append(tests, testCase{ |
| 3909 | name: "FalseStart-CECPQ1", |
| 3910 | config: Config{ |
| 3911 | MaxVersion: VersionTLS12, |
| 3912 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 3913 | NextProtos: []string{"foo"}, |
| 3914 | Bugs: ProtocolBugs{ |
| 3915 | ExpectFalseStart: true, |
| 3916 | }, |
| 3917 | }, |
| 3918 | flags: []string{ |
| 3919 | "-false-start", |
| 3920 | "-cipher", "DEFAULT:kCECPQ1", |
| 3921 | "-select-next-proto", "foo", |
| 3922 | }, |
| 3923 | shimWritesFirst: true, |
| 3924 | resumeSession: true, |
| 3925 | }) |
| 3926 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3927 | // Server parses a V2ClientHello. |
| 3928 | tests = append(tests, testCase{ |
| 3929 | testType: serverTest, |
| 3930 | name: "SendV2ClientHello", |
| 3931 | config: Config{ |
| 3932 | // Choose a cipher suite that does not involve |
| 3933 | // elliptic curves, so no extensions are |
| 3934 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3935 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 3936 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3937 | Bugs: ProtocolBugs{ |
| 3938 | SendV2ClientHello: true, |
| 3939 | }, |
| 3940 | }, |
| 3941 | }) |
| 3942 | |
| 3943 | // Client sends a Channel ID. |
| 3944 | tests = append(tests, testCase{ |
| 3945 | name: "ChannelID-Client", |
| 3946 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3947 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3948 | RequestChannelID: true, |
| 3949 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3950 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3951 | resumeSession: true, |
| 3952 | expectChannelID: true, |
| 3953 | }) |
| 3954 | |
| 3955 | // Server accepts a Channel ID. |
| 3956 | tests = append(tests, testCase{ |
| 3957 | testType: serverTest, |
| 3958 | name: "ChannelID-Server", |
| 3959 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3960 | MaxVersion: VersionTLS12, |
| 3961 | ChannelID: channelIDKey, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3962 | }, |
| 3963 | flags: []string{ |
| 3964 | "-expect-channel-id", |
| 3965 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3966 | }, |
| 3967 | resumeSession: true, |
| 3968 | expectChannelID: true, |
| 3969 | }) |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3970 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3971 | // Channel ID and NPN at the same time, to ensure their relative |
| 3972 | // ordering is correct. |
| 3973 | tests = append(tests, testCase{ |
| 3974 | name: "ChannelID-NPN-Client", |
| 3975 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3976 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3977 | RequestChannelID: true, |
| 3978 | NextProtos: []string{"foo"}, |
| 3979 | }, |
| 3980 | flags: []string{ |
| 3981 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 3982 | "-select-next-proto", "foo", |
| 3983 | }, |
| 3984 | resumeSession: true, |
| 3985 | expectChannelID: true, |
| 3986 | expectedNextProto: "foo", |
| 3987 | expectedNextProtoType: npn, |
| 3988 | }) |
| 3989 | tests = append(tests, testCase{ |
| 3990 | testType: serverTest, |
| 3991 | name: "ChannelID-NPN-Server", |
| 3992 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3993 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3994 | ChannelID: channelIDKey, |
| 3995 | NextProtos: []string{"bar"}, |
| 3996 | }, |
| 3997 | flags: []string{ |
| 3998 | "-expect-channel-id", |
| 3999 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4000 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4001 | "-expect-next-proto", "bar", |
| 4002 | }, |
| 4003 | resumeSession: true, |
| 4004 | expectChannelID: true, |
| 4005 | expectedNextProto: "bar", |
| 4006 | expectedNextProtoType: npn, |
| 4007 | }) |
| 4008 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4009 | // Bidirectional shutdown with the runner initiating. |
| 4010 | tests = append(tests, testCase{ |
| 4011 | name: "Shutdown-Runner", |
| 4012 | config: Config{ |
| 4013 | Bugs: ProtocolBugs{ |
| 4014 | ExpectCloseNotify: true, |
| 4015 | }, |
| 4016 | }, |
| 4017 | flags: []string{"-check-close-notify"}, |
| 4018 | }) |
| 4019 | |
| 4020 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4021 | // in the meantime, sends garbage before the close_notify which |
| 4022 | // the shim must ignore. |
| 4023 | tests = append(tests, testCase{ |
| 4024 | name: "Shutdown-Shim", |
| 4025 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4026 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4027 | Bugs: ProtocolBugs{ |
| 4028 | ExpectCloseNotify: true, |
| 4029 | }, |
| 4030 | }, |
| 4031 | shimShutsDown: true, |
| 4032 | sendEmptyRecords: 1, |
| 4033 | sendWarningAlerts: 1, |
| 4034 | flags: []string{"-check-close-notify"}, |
| 4035 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4036 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4037 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4038 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4039 | tests = append(tests, testCase{ |
| 4040 | name: "SkipHelloVerifyRequest", |
| 4041 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4042 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4043 | Bugs: ProtocolBugs{ |
| 4044 | SkipHelloVerifyRequest: true, |
| 4045 | }, |
| 4046 | }, |
| 4047 | }) |
| 4048 | } |
| 4049 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4050 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4051 | test.protocol = config.protocol |
| 4052 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4053 | test.name += "-DTLS" |
| 4054 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4055 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4056 | test.name += "-Async" |
| 4057 | test.flags = append(test.flags, "-async") |
| 4058 | } else { |
| 4059 | test.name += "-Sync" |
| 4060 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4061 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4062 | test.name += "-SplitHandshakeRecords" |
| 4063 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4064 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4065 | test.config.Bugs.MaxPacketLength = 256 |
| 4066 | test.flags = append(test.flags, "-mtu", "256") |
| 4067 | } |
| 4068 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4069 | if config.packHandshakeFlight { |
| 4070 | test.name += "-PackHandshakeFlight" |
| 4071 | test.config.Bugs.PackHandshakeFlight = true |
| 4072 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4073 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4074 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4075 | } |
| 4076 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4077 | func addDDoSCallbackTests() { |
| 4078 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4079 | for _, resume := range []bool{false, true} { |
| 4080 | suffix := "Resume" |
| 4081 | if resume { |
| 4082 | suffix = "No" + suffix |
| 4083 | } |
| 4084 | |
| 4085 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4086 | testType: serverTest, |
| 4087 | name: "Server-DDoS-OK-" + suffix, |
| 4088 | config: Config{ |
| 4089 | MaxVersion: VersionTLS12, |
| 4090 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4091 | flags: []string{"-install-ddos-callback"}, |
| 4092 | resumeSession: resume, |
| 4093 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4094 | testCases = append(testCases, testCase{ |
| 4095 | testType: serverTest, |
| 4096 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4097 | config: Config{ |
| 4098 | MaxVersion: VersionTLS13, |
| 4099 | }, |
| 4100 | flags: []string{"-install-ddos-callback"}, |
| 4101 | resumeSession: resume, |
| 4102 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4103 | |
| 4104 | failFlag := "-fail-ddos-callback" |
| 4105 | if resume { |
| 4106 | failFlag = "-fail-second-ddos-callback" |
| 4107 | } |
| 4108 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4109 | testType: serverTest, |
| 4110 | name: "Server-DDoS-Reject-" + suffix, |
| 4111 | config: Config{ |
| 4112 | MaxVersion: VersionTLS12, |
| 4113 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4114 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4115 | resumeSession: resume, |
| 4116 | shouldFail: true, |
| 4117 | expectedError: ":CONNECTION_REJECTED:", |
| 4118 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4119 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4120 | testCases = append(testCases, testCase{ |
| 4121 | testType: serverTest, |
| 4122 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4123 | config: Config{ |
| 4124 | MaxVersion: VersionTLS13, |
| 4125 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4126 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4127 | resumeSession: resume, |
| 4128 | shouldFail: true, |
| 4129 | expectedError: ":CONNECTION_REJECTED:", |
| 4130 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4131 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4132 | } |
| 4133 | } |
| 4134 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4135 | func addVersionNegotiationTests() { |
| 4136 | for i, shimVers := range tlsVersions { |
| 4137 | // Assemble flags to disable all newer versions on the shim. |
| 4138 | var flags []string |
| 4139 | for _, vers := range tlsVersions[i+1:] { |
| 4140 | flags = append(flags, vers.flag) |
| 4141 | } |
| 4142 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4143 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4144 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4145 | protocols := []protocol{tls} |
| 4146 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4147 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4148 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4149 | for _, protocol := range protocols { |
| 4150 | expectedVersion := shimVers.version |
| 4151 | if runnerVers.version < shimVers.version { |
| 4152 | expectedVersion = runnerVers.version |
| 4153 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4154 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4155 | suffix := shimVers.name + "-" + runnerVers.name |
| 4156 | if protocol == dtls { |
| 4157 | suffix += "-DTLS" |
| 4158 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4159 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4160 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4161 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4162 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4163 | clientVers := shimVers.version |
| 4164 | if clientVers > VersionTLS10 { |
| 4165 | clientVers = VersionTLS10 |
| 4166 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4167 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4168 | serverVers := expectedVersion |
| 4169 | if expectedVersion >= VersionTLS13 { |
| 4170 | serverVers = VersionTLS10 |
| 4171 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4172 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4173 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4174 | testCases = append(testCases, testCase{ |
| 4175 | protocol: protocol, |
| 4176 | testType: clientTest, |
| 4177 | name: "VersionNegotiation-Client-" + suffix, |
| 4178 | config: Config{ |
| 4179 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4180 | Bugs: ProtocolBugs{ |
| 4181 | ExpectInitialRecordVersion: clientVers, |
| 4182 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4183 | }, |
| 4184 | flags: flags, |
| 4185 | expectedVersion: expectedVersion, |
| 4186 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4187 | testCases = append(testCases, testCase{ |
| 4188 | protocol: protocol, |
| 4189 | testType: clientTest, |
| 4190 | name: "VersionNegotiation-Client2-" + suffix, |
| 4191 | config: Config{ |
| 4192 | MaxVersion: runnerVers.version, |
| 4193 | Bugs: ProtocolBugs{ |
| 4194 | ExpectInitialRecordVersion: clientVers, |
| 4195 | }, |
| 4196 | }, |
| 4197 | flags: []string{"-max-version", shimVersFlag}, |
| 4198 | expectedVersion: expectedVersion, |
| 4199 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4200 | |
| 4201 | testCases = append(testCases, testCase{ |
| 4202 | protocol: protocol, |
| 4203 | testType: serverTest, |
| 4204 | name: "VersionNegotiation-Server-" + suffix, |
| 4205 | config: Config{ |
| 4206 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4207 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4208 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4209 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4210 | }, |
| 4211 | flags: flags, |
| 4212 | expectedVersion: expectedVersion, |
| 4213 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4214 | testCases = append(testCases, testCase{ |
| 4215 | protocol: protocol, |
| 4216 | testType: serverTest, |
| 4217 | name: "VersionNegotiation-Server2-" + suffix, |
| 4218 | config: Config{ |
| 4219 | MaxVersion: runnerVers.version, |
| 4220 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4221 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4222 | }, |
| 4223 | }, |
| 4224 | flags: []string{"-max-version", shimVersFlag}, |
| 4225 | expectedVersion: expectedVersion, |
| 4226 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4227 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4228 | } |
| 4229 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4230 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4231 | // Test the version extension at all versions. |
| 4232 | for _, vers := range tlsVersions { |
| 4233 | protocols := []protocol{tls} |
| 4234 | if vers.hasDTLS { |
| 4235 | protocols = append(protocols, dtls) |
| 4236 | } |
| 4237 | for _, protocol := range protocols { |
| 4238 | suffix := vers.name |
| 4239 | if protocol == dtls { |
| 4240 | suffix += "-DTLS" |
| 4241 | } |
| 4242 | |
| 4243 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4244 | testCases = append(testCases, testCase{ |
| 4245 | protocol: protocol, |
| 4246 | testType: serverTest, |
| 4247 | name: "VersionNegotiationExtension-" + suffix, |
| 4248 | config: Config{ |
| 4249 | Bugs: ProtocolBugs{ |
| 4250 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4251 | }, |
| 4252 | }, |
| 4253 | expectedVersion: vers.version, |
| 4254 | }) |
| 4255 | } |
| 4256 | |
| 4257 | } |
| 4258 | |
| 4259 | // If all versions are unknown, negotiation fails. |
| 4260 | testCases = append(testCases, testCase{ |
| 4261 | testType: serverTest, |
| 4262 | name: "NoSupportedVersions", |
| 4263 | config: Config{ |
| 4264 | Bugs: ProtocolBugs{ |
| 4265 | SendSupportedVersions: []uint16{0x1111}, |
| 4266 | }, |
| 4267 | }, |
| 4268 | shouldFail: true, |
| 4269 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4270 | }) |
| 4271 | testCases = append(testCases, testCase{ |
| 4272 | protocol: dtls, |
| 4273 | testType: serverTest, |
| 4274 | name: "NoSupportedVersions-DTLS", |
| 4275 | config: Config{ |
| 4276 | Bugs: ProtocolBugs{ |
| 4277 | SendSupportedVersions: []uint16{0x1111}, |
| 4278 | }, |
| 4279 | }, |
| 4280 | shouldFail: true, |
| 4281 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4282 | }) |
| 4283 | |
| 4284 | testCases = append(testCases, testCase{ |
| 4285 | testType: serverTest, |
| 4286 | name: "ClientHelloVersionTooHigh", |
| 4287 | config: Config{ |
| 4288 | MaxVersion: VersionTLS13, |
| 4289 | Bugs: ProtocolBugs{ |
| 4290 | SendClientVersion: 0x0304, |
| 4291 | OmitSupportedVersions: true, |
| 4292 | }, |
| 4293 | }, |
| 4294 | expectedVersion: VersionTLS12, |
| 4295 | }) |
| 4296 | |
| 4297 | testCases = append(testCases, testCase{ |
| 4298 | testType: serverTest, |
| 4299 | name: "ConflictingVersionNegotiation", |
| 4300 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4301 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4302 | SendClientVersion: VersionTLS12, |
| 4303 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4304 | }, |
| 4305 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4306 | // The extension takes precedence over the ClientHello version. |
| 4307 | expectedVersion: VersionTLS11, |
| 4308 | }) |
| 4309 | |
| 4310 | testCases = append(testCases, testCase{ |
| 4311 | testType: serverTest, |
| 4312 | name: "ConflictingVersionNegotiation-2", |
| 4313 | config: Config{ |
| 4314 | Bugs: ProtocolBugs{ |
| 4315 | SendClientVersion: VersionTLS11, |
| 4316 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4317 | }, |
| 4318 | }, |
| 4319 | // The extension takes precedence over the ClientHello version. |
| 4320 | expectedVersion: VersionTLS12, |
| 4321 | }) |
| 4322 | |
| 4323 | testCases = append(testCases, testCase{ |
| 4324 | testType: serverTest, |
| 4325 | name: "RejectFinalTLS13", |
| 4326 | config: Config{ |
| 4327 | Bugs: ProtocolBugs{ |
| 4328 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4329 | }, |
| 4330 | }, |
| 4331 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4332 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4333 | expectedVersion: VersionTLS12, |
| 4334 | }) |
| 4335 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4336 | // Test for version tolerance. |
| 4337 | testCases = append(testCases, testCase{ |
| 4338 | testType: serverTest, |
| 4339 | name: "MinorVersionTolerance", |
| 4340 | config: Config{ |
| 4341 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4342 | SendClientVersion: 0x03ff, |
| 4343 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4344 | }, |
| 4345 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4346 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4347 | }) |
| 4348 | testCases = append(testCases, testCase{ |
| 4349 | testType: serverTest, |
| 4350 | name: "MajorVersionTolerance", |
| 4351 | config: Config{ |
| 4352 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4353 | SendClientVersion: 0x0400, |
| 4354 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4355 | }, |
| 4356 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4357 | // TLS 1.3 must be negotiated with the supported_versions |
| 4358 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4359 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4360 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4361 | testCases = append(testCases, testCase{ |
| 4362 | testType: serverTest, |
| 4363 | name: "VersionTolerance-TLS13", |
| 4364 | config: Config{ |
| 4365 | Bugs: ProtocolBugs{ |
| 4366 | // Although TLS 1.3 does not use |
| 4367 | // ClientHello.version, it still tolerates high |
| 4368 | // values there. |
| 4369 | SendClientVersion: 0x0400, |
| 4370 | }, |
| 4371 | }, |
| 4372 | expectedVersion: VersionTLS13, |
| 4373 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4374 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4375 | testCases = append(testCases, testCase{ |
| 4376 | protocol: dtls, |
| 4377 | testType: serverTest, |
| 4378 | name: "MinorVersionTolerance-DTLS", |
| 4379 | config: Config{ |
| 4380 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4381 | SendClientVersion: 0xfe00, |
| 4382 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4383 | }, |
| 4384 | }, |
| 4385 | expectedVersion: VersionTLS12, |
| 4386 | }) |
| 4387 | testCases = append(testCases, testCase{ |
| 4388 | protocol: dtls, |
| 4389 | testType: serverTest, |
| 4390 | name: "MajorVersionTolerance-DTLS", |
| 4391 | config: Config{ |
| 4392 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4393 | SendClientVersion: 0xfdff, |
| 4394 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4395 | }, |
| 4396 | }, |
| 4397 | expectedVersion: VersionTLS12, |
| 4398 | }) |
| 4399 | |
| 4400 | // Test that versions below 3.0 are rejected. |
| 4401 | testCases = append(testCases, testCase{ |
| 4402 | testType: serverTest, |
| 4403 | name: "VersionTooLow", |
| 4404 | config: Config{ |
| 4405 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4406 | SendClientVersion: 0x0200, |
| 4407 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4408 | }, |
| 4409 | }, |
| 4410 | shouldFail: true, |
| 4411 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4412 | }) |
| 4413 | testCases = append(testCases, testCase{ |
| 4414 | protocol: dtls, |
| 4415 | testType: serverTest, |
| 4416 | name: "VersionTooLow-DTLS", |
| 4417 | config: Config{ |
| 4418 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4419 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4420 | }, |
| 4421 | }, |
| 4422 | shouldFail: true, |
| 4423 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4424 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4425 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4426 | testCases = append(testCases, testCase{ |
| 4427 | name: "ServerBogusVersion", |
| 4428 | config: Config{ |
| 4429 | Bugs: ProtocolBugs{ |
| 4430 | SendServerHelloVersion: 0x1234, |
| 4431 | }, |
| 4432 | }, |
| 4433 | shouldFail: true, |
| 4434 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4435 | }) |
| 4436 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4437 | // Test TLS 1.3's downgrade signal. |
| 4438 | testCases = append(testCases, testCase{ |
| 4439 | name: "Downgrade-TLS12-Client", |
| 4440 | config: Config{ |
| 4441 | Bugs: ProtocolBugs{ |
| 4442 | NegotiateVersion: VersionTLS12, |
| 4443 | }, |
| 4444 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4445 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4446 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4447 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4448 | }) |
| 4449 | testCases = append(testCases, testCase{ |
| 4450 | testType: serverTest, |
| 4451 | name: "Downgrade-TLS12-Server", |
| 4452 | config: Config{ |
| 4453 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4454 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4455 | }, |
| 4456 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4457 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4458 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4459 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4460 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4461 | } |
| 4462 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4463 | func addMinimumVersionTests() { |
| 4464 | for i, shimVers := range tlsVersions { |
| 4465 | // Assemble flags to disable all older versions on the shim. |
| 4466 | var flags []string |
| 4467 | for _, vers := range tlsVersions[:i] { |
| 4468 | flags = append(flags, vers.flag) |
| 4469 | } |
| 4470 | |
| 4471 | for _, runnerVers := range tlsVersions { |
| 4472 | protocols := []protocol{tls} |
| 4473 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4474 | protocols = append(protocols, dtls) |
| 4475 | } |
| 4476 | for _, protocol := range protocols { |
| 4477 | suffix := shimVers.name + "-" + runnerVers.name |
| 4478 | if protocol == dtls { |
| 4479 | suffix += "-DTLS" |
| 4480 | } |
| 4481 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4482 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4483 | var expectedVersion uint16 |
| 4484 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4485 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4486 | if runnerVers.version >= shimVers.version { |
| 4487 | expectedVersion = runnerVers.version |
| 4488 | } else { |
| 4489 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4490 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4491 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4492 | } |
| 4493 | |
| 4494 | testCases = append(testCases, testCase{ |
| 4495 | protocol: protocol, |
| 4496 | testType: clientTest, |
| 4497 | name: "MinimumVersion-Client-" + suffix, |
| 4498 | config: Config{ |
| 4499 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4500 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4501 | // Ensure the server does not decline to |
| 4502 | // select a version (versions extension) or |
| 4503 | // cipher (some ciphers depend on versions). |
| 4504 | NegotiateVersion: runnerVers.version, |
| 4505 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4506 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4507 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4508 | flags: flags, |
| 4509 | expectedVersion: expectedVersion, |
| 4510 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4511 | expectedError: expectedError, |
| 4512 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4513 | }) |
| 4514 | testCases = append(testCases, testCase{ |
| 4515 | protocol: protocol, |
| 4516 | testType: clientTest, |
| 4517 | name: "MinimumVersion-Client2-" + suffix, |
| 4518 | config: Config{ |
| 4519 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4520 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4521 | // Ensure the server does not decline to |
| 4522 | // select a version (versions extension) or |
| 4523 | // cipher (some ciphers depend on versions). |
| 4524 | NegotiateVersion: runnerVers.version, |
| 4525 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4526 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4527 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4528 | flags: []string{"-min-version", shimVersFlag}, |
| 4529 | expectedVersion: expectedVersion, |
| 4530 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4531 | expectedError: expectedError, |
| 4532 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4533 | }) |
| 4534 | |
| 4535 | testCases = append(testCases, testCase{ |
| 4536 | protocol: protocol, |
| 4537 | testType: serverTest, |
| 4538 | name: "MinimumVersion-Server-" + suffix, |
| 4539 | config: Config{ |
| 4540 | MaxVersion: runnerVers.version, |
| 4541 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4542 | flags: flags, |
| 4543 | expectedVersion: expectedVersion, |
| 4544 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4545 | expectedError: expectedError, |
| 4546 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4547 | }) |
| 4548 | testCases = append(testCases, testCase{ |
| 4549 | protocol: protocol, |
| 4550 | testType: serverTest, |
| 4551 | name: "MinimumVersion-Server2-" + suffix, |
| 4552 | config: Config{ |
| 4553 | MaxVersion: runnerVers.version, |
| 4554 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4555 | flags: []string{"-min-version", shimVersFlag}, |
| 4556 | expectedVersion: expectedVersion, |
| 4557 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4558 | expectedError: expectedError, |
| 4559 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4560 | }) |
| 4561 | } |
| 4562 | } |
| 4563 | } |
| 4564 | } |
| 4565 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4566 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4567 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4568 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4569 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4570 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4571 | // Repeat extensions tests all versions except SSL 3.0. |
| 4572 | for _, ver := range tlsVersions { |
| 4573 | if ver.version == VersionSSL30 { |
| 4574 | continue |
| 4575 | } |
| 4576 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4577 | // Test that duplicate extensions are rejected. |
| 4578 | testCases = append(testCases, testCase{ |
| 4579 | testType: clientTest, |
| 4580 | name: "DuplicateExtensionClient-" + ver.name, |
| 4581 | config: Config{ |
| 4582 | MaxVersion: ver.version, |
| 4583 | Bugs: ProtocolBugs{ |
| 4584 | DuplicateExtension: true, |
| 4585 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4586 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4587 | shouldFail: true, |
| 4588 | expectedLocalError: "remote error: error decoding message", |
| 4589 | }) |
| 4590 | testCases = append(testCases, testCase{ |
| 4591 | testType: serverTest, |
| 4592 | name: "DuplicateExtensionServer-" + ver.name, |
| 4593 | config: Config{ |
| 4594 | MaxVersion: ver.version, |
| 4595 | Bugs: ProtocolBugs{ |
| 4596 | DuplicateExtension: true, |
| 4597 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4598 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4599 | shouldFail: true, |
| 4600 | expectedLocalError: "remote error: error decoding message", |
| 4601 | }) |
| 4602 | |
| 4603 | // Test SNI. |
| 4604 | testCases = append(testCases, testCase{ |
| 4605 | testType: clientTest, |
| 4606 | name: "ServerNameExtensionClient-" + ver.name, |
| 4607 | config: Config{ |
| 4608 | MaxVersion: ver.version, |
| 4609 | Bugs: ProtocolBugs{ |
| 4610 | ExpectServerName: "example.com", |
| 4611 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4612 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4613 | flags: []string{"-host-name", "example.com"}, |
| 4614 | }) |
| 4615 | testCases = append(testCases, testCase{ |
| 4616 | testType: clientTest, |
| 4617 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4618 | config: Config{ |
| 4619 | MaxVersion: ver.version, |
| 4620 | Bugs: ProtocolBugs{ |
| 4621 | ExpectServerName: "mismatch.com", |
| 4622 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4623 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4624 | flags: []string{"-host-name", "example.com"}, |
| 4625 | shouldFail: true, |
| 4626 | expectedLocalError: "tls: unexpected server name", |
| 4627 | }) |
| 4628 | testCases = append(testCases, testCase{ |
| 4629 | testType: clientTest, |
| 4630 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4631 | config: Config{ |
| 4632 | MaxVersion: ver.version, |
| 4633 | Bugs: ProtocolBugs{ |
| 4634 | ExpectServerName: "missing.com", |
| 4635 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4636 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4637 | shouldFail: true, |
| 4638 | expectedLocalError: "tls: unexpected server name", |
| 4639 | }) |
| 4640 | testCases = append(testCases, testCase{ |
| 4641 | testType: serverTest, |
| 4642 | name: "ServerNameExtensionServer-" + ver.name, |
| 4643 | config: Config{ |
| 4644 | MaxVersion: ver.version, |
| 4645 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4646 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4647 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4648 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4649 | }) |
| 4650 | |
| 4651 | // Test ALPN. |
| 4652 | testCases = append(testCases, testCase{ |
| 4653 | testType: clientTest, |
| 4654 | name: "ALPNClient-" + ver.name, |
| 4655 | config: Config{ |
| 4656 | MaxVersion: ver.version, |
| 4657 | NextProtos: []string{"foo"}, |
| 4658 | }, |
| 4659 | flags: []string{ |
| 4660 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4661 | "-expect-alpn", "foo", |
| 4662 | }, |
| 4663 | expectedNextProto: "foo", |
| 4664 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4665 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4666 | }) |
| 4667 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4668 | testType: clientTest, |
| 4669 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4670 | config: Config{ |
| 4671 | MaxVersion: ver.version, |
| 4672 | Bugs: ProtocolBugs{ |
| 4673 | SendALPN: "baz", |
| 4674 | }, |
| 4675 | }, |
| 4676 | flags: []string{ |
| 4677 | "-advertise-alpn", "\x03foo\x03bar", |
| 4678 | }, |
| 4679 | shouldFail: true, |
| 4680 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4681 | expectedLocalError: "remote error: illegal parameter", |
| 4682 | }) |
| 4683 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4684 | testType: serverTest, |
| 4685 | name: "ALPNServer-" + ver.name, |
| 4686 | config: Config{ |
| 4687 | MaxVersion: ver.version, |
| 4688 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4689 | }, |
| 4690 | flags: []string{ |
| 4691 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4692 | "-select-alpn", "foo", |
| 4693 | }, |
| 4694 | expectedNextProto: "foo", |
| 4695 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4696 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4697 | }) |
| 4698 | testCases = append(testCases, testCase{ |
| 4699 | testType: serverTest, |
| 4700 | name: "ALPNServer-Decline-" + ver.name, |
| 4701 | config: Config{ |
| 4702 | MaxVersion: ver.version, |
| 4703 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4704 | }, |
| 4705 | flags: []string{"-decline-alpn"}, |
| 4706 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4707 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4708 | }) |
| 4709 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4710 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4711 | // called once. |
| 4712 | testCases = append(testCases, testCase{ |
| 4713 | testType: serverTest, |
| 4714 | name: "ALPNServer-Async-" + ver.name, |
| 4715 | config: Config{ |
| 4716 | MaxVersion: ver.version, |
| 4717 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4718 | }, |
| 4719 | flags: []string{ |
| 4720 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4721 | "-select-alpn", "foo", |
| 4722 | "-async", |
| 4723 | }, |
| 4724 | expectedNextProto: "foo", |
| 4725 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4726 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4727 | }) |
| 4728 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4729 | var emptyString string |
| 4730 | testCases = append(testCases, testCase{ |
| 4731 | testType: clientTest, |
| 4732 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4733 | config: Config{ |
| 4734 | MaxVersion: ver.version, |
| 4735 | NextProtos: []string{""}, |
| 4736 | Bugs: ProtocolBugs{ |
| 4737 | // A server returning an empty ALPN protocol |
| 4738 | // should be rejected. |
| 4739 | ALPNProtocol: &emptyString, |
| 4740 | }, |
| 4741 | }, |
| 4742 | flags: []string{ |
| 4743 | "-advertise-alpn", "\x03foo", |
| 4744 | }, |
| 4745 | shouldFail: true, |
| 4746 | expectedError: ":PARSE_TLSEXT:", |
| 4747 | }) |
| 4748 | testCases = append(testCases, testCase{ |
| 4749 | testType: serverTest, |
| 4750 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4751 | config: Config{ |
| 4752 | MaxVersion: ver.version, |
| 4753 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4754 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4755 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4756 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4757 | flags: []string{ |
| 4758 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4759 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4760 | shouldFail: true, |
| 4761 | expectedError: ":PARSE_TLSEXT:", |
| 4762 | }) |
| 4763 | |
| 4764 | // Test NPN and the interaction with ALPN. |
| 4765 | if ver.version < VersionTLS13 { |
| 4766 | // Test that the server prefers ALPN over NPN. |
| 4767 | testCases = append(testCases, testCase{ |
| 4768 | testType: serverTest, |
| 4769 | name: "ALPNServer-Preferred-" + ver.name, |
| 4770 | config: Config{ |
| 4771 | MaxVersion: ver.version, |
| 4772 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4773 | }, |
| 4774 | flags: []string{ |
| 4775 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4776 | "-select-alpn", "foo", |
| 4777 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4778 | }, |
| 4779 | expectedNextProto: "foo", |
| 4780 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4781 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4782 | }) |
| 4783 | testCases = append(testCases, testCase{ |
| 4784 | testType: serverTest, |
| 4785 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4786 | config: Config{ |
| 4787 | MaxVersion: ver.version, |
| 4788 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4789 | Bugs: ProtocolBugs{ |
| 4790 | SwapNPNAndALPN: true, |
| 4791 | }, |
| 4792 | }, |
| 4793 | flags: []string{ |
| 4794 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4795 | "-select-alpn", "foo", |
| 4796 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4797 | }, |
| 4798 | expectedNextProto: "foo", |
| 4799 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4800 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4801 | }) |
| 4802 | |
| 4803 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4804 | testCases = append(testCases, testCase{ |
| 4805 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4806 | config: Config{ |
| 4807 | MaxVersion: ver.version, |
| 4808 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4809 | Bugs: ProtocolBugs{ |
| 4810 | NegotiateALPNAndNPN: true, |
| 4811 | }, |
| 4812 | }, |
| 4813 | flags: []string{ |
| 4814 | "-advertise-alpn", "\x03foo", |
| 4815 | "-select-next-proto", "foo", |
| 4816 | }, |
| 4817 | shouldFail: true, |
| 4818 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4819 | }) |
| 4820 | testCases = append(testCases, testCase{ |
| 4821 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4822 | config: Config{ |
| 4823 | MaxVersion: ver.version, |
| 4824 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4825 | Bugs: ProtocolBugs{ |
| 4826 | NegotiateALPNAndNPN: true, |
| 4827 | SwapNPNAndALPN: true, |
| 4828 | }, |
| 4829 | }, |
| 4830 | flags: []string{ |
| 4831 | "-advertise-alpn", "\x03foo", |
| 4832 | "-select-next-proto", "foo", |
| 4833 | }, |
| 4834 | shouldFail: true, |
| 4835 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4836 | }) |
| 4837 | |
| 4838 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4839 | testCases = append(testCases, testCase{ |
| 4840 | name: "DisableNPN-" + ver.name, |
| 4841 | config: Config{ |
| 4842 | MaxVersion: ver.version, |
| 4843 | NextProtos: []string{"foo"}, |
| 4844 | }, |
| 4845 | flags: []string{ |
| 4846 | "-select-next-proto", "foo", |
| 4847 | "-disable-npn", |
| 4848 | }, |
| 4849 | expectNoNextProto: true, |
| 4850 | }) |
| 4851 | } |
| 4852 | |
| 4853 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4854 | |
| 4855 | // Resume with a corrupt ticket. |
| 4856 | testCases = append(testCases, testCase{ |
| 4857 | testType: serverTest, |
| 4858 | name: "CorruptTicket-" + ver.name, |
| 4859 | config: Config{ |
| 4860 | MaxVersion: ver.version, |
| 4861 | Bugs: ProtocolBugs{ |
| 4862 | CorruptTicket: true, |
| 4863 | }, |
| 4864 | }, |
| 4865 | resumeSession: true, |
| 4866 | expectResumeRejected: true, |
| 4867 | }) |
| 4868 | // Test the ticket callback, with and without renewal. |
| 4869 | testCases = append(testCases, testCase{ |
| 4870 | testType: serverTest, |
| 4871 | name: "TicketCallback-" + ver.name, |
| 4872 | config: Config{ |
| 4873 | MaxVersion: ver.version, |
| 4874 | }, |
| 4875 | resumeSession: true, |
| 4876 | flags: []string{"-use-ticket-callback"}, |
| 4877 | }) |
| 4878 | testCases = append(testCases, testCase{ |
| 4879 | testType: serverTest, |
| 4880 | name: "TicketCallback-Renew-" + ver.name, |
| 4881 | config: Config{ |
| 4882 | MaxVersion: ver.version, |
| 4883 | Bugs: ProtocolBugs{ |
| 4884 | ExpectNewTicket: true, |
| 4885 | }, |
| 4886 | }, |
| 4887 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 4888 | resumeSession: true, |
| 4889 | }) |
| 4890 | |
| 4891 | // Test that the ticket callback is only called once when everything before |
| 4892 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 4893 | // certificate selection callbacks run. |
| 4894 | testCases = append(testCases, testCase{ |
| 4895 | testType: serverTest, |
| 4896 | name: "TicketCallback-SingleCall-" + ver.name, |
| 4897 | config: Config{ |
| 4898 | MaxVersion: ver.version, |
| 4899 | Bugs: ProtocolBugs{ |
| 4900 | CorruptTicket: true, |
| 4901 | }, |
| 4902 | }, |
| 4903 | resumeSession: true, |
| 4904 | expectResumeRejected: true, |
| 4905 | flags: []string{ |
| 4906 | "-use-ticket-callback", |
| 4907 | "-async", |
| 4908 | }, |
| 4909 | }) |
| 4910 | |
| 4911 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4912 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4913 | testCases = append(testCases, testCase{ |
| 4914 | testType: serverTest, |
| 4915 | name: "OversizedSessionId-" + ver.name, |
| 4916 | config: Config{ |
| 4917 | MaxVersion: ver.version, |
| 4918 | Bugs: ProtocolBugs{ |
| 4919 | OversizedSessionId: true, |
| 4920 | }, |
| 4921 | }, |
| 4922 | resumeSession: true, |
| 4923 | shouldFail: true, |
| 4924 | expectedError: ":DECODE_ERROR:", |
| 4925 | }) |
| 4926 | } |
| 4927 | |
| 4928 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 4929 | // are ignored. |
| 4930 | if ver.hasDTLS { |
| 4931 | testCases = append(testCases, testCase{ |
| 4932 | protocol: dtls, |
| 4933 | name: "SRTP-Client-" + ver.name, |
| 4934 | config: Config{ |
| 4935 | MaxVersion: ver.version, |
| 4936 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4937 | }, |
| 4938 | flags: []string{ |
| 4939 | "-srtp-profiles", |
| 4940 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4941 | }, |
| 4942 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4943 | }) |
| 4944 | testCases = append(testCases, testCase{ |
| 4945 | protocol: dtls, |
| 4946 | testType: serverTest, |
| 4947 | name: "SRTP-Server-" + ver.name, |
| 4948 | config: Config{ |
| 4949 | MaxVersion: ver.version, |
| 4950 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4951 | }, |
| 4952 | flags: []string{ |
| 4953 | "-srtp-profiles", |
| 4954 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4955 | }, |
| 4956 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4957 | }) |
| 4958 | // Test that the MKI is ignored. |
| 4959 | testCases = append(testCases, testCase{ |
| 4960 | protocol: dtls, |
| 4961 | testType: serverTest, |
| 4962 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 4963 | config: Config{ |
| 4964 | MaxVersion: ver.version, |
| 4965 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 4966 | Bugs: ProtocolBugs{ |
| 4967 | SRTPMasterKeyIdentifer: "bogus", |
| 4968 | }, |
| 4969 | }, |
| 4970 | flags: []string{ |
| 4971 | "-srtp-profiles", |
| 4972 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4973 | }, |
| 4974 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4975 | }) |
| 4976 | // Test that SRTP isn't negotiated on the server if there were |
| 4977 | // no matching profiles. |
| 4978 | testCases = append(testCases, testCase{ |
| 4979 | protocol: dtls, |
| 4980 | testType: serverTest, |
| 4981 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 4982 | config: Config{ |
| 4983 | MaxVersion: ver.version, |
| 4984 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 4985 | }, |
| 4986 | flags: []string{ |
| 4987 | "-srtp-profiles", |
| 4988 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4989 | }, |
| 4990 | expectedSRTPProtectionProfile: 0, |
| 4991 | }) |
| 4992 | // Test that the server returning an invalid SRTP profile is |
| 4993 | // flagged as an error by the client. |
| 4994 | testCases = append(testCases, testCase{ |
| 4995 | protocol: dtls, |
| 4996 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 4997 | config: Config{ |
| 4998 | MaxVersion: ver.version, |
| 4999 | Bugs: ProtocolBugs{ |
| 5000 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5001 | }, |
| 5002 | }, |
| 5003 | flags: []string{ |
| 5004 | "-srtp-profiles", |
| 5005 | "SRTP_AES128_CM_SHA1_80", |
| 5006 | }, |
| 5007 | shouldFail: true, |
| 5008 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5009 | }) |
| 5010 | } |
| 5011 | |
| 5012 | // Test SCT list. |
| 5013 | testCases = append(testCases, testCase{ |
| 5014 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5015 | testType: clientTest, |
| 5016 | config: Config{ |
| 5017 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5018 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5019 | flags: []string{ |
| 5020 | "-enable-signed-cert-timestamps", |
| 5021 | "-expect-signed-cert-timestamps", |
| 5022 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5023 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5024 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5025 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5026 | |
| 5027 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5028 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5029 | testCases = append(testCases, testCase{ |
| 5030 | name: "SendSCTListOnResume-" + ver.name, |
| 5031 | config: Config{ |
| 5032 | MaxVersion: ver.version, |
| 5033 | Bugs: ProtocolBugs{ |
| 5034 | SendSCTListOnResume: []byte("bogus"), |
| 5035 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5036 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5037 | flags: []string{ |
| 5038 | "-enable-signed-cert-timestamps", |
| 5039 | "-expect-signed-cert-timestamps", |
| 5040 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5041 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5042 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5043 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5044 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5045 | testCases = append(testCases, testCase{ |
| 5046 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5047 | testType: serverTest, |
| 5048 | config: Config{ |
| 5049 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5050 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5051 | flags: []string{ |
| 5052 | "-signed-cert-timestamps", |
| 5053 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5054 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5055 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5056 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5057 | }) |
| 5058 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5059 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5060 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5061 | testType: clientTest, |
| 5062 | name: "ClientHelloPadding", |
| 5063 | config: Config{ |
| 5064 | Bugs: ProtocolBugs{ |
| 5065 | RequireClientHelloSize: 512, |
| 5066 | }, |
| 5067 | }, |
| 5068 | // This hostname just needs to be long enough to push the |
| 5069 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5070 | // long. |
| 5071 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5072 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5073 | |
| 5074 | // Extensions should not function in SSL 3.0. |
| 5075 | testCases = append(testCases, testCase{ |
| 5076 | testType: serverTest, |
| 5077 | name: "SSLv3Extensions-NoALPN", |
| 5078 | config: Config{ |
| 5079 | MaxVersion: VersionSSL30, |
| 5080 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5081 | }, |
| 5082 | flags: []string{ |
| 5083 | "-select-alpn", "foo", |
| 5084 | }, |
| 5085 | expectNoNextProto: true, |
| 5086 | }) |
| 5087 | |
| 5088 | // Test session tickets separately as they follow a different codepath. |
| 5089 | testCases = append(testCases, testCase{ |
| 5090 | testType: serverTest, |
| 5091 | name: "SSLv3Extensions-NoTickets", |
| 5092 | config: Config{ |
| 5093 | MaxVersion: VersionSSL30, |
| 5094 | Bugs: ProtocolBugs{ |
| 5095 | // Historically, session tickets in SSL 3.0 |
| 5096 | // failed in different ways depending on whether |
| 5097 | // the client supported renegotiation_info. |
| 5098 | NoRenegotiationInfo: true, |
| 5099 | }, |
| 5100 | }, |
| 5101 | resumeSession: true, |
| 5102 | }) |
| 5103 | testCases = append(testCases, testCase{ |
| 5104 | testType: serverTest, |
| 5105 | name: "SSLv3Extensions-NoTickets2", |
| 5106 | config: Config{ |
| 5107 | MaxVersion: VersionSSL30, |
| 5108 | }, |
| 5109 | resumeSession: true, |
| 5110 | }) |
| 5111 | |
| 5112 | // But SSL 3.0 does send and process renegotiation_info. |
| 5113 | testCases = append(testCases, testCase{ |
| 5114 | testType: serverTest, |
| 5115 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5116 | config: Config{ |
| 5117 | MaxVersion: VersionSSL30, |
| 5118 | Bugs: ProtocolBugs{ |
| 5119 | RequireRenegotiationInfo: true, |
| 5120 | }, |
| 5121 | }, |
| 5122 | }) |
| 5123 | testCases = append(testCases, testCase{ |
| 5124 | testType: serverTest, |
| 5125 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5126 | config: Config{ |
| 5127 | MaxVersion: VersionSSL30, |
| 5128 | Bugs: ProtocolBugs{ |
| 5129 | NoRenegotiationInfo: true, |
| 5130 | SendRenegotiationSCSV: true, |
| 5131 | RequireRenegotiationInfo: true, |
| 5132 | }, |
| 5133 | }, |
| 5134 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5135 | |
| 5136 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5137 | // in ServerHello. |
| 5138 | testCases = append(testCases, testCase{ |
| 5139 | name: "NPN-Forbidden-TLS13", |
| 5140 | config: Config{ |
| 5141 | MaxVersion: VersionTLS13, |
| 5142 | NextProtos: []string{"foo"}, |
| 5143 | Bugs: ProtocolBugs{ |
| 5144 | NegotiateNPNAtAllVersions: true, |
| 5145 | }, |
| 5146 | }, |
| 5147 | flags: []string{"-select-next-proto", "foo"}, |
| 5148 | shouldFail: true, |
| 5149 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5150 | }) |
| 5151 | testCases = append(testCases, testCase{ |
| 5152 | name: "EMS-Forbidden-TLS13", |
| 5153 | config: Config{ |
| 5154 | MaxVersion: VersionTLS13, |
| 5155 | Bugs: ProtocolBugs{ |
| 5156 | NegotiateEMSAtAllVersions: true, |
| 5157 | }, |
| 5158 | }, |
| 5159 | shouldFail: true, |
| 5160 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5161 | }) |
| 5162 | testCases = append(testCases, testCase{ |
| 5163 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5164 | config: Config{ |
| 5165 | MaxVersion: VersionTLS13, |
| 5166 | Bugs: ProtocolBugs{ |
| 5167 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5168 | }, |
| 5169 | }, |
| 5170 | shouldFail: true, |
| 5171 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5172 | }) |
| 5173 | testCases = append(testCases, testCase{ |
| 5174 | name: "ChannelID-Forbidden-TLS13", |
| 5175 | config: Config{ |
| 5176 | MaxVersion: VersionTLS13, |
| 5177 | RequestChannelID: true, |
| 5178 | Bugs: ProtocolBugs{ |
| 5179 | NegotiateChannelIDAtAllVersions: true, |
| 5180 | }, |
| 5181 | }, |
| 5182 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 5183 | shouldFail: true, |
| 5184 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5185 | }) |
| 5186 | testCases = append(testCases, testCase{ |
| 5187 | name: "Ticket-Forbidden-TLS13", |
| 5188 | config: Config{ |
| 5189 | MaxVersion: VersionTLS12, |
| 5190 | }, |
| 5191 | resumeConfig: &Config{ |
| 5192 | MaxVersion: VersionTLS13, |
| 5193 | Bugs: ProtocolBugs{ |
| 5194 | AdvertiseTicketExtension: true, |
| 5195 | }, |
| 5196 | }, |
| 5197 | resumeSession: true, |
| 5198 | shouldFail: true, |
| 5199 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5200 | }) |
| 5201 | |
| 5202 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5203 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5204 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5205 | // implicit in every test.) |
| 5206 | testCases = append(testCases, testCase{ |
| 5207 | testType: serverTest, |
| 5208 | name: "ChannelID-Declined-TLS13", |
| 5209 | config: Config{ |
| 5210 | MaxVersion: VersionTLS13, |
| 5211 | ChannelID: channelIDKey, |
| 5212 | }, |
| 5213 | flags: []string{"-enable-channel-id"}, |
| 5214 | }) |
| 5215 | testCases = append(testCases, testCase{ |
| 5216 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5217 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5218 | config: Config{ |
| 5219 | MaxVersion: VersionTLS13, |
| 5220 | NextProtos: []string{"bar"}, |
| 5221 | }, |
| 5222 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5223 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5224 | |
| 5225 | testCases = append(testCases, testCase{ |
| 5226 | testType: serverTest, |
| 5227 | name: "InvalidChannelIDSignature", |
| 5228 | config: Config{ |
| 5229 | MaxVersion: VersionTLS12, |
| 5230 | ChannelID: channelIDKey, |
| 5231 | Bugs: ProtocolBugs{ |
| 5232 | InvalidChannelIDSignature: true, |
| 5233 | }, |
| 5234 | }, |
| 5235 | flags: []string{"-enable-channel-id"}, |
| 5236 | shouldFail: true, |
| 5237 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 5238 | expectedLocalError: "remote error: error decrypting message", |
| 5239 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5240 | |
| 5241 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5242 | // tolerated. |
| 5243 | testCases = append(testCases, testCase{ |
| 5244 | name: "SendOCSPResponseOnResume-TLS12", |
| 5245 | config: Config{ |
| 5246 | MaxVersion: VersionTLS12, |
| 5247 | Bugs: ProtocolBugs{ |
| 5248 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5249 | }, |
| 5250 | }, |
| 5251 | flags: []string{ |
| 5252 | "-enable-ocsp-stapling", |
| 5253 | "-expect-ocsp-response", |
| 5254 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5255 | }, |
| 5256 | resumeSession: true, |
| 5257 | }) |
| 5258 | |
| 5259 | // Beginning TLS 1.3, enforce this does not happen. |
| 5260 | testCases = append(testCases, testCase{ |
| 5261 | name: "SendOCSPResponseOnResume-TLS13", |
| 5262 | config: Config{ |
| 5263 | MaxVersion: VersionTLS13, |
| 5264 | Bugs: ProtocolBugs{ |
| 5265 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5266 | }, |
| 5267 | }, |
| 5268 | flags: []string{ |
| 5269 | "-enable-ocsp-stapling", |
| 5270 | "-expect-ocsp-response", |
| 5271 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5272 | }, |
| 5273 | resumeSession: true, |
| 5274 | shouldFail: true, |
| 5275 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5276 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5277 | } |
| 5278 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5279 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5280 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5281 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5282 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5283 | // have session IDs, so skip their cross-resumption |
| 5284 | // tests. |
| 5285 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5286 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5287 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5288 | } |
| 5289 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5290 | protocols := []protocol{tls} |
| 5291 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5292 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5293 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5294 | for _, protocol := range protocols { |
| 5295 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5296 | if protocol == dtls { |
| 5297 | suffix += "-DTLS" |
| 5298 | } |
| 5299 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5300 | if sessionVers.version == resumeVers.version { |
| 5301 | testCases = append(testCases, testCase{ |
| 5302 | protocol: protocol, |
| 5303 | name: "Resume-Client" + suffix, |
| 5304 | resumeSession: true, |
| 5305 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5306 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5307 | Bugs: ProtocolBugs{ |
| 5308 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5309 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5310 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5311 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5312 | expectedVersion: sessionVers.version, |
| 5313 | expectedResumeVersion: resumeVers.version, |
| 5314 | }) |
| 5315 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5316 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5317 | |
| 5318 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5319 | // there is no way to convince a non-lookahead client the |
| 5320 | // session was resumed. It will appear to the client that a |
| 5321 | // stray ChangeCipherSpec was sent. |
| 5322 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5323 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5324 | } |
| 5325 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5326 | testCases = append(testCases, testCase{ |
| 5327 | protocol: protocol, |
| 5328 | name: "Resume-Client-Mismatch" + suffix, |
| 5329 | resumeSession: true, |
| 5330 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5331 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5332 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5333 | expectedVersion: sessionVers.version, |
| 5334 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5335 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5336 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5337 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5338 | }, |
| 5339 | }, |
| 5340 | expectedResumeVersion: resumeVers.version, |
| 5341 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5342 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5343 | }) |
| 5344 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5345 | |
| 5346 | testCases = append(testCases, testCase{ |
| 5347 | protocol: protocol, |
| 5348 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5349 | resumeSession: true, |
| 5350 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5351 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5352 | }, |
| 5353 | expectedVersion: sessionVers.version, |
| 5354 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5355 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5356 | }, |
| 5357 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5358 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5359 | expectedResumeVersion: resumeVers.version, |
| 5360 | }) |
| 5361 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5362 | testCases = append(testCases, testCase{ |
| 5363 | protocol: protocol, |
| 5364 | testType: serverTest, |
| 5365 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5366 | resumeSession: true, |
| 5367 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5368 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5369 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5370 | expectedVersion: sessionVers.version, |
| 5371 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5372 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5373 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5374 | Bugs: ProtocolBugs{ |
| 5375 | SendBothTickets: true, |
| 5376 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5377 | }, |
| 5378 | expectedResumeVersion: resumeVers.version, |
| 5379 | }) |
| 5380 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5381 | } |
| 5382 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5383 | |
| 5384 | testCases = append(testCases, testCase{ |
| 5385 | name: "Resume-Client-CipherMismatch", |
| 5386 | resumeSession: true, |
| 5387 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5388 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5389 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5390 | }, |
| 5391 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5392 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5393 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5394 | Bugs: ProtocolBugs{ |
| 5395 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5396 | }, |
| 5397 | }, |
| 5398 | shouldFail: true, |
| 5399 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5400 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5401 | |
| 5402 | testCases = append(testCases, testCase{ |
| 5403 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5404 | resumeSession: true, |
| 5405 | config: Config{ |
| 5406 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5407 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5408 | }, |
| 5409 | resumeConfig: &Config{ |
| 5410 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5411 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5412 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5413 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5414 | }, |
| 5415 | }, |
| 5416 | shouldFail: true, |
| 5417 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5418 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5419 | } |
| 5420 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5421 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 5422 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5423 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5424 | testType: serverTest, |
| 5425 | name: "Renegotiate-Server-Forbidden", |
| 5426 | config: Config{ |
| 5427 | MaxVersion: VersionTLS12, |
| 5428 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5429 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5430 | shouldFail: true, |
| 5431 | expectedError: ":NO_RENEGOTIATION:", |
| 5432 | expectedLocalError: "remote error: no renegotiation", |
| 5433 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5434 | // The server shouldn't echo the renegotiation extension unless |
| 5435 | // requested by the client. |
| 5436 | testCases = append(testCases, testCase{ |
| 5437 | testType: serverTest, |
| 5438 | name: "Renegotiate-Server-NoExt", |
| 5439 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5440 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5441 | Bugs: ProtocolBugs{ |
| 5442 | NoRenegotiationInfo: true, |
| 5443 | RequireRenegotiationInfo: true, |
| 5444 | }, |
| 5445 | }, |
| 5446 | shouldFail: true, |
| 5447 | expectedLocalError: "renegotiation extension missing", |
| 5448 | }) |
| 5449 | // The renegotiation SCSV should be sufficient for the server to echo |
| 5450 | // the extension. |
| 5451 | testCases = append(testCases, testCase{ |
| 5452 | testType: serverTest, |
| 5453 | name: "Renegotiate-Server-NoExt-SCSV", |
| 5454 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5455 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5456 | Bugs: ProtocolBugs{ |
| 5457 | NoRenegotiationInfo: true, |
| 5458 | SendRenegotiationSCSV: true, |
| 5459 | RequireRenegotiationInfo: true, |
| 5460 | }, |
| 5461 | }, |
| 5462 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5463 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5464 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5465 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5466 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5467 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5468 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5469 | }, |
| 5470 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5471 | renegotiate: 1, |
| 5472 | flags: []string{ |
| 5473 | "-renegotiate-freely", |
| 5474 | "-expect-total-renegotiations", "1", |
| 5475 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5476 | }) |
| 5477 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5478 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5479 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5480 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5481 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5482 | Bugs: ProtocolBugs{ |
| 5483 | EmptyRenegotiationInfo: true, |
| 5484 | }, |
| 5485 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5486 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5487 | shouldFail: true, |
| 5488 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5489 | }) |
| 5490 | testCases = append(testCases, testCase{ |
| 5491 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5492 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5493 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5494 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5495 | Bugs: ProtocolBugs{ |
| 5496 | BadRenegotiationInfo: true, |
| 5497 | }, |
| 5498 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5499 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5500 | shouldFail: true, |
| 5501 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5502 | }) |
| 5503 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5504 | name: "Renegotiate-Client-Downgrade", |
| 5505 | renegotiate: 1, |
| 5506 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5507 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5508 | Bugs: ProtocolBugs{ |
| 5509 | NoRenegotiationInfoAfterInitial: true, |
| 5510 | }, |
| 5511 | }, |
| 5512 | flags: []string{"-renegotiate-freely"}, |
| 5513 | shouldFail: true, |
| 5514 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5515 | }) |
| 5516 | testCases = append(testCases, testCase{ |
| 5517 | name: "Renegotiate-Client-Upgrade", |
| 5518 | renegotiate: 1, |
| 5519 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5520 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5521 | Bugs: ProtocolBugs{ |
| 5522 | NoRenegotiationInfoInInitial: true, |
| 5523 | }, |
| 5524 | }, |
| 5525 | flags: []string{"-renegotiate-freely"}, |
| 5526 | shouldFail: true, |
| 5527 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5528 | }) |
| 5529 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5530 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5531 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5532 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5533 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5534 | Bugs: ProtocolBugs{ |
| 5535 | NoRenegotiationInfo: true, |
| 5536 | }, |
| 5537 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5538 | flags: []string{ |
| 5539 | "-renegotiate-freely", |
| 5540 | "-expect-total-renegotiations", "1", |
| 5541 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5542 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5543 | |
| 5544 | // Test that the server may switch ciphers on renegotiation without |
| 5545 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5546 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5547 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5548 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5549 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5550 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5551 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5552 | }, |
| 5553 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5554 | flags: []string{ |
| 5555 | "-renegotiate-freely", |
| 5556 | "-expect-total-renegotiations", "1", |
| 5557 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5558 | }) |
| 5559 | testCases = append(testCases, testCase{ |
| 5560 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5561 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5562 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5563 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5564 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5565 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5566 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5567 | flags: []string{ |
| 5568 | "-renegotiate-freely", |
| 5569 | "-expect-total-renegotiations", "1", |
| 5570 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5571 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5572 | |
| 5573 | // Test that the server may not switch versions on renegotiation. |
| 5574 | testCases = append(testCases, testCase{ |
| 5575 | name: "Renegotiate-Client-SwitchVersion", |
| 5576 | config: Config{ |
| 5577 | MaxVersion: VersionTLS12, |
| 5578 | // Pick a cipher which exists at both versions. |
| 5579 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 5580 | Bugs: ProtocolBugs{ |
| 5581 | NegotiateVersionOnRenego: VersionTLS11, |
| 5582 | }, |
| 5583 | }, |
| 5584 | renegotiate: 1, |
| 5585 | flags: []string{ |
| 5586 | "-renegotiate-freely", |
| 5587 | "-expect-total-renegotiations", "1", |
| 5588 | }, |
| 5589 | shouldFail: true, |
| 5590 | expectedError: ":WRONG_SSL_VERSION:", |
| 5591 | }) |
| 5592 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5593 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5594 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5595 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5596 | config: Config{ |
| 5597 | MaxVersion: VersionTLS10, |
| 5598 | Bugs: ProtocolBugs{ |
| 5599 | RequireSameRenegoClientVersion: true, |
| 5600 | }, |
| 5601 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5602 | flags: []string{ |
| 5603 | "-renegotiate-freely", |
| 5604 | "-expect-total-renegotiations", "1", |
| 5605 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5606 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5607 | testCases = append(testCases, testCase{ |
| 5608 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5609 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5610 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5611 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5612 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5613 | NextProtos: []string{"foo"}, |
| 5614 | }, |
| 5615 | flags: []string{ |
| 5616 | "-false-start", |
| 5617 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5618 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 5619 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5620 | }, |
| 5621 | shimWritesFirst: true, |
| 5622 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5623 | |
| 5624 | // Client-side renegotiation controls. |
| 5625 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5626 | name: "Renegotiate-Client-Forbidden-1", |
| 5627 | config: Config{ |
| 5628 | MaxVersion: VersionTLS12, |
| 5629 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5630 | renegotiate: 1, |
| 5631 | shouldFail: true, |
| 5632 | expectedError: ":NO_RENEGOTIATION:", |
| 5633 | expectedLocalError: "remote error: no renegotiation", |
| 5634 | }) |
| 5635 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5636 | name: "Renegotiate-Client-Once-1", |
| 5637 | config: Config{ |
| 5638 | MaxVersion: VersionTLS12, |
| 5639 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5640 | renegotiate: 1, |
| 5641 | flags: []string{ |
| 5642 | "-renegotiate-once", |
| 5643 | "-expect-total-renegotiations", "1", |
| 5644 | }, |
| 5645 | }) |
| 5646 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5647 | name: "Renegotiate-Client-Freely-1", |
| 5648 | config: Config{ |
| 5649 | MaxVersion: VersionTLS12, |
| 5650 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5651 | renegotiate: 1, |
| 5652 | flags: []string{ |
| 5653 | "-renegotiate-freely", |
| 5654 | "-expect-total-renegotiations", "1", |
| 5655 | }, |
| 5656 | }) |
| 5657 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5658 | name: "Renegotiate-Client-Once-2", |
| 5659 | config: Config{ |
| 5660 | MaxVersion: VersionTLS12, |
| 5661 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5662 | renegotiate: 2, |
| 5663 | flags: []string{"-renegotiate-once"}, |
| 5664 | shouldFail: true, |
| 5665 | expectedError: ":NO_RENEGOTIATION:", |
| 5666 | expectedLocalError: "remote error: no renegotiation", |
| 5667 | }) |
| 5668 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5669 | name: "Renegotiate-Client-Freely-2", |
| 5670 | config: Config{ |
| 5671 | MaxVersion: VersionTLS12, |
| 5672 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5673 | renegotiate: 2, |
| 5674 | flags: []string{ |
| 5675 | "-renegotiate-freely", |
| 5676 | "-expect-total-renegotiations", "2", |
| 5677 | }, |
| 5678 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5679 | testCases = append(testCases, testCase{ |
| 5680 | name: "Renegotiate-Client-NoIgnore", |
| 5681 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5682 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5683 | Bugs: ProtocolBugs{ |
| 5684 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5685 | }, |
| 5686 | }, |
| 5687 | shouldFail: true, |
| 5688 | expectedError: ":NO_RENEGOTIATION:", |
| 5689 | }) |
| 5690 | testCases = append(testCases, testCase{ |
| 5691 | name: "Renegotiate-Client-Ignore", |
| 5692 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5693 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5694 | Bugs: ProtocolBugs{ |
| 5695 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5696 | }, |
| 5697 | }, |
| 5698 | flags: []string{ |
| 5699 | "-renegotiate-ignore", |
| 5700 | "-expect-total-renegotiations", "0", |
| 5701 | }, |
| 5702 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5703 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 5704 | // Renegotiation is not allowed at SSL 3.0. |
| 5705 | testCases = append(testCases, testCase{ |
| 5706 | name: "Renegotiate-Client-SSL3", |
| 5707 | config: Config{ |
| 5708 | MaxVersion: VersionSSL30, |
| 5709 | }, |
| 5710 | renegotiate: 1, |
| 5711 | flags: []string{ |
| 5712 | "-renegotiate-freely", |
| 5713 | "-expect-total-renegotiations", "1", |
| 5714 | }, |
| 5715 | shouldFail: true, |
| 5716 | expectedError: ":NO_RENEGOTIATION:", |
| 5717 | expectedLocalError: "remote error: no renegotiation", |
| 5718 | }) |
| 5719 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5720 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 5721 | testCases = append(testCases, testCase{ |
| 5722 | name: "StrayHelloRequest", |
| 5723 | config: Config{ |
| 5724 | MaxVersion: VersionTLS12, |
| 5725 | Bugs: ProtocolBugs{ |
| 5726 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5727 | }, |
| 5728 | }, |
| 5729 | }) |
| 5730 | testCases = append(testCases, testCase{ |
| 5731 | name: "StrayHelloRequest-Packed", |
| 5732 | config: Config{ |
| 5733 | MaxVersion: VersionTLS12, |
| 5734 | Bugs: ProtocolBugs{ |
| 5735 | PackHandshakeFlight: true, |
| 5736 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5737 | }, |
| 5738 | }, |
| 5739 | }) |
| 5740 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 5741 | // Test renegotiation works if HelloRequest and server Finished come in |
| 5742 | // the same record. |
| 5743 | testCases = append(testCases, testCase{ |
| 5744 | name: "Renegotiate-Client-Packed", |
| 5745 | config: Config{ |
| 5746 | MaxVersion: VersionTLS12, |
| 5747 | Bugs: ProtocolBugs{ |
| 5748 | PackHandshakeFlight: true, |
| 5749 | PackHelloRequestWithFinished: true, |
| 5750 | }, |
| 5751 | }, |
| 5752 | renegotiate: 1, |
| 5753 | flags: []string{ |
| 5754 | "-renegotiate-freely", |
| 5755 | "-expect-total-renegotiations", "1", |
| 5756 | }, |
| 5757 | }) |
| 5758 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5759 | // Renegotiation is forbidden in TLS 1.3. |
| 5760 | testCases = append(testCases, testCase{ |
| 5761 | name: "Renegotiate-Client-TLS13", |
| 5762 | config: Config{ |
| 5763 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5764 | Bugs: ProtocolBugs{ |
| 5765 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5766 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5767 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5768 | flags: []string{ |
| 5769 | "-renegotiate-freely", |
| 5770 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 5771 | shouldFail: true, |
| 5772 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5773 | }) |
| 5774 | |
| 5775 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 5776 | testCases = append(testCases, testCase{ |
| 5777 | name: "StrayHelloRequest-TLS13", |
| 5778 | config: Config{ |
| 5779 | MaxVersion: VersionTLS13, |
| 5780 | Bugs: ProtocolBugs{ |
| 5781 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5782 | }, |
| 5783 | }, |
| 5784 | shouldFail: true, |
| 5785 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 5786 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5787 | } |
| 5788 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5789 | func addDTLSReplayTests() { |
| 5790 | // Test that sequence number replays are detected. |
| 5791 | testCases = append(testCases, testCase{ |
| 5792 | protocol: dtls, |
| 5793 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5794 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5795 | replayWrites: true, |
| 5796 | }) |
| 5797 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5798 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5799 | // than the retransmit window. |
| 5800 | testCases = append(testCases, testCase{ |
| 5801 | protocol: dtls, |
| 5802 | name: "DTLS-Replay-LargeGaps", |
| 5803 | config: Config{ |
| 5804 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5805 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5806 | return in * 127 |
| 5807 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5808 | }, |
| 5809 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5810 | messageCount: 200, |
| 5811 | replayWrites: true, |
| 5812 | }) |
| 5813 | |
| 5814 | // Test the incoming sequence number changing non-monotonically. |
| 5815 | testCases = append(testCases, testCase{ |
| 5816 | protocol: dtls, |
| 5817 | name: "DTLS-Replay-NonMonotonic", |
| 5818 | config: Config{ |
| 5819 | Bugs: ProtocolBugs{ |
| 5820 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5821 | return in ^ 31 |
| 5822 | }, |
| 5823 | }, |
| 5824 | }, |
| 5825 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5826 | replayWrites: true, |
| 5827 | }) |
| 5828 | } |
| 5829 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5830 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5831 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5832 | id signatureAlgorithm |
| 5833 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5834 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5835 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 5836 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 5837 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 5838 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5839 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5840 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 5841 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 5842 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5843 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 5844 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 5845 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5846 | // Tests for key types prior to TLS 1.2. |
| 5847 | {"RSA", 0, testCertRSA}, |
| 5848 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5849 | } |
| 5850 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5851 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 5852 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 5853 | |
| 5854 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5855 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 5856 | // versions a signing cipher. |
| 5857 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5858 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5859 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 5860 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 5861 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 5862 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 5863 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 5864 | } |
| 5865 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5866 | var allAlgorithms []signatureAlgorithm |
| 5867 | for _, alg := range testSignatureAlgorithms { |
| 5868 | if alg.id != 0 { |
| 5869 | allAlgorithms = append(allAlgorithms, alg.id) |
| 5870 | } |
| 5871 | } |
| 5872 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5873 | // Make sure each signature algorithm works. Include some fake values in |
| 5874 | // the list and ensure they're ignored. |
| 5875 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5876 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5877 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 5878 | continue |
| 5879 | } |
| 5880 | |
| 5881 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 5882 | // or remove it in C. |
| 5883 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5884 | continue |
| 5885 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5886 | |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5887 | var shouldFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5888 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5889 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
| 5890 | shouldFail = true |
| 5891 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 5892 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 5893 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 5894 | shouldFail = true |
| 5895 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5896 | |
| 5897 | var signError, verifyError string |
| 5898 | if shouldFail { |
| 5899 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
| 5900 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5901 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5902 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5903 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 5904 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5905 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5906 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5907 | config: Config{ |
| 5908 | MaxVersion: ver.version, |
| 5909 | ClientAuth: RequireAnyClientCert, |
| 5910 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5911 | fakeSigAlg1, |
| 5912 | alg.id, |
| 5913 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5914 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5915 | }, |
| 5916 | flags: []string{ |
| 5917 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5918 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5919 | "-enable-all-curves", |
| 5920 | }, |
| 5921 | shouldFail: shouldFail, |
| 5922 | expectedError: signError, |
| 5923 | expectedPeerSignatureAlgorithm: alg.id, |
| 5924 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5925 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5926 | testCases = append(testCases, testCase{ |
| 5927 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5928 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5929 | config: Config{ |
| 5930 | MaxVersion: ver.version, |
| 5931 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5932 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5933 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5934 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5935 | Bugs: ProtocolBugs{ |
| 5936 | SkipECDSACurveCheck: shouldFail, |
| 5937 | IgnoreSignatureVersionChecks: shouldFail, |
| 5938 | // The client won't advertise 1.3-only algorithms after |
| 5939 | // version negotiation. |
| 5940 | IgnorePeerSignatureAlgorithmPreferences: shouldFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5941 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5942 | }, |
| 5943 | flags: []string{ |
| 5944 | "-require-any-client-certificate", |
| 5945 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5946 | "-enable-all-curves", |
| 5947 | }, |
| 5948 | shouldFail: shouldFail, |
| 5949 | expectedError: verifyError, |
| 5950 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5951 | |
| 5952 | testCases = append(testCases, testCase{ |
| 5953 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5954 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5955 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5956 | MaxVersion: ver.version, |
| 5957 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5958 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5959 | fakeSigAlg1, |
| 5960 | alg.id, |
| 5961 | fakeSigAlg2, |
| 5962 | }, |
| 5963 | }, |
| 5964 | flags: []string{ |
| 5965 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5966 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5967 | "-enable-all-curves", |
| 5968 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5969 | shouldFail: shouldFail, |
| 5970 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5971 | expectedPeerSignatureAlgorithm: alg.id, |
| 5972 | }) |
| 5973 | |
| 5974 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5975 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5976 | config: Config{ |
| 5977 | MaxVersion: ver.version, |
| 5978 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5979 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5980 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5981 | alg.id, |
| 5982 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5983 | Bugs: ProtocolBugs{ |
| 5984 | SkipECDSACurveCheck: shouldFail, |
| 5985 | IgnoreSignatureVersionChecks: shouldFail, |
| 5986 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5987 | }, |
| 5988 | flags: []string{ |
| 5989 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5990 | "-enable-all-curves", |
| 5991 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5992 | shouldFail: shouldFail, |
| 5993 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5994 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5995 | |
| 5996 | if !shouldFail { |
| 5997 | testCases = append(testCases, testCase{ |
| 5998 | testType: serverTest, |
| 5999 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6000 | config: Config{ |
| 6001 | MaxVersion: ver.version, |
| 6002 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6003 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6004 | alg.id, |
| 6005 | }, |
| 6006 | Bugs: ProtocolBugs{ |
| 6007 | InvalidSignature: true, |
| 6008 | }, |
| 6009 | }, |
| 6010 | flags: []string{ |
| 6011 | "-require-any-client-certificate", |
| 6012 | "-enable-all-curves", |
| 6013 | }, |
| 6014 | shouldFail: true, |
| 6015 | expectedError: ":BAD_SIGNATURE:", |
| 6016 | }) |
| 6017 | |
| 6018 | testCases = append(testCases, testCase{ |
| 6019 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6020 | config: Config{ |
| 6021 | MaxVersion: ver.version, |
| 6022 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6023 | CipherSuites: signingCiphers, |
| 6024 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6025 | alg.id, |
| 6026 | }, |
| 6027 | Bugs: ProtocolBugs{ |
| 6028 | InvalidSignature: true, |
| 6029 | }, |
| 6030 | }, |
| 6031 | flags: []string{"-enable-all-curves"}, |
| 6032 | shouldFail: true, |
| 6033 | expectedError: ":BAD_SIGNATURE:", |
| 6034 | }) |
| 6035 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6036 | |
| 6037 | if ver.version >= VersionTLS12 && !shouldFail { |
| 6038 | testCases = append(testCases, testCase{ |
| 6039 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6040 | config: Config{ |
| 6041 | MaxVersion: ver.version, |
| 6042 | ClientAuth: RequireAnyClientCert, |
| 6043 | VerifySignatureAlgorithms: allAlgorithms, |
| 6044 | }, |
| 6045 | flags: []string{ |
| 6046 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6047 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6048 | "-enable-all-curves", |
| 6049 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6050 | }, |
| 6051 | expectedPeerSignatureAlgorithm: alg.id, |
| 6052 | }) |
| 6053 | |
| 6054 | testCases = append(testCases, testCase{ |
| 6055 | testType: serverTest, |
| 6056 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6057 | config: Config{ |
| 6058 | MaxVersion: ver.version, |
| 6059 | CipherSuites: signingCiphers, |
| 6060 | VerifySignatureAlgorithms: allAlgorithms, |
| 6061 | }, |
| 6062 | flags: []string{ |
| 6063 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6064 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6065 | "-enable-all-curves", |
| 6066 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6067 | }, |
| 6068 | expectedPeerSignatureAlgorithm: alg.id, |
| 6069 | }) |
| 6070 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6071 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6072 | } |
| 6073 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6074 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6075 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6076 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6077 | config: Config{ |
| 6078 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6079 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6080 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6081 | signatureECDSAWithP521AndSHA512, |
| 6082 | signatureRSAPKCS1WithSHA384, |
| 6083 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6084 | }, |
| 6085 | }, |
| 6086 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6087 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6088 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6089 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6090 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6091 | }) |
| 6092 | |
| 6093 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6094 | name: "ClientAuth-SignatureType-TLS13", |
| 6095 | config: Config{ |
| 6096 | ClientAuth: RequireAnyClientCert, |
| 6097 | MaxVersion: VersionTLS13, |
| 6098 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6099 | signatureECDSAWithP521AndSHA512, |
| 6100 | signatureRSAPKCS1WithSHA384, |
| 6101 | signatureRSAPSSWithSHA384, |
| 6102 | signatureECDSAWithSHA1, |
| 6103 | }, |
| 6104 | }, |
| 6105 | flags: []string{ |
| 6106 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6107 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6108 | }, |
| 6109 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6110 | }) |
| 6111 | |
| 6112 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6113 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6114 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6115 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6116 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6117 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6118 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6119 | signatureECDSAWithP521AndSHA512, |
| 6120 | signatureRSAPKCS1WithSHA384, |
| 6121 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6122 | }, |
| 6123 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6124 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6125 | }) |
| 6126 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6127 | testCases = append(testCases, testCase{ |
| 6128 | testType: serverTest, |
| 6129 | name: "ServerAuth-SignatureType-TLS13", |
| 6130 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6131 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6132 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6133 | signatureECDSAWithP521AndSHA512, |
| 6134 | signatureRSAPKCS1WithSHA384, |
| 6135 | signatureRSAPSSWithSHA384, |
| 6136 | signatureECDSAWithSHA1, |
| 6137 | }, |
| 6138 | }, |
| 6139 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6140 | }) |
| 6141 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6142 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6143 | testCases = append(testCases, testCase{ |
| 6144 | testType: serverTest, |
| 6145 | name: "Verify-ClientAuth-SignatureType", |
| 6146 | config: Config{ |
| 6147 | MaxVersion: VersionTLS12, |
| 6148 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6149 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6150 | signatureRSAPKCS1WithSHA256, |
| 6151 | }, |
| 6152 | Bugs: ProtocolBugs{ |
| 6153 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6154 | }, |
| 6155 | }, |
| 6156 | flags: []string{ |
| 6157 | "-require-any-client-certificate", |
| 6158 | }, |
| 6159 | shouldFail: true, |
| 6160 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6161 | }) |
| 6162 | |
| 6163 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6164 | testType: serverTest, |
| 6165 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6166 | config: Config{ |
| 6167 | MaxVersion: VersionTLS13, |
| 6168 | Certificates: []Certificate{rsaCertificate}, |
| 6169 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6170 | signatureRSAPSSWithSHA256, |
| 6171 | }, |
| 6172 | Bugs: ProtocolBugs{ |
| 6173 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6174 | }, |
| 6175 | }, |
| 6176 | flags: []string{ |
| 6177 | "-require-any-client-certificate", |
| 6178 | }, |
| 6179 | shouldFail: true, |
| 6180 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6181 | }) |
| 6182 | |
| 6183 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6184 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6185 | config: Config{ |
| 6186 | MaxVersion: VersionTLS12, |
| 6187 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6188 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6189 | signatureRSAPKCS1WithSHA256, |
| 6190 | }, |
| 6191 | Bugs: ProtocolBugs{ |
| 6192 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6193 | }, |
| 6194 | }, |
| 6195 | shouldFail: true, |
| 6196 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6197 | }) |
| 6198 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6199 | testCases = append(testCases, testCase{ |
| 6200 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6201 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6202 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6203 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6204 | signatureRSAPSSWithSHA256, |
| 6205 | }, |
| 6206 | Bugs: ProtocolBugs{ |
| 6207 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6208 | }, |
| 6209 | }, |
| 6210 | shouldFail: true, |
| 6211 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6212 | }) |
| 6213 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6214 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6215 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6216 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6217 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6218 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6219 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6220 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6221 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6222 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6223 | }, |
| 6224 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6225 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6226 | }, |
| 6227 | }, |
| 6228 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6229 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6230 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6231 | }, |
| 6232 | }) |
| 6233 | |
| 6234 | testCases = append(testCases, testCase{ |
| 6235 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6236 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6237 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6238 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6239 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6240 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6241 | }, |
| 6242 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6243 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6244 | }, |
| 6245 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6246 | flags: []string{ |
| 6247 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6248 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6249 | }, |
| 6250 | }) |
| 6251 | |
| 6252 | testCases = append(testCases, testCase{ |
| 6253 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6254 | config: Config{ |
| 6255 | MaxVersion: VersionTLS12, |
| 6256 | ClientAuth: RequireAnyClientCert, |
| 6257 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6258 | signatureECDSAWithSHA1, |
| 6259 | }, |
| 6260 | Bugs: ProtocolBugs{ |
| 6261 | NoSignatureAlgorithms: true, |
| 6262 | }, |
| 6263 | }, |
| 6264 | flags: []string{ |
| 6265 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6266 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6267 | }, |
| 6268 | }) |
| 6269 | |
| 6270 | testCases = append(testCases, testCase{ |
| 6271 | testType: serverTest, |
| 6272 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6273 | config: Config{ |
| 6274 | MaxVersion: VersionTLS12, |
| 6275 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6276 | signatureECDSAWithSHA1, |
| 6277 | }, |
| 6278 | Bugs: ProtocolBugs{ |
| 6279 | NoSignatureAlgorithms: true, |
| 6280 | }, |
| 6281 | }, |
| 6282 | flags: []string{ |
| 6283 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6284 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6285 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6286 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6287 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6288 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6289 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6290 | config: Config{ |
| 6291 | MaxVersion: VersionTLS13, |
| 6292 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6293 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6294 | signatureRSAPKCS1WithSHA1, |
| 6295 | }, |
| 6296 | Bugs: ProtocolBugs{ |
| 6297 | NoSignatureAlgorithms: true, |
| 6298 | }, |
| 6299 | }, |
| 6300 | flags: []string{ |
| 6301 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6302 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6303 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6304 | shouldFail: true, |
| 6305 | // An empty CertificateRequest signature algorithm list is a |
| 6306 | // syntax error in TLS 1.3. |
| 6307 | expectedError: ":DECODE_ERROR:", |
| 6308 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6309 | }) |
| 6310 | |
| 6311 | testCases = append(testCases, testCase{ |
| 6312 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6313 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6314 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6315 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6316 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6317 | signatureRSAPKCS1WithSHA1, |
| 6318 | }, |
| 6319 | Bugs: ProtocolBugs{ |
| 6320 | NoSignatureAlgorithms: true, |
| 6321 | }, |
| 6322 | }, |
| 6323 | shouldFail: true, |
| 6324 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6325 | }) |
| 6326 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6327 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6328 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6329 | testCases = append(testCases, testCase{ |
| 6330 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6331 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6332 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6333 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6334 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6335 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6336 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6337 | }, |
| 6338 | Bugs: ProtocolBugs{ |
| 6339 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6340 | }, |
| 6341 | }, |
| 6342 | flags: []string{"-require-any-client-certificate"}, |
| 6343 | shouldFail: true, |
| 6344 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6345 | }) |
| 6346 | |
| 6347 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6348 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6349 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6350 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6351 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6352 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6353 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6354 | }, |
| 6355 | Bugs: ProtocolBugs{ |
| 6356 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6357 | }, |
| 6358 | }, |
| 6359 | shouldFail: true, |
| 6360 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6361 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6362 | testCases = append(testCases, testCase{ |
| 6363 | testType: serverTest, |
| 6364 | name: "ClientAuth-Enforced-TLS13", |
| 6365 | config: Config{ |
| 6366 | MaxVersion: VersionTLS13, |
| 6367 | Certificates: []Certificate{rsaCertificate}, |
| 6368 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6369 | signatureRSAPKCS1WithMD5, |
| 6370 | }, |
| 6371 | Bugs: ProtocolBugs{ |
| 6372 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6373 | IgnoreSignatureVersionChecks: true, |
| 6374 | }, |
| 6375 | }, |
| 6376 | flags: []string{"-require-any-client-certificate"}, |
| 6377 | shouldFail: true, |
| 6378 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6379 | }) |
| 6380 | |
| 6381 | testCases = append(testCases, testCase{ |
| 6382 | name: "ServerAuth-Enforced-TLS13", |
| 6383 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6384 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6385 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6386 | signatureRSAPKCS1WithMD5, |
| 6387 | }, |
| 6388 | Bugs: ProtocolBugs{ |
| 6389 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6390 | IgnoreSignatureVersionChecks: true, |
| 6391 | }, |
| 6392 | }, |
| 6393 | shouldFail: true, |
| 6394 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6395 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6396 | |
| 6397 | // Test that the agreed upon digest respects the client preferences and |
| 6398 | // the server digests. |
| 6399 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6400 | name: "NoCommonAlgorithms-Digests", |
| 6401 | config: Config{ |
| 6402 | MaxVersion: VersionTLS12, |
| 6403 | ClientAuth: RequireAnyClientCert, |
| 6404 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6405 | signatureRSAPKCS1WithSHA512, |
| 6406 | signatureRSAPKCS1WithSHA1, |
| 6407 | }, |
| 6408 | }, |
| 6409 | flags: []string{ |
| 6410 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6411 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6412 | "-digest-prefs", "SHA256", |
| 6413 | }, |
| 6414 | shouldFail: true, |
| 6415 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6416 | }) |
| 6417 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6418 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6419 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6420 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6421 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6422 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6423 | signatureRSAPKCS1WithSHA512, |
| 6424 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6425 | }, |
| 6426 | }, |
| 6427 | flags: []string{ |
| 6428 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6429 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6430 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6431 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6432 | shouldFail: true, |
| 6433 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6434 | }) |
| 6435 | testCases = append(testCases, testCase{ |
| 6436 | name: "NoCommonAlgorithms-TLS13", |
| 6437 | config: Config{ |
| 6438 | MaxVersion: VersionTLS13, |
| 6439 | ClientAuth: RequireAnyClientCert, |
| 6440 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6441 | signatureRSAPSSWithSHA512, |
| 6442 | signatureRSAPSSWithSHA384, |
| 6443 | }, |
| 6444 | }, |
| 6445 | flags: []string{ |
| 6446 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6447 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6448 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 6449 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6450 | shouldFail: true, |
| 6451 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6452 | }) |
| 6453 | testCases = append(testCases, testCase{ |
| 6454 | name: "Agree-Digest-SHA256", |
| 6455 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6456 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6457 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6458 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6459 | signatureRSAPKCS1WithSHA1, |
| 6460 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6461 | }, |
| 6462 | }, |
| 6463 | flags: []string{ |
| 6464 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6465 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6466 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6467 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6468 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6469 | }) |
| 6470 | testCases = append(testCases, testCase{ |
| 6471 | name: "Agree-Digest-SHA1", |
| 6472 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6473 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6474 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6475 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6476 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6477 | }, |
| 6478 | }, |
| 6479 | flags: []string{ |
| 6480 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6481 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6482 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6483 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6484 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6485 | }) |
| 6486 | testCases = append(testCases, testCase{ |
| 6487 | name: "Agree-Digest-Default", |
| 6488 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6489 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6490 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6491 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6492 | signatureRSAPKCS1WithSHA256, |
| 6493 | signatureECDSAWithP256AndSHA256, |
| 6494 | signatureRSAPKCS1WithSHA1, |
| 6495 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6496 | }, |
| 6497 | }, |
| 6498 | flags: []string{ |
| 6499 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6500 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6501 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6502 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6503 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6504 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6505 | // Test that the signing preference list may include extra algorithms |
| 6506 | // without negotiation problems. |
| 6507 | testCases = append(testCases, testCase{ |
| 6508 | testType: serverTest, |
| 6509 | name: "FilterExtraAlgorithms", |
| 6510 | config: Config{ |
| 6511 | MaxVersion: VersionTLS12, |
| 6512 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6513 | signatureRSAPKCS1WithSHA256, |
| 6514 | }, |
| 6515 | }, |
| 6516 | flags: []string{ |
| 6517 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6518 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6519 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 6520 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 6521 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 6522 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 6523 | }, |
| 6524 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 6525 | }) |
| 6526 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6527 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 6528 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6529 | testCases = append(testCases, testCase{ |
| 6530 | name: "CheckLeafCurve", |
| 6531 | config: Config{ |
| 6532 | MaxVersion: VersionTLS12, |
| 6533 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6534 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6535 | }, |
| 6536 | flags: []string{"-p384-only"}, |
| 6537 | shouldFail: true, |
| 6538 | expectedError: ":BAD_ECC_CERT:", |
| 6539 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 6540 | |
| 6541 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 6542 | testCases = append(testCases, testCase{ |
| 6543 | name: "CheckLeafCurve-TLS13", |
| 6544 | config: Config{ |
| 6545 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 6546 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 6547 | }, |
| 6548 | flags: []string{"-p384-only"}, |
| 6549 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6550 | |
| 6551 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 6552 | testCases = append(testCases, testCase{ |
| 6553 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 6554 | config: Config{ |
| 6555 | MaxVersion: VersionTLS12, |
| 6556 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6557 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6558 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6559 | signatureECDSAWithP384AndSHA384, |
| 6560 | }, |
| 6561 | }, |
| 6562 | }) |
| 6563 | |
| 6564 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 6565 | testCases = append(testCases, testCase{ |
| 6566 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 6567 | config: Config{ |
| 6568 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6569 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6570 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6571 | signatureECDSAWithP384AndSHA384, |
| 6572 | }, |
| 6573 | Bugs: ProtocolBugs{ |
| 6574 | SkipECDSACurveCheck: true, |
| 6575 | }, |
| 6576 | }, |
| 6577 | shouldFail: true, |
| 6578 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6579 | }) |
| 6580 | |
| 6581 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 6582 | // account. |
| 6583 | testCases = append(testCases, testCase{ |
| 6584 | testType: serverTest, |
| 6585 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 6586 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6587 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6588 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6589 | signatureECDSAWithP384AndSHA384, |
| 6590 | signatureECDSAWithP256AndSHA256, |
| 6591 | }, |
| 6592 | }, |
| 6593 | flags: []string{ |
| 6594 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6595 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6596 | }, |
| 6597 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6598 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 6599 | |
| 6600 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 6601 | // server does not attempt to sign in that case. |
| 6602 | testCases = append(testCases, testCase{ |
| 6603 | testType: serverTest, |
| 6604 | name: "RSA-PSS-Large", |
| 6605 | config: Config{ |
| 6606 | MaxVersion: VersionTLS13, |
| 6607 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6608 | signatureRSAPSSWithSHA512, |
| 6609 | }, |
| 6610 | }, |
| 6611 | flags: []string{ |
| 6612 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 6613 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 6614 | }, |
| 6615 | shouldFail: true, |
| 6616 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6617 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 6618 | |
| 6619 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 6620 | testCases = append(testCases, testCase{ |
| 6621 | testType: clientTest, |
| 6622 | name: "RSA-PSS-Default-Verify", |
| 6623 | config: Config{ |
| 6624 | MaxVersion: VersionTLS12, |
| 6625 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6626 | signatureRSAPSSWithSHA256, |
| 6627 | }, |
| 6628 | }, |
| 6629 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6630 | }) |
| 6631 | |
| 6632 | testCases = append(testCases, testCase{ |
| 6633 | testType: serverTest, |
| 6634 | name: "RSA-PSS-Default-Sign", |
| 6635 | config: Config{ |
| 6636 | MaxVersion: VersionTLS12, |
| 6637 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6638 | signatureRSAPSSWithSHA256, |
| 6639 | }, |
| 6640 | }, |
| 6641 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6642 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6643 | } |
| 6644 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6645 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 6646 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 6647 | var timeouts = []time.Duration{ |
| 6648 | 1 * time.Second, |
| 6649 | 2 * time.Second, |
| 6650 | 4 * time.Second, |
| 6651 | 8 * time.Second, |
| 6652 | 16 * time.Second, |
| 6653 | 32 * time.Second, |
| 6654 | 60 * time.Second, |
| 6655 | 60 * time.Second, |
| 6656 | 60 * time.Second, |
| 6657 | 60 * time.Second, |
| 6658 | 60 * time.Second, |
| 6659 | 60 * time.Second, |
| 6660 | 60 * time.Second, |
| 6661 | } |
| 6662 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 6663 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 6664 | // initial timeout duration was set to 250ms. |
| 6665 | var shortTimeouts = []time.Duration{ |
| 6666 | 250 * time.Millisecond, |
| 6667 | 500 * time.Millisecond, |
| 6668 | 1 * time.Second, |
| 6669 | 2 * time.Second, |
| 6670 | 4 * time.Second, |
| 6671 | 8 * time.Second, |
| 6672 | 16 * time.Second, |
| 6673 | 32 * time.Second, |
| 6674 | 60 * time.Second, |
| 6675 | 60 * time.Second, |
| 6676 | 60 * time.Second, |
| 6677 | 60 * time.Second, |
| 6678 | 60 * time.Second, |
| 6679 | } |
| 6680 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6681 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6682 | // These tests work by coordinating some behavior on both the shim and |
| 6683 | // the runner. |
| 6684 | // |
| 6685 | // TimeoutSchedule configures the runner to send a series of timeout |
| 6686 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 6687 | // each peer handshake flight N. The timeout opcode both simulates a |
| 6688 | // timeout in the shim and acts as a synchronization point to help the |
| 6689 | // runner bracket each handshake flight. |
| 6690 | // |
| 6691 | // We assume the shim does not read from the channel eagerly. It must |
| 6692 | // first wait until it has sent flight N and is ready to receive |
| 6693 | // handshake flight N+1. At this point, it will process the timeout |
| 6694 | // opcode. It must then immediately respond with a timeout ACK and act |
| 6695 | // as if the shim was idle for the specified amount of time. |
| 6696 | // |
| 6697 | // The runner then drops all packets received before the ACK and |
| 6698 | // continues waiting for flight N. This ordering results in one attempt |
| 6699 | // at sending flight N to be dropped. For the test to complete, the |
| 6700 | // shim must send flight N again, testing that the shim implements DTLS |
| 6701 | // retransmit on a timeout. |
| 6702 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6703 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6704 | // likely be more epochs to cross and the final message's retransmit may |
| 6705 | // be more complex. |
| 6706 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6707 | for _, async := range []bool{true, false} { |
| 6708 | var tests []testCase |
| 6709 | |
| 6710 | // Test that this is indeed the timeout schedule. Stress all |
| 6711 | // four patterns of handshake. |
| 6712 | for i := 1; i < len(timeouts); i++ { |
| 6713 | number := strconv.Itoa(i) |
| 6714 | tests = append(tests, testCase{ |
| 6715 | protocol: dtls, |
| 6716 | name: "DTLS-Retransmit-Client-" + number, |
| 6717 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6718 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6719 | Bugs: ProtocolBugs{ |
| 6720 | TimeoutSchedule: timeouts[:i], |
| 6721 | }, |
| 6722 | }, |
| 6723 | resumeSession: true, |
| 6724 | }) |
| 6725 | tests = append(tests, testCase{ |
| 6726 | protocol: dtls, |
| 6727 | testType: serverTest, |
| 6728 | name: "DTLS-Retransmit-Server-" + number, |
| 6729 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6730 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6731 | Bugs: ProtocolBugs{ |
| 6732 | TimeoutSchedule: timeouts[:i], |
| 6733 | }, |
| 6734 | }, |
| 6735 | resumeSession: true, |
| 6736 | }) |
| 6737 | } |
| 6738 | |
| 6739 | // Test that exceeding the timeout schedule hits a read |
| 6740 | // timeout. |
| 6741 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6742 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6743 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6744 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6745 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6746 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6747 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6748 | }, |
| 6749 | }, |
| 6750 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6751 | shouldFail: true, |
| 6752 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6753 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6754 | |
| 6755 | if async { |
| 6756 | // Test that timeout handling has a fudge factor, due to API |
| 6757 | // problems. |
| 6758 | tests = append(tests, testCase{ |
| 6759 | protocol: dtls, |
| 6760 | name: "DTLS-Retransmit-Fudge", |
| 6761 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6762 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6763 | Bugs: ProtocolBugs{ |
| 6764 | TimeoutSchedule: []time.Duration{ |
| 6765 | timeouts[0] - 10*time.Millisecond, |
| 6766 | }, |
| 6767 | }, |
| 6768 | }, |
| 6769 | resumeSession: true, |
| 6770 | }) |
| 6771 | } |
| 6772 | |
| 6773 | // Test that the final Finished retransmitting isn't |
| 6774 | // duplicated if the peer badly fragments everything. |
| 6775 | tests = append(tests, testCase{ |
| 6776 | testType: serverTest, |
| 6777 | protocol: dtls, |
| 6778 | name: "DTLS-Retransmit-Fragmented", |
| 6779 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6780 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6781 | Bugs: ProtocolBugs{ |
| 6782 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 6783 | MaxHandshakeRecordLength: 2, |
| 6784 | }, |
| 6785 | }, |
| 6786 | }) |
| 6787 | |
| 6788 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 6789 | tests = append(tests, testCase{ |
| 6790 | protocol: dtls, |
| 6791 | name: "DTLS-Retransmit-Short-Client", |
| 6792 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6793 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6794 | Bugs: ProtocolBugs{ |
| 6795 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 6796 | }, |
| 6797 | }, |
| 6798 | resumeSession: true, |
| 6799 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 6800 | }) |
| 6801 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6802 | protocol: dtls, |
| 6803 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6804 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6805 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6806 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6807 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6808 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6809 | }, |
| 6810 | }, |
| 6811 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6812 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6813 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6814 | |
| 6815 | for _, test := range tests { |
| 6816 | if async { |
| 6817 | test.name += "-Async" |
| 6818 | test.flags = append(test.flags, "-async") |
| 6819 | } |
| 6820 | |
| 6821 | testCases = append(testCases, test) |
| 6822 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6823 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6824 | } |
| 6825 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 6826 | func addExportKeyingMaterialTests() { |
| 6827 | for _, vers := range tlsVersions { |
| 6828 | if vers.version == VersionSSL30 { |
| 6829 | continue |
| 6830 | } |
| 6831 | testCases = append(testCases, testCase{ |
| 6832 | name: "ExportKeyingMaterial-" + vers.name, |
| 6833 | config: Config{ |
| 6834 | MaxVersion: vers.version, |
| 6835 | }, |
| 6836 | exportKeyingMaterial: 1024, |
| 6837 | exportLabel: "label", |
| 6838 | exportContext: "context", |
| 6839 | useExportContext: true, |
| 6840 | }) |
| 6841 | testCases = append(testCases, testCase{ |
| 6842 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 6843 | config: Config{ |
| 6844 | MaxVersion: vers.version, |
| 6845 | }, |
| 6846 | exportKeyingMaterial: 1024, |
| 6847 | }) |
| 6848 | testCases = append(testCases, testCase{ |
| 6849 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 6850 | config: Config{ |
| 6851 | MaxVersion: vers.version, |
| 6852 | }, |
| 6853 | exportKeyingMaterial: 1024, |
| 6854 | useExportContext: true, |
| 6855 | }) |
| 6856 | testCases = append(testCases, testCase{ |
| 6857 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 6858 | config: Config{ |
| 6859 | MaxVersion: vers.version, |
| 6860 | }, |
| 6861 | exportKeyingMaterial: 1, |
| 6862 | exportLabel: "label", |
| 6863 | exportContext: "context", |
| 6864 | useExportContext: true, |
| 6865 | }) |
| 6866 | } |
| 6867 | testCases = append(testCases, testCase{ |
| 6868 | name: "ExportKeyingMaterial-SSL3", |
| 6869 | config: Config{ |
| 6870 | MaxVersion: VersionSSL30, |
| 6871 | }, |
| 6872 | exportKeyingMaterial: 1024, |
| 6873 | exportLabel: "label", |
| 6874 | exportContext: "context", |
| 6875 | useExportContext: true, |
| 6876 | shouldFail: true, |
| 6877 | expectedError: "failed to export keying material", |
| 6878 | }) |
| 6879 | } |
| 6880 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6881 | func addTLSUniqueTests() { |
| 6882 | for _, isClient := range []bool{false, true} { |
| 6883 | for _, isResumption := range []bool{false, true} { |
| 6884 | for _, hasEMS := range []bool{false, true} { |
| 6885 | var suffix string |
| 6886 | if isResumption { |
| 6887 | suffix = "Resume-" |
| 6888 | } else { |
| 6889 | suffix = "Full-" |
| 6890 | } |
| 6891 | |
| 6892 | if hasEMS { |
| 6893 | suffix += "EMS-" |
| 6894 | } else { |
| 6895 | suffix += "NoEMS-" |
| 6896 | } |
| 6897 | |
| 6898 | if isClient { |
| 6899 | suffix += "Client" |
| 6900 | } else { |
| 6901 | suffix += "Server" |
| 6902 | } |
| 6903 | |
| 6904 | test := testCase{ |
| 6905 | name: "TLSUnique-" + suffix, |
| 6906 | testTLSUnique: true, |
| 6907 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6908 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6909 | Bugs: ProtocolBugs{ |
| 6910 | NoExtendedMasterSecret: !hasEMS, |
| 6911 | }, |
| 6912 | }, |
| 6913 | } |
| 6914 | |
| 6915 | if isResumption { |
| 6916 | test.resumeSession = true |
| 6917 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6918 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6919 | Bugs: ProtocolBugs{ |
| 6920 | NoExtendedMasterSecret: !hasEMS, |
| 6921 | }, |
| 6922 | } |
| 6923 | } |
| 6924 | |
| 6925 | if isResumption && !hasEMS { |
| 6926 | test.shouldFail = true |
| 6927 | test.expectedError = "failed to get tls-unique" |
| 6928 | } |
| 6929 | |
| 6930 | testCases = append(testCases, test) |
| 6931 | } |
| 6932 | } |
| 6933 | } |
| 6934 | } |
| 6935 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6936 | func addCustomExtensionTests() { |
| 6937 | expectedContents := "custom extension" |
| 6938 | emptyString := "" |
| 6939 | |
| 6940 | for _, isClient := range []bool{false, true} { |
| 6941 | suffix := "Server" |
| 6942 | flag := "-enable-server-custom-extension" |
| 6943 | testType := serverTest |
| 6944 | if isClient { |
| 6945 | suffix = "Client" |
| 6946 | flag = "-enable-client-custom-extension" |
| 6947 | testType = clientTest |
| 6948 | } |
| 6949 | |
| 6950 | testCases = append(testCases, testCase{ |
| 6951 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6952 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6953 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6954 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6955 | Bugs: ProtocolBugs{ |
| 6956 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6957 | ExpectedCustomExtension: &expectedContents, |
| 6958 | }, |
| 6959 | }, |
| 6960 | flags: []string{flag}, |
| 6961 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6962 | testCases = append(testCases, testCase{ |
| 6963 | testType: testType, |
| 6964 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 6965 | config: Config{ |
| 6966 | MaxVersion: VersionTLS13, |
| 6967 | Bugs: ProtocolBugs{ |
| 6968 | CustomExtension: expectedContents, |
| 6969 | ExpectedCustomExtension: &expectedContents, |
| 6970 | }, |
| 6971 | }, |
| 6972 | flags: []string{flag}, |
| 6973 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6974 | |
| 6975 | // If the parse callback fails, the handshake should also fail. |
| 6976 | testCases = append(testCases, testCase{ |
| 6977 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6978 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6979 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6980 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6981 | Bugs: ProtocolBugs{ |
| 6982 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6983 | ExpectedCustomExtension: &expectedContents, |
| 6984 | }, |
| 6985 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6986 | flags: []string{flag}, |
| 6987 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6988 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6989 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6990 | testCases = append(testCases, testCase{ |
| 6991 | testType: testType, |
| 6992 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 6993 | config: Config{ |
| 6994 | MaxVersion: VersionTLS13, |
| 6995 | Bugs: ProtocolBugs{ |
| 6996 | CustomExtension: expectedContents + "foo", |
| 6997 | ExpectedCustomExtension: &expectedContents, |
| 6998 | }, |
| 6999 | }, |
| 7000 | flags: []string{flag}, |
| 7001 | shouldFail: true, |
| 7002 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7003 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7004 | |
| 7005 | // If the add callback fails, the handshake should also fail. |
| 7006 | testCases = append(testCases, testCase{ |
| 7007 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7008 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7009 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7010 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7011 | Bugs: ProtocolBugs{ |
| 7012 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7013 | ExpectedCustomExtension: &expectedContents, |
| 7014 | }, |
| 7015 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7016 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7017 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7018 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7019 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7020 | testCases = append(testCases, testCase{ |
| 7021 | testType: testType, |
| 7022 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7023 | config: Config{ |
| 7024 | MaxVersion: VersionTLS13, |
| 7025 | Bugs: ProtocolBugs{ |
| 7026 | CustomExtension: expectedContents, |
| 7027 | ExpectedCustomExtension: &expectedContents, |
| 7028 | }, |
| 7029 | }, |
| 7030 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7031 | shouldFail: true, |
| 7032 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7033 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7034 | |
| 7035 | // If the add callback returns zero, no extension should be |
| 7036 | // added. |
| 7037 | skipCustomExtension := expectedContents |
| 7038 | if isClient { |
| 7039 | // For the case where the client skips sending the |
| 7040 | // custom extension, the server must not “echo” it. |
| 7041 | skipCustomExtension = "" |
| 7042 | } |
| 7043 | testCases = append(testCases, testCase{ |
| 7044 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7045 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7046 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7047 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7048 | Bugs: ProtocolBugs{ |
| 7049 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7050 | ExpectedCustomExtension: &emptyString, |
| 7051 | }, |
| 7052 | }, |
| 7053 | flags: []string{flag, "-custom-extension-skip"}, |
| 7054 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7055 | testCases = append(testCases, testCase{ |
| 7056 | testType: testType, |
| 7057 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7058 | config: Config{ |
| 7059 | MaxVersion: VersionTLS13, |
| 7060 | Bugs: ProtocolBugs{ |
| 7061 | CustomExtension: skipCustomExtension, |
| 7062 | ExpectedCustomExtension: &emptyString, |
| 7063 | }, |
| 7064 | }, |
| 7065 | flags: []string{flag, "-custom-extension-skip"}, |
| 7066 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7067 | } |
| 7068 | |
| 7069 | // The custom extension add callback should not be called if the client |
| 7070 | // doesn't send the extension. |
| 7071 | testCases = append(testCases, testCase{ |
| 7072 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7073 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7074 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7075 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7076 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7077 | ExpectedCustomExtension: &emptyString, |
| 7078 | }, |
| 7079 | }, |
| 7080 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7081 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7082 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7083 | testCases = append(testCases, testCase{ |
| 7084 | testType: serverTest, |
| 7085 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7086 | config: Config{ |
| 7087 | MaxVersion: VersionTLS13, |
| 7088 | Bugs: ProtocolBugs{ |
| 7089 | ExpectedCustomExtension: &emptyString, |
| 7090 | }, |
| 7091 | }, |
| 7092 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7093 | }) |
| 7094 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7095 | // Test an unknown extension from the server. |
| 7096 | testCases = append(testCases, testCase{ |
| 7097 | testType: clientTest, |
| 7098 | name: "UnknownExtension-Client", |
| 7099 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7100 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7101 | Bugs: ProtocolBugs{ |
| 7102 | CustomExtension: expectedContents, |
| 7103 | }, |
| 7104 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7105 | shouldFail: true, |
| 7106 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7107 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7108 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7109 | testCases = append(testCases, testCase{ |
| 7110 | testType: clientTest, |
| 7111 | name: "UnknownExtension-Client-TLS13", |
| 7112 | config: Config{ |
| 7113 | MaxVersion: VersionTLS13, |
| 7114 | Bugs: ProtocolBugs{ |
| 7115 | CustomExtension: expectedContents, |
| 7116 | }, |
| 7117 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7118 | shouldFail: true, |
| 7119 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7120 | expectedLocalError: "remote error: unsupported extension", |
| 7121 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7122 | testCases = append(testCases, testCase{ |
| 7123 | testType: clientTest, |
| 7124 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7125 | config: Config{ |
| 7126 | MaxVersion: VersionTLS13, |
| 7127 | Bugs: ProtocolBugs{ |
| 7128 | CustomUnencryptedExtension: expectedContents, |
| 7129 | }, |
| 7130 | }, |
| 7131 | shouldFail: true, |
| 7132 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7133 | // The shim must send an alert, but alerts at this point do not |
| 7134 | // get successfully decrypted by the runner. |
| 7135 | expectedLocalError: "local error: bad record MAC", |
| 7136 | }) |
| 7137 | testCases = append(testCases, testCase{ |
| 7138 | testType: clientTest, |
| 7139 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7140 | config: Config{ |
| 7141 | MaxVersion: VersionTLS13, |
| 7142 | Bugs: ProtocolBugs{ |
| 7143 | SendUnencryptedALPN: "foo", |
| 7144 | }, |
| 7145 | }, |
| 7146 | flags: []string{ |
| 7147 | "-advertise-alpn", "\x03foo\x03bar", |
| 7148 | }, |
| 7149 | shouldFail: true, |
| 7150 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7151 | // The shim must send an alert, but alerts at this point do not |
| 7152 | // get successfully decrypted by the runner. |
| 7153 | expectedLocalError: "local error: bad record MAC", |
| 7154 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7155 | |
| 7156 | // Test a known but unoffered extension from the server. |
| 7157 | testCases = append(testCases, testCase{ |
| 7158 | testType: clientTest, |
| 7159 | name: "UnofferedExtension-Client", |
| 7160 | config: Config{ |
| 7161 | MaxVersion: VersionTLS12, |
| 7162 | Bugs: ProtocolBugs{ |
| 7163 | SendALPN: "alpn", |
| 7164 | }, |
| 7165 | }, |
| 7166 | shouldFail: true, |
| 7167 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7168 | expectedLocalError: "remote error: unsupported extension", |
| 7169 | }) |
| 7170 | testCases = append(testCases, testCase{ |
| 7171 | testType: clientTest, |
| 7172 | name: "UnofferedExtension-Client-TLS13", |
| 7173 | config: Config{ |
| 7174 | MaxVersion: VersionTLS13, |
| 7175 | Bugs: ProtocolBugs{ |
| 7176 | SendALPN: "alpn", |
| 7177 | }, |
| 7178 | }, |
| 7179 | shouldFail: true, |
| 7180 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7181 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7182 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7183 | } |
| 7184 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7185 | func addRSAClientKeyExchangeTests() { |
| 7186 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7187 | testCases = append(testCases, testCase{ |
| 7188 | testType: serverTest, |
| 7189 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7190 | config: Config{ |
| 7191 | // Ensure the ClientHello version and final |
| 7192 | // version are different, to detect if the |
| 7193 | // server uses the wrong one. |
| 7194 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7195 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7196 | Bugs: ProtocolBugs{ |
| 7197 | BadRSAClientKeyExchange: bad, |
| 7198 | }, |
| 7199 | }, |
| 7200 | shouldFail: true, |
| 7201 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7202 | }) |
| 7203 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7204 | |
| 7205 | // The server must compare whatever was in ClientHello.version for the |
| 7206 | // RSA premaster. |
| 7207 | testCases = append(testCases, testCase{ |
| 7208 | testType: serverTest, |
| 7209 | name: "SendClientVersion-RSA", |
| 7210 | config: Config{ |
| 7211 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7212 | Bugs: ProtocolBugs{ |
| 7213 | SendClientVersion: 0x1234, |
| 7214 | }, |
| 7215 | }, |
| 7216 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7217 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7218 | } |
| 7219 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7220 | var testCurves = []struct { |
| 7221 | name string |
| 7222 | id CurveID |
| 7223 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7224 | {"P-256", CurveP256}, |
| 7225 | {"P-384", CurveP384}, |
| 7226 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7227 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7228 | } |
| 7229 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7230 | const bogusCurve = 0x1234 |
| 7231 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7232 | func addCurveTests() { |
| 7233 | for _, curve := range testCurves { |
| 7234 | testCases = append(testCases, testCase{ |
| 7235 | name: "CurveTest-Client-" + curve.name, |
| 7236 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7237 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7238 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7239 | CurvePreferences: []CurveID{curve.id}, |
| 7240 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7241 | flags: []string{ |
| 7242 | "-enable-all-curves", |
| 7243 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7244 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7245 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7246 | }) |
| 7247 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7248 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7249 | config: Config{ |
| 7250 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7251 | CurvePreferences: []CurveID{curve.id}, |
| 7252 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7253 | flags: []string{ |
| 7254 | "-enable-all-curves", |
| 7255 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7256 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7257 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7258 | }) |
| 7259 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7260 | testType: serverTest, |
| 7261 | name: "CurveTest-Server-" + curve.name, |
| 7262 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7263 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7264 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7265 | CurvePreferences: []CurveID{curve.id}, |
| 7266 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7267 | flags: []string{ |
| 7268 | "-enable-all-curves", |
| 7269 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7270 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7271 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7272 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7273 | testCases = append(testCases, testCase{ |
| 7274 | testType: serverTest, |
| 7275 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7276 | config: Config{ |
| 7277 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7278 | CurvePreferences: []CurveID{curve.id}, |
| 7279 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7280 | flags: []string{ |
| 7281 | "-enable-all-curves", |
| 7282 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7283 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7284 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7285 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7286 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7287 | |
| 7288 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7289 | testCases = append(testCases, testCase{ |
| 7290 | testType: serverTest, |
| 7291 | name: "UnknownCurve", |
| 7292 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7293 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7294 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7295 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7296 | }, |
| 7297 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7298 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7299 | // The server must be tolerant to bogus curves. |
| 7300 | testCases = append(testCases, testCase{ |
| 7301 | testType: serverTest, |
| 7302 | name: "UnknownCurve-TLS13", |
| 7303 | config: Config{ |
| 7304 | MaxVersion: VersionTLS13, |
| 7305 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7306 | }, |
| 7307 | }) |
| 7308 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7309 | // The server must not consider ECDHE ciphers when there are no |
| 7310 | // supported curves. |
| 7311 | testCases = append(testCases, testCase{ |
| 7312 | testType: serverTest, |
| 7313 | name: "NoSupportedCurves", |
| 7314 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7315 | MaxVersion: VersionTLS12, |
| 7316 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7317 | Bugs: ProtocolBugs{ |
| 7318 | NoSupportedCurves: true, |
| 7319 | }, |
| 7320 | }, |
| 7321 | shouldFail: true, |
| 7322 | expectedError: ":NO_SHARED_CIPHER:", |
| 7323 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7324 | testCases = append(testCases, testCase{ |
| 7325 | testType: serverTest, |
| 7326 | name: "NoSupportedCurves-TLS13", |
| 7327 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7328 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7329 | Bugs: ProtocolBugs{ |
| 7330 | NoSupportedCurves: true, |
| 7331 | }, |
| 7332 | }, |
| 7333 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7334 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7335 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7336 | |
| 7337 | // The server must fall back to another cipher when there are no |
| 7338 | // supported curves. |
| 7339 | testCases = append(testCases, testCase{ |
| 7340 | testType: serverTest, |
| 7341 | name: "NoCommonCurves", |
| 7342 | config: Config{ |
| 7343 | MaxVersion: VersionTLS12, |
| 7344 | CipherSuites: []uint16{ |
| 7345 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7346 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7347 | }, |
| 7348 | CurvePreferences: []CurveID{CurveP224}, |
| 7349 | }, |
| 7350 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7351 | }) |
| 7352 | |
| 7353 | // The client must reject bogus curves and disabled curves. |
| 7354 | testCases = append(testCases, testCase{ |
| 7355 | name: "BadECDHECurve", |
| 7356 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7357 | MaxVersion: VersionTLS12, |
| 7358 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7359 | Bugs: ProtocolBugs{ |
| 7360 | SendCurve: bogusCurve, |
| 7361 | }, |
| 7362 | }, |
| 7363 | shouldFail: true, |
| 7364 | expectedError: ":WRONG_CURVE:", |
| 7365 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7366 | testCases = append(testCases, testCase{ |
| 7367 | name: "BadECDHECurve-TLS13", |
| 7368 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7369 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7370 | Bugs: ProtocolBugs{ |
| 7371 | SendCurve: bogusCurve, |
| 7372 | }, |
| 7373 | }, |
| 7374 | shouldFail: true, |
| 7375 | expectedError: ":WRONG_CURVE:", |
| 7376 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7377 | |
| 7378 | testCases = append(testCases, testCase{ |
| 7379 | name: "UnsupportedCurve", |
| 7380 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7381 | MaxVersion: VersionTLS12, |
| 7382 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7383 | CurvePreferences: []CurveID{CurveP256}, |
| 7384 | Bugs: ProtocolBugs{ |
| 7385 | IgnorePeerCurvePreferences: true, |
| 7386 | }, |
| 7387 | }, |
| 7388 | flags: []string{"-p384-only"}, |
| 7389 | shouldFail: true, |
| 7390 | expectedError: ":WRONG_CURVE:", |
| 7391 | }) |
| 7392 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7393 | testCases = append(testCases, testCase{ |
| 7394 | // TODO(davidben): Add a TLS 1.3 version where |
| 7395 | // HelloRetryRequest requests an unsupported curve. |
| 7396 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 7397 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7398 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7399 | CurvePreferences: []CurveID{CurveP384}, |
| 7400 | Bugs: ProtocolBugs{ |
| 7401 | SendCurve: CurveP256, |
| 7402 | }, |
| 7403 | }, |
| 7404 | flags: []string{"-p384-only"}, |
| 7405 | shouldFail: true, |
| 7406 | expectedError: ":WRONG_CURVE:", |
| 7407 | }) |
| 7408 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7409 | // Test invalid curve points. |
| 7410 | testCases = append(testCases, testCase{ |
| 7411 | name: "InvalidECDHPoint-Client", |
| 7412 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7413 | MaxVersion: VersionTLS12, |
| 7414 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7415 | CurvePreferences: []CurveID{CurveP256}, |
| 7416 | Bugs: ProtocolBugs{ |
| 7417 | InvalidECDHPoint: true, |
| 7418 | }, |
| 7419 | }, |
| 7420 | shouldFail: true, |
| 7421 | expectedError: ":INVALID_ENCODING:", |
| 7422 | }) |
| 7423 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7424 | name: "InvalidECDHPoint-Client-TLS13", |
| 7425 | config: Config{ |
| 7426 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7427 | CurvePreferences: []CurveID{CurveP256}, |
| 7428 | Bugs: ProtocolBugs{ |
| 7429 | InvalidECDHPoint: true, |
| 7430 | }, |
| 7431 | }, |
| 7432 | shouldFail: true, |
| 7433 | expectedError: ":INVALID_ENCODING:", |
| 7434 | }) |
| 7435 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7436 | testType: serverTest, |
| 7437 | name: "InvalidECDHPoint-Server", |
| 7438 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7439 | MaxVersion: VersionTLS12, |
| 7440 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7441 | CurvePreferences: []CurveID{CurveP256}, |
| 7442 | Bugs: ProtocolBugs{ |
| 7443 | InvalidECDHPoint: true, |
| 7444 | }, |
| 7445 | }, |
| 7446 | shouldFail: true, |
| 7447 | expectedError: ":INVALID_ENCODING:", |
| 7448 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7449 | testCases = append(testCases, testCase{ |
| 7450 | testType: serverTest, |
| 7451 | name: "InvalidECDHPoint-Server-TLS13", |
| 7452 | config: Config{ |
| 7453 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7454 | CurvePreferences: []CurveID{CurveP256}, |
| 7455 | Bugs: ProtocolBugs{ |
| 7456 | InvalidECDHPoint: true, |
| 7457 | }, |
| 7458 | }, |
| 7459 | shouldFail: true, |
| 7460 | expectedError: ":INVALID_ENCODING:", |
| 7461 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7462 | } |
| 7463 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7464 | func addCECPQ1Tests() { |
| 7465 | testCases = append(testCases, testCase{ |
| 7466 | testType: clientTest, |
| 7467 | name: "CECPQ1-Client-BadX25519Part", |
| 7468 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7469 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7470 | MinVersion: VersionTLS12, |
| 7471 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7472 | Bugs: ProtocolBugs{ |
| 7473 | CECPQ1BadX25519Part: true, |
| 7474 | }, |
| 7475 | }, |
| 7476 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7477 | shouldFail: true, |
| 7478 | expectedLocalError: "local error: bad record MAC", |
| 7479 | }) |
| 7480 | testCases = append(testCases, testCase{ |
| 7481 | testType: clientTest, |
| 7482 | name: "CECPQ1-Client-BadNewhopePart", |
| 7483 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7484 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7485 | MinVersion: VersionTLS12, |
| 7486 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7487 | Bugs: ProtocolBugs{ |
| 7488 | CECPQ1BadNewhopePart: true, |
| 7489 | }, |
| 7490 | }, |
| 7491 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7492 | shouldFail: true, |
| 7493 | expectedLocalError: "local error: bad record MAC", |
| 7494 | }) |
| 7495 | testCases = append(testCases, testCase{ |
| 7496 | testType: serverTest, |
| 7497 | name: "CECPQ1-Server-BadX25519Part", |
| 7498 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7499 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7500 | MinVersion: VersionTLS12, |
| 7501 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7502 | Bugs: ProtocolBugs{ |
| 7503 | CECPQ1BadX25519Part: true, |
| 7504 | }, |
| 7505 | }, |
| 7506 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7507 | shouldFail: true, |
| 7508 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7509 | }) |
| 7510 | testCases = append(testCases, testCase{ |
| 7511 | testType: serverTest, |
| 7512 | name: "CECPQ1-Server-BadNewhopePart", |
| 7513 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7514 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7515 | MinVersion: VersionTLS12, |
| 7516 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7517 | Bugs: ProtocolBugs{ |
| 7518 | CECPQ1BadNewhopePart: true, |
| 7519 | }, |
| 7520 | }, |
| 7521 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7522 | shouldFail: true, |
| 7523 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7524 | }) |
| 7525 | } |
| 7526 | |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7527 | func addDHEGroupSizeTests() { |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7528 | testCases = append(testCases, testCase{ |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7529 | name: "DHEGroupSize-Client", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7530 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7531 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7532 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7533 | Bugs: ProtocolBugs{ |
| 7534 | // This is a 1234-bit prime number, generated |
| 7535 | // with: |
| 7536 | // openssl gendh 1234 | openssl asn1parse -i |
| 7537 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 7538 | }, |
| 7539 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7540 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7541 | }) |
| 7542 | testCases = append(testCases, testCase{ |
| 7543 | testType: serverTest, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7544 | name: "DHEGroupSize-Server", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7545 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7546 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7547 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7548 | }, |
| 7549 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7550 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7551 | }) |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7552 | } |
| 7553 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 7554 | func addTLS13RecordTests() { |
| 7555 | testCases = append(testCases, testCase{ |
| 7556 | name: "TLS13-RecordPadding", |
| 7557 | config: Config{ |
| 7558 | MaxVersion: VersionTLS13, |
| 7559 | MinVersion: VersionTLS13, |
| 7560 | Bugs: ProtocolBugs{ |
| 7561 | RecordPadding: 10, |
| 7562 | }, |
| 7563 | }, |
| 7564 | }) |
| 7565 | |
| 7566 | testCases = append(testCases, testCase{ |
| 7567 | name: "TLS13-EmptyRecords", |
| 7568 | config: Config{ |
| 7569 | MaxVersion: VersionTLS13, |
| 7570 | MinVersion: VersionTLS13, |
| 7571 | Bugs: ProtocolBugs{ |
| 7572 | OmitRecordContents: true, |
| 7573 | }, |
| 7574 | }, |
| 7575 | shouldFail: true, |
| 7576 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7577 | }) |
| 7578 | |
| 7579 | testCases = append(testCases, testCase{ |
| 7580 | name: "TLS13-OnlyPadding", |
| 7581 | config: Config{ |
| 7582 | MaxVersion: VersionTLS13, |
| 7583 | MinVersion: VersionTLS13, |
| 7584 | Bugs: ProtocolBugs{ |
| 7585 | OmitRecordContents: true, |
| 7586 | RecordPadding: 10, |
| 7587 | }, |
| 7588 | }, |
| 7589 | shouldFail: true, |
| 7590 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7591 | }) |
| 7592 | |
| 7593 | testCases = append(testCases, testCase{ |
| 7594 | name: "TLS13-WrongOuterRecord", |
| 7595 | config: Config{ |
| 7596 | MaxVersion: VersionTLS13, |
| 7597 | MinVersion: VersionTLS13, |
| 7598 | Bugs: ProtocolBugs{ |
| 7599 | OuterRecordType: recordTypeHandshake, |
| 7600 | }, |
| 7601 | }, |
| 7602 | shouldFail: true, |
| 7603 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 7604 | }) |
| 7605 | } |
| 7606 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 7607 | func addSessionTicketTests() { |
| 7608 | testCases = append(testCases, testCase{ |
| 7609 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 7610 | // mean the server changed its mind on sending a ticket. |
| 7611 | name: "SendEmptySessionTicket", |
| 7612 | config: Config{ |
| 7613 | MaxVersion: VersionTLS12, |
| 7614 | Bugs: ProtocolBugs{ |
| 7615 | SendEmptySessionTicket: true, |
| 7616 | }, |
| 7617 | }, |
| 7618 | flags: []string{"-expect-no-session"}, |
| 7619 | }) |
| 7620 | |
| 7621 | // Test that the server ignores unknown PSK modes. |
| 7622 | testCases = append(testCases, testCase{ |
| 7623 | testType: serverTest, |
| 7624 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 7625 | config: Config{ |
| 7626 | MaxVersion: VersionTLS13, |
| 7627 | Bugs: ProtocolBugs{ |
| 7628 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
| 7629 | SendPSKAuthModes: []byte{0x1a, pskAuthMode, 0x2a}, |
| 7630 | }, |
| 7631 | }, |
| 7632 | resumeSession: true, |
| 7633 | expectedResumeVersion: VersionTLS13, |
| 7634 | }) |
| 7635 | |
| 7636 | // Test that the server declines sessions with no matching key exchange mode. |
| 7637 | testCases = append(testCases, testCase{ |
| 7638 | testType: serverTest, |
| 7639 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 7640 | config: Config{ |
| 7641 | MaxVersion: VersionTLS13, |
| 7642 | Bugs: ProtocolBugs{ |
| 7643 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 7644 | }, |
| 7645 | }, |
| 7646 | resumeSession: true, |
| 7647 | expectResumeRejected: true, |
| 7648 | }) |
| 7649 | |
| 7650 | // Test that the server declines sessions with no matching auth mode. |
| 7651 | testCases = append(testCases, testCase{ |
| 7652 | testType: serverTest, |
| 7653 | name: "TLS13-SendBadAuthModeSessionTicket-Server", |
| 7654 | config: Config{ |
| 7655 | MaxVersion: VersionTLS13, |
| 7656 | Bugs: ProtocolBugs{ |
| 7657 | SendPSKAuthModes: []byte{0x1a}, |
| 7658 | }, |
| 7659 | }, |
| 7660 | resumeSession: true, |
| 7661 | expectResumeRejected: true, |
| 7662 | }) |
| 7663 | |
| 7664 | // Test that the client ignores unknown PSK modes. |
| 7665 | testCases = append(testCases, testCase{ |
| 7666 | testType: clientTest, |
| 7667 | name: "TLS13-SendUnknownModeSessionTicket-Client", |
| 7668 | config: Config{ |
| 7669 | MaxVersion: VersionTLS13, |
| 7670 | Bugs: ProtocolBugs{ |
| 7671 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
| 7672 | SendPSKAuthModes: []byte{0x1a, pskAuthMode, 0x2a}, |
| 7673 | }, |
| 7674 | }, |
| 7675 | resumeSession: true, |
| 7676 | expectedResumeVersion: VersionTLS13, |
| 7677 | }) |
| 7678 | |
| 7679 | // Test that the client ignores tickets with no matching key exchange mode. |
| 7680 | testCases = append(testCases, testCase{ |
| 7681 | testType: clientTest, |
| 7682 | name: "TLS13-SendBadKEModeSessionTicket-Client", |
| 7683 | config: Config{ |
| 7684 | MaxVersion: VersionTLS13, |
| 7685 | Bugs: ProtocolBugs{ |
| 7686 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 7687 | }, |
| 7688 | }, |
| 7689 | flags: []string{"-expect-no-session"}, |
| 7690 | }) |
| 7691 | |
| 7692 | // Test that the client ignores tickets with no matching auth mode. |
| 7693 | testCases = append(testCases, testCase{ |
| 7694 | testType: clientTest, |
| 7695 | name: "TLS13-SendBadAuthModeSessionTicket-Client", |
| 7696 | config: Config{ |
| 7697 | MaxVersion: VersionTLS13, |
| 7698 | Bugs: ProtocolBugs{ |
| 7699 | SendPSKAuthModes: []byte{0x1a}, |
| 7700 | }, |
| 7701 | }, |
| 7702 | flags: []string{"-expect-no-session"}, |
| 7703 | }) |
| 7704 | } |
| 7705 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7706 | func addChangeCipherSpecTests() { |
| 7707 | // Test missing ChangeCipherSpecs. |
| 7708 | testCases = append(testCases, testCase{ |
| 7709 | name: "SkipChangeCipherSpec-Client", |
| 7710 | config: Config{ |
| 7711 | MaxVersion: VersionTLS12, |
| 7712 | Bugs: ProtocolBugs{ |
| 7713 | SkipChangeCipherSpec: true, |
| 7714 | }, |
| 7715 | }, |
| 7716 | shouldFail: true, |
| 7717 | expectedError: ":UNEXPECTED_RECORD:", |
| 7718 | }) |
| 7719 | testCases = append(testCases, testCase{ |
| 7720 | testType: serverTest, |
| 7721 | name: "SkipChangeCipherSpec-Server", |
| 7722 | config: Config{ |
| 7723 | MaxVersion: VersionTLS12, |
| 7724 | Bugs: ProtocolBugs{ |
| 7725 | SkipChangeCipherSpec: true, |
| 7726 | }, |
| 7727 | }, |
| 7728 | shouldFail: true, |
| 7729 | expectedError: ":UNEXPECTED_RECORD:", |
| 7730 | }) |
| 7731 | testCases = append(testCases, testCase{ |
| 7732 | testType: serverTest, |
| 7733 | name: "SkipChangeCipherSpec-Server-NPN", |
| 7734 | config: Config{ |
| 7735 | MaxVersion: VersionTLS12, |
| 7736 | NextProtos: []string{"bar"}, |
| 7737 | Bugs: ProtocolBugs{ |
| 7738 | SkipChangeCipherSpec: true, |
| 7739 | }, |
| 7740 | }, |
| 7741 | flags: []string{ |
| 7742 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 7743 | }, |
| 7744 | shouldFail: true, |
| 7745 | expectedError: ":UNEXPECTED_RECORD:", |
| 7746 | }) |
| 7747 | |
| 7748 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 7749 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 7750 | // rejected. Test both with and without handshake packing to handle both |
| 7751 | // when the partial post-CCS message is in its own record and when it is |
| 7752 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7753 | for _, packed := range []bool{false, true} { |
| 7754 | var suffix string |
| 7755 | if packed { |
| 7756 | suffix = "-Packed" |
| 7757 | } |
| 7758 | |
| 7759 | testCases = append(testCases, testCase{ |
| 7760 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 7761 | config: Config{ |
| 7762 | MaxVersion: VersionTLS12, |
| 7763 | Bugs: ProtocolBugs{ |
| 7764 | FragmentAcrossChangeCipherSpec: true, |
| 7765 | PackHandshakeFlight: packed, |
| 7766 | }, |
| 7767 | }, |
| 7768 | shouldFail: true, |
| 7769 | expectedError: ":UNEXPECTED_RECORD:", |
| 7770 | }) |
| 7771 | testCases = append(testCases, testCase{ |
| 7772 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 7773 | config: Config{ |
| 7774 | MaxVersion: VersionTLS12, |
| 7775 | }, |
| 7776 | resumeSession: true, |
| 7777 | resumeConfig: &Config{ |
| 7778 | MaxVersion: VersionTLS12, |
| 7779 | Bugs: ProtocolBugs{ |
| 7780 | FragmentAcrossChangeCipherSpec: true, |
| 7781 | PackHandshakeFlight: packed, |
| 7782 | }, |
| 7783 | }, |
| 7784 | shouldFail: true, |
| 7785 | expectedError: ":UNEXPECTED_RECORD:", |
| 7786 | }) |
| 7787 | testCases = append(testCases, testCase{ |
| 7788 | testType: serverTest, |
| 7789 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 7790 | config: Config{ |
| 7791 | MaxVersion: VersionTLS12, |
| 7792 | Bugs: ProtocolBugs{ |
| 7793 | FragmentAcrossChangeCipherSpec: true, |
| 7794 | PackHandshakeFlight: packed, |
| 7795 | }, |
| 7796 | }, |
| 7797 | shouldFail: true, |
| 7798 | expectedError: ":UNEXPECTED_RECORD:", |
| 7799 | }) |
| 7800 | testCases = append(testCases, testCase{ |
| 7801 | testType: serverTest, |
| 7802 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 7803 | config: Config{ |
| 7804 | MaxVersion: VersionTLS12, |
| 7805 | }, |
| 7806 | resumeSession: true, |
| 7807 | resumeConfig: &Config{ |
| 7808 | MaxVersion: VersionTLS12, |
| 7809 | Bugs: ProtocolBugs{ |
| 7810 | FragmentAcrossChangeCipherSpec: true, |
| 7811 | PackHandshakeFlight: packed, |
| 7812 | }, |
| 7813 | }, |
| 7814 | shouldFail: true, |
| 7815 | expectedError: ":UNEXPECTED_RECORD:", |
| 7816 | }) |
| 7817 | testCases = append(testCases, testCase{ |
| 7818 | testType: serverTest, |
| 7819 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 7820 | config: Config{ |
| 7821 | MaxVersion: VersionTLS12, |
| 7822 | NextProtos: []string{"bar"}, |
| 7823 | Bugs: ProtocolBugs{ |
| 7824 | FragmentAcrossChangeCipherSpec: true, |
| 7825 | PackHandshakeFlight: packed, |
| 7826 | }, |
| 7827 | }, |
| 7828 | flags: []string{ |
| 7829 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 7830 | }, |
| 7831 | shouldFail: true, |
| 7832 | expectedError: ":UNEXPECTED_RECORD:", |
| 7833 | }) |
| 7834 | } |
| 7835 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 7836 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 7837 | // messages in the handshake queue. Do this by testing the server |
| 7838 | // reading the client Finished, reversing the flight so Finished comes |
| 7839 | // first. |
| 7840 | testCases = append(testCases, testCase{ |
| 7841 | protocol: dtls, |
| 7842 | testType: serverTest, |
| 7843 | name: "SendUnencryptedFinished-DTLS", |
| 7844 | config: Config{ |
| 7845 | MaxVersion: VersionTLS12, |
| 7846 | Bugs: ProtocolBugs{ |
| 7847 | SendUnencryptedFinished: true, |
| 7848 | ReverseHandshakeFragments: true, |
| 7849 | }, |
| 7850 | }, |
| 7851 | shouldFail: true, |
| 7852 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7853 | }) |
| 7854 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7855 | // Test synchronization between encryption changes and the handshake in |
| 7856 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 7857 | testCases = append(testCases, testCase{ |
| 7858 | name: "PartialEncryptedExtensionsWithServerHello", |
| 7859 | config: Config{ |
| 7860 | MaxVersion: VersionTLS13, |
| 7861 | Bugs: ProtocolBugs{ |
| 7862 | PartialEncryptedExtensionsWithServerHello: true, |
| 7863 | }, |
| 7864 | }, |
| 7865 | shouldFail: true, |
| 7866 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7867 | }) |
| 7868 | testCases = append(testCases, testCase{ |
| 7869 | testType: serverTest, |
| 7870 | name: "PartialClientFinishedWithClientHello", |
| 7871 | config: Config{ |
| 7872 | MaxVersion: VersionTLS13, |
| 7873 | Bugs: ProtocolBugs{ |
| 7874 | PartialClientFinishedWithClientHello: true, |
| 7875 | }, |
| 7876 | }, |
| 7877 | shouldFail: true, |
| 7878 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7879 | }) |
| 7880 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7881 | // Test that early ChangeCipherSpecs are handled correctly. |
| 7882 | testCases = append(testCases, testCase{ |
| 7883 | testType: serverTest, |
| 7884 | name: "EarlyChangeCipherSpec-server-1", |
| 7885 | config: Config{ |
| 7886 | MaxVersion: VersionTLS12, |
| 7887 | Bugs: ProtocolBugs{ |
| 7888 | EarlyChangeCipherSpec: 1, |
| 7889 | }, |
| 7890 | }, |
| 7891 | shouldFail: true, |
| 7892 | expectedError: ":UNEXPECTED_RECORD:", |
| 7893 | }) |
| 7894 | testCases = append(testCases, testCase{ |
| 7895 | testType: serverTest, |
| 7896 | name: "EarlyChangeCipherSpec-server-2", |
| 7897 | config: Config{ |
| 7898 | MaxVersion: VersionTLS12, |
| 7899 | Bugs: ProtocolBugs{ |
| 7900 | EarlyChangeCipherSpec: 2, |
| 7901 | }, |
| 7902 | }, |
| 7903 | shouldFail: true, |
| 7904 | expectedError: ":UNEXPECTED_RECORD:", |
| 7905 | }) |
| 7906 | testCases = append(testCases, testCase{ |
| 7907 | protocol: dtls, |
| 7908 | name: "StrayChangeCipherSpec", |
| 7909 | config: Config{ |
| 7910 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 7911 | // that stray ChangeCipherSpec messages are |
| 7912 | // rejected. |
| 7913 | MaxVersion: VersionTLS12, |
| 7914 | Bugs: ProtocolBugs{ |
| 7915 | StrayChangeCipherSpec: true, |
| 7916 | }, |
| 7917 | }, |
| 7918 | }) |
| 7919 | |
| 7920 | // Test that the contents of ChangeCipherSpec are checked. |
| 7921 | testCases = append(testCases, testCase{ |
| 7922 | name: "BadChangeCipherSpec-1", |
| 7923 | config: Config{ |
| 7924 | MaxVersion: VersionTLS12, |
| 7925 | Bugs: ProtocolBugs{ |
| 7926 | BadChangeCipherSpec: []byte{2}, |
| 7927 | }, |
| 7928 | }, |
| 7929 | shouldFail: true, |
| 7930 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7931 | }) |
| 7932 | testCases = append(testCases, testCase{ |
| 7933 | name: "BadChangeCipherSpec-2", |
| 7934 | config: Config{ |
| 7935 | MaxVersion: VersionTLS12, |
| 7936 | Bugs: ProtocolBugs{ |
| 7937 | BadChangeCipherSpec: []byte{1, 1}, |
| 7938 | }, |
| 7939 | }, |
| 7940 | shouldFail: true, |
| 7941 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7942 | }) |
| 7943 | testCases = append(testCases, testCase{ |
| 7944 | protocol: dtls, |
| 7945 | name: "BadChangeCipherSpec-DTLS-1", |
| 7946 | config: Config{ |
| 7947 | MaxVersion: VersionTLS12, |
| 7948 | Bugs: ProtocolBugs{ |
| 7949 | BadChangeCipherSpec: []byte{2}, |
| 7950 | }, |
| 7951 | }, |
| 7952 | shouldFail: true, |
| 7953 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7954 | }) |
| 7955 | testCases = append(testCases, testCase{ |
| 7956 | protocol: dtls, |
| 7957 | name: "BadChangeCipherSpec-DTLS-2", |
| 7958 | config: Config{ |
| 7959 | MaxVersion: VersionTLS12, |
| 7960 | Bugs: ProtocolBugs{ |
| 7961 | BadChangeCipherSpec: []byte{1, 1}, |
| 7962 | }, |
| 7963 | }, |
| 7964 | shouldFail: true, |
| 7965 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7966 | }) |
| 7967 | } |
| 7968 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7969 | type perMessageTest struct { |
| 7970 | messageType uint8 |
| 7971 | test testCase |
| 7972 | } |
| 7973 | |
| 7974 | // makePerMessageTests returns a series of test templates which cover each |
| 7975 | // message in the TLS handshake. These may be used with bugs like |
| 7976 | // WrongMessageType to fully test a per-message bug. |
| 7977 | func makePerMessageTests() []perMessageTest { |
| 7978 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7979 | for _, protocol := range []protocol{tls, dtls} { |
| 7980 | var suffix string |
| 7981 | if protocol == dtls { |
| 7982 | suffix = "-DTLS" |
| 7983 | } |
| 7984 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7985 | ret = append(ret, perMessageTest{ |
| 7986 | messageType: typeClientHello, |
| 7987 | test: testCase{ |
| 7988 | protocol: protocol, |
| 7989 | testType: serverTest, |
| 7990 | name: "ClientHello" + suffix, |
| 7991 | config: Config{ |
| 7992 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7993 | }, |
| 7994 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7995 | }) |
| 7996 | |
| 7997 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7998 | ret = append(ret, perMessageTest{ |
| 7999 | messageType: typeHelloVerifyRequest, |
| 8000 | test: testCase{ |
| 8001 | protocol: protocol, |
| 8002 | name: "HelloVerifyRequest" + suffix, |
| 8003 | config: Config{ |
| 8004 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8005 | }, |
| 8006 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8007 | }) |
| 8008 | } |
| 8009 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8010 | ret = append(ret, perMessageTest{ |
| 8011 | messageType: typeServerHello, |
| 8012 | test: testCase{ |
| 8013 | protocol: protocol, |
| 8014 | name: "ServerHello" + suffix, |
| 8015 | config: Config{ |
| 8016 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8017 | }, |
| 8018 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8019 | }) |
| 8020 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8021 | ret = append(ret, perMessageTest{ |
| 8022 | messageType: typeCertificate, |
| 8023 | test: testCase{ |
| 8024 | protocol: protocol, |
| 8025 | name: "ServerCertificate" + suffix, |
| 8026 | config: Config{ |
| 8027 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8028 | }, |
| 8029 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8030 | }) |
| 8031 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8032 | ret = append(ret, perMessageTest{ |
| 8033 | messageType: typeCertificateStatus, |
| 8034 | test: testCase{ |
| 8035 | protocol: protocol, |
| 8036 | name: "CertificateStatus" + suffix, |
| 8037 | config: Config{ |
| 8038 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8039 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8040 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8041 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8042 | }) |
| 8043 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8044 | ret = append(ret, perMessageTest{ |
| 8045 | messageType: typeServerKeyExchange, |
| 8046 | test: testCase{ |
| 8047 | protocol: protocol, |
| 8048 | name: "ServerKeyExchange" + suffix, |
| 8049 | config: Config{ |
| 8050 | MaxVersion: VersionTLS12, |
| 8051 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8052 | }, |
| 8053 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8054 | }) |
| 8055 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8056 | ret = append(ret, perMessageTest{ |
| 8057 | messageType: typeCertificateRequest, |
| 8058 | test: testCase{ |
| 8059 | protocol: protocol, |
| 8060 | name: "CertificateRequest" + suffix, |
| 8061 | config: Config{ |
| 8062 | MaxVersion: VersionTLS12, |
| 8063 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8064 | }, |
| 8065 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8066 | }) |
| 8067 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8068 | ret = append(ret, perMessageTest{ |
| 8069 | messageType: typeServerHelloDone, |
| 8070 | test: testCase{ |
| 8071 | protocol: protocol, |
| 8072 | name: "ServerHelloDone" + suffix, |
| 8073 | config: Config{ |
| 8074 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8075 | }, |
| 8076 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8077 | }) |
| 8078 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8079 | ret = append(ret, perMessageTest{ |
| 8080 | messageType: typeCertificate, |
| 8081 | test: testCase{ |
| 8082 | testType: serverTest, |
| 8083 | protocol: protocol, |
| 8084 | name: "ClientCertificate" + suffix, |
| 8085 | config: Config{ |
| 8086 | Certificates: []Certificate{rsaCertificate}, |
| 8087 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8088 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8089 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8090 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8091 | }) |
| 8092 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8093 | ret = append(ret, perMessageTest{ |
| 8094 | messageType: typeCertificateVerify, |
| 8095 | test: testCase{ |
| 8096 | testType: serverTest, |
| 8097 | protocol: protocol, |
| 8098 | name: "CertificateVerify" + suffix, |
| 8099 | config: Config{ |
| 8100 | Certificates: []Certificate{rsaCertificate}, |
| 8101 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8102 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8103 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8104 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8105 | }) |
| 8106 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8107 | ret = append(ret, perMessageTest{ |
| 8108 | messageType: typeClientKeyExchange, |
| 8109 | test: testCase{ |
| 8110 | testType: serverTest, |
| 8111 | protocol: protocol, |
| 8112 | name: "ClientKeyExchange" + suffix, |
| 8113 | config: Config{ |
| 8114 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8115 | }, |
| 8116 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8117 | }) |
| 8118 | |
| 8119 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8120 | ret = append(ret, perMessageTest{ |
| 8121 | messageType: typeNextProtocol, |
| 8122 | test: testCase{ |
| 8123 | testType: serverTest, |
| 8124 | protocol: protocol, |
| 8125 | name: "NextProtocol" + suffix, |
| 8126 | config: Config{ |
| 8127 | MaxVersion: VersionTLS12, |
| 8128 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8129 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8130 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8131 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8132 | }) |
| 8133 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8134 | ret = append(ret, perMessageTest{ |
| 8135 | messageType: typeChannelID, |
| 8136 | test: testCase{ |
| 8137 | testType: serverTest, |
| 8138 | protocol: protocol, |
| 8139 | name: "ChannelID" + suffix, |
| 8140 | config: Config{ |
| 8141 | MaxVersion: VersionTLS12, |
| 8142 | ChannelID: channelIDKey, |
| 8143 | }, |
| 8144 | flags: []string{ |
| 8145 | "-expect-channel-id", |
| 8146 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8147 | }, |
| 8148 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8149 | }) |
| 8150 | } |
| 8151 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8152 | ret = append(ret, perMessageTest{ |
| 8153 | messageType: typeFinished, |
| 8154 | test: testCase{ |
| 8155 | testType: serverTest, |
| 8156 | protocol: protocol, |
| 8157 | name: "ClientFinished" + suffix, |
| 8158 | config: Config{ |
| 8159 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8160 | }, |
| 8161 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8162 | }) |
| 8163 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8164 | ret = append(ret, perMessageTest{ |
| 8165 | messageType: typeNewSessionTicket, |
| 8166 | test: testCase{ |
| 8167 | protocol: protocol, |
| 8168 | name: "NewSessionTicket" + suffix, |
| 8169 | config: Config{ |
| 8170 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8171 | }, |
| 8172 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8173 | }) |
| 8174 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8175 | ret = append(ret, perMessageTest{ |
| 8176 | messageType: typeFinished, |
| 8177 | test: testCase{ |
| 8178 | protocol: protocol, |
| 8179 | name: "ServerFinished" + suffix, |
| 8180 | config: Config{ |
| 8181 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8182 | }, |
| 8183 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8184 | }) |
| 8185 | |
| 8186 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8187 | |
| 8188 | ret = append(ret, perMessageTest{ |
| 8189 | messageType: typeClientHello, |
| 8190 | test: testCase{ |
| 8191 | testType: serverTest, |
| 8192 | name: "TLS13-ClientHello", |
| 8193 | config: Config{ |
| 8194 | MaxVersion: VersionTLS13, |
| 8195 | }, |
| 8196 | }, |
| 8197 | }) |
| 8198 | |
| 8199 | ret = append(ret, perMessageTest{ |
| 8200 | messageType: typeServerHello, |
| 8201 | test: testCase{ |
| 8202 | name: "TLS13-ServerHello", |
| 8203 | config: Config{ |
| 8204 | MaxVersion: VersionTLS13, |
| 8205 | }, |
| 8206 | }, |
| 8207 | }) |
| 8208 | |
| 8209 | ret = append(ret, perMessageTest{ |
| 8210 | messageType: typeEncryptedExtensions, |
| 8211 | test: testCase{ |
| 8212 | name: "TLS13-EncryptedExtensions", |
| 8213 | config: Config{ |
| 8214 | MaxVersion: VersionTLS13, |
| 8215 | }, |
| 8216 | }, |
| 8217 | }) |
| 8218 | |
| 8219 | ret = append(ret, perMessageTest{ |
| 8220 | messageType: typeCertificateRequest, |
| 8221 | test: testCase{ |
| 8222 | name: "TLS13-CertificateRequest", |
| 8223 | config: Config{ |
| 8224 | MaxVersion: VersionTLS13, |
| 8225 | ClientAuth: RequireAnyClientCert, |
| 8226 | }, |
| 8227 | }, |
| 8228 | }) |
| 8229 | |
| 8230 | ret = append(ret, perMessageTest{ |
| 8231 | messageType: typeCertificate, |
| 8232 | test: testCase{ |
| 8233 | name: "TLS13-ServerCertificate", |
| 8234 | config: Config{ |
| 8235 | MaxVersion: VersionTLS13, |
| 8236 | }, |
| 8237 | }, |
| 8238 | }) |
| 8239 | |
| 8240 | ret = append(ret, perMessageTest{ |
| 8241 | messageType: typeCertificateVerify, |
| 8242 | test: testCase{ |
| 8243 | name: "TLS13-ServerCertificateVerify", |
| 8244 | config: Config{ |
| 8245 | MaxVersion: VersionTLS13, |
| 8246 | }, |
| 8247 | }, |
| 8248 | }) |
| 8249 | |
| 8250 | ret = append(ret, perMessageTest{ |
| 8251 | messageType: typeFinished, |
| 8252 | test: testCase{ |
| 8253 | name: "TLS13-ServerFinished", |
| 8254 | config: Config{ |
| 8255 | MaxVersion: VersionTLS13, |
| 8256 | }, |
| 8257 | }, |
| 8258 | }) |
| 8259 | |
| 8260 | ret = append(ret, perMessageTest{ |
| 8261 | messageType: typeCertificate, |
| 8262 | test: testCase{ |
| 8263 | testType: serverTest, |
| 8264 | name: "TLS13-ClientCertificate", |
| 8265 | config: Config{ |
| 8266 | Certificates: []Certificate{rsaCertificate}, |
| 8267 | MaxVersion: VersionTLS13, |
| 8268 | }, |
| 8269 | flags: []string{"-require-any-client-certificate"}, |
| 8270 | }, |
| 8271 | }) |
| 8272 | |
| 8273 | ret = append(ret, perMessageTest{ |
| 8274 | messageType: typeCertificateVerify, |
| 8275 | test: testCase{ |
| 8276 | testType: serverTest, |
| 8277 | name: "TLS13-ClientCertificateVerify", |
| 8278 | config: Config{ |
| 8279 | Certificates: []Certificate{rsaCertificate}, |
| 8280 | MaxVersion: VersionTLS13, |
| 8281 | }, |
| 8282 | flags: []string{"-require-any-client-certificate"}, |
| 8283 | }, |
| 8284 | }) |
| 8285 | |
| 8286 | ret = append(ret, perMessageTest{ |
| 8287 | messageType: typeFinished, |
| 8288 | test: testCase{ |
| 8289 | testType: serverTest, |
| 8290 | name: "TLS13-ClientFinished", |
| 8291 | config: Config{ |
| 8292 | MaxVersion: VersionTLS13, |
| 8293 | }, |
| 8294 | }, |
| 8295 | }) |
| 8296 | |
| 8297 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8298 | } |
| 8299 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8300 | func addWrongMessageTypeTests() { |
| 8301 | for _, t := range makePerMessageTests() { |
| 8302 | t.test.name = "WrongMessageType-" + t.test.name |
| 8303 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 8304 | t.test.shouldFail = true |
| 8305 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 8306 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8307 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8308 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8309 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8310 | // an unencrypted alert while the server expects |
| 8311 | // encryption, so the alert is not readable by runner. |
| 8312 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8313 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8314 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8315 | testCases = append(testCases, t.test) |
| 8316 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8317 | } |
| 8318 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8319 | func addTrailingMessageDataTests() { |
| 8320 | for _, t := range makePerMessageTests() { |
| 8321 | t.test.name = "TrailingMessageData-" + t.test.name |
| 8322 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 8323 | t.test.shouldFail = true |
| 8324 | t.test.expectedError = ":DECODE_ERROR:" |
| 8325 | t.test.expectedLocalError = "remote error: error decoding message" |
| 8326 | |
| 8327 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8328 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8329 | // an unencrypted alert while the server expects |
| 8330 | // encryption, so the alert is not readable by runner. |
| 8331 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8332 | } |
| 8333 | |
| 8334 | if t.messageType == typeFinished { |
| 8335 | // Bad Finished messages read as the verify data having |
| 8336 | // the wrong length. |
| 8337 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 8338 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 8339 | } |
| 8340 | |
| 8341 | testCases = append(testCases, t.test) |
| 8342 | } |
| 8343 | } |
| 8344 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8345 | func addTLS13HandshakeTests() { |
| 8346 | testCases = append(testCases, testCase{ |
| 8347 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8348 | name: "NegotiatePSKResumption-TLS13", |
| 8349 | config: Config{ |
| 8350 | MaxVersion: VersionTLS13, |
| 8351 | Bugs: ProtocolBugs{ |
| 8352 | NegotiatePSKResumption: true, |
| 8353 | }, |
| 8354 | }, |
| 8355 | resumeSession: true, |
| 8356 | shouldFail: true, |
| 8357 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8358 | }) |
| 8359 | |
| 8360 | testCases = append(testCases, testCase{ |
| 8361 | testType: clientTest, |
| 8362 | name: "OmitServerHelloSignatureAlgorithms", |
| 8363 | config: Config{ |
| 8364 | MaxVersion: VersionTLS13, |
| 8365 | Bugs: ProtocolBugs{ |
| 8366 | OmitServerHelloSignatureAlgorithms: true, |
| 8367 | }, |
| 8368 | }, |
| 8369 | shouldFail: true, |
| 8370 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8371 | }) |
| 8372 | |
| 8373 | testCases = append(testCases, testCase{ |
| 8374 | testType: clientTest, |
| 8375 | name: "IncludeServerHelloSignatureAlgorithms", |
| 8376 | config: Config{ |
| 8377 | MaxVersion: VersionTLS13, |
| 8378 | Bugs: ProtocolBugs{ |
| 8379 | IncludeServerHelloSignatureAlgorithms: true, |
| 8380 | }, |
| 8381 | }, |
| 8382 | resumeSession: true, |
| 8383 | shouldFail: true, |
| 8384 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8385 | }) |
| 8386 | |
| 8387 | testCases = append(testCases, testCase{ |
| 8388 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8389 | name: "MissingKeyShare-Client", |
| 8390 | config: Config{ |
| 8391 | MaxVersion: VersionTLS13, |
| 8392 | Bugs: ProtocolBugs{ |
| 8393 | MissingKeyShare: true, |
| 8394 | }, |
| 8395 | }, |
| 8396 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8397 | expectedError: ":UNEXPECTED_EXTENSION:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8398 | }) |
| 8399 | |
| 8400 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8401 | testType: serverTest, |
| 8402 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8403 | config: Config{ |
| 8404 | MaxVersion: VersionTLS13, |
| 8405 | Bugs: ProtocolBugs{ |
| 8406 | MissingKeyShare: true, |
| 8407 | }, |
| 8408 | }, |
| 8409 | shouldFail: true, |
| 8410 | expectedError: ":MISSING_KEY_SHARE:", |
| 8411 | }) |
| 8412 | |
| 8413 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8414 | testType: serverTest, |
| 8415 | name: "DuplicateKeyShares", |
| 8416 | config: Config{ |
| 8417 | MaxVersion: VersionTLS13, |
| 8418 | Bugs: ProtocolBugs{ |
| 8419 | DuplicateKeyShares: true, |
| 8420 | }, |
| 8421 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 8422 | shouldFail: true, |
| 8423 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8424 | }) |
| 8425 | |
| 8426 | testCases = append(testCases, testCase{ |
| 8427 | testType: clientTest, |
| 8428 | name: "EmptyEncryptedExtensions", |
| 8429 | config: Config{ |
| 8430 | MaxVersion: VersionTLS13, |
| 8431 | Bugs: ProtocolBugs{ |
| 8432 | EmptyEncryptedExtensions: true, |
| 8433 | }, |
| 8434 | }, |
| 8435 | shouldFail: true, |
| 8436 | expectedLocalError: "remote error: error decoding message", |
| 8437 | }) |
| 8438 | |
| 8439 | testCases = append(testCases, testCase{ |
| 8440 | testType: clientTest, |
| 8441 | name: "EncryptedExtensionsWithKeyShare", |
| 8442 | config: Config{ |
| 8443 | MaxVersion: VersionTLS13, |
| 8444 | Bugs: ProtocolBugs{ |
| 8445 | EncryptedExtensionsWithKeyShare: true, |
| 8446 | }, |
| 8447 | }, |
| 8448 | shouldFail: true, |
| 8449 | expectedLocalError: "remote error: unsupported extension", |
| 8450 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8451 | |
| 8452 | testCases = append(testCases, testCase{ |
| 8453 | testType: serverTest, |
| 8454 | name: "SendHelloRetryRequest", |
| 8455 | config: Config{ |
| 8456 | MaxVersion: VersionTLS13, |
| 8457 | // Require a HelloRetryRequest for every curve. |
| 8458 | DefaultCurves: []CurveID{}, |
| 8459 | }, |
| 8460 | expectedCurveID: CurveX25519, |
| 8461 | }) |
| 8462 | |
| 8463 | testCases = append(testCases, testCase{ |
| 8464 | testType: serverTest, |
| 8465 | name: "SendHelloRetryRequest-2", |
| 8466 | config: Config{ |
| 8467 | MaxVersion: VersionTLS13, |
| 8468 | DefaultCurves: []CurveID{CurveP384}, |
| 8469 | }, |
| 8470 | // Although the ClientHello did not predict our preferred curve, |
| 8471 | // we always select it whether it is predicted or not. |
| 8472 | expectedCurveID: CurveX25519, |
| 8473 | }) |
| 8474 | |
| 8475 | testCases = append(testCases, testCase{ |
| 8476 | name: "UnknownCurve-HelloRetryRequest", |
| 8477 | config: Config{ |
| 8478 | MaxVersion: VersionTLS13, |
| 8479 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8480 | CurvePreferences: []CurveID{CurveP384}, |
| 8481 | Bugs: ProtocolBugs{ |
| 8482 | SendHelloRetryRequestCurve: bogusCurve, |
| 8483 | }, |
| 8484 | }, |
| 8485 | shouldFail: true, |
| 8486 | expectedError: ":WRONG_CURVE:", |
| 8487 | }) |
| 8488 | |
| 8489 | testCases = append(testCases, testCase{ |
| 8490 | name: "DisabledCurve-HelloRetryRequest", |
| 8491 | config: Config{ |
| 8492 | MaxVersion: VersionTLS13, |
| 8493 | CurvePreferences: []CurveID{CurveP256}, |
| 8494 | Bugs: ProtocolBugs{ |
| 8495 | IgnorePeerCurvePreferences: true, |
| 8496 | }, |
| 8497 | }, |
| 8498 | flags: []string{"-p384-only"}, |
| 8499 | shouldFail: true, |
| 8500 | expectedError: ":WRONG_CURVE:", |
| 8501 | }) |
| 8502 | |
| 8503 | testCases = append(testCases, testCase{ |
| 8504 | name: "UnnecessaryHelloRetryRequest", |
| 8505 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame^] | 8506 | MaxVersion: VersionTLS13, |
| 8507 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8508 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame^] | 8509 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8510 | }, |
| 8511 | }, |
| 8512 | shouldFail: true, |
| 8513 | expectedError: ":WRONG_CURVE:", |
| 8514 | }) |
| 8515 | |
| 8516 | testCases = append(testCases, testCase{ |
| 8517 | name: "SecondHelloRetryRequest", |
| 8518 | config: Config{ |
| 8519 | MaxVersion: VersionTLS13, |
| 8520 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8521 | CurvePreferences: []CurveID{CurveP384}, |
| 8522 | Bugs: ProtocolBugs{ |
| 8523 | SecondHelloRetryRequest: true, |
| 8524 | }, |
| 8525 | }, |
| 8526 | shouldFail: true, |
| 8527 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 8528 | }) |
| 8529 | |
| 8530 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame^] | 8531 | name: "HelloRetryRequest-Empty", |
| 8532 | config: Config{ |
| 8533 | MaxVersion: VersionTLS13, |
| 8534 | Bugs: ProtocolBugs{ |
| 8535 | AlwaysSendHelloRetryRequest: true, |
| 8536 | }, |
| 8537 | }, |
| 8538 | shouldFail: true, |
| 8539 | expectedError: ":DECODE_ERROR:", |
| 8540 | }) |
| 8541 | |
| 8542 | testCases = append(testCases, testCase{ |
| 8543 | name: "HelloRetryRequest-DuplicateCurve", |
| 8544 | config: Config{ |
| 8545 | MaxVersion: VersionTLS13, |
| 8546 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 8547 | // configuration. Assert this ExpectMissingKeyShare. |
| 8548 | CurvePreferences: []CurveID{CurveP384}, |
| 8549 | Bugs: ProtocolBugs{ |
| 8550 | ExpectMissingKeyShare: true, |
| 8551 | DuplicateHelloRetryRequestExtensions: true, |
| 8552 | }, |
| 8553 | }, |
| 8554 | shouldFail: true, |
| 8555 | expectedError: ":DUPLICATE_EXTENSION:", |
| 8556 | expectedLocalError: "remote error: illegal parameter", |
| 8557 | }) |
| 8558 | |
| 8559 | testCases = append(testCases, testCase{ |
| 8560 | name: "HelloRetryRequest-Cookie", |
| 8561 | config: Config{ |
| 8562 | MaxVersion: VersionTLS13, |
| 8563 | Bugs: ProtocolBugs{ |
| 8564 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 8565 | }, |
| 8566 | }, |
| 8567 | }) |
| 8568 | |
| 8569 | testCases = append(testCases, testCase{ |
| 8570 | name: "HelloRetryRequest-DuplicateCookie", |
| 8571 | config: Config{ |
| 8572 | MaxVersion: VersionTLS13, |
| 8573 | Bugs: ProtocolBugs{ |
| 8574 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 8575 | DuplicateHelloRetryRequestExtensions: true, |
| 8576 | }, |
| 8577 | }, |
| 8578 | shouldFail: true, |
| 8579 | expectedError: ":DUPLICATE_EXTENSION:", |
| 8580 | expectedLocalError: "remote error: illegal parameter", |
| 8581 | }) |
| 8582 | |
| 8583 | testCases = append(testCases, testCase{ |
| 8584 | name: "HelloRetryRequest-EmptyCookie", |
| 8585 | config: Config{ |
| 8586 | MaxVersion: VersionTLS13, |
| 8587 | Bugs: ProtocolBugs{ |
| 8588 | SendHelloRetryRequestCookie: []byte{}, |
| 8589 | }, |
| 8590 | }, |
| 8591 | shouldFail: true, |
| 8592 | expectedError: ":DECODE_ERROR:", |
| 8593 | }) |
| 8594 | |
| 8595 | testCases = append(testCases, testCase{ |
| 8596 | name: "HelloRetryRequest-Cookie-Curve", |
| 8597 | config: Config{ |
| 8598 | MaxVersion: VersionTLS13, |
| 8599 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8600 | CurvePreferences: []CurveID{CurveP384}, |
| 8601 | Bugs: ProtocolBugs{ |
| 8602 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 8603 | ExpectMissingKeyShare: true, |
| 8604 | }, |
| 8605 | }, |
| 8606 | }) |
| 8607 | |
| 8608 | testCases = append(testCases, testCase{ |
| 8609 | name: "HelloRetryRequest-Unknown", |
| 8610 | config: Config{ |
| 8611 | MaxVersion: VersionTLS13, |
| 8612 | Bugs: ProtocolBugs{ |
| 8613 | CustomHelloRetryRequestExtension: "extension", |
| 8614 | }, |
| 8615 | }, |
| 8616 | shouldFail: true, |
| 8617 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8618 | expectedLocalError: "remote error: unsupported extension", |
| 8619 | }) |
| 8620 | |
| 8621 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8622 | testType: serverTest, |
| 8623 | name: "SecondClientHelloMissingKeyShare", |
| 8624 | config: Config{ |
| 8625 | MaxVersion: VersionTLS13, |
| 8626 | DefaultCurves: []CurveID{}, |
| 8627 | Bugs: ProtocolBugs{ |
| 8628 | SecondClientHelloMissingKeyShare: true, |
| 8629 | }, |
| 8630 | }, |
| 8631 | shouldFail: true, |
| 8632 | expectedError: ":MISSING_KEY_SHARE:", |
| 8633 | }) |
| 8634 | |
| 8635 | testCases = append(testCases, testCase{ |
| 8636 | testType: serverTest, |
| 8637 | name: "SecondClientHelloWrongCurve", |
| 8638 | config: Config{ |
| 8639 | MaxVersion: VersionTLS13, |
| 8640 | DefaultCurves: []CurveID{}, |
| 8641 | Bugs: ProtocolBugs{ |
| 8642 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 8643 | }, |
| 8644 | }, |
| 8645 | shouldFail: true, |
| 8646 | expectedError: ":WRONG_CURVE:", |
| 8647 | }) |
| 8648 | |
| 8649 | testCases = append(testCases, testCase{ |
| 8650 | name: "HelloRetryRequestVersionMismatch", |
| 8651 | config: Config{ |
| 8652 | MaxVersion: VersionTLS13, |
| 8653 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8654 | CurvePreferences: []CurveID{CurveP384}, |
| 8655 | Bugs: ProtocolBugs{ |
| 8656 | SendServerHelloVersion: 0x0305, |
| 8657 | }, |
| 8658 | }, |
| 8659 | shouldFail: true, |
| 8660 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 8661 | }) |
| 8662 | |
| 8663 | testCases = append(testCases, testCase{ |
| 8664 | name: "HelloRetryRequestCurveMismatch", |
| 8665 | config: Config{ |
| 8666 | MaxVersion: VersionTLS13, |
| 8667 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8668 | CurvePreferences: []CurveID{CurveP384}, |
| 8669 | Bugs: ProtocolBugs{ |
| 8670 | // Send P-384 (correct) in the HelloRetryRequest. |
| 8671 | SendHelloRetryRequestCurve: CurveP384, |
| 8672 | // But send P-256 in the ServerHello. |
| 8673 | SendCurve: CurveP256, |
| 8674 | }, |
| 8675 | }, |
| 8676 | shouldFail: true, |
| 8677 | expectedError: ":WRONG_CURVE:", |
| 8678 | }) |
| 8679 | |
| 8680 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 8681 | // without sending it. |
| 8682 | testCases = append(testCases, testCase{ |
| 8683 | name: "SkipHelloRetryRequest", |
| 8684 | config: Config{ |
| 8685 | MaxVersion: VersionTLS13, |
| 8686 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8687 | CurvePreferences: []CurveID{CurveP384}, |
| 8688 | Bugs: ProtocolBugs{ |
| 8689 | SkipHelloRetryRequest: true, |
| 8690 | }, |
| 8691 | }, |
| 8692 | shouldFail: true, |
| 8693 | expectedError: ":WRONG_CURVE:", |
| 8694 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 8695 | |
| 8696 | testCases = append(testCases, testCase{ |
| 8697 | name: "TLS13-RequestContextInHandshake", |
| 8698 | config: Config{ |
| 8699 | MaxVersion: VersionTLS13, |
| 8700 | MinVersion: VersionTLS13, |
| 8701 | ClientAuth: RequireAnyClientCert, |
| 8702 | Bugs: ProtocolBugs{ |
| 8703 | SendRequestContext: []byte("request context"), |
| 8704 | }, |
| 8705 | }, |
| 8706 | flags: []string{ |
| 8707 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8708 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8709 | }, |
| 8710 | shouldFail: true, |
| 8711 | expectedError: ":DECODE_ERROR:", |
| 8712 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 8713 | |
| 8714 | testCases = append(testCases, testCase{ |
| 8715 | testType: serverTest, |
| 8716 | name: "TLS13-TrailingKeyShareData", |
| 8717 | config: Config{ |
| 8718 | MaxVersion: VersionTLS13, |
| 8719 | Bugs: ProtocolBugs{ |
| 8720 | TrailingKeyShareData: true, |
| 8721 | }, |
| 8722 | }, |
| 8723 | shouldFail: true, |
| 8724 | expectedError: ":DECODE_ERROR:", |
| 8725 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 8726 | |
| 8727 | testCases = append(testCases, testCase{ |
| 8728 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 8729 | config: Config{ |
| 8730 | MaxVersion: VersionTLS13, |
| 8731 | Bugs: ProtocolBugs{ |
| 8732 | AlwaysSelectPSKIdentity: true, |
| 8733 | }, |
| 8734 | }, |
| 8735 | shouldFail: true, |
| 8736 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8737 | }) |
| 8738 | |
| 8739 | testCases = append(testCases, testCase{ |
| 8740 | name: "TLS13-InvalidPSKIdentity", |
| 8741 | config: Config{ |
| 8742 | MaxVersion: VersionTLS13, |
| 8743 | Bugs: ProtocolBugs{ |
| 8744 | SelectPSKIdentityOnResume: 1, |
| 8745 | }, |
| 8746 | }, |
| 8747 | resumeSession: true, |
| 8748 | shouldFail: true, |
| 8749 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 8750 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 8751 | |
| 8752 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 8753 | testCases = append(testCases, testCase{ |
| 8754 | name: "TLS13-CustomTicketExtension", |
| 8755 | config: Config{ |
| 8756 | MaxVersion: VersionTLS13, |
| 8757 | Bugs: ProtocolBugs{ |
| 8758 | CustomTicketExtension: "1234", |
| 8759 | }, |
| 8760 | }, |
| 8761 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8762 | } |
| 8763 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 8764 | func addPeekTests() { |
| 8765 | // Test SSL_peek works, including on empty records. |
| 8766 | testCases = append(testCases, testCase{ |
| 8767 | name: "Peek-Basic", |
| 8768 | sendEmptyRecords: 1, |
| 8769 | flags: []string{"-peek-then-read"}, |
| 8770 | }) |
| 8771 | |
| 8772 | // Test SSL_peek can drive the initial handshake. |
| 8773 | testCases = append(testCases, testCase{ |
| 8774 | name: "Peek-ImplicitHandshake", |
| 8775 | flags: []string{ |
| 8776 | "-peek-then-read", |
| 8777 | "-implicit-handshake", |
| 8778 | }, |
| 8779 | }) |
| 8780 | |
| 8781 | // Test SSL_peek can discover and drive a renegotiation. |
| 8782 | testCases = append(testCases, testCase{ |
| 8783 | name: "Peek-Renegotiate", |
| 8784 | config: Config{ |
| 8785 | MaxVersion: VersionTLS12, |
| 8786 | }, |
| 8787 | renegotiate: 1, |
| 8788 | flags: []string{ |
| 8789 | "-peek-then-read", |
| 8790 | "-renegotiate-freely", |
| 8791 | "-expect-total-renegotiations", "1", |
| 8792 | }, |
| 8793 | }) |
| 8794 | |
| 8795 | // Test SSL_peek can discover a close_notify. |
| 8796 | testCases = append(testCases, testCase{ |
| 8797 | name: "Peek-Shutdown", |
| 8798 | config: Config{ |
| 8799 | Bugs: ProtocolBugs{ |
| 8800 | ExpectCloseNotify: true, |
| 8801 | }, |
| 8802 | }, |
| 8803 | flags: []string{ |
| 8804 | "-peek-then-read", |
| 8805 | "-check-close-notify", |
| 8806 | }, |
| 8807 | }) |
| 8808 | |
| 8809 | // Test SSL_peek can discover an alert. |
| 8810 | testCases = append(testCases, testCase{ |
| 8811 | name: "Peek-Alert", |
| 8812 | config: Config{ |
| 8813 | Bugs: ProtocolBugs{ |
| 8814 | SendSpuriousAlert: alertRecordOverflow, |
| 8815 | }, |
| 8816 | }, |
| 8817 | flags: []string{"-peek-then-read"}, |
| 8818 | shouldFail: true, |
| 8819 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 8820 | }) |
| 8821 | |
| 8822 | // Test SSL_peek can handle KeyUpdate. |
| 8823 | testCases = append(testCases, testCase{ |
| 8824 | name: "Peek-KeyUpdate", |
| 8825 | config: Config{ |
| 8826 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 8827 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 8828 | sendKeyUpdates: 1, |
| 8829 | keyUpdateRequest: keyUpdateNotRequested, |
| 8830 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 8831 | }) |
| 8832 | } |
| 8833 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8834 | 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] | 8835 | defer wg.Done() |
| 8836 | |
| 8837 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8838 | var err error |
| 8839 | |
| 8840 | if *mallocTest < 0 { |
| 8841 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8842 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8843 | } else { |
| 8844 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 8845 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8846 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8847 | if err != nil { |
| 8848 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 8849 | } |
| 8850 | break |
| 8851 | } |
| 8852 | } |
| 8853 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8854 | statusChan <- statusMsg{test: test, err: err} |
| 8855 | } |
| 8856 | } |
| 8857 | |
| 8858 | type statusMsg struct { |
| 8859 | test *testCase |
| 8860 | started bool |
| 8861 | err error |
| 8862 | } |
| 8863 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8864 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8865 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8866 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8867 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8868 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8869 | if !*pipe { |
| 8870 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 8871 | var erase string |
| 8872 | for i := 0; i < lineLen; i++ { |
| 8873 | erase += "\b \b" |
| 8874 | } |
| 8875 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8876 | } |
| 8877 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8878 | if msg.started { |
| 8879 | started++ |
| 8880 | } else { |
| 8881 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8882 | |
| 8883 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8884 | if msg.err == errUnimplemented { |
| 8885 | if *pipe { |
| 8886 | // Print each test instead of a status line. |
| 8887 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 8888 | } |
| 8889 | unimplemented++ |
| 8890 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 8891 | } else { |
| 8892 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 8893 | failed++ |
| 8894 | testOutput.addResult(msg.test.name, "FAIL") |
| 8895 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8896 | } else { |
| 8897 | if *pipe { |
| 8898 | // Print each test instead of a status line. |
| 8899 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 8900 | } |
| 8901 | testOutput.addResult(msg.test.name, "PASS") |
| 8902 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8903 | } |
| 8904 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8905 | if !*pipe { |
| 8906 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8907 | 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] | 8908 | lineLen = len(line) |
| 8909 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8910 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8911 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8912 | |
| 8913 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8914 | } |
| 8915 | |
| 8916 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8917 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8918 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8919 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8920 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8921 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8922 | addCipherSuiteTests() |
| 8923 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8924 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 8925 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 8926 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 8927 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 8928 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 8929 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 8930 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 8931 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 8932 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 8933 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 8934 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8935 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8936 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8937 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8938 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8939 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8940 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8941 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8942 | addCECPQ1Tests() |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8943 | addDHEGroupSizeTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8944 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8945 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 8946 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8947 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8948 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8949 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8950 | addTLS13HandshakeTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 8951 | addPeekTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8952 | |
| 8953 | var wg sync.WaitGroup |
| 8954 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8955 | statusChan := make(chan statusMsg, *numWorkers) |
| 8956 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8957 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8958 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8959 | if len(*shimConfigFile) != 0 { |
| 8960 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 8961 | if err != nil { |
| 8962 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 8963 | os.Exit(1) |
| 8964 | } |
| 8965 | |
| 8966 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 8967 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 8968 | os.Exit(1) |
| 8969 | } |
| 8970 | } |
| 8971 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8972 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8973 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8974 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8975 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8976 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8977 | } |
| 8978 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8979 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8980 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8981 | matched := true |
| 8982 | if len(*testToRun) != 0 { |
| 8983 | var err error |
| 8984 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 8985 | if err != nil { |
| 8986 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 8987 | os.Exit(1) |
| 8988 | } |
| 8989 | } |
| 8990 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8991 | if !*includeDisabled { |
| 8992 | for pattern := range shimConfig.DisabledTests { |
| 8993 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 8994 | if err != nil { |
| 8995 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 8996 | os.Exit(1) |
| 8997 | } |
| 8998 | |
| 8999 | if isDisabled { |
| 9000 | matched = false |
| 9001 | break |
| 9002 | } |
| 9003 | } |
| 9004 | } |
| 9005 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9006 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9007 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9008 | testChan <- &testCases[i] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9009 | } |
| 9010 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9011 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9012 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9013 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9014 | os.Exit(1) |
| 9015 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9016 | |
| 9017 | close(testChan) |
| 9018 | wg.Wait() |
| 9019 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9020 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9021 | |
| 9022 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9023 | |
| 9024 | if *jsonOutput != "" { |
| 9025 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 9026 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 9027 | } |
| 9028 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9029 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9030 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 9031 | os.Exit(1) |
| 9032 | } |
| 9033 | |
| 9034 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9035 | os.Exit(1) |
| 9036 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9037 | } |