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 |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 362 | // expectMessageDropped, if true, means the test message is expected to |
| 363 | // be dropped by the client rather than echoed back. |
| 364 | expectMessageDropped bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 367 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 368 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 369 | func writeTranscript(test *testCase, isResume bool, data []byte) { |
| 370 | if len(data) == 0 { |
| 371 | return |
| 372 | } |
| 373 | |
| 374 | protocol := "tls" |
| 375 | if test.protocol == dtls { |
| 376 | protocol = "dtls" |
| 377 | } |
| 378 | |
| 379 | side := "client" |
| 380 | if test.testType == serverTest { |
| 381 | side = "server" |
| 382 | } |
| 383 | |
| 384 | dir := path.Join(*transcriptDir, protocol, side) |
| 385 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 386 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | name := test.name |
| 391 | if isResume { |
| 392 | name += "-Resume" |
| 393 | } else { |
| 394 | name += "-Normal" |
| 395 | } |
| 396 | |
| 397 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 398 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 399 | } |
| 400 | } |
| 401 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 402 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 403 | type timeoutConn struct { |
| 404 | net.Conn |
| 405 | timeout time.Duration |
| 406 | } |
| 407 | |
| 408 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 409 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 410 | return 0, err |
| 411 | } |
| 412 | return t.Conn.Read(b) |
| 413 | } |
| 414 | |
| 415 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 416 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 417 | return 0, err |
| 418 | } |
| 419 | return t.Conn.Write(b) |
| 420 | } |
| 421 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 422 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 423 | if !test.noSessionCache { |
| 424 | if config.ClientSessionCache == nil { |
| 425 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 426 | } |
| 427 | if config.ServerSessionCache == nil { |
| 428 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 429 | } |
| 430 | } |
| 431 | if test.testType == clientTest { |
| 432 | if len(config.Certificates) == 0 { |
| 433 | config.Certificates = []Certificate{rsaCertificate} |
| 434 | } |
| 435 | } else { |
| 436 | // Supply a ServerName to ensure a constant session cache key, |
| 437 | // rather than falling back to net.Conn.RemoteAddr. |
| 438 | if len(config.ServerName) == 0 { |
| 439 | config.ServerName = "test" |
| 440 | } |
| 441 | } |
| 442 | if *fuzzer { |
| 443 | config.Bugs.NullAllCiphers = true |
| 444 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 445 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 446 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 447 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 448 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 449 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 450 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 451 | } |
| 452 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 453 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 454 | local, peer := "client", "server" |
| 455 | if test.testType == clientTest { |
| 456 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 457 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 458 | connDebug := &recordingConn{ |
| 459 | Conn: conn, |
| 460 | isDatagram: test.protocol == dtls, |
| 461 | local: local, |
| 462 | peer: peer, |
| 463 | } |
| 464 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 465 | if *flagDebug { |
| 466 | defer connDebug.WriteTo(os.Stdout) |
| 467 | } |
| 468 | if len(*transcriptDir) != 0 { |
| 469 | defer func() { |
| 470 | writeTranscript(test, isResume, connDebug.Transcript()) |
| 471 | }() |
| 472 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 473 | |
| 474 | if config.Bugs.PacketAdaptor != nil { |
| 475 | config.Bugs.PacketAdaptor.debug = connDebug |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | if test.replayWrites { |
| 480 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 481 | } |
| 482 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 483 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 484 | if test.damageFirstWrite { |
| 485 | connDamage = newDamageAdaptor(conn) |
| 486 | conn = connDamage |
| 487 | } |
| 488 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 489 | if test.sendPrefix != "" { |
| 490 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 491 | return err |
| 492 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 493 | } |
| 494 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 495 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 496 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 497 | if test.protocol == dtls { |
| 498 | tlsConn = DTLSServer(conn, config) |
| 499 | } else { |
| 500 | tlsConn = Server(conn, config) |
| 501 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 502 | } else { |
| 503 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 504 | if test.protocol == dtls { |
| 505 | tlsConn = DTLSClient(conn, config) |
| 506 | } else { |
| 507 | tlsConn = Client(conn, config) |
| 508 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 509 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 510 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 511 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 512 | if err := tlsConn.Handshake(); err != nil { |
| 513 | return err |
| 514 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 515 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 516 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 517 | // expectations struct that can be specified separately for the two |
| 518 | // legs. |
| 519 | expectedVersion := test.expectedVersion |
| 520 | if isResume && test.expectedResumeVersion != 0 { |
| 521 | expectedVersion = test.expectedResumeVersion |
| 522 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 523 | connState := tlsConn.ConnectionState() |
| 524 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 525 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 526 | } |
| 527 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 528 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 529 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 530 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 531 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 532 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 533 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 534 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 535 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 536 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 537 | if channelID == nil { |
| 538 | return fmt.Errorf("no channel ID negotiated") |
| 539 | } |
| 540 | if channelID.Curve != channelIDKey.Curve || |
| 541 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 542 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 543 | return fmt.Errorf("incorrect channel ID") |
| 544 | } |
| 545 | } |
| 546 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 547 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 548 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 549 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 550 | } |
| 551 | } |
| 552 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 553 | if test.expectNoNextProto { |
| 554 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 555 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 556 | } |
| 557 | } |
| 558 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 559 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 560 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 561 | return fmt.Errorf("next proto type mismatch") |
| 562 | } |
| 563 | } |
| 564 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 565 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 566 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 567 | } |
| 568 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 569 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 570 | 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] | 571 | } |
| 572 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 573 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 574 | return fmt.Errorf("SCT list mismatch") |
| 575 | } |
| 576 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 577 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 578 | 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] | 579 | } |
| 580 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 581 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 582 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 583 | } |
| 584 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 585 | if test.exportKeyingMaterial > 0 { |
| 586 | actual := make([]byte, test.exportKeyingMaterial) |
| 587 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 588 | return err |
| 589 | } |
| 590 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 591 | if err != nil { |
| 592 | return err |
| 593 | } |
| 594 | if !bytes.Equal(actual, expected) { |
| 595 | return fmt.Errorf("keying material mismatch") |
| 596 | } |
| 597 | } |
| 598 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 599 | if test.testTLSUnique { |
| 600 | var peersValue [12]byte |
| 601 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 602 | return err |
| 603 | } |
| 604 | expected := tlsConn.ConnectionState().TLSUnique |
| 605 | if !bytes.Equal(peersValue[:], expected) { |
| 606 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 607 | } |
| 608 | } |
| 609 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 610 | if test.shimWritesFirst { |
| 611 | var buf [5]byte |
| 612 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 613 | if err != nil { |
| 614 | return err |
| 615 | } |
| 616 | if string(buf[:]) != "hello" { |
| 617 | return fmt.Errorf("bad initial message") |
| 618 | } |
| 619 | } |
| 620 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 621 | for i := 0; i < test.sendKeyUpdates; i++ { |
| 622 | tlsConn.SendKeyUpdate() |
| 623 | } |
| 624 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 625 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 626 | tlsConn.Write(nil) |
| 627 | } |
| 628 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 629 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 630 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 631 | } |
| 632 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 633 | if test.sendHalfHelloRequest { |
| 634 | tlsConn.SendHalfHelloRequest() |
| 635 | } |
| 636 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 637 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 638 | if test.renegotiateCiphers != nil { |
| 639 | config.CipherSuites = test.renegotiateCiphers |
| 640 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 641 | for i := 0; i < test.renegotiate; i++ { |
| 642 | if err := tlsConn.Renegotiate(); err != nil { |
| 643 | return err |
| 644 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 645 | } |
| 646 | } else if test.renegotiateCiphers != nil { |
| 647 | panic("renegotiateCiphers without renegotiate") |
| 648 | } |
| 649 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 650 | if test.damageFirstWrite { |
| 651 | connDamage.setDamage(true) |
| 652 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 653 | connDamage.setDamage(false) |
| 654 | } |
| 655 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 656 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 657 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 658 | if test.protocol == dtls { |
| 659 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 660 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 661 | // Read until EOF. |
| 662 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 663 | return err |
| 664 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 665 | if messageLen == 0 { |
| 666 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 667 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 668 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 669 | messageCount := test.messageCount |
| 670 | if messageCount == 0 { |
| 671 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 672 | } |
| 673 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 674 | for j := 0; j < messageCount; j++ { |
| 675 | testMessage := make([]byte, messageLen) |
| 676 | for i := range testMessage { |
| 677 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 678 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 679 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 680 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 681 | for i := 0; i < test.sendKeyUpdates; i++ { |
| 682 | tlsConn.SendKeyUpdate() |
| 683 | } |
| 684 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 685 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 686 | tlsConn.Write(nil) |
| 687 | } |
| 688 | |
| 689 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 690 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 691 | } |
| 692 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 693 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 694 | // The shim will not respond. |
| 695 | continue |
| 696 | } |
| 697 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 698 | buf := make([]byte, len(testMessage)) |
| 699 | if test.protocol == dtls { |
| 700 | bufTmp := make([]byte, len(buf)+1) |
| 701 | n, err := tlsConn.Read(bufTmp) |
| 702 | if err != nil { |
| 703 | return err |
| 704 | } |
| 705 | if n != len(buf) { |
| 706 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 707 | } |
| 708 | copy(buf, bufTmp) |
| 709 | } else { |
| 710 | _, err := io.ReadFull(tlsConn, buf) |
| 711 | if err != nil { |
| 712 | return err |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | for i, v := range buf { |
| 717 | if v != testMessage[i]^0xff { |
| 718 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 719 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | |
| 723 | return nil |
| 724 | } |
| 725 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 726 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
| 727 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 728 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 729 | 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] | 730 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 731 | valgrindArgs = append(valgrindArgs, path) |
| 732 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 733 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 734 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 735 | } |
| 736 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 737 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 738 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 739 | xtermArgs = append(xtermArgs, path) |
| 740 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 741 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 742 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 743 | } |
| 744 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 745 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 746 | xtermArgs := []string{"-e", "lldb", "--"} |
| 747 | xtermArgs = append(xtermArgs, path) |
| 748 | xtermArgs = append(xtermArgs, args...) |
| 749 | |
| 750 | return exec.Command("xterm", xtermArgs...) |
| 751 | } |
| 752 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 753 | var ( |
| 754 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 755 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 756 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 757 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 758 | // accept accepts a connection from listener, unless waitChan signals a process |
| 759 | // exit first. |
| 760 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 761 | type connOrError struct { |
| 762 | conn net.Conn |
| 763 | err error |
| 764 | } |
| 765 | connChan := make(chan connOrError, 1) |
| 766 | go func() { |
| 767 | conn, err := listener.Accept() |
| 768 | connChan <- connOrError{conn, err} |
| 769 | close(connChan) |
| 770 | }() |
| 771 | select { |
| 772 | case result := <-connChan: |
| 773 | return result.conn, result.err |
| 774 | case childErr := <-waitChan: |
| 775 | waitChan <- childErr |
| 776 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 777 | } |
| 778 | } |
| 779 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 780 | func translateExpectedError(errorStr string) string { |
| 781 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 782 | return translated |
| 783 | } |
| 784 | |
| 785 | if *looseErrors { |
| 786 | return "" |
| 787 | } |
| 788 | |
| 789 | return errorStr |
| 790 | } |
| 791 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 792 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 793 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 794 | panic("Error expected without shouldFail in " + test.name) |
| 795 | } |
| 796 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 797 | if test.expectResumeRejected && !test.resumeSession { |
| 798 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 799 | } |
| 800 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 801 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 802 | if err != nil { |
| 803 | panic(err) |
| 804 | } |
| 805 | defer func() { |
| 806 | if listener != nil { |
| 807 | listener.Close() |
| 808 | } |
| 809 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 810 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 811 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 812 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 813 | flags = append(flags, "-server") |
| 814 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 815 | flags = append(flags, "-key-file") |
| 816 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 817 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 818 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 819 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 820 | } |
| 821 | |
| 822 | flags = append(flags, "-cert-file") |
| 823 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 824 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 825 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 826 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 827 | } |
| 828 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 829 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 830 | if test.protocol == dtls { |
| 831 | flags = append(flags, "-dtls") |
| 832 | } |
| 833 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 834 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 835 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 836 | resumeCount++ |
| 837 | if test.resumeRenewedSession { |
| 838 | resumeCount++ |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | if resumeCount > 0 { |
| 843 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 844 | } |
| 845 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 846 | if test.shimWritesFirst { |
| 847 | flags = append(flags, "-shim-writes-first") |
| 848 | } |
| 849 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 850 | if test.shimShutsDown { |
| 851 | flags = append(flags, "-shim-shuts-down") |
| 852 | } |
| 853 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 854 | if test.exportKeyingMaterial > 0 { |
| 855 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 856 | flags = append(flags, "-export-label", test.exportLabel) |
| 857 | flags = append(flags, "-export-context", test.exportContext) |
| 858 | if test.useExportContext { |
| 859 | flags = append(flags, "-use-export-context") |
| 860 | } |
| 861 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 862 | if test.expectResumeRejected { |
| 863 | flags = append(flags, "-expect-session-miss") |
| 864 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 865 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 866 | if test.testTLSUnique { |
| 867 | flags = append(flags, "-tls-unique") |
| 868 | } |
| 869 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 870 | flags = append(flags, test.flags...) |
| 871 | |
| 872 | var shim *exec.Cmd |
| 873 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 874 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 875 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 876 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 877 | } else if *useLLDB { |
| 878 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 879 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 880 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 881 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 882 | shim.Stdin = os.Stdin |
| 883 | var stdoutBuf, stderrBuf bytes.Buffer |
| 884 | shim.Stdout = &stdoutBuf |
| 885 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 886 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 887 | shim.Env = os.Environ() |
| 888 | 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] | 889 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 890 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 891 | } |
| 892 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 893 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 894 | |
| 895 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 896 | panic(err) |
| 897 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 898 | waitChan := make(chan error, 1) |
| 899 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 900 | |
| 901 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 902 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame^] | 903 | if *deterministic { |
| 904 | config.Rand = &deterministicRand{} |
| 905 | } |
| 906 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 907 | conn, err := acceptOrWait(listener, waitChan) |
| 908 | if err == nil { |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 909 | err = doExchange(test, &config, conn, false /* not a resumption */) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 910 | conn.Close() |
| 911 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 912 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 913 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 914 | var resumeConfig Config |
| 915 | if test.resumeConfig != nil { |
| 916 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 917 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 918 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 919 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 920 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 921 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 922 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 923 | } else { |
| 924 | resumeConfig = config |
| 925 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 926 | var connResume net.Conn |
| 927 | connResume, err = acceptOrWait(listener, waitChan) |
| 928 | if err == nil { |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 929 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 930 | connResume.Close() |
| 931 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 932 | } |
| 933 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 934 | // Close the listener now. This is to avoid hangs should the shim try to |
| 935 | // open more connections than expected. |
| 936 | listener.Close() |
| 937 | listener = nil |
| 938 | |
| 939 | childErr := <-waitChan |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 940 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 941 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 942 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 943 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 944 | case 89: |
| 945 | return errUnimplemented |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 946 | } |
| 947 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 948 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 949 | // Account for Windows line endings. |
| 950 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 951 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 952 | |
| 953 | // Separate the errors from the shim and those from tools like |
| 954 | // AddressSanitizer. |
| 955 | var extraStderr string |
| 956 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 957 | stderr = stderrParts[0] |
| 958 | extraStderr = stderrParts[1] |
| 959 | } |
| 960 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 961 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 962 | expectedError := translateExpectedError(test.expectedError) |
| 963 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 964 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 965 | localError := "none" |
| 966 | if err != nil { |
| 967 | localError = err.Error() |
| 968 | } |
| 969 | if len(test.expectedLocalError) != 0 { |
| 970 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 971 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 972 | |
| 973 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 974 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 975 | if childErr != nil { |
| 976 | childError = childErr.Error() |
| 977 | } |
| 978 | |
| 979 | var msg string |
| 980 | switch { |
| 981 | case failed && !test.shouldFail: |
| 982 | msg = "unexpected failure" |
| 983 | case !failed && test.shouldFail: |
| 984 | msg = "unexpected success" |
| 985 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 986 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 987 | default: |
| 988 | panic("internal error") |
| 989 | } |
| 990 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 991 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s", msg, localError, childError, stdout, stderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 992 | } |
| 993 | |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 994 | if !*useValgrind && (len(extraStderr) > 0 || (!failed && len(stderr) > 0)) { |
| 995 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | return nil |
| 999 | } |
| 1000 | |
| 1001 | var tlsVersions = []struct { |
| 1002 | name string |
| 1003 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1004 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1005 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1006 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1007 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1008 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1009 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1010 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1011 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | var testCipherSuites = []struct { |
| 1015 | name string |
| 1016 | id uint16 |
| 1017 | }{ |
| 1018 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1019 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1020 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1021 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1022 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1023 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1024 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1025 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1026 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1027 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1028 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1029 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1030 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1031 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1032 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1033 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1034 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1035 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1036 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1037 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1038 | {"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] | 1039 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1040 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1041 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1042 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1043 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1044 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1045 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1046 | {"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] | 1047 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1048 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1049 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1050 | {"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] | 1051 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1052 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1053 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1054 | {"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] | 1055 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 3084e7b | 2016-06-02 12:07:20 -0400 | [diff] [blame] | 1056 | {"ECDHE-PSK-AES128-GCM-SHA256", TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256}, |
| 1057 | {"ECDHE-PSK-AES256-GCM-SHA384", TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1058 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1059 | } |
| 1060 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1061 | func hasComponent(suiteName, component string) bool { |
| 1062 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1063 | } |
| 1064 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1065 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1066 | return hasComponent(suiteName, "GCM") || |
| 1067 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1068 | hasComponent(suiteName, "SHA384") || |
| 1069 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1070 | } |
| 1071 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1072 | func isTLS13Suite(suiteName string) bool { |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 1073 | // Only AEADs. |
| 1074 | if !hasComponent(suiteName, "GCM") && !hasComponent(suiteName, "POLY1305") { |
| 1075 | return false |
| 1076 | } |
| 1077 | // No old CHACHA20_POLY1305. |
| 1078 | if hasComponent(suiteName, "CHACHA20-POLY1305-OLD") { |
| 1079 | return false |
| 1080 | } |
| 1081 | // Must have ECDHE. |
| 1082 | // TODO(davidben,svaldez): Add pure PSK support. |
| 1083 | if !hasComponent(suiteName, "ECDHE") { |
| 1084 | return false |
| 1085 | } |
| 1086 | // TODO(davidben,svaldez): Add PSK support. |
| 1087 | if hasComponent(suiteName, "PSK") { |
| 1088 | return false |
| 1089 | } |
| 1090 | return true |
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 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1415 | name: "CertMismatchRSA-TLS13", |
| 1416 | config: Config{ |
| 1417 | MaxVersion: VersionTLS13, |
| 1418 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1419 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 1420 | Bugs: ProtocolBugs{ |
| 1421 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1422 | }, |
| 1423 | }, |
| 1424 | shouldFail: true, |
| 1425 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1426 | }, |
| 1427 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1428 | name: "CertMismatchECDSA", |
| 1429 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1430 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1431 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1432 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1433 | Bugs: ProtocolBugs{ |
| 1434 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1435 | }, |
| 1436 | }, |
| 1437 | shouldFail: true, |
| 1438 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1439 | }, |
| 1440 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1441 | name: "CertMismatchECDSA-TLS13", |
| 1442 | config: Config{ |
| 1443 | MaxVersion: VersionTLS13, |
| 1444 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1445 | Certificates: []Certificate{rsaCertificate}, |
| 1446 | Bugs: ProtocolBugs{ |
| 1447 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1448 | }, |
| 1449 | }, |
| 1450 | shouldFail: true, |
| 1451 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1452 | }, |
| 1453 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1454 | name: "EmptyCertificateList", |
| 1455 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1456 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1457 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1458 | Bugs: ProtocolBugs{ |
| 1459 | EmptyCertificateList: true, |
| 1460 | }, |
| 1461 | }, |
| 1462 | shouldFail: true, |
| 1463 | expectedError: ":DECODE_ERROR:", |
| 1464 | }, |
| 1465 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1466 | name: "EmptyCertificateList-TLS13", |
| 1467 | config: Config{ |
| 1468 | MaxVersion: VersionTLS13, |
| 1469 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1470 | Bugs: ProtocolBugs{ |
| 1471 | EmptyCertificateList: true, |
| 1472 | }, |
| 1473 | }, |
| 1474 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1475 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1476 | }, |
| 1477 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1478 | name: "TLSFatalBadPackets", |
| 1479 | damageFirstWrite: true, |
| 1480 | shouldFail: true, |
| 1481 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1482 | }, |
| 1483 | { |
| 1484 | protocol: dtls, |
| 1485 | name: "DTLSIgnoreBadPackets", |
| 1486 | damageFirstWrite: true, |
| 1487 | }, |
| 1488 | { |
| 1489 | protocol: dtls, |
| 1490 | name: "DTLSIgnoreBadPackets-Async", |
| 1491 | damageFirstWrite: true, |
| 1492 | flags: []string{"-async"}, |
| 1493 | }, |
| 1494 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1495 | name: "AppDataBeforeHandshake", |
| 1496 | config: Config{ |
| 1497 | Bugs: ProtocolBugs{ |
| 1498 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1499 | }, |
| 1500 | }, |
| 1501 | shouldFail: true, |
| 1502 | expectedError: ":UNEXPECTED_RECORD:", |
| 1503 | }, |
| 1504 | { |
| 1505 | name: "AppDataBeforeHandshake-Empty", |
| 1506 | config: Config{ |
| 1507 | Bugs: ProtocolBugs{ |
| 1508 | AppDataBeforeHandshake: []byte{}, |
| 1509 | }, |
| 1510 | }, |
| 1511 | shouldFail: true, |
| 1512 | expectedError: ":UNEXPECTED_RECORD:", |
| 1513 | }, |
| 1514 | { |
| 1515 | protocol: dtls, |
| 1516 | name: "AppDataBeforeHandshake-DTLS", |
| 1517 | config: Config{ |
| 1518 | Bugs: ProtocolBugs{ |
| 1519 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1520 | }, |
| 1521 | }, |
| 1522 | shouldFail: true, |
| 1523 | expectedError: ":UNEXPECTED_RECORD:", |
| 1524 | }, |
| 1525 | { |
| 1526 | protocol: dtls, |
| 1527 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1528 | config: Config{ |
| 1529 | Bugs: ProtocolBugs{ |
| 1530 | AppDataBeforeHandshake: []byte{}, |
| 1531 | }, |
| 1532 | }, |
| 1533 | shouldFail: true, |
| 1534 | expectedError: ":UNEXPECTED_RECORD:", |
| 1535 | }, |
| 1536 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1537 | name: "AppDataAfterChangeCipherSpec", |
| 1538 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1539 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1540 | Bugs: ProtocolBugs{ |
| 1541 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1542 | }, |
| 1543 | }, |
| 1544 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1545 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1546 | }, |
| 1547 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1548 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1549 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1550 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1551 | Bugs: ProtocolBugs{ |
| 1552 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1553 | }, |
| 1554 | }, |
| 1555 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1556 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1557 | }, |
| 1558 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1559 | protocol: dtls, |
| 1560 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1561 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1562 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1563 | Bugs: ProtocolBugs{ |
| 1564 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1565 | }, |
| 1566 | }, |
| 1567 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1568 | // application data. |
| 1569 | }, |
| 1570 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1571 | protocol: dtls, |
| 1572 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1573 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1574 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1575 | Bugs: ProtocolBugs{ |
| 1576 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1577 | }, |
| 1578 | }, |
| 1579 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1580 | // application data. |
| 1581 | }, |
| 1582 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1583 | name: "AlertAfterChangeCipherSpec", |
| 1584 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1585 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1586 | Bugs: ProtocolBugs{ |
| 1587 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1588 | }, |
| 1589 | }, |
| 1590 | shouldFail: true, |
| 1591 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1592 | }, |
| 1593 | { |
| 1594 | protocol: dtls, |
| 1595 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1596 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1597 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1598 | Bugs: ProtocolBugs{ |
| 1599 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1600 | }, |
| 1601 | }, |
| 1602 | shouldFail: true, |
| 1603 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1604 | }, |
| 1605 | { |
| 1606 | protocol: dtls, |
| 1607 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1608 | config: Config{ |
| 1609 | Bugs: ProtocolBugs{ |
| 1610 | ReorderHandshakeFragments: true, |
| 1611 | // Small enough that every handshake message is |
| 1612 | // fragmented. |
| 1613 | MaxHandshakeRecordLength: 2, |
| 1614 | }, |
| 1615 | }, |
| 1616 | }, |
| 1617 | { |
| 1618 | protocol: dtls, |
| 1619 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1620 | config: Config{ |
| 1621 | Bugs: ProtocolBugs{ |
| 1622 | ReorderHandshakeFragments: true, |
| 1623 | // Large enough that no handshake message is |
| 1624 | // fragmented. |
| 1625 | MaxHandshakeRecordLength: 2048, |
| 1626 | }, |
| 1627 | }, |
| 1628 | }, |
| 1629 | { |
| 1630 | protocol: dtls, |
| 1631 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1632 | config: Config{ |
| 1633 | Bugs: ProtocolBugs{ |
| 1634 | ReorderHandshakeFragments: true, |
| 1635 | MixCompleteMessageWithFragments: true, |
| 1636 | MaxHandshakeRecordLength: 2, |
| 1637 | }, |
| 1638 | }, |
| 1639 | }, |
| 1640 | { |
| 1641 | name: "SendInvalidRecordType", |
| 1642 | config: Config{ |
| 1643 | Bugs: ProtocolBugs{ |
| 1644 | SendInvalidRecordType: true, |
| 1645 | }, |
| 1646 | }, |
| 1647 | shouldFail: true, |
| 1648 | expectedError: ":UNEXPECTED_RECORD:", |
| 1649 | }, |
| 1650 | { |
| 1651 | protocol: dtls, |
| 1652 | name: "SendInvalidRecordType-DTLS", |
| 1653 | config: Config{ |
| 1654 | Bugs: ProtocolBugs{ |
| 1655 | SendInvalidRecordType: true, |
| 1656 | }, |
| 1657 | }, |
| 1658 | shouldFail: true, |
| 1659 | expectedError: ":UNEXPECTED_RECORD:", |
| 1660 | }, |
| 1661 | { |
| 1662 | name: "FalseStart-SkipServerSecondLeg", |
| 1663 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1664 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1665 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1666 | NextProtos: []string{"foo"}, |
| 1667 | Bugs: ProtocolBugs{ |
| 1668 | SkipNewSessionTicket: true, |
| 1669 | SkipChangeCipherSpec: true, |
| 1670 | SkipFinished: true, |
| 1671 | ExpectFalseStart: true, |
| 1672 | }, |
| 1673 | }, |
| 1674 | flags: []string{ |
| 1675 | "-false-start", |
| 1676 | "-handshake-never-done", |
| 1677 | "-advertise-alpn", "\x03foo", |
| 1678 | }, |
| 1679 | shimWritesFirst: true, |
| 1680 | shouldFail: true, |
| 1681 | expectedError: ":UNEXPECTED_RECORD:", |
| 1682 | }, |
| 1683 | { |
| 1684 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1685 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1686 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1687 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1688 | NextProtos: []string{"foo"}, |
| 1689 | Bugs: ProtocolBugs{ |
| 1690 | SkipNewSessionTicket: true, |
| 1691 | SkipChangeCipherSpec: true, |
| 1692 | SkipFinished: true, |
| 1693 | }, |
| 1694 | }, |
| 1695 | flags: []string{ |
| 1696 | "-implicit-handshake", |
| 1697 | "-false-start", |
| 1698 | "-handshake-never-done", |
| 1699 | "-advertise-alpn", "\x03foo", |
| 1700 | }, |
| 1701 | shouldFail: true, |
| 1702 | expectedError: ":UNEXPECTED_RECORD:", |
| 1703 | }, |
| 1704 | { |
| 1705 | testType: serverTest, |
| 1706 | name: "FailEarlyCallback", |
| 1707 | flags: []string{"-fail-early-callback"}, |
| 1708 | shouldFail: true, |
| 1709 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1710 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1711 | }, |
| 1712 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1713 | protocol: dtls, |
| 1714 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1715 | config: Config{ |
| 1716 | Bugs: ProtocolBugs{ |
| 1717 | MaxHandshakeRecordLength: 2, |
| 1718 | FragmentMessageTypeMismatch: true, |
| 1719 | }, |
| 1720 | }, |
| 1721 | shouldFail: true, |
| 1722 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1723 | }, |
| 1724 | { |
| 1725 | protocol: dtls, |
| 1726 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1727 | config: Config{ |
| 1728 | Bugs: ProtocolBugs{ |
| 1729 | MaxHandshakeRecordLength: 2, |
| 1730 | FragmentMessageLengthMismatch: true, |
| 1731 | }, |
| 1732 | }, |
| 1733 | shouldFail: true, |
| 1734 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1735 | }, |
| 1736 | { |
| 1737 | protocol: dtls, |
| 1738 | name: "SplitFragments-Header-DTLS", |
| 1739 | config: Config{ |
| 1740 | Bugs: ProtocolBugs{ |
| 1741 | SplitFragments: 2, |
| 1742 | }, |
| 1743 | }, |
| 1744 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1745 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1746 | }, |
| 1747 | { |
| 1748 | protocol: dtls, |
| 1749 | name: "SplitFragments-Boundary-DTLS", |
| 1750 | config: Config{ |
| 1751 | Bugs: ProtocolBugs{ |
| 1752 | SplitFragments: dtlsRecordHeaderLen, |
| 1753 | }, |
| 1754 | }, |
| 1755 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1756 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1757 | }, |
| 1758 | { |
| 1759 | protocol: dtls, |
| 1760 | name: "SplitFragments-Body-DTLS", |
| 1761 | config: Config{ |
| 1762 | Bugs: ProtocolBugs{ |
| 1763 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1764 | }, |
| 1765 | }, |
| 1766 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1767 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1768 | }, |
| 1769 | { |
| 1770 | protocol: dtls, |
| 1771 | name: "SendEmptyFragments-DTLS", |
| 1772 | config: Config{ |
| 1773 | Bugs: ProtocolBugs{ |
| 1774 | SendEmptyFragments: true, |
| 1775 | }, |
| 1776 | }, |
| 1777 | }, |
| 1778 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1779 | name: "BadFinished-Client", |
| 1780 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1781 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1782 | Bugs: ProtocolBugs{ |
| 1783 | BadFinished: true, |
| 1784 | }, |
| 1785 | }, |
| 1786 | shouldFail: true, |
| 1787 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1788 | }, |
| 1789 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1790 | name: "BadFinished-Client-TLS13", |
| 1791 | config: Config{ |
| 1792 | MaxVersion: VersionTLS13, |
| 1793 | Bugs: ProtocolBugs{ |
| 1794 | BadFinished: true, |
| 1795 | }, |
| 1796 | }, |
| 1797 | shouldFail: true, |
| 1798 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1799 | }, |
| 1800 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1801 | testType: serverTest, |
| 1802 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1803 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1804 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1805 | Bugs: ProtocolBugs{ |
| 1806 | BadFinished: true, |
| 1807 | }, |
| 1808 | }, |
| 1809 | shouldFail: true, |
| 1810 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1811 | }, |
| 1812 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1813 | testType: serverTest, |
| 1814 | name: "BadFinished-Server-TLS13", |
| 1815 | config: Config{ |
| 1816 | MaxVersion: VersionTLS13, |
| 1817 | Bugs: ProtocolBugs{ |
| 1818 | BadFinished: true, |
| 1819 | }, |
| 1820 | }, |
| 1821 | shouldFail: true, |
| 1822 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1823 | }, |
| 1824 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1825 | name: "FalseStart-BadFinished", |
| 1826 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1827 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1828 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1829 | NextProtos: []string{"foo"}, |
| 1830 | Bugs: ProtocolBugs{ |
| 1831 | BadFinished: true, |
| 1832 | ExpectFalseStart: true, |
| 1833 | }, |
| 1834 | }, |
| 1835 | flags: []string{ |
| 1836 | "-false-start", |
| 1837 | "-handshake-never-done", |
| 1838 | "-advertise-alpn", "\x03foo", |
| 1839 | }, |
| 1840 | shimWritesFirst: true, |
| 1841 | shouldFail: true, |
| 1842 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1843 | }, |
| 1844 | { |
| 1845 | name: "NoFalseStart-NoALPN", |
| 1846 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1847 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1848 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1849 | Bugs: ProtocolBugs{ |
| 1850 | ExpectFalseStart: true, |
| 1851 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1852 | }, |
| 1853 | }, |
| 1854 | flags: []string{ |
| 1855 | "-false-start", |
| 1856 | }, |
| 1857 | shimWritesFirst: true, |
| 1858 | shouldFail: true, |
| 1859 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1860 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1861 | }, |
| 1862 | { |
| 1863 | name: "NoFalseStart-NoAEAD", |
| 1864 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1865 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1866 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1867 | NextProtos: []string{"foo"}, |
| 1868 | Bugs: ProtocolBugs{ |
| 1869 | ExpectFalseStart: true, |
| 1870 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1871 | }, |
| 1872 | }, |
| 1873 | flags: []string{ |
| 1874 | "-false-start", |
| 1875 | "-advertise-alpn", "\x03foo", |
| 1876 | }, |
| 1877 | shimWritesFirst: true, |
| 1878 | shouldFail: true, |
| 1879 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1880 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1881 | }, |
| 1882 | { |
| 1883 | name: "NoFalseStart-RSA", |
| 1884 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1885 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1886 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1887 | NextProtos: []string{"foo"}, |
| 1888 | Bugs: ProtocolBugs{ |
| 1889 | ExpectFalseStart: true, |
| 1890 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1891 | }, |
| 1892 | }, |
| 1893 | flags: []string{ |
| 1894 | "-false-start", |
| 1895 | "-advertise-alpn", "\x03foo", |
| 1896 | }, |
| 1897 | shimWritesFirst: true, |
| 1898 | shouldFail: true, |
| 1899 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1900 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1901 | }, |
| 1902 | { |
| 1903 | name: "NoFalseStart-DHE_RSA", |
| 1904 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1905 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1906 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1907 | NextProtos: []string{"foo"}, |
| 1908 | Bugs: ProtocolBugs{ |
| 1909 | ExpectFalseStart: true, |
| 1910 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1911 | }, |
| 1912 | }, |
| 1913 | flags: []string{ |
| 1914 | "-false-start", |
| 1915 | "-advertise-alpn", "\x03foo", |
| 1916 | }, |
| 1917 | shimWritesFirst: true, |
| 1918 | shouldFail: true, |
| 1919 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1920 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1921 | }, |
| 1922 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1923 | protocol: dtls, |
| 1924 | name: "SendSplitAlert-Sync", |
| 1925 | config: Config{ |
| 1926 | Bugs: ProtocolBugs{ |
| 1927 | SendSplitAlert: true, |
| 1928 | }, |
| 1929 | }, |
| 1930 | }, |
| 1931 | { |
| 1932 | protocol: dtls, |
| 1933 | name: "SendSplitAlert-Async", |
| 1934 | config: Config{ |
| 1935 | Bugs: ProtocolBugs{ |
| 1936 | SendSplitAlert: true, |
| 1937 | }, |
| 1938 | }, |
| 1939 | flags: []string{"-async"}, |
| 1940 | }, |
| 1941 | { |
| 1942 | protocol: dtls, |
| 1943 | name: "PackDTLSHandshake", |
| 1944 | config: Config{ |
| 1945 | Bugs: ProtocolBugs{ |
| 1946 | MaxHandshakeRecordLength: 2, |
| 1947 | PackHandshakeFragments: 20, |
| 1948 | PackHandshakeRecords: 200, |
| 1949 | }, |
| 1950 | }, |
| 1951 | }, |
| 1952 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1953 | name: "SendEmptyRecords-Pass", |
| 1954 | sendEmptyRecords: 32, |
| 1955 | }, |
| 1956 | { |
| 1957 | name: "SendEmptyRecords", |
| 1958 | sendEmptyRecords: 33, |
| 1959 | shouldFail: true, |
| 1960 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1961 | }, |
| 1962 | { |
| 1963 | name: "SendEmptyRecords-Async", |
| 1964 | sendEmptyRecords: 33, |
| 1965 | flags: []string{"-async"}, |
| 1966 | shouldFail: true, |
| 1967 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1968 | }, |
| 1969 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1970 | name: "SendWarningAlerts-Pass", |
| 1971 | config: Config{ |
| 1972 | MaxVersion: VersionTLS12, |
| 1973 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1974 | sendWarningAlerts: 4, |
| 1975 | }, |
| 1976 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1977 | protocol: dtls, |
| 1978 | name: "SendWarningAlerts-DTLS-Pass", |
| 1979 | config: Config{ |
| 1980 | MaxVersion: VersionTLS12, |
| 1981 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1982 | sendWarningAlerts: 4, |
| 1983 | }, |
| 1984 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1985 | name: "SendWarningAlerts-TLS13", |
| 1986 | config: Config{ |
| 1987 | MaxVersion: VersionTLS13, |
| 1988 | }, |
| 1989 | sendWarningAlerts: 4, |
| 1990 | shouldFail: true, |
| 1991 | expectedError: ":BAD_ALERT:", |
| 1992 | expectedLocalError: "remote error: error decoding message", |
| 1993 | }, |
| 1994 | { |
| 1995 | name: "SendWarningAlerts", |
| 1996 | config: Config{ |
| 1997 | MaxVersion: VersionTLS12, |
| 1998 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1999 | sendWarningAlerts: 5, |
| 2000 | shouldFail: true, |
| 2001 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2002 | }, |
| 2003 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2004 | name: "SendWarningAlerts-Async", |
| 2005 | config: Config{ |
| 2006 | MaxVersion: VersionTLS12, |
| 2007 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2008 | sendWarningAlerts: 5, |
| 2009 | flags: []string{"-async"}, |
| 2010 | shouldFail: true, |
| 2011 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2012 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2013 | { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2014 | name: "SendKeyUpdates", |
| 2015 | config: Config{ |
| 2016 | MaxVersion: VersionTLS13, |
| 2017 | }, |
| 2018 | sendKeyUpdates: 33, |
| 2019 | shouldFail: true, |
| 2020 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
| 2021 | }, |
| 2022 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2023 | name: "EmptySessionID", |
| 2024 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2025 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2026 | SessionTicketsDisabled: true, |
| 2027 | }, |
| 2028 | noSessionCache: true, |
| 2029 | flags: []string{"-expect-no-session"}, |
| 2030 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2031 | { |
| 2032 | name: "Unclean-Shutdown", |
| 2033 | config: Config{ |
| 2034 | Bugs: ProtocolBugs{ |
| 2035 | NoCloseNotify: true, |
| 2036 | ExpectCloseNotify: true, |
| 2037 | }, |
| 2038 | }, |
| 2039 | shimShutsDown: true, |
| 2040 | flags: []string{"-check-close-notify"}, |
| 2041 | shouldFail: true, |
| 2042 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2043 | }, |
| 2044 | { |
| 2045 | name: "Unclean-Shutdown-Ignored", |
| 2046 | config: Config{ |
| 2047 | Bugs: ProtocolBugs{ |
| 2048 | NoCloseNotify: true, |
| 2049 | }, |
| 2050 | }, |
| 2051 | shimShutsDown: true, |
| 2052 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2053 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2054 | name: "Unclean-Shutdown-Alert", |
| 2055 | config: Config{ |
| 2056 | Bugs: ProtocolBugs{ |
| 2057 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2058 | ExpectCloseNotify: true, |
| 2059 | }, |
| 2060 | }, |
| 2061 | shimShutsDown: true, |
| 2062 | flags: []string{"-check-close-notify"}, |
| 2063 | shouldFail: true, |
| 2064 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2065 | }, |
| 2066 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2067 | name: "LargePlaintext", |
| 2068 | config: Config{ |
| 2069 | Bugs: ProtocolBugs{ |
| 2070 | SendLargeRecords: true, |
| 2071 | }, |
| 2072 | }, |
| 2073 | messageLen: maxPlaintext + 1, |
| 2074 | shouldFail: true, |
| 2075 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2076 | }, |
| 2077 | { |
| 2078 | protocol: dtls, |
| 2079 | name: "LargePlaintext-DTLS", |
| 2080 | config: Config{ |
| 2081 | Bugs: ProtocolBugs{ |
| 2082 | SendLargeRecords: true, |
| 2083 | }, |
| 2084 | }, |
| 2085 | messageLen: maxPlaintext + 1, |
| 2086 | shouldFail: true, |
| 2087 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2088 | }, |
| 2089 | { |
| 2090 | name: "LargeCiphertext", |
| 2091 | config: Config{ |
| 2092 | Bugs: ProtocolBugs{ |
| 2093 | SendLargeRecords: true, |
| 2094 | }, |
| 2095 | }, |
| 2096 | messageLen: maxPlaintext * 2, |
| 2097 | shouldFail: true, |
| 2098 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2099 | }, |
| 2100 | { |
| 2101 | protocol: dtls, |
| 2102 | name: "LargeCiphertext-DTLS", |
| 2103 | config: Config{ |
| 2104 | Bugs: ProtocolBugs{ |
| 2105 | SendLargeRecords: true, |
| 2106 | }, |
| 2107 | }, |
| 2108 | messageLen: maxPlaintext * 2, |
| 2109 | // Unlike the other four cases, DTLS drops records which |
| 2110 | // are invalid before authentication, so the connection |
| 2111 | // does not fail. |
| 2112 | expectMessageDropped: true, |
| 2113 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2114 | { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2115 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 2116 | // mean the server changed its mind on sending a ticket. |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2117 | name: "SendEmptySessionTicket", |
| 2118 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2119 | MaxVersion: VersionTLS12, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2120 | Bugs: ProtocolBugs{ |
| 2121 | SendEmptySessionTicket: true, |
| 2122 | FailIfSessionOffered: true, |
| 2123 | }, |
| 2124 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 2125 | flags: []string{"-expect-no-session"}, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2126 | }, |
David Benjamin | 99fdfb9 | 2015-11-02 12:11:35 -0500 | [diff] [blame] | 2127 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2128 | name: "BadHelloRequest-1", |
| 2129 | renegotiate: 1, |
| 2130 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2131 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2132 | Bugs: ProtocolBugs{ |
| 2133 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2134 | }, |
| 2135 | }, |
| 2136 | flags: []string{ |
| 2137 | "-renegotiate-freely", |
| 2138 | "-expect-total-renegotiations", "1", |
| 2139 | }, |
| 2140 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2141 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2142 | }, |
| 2143 | { |
| 2144 | name: "BadHelloRequest-2", |
| 2145 | renegotiate: 1, |
| 2146 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2147 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2148 | Bugs: ProtocolBugs{ |
| 2149 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2150 | }, |
| 2151 | }, |
| 2152 | flags: []string{ |
| 2153 | "-renegotiate-freely", |
| 2154 | "-expect-total-renegotiations", "1", |
| 2155 | }, |
| 2156 | shouldFail: true, |
| 2157 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2158 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2159 | { |
| 2160 | testType: serverTest, |
| 2161 | name: "SupportTicketsWithSessionID", |
| 2162 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2163 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2164 | SessionTicketsDisabled: true, |
| 2165 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2166 | resumeConfig: &Config{ |
| 2167 | MaxVersion: VersionTLS12, |
| 2168 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2169 | resumeSession: true, |
| 2170 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2171 | { |
| 2172 | protocol: dtls, |
| 2173 | name: "DTLS-SendExtraFinished", |
| 2174 | config: Config{ |
| 2175 | Bugs: ProtocolBugs{ |
| 2176 | SendExtraFinished: true, |
| 2177 | }, |
| 2178 | }, |
| 2179 | shouldFail: true, |
| 2180 | expectedError: ":UNEXPECTED_RECORD:", |
| 2181 | }, |
| 2182 | { |
| 2183 | protocol: dtls, |
| 2184 | name: "DTLS-SendExtraFinished-Reordered", |
| 2185 | config: Config{ |
| 2186 | Bugs: ProtocolBugs{ |
| 2187 | MaxHandshakeRecordLength: 2, |
| 2188 | ReorderHandshakeFragments: true, |
| 2189 | SendExtraFinished: true, |
| 2190 | }, |
| 2191 | }, |
| 2192 | shouldFail: true, |
| 2193 | expectedError: ":UNEXPECTED_RECORD:", |
| 2194 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2195 | { |
| 2196 | testType: serverTest, |
| 2197 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2198 | config: Config{ |
| 2199 | // Choose a cipher suite that does not involve |
| 2200 | // elliptic curves, so no extensions are |
| 2201 | // involved. |
| 2202 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2203 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2204 | Bugs: ProtocolBugs{ |
| 2205 | SendV2ClientHello: true, |
| 2206 | }, |
| 2207 | }, |
| 2208 | sendPrefix: string([]byte{ |
| 2209 | byte(recordTypeHandshake), |
| 2210 | 3, 1, // version |
| 2211 | 0, 0, // length |
| 2212 | }), |
| 2213 | // A no-op empty record may not be sent before V2ClientHello. |
| 2214 | shouldFail: true, |
| 2215 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2216 | }, |
| 2217 | { |
| 2218 | testType: serverTest, |
| 2219 | name: "V2ClientHello-WarningAlertPrefix", |
| 2220 | config: Config{ |
| 2221 | // Choose a cipher suite that does not involve |
| 2222 | // elliptic curves, so no extensions are |
| 2223 | // involved. |
| 2224 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2225 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2226 | Bugs: ProtocolBugs{ |
| 2227 | SendV2ClientHello: true, |
| 2228 | }, |
| 2229 | }, |
| 2230 | sendPrefix: string([]byte{ |
| 2231 | byte(recordTypeAlert), |
| 2232 | 3, 1, // version |
| 2233 | 0, 2, // length |
| 2234 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2235 | }), |
| 2236 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2237 | shouldFail: true, |
| 2238 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2239 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2240 | { |
| 2241 | testType: clientTest, |
| 2242 | name: "KeyUpdate", |
| 2243 | config: Config{ |
| 2244 | MaxVersion: VersionTLS13, |
| 2245 | Bugs: ProtocolBugs{ |
| 2246 | SendKeyUpdateBeforeEveryAppDataRecord: true, |
| 2247 | }, |
| 2248 | }, |
| 2249 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2250 | { |
| 2251 | name: "SendSNIWarningAlert", |
| 2252 | config: Config{ |
| 2253 | MaxVersion: VersionTLS12, |
| 2254 | Bugs: ProtocolBugs{ |
| 2255 | SendSNIWarningAlert: true, |
| 2256 | }, |
| 2257 | }, |
| 2258 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2259 | { |
| 2260 | testType: serverTest, |
| 2261 | name: "ExtraCompressionMethods-TLS12", |
| 2262 | config: Config{ |
| 2263 | MaxVersion: VersionTLS12, |
| 2264 | Bugs: ProtocolBugs{ |
| 2265 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2266 | }, |
| 2267 | }, |
| 2268 | }, |
| 2269 | { |
| 2270 | testType: serverTest, |
| 2271 | name: "ExtraCompressionMethods-TLS13", |
| 2272 | config: Config{ |
| 2273 | MaxVersion: VersionTLS13, |
| 2274 | Bugs: ProtocolBugs{ |
| 2275 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2276 | }, |
| 2277 | }, |
| 2278 | shouldFail: true, |
| 2279 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2280 | expectedLocalError: "remote error: illegal parameter", |
| 2281 | }, |
| 2282 | { |
| 2283 | testType: serverTest, |
| 2284 | name: "NoNullCompression-TLS12", |
| 2285 | config: Config{ |
| 2286 | MaxVersion: VersionTLS12, |
| 2287 | Bugs: ProtocolBugs{ |
| 2288 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2289 | }, |
| 2290 | }, |
| 2291 | shouldFail: true, |
| 2292 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2293 | expectedLocalError: "remote error: illegal parameter", |
| 2294 | }, |
| 2295 | { |
| 2296 | testType: serverTest, |
| 2297 | name: "NoNullCompression-TLS13", |
| 2298 | config: Config{ |
| 2299 | MaxVersion: VersionTLS13, |
| 2300 | Bugs: ProtocolBugs{ |
| 2301 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2302 | }, |
| 2303 | }, |
| 2304 | shouldFail: true, |
| 2305 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2306 | expectedLocalError: "remote error: illegal parameter", |
| 2307 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2308 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2309 | testCases = append(testCases, basicTests...) |
| 2310 | } |
| 2311 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2312 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2313 | const bogusCipher = 0xfe00 |
| 2314 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2315 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2316 | const psk = "12345" |
| 2317 | const pskIdentity = "luggage combo" |
| 2318 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2319 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2320 | var certFile string |
| 2321 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2322 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2323 | cert = ecdsaP256Certificate |
| 2324 | certFile = ecdsaP256CertificateFile |
| 2325 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2326 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2327 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2328 | certFile = rsaCertificateFile |
| 2329 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2330 | } |
| 2331 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2332 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2333 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2334 | flags = append(flags, |
| 2335 | "-psk", psk, |
| 2336 | "-psk-identity", pskIdentity) |
| 2337 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2338 | if hasComponent(suite.name, "NULL") { |
| 2339 | // NULL ciphers must be explicitly enabled. |
| 2340 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2341 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2342 | if hasComponent(suite.name, "CECPQ1") { |
| 2343 | // CECPQ1 ciphers must be explicitly enabled. |
| 2344 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2345 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2346 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2347 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2348 | // for now. |
| 2349 | flags = append(flags, "-cipher", suite.name) |
| 2350 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2351 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2352 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2353 | for _, protocol := range []protocol{tls, dtls} { |
| 2354 | var prefix string |
| 2355 | if protocol == dtls { |
| 2356 | if !ver.hasDTLS { |
| 2357 | continue |
| 2358 | } |
| 2359 | prefix = "D" |
| 2360 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2361 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2362 | var shouldServerFail, shouldClientFail bool |
| 2363 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2364 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2365 | // a BoringSSL server will never select it |
| 2366 | // because the extension is missing. |
| 2367 | shouldServerFail = true |
| 2368 | } |
| 2369 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2370 | shouldClientFail = true |
| 2371 | shouldServerFail = true |
| 2372 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2373 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2374 | shouldClientFail = true |
| 2375 | shouldServerFail = true |
| 2376 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2377 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2378 | shouldClientFail = true |
| 2379 | shouldServerFail = true |
| 2380 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2381 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2382 | var expectedServerError, expectedClientError string |
| 2383 | if shouldServerFail { |
| 2384 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2385 | } |
| 2386 | if shouldClientFail { |
| 2387 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2388 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2389 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2390 | testCases = append(testCases, testCase{ |
| 2391 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2392 | protocol: protocol, |
| 2393 | |
| 2394 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2395 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2396 | MinVersion: ver.version, |
| 2397 | MaxVersion: ver.version, |
| 2398 | CipherSuites: []uint16{suite.id}, |
| 2399 | Certificates: []Certificate{cert}, |
| 2400 | PreSharedKey: []byte(psk), |
| 2401 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2402 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2403 | EnableAllCiphers: shouldServerFail, |
| 2404 | IgnorePeerCipherPreferences: shouldServerFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2405 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2406 | }, |
| 2407 | certFile: certFile, |
| 2408 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2409 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2410 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2411 | shouldFail: shouldServerFail, |
| 2412 | expectedError: expectedServerError, |
| 2413 | }) |
| 2414 | |
| 2415 | testCases = append(testCases, testCase{ |
| 2416 | testType: clientTest, |
| 2417 | protocol: protocol, |
| 2418 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2419 | config: Config{ |
| 2420 | MinVersion: ver.version, |
| 2421 | MaxVersion: ver.version, |
| 2422 | CipherSuites: []uint16{suite.id}, |
| 2423 | Certificates: []Certificate{cert}, |
| 2424 | PreSharedKey: []byte(psk), |
| 2425 | PreSharedKeyIdentity: pskIdentity, |
| 2426 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2427 | EnableAllCiphers: shouldClientFail, |
| 2428 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2429 | }, |
| 2430 | }, |
| 2431 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2432 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2433 | shouldFail: shouldClientFail, |
| 2434 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2435 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2436 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2437 | if !shouldClientFail { |
| 2438 | // Ensure the maximum record size is accepted. |
| 2439 | testCases = append(testCases, testCase{ |
| 2440 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2441 | config: Config{ |
| 2442 | MinVersion: ver.version, |
| 2443 | MaxVersion: ver.version, |
| 2444 | CipherSuites: []uint16{suite.id}, |
| 2445 | Certificates: []Certificate{cert}, |
| 2446 | PreSharedKey: []byte(psk), |
| 2447 | PreSharedKeyIdentity: pskIdentity, |
| 2448 | }, |
| 2449 | flags: flags, |
| 2450 | messageLen: maxPlaintext, |
| 2451 | }) |
| 2452 | } |
| 2453 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2454 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2455 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2456 | |
| 2457 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2458 | name: "NoSharedCipher", |
| 2459 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2460 | MaxVersion: VersionTLS12, |
| 2461 | CipherSuites: []uint16{}, |
| 2462 | }, |
| 2463 | shouldFail: true, |
| 2464 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2465 | }) |
| 2466 | |
| 2467 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2468 | name: "NoSharedCipher-TLS13", |
| 2469 | config: Config{ |
| 2470 | MaxVersion: VersionTLS13, |
| 2471 | CipherSuites: []uint16{}, |
| 2472 | }, |
| 2473 | shouldFail: true, |
| 2474 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2475 | }) |
| 2476 | |
| 2477 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2478 | name: "UnsupportedCipherSuite", |
| 2479 | config: Config{ |
| 2480 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2481 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2482 | Bugs: ProtocolBugs{ |
| 2483 | IgnorePeerCipherPreferences: true, |
| 2484 | }, |
| 2485 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2486 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2487 | shouldFail: true, |
| 2488 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2489 | }) |
| 2490 | |
| 2491 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2492 | name: "ServerHelloBogusCipher", |
| 2493 | config: Config{ |
| 2494 | MaxVersion: VersionTLS12, |
| 2495 | Bugs: ProtocolBugs{ |
| 2496 | SendCipherSuite: bogusCipher, |
| 2497 | }, |
| 2498 | }, |
| 2499 | shouldFail: true, |
| 2500 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2501 | }) |
| 2502 | testCases = append(testCases, testCase{ |
| 2503 | name: "ServerHelloBogusCipher-TLS13", |
| 2504 | config: Config{ |
| 2505 | MaxVersion: VersionTLS13, |
| 2506 | Bugs: ProtocolBugs{ |
| 2507 | SendCipherSuite: bogusCipher, |
| 2508 | }, |
| 2509 | }, |
| 2510 | shouldFail: true, |
| 2511 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2512 | }) |
| 2513 | |
| 2514 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2515 | name: "WeakDH", |
| 2516 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2517 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2518 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2519 | Bugs: ProtocolBugs{ |
| 2520 | // This is a 1023-bit prime number, generated |
| 2521 | // with: |
| 2522 | // openssl gendh 1023 | openssl asn1parse -i |
| 2523 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2524 | }, |
| 2525 | }, |
| 2526 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2527 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2528 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2529 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2530 | testCases = append(testCases, testCase{ |
| 2531 | name: "SillyDH", |
| 2532 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2533 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2534 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2535 | Bugs: ProtocolBugs{ |
| 2536 | // This is a 4097-bit prime number, generated |
| 2537 | // with: |
| 2538 | // openssl gendh 4097 | openssl asn1parse -i |
| 2539 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2540 | }, |
| 2541 | }, |
| 2542 | shouldFail: true, |
| 2543 | expectedError: ":DH_P_TOO_LONG:", |
| 2544 | }) |
| 2545 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2546 | // This test ensures that Diffie-Hellman public values are padded with |
| 2547 | // zeros so that they're the same length as the prime. This is to avoid |
| 2548 | // hitting a bug in yaSSL. |
| 2549 | testCases = append(testCases, testCase{ |
| 2550 | testType: serverTest, |
| 2551 | name: "DHPublicValuePadded", |
| 2552 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2553 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2554 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2555 | Bugs: ProtocolBugs{ |
| 2556 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2557 | }, |
| 2558 | }, |
| 2559 | flags: []string{"-use-sparse-dh-prime"}, |
| 2560 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2561 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2562 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2563 | testCases = append(testCases, testCase{ |
| 2564 | testType: serverTest, |
| 2565 | name: "UnknownCipher", |
| 2566 | config: Config{ |
| 2567 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2568 | }, |
| 2569 | }) |
| 2570 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2571 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2572 | testCases = append(testCases, testCase{ |
| 2573 | name: "EmptyECDHEPSKHint", |
| 2574 | config: Config{ |
| 2575 | MaxVersion: VersionTLS12, |
| 2576 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2577 | PreSharedKey: []byte("secret"), |
| 2578 | }, |
| 2579 | flags: []string{"-psk", "secret"}, |
| 2580 | }) |
| 2581 | |
| 2582 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2583 | // ServerKeyExchange is sent. |
| 2584 | testCases = append(testCases, testCase{ |
| 2585 | name: "ExplicitEmptyPSKHint", |
| 2586 | config: Config{ |
| 2587 | MaxVersion: VersionTLS12, |
| 2588 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2589 | PreSharedKey: []byte("secret"), |
| 2590 | Bugs: ProtocolBugs{ |
| 2591 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2592 | }, |
| 2593 | }, |
| 2594 | flags: []string{"-psk", "secret"}, |
| 2595 | }) |
| 2596 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2597 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2598 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2599 | // cipher lists and then a connection is made for each member of |
| 2600 | // expectations. The cipher suite that the server selects must match |
| 2601 | // the specified one. |
| 2602 | var versionSpecificCiphersTest = []struct { |
| 2603 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2604 | // expectations is a map from TLS version to cipher suite id. |
| 2605 | expectations map[uint16]uint16 |
| 2606 | }{ |
| 2607 | { |
| 2608 | // Test that the null case (where no version-specific ciphers are set) |
| 2609 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2610 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2611 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2612 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2613 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2614 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2615 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2616 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2617 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2618 | }, |
| 2619 | }, |
| 2620 | { |
| 2621 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2622 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2623 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2624 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2625 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2626 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2627 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2628 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2629 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2630 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2631 | }, |
| 2632 | }, |
| 2633 | { |
| 2634 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2635 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2636 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2637 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2638 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2639 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2640 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2641 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2642 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2643 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2644 | }, |
| 2645 | }, |
| 2646 | { |
| 2647 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2648 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2649 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2650 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2651 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2652 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2653 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2654 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2655 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2656 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2657 | }, |
| 2658 | }, |
| 2659 | } |
| 2660 | |
| 2661 | for i, test := range versionSpecificCiphersTest { |
| 2662 | for version, expectedCipherSuite := range test.expectations { |
| 2663 | flags := []string{"-cipher", test.ciphersDefault} |
| 2664 | if len(test.ciphersTLS10) > 0 { |
| 2665 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2666 | } |
| 2667 | if len(test.ciphersTLS11) > 0 { |
| 2668 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2669 | } |
| 2670 | |
| 2671 | testCases = append(testCases, testCase{ |
| 2672 | testType: serverTest, |
| 2673 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2674 | config: Config{ |
| 2675 | MaxVersion: version, |
| 2676 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2677 | 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] | 2678 | }, |
| 2679 | flags: flags, |
| 2680 | expectedCipher: expectedCipherSuite, |
| 2681 | }) |
| 2682 | } |
| 2683 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2684 | } |
| 2685 | |
| 2686 | func addBadECDSASignatureTests() { |
| 2687 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2688 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2689 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2690 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2691 | config: Config{ |
| 2692 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2693 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2694 | Bugs: ProtocolBugs{ |
| 2695 | BadECDSAR: badR, |
| 2696 | BadECDSAS: badS, |
| 2697 | }, |
| 2698 | }, |
| 2699 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2700 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2701 | }) |
| 2702 | } |
| 2703 | } |
| 2704 | } |
| 2705 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2706 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2707 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2708 | name: "MaxCBCPadding", |
| 2709 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2710 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2711 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2712 | Bugs: ProtocolBugs{ |
| 2713 | MaxPadding: true, |
| 2714 | }, |
| 2715 | }, |
| 2716 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2717 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2718 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2719 | name: "BadCBCPadding", |
| 2720 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2721 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2722 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2723 | Bugs: ProtocolBugs{ |
| 2724 | PaddingFirstByteBad: true, |
| 2725 | }, |
| 2726 | }, |
| 2727 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2728 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2729 | }) |
| 2730 | // OpenSSL previously had an issue where the first byte of padding in |
| 2731 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2732 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2733 | name: "BadCBCPadding255", |
| 2734 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2735 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2736 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2737 | Bugs: ProtocolBugs{ |
| 2738 | MaxPadding: true, |
| 2739 | PaddingFirstByteBadIf255: true, |
| 2740 | }, |
| 2741 | }, |
| 2742 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2743 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2744 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2745 | }) |
| 2746 | } |
| 2747 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2748 | func addCBCSplittingTests() { |
| 2749 | testCases = append(testCases, testCase{ |
| 2750 | name: "CBCRecordSplitting", |
| 2751 | config: Config{ |
| 2752 | MaxVersion: VersionTLS10, |
| 2753 | MinVersion: VersionTLS10, |
| 2754 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2755 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2756 | messageLen: -1, // read until EOF |
| 2757 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2758 | flags: []string{ |
| 2759 | "-async", |
| 2760 | "-write-different-record-sizes", |
| 2761 | "-cbc-record-splitting", |
| 2762 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2763 | }) |
| 2764 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2765 | name: "CBCRecordSplittingPartialWrite", |
| 2766 | config: Config{ |
| 2767 | MaxVersion: VersionTLS10, |
| 2768 | MinVersion: VersionTLS10, |
| 2769 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2770 | }, |
| 2771 | messageLen: -1, // read until EOF |
| 2772 | flags: []string{ |
| 2773 | "-async", |
| 2774 | "-write-different-record-sizes", |
| 2775 | "-cbc-record-splitting", |
| 2776 | "-partial-write", |
| 2777 | }, |
| 2778 | }) |
| 2779 | } |
| 2780 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2781 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2782 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2783 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2784 | certPool := x509.NewCertPool() |
| 2785 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2786 | if err != nil { |
| 2787 | panic(err) |
| 2788 | } |
| 2789 | certPool.AddCert(cert) |
| 2790 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2791 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2792 | testCases = append(testCases, testCase{ |
| 2793 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2794 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2795 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2796 | MinVersion: ver.version, |
| 2797 | MaxVersion: ver.version, |
| 2798 | ClientAuth: RequireAnyClientCert, |
| 2799 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2800 | }, |
| 2801 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2802 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2803 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2804 | }, |
| 2805 | }) |
| 2806 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2807 | testType: serverTest, |
| 2808 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2809 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2810 | MinVersion: ver.version, |
| 2811 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2812 | Certificates: []Certificate{rsaCertificate}, |
| 2813 | }, |
| 2814 | flags: []string{"-require-any-client-certificate"}, |
| 2815 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2816 | if ver.version != VersionSSL30 { |
| 2817 | testCases = append(testCases, testCase{ |
| 2818 | testType: serverTest, |
| 2819 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 2820 | config: Config{ |
| 2821 | MinVersion: ver.version, |
| 2822 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2823 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2824 | }, |
| 2825 | flags: []string{"-require-any-client-certificate"}, |
| 2826 | }) |
| 2827 | testCases = append(testCases, testCase{ |
| 2828 | testType: clientTest, |
| 2829 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 2830 | config: Config{ |
| 2831 | MinVersion: ver.version, |
| 2832 | MaxVersion: ver.version, |
| 2833 | ClientAuth: RequireAnyClientCert, |
| 2834 | ClientCAs: certPool, |
| 2835 | }, |
| 2836 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2837 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2838 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2839 | }, |
| 2840 | }) |
| 2841 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2842 | |
| 2843 | testCases = append(testCases, testCase{ |
| 2844 | name: "NoClientCertificate-" + ver.name, |
| 2845 | config: Config{ |
| 2846 | MinVersion: ver.version, |
| 2847 | MaxVersion: ver.version, |
| 2848 | ClientAuth: RequireAnyClientCert, |
| 2849 | }, |
| 2850 | shouldFail: true, |
| 2851 | expectedLocalError: "client didn't provide a certificate", |
| 2852 | }) |
| 2853 | |
| 2854 | testCases = append(testCases, testCase{ |
| 2855 | // Even if not configured to expect a certificate, OpenSSL will |
| 2856 | // return X509_V_OK as the verify_result. |
| 2857 | testType: serverTest, |
| 2858 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 2859 | config: Config{ |
| 2860 | MinVersion: ver.version, |
| 2861 | MaxVersion: ver.version, |
| 2862 | }, |
| 2863 | flags: []string{ |
| 2864 | "-expect-verify-result", |
| 2865 | }, |
| 2866 | // TODO(davidben): Switch this to true when TLS 1.3 |
| 2867 | // supports session resumption. |
| 2868 | resumeSession: ver.version < VersionTLS13, |
| 2869 | }) |
| 2870 | |
| 2871 | testCases = append(testCases, testCase{ |
| 2872 | // If a client certificate is not provided, OpenSSL will still |
| 2873 | // return X509_V_OK as the verify_result. |
| 2874 | testType: serverTest, |
| 2875 | name: "NoClientCertificate-Server-" + ver.name, |
| 2876 | config: Config{ |
| 2877 | MinVersion: ver.version, |
| 2878 | MaxVersion: ver.version, |
| 2879 | }, |
| 2880 | flags: []string{ |
| 2881 | "-expect-verify-result", |
| 2882 | "-verify-peer", |
| 2883 | }, |
| 2884 | // TODO(davidben): Switch this to true when TLS 1.3 |
| 2885 | // supports session resumption. |
| 2886 | resumeSession: ver.version < VersionTLS13, |
| 2887 | }) |
| 2888 | |
| 2889 | testCases = append(testCases, testCase{ |
| 2890 | testType: serverTest, |
| 2891 | name: "RequireAnyClientCertificate-" + ver.name, |
| 2892 | config: Config{ |
| 2893 | MinVersion: ver.version, |
| 2894 | MaxVersion: ver.version, |
| 2895 | }, |
| 2896 | flags: []string{"-require-any-client-certificate"}, |
| 2897 | shouldFail: true, |
| 2898 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2899 | }) |
| 2900 | |
| 2901 | if ver.version != VersionSSL30 { |
| 2902 | testCases = append(testCases, testCase{ |
| 2903 | testType: serverTest, |
| 2904 | name: "SkipClientCertificate-" + ver.name, |
| 2905 | config: Config{ |
| 2906 | MinVersion: ver.version, |
| 2907 | MaxVersion: ver.version, |
| 2908 | Bugs: ProtocolBugs{ |
| 2909 | SkipClientCertificate: true, |
| 2910 | }, |
| 2911 | }, |
| 2912 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2913 | flags: []string{"-verify-peer"}, |
| 2914 | shouldFail: true, |
| 2915 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2916 | }) |
| 2917 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2918 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2919 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2920 | // Client auth is only legal in certificate-based ciphers. |
| 2921 | testCases = append(testCases, testCase{ |
| 2922 | testType: clientTest, |
| 2923 | name: "ClientAuth-PSK", |
| 2924 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2925 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2926 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2927 | PreSharedKey: []byte("secret"), |
| 2928 | ClientAuth: RequireAnyClientCert, |
| 2929 | }, |
| 2930 | flags: []string{ |
| 2931 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2932 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2933 | "-psk", "secret", |
| 2934 | }, |
| 2935 | shouldFail: true, |
| 2936 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2937 | }) |
| 2938 | testCases = append(testCases, testCase{ |
| 2939 | testType: clientTest, |
| 2940 | name: "ClientAuth-ECDHE_PSK", |
| 2941 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2942 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2943 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2944 | PreSharedKey: []byte("secret"), |
| 2945 | ClientAuth: RequireAnyClientCert, |
| 2946 | }, |
| 2947 | flags: []string{ |
| 2948 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2949 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2950 | "-psk", "secret", |
| 2951 | }, |
| 2952 | shouldFail: true, |
| 2953 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2954 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 2955 | |
| 2956 | // Regression test for a bug where the client CA list, if explicitly |
| 2957 | // set to NULL, was mis-encoded. |
| 2958 | testCases = append(testCases, testCase{ |
| 2959 | testType: serverTest, |
| 2960 | name: "Null-Client-CA-List", |
| 2961 | config: Config{ |
| 2962 | MaxVersion: VersionTLS12, |
| 2963 | Certificates: []Certificate{rsaCertificate}, |
| 2964 | }, |
| 2965 | flags: []string{ |
| 2966 | "-require-any-client-certificate", |
| 2967 | "-use-null-client-ca-list", |
| 2968 | }, |
| 2969 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2970 | } |
| 2971 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2972 | func addExtendedMasterSecretTests() { |
| 2973 | const expectEMSFlag = "-expect-extended-master-secret" |
| 2974 | |
| 2975 | for _, with := range []bool{false, true} { |
| 2976 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2977 | if with { |
| 2978 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2979 | } |
| 2980 | |
| 2981 | for _, isClient := range []bool{false, true} { |
| 2982 | suffix := "-Server" |
| 2983 | testType := serverTest |
| 2984 | if isClient { |
| 2985 | suffix = "-Client" |
| 2986 | testType = clientTest |
| 2987 | } |
| 2988 | |
| 2989 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2990 | // In TLS 1.3, the extension is irrelevant and |
| 2991 | // always reports as enabled. |
| 2992 | var flags []string |
| 2993 | if with || ver.version >= VersionTLS13 { |
| 2994 | flags = []string{expectEMSFlag} |
| 2995 | } |
| 2996 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2997 | test := testCase{ |
| 2998 | testType: testType, |
| 2999 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3000 | config: Config{ |
| 3001 | MinVersion: ver.version, |
| 3002 | MaxVersion: ver.version, |
| 3003 | Bugs: ProtocolBugs{ |
| 3004 | NoExtendedMasterSecret: !with, |
| 3005 | RequireExtendedMasterSecret: with, |
| 3006 | }, |
| 3007 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3008 | flags: flags, |
| 3009 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3010 | } |
| 3011 | if test.shouldFail { |
| 3012 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3013 | } |
| 3014 | testCases = append(testCases, test) |
| 3015 | } |
| 3016 | } |
| 3017 | } |
| 3018 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3019 | for _, isClient := range []bool{false, true} { |
| 3020 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3021 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3022 | boolToWord := func(b bool) string { |
| 3023 | if b { |
| 3024 | return "Yes" |
| 3025 | } |
| 3026 | return "No" |
| 3027 | } |
| 3028 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3029 | if isClient { |
| 3030 | suffix += "Client" |
| 3031 | } else { |
| 3032 | suffix += "Server" |
| 3033 | } |
| 3034 | |
| 3035 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3036 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3037 | Bugs: ProtocolBugs{ |
| 3038 | RequireExtendedMasterSecret: true, |
| 3039 | }, |
| 3040 | } |
| 3041 | |
| 3042 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3043 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3044 | Bugs: ProtocolBugs{ |
| 3045 | NoExtendedMasterSecret: true, |
| 3046 | }, |
| 3047 | } |
| 3048 | |
| 3049 | test := testCase{ |
| 3050 | name: "ExtendedMasterSecret-" + suffix, |
| 3051 | resumeSession: true, |
| 3052 | } |
| 3053 | |
| 3054 | if !isClient { |
| 3055 | test.testType = serverTest |
| 3056 | } |
| 3057 | |
| 3058 | if supportedInFirstConnection { |
| 3059 | test.config = supportedConfig |
| 3060 | } else { |
| 3061 | test.config = noSupportConfig |
| 3062 | } |
| 3063 | |
| 3064 | if supportedInResumeConnection { |
| 3065 | test.resumeConfig = &supportedConfig |
| 3066 | } else { |
| 3067 | test.resumeConfig = &noSupportConfig |
| 3068 | } |
| 3069 | |
| 3070 | switch suffix { |
| 3071 | case "YesToYes-Client", "YesToYes-Server": |
| 3072 | // When a session is resumed, it should |
| 3073 | // still be aware that its master |
| 3074 | // secret was generated via EMS and |
| 3075 | // thus it's safe to use tls-unique. |
| 3076 | test.flags = []string{expectEMSFlag} |
| 3077 | case "NoToYes-Server": |
| 3078 | // If an original connection did not |
| 3079 | // contain EMS, but a resumption |
| 3080 | // handshake does, then a server should |
| 3081 | // not resume the session. |
| 3082 | test.expectResumeRejected = true |
| 3083 | case "YesToNo-Server": |
| 3084 | // Resuming an EMS session without the |
| 3085 | // EMS extension should cause the |
| 3086 | // server to abort the connection. |
| 3087 | test.shouldFail = true |
| 3088 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3089 | case "NoToYes-Client": |
| 3090 | // A client should abort a connection |
| 3091 | // where the server resumed a non-EMS |
| 3092 | // session but echoed the EMS |
| 3093 | // extension. |
| 3094 | test.shouldFail = true |
| 3095 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3096 | case "YesToNo-Client": |
| 3097 | // A client should abort a connection |
| 3098 | // where the server didn't echo EMS |
| 3099 | // when the session used it. |
| 3100 | test.shouldFail = true |
| 3101 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3102 | } |
| 3103 | |
| 3104 | testCases = append(testCases, test) |
| 3105 | } |
| 3106 | } |
| 3107 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3108 | |
| 3109 | // Switching EMS on renegotiation is forbidden. |
| 3110 | testCases = append(testCases, testCase{ |
| 3111 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3112 | config: Config{ |
| 3113 | MaxVersion: VersionTLS12, |
| 3114 | Bugs: ProtocolBugs{ |
| 3115 | NoExtendedMasterSecret: true, |
| 3116 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3117 | }, |
| 3118 | }, |
| 3119 | renegotiate: 1, |
| 3120 | flags: []string{ |
| 3121 | "-renegotiate-freely", |
| 3122 | "-expect-total-renegotiations", "1", |
| 3123 | }, |
| 3124 | }) |
| 3125 | |
| 3126 | testCases = append(testCases, testCase{ |
| 3127 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3128 | config: Config{ |
| 3129 | MaxVersion: VersionTLS12, |
| 3130 | Bugs: ProtocolBugs{ |
| 3131 | NoExtendedMasterSecret: true, |
| 3132 | }, |
| 3133 | }, |
| 3134 | renegotiate: 1, |
| 3135 | flags: []string{ |
| 3136 | "-renegotiate-freely", |
| 3137 | "-expect-total-renegotiations", "1", |
| 3138 | }, |
| 3139 | shouldFail: true, |
| 3140 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3141 | }) |
| 3142 | |
| 3143 | testCases = append(testCases, testCase{ |
| 3144 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3145 | config: Config{ |
| 3146 | MaxVersion: VersionTLS12, |
| 3147 | Bugs: ProtocolBugs{ |
| 3148 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3149 | }, |
| 3150 | }, |
| 3151 | renegotiate: 1, |
| 3152 | flags: []string{ |
| 3153 | "-renegotiate-freely", |
| 3154 | "-expect-total-renegotiations", "1", |
| 3155 | }, |
| 3156 | shouldFail: true, |
| 3157 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3158 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3159 | } |
| 3160 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3161 | type stateMachineTestConfig struct { |
| 3162 | protocol protocol |
| 3163 | async bool |
| 3164 | splitHandshake, packHandshakeFlight bool |
| 3165 | } |
| 3166 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3167 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3168 | // various conditions. Some of these are redundant with other tests, but they |
| 3169 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3170 | func addAllStateMachineCoverageTests() { |
| 3171 | for _, async := range []bool{false, true} { |
| 3172 | for _, protocol := range []protocol{tls, dtls} { |
| 3173 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3174 | protocol: protocol, |
| 3175 | async: async, |
| 3176 | }) |
| 3177 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3178 | protocol: protocol, |
| 3179 | async: async, |
| 3180 | splitHandshake: true, |
| 3181 | }) |
| 3182 | if protocol == tls { |
| 3183 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3184 | protocol: protocol, |
| 3185 | async: async, |
| 3186 | packHandshakeFlight: true, |
| 3187 | }) |
| 3188 | } |
| 3189 | } |
| 3190 | } |
| 3191 | } |
| 3192 | |
| 3193 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3194 | var tests []testCase |
| 3195 | |
| 3196 | // Basic handshake, with resumption. Client and server, |
| 3197 | // session ID and session ticket. |
| 3198 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3199 | name: "Basic-Client", |
| 3200 | config: Config{ |
| 3201 | MaxVersion: VersionTLS12, |
| 3202 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3203 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3204 | // Ensure session tickets are used, not session IDs. |
| 3205 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3206 | }) |
| 3207 | tests = append(tests, testCase{ |
| 3208 | name: "Basic-Client-RenewTicket", |
| 3209 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3210 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3211 | Bugs: ProtocolBugs{ |
| 3212 | RenewTicketOnResume: true, |
| 3213 | }, |
| 3214 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3215 | flags: []string{"-expect-ticket-renewal"}, |
| 3216 | resumeSession: true, |
| 3217 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3218 | }) |
| 3219 | tests = append(tests, testCase{ |
| 3220 | name: "Basic-Client-NoTicket", |
| 3221 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3222 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3223 | SessionTicketsDisabled: true, |
| 3224 | }, |
| 3225 | resumeSession: true, |
| 3226 | }) |
| 3227 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3228 | name: "Basic-Client-Implicit", |
| 3229 | config: Config{ |
| 3230 | MaxVersion: VersionTLS12, |
| 3231 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3232 | flags: []string{"-implicit-handshake"}, |
| 3233 | resumeSession: true, |
| 3234 | }) |
| 3235 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3236 | testType: serverTest, |
| 3237 | name: "Basic-Server", |
| 3238 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3239 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3240 | Bugs: ProtocolBugs{ |
| 3241 | RequireSessionTickets: true, |
| 3242 | }, |
| 3243 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3244 | resumeSession: true, |
| 3245 | }) |
| 3246 | tests = append(tests, testCase{ |
| 3247 | testType: serverTest, |
| 3248 | name: "Basic-Server-NoTickets", |
| 3249 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3250 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3251 | SessionTicketsDisabled: true, |
| 3252 | }, |
| 3253 | resumeSession: true, |
| 3254 | }) |
| 3255 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3256 | testType: serverTest, |
| 3257 | name: "Basic-Server-Implicit", |
| 3258 | config: Config{ |
| 3259 | MaxVersion: VersionTLS12, |
| 3260 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3261 | flags: []string{"-implicit-handshake"}, |
| 3262 | resumeSession: true, |
| 3263 | }) |
| 3264 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3265 | testType: serverTest, |
| 3266 | name: "Basic-Server-EarlyCallback", |
| 3267 | config: Config{ |
| 3268 | MaxVersion: VersionTLS12, |
| 3269 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3270 | flags: []string{"-use-early-callback"}, |
| 3271 | resumeSession: true, |
| 3272 | }) |
| 3273 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3274 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3275 | if config.protocol == tls { |
| 3276 | tests = append(tests, testCase{ |
| 3277 | name: "TLS13-1RTT-Client", |
| 3278 | config: Config{ |
| 3279 | MaxVersion: VersionTLS13, |
| 3280 | MinVersion: VersionTLS13, |
| 3281 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3282 | resumeSession: true, |
| 3283 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3284 | }) |
| 3285 | |
| 3286 | tests = append(tests, testCase{ |
| 3287 | testType: serverTest, |
| 3288 | name: "TLS13-1RTT-Server", |
| 3289 | config: Config{ |
| 3290 | MaxVersion: VersionTLS13, |
| 3291 | MinVersion: VersionTLS13, |
| 3292 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3293 | resumeSession: true, |
| 3294 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3295 | }) |
| 3296 | |
| 3297 | tests = append(tests, testCase{ |
| 3298 | name: "TLS13-HelloRetryRequest-Client", |
| 3299 | config: Config{ |
| 3300 | MaxVersion: VersionTLS13, |
| 3301 | MinVersion: VersionTLS13, |
| 3302 | // P-384 requires a HelloRetryRequest against |
| 3303 | // BoringSSL's default configuration. Assert |
| 3304 | // that we do indeed test this with |
| 3305 | // ExpectMissingKeyShare. |
| 3306 | CurvePreferences: []CurveID{CurveP384}, |
| 3307 | Bugs: ProtocolBugs{ |
| 3308 | ExpectMissingKeyShare: true, |
| 3309 | }, |
| 3310 | }, |
| 3311 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3312 | resumeSession: true, |
| 3313 | }) |
| 3314 | |
| 3315 | tests = append(tests, testCase{ |
| 3316 | testType: serverTest, |
| 3317 | name: "TLS13-HelloRetryRequest-Server", |
| 3318 | config: Config{ |
| 3319 | MaxVersion: VersionTLS13, |
| 3320 | MinVersion: VersionTLS13, |
| 3321 | // Require a HelloRetryRequest for every curve. |
| 3322 | DefaultCurves: []CurveID{}, |
| 3323 | }, |
| 3324 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3325 | resumeSession: true, |
| 3326 | }) |
| 3327 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3328 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3329 | // TLS client auth. |
| 3330 | tests = append(tests, testCase{ |
| 3331 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3332 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3333 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3334 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3335 | ClientAuth: RequestClientCert, |
| 3336 | }, |
| 3337 | }) |
| 3338 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3339 | testType: serverTest, |
| 3340 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3341 | config: Config{ |
| 3342 | MaxVersion: VersionTLS12, |
| 3343 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3344 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3345 | flags: []string{"-verify-peer"}, |
| 3346 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3347 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3348 | tests = append(tests, testCase{ |
| 3349 | testType: clientTest, |
| 3350 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3351 | config: Config{ |
| 3352 | MaxVersion: VersionSSL30, |
| 3353 | ClientAuth: RequestClientCert, |
| 3354 | }, |
| 3355 | }) |
| 3356 | tests = append(tests, testCase{ |
| 3357 | testType: serverTest, |
| 3358 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3359 | config: Config{ |
| 3360 | MaxVersion: VersionSSL30, |
| 3361 | }, |
| 3362 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3363 | flags: []string{"-verify-peer"}, |
| 3364 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3365 | tests = append(tests, testCase{ |
| 3366 | testType: clientTest, |
| 3367 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3368 | config: Config{ |
| 3369 | MaxVersion: VersionTLS13, |
| 3370 | ClientAuth: RequestClientCert, |
| 3371 | }, |
| 3372 | }) |
| 3373 | tests = append(tests, testCase{ |
| 3374 | testType: serverTest, |
| 3375 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3376 | config: Config{ |
| 3377 | MaxVersion: VersionTLS13, |
| 3378 | }, |
| 3379 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3380 | flags: []string{"-verify-peer"}, |
| 3381 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3382 | } |
| 3383 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3384 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3385 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3386 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3387 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3388 | ClientAuth: RequireAnyClientCert, |
| 3389 | }, |
| 3390 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3391 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3392 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3393 | }, |
| 3394 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3395 | tests = append(tests, testCase{ |
| 3396 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3397 | name: "ClientAuth-RSA-Client-TLS13", |
| 3398 | config: Config{ |
| 3399 | MaxVersion: VersionTLS13, |
| 3400 | ClientAuth: RequireAnyClientCert, |
| 3401 | }, |
| 3402 | flags: []string{ |
| 3403 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3404 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3405 | }, |
| 3406 | }) |
| 3407 | tests = append(tests, testCase{ |
| 3408 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3409 | name: "ClientAuth-ECDSA-Client", |
| 3410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3411 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3412 | ClientAuth: RequireAnyClientCert, |
| 3413 | }, |
| 3414 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3415 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3416 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3417 | }, |
| 3418 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3419 | tests = append(tests, testCase{ |
| 3420 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3421 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3422 | config: Config{ |
| 3423 | MaxVersion: VersionTLS13, |
| 3424 | ClientAuth: RequireAnyClientCert, |
| 3425 | }, |
| 3426 | flags: []string{ |
| 3427 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3428 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3429 | }, |
| 3430 | }) |
| 3431 | tests = append(tests, testCase{ |
| 3432 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3433 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3434 | config: Config{ |
| 3435 | MaxVersion: VersionTLS12, |
| 3436 | ClientAuth: RequestClientCert, |
| 3437 | }, |
| 3438 | flags: []string{"-use-old-client-cert-callback"}, |
| 3439 | }) |
| 3440 | tests = append(tests, testCase{ |
| 3441 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3442 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3443 | config: Config{ |
| 3444 | MaxVersion: VersionTLS13, |
| 3445 | ClientAuth: RequestClientCert, |
| 3446 | }, |
| 3447 | flags: []string{"-use-old-client-cert-callback"}, |
| 3448 | }) |
| 3449 | tests = append(tests, testCase{ |
| 3450 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3451 | name: "ClientAuth-OldCallback", |
| 3452 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3453 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3454 | ClientAuth: RequireAnyClientCert, |
| 3455 | }, |
| 3456 | flags: []string{ |
| 3457 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3458 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3459 | "-use-old-client-cert-callback", |
| 3460 | }, |
| 3461 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3462 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3463 | testType: clientTest, |
| 3464 | name: "ClientAuth-OldCallback-TLS13", |
| 3465 | config: Config{ |
| 3466 | MaxVersion: VersionTLS13, |
| 3467 | ClientAuth: RequireAnyClientCert, |
| 3468 | }, |
| 3469 | flags: []string{ |
| 3470 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3471 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3472 | "-use-old-client-cert-callback", |
| 3473 | }, |
| 3474 | }) |
| 3475 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3476 | testType: serverTest, |
| 3477 | name: "ClientAuth-Server", |
| 3478 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3479 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3480 | Certificates: []Certificate{rsaCertificate}, |
| 3481 | }, |
| 3482 | flags: []string{"-require-any-client-certificate"}, |
| 3483 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3484 | tests = append(tests, testCase{ |
| 3485 | testType: serverTest, |
| 3486 | name: "ClientAuth-Server-TLS13", |
| 3487 | config: Config{ |
| 3488 | MaxVersion: VersionTLS13, |
| 3489 | Certificates: []Certificate{rsaCertificate}, |
| 3490 | }, |
| 3491 | flags: []string{"-require-any-client-certificate"}, |
| 3492 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3493 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3494 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3495 | tests = append(tests, testCase{ |
| 3496 | testType: serverTest, |
| 3497 | name: "Basic-Server-RSA", |
| 3498 | config: Config{ |
| 3499 | MaxVersion: VersionTLS12, |
| 3500 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3501 | }, |
| 3502 | flags: []string{ |
| 3503 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3504 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3505 | }, |
| 3506 | }) |
| 3507 | tests = append(tests, testCase{ |
| 3508 | testType: serverTest, |
| 3509 | name: "Basic-Server-ECDHE-RSA", |
| 3510 | config: Config{ |
| 3511 | MaxVersion: VersionTLS12, |
| 3512 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3513 | }, |
| 3514 | flags: []string{ |
| 3515 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3516 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3517 | }, |
| 3518 | }) |
| 3519 | tests = append(tests, testCase{ |
| 3520 | testType: serverTest, |
| 3521 | name: "Basic-Server-ECDHE-ECDSA", |
| 3522 | config: Config{ |
| 3523 | MaxVersion: VersionTLS12, |
| 3524 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3525 | }, |
| 3526 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3527 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3528 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3529 | }, |
| 3530 | }) |
| 3531 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3532 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3533 | tests = append(tests, testCase{ |
| 3534 | name: "SessionTicketsDisabled-Client", |
| 3535 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3536 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3537 | SessionTicketsDisabled: true, |
| 3538 | }, |
| 3539 | }) |
| 3540 | tests = append(tests, testCase{ |
| 3541 | testType: serverTest, |
| 3542 | name: "SessionTicketsDisabled-Server", |
| 3543 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3544 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3545 | SessionTicketsDisabled: true, |
| 3546 | }, |
| 3547 | }) |
| 3548 | |
| 3549 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3550 | // identity hint. |
| 3551 | tests = append(tests, testCase{ |
| 3552 | name: "EmptyPSKHint-Client", |
| 3553 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3554 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3555 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3556 | PreSharedKey: []byte("secret"), |
| 3557 | }, |
| 3558 | flags: []string{"-psk", "secret"}, |
| 3559 | }) |
| 3560 | tests = append(tests, testCase{ |
| 3561 | testType: serverTest, |
| 3562 | name: "EmptyPSKHint-Server", |
| 3563 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3564 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3565 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3566 | PreSharedKey: []byte("secret"), |
| 3567 | }, |
| 3568 | flags: []string{"-psk", "secret"}, |
| 3569 | }) |
| 3570 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3571 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3572 | tests = append(tests, testCase{ |
| 3573 | testType: clientTest, |
| 3574 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3575 | config: Config{ |
| 3576 | MaxVersion: VersionTLS12, |
| 3577 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3578 | flags: []string{ |
| 3579 | "-enable-ocsp-stapling", |
| 3580 | "-expect-ocsp-response", |
| 3581 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3582 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3583 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3584 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3585 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3586 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3587 | testType: serverTest, |
| 3588 | name: "OCSPStapling-Server", |
| 3589 | config: Config{ |
| 3590 | MaxVersion: VersionTLS12, |
| 3591 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3592 | expectedOCSPResponse: testOCSPResponse, |
| 3593 | flags: []string{ |
| 3594 | "-ocsp-response", |
| 3595 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3596 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3597 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3598 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3599 | tests = append(tests, testCase{ |
| 3600 | testType: clientTest, |
| 3601 | name: "OCSPStapling-Client-TLS13", |
| 3602 | config: Config{ |
| 3603 | MaxVersion: VersionTLS13, |
| 3604 | }, |
| 3605 | flags: []string{ |
| 3606 | "-enable-ocsp-stapling", |
| 3607 | "-expect-ocsp-response", |
| 3608 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3609 | "-verify-peer", |
| 3610 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3611 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3612 | }) |
| 3613 | tests = append(tests, testCase{ |
| 3614 | testType: serverTest, |
| 3615 | name: "OCSPStapling-Server-TLS13", |
| 3616 | config: Config{ |
| 3617 | MaxVersion: VersionTLS13, |
| 3618 | }, |
| 3619 | expectedOCSPResponse: testOCSPResponse, |
| 3620 | flags: []string{ |
| 3621 | "-ocsp-response", |
| 3622 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3623 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3624 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3625 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3626 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3627 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3628 | for _, vers := range tlsVersions { |
| 3629 | if config.protocol == dtls && !vers.hasDTLS { |
| 3630 | continue |
| 3631 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3632 | for _, testType := range []testType{clientTest, serverTest} { |
| 3633 | suffix := "-Client" |
| 3634 | if testType == serverTest { |
| 3635 | suffix = "-Server" |
| 3636 | } |
| 3637 | suffix += "-" + vers.name |
| 3638 | |
| 3639 | flag := "-verify-peer" |
| 3640 | if testType == serverTest { |
| 3641 | flag = "-require-any-client-certificate" |
| 3642 | } |
| 3643 | |
| 3644 | tests = append(tests, testCase{ |
| 3645 | testType: testType, |
| 3646 | name: "CertificateVerificationSucceed" + suffix, |
| 3647 | config: Config{ |
| 3648 | MaxVersion: vers.version, |
| 3649 | Certificates: []Certificate{rsaCertificate}, |
| 3650 | }, |
| 3651 | flags: []string{ |
| 3652 | flag, |
| 3653 | "-expect-verify-result", |
| 3654 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3655 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3656 | }) |
| 3657 | tests = append(tests, testCase{ |
| 3658 | testType: testType, |
| 3659 | name: "CertificateVerificationFail" + suffix, |
| 3660 | config: Config{ |
| 3661 | MaxVersion: vers.version, |
| 3662 | Certificates: []Certificate{rsaCertificate}, |
| 3663 | }, |
| 3664 | flags: []string{ |
| 3665 | flag, |
| 3666 | "-verify-fail", |
| 3667 | }, |
| 3668 | shouldFail: true, |
| 3669 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3670 | }) |
| 3671 | } |
| 3672 | |
| 3673 | // By default, the client is in a soft fail mode where the peer |
| 3674 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3675 | tests = append(tests, testCase{ |
| 3676 | testType: clientTest, |
| 3677 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3678 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3679 | MaxVersion: vers.version, |
| 3680 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3681 | }, |
| 3682 | flags: []string{ |
| 3683 | "-verify-fail", |
| 3684 | "-expect-verify-result", |
| 3685 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3686 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3687 | }) |
| 3688 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3689 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3690 | tests = append(tests, testCase{ |
| 3691 | name: "ShimSendAlert", |
| 3692 | flags: []string{"-send-alert"}, |
| 3693 | shimWritesFirst: true, |
| 3694 | shouldFail: true, |
| 3695 | expectedLocalError: "remote error: decompression failure", |
| 3696 | }) |
| 3697 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3698 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3699 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3700 | name: "Renegotiate-Client", |
| 3701 | config: Config{ |
| 3702 | MaxVersion: VersionTLS12, |
| 3703 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3704 | renegotiate: 1, |
| 3705 | flags: []string{ |
| 3706 | "-renegotiate-freely", |
| 3707 | "-expect-total-renegotiations", "1", |
| 3708 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3709 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3710 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3711 | tests = append(tests, testCase{ |
| 3712 | name: "SendHalfHelloRequest", |
| 3713 | config: Config{ |
| 3714 | MaxVersion: VersionTLS12, |
| 3715 | Bugs: ProtocolBugs{ |
| 3716 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3717 | }, |
| 3718 | }, |
| 3719 | sendHalfHelloRequest: true, |
| 3720 | flags: []string{"-renegotiate-ignore"}, |
| 3721 | shouldFail: true, |
| 3722 | expectedError: ":UNEXPECTED_RECORD:", |
| 3723 | }) |
| 3724 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3725 | // NPN on client and server; results in post-handshake message. |
| 3726 | tests = append(tests, testCase{ |
| 3727 | name: "NPN-Client", |
| 3728 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3729 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3730 | NextProtos: []string{"foo"}, |
| 3731 | }, |
| 3732 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3733 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3734 | expectedNextProto: "foo", |
| 3735 | expectedNextProtoType: npn, |
| 3736 | }) |
| 3737 | tests = append(tests, testCase{ |
| 3738 | testType: serverTest, |
| 3739 | name: "NPN-Server", |
| 3740 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3741 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3742 | NextProtos: []string{"bar"}, |
| 3743 | }, |
| 3744 | flags: []string{ |
| 3745 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3746 | "-expect-next-proto", "bar", |
| 3747 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3748 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3749 | expectedNextProto: "bar", |
| 3750 | expectedNextProtoType: npn, |
| 3751 | }) |
| 3752 | |
| 3753 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3754 | |
| 3755 | // Client does False Start and negotiates NPN. |
| 3756 | tests = append(tests, testCase{ |
| 3757 | name: "FalseStart", |
| 3758 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3759 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3760 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3761 | NextProtos: []string{"foo"}, |
| 3762 | Bugs: ProtocolBugs{ |
| 3763 | ExpectFalseStart: true, |
| 3764 | }, |
| 3765 | }, |
| 3766 | flags: []string{ |
| 3767 | "-false-start", |
| 3768 | "-select-next-proto", "foo", |
| 3769 | }, |
| 3770 | shimWritesFirst: true, |
| 3771 | resumeSession: true, |
| 3772 | }) |
| 3773 | |
| 3774 | // Client does False Start and negotiates ALPN. |
| 3775 | tests = append(tests, testCase{ |
| 3776 | name: "FalseStart-ALPN", |
| 3777 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3778 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3779 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3780 | NextProtos: []string{"foo"}, |
| 3781 | Bugs: ProtocolBugs{ |
| 3782 | ExpectFalseStart: true, |
| 3783 | }, |
| 3784 | }, |
| 3785 | flags: []string{ |
| 3786 | "-false-start", |
| 3787 | "-advertise-alpn", "\x03foo", |
| 3788 | }, |
| 3789 | shimWritesFirst: true, |
| 3790 | resumeSession: true, |
| 3791 | }) |
| 3792 | |
| 3793 | // Client does False Start but doesn't explicitly call |
| 3794 | // SSL_connect. |
| 3795 | tests = append(tests, testCase{ |
| 3796 | name: "FalseStart-Implicit", |
| 3797 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3798 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3799 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3800 | NextProtos: []string{"foo"}, |
| 3801 | }, |
| 3802 | flags: []string{ |
| 3803 | "-implicit-handshake", |
| 3804 | "-false-start", |
| 3805 | "-advertise-alpn", "\x03foo", |
| 3806 | }, |
| 3807 | }) |
| 3808 | |
| 3809 | // False Start without session tickets. |
| 3810 | tests = append(tests, testCase{ |
| 3811 | name: "FalseStart-SessionTicketsDisabled", |
| 3812 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3813 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3814 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3815 | NextProtos: []string{"foo"}, |
| 3816 | SessionTicketsDisabled: true, |
| 3817 | Bugs: ProtocolBugs{ |
| 3818 | ExpectFalseStart: true, |
| 3819 | }, |
| 3820 | }, |
| 3821 | flags: []string{ |
| 3822 | "-false-start", |
| 3823 | "-select-next-proto", "foo", |
| 3824 | }, |
| 3825 | shimWritesFirst: true, |
| 3826 | }) |
| 3827 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 3828 | tests = append(tests, testCase{ |
| 3829 | name: "FalseStart-CECPQ1", |
| 3830 | config: Config{ |
| 3831 | MaxVersion: VersionTLS12, |
| 3832 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 3833 | NextProtos: []string{"foo"}, |
| 3834 | Bugs: ProtocolBugs{ |
| 3835 | ExpectFalseStart: true, |
| 3836 | }, |
| 3837 | }, |
| 3838 | flags: []string{ |
| 3839 | "-false-start", |
| 3840 | "-cipher", "DEFAULT:kCECPQ1", |
| 3841 | "-select-next-proto", "foo", |
| 3842 | }, |
| 3843 | shimWritesFirst: true, |
| 3844 | resumeSession: true, |
| 3845 | }) |
| 3846 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3847 | // Server parses a V2ClientHello. |
| 3848 | tests = append(tests, testCase{ |
| 3849 | testType: serverTest, |
| 3850 | name: "SendV2ClientHello", |
| 3851 | config: Config{ |
| 3852 | // Choose a cipher suite that does not involve |
| 3853 | // elliptic curves, so no extensions are |
| 3854 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3855 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 3856 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3857 | Bugs: ProtocolBugs{ |
| 3858 | SendV2ClientHello: true, |
| 3859 | }, |
| 3860 | }, |
| 3861 | }) |
| 3862 | |
| 3863 | // Client sends a Channel ID. |
| 3864 | tests = append(tests, testCase{ |
| 3865 | name: "ChannelID-Client", |
| 3866 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3867 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3868 | RequestChannelID: true, |
| 3869 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3870 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3871 | resumeSession: true, |
| 3872 | expectChannelID: true, |
| 3873 | }) |
| 3874 | |
| 3875 | // Server accepts a Channel ID. |
| 3876 | tests = append(tests, testCase{ |
| 3877 | testType: serverTest, |
| 3878 | name: "ChannelID-Server", |
| 3879 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3880 | MaxVersion: VersionTLS12, |
| 3881 | ChannelID: channelIDKey, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3882 | }, |
| 3883 | flags: []string{ |
| 3884 | "-expect-channel-id", |
| 3885 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3886 | }, |
| 3887 | resumeSession: true, |
| 3888 | expectChannelID: true, |
| 3889 | }) |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3890 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3891 | // Channel ID and NPN at the same time, to ensure their relative |
| 3892 | // ordering is correct. |
| 3893 | tests = append(tests, testCase{ |
| 3894 | name: "ChannelID-NPN-Client", |
| 3895 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3896 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3897 | RequestChannelID: true, |
| 3898 | NextProtos: []string{"foo"}, |
| 3899 | }, |
| 3900 | flags: []string{ |
| 3901 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 3902 | "-select-next-proto", "foo", |
| 3903 | }, |
| 3904 | resumeSession: true, |
| 3905 | expectChannelID: true, |
| 3906 | expectedNextProto: "foo", |
| 3907 | expectedNextProtoType: npn, |
| 3908 | }) |
| 3909 | tests = append(tests, testCase{ |
| 3910 | testType: serverTest, |
| 3911 | name: "ChannelID-NPN-Server", |
| 3912 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3913 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3914 | ChannelID: channelIDKey, |
| 3915 | NextProtos: []string{"bar"}, |
| 3916 | }, |
| 3917 | flags: []string{ |
| 3918 | "-expect-channel-id", |
| 3919 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3920 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3921 | "-expect-next-proto", "bar", |
| 3922 | }, |
| 3923 | resumeSession: true, |
| 3924 | expectChannelID: true, |
| 3925 | expectedNextProto: "bar", |
| 3926 | expectedNextProtoType: npn, |
| 3927 | }) |
| 3928 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3929 | // Bidirectional shutdown with the runner initiating. |
| 3930 | tests = append(tests, testCase{ |
| 3931 | name: "Shutdown-Runner", |
| 3932 | config: Config{ |
| 3933 | Bugs: ProtocolBugs{ |
| 3934 | ExpectCloseNotify: true, |
| 3935 | }, |
| 3936 | }, |
| 3937 | flags: []string{"-check-close-notify"}, |
| 3938 | }) |
| 3939 | |
| 3940 | // Bidirectional shutdown with the shim initiating. The runner, |
| 3941 | // in the meantime, sends garbage before the close_notify which |
| 3942 | // the shim must ignore. |
| 3943 | tests = append(tests, testCase{ |
| 3944 | name: "Shutdown-Shim", |
| 3945 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 3946 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3947 | Bugs: ProtocolBugs{ |
| 3948 | ExpectCloseNotify: true, |
| 3949 | }, |
| 3950 | }, |
| 3951 | shimShutsDown: true, |
| 3952 | sendEmptyRecords: 1, |
| 3953 | sendWarningAlerts: 1, |
| 3954 | flags: []string{"-check-close-notify"}, |
| 3955 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3956 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3957 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 3958 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3959 | tests = append(tests, testCase{ |
| 3960 | name: "SkipHelloVerifyRequest", |
| 3961 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3962 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3963 | Bugs: ProtocolBugs{ |
| 3964 | SkipHelloVerifyRequest: true, |
| 3965 | }, |
| 3966 | }, |
| 3967 | }) |
| 3968 | } |
| 3969 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3970 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3971 | test.protocol = config.protocol |
| 3972 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3973 | test.name += "-DTLS" |
| 3974 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3975 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3976 | test.name += "-Async" |
| 3977 | test.flags = append(test.flags, "-async") |
| 3978 | } else { |
| 3979 | test.name += "-Sync" |
| 3980 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3981 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3982 | test.name += "-SplitHandshakeRecords" |
| 3983 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3984 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3985 | test.config.Bugs.MaxPacketLength = 256 |
| 3986 | test.flags = append(test.flags, "-mtu", "256") |
| 3987 | } |
| 3988 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3989 | if config.packHandshakeFlight { |
| 3990 | test.name += "-PackHandshakeFlight" |
| 3991 | test.config.Bugs.PackHandshakeFlight = true |
| 3992 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3993 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 3994 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3995 | } |
| 3996 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3997 | func addDDoSCallbackTests() { |
| 3998 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3999 | for _, resume := range []bool{false, true} { |
| 4000 | suffix := "Resume" |
| 4001 | if resume { |
| 4002 | suffix = "No" + suffix |
| 4003 | } |
| 4004 | |
| 4005 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4006 | testType: serverTest, |
| 4007 | name: "Server-DDoS-OK-" + suffix, |
| 4008 | config: Config{ |
| 4009 | MaxVersion: VersionTLS12, |
| 4010 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4011 | flags: []string{"-install-ddos-callback"}, |
| 4012 | resumeSession: resume, |
| 4013 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4014 | testCases = append(testCases, testCase{ |
| 4015 | testType: serverTest, |
| 4016 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4017 | config: Config{ |
| 4018 | MaxVersion: VersionTLS13, |
| 4019 | }, |
| 4020 | flags: []string{"-install-ddos-callback"}, |
| 4021 | resumeSession: resume, |
| 4022 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4023 | |
| 4024 | failFlag := "-fail-ddos-callback" |
| 4025 | if resume { |
| 4026 | failFlag = "-fail-second-ddos-callback" |
| 4027 | } |
| 4028 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4029 | testType: serverTest, |
| 4030 | name: "Server-DDoS-Reject-" + suffix, |
| 4031 | config: Config{ |
| 4032 | MaxVersion: VersionTLS12, |
| 4033 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4034 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4035 | resumeSession: resume, |
| 4036 | shouldFail: true, |
| 4037 | expectedError: ":CONNECTION_REJECTED:", |
| 4038 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4039 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4040 | testCases = append(testCases, testCase{ |
| 4041 | testType: serverTest, |
| 4042 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4043 | config: Config{ |
| 4044 | MaxVersion: VersionTLS13, |
| 4045 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4046 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4047 | resumeSession: resume, |
| 4048 | shouldFail: true, |
| 4049 | expectedError: ":CONNECTION_REJECTED:", |
| 4050 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4051 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4052 | } |
| 4053 | } |
| 4054 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4055 | func addVersionNegotiationTests() { |
| 4056 | for i, shimVers := range tlsVersions { |
| 4057 | // Assemble flags to disable all newer versions on the shim. |
| 4058 | var flags []string |
| 4059 | for _, vers := range tlsVersions[i+1:] { |
| 4060 | flags = append(flags, vers.flag) |
| 4061 | } |
| 4062 | |
| 4063 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4064 | protocols := []protocol{tls} |
| 4065 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4066 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4067 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4068 | for _, protocol := range protocols { |
| 4069 | expectedVersion := shimVers.version |
| 4070 | if runnerVers.version < shimVers.version { |
| 4071 | expectedVersion = runnerVers.version |
| 4072 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4073 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4074 | suffix := shimVers.name + "-" + runnerVers.name |
| 4075 | if protocol == dtls { |
| 4076 | suffix += "-DTLS" |
| 4077 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4078 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4079 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4080 | |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4081 | clientVers := shimVers.version |
| 4082 | if clientVers > VersionTLS10 { |
| 4083 | clientVers = VersionTLS10 |
| 4084 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4085 | serverVers := expectedVersion |
| 4086 | if expectedVersion >= VersionTLS13 { |
| 4087 | serverVers = VersionTLS10 |
| 4088 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4089 | testCases = append(testCases, testCase{ |
| 4090 | protocol: protocol, |
| 4091 | testType: clientTest, |
| 4092 | name: "VersionNegotiation-Client-" + suffix, |
| 4093 | config: Config{ |
| 4094 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4095 | Bugs: ProtocolBugs{ |
| 4096 | ExpectInitialRecordVersion: clientVers, |
| 4097 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4098 | }, |
| 4099 | flags: flags, |
| 4100 | expectedVersion: expectedVersion, |
| 4101 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4102 | testCases = append(testCases, testCase{ |
| 4103 | protocol: protocol, |
| 4104 | testType: clientTest, |
| 4105 | name: "VersionNegotiation-Client2-" + suffix, |
| 4106 | config: Config{ |
| 4107 | MaxVersion: runnerVers.version, |
| 4108 | Bugs: ProtocolBugs{ |
| 4109 | ExpectInitialRecordVersion: clientVers, |
| 4110 | }, |
| 4111 | }, |
| 4112 | flags: []string{"-max-version", shimVersFlag}, |
| 4113 | expectedVersion: expectedVersion, |
| 4114 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4115 | |
| 4116 | testCases = append(testCases, testCase{ |
| 4117 | protocol: protocol, |
| 4118 | testType: serverTest, |
| 4119 | name: "VersionNegotiation-Server-" + suffix, |
| 4120 | config: Config{ |
| 4121 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4122 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4123 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4124 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4125 | }, |
| 4126 | flags: flags, |
| 4127 | expectedVersion: expectedVersion, |
| 4128 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4129 | testCases = append(testCases, testCase{ |
| 4130 | protocol: protocol, |
| 4131 | testType: serverTest, |
| 4132 | name: "VersionNegotiation-Server2-" + suffix, |
| 4133 | config: Config{ |
| 4134 | MaxVersion: runnerVers.version, |
| 4135 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4136 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4137 | }, |
| 4138 | }, |
| 4139 | flags: []string{"-max-version", shimVersFlag}, |
| 4140 | expectedVersion: expectedVersion, |
| 4141 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4142 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4143 | } |
| 4144 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4145 | |
| 4146 | // Test for version tolerance. |
| 4147 | testCases = append(testCases, testCase{ |
| 4148 | testType: serverTest, |
| 4149 | name: "MinorVersionTolerance", |
| 4150 | config: Config{ |
| 4151 | Bugs: ProtocolBugs{ |
| 4152 | SendClientVersion: 0x03ff, |
| 4153 | }, |
| 4154 | }, |
| 4155 | expectedVersion: VersionTLS13, |
| 4156 | }) |
| 4157 | testCases = append(testCases, testCase{ |
| 4158 | testType: serverTest, |
| 4159 | name: "MajorVersionTolerance", |
| 4160 | config: Config{ |
| 4161 | Bugs: ProtocolBugs{ |
| 4162 | SendClientVersion: 0x0400, |
| 4163 | }, |
| 4164 | }, |
| 4165 | expectedVersion: VersionTLS13, |
| 4166 | }) |
| 4167 | testCases = append(testCases, testCase{ |
| 4168 | protocol: dtls, |
| 4169 | testType: serverTest, |
| 4170 | name: "MinorVersionTolerance-DTLS", |
| 4171 | config: Config{ |
| 4172 | Bugs: ProtocolBugs{ |
| 4173 | SendClientVersion: 0x03ff, |
| 4174 | }, |
| 4175 | }, |
| 4176 | expectedVersion: VersionTLS12, |
| 4177 | }) |
| 4178 | testCases = append(testCases, testCase{ |
| 4179 | protocol: dtls, |
| 4180 | testType: serverTest, |
| 4181 | name: "MajorVersionTolerance-DTLS", |
| 4182 | config: Config{ |
| 4183 | Bugs: ProtocolBugs{ |
| 4184 | SendClientVersion: 0x0400, |
| 4185 | }, |
| 4186 | }, |
| 4187 | expectedVersion: VersionTLS12, |
| 4188 | }) |
| 4189 | |
| 4190 | // Test that versions below 3.0 are rejected. |
| 4191 | testCases = append(testCases, testCase{ |
| 4192 | testType: serverTest, |
| 4193 | name: "VersionTooLow", |
| 4194 | config: Config{ |
| 4195 | Bugs: ProtocolBugs{ |
| 4196 | SendClientVersion: 0x0200, |
| 4197 | }, |
| 4198 | }, |
| 4199 | shouldFail: true, |
| 4200 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4201 | }) |
| 4202 | testCases = append(testCases, testCase{ |
| 4203 | protocol: dtls, |
| 4204 | testType: serverTest, |
| 4205 | name: "VersionTooLow-DTLS", |
| 4206 | config: Config{ |
| 4207 | Bugs: ProtocolBugs{ |
| 4208 | // 0x0201 is the lowest version expressable in |
| 4209 | // DTLS. |
| 4210 | SendClientVersion: 0x0201, |
| 4211 | }, |
| 4212 | }, |
| 4213 | shouldFail: true, |
| 4214 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4215 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4216 | |
| 4217 | // Test TLS 1.3's downgrade signal. |
| 4218 | testCases = append(testCases, testCase{ |
| 4219 | name: "Downgrade-TLS12-Client", |
| 4220 | config: Config{ |
| 4221 | Bugs: ProtocolBugs{ |
| 4222 | NegotiateVersion: VersionTLS12, |
| 4223 | }, |
| 4224 | }, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4225 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4226 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4227 | }) |
| 4228 | testCases = append(testCases, testCase{ |
| 4229 | testType: serverTest, |
| 4230 | name: "Downgrade-TLS12-Server", |
| 4231 | config: Config{ |
| 4232 | Bugs: ProtocolBugs{ |
| 4233 | SendClientVersion: VersionTLS12, |
| 4234 | }, |
| 4235 | }, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4236 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4237 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4238 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4239 | } |
| 4240 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4241 | func addMinimumVersionTests() { |
| 4242 | for i, shimVers := range tlsVersions { |
| 4243 | // Assemble flags to disable all older versions on the shim. |
| 4244 | var flags []string |
| 4245 | for _, vers := range tlsVersions[:i] { |
| 4246 | flags = append(flags, vers.flag) |
| 4247 | } |
| 4248 | |
| 4249 | for _, runnerVers := range tlsVersions { |
| 4250 | protocols := []protocol{tls} |
| 4251 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4252 | protocols = append(protocols, dtls) |
| 4253 | } |
| 4254 | for _, protocol := range protocols { |
| 4255 | suffix := shimVers.name + "-" + runnerVers.name |
| 4256 | if protocol == dtls { |
| 4257 | suffix += "-DTLS" |
| 4258 | } |
| 4259 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4260 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4261 | var expectedVersion uint16 |
| 4262 | var shouldFail bool |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4263 | var expectedClientError, expectedServerError string |
| 4264 | var expectedClientLocalError, expectedServerLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4265 | if runnerVers.version >= shimVers.version { |
| 4266 | expectedVersion = runnerVers.version |
| 4267 | } else { |
| 4268 | shouldFail = true |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4269 | expectedServerError = ":UNSUPPORTED_PROTOCOL:" |
| 4270 | expectedServerLocalError = "remote error: protocol version not supported" |
| 4271 | if shimVers.version >= VersionTLS13 && runnerVers.version <= VersionTLS11 { |
| 4272 | // If the client's minimum version is TLS 1.3 and the runner's |
| 4273 | // maximum is below TLS 1.2, the runner will fail to select a |
| 4274 | // cipher before the shim rejects the selected version. |
| 4275 | expectedClientError = ":SSLV3_ALERT_HANDSHAKE_FAILURE:" |
| 4276 | expectedClientLocalError = "tls: no cipher suite supported by both client and server" |
| 4277 | } else { |
| 4278 | expectedClientError = expectedServerError |
| 4279 | expectedClientLocalError = expectedServerLocalError |
| 4280 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4281 | } |
| 4282 | |
| 4283 | testCases = append(testCases, testCase{ |
| 4284 | protocol: protocol, |
| 4285 | testType: clientTest, |
| 4286 | name: "MinimumVersion-Client-" + suffix, |
| 4287 | config: Config{ |
| 4288 | MaxVersion: runnerVers.version, |
| 4289 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4290 | flags: flags, |
| 4291 | expectedVersion: expectedVersion, |
| 4292 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4293 | expectedError: expectedClientError, |
| 4294 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4295 | }) |
| 4296 | testCases = append(testCases, testCase{ |
| 4297 | protocol: protocol, |
| 4298 | testType: clientTest, |
| 4299 | name: "MinimumVersion-Client2-" + suffix, |
| 4300 | config: Config{ |
| 4301 | MaxVersion: runnerVers.version, |
| 4302 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4303 | flags: []string{"-min-version", shimVersFlag}, |
| 4304 | expectedVersion: expectedVersion, |
| 4305 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4306 | expectedError: expectedClientError, |
| 4307 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4308 | }) |
| 4309 | |
| 4310 | testCases = append(testCases, testCase{ |
| 4311 | protocol: protocol, |
| 4312 | testType: serverTest, |
| 4313 | name: "MinimumVersion-Server-" + suffix, |
| 4314 | config: Config{ |
| 4315 | MaxVersion: runnerVers.version, |
| 4316 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4317 | flags: flags, |
| 4318 | expectedVersion: expectedVersion, |
| 4319 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4320 | expectedError: expectedServerError, |
| 4321 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4322 | }) |
| 4323 | testCases = append(testCases, testCase{ |
| 4324 | protocol: protocol, |
| 4325 | testType: serverTest, |
| 4326 | name: "MinimumVersion-Server2-" + suffix, |
| 4327 | config: Config{ |
| 4328 | MaxVersion: runnerVers.version, |
| 4329 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4330 | flags: []string{"-min-version", shimVersFlag}, |
| 4331 | expectedVersion: expectedVersion, |
| 4332 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4333 | expectedError: expectedServerError, |
| 4334 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4335 | }) |
| 4336 | } |
| 4337 | } |
| 4338 | } |
| 4339 | } |
| 4340 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4341 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4342 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4343 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4344 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4345 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4346 | // Repeat extensions tests all versions except SSL 3.0. |
| 4347 | for _, ver := range tlsVersions { |
| 4348 | if ver.version == VersionSSL30 { |
| 4349 | continue |
| 4350 | } |
| 4351 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4352 | // Test that duplicate extensions are rejected. |
| 4353 | testCases = append(testCases, testCase{ |
| 4354 | testType: clientTest, |
| 4355 | name: "DuplicateExtensionClient-" + ver.name, |
| 4356 | config: Config{ |
| 4357 | MaxVersion: ver.version, |
| 4358 | Bugs: ProtocolBugs{ |
| 4359 | DuplicateExtension: true, |
| 4360 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4361 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4362 | shouldFail: true, |
| 4363 | expectedLocalError: "remote error: error decoding message", |
| 4364 | }) |
| 4365 | testCases = append(testCases, testCase{ |
| 4366 | testType: serverTest, |
| 4367 | name: "DuplicateExtensionServer-" + ver.name, |
| 4368 | config: Config{ |
| 4369 | MaxVersion: ver.version, |
| 4370 | Bugs: ProtocolBugs{ |
| 4371 | DuplicateExtension: true, |
| 4372 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4373 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4374 | shouldFail: true, |
| 4375 | expectedLocalError: "remote error: error decoding message", |
| 4376 | }) |
| 4377 | |
| 4378 | // Test SNI. |
| 4379 | testCases = append(testCases, testCase{ |
| 4380 | testType: clientTest, |
| 4381 | name: "ServerNameExtensionClient-" + ver.name, |
| 4382 | config: Config{ |
| 4383 | MaxVersion: ver.version, |
| 4384 | Bugs: ProtocolBugs{ |
| 4385 | ExpectServerName: "example.com", |
| 4386 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4387 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4388 | flags: []string{"-host-name", "example.com"}, |
| 4389 | }) |
| 4390 | testCases = append(testCases, testCase{ |
| 4391 | testType: clientTest, |
| 4392 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4393 | config: Config{ |
| 4394 | MaxVersion: ver.version, |
| 4395 | Bugs: ProtocolBugs{ |
| 4396 | ExpectServerName: "mismatch.com", |
| 4397 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4398 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4399 | flags: []string{"-host-name", "example.com"}, |
| 4400 | shouldFail: true, |
| 4401 | expectedLocalError: "tls: unexpected server name", |
| 4402 | }) |
| 4403 | testCases = append(testCases, testCase{ |
| 4404 | testType: clientTest, |
| 4405 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4406 | config: Config{ |
| 4407 | MaxVersion: ver.version, |
| 4408 | Bugs: ProtocolBugs{ |
| 4409 | ExpectServerName: "missing.com", |
| 4410 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4411 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4412 | shouldFail: true, |
| 4413 | expectedLocalError: "tls: unexpected server name", |
| 4414 | }) |
| 4415 | testCases = append(testCases, testCase{ |
| 4416 | testType: serverTest, |
| 4417 | name: "ServerNameExtensionServer-" + ver.name, |
| 4418 | config: Config{ |
| 4419 | MaxVersion: ver.version, |
| 4420 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4421 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4422 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4423 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4424 | }) |
| 4425 | |
| 4426 | // Test ALPN. |
| 4427 | testCases = append(testCases, testCase{ |
| 4428 | testType: clientTest, |
| 4429 | name: "ALPNClient-" + ver.name, |
| 4430 | config: Config{ |
| 4431 | MaxVersion: ver.version, |
| 4432 | NextProtos: []string{"foo"}, |
| 4433 | }, |
| 4434 | flags: []string{ |
| 4435 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4436 | "-expect-alpn", "foo", |
| 4437 | }, |
| 4438 | expectedNextProto: "foo", |
| 4439 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4440 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4441 | }) |
| 4442 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4443 | testType: clientTest, |
| 4444 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4445 | config: Config{ |
| 4446 | MaxVersion: ver.version, |
| 4447 | Bugs: ProtocolBugs{ |
| 4448 | SendALPN: "baz", |
| 4449 | }, |
| 4450 | }, |
| 4451 | flags: []string{ |
| 4452 | "-advertise-alpn", "\x03foo\x03bar", |
| 4453 | }, |
| 4454 | shouldFail: true, |
| 4455 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4456 | expectedLocalError: "remote error: illegal parameter", |
| 4457 | }) |
| 4458 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4459 | testType: serverTest, |
| 4460 | name: "ALPNServer-" + ver.name, |
| 4461 | config: Config{ |
| 4462 | MaxVersion: ver.version, |
| 4463 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4464 | }, |
| 4465 | flags: []string{ |
| 4466 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4467 | "-select-alpn", "foo", |
| 4468 | }, |
| 4469 | expectedNextProto: "foo", |
| 4470 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4471 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4472 | }) |
| 4473 | testCases = append(testCases, testCase{ |
| 4474 | testType: serverTest, |
| 4475 | name: "ALPNServer-Decline-" + ver.name, |
| 4476 | config: Config{ |
| 4477 | MaxVersion: ver.version, |
| 4478 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4479 | }, |
| 4480 | flags: []string{"-decline-alpn"}, |
| 4481 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4482 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4483 | }) |
| 4484 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4485 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4486 | // called once. |
| 4487 | testCases = append(testCases, testCase{ |
| 4488 | testType: serverTest, |
| 4489 | name: "ALPNServer-Async-" + ver.name, |
| 4490 | config: Config{ |
| 4491 | MaxVersion: ver.version, |
| 4492 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4493 | }, |
| 4494 | flags: []string{ |
| 4495 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4496 | "-select-alpn", "foo", |
| 4497 | "-async", |
| 4498 | }, |
| 4499 | expectedNextProto: "foo", |
| 4500 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4501 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4502 | }) |
| 4503 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4504 | var emptyString string |
| 4505 | testCases = append(testCases, testCase{ |
| 4506 | testType: clientTest, |
| 4507 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4508 | config: Config{ |
| 4509 | MaxVersion: ver.version, |
| 4510 | NextProtos: []string{""}, |
| 4511 | Bugs: ProtocolBugs{ |
| 4512 | // A server returning an empty ALPN protocol |
| 4513 | // should be rejected. |
| 4514 | ALPNProtocol: &emptyString, |
| 4515 | }, |
| 4516 | }, |
| 4517 | flags: []string{ |
| 4518 | "-advertise-alpn", "\x03foo", |
| 4519 | }, |
| 4520 | shouldFail: true, |
| 4521 | expectedError: ":PARSE_TLSEXT:", |
| 4522 | }) |
| 4523 | testCases = append(testCases, testCase{ |
| 4524 | testType: serverTest, |
| 4525 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4526 | config: Config{ |
| 4527 | MaxVersion: ver.version, |
| 4528 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4529 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4530 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4531 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4532 | flags: []string{ |
| 4533 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4534 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4535 | shouldFail: true, |
| 4536 | expectedError: ":PARSE_TLSEXT:", |
| 4537 | }) |
| 4538 | |
| 4539 | // Test NPN and the interaction with ALPN. |
| 4540 | if ver.version < VersionTLS13 { |
| 4541 | // Test that the server prefers ALPN over NPN. |
| 4542 | testCases = append(testCases, testCase{ |
| 4543 | testType: serverTest, |
| 4544 | name: "ALPNServer-Preferred-" + ver.name, |
| 4545 | config: Config{ |
| 4546 | MaxVersion: ver.version, |
| 4547 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4548 | }, |
| 4549 | flags: []string{ |
| 4550 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4551 | "-select-alpn", "foo", |
| 4552 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4553 | }, |
| 4554 | expectedNextProto: "foo", |
| 4555 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4556 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4557 | }) |
| 4558 | testCases = append(testCases, testCase{ |
| 4559 | testType: serverTest, |
| 4560 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4561 | config: Config{ |
| 4562 | MaxVersion: ver.version, |
| 4563 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4564 | Bugs: ProtocolBugs{ |
| 4565 | SwapNPNAndALPN: true, |
| 4566 | }, |
| 4567 | }, |
| 4568 | flags: []string{ |
| 4569 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4570 | "-select-alpn", "foo", |
| 4571 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4572 | }, |
| 4573 | expectedNextProto: "foo", |
| 4574 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4575 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4576 | }) |
| 4577 | |
| 4578 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4579 | testCases = append(testCases, testCase{ |
| 4580 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4581 | config: Config{ |
| 4582 | MaxVersion: ver.version, |
| 4583 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4584 | Bugs: ProtocolBugs{ |
| 4585 | NegotiateALPNAndNPN: true, |
| 4586 | }, |
| 4587 | }, |
| 4588 | flags: []string{ |
| 4589 | "-advertise-alpn", "\x03foo", |
| 4590 | "-select-next-proto", "foo", |
| 4591 | }, |
| 4592 | shouldFail: true, |
| 4593 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4594 | }) |
| 4595 | testCases = append(testCases, testCase{ |
| 4596 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4597 | config: Config{ |
| 4598 | MaxVersion: ver.version, |
| 4599 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4600 | Bugs: ProtocolBugs{ |
| 4601 | NegotiateALPNAndNPN: true, |
| 4602 | SwapNPNAndALPN: true, |
| 4603 | }, |
| 4604 | }, |
| 4605 | flags: []string{ |
| 4606 | "-advertise-alpn", "\x03foo", |
| 4607 | "-select-next-proto", "foo", |
| 4608 | }, |
| 4609 | shouldFail: true, |
| 4610 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4611 | }) |
| 4612 | |
| 4613 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4614 | testCases = append(testCases, testCase{ |
| 4615 | name: "DisableNPN-" + ver.name, |
| 4616 | config: Config{ |
| 4617 | MaxVersion: ver.version, |
| 4618 | NextProtos: []string{"foo"}, |
| 4619 | }, |
| 4620 | flags: []string{ |
| 4621 | "-select-next-proto", "foo", |
| 4622 | "-disable-npn", |
| 4623 | }, |
| 4624 | expectNoNextProto: true, |
| 4625 | }) |
| 4626 | } |
| 4627 | |
| 4628 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4629 | |
| 4630 | // Resume with a corrupt ticket. |
| 4631 | testCases = append(testCases, testCase{ |
| 4632 | testType: serverTest, |
| 4633 | name: "CorruptTicket-" + ver.name, |
| 4634 | config: Config{ |
| 4635 | MaxVersion: ver.version, |
| 4636 | Bugs: ProtocolBugs{ |
| 4637 | CorruptTicket: true, |
| 4638 | }, |
| 4639 | }, |
| 4640 | resumeSession: true, |
| 4641 | expectResumeRejected: true, |
| 4642 | }) |
| 4643 | // Test the ticket callback, with and without renewal. |
| 4644 | testCases = append(testCases, testCase{ |
| 4645 | testType: serverTest, |
| 4646 | name: "TicketCallback-" + ver.name, |
| 4647 | config: Config{ |
| 4648 | MaxVersion: ver.version, |
| 4649 | }, |
| 4650 | resumeSession: true, |
| 4651 | flags: []string{"-use-ticket-callback"}, |
| 4652 | }) |
| 4653 | testCases = append(testCases, testCase{ |
| 4654 | testType: serverTest, |
| 4655 | name: "TicketCallback-Renew-" + ver.name, |
| 4656 | config: Config{ |
| 4657 | MaxVersion: ver.version, |
| 4658 | Bugs: ProtocolBugs{ |
| 4659 | ExpectNewTicket: true, |
| 4660 | }, |
| 4661 | }, |
| 4662 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 4663 | resumeSession: true, |
| 4664 | }) |
| 4665 | |
| 4666 | // Test that the ticket callback is only called once when everything before |
| 4667 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 4668 | // certificate selection callbacks run. |
| 4669 | testCases = append(testCases, testCase{ |
| 4670 | testType: serverTest, |
| 4671 | name: "TicketCallback-SingleCall-" + ver.name, |
| 4672 | config: Config{ |
| 4673 | MaxVersion: ver.version, |
| 4674 | Bugs: ProtocolBugs{ |
| 4675 | CorruptTicket: true, |
| 4676 | }, |
| 4677 | }, |
| 4678 | resumeSession: true, |
| 4679 | expectResumeRejected: true, |
| 4680 | flags: []string{ |
| 4681 | "-use-ticket-callback", |
| 4682 | "-async", |
| 4683 | }, |
| 4684 | }) |
| 4685 | |
| 4686 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4687 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4688 | testCases = append(testCases, testCase{ |
| 4689 | testType: serverTest, |
| 4690 | name: "OversizedSessionId-" + ver.name, |
| 4691 | config: Config{ |
| 4692 | MaxVersion: ver.version, |
| 4693 | Bugs: ProtocolBugs{ |
| 4694 | OversizedSessionId: true, |
| 4695 | }, |
| 4696 | }, |
| 4697 | resumeSession: true, |
| 4698 | shouldFail: true, |
| 4699 | expectedError: ":DECODE_ERROR:", |
| 4700 | }) |
| 4701 | } |
| 4702 | |
| 4703 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 4704 | // are ignored. |
| 4705 | if ver.hasDTLS { |
| 4706 | testCases = append(testCases, testCase{ |
| 4707 | protocol: dtls, |
| 4708 | name: "SRTP-Client-" + ver.name, |
| 4709 | config: Config{ |
| 4710 | MaxVersion: ver.version, |
| 4711 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4712 | }, |
| 4713 | flags: []string{ |
| 4714 | "-srtp-profiles", |
| 4715 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4716 | }, |
| 4717 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4718 | }) |
| 4719 | testCases = append(testCases, testCase{ |
| 4720 | protocol: dtls, |
| 4721 | testType: serverTest, |
| 4722 | name: "SRTP-Server-" + ver.name, |
| 4723 | config: Config{ |
| 4724 | MaxVersion: ver.version, |
| 4725 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4726 | }, |
| 4727 | flags: []string{ |
| 4728 | "-srtp-profiles", |
| 4729 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4730 | }, |
| 4731 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4732 | }) |
| 4733 | // Test that the MKI is ignored. |
| 4734 | testCases = append(testCases, testCase{ |
| 4735 | protocol: dtls, |
| 4736 | testType: serverTest, |
| 4737 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 4738 | config: Config{ |
| 4739 | MaxVersion: ver.version, |
| 4740 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 4741 | Bugs: ProtocolBugs{ |
| 4742 | SRTPMasterKeyIdentifer: "bogus", |
| 4743 | }, |
| 4744 | }, |
| 4745 | flags: []string{ |
| 4746 | "-srtp-profiles", |
| 4747 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4748 | }, |
| 4749 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4750 | }) |
| 4751 | // Test that SRTP isn't negotiated on the server if there were |
| 4752 | // no matching profiles. |
| 4753 | testCases = append(testCases, testCase{ |
| 4754 | protocol: dtls, |
| 4755 | testType: serverTest, |
| 4756 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 4757 | config: Config{ |
| 4758 | MaxVersion: ver.version, |
| 4759 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 4760 | }, |
| 4761 | flags: []string{ |
| 4762 | "-srtp-profiles", |
| 4763 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4764 | }, |
| 4765 | expectedSRTPProtectionProfile: 0, |
| 4766 | }) |
| 4767 | // Test that the server returning an invalid SRTP profile is |
| 4768 | // flagged as an error by the client. |
| 4769 | testCases = append(testCases, testCase{ |
| 4770 | protocol: dtls, |
| 4771 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 4772 | config: Config{ |
| 4773 | MaxVersion: ver.version, |
| 4774 | Bugs: ProtocolBugs{ |
| 4775 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 4776 | }, |
| 4777 | }, |
| 4778 | flags: []string{ |
| 4779 | "-srtp-profiles", |
| 4780 | "SRTP_AES128_CM_SHA1_80", |
| 4781 | }, |
| 4782 | shouldFail: true, |
| 4783 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 4784 | }) |
| 4785 | } |
| 4786 | |
| 4787 | // Test SCT list. |
| 4788 | testCases = append(testCases, testCase{ |
| 4789 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 4790 | testType: clientTest, |
| 4791 | config: Config{ |
| 4792 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4793 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4794 | flags: []string{ |
| 4795 | "-enable-signed-cert-timestamps", |
| 4796 | "-expect-signed-cert-timestamps", |
| 4797 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4798 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4799 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4800 | }) |
| 4801 | testCases = append(testCases, testCase{ |
| 4802 | name: "SendSCTListOnResume-" + ver.name, |
| 4803 | config: Config{ |
| 4804 | MaxVersion: ver.version, |
| 4805 | Bugs: ProtocolBugs{ |
| 4806 | SendSCTListOnResume: []byte("bogus"), |
| 4807 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 4808 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4809 | flags: []string{ |
| 4810 | "-enable-signed-cert-timestamps", |
| 4811 | "-expect-signed-cert-timestamps", |
| 4812 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4813 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4814 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4815 | }) |
| 4816 | testCases = append(testCases, testCase{ |
| 4817 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 4818 | testType: serverTest, |
| 4819 | config: Config{ |
| 4820 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4821 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4822 | flags: []string{ |
| 4823 | "-signed-cert-timestamps", |
| 4824 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4825 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4826 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4827 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4828 | }) |
| 4829 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4830 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 4831 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 4832 | testType: clientTest, |
| 4833 | name: "ClientHelloPadding", |
| 4834 | config: Config{ |
| 4835 | Bugs: ProtocolBugs{ |
| 4836 | RequireClientHelloSize: 512, |
| 4837 | }, |
| 4838 | }, |
| 4839 | // This hostname just needs to be long enough to push the |
| 4840 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 4841 | // long. |
| 4842 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 4843 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 4844 | |
| 4845 | // Extensions should not function in SSL 3.0. |
| 4846 | testCases = append(testCases, testCase{ |
| 4847 | testType: serverTest, |
| 4848 | name: "SSLv3Extensions-NoALPN", |
| 4849 | config: Config{ |
| 4850 | MaxVersion: VersionSSL30, |
| 4851 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4852 | }, |
| 4853 | flags: []string{ |
| 4854 | "-select-alpn", "foo", |
| 4855 | }, |
| 4856 | expectNoNextProto: true, |
| 4857 | }) |
| 4858 | |
| 4859 | // Test session tickets separately as they follow a different codepath. |
| 4860 | testCases = append(testCases, testCase{ |
| 4861 | testType: serverTest, |
| 4862 | name: "SSLv3Extensions-NoTickets", |
| 4863 | config: Config{ |
| 4864 | MaxVersion: VersionSSL30, |
| 4865 | Bugs: ProtocolBugs{ |
| 4866 | // Historically, session tickets in SSL 3.0 |
| 4867 | // failed in different ways depending on whether |
| 4868 | // the client supported renegotiation_info. |
| 4869 | NoRenegotiationInfo: true, |
| 4870 | }, |
| 4871 | }, |
| 4872 | resumeSession: true, |
| 4873 | }) |
| 4874 | testCases = append(testCases, testCase{ |
| 4875 | testType: serverTest, |
| 4876 | name: "SSLv3Extensions-NoTickets2", |
| 4877 | config: Config{ |
| 4878 | MaxVersion: VersionSSL30, |
| 4879 | }, |
| 4880 | resumeSession: true, |
| 4881 | }) |
| 4882 | |
| 4883 | // But SSL 3.0 does send and process renegotiation_info. |
| 4884 | testCases = append(testCases, testCase{ |
| 4885 | testType: serverTest, |
| 4886 | name: "SSLv3Extensions-RenegotiationInfo", |
| 4887 | config: Config{ |
| 4888 | MaxVersion: VersionSSL30, |
| 4889 | Bugs: ProtocolBugs{ |
| 4890 | RequireRenegotiationInfo: true, |
| 4891 | }, |
| 4892 | }, |
| 4893 | }) |
| 4894 | testCases = append(testCases, testCase{ |
| 4895 | testType: serverTest, |
| 4896 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 4897 | config: Config{ |
| 4898 | MaxVersion: VersionSSL30, |
| 4899 | Bugs: ProtocolBugs{ |
| 4900 | NoRenegotiationInfo: true, |
| 4901 | SendRenegotiationSCSV: true, |
| 4902 | RequireRenegotiationInfo: true, |
| 4903 | }, |
| 4904 | }, |
| 4905 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4906 | |
| 4907 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 4908 | // in ServerHello. |
| 4909 | testCases = append(testCases, testCase{ |
| 4910 | name: "NPN-Forbidden-TLS13", |
| 4911 | config: Config{ |
| 4912 | MaxVersion: VersionTLS13, |
| 4913 | NextProtos: []string{"foo"}, |
| 4914 | Bugs: ProtocolBugs{ |
| 4915 | NegotiateNPNAtAllVersions: true, |
| 4916 | }, |
| 4917 | }, |
| 4918 | flags: []string{"-select-next-proto", "foo"}, |
| 4919 | shouldFail: true, |
| 4920 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4921 | }) |
| 4922 | testCases = append(testCases, testCase{ |
| 4923 | name: "EMS-Forbidden-TLS13", |
| 4924 | config: Config{ |
| 4925 | MaxVersion: VersionTLS13, |
| 4926 | Bugs: ProtocolBugs{ |
| 4927 | NegotiateEMSAtAllVersions: true, |
| 4928 | }, |
| 4929 | }, |
| 4930 | shouldFail: true, |
| 4931 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4932 | }) |
| 4933 | testCases = append(testCases, testCase{ |
| 4934 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 4935 | config: Config{ |
| 4936 | MaxVersion: VersionTLS13, |
| 4937 | Bugs: ProtocolBugs{ |
| 4938 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 4939 | }, |
| 4940 | }, |
| 4941 | shouldFail: true, |
| 4942 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4943 | }) |
| 4944 | testCases = append(testCases, testCase{ |
| 4945 | name: "ChannelID-Forbidden-TLS13", |
| 4946 | config: Config{ |
| 4947 | MaxVersion: VersionTLS13, |
| 4948 | RequestChannelID: true, |
| 4949 | Bugs: ProtocolBugs{ |
| 4950 | NegotiateChannelIDAtAllVersions: true, |
| 4951 | }, |
| 4952 | }, |
| 4953 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4954 | shouldFail: true, |
| 4955 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4956 | }) |
| 4957 | testCases = append(testCases, testCase{ |
| 4958 | name: "Ticket-Forbidden-TLS13", |
| 4959 | config: Config{ |
| 4960 | MaxVersion: VersionTLS12, |
| 4961 | }, |
| 4962 | resumeConfig: &Config{ |
| 4963 | MaxVersion: VersionTLS13, |
| 4964 | Bugs: ProtocolBugs{ |
| 4965 | AdvertiseTicketExtension: true, |
| 4966 | }, |
| 4967 | }, |
| 4968 | resumeSession: true, |
| 4969 | shouldFail: true, |
| 4970 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4971 | }) |
| 4972 | |
| 4973 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 4974 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 4975 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 4976 | // implicit in every test.) |
| 4977 | testCases = append(testCases, testCase{ |
| 4978 | testType: serverTest, |
| 4979 | name: "ChannelID-Declined-TLS13", |
| 4980 | config: Config{ |
| 4981 | MaxVersion: VersionTLS13, |
| 4982 | ChannelID: channelIDKey, |
| 4983 | }, |
| 4984 | flags: []string{"-enable-channel-id"}, |
| 4985 | }) |
| 4986 | testCases = append(testCases, testCase{ |
| 4987 | testType: serverTest, |
| 4988 | name: "NPN-Server", |
| 4989 | config: Config{ |
| 4990 | MaxVersion: VersionTLS13, |
| 4991 | NextProtos: []string{"bar"}, |
| 4992 | }, |
| 4993 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 4994 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4995 | } |
| 4996 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4997 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4998 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4999 | for _, resumeVers := range tlsVersions { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5000 | cipher := TLS_RSA_WITH_AES_128_CBC_SHA |
| 5001 | if sessionVers.version >= VersionTLS13 || resumeVers.version >= VersionTLS13 { |
| 5002 | // TLS 1.3 only shares ciphers with TLS 1.2, so |
| 5003 | // we skip certain combinations and use a |
| 5004 | // different cipher to test with. |
| 5005 | cipher = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 |
| 5006 | if sessionVers.version < VersionTLS12 || resumeVers.version < VersionTLS12 { |
| 5007 | continue |
| 5008 | } |
| 5009 | } |
| 5010 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5011 | protocols := []protocol{tls} |
| 5012 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5013 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5014 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5015 | for _, protocol := range protocols { |
| 5016 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5017 | if protocol == dtls { |
| 5018 | suffix += "-DTLS" |
| 5019 | } |
| 5020 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5021 | if sessionVers.version == resumeVers.version { |
| 5022 | testCases = append(testCases, testCase{ |
| 5023 | protocol: protocol, |
| 5024 | name: "Resume-Client" + suffix, |
| 5025 | resumeSession: true, |
| 5026 | config: Config{ |
| 5027 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5028 | CipherSuites: []uint16{cipher}, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5029 | Bugs: ProtocolBugs{ |
| 5030 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5031 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5032 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5033 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5034 | expectedVersion: sessionVers.version, |
| 5035 | expectedResumeVersion: resumeVers.version, |
| 5036 | }) |
| 5037 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5038 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5039 | |
| 5040 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5041 | // there is no way to convince a non-lookahead client the |
| 5042 | // session was resumed. It will appear to the client that a |
| 5043 | // stray ChangeCipherSpec was sent. |
| 5044 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5045 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5046 | } |
| 5047 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5048 | testCases = append(testCases, testCase{ |
| 5049 | protocol: protocol, |
| 5050 | name: "Resume-Client-Mismatch" + suffix, |
| 5051 | resumeSession: true, |
| 5052 | config: Config{ |
| 5053 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5054 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5055 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5056 | expectedVersion: sessionVers.version, |
| 5057 | resumeConfig: &Config{ |
| 5058 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5059 | CipherSuites: []uint16{cipher}, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5060 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5061 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5062 | }, |
| 5063 | }, |
| 5064 | expectedResumeVersion: resumeVers.version, |
| 5065 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5066 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5067 | }) |
| 5068 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5069 | |
| 5070 | testCases = append(testCases, testCase{ |
| 5071 | protocol: protocol, |
| 5072 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5073 | resumeSession: true, |
| 5074 | config: Config{ |
| 5075 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5076 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5077 | }, |
| 5078 | expectedVersion: sessionVers.version, |
| 5079 | resumeConfig: &Config{ |
| 5080 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5081 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5082 | }, |
| 5083 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5084 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5085 | expectedResumeVersion: resumeVers.version, |
| 5086 | }) |
| 5087 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5088 | testCases = append(testCases, testCase{ |
| 5089 | protocol: protocol, |
| 5090 | testType: serverTest, |
| 5091 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5092 | resumeSession: true, |
| 5093 | config: Config{ |
| 5094 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5095 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5096 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5097 | expectedVersion: sessionVers.version, |
| 5098 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5099 | resumeConfig: &Config{ |
| 5100 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5101 | CipherSuites: []uint16{cipher}, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5102 | Bugs: ProtocolBugs{ |
| 5103 | SendBothTickets: true, |
| 5104 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5105 | }, |
| 5106 | expectedResumeVersion: resumeVers.version, |
| 5107 | }) |
| 5108 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5109 | } |
| 5110 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5111 | |
| 5112 | testCases = append(testCases, testCase{ |
| 5113 | name: "Resume-Client-CipherMismatch", |
| 5114 | resumeSession: true, |
| 5115 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5116 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5117 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5118 | }, |
| 5119 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5120 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5121 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5122 | Bugs: ProtocolBugs{ |
| 5123 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5124 | }, |
| 5125 | }, |
| 5126 | shouldFail: true, |
| 5127 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5128 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5129 | |
| 5130 | testCases = append(testCases, testCase{ |
| 5131 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5132 | resumeSession: true, |
| 5133 | config: Config{ |
| 5134 | MaxVersion: VersionTLS13, |
| 5135 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5136 | }, |
| 5137 | resumeConfig: &Config{ |
| 5138 | MaxVersion: VersionTLS13, |
| 5139 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5140 | Bugs: ProtocolBugs{ |
| 5141 | SendCipherSuite: TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, |
| 5142 | }, |
| 5143 | }, |
| 5144 | shouldFail: true, |
| 5145 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5146 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5147 | } |
| 5148 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5149 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 5150 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5151 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5152 | testType: serverTest, |
| 5153 | name: "Renegotiate-Server-Forbidden", |
| 5154 | config: Config{ |
| 5155 | MaxVersion: VersionTLS12, |
| 5156 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5157 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5158 | shouldFail: true, |
| 5159 | expectedError: ":NO_RENEGOTIATION:", |
| 5160 | expectedLocalError: "remote error: no renegotiation", |
| 5161 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5162 | // The server shouldn't echo the renegotiation extension unless |
| 5163 | // requested by the client. |
| 5164 | testCases = append(testCases, testCase{ |
| 5165 | testType: serverTest, |
| 5166 | name: "Renegotiate-Server-NoExt", |
| 5167 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5168 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5169 | Bugs: ProtocolBugs{ |
| 5170 | NoRenegotiationInfo: true, |
| 5171 | RequireRenegotiationInfo: true, |
| 5172 | }, |
| 5173 | }, |
| 5174 | shouldFail: true, |
| 5175 | expectedLocalError: "renegotiation extension missing", |
| 5176 | }) |
| 5177 | // The renegotiation SCSV should be sufficient for the server to echo |
| 5178 | // the extension. |
| 5179 | testCases = append(testCases, testCase{ |
| 5180 | testType: serverTest, |
| 5181 | name: "Renegotiate-Server-NoExt-SCSV", |
| 5182 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5183 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5184 | Bugs: ProtocolBugs{ |
| 5185 | NoRenegotiationInfo: true, |
| 5186 | SendRenegotiationSCSV: true, |
| 5187 | RequireRenegotiationInfo: true, |
| 5188 | }, |
| 5189 | }, |
| 5190 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5191 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5192 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5193 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5194 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5195 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5196 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5197 | }, |
| 5198 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5199 | renegotiate: 1, |
| 5200 | flags: []string{ |
| 5201 | "-renegotiate-freely", |
| 5202 | "-expect-total-renegotiations", "1", |
| 5203 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5204 | }) |
| 5205 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5206 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5207 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5208 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5209 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5210 | Bugs: ProtocolBugs{ |
| 5211 | EmptyRenegotiationInfo: true, |
| 5212 | }, |
| 5213 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5214 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5215 | shouldFail: true, |
| 5216 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5217 | }) |
| 5218 | testCases = append(testCases, testCase{ |
| 5219 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5220 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5221 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5222 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5223 | Bugs: ProtocolBugs{ |
| 5224 | BadRenegotiationInfo: true, |
| 5225 | }, |
| 5226 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5227 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5228 | shouldFail: true, |
| 5229 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5230 | }) |
| 5231 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5232 | name: "Renegotiate-Client-Downgrade", |
| 5233 | renegotiate: 1, |
| 5234 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5235 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5236 | Bugs: ProtocolBugs{ |
| 5237 | NoRenegotiationInfoAfterInitial: true, |
| 5238 | }, |
| 5239 | }, |
| 5240 | flags: []string{"-renegotiate-freely"}, |
| 5241 | shouldFail: true, |
| 5242 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5243 | }) |
| 5244 | testCases = append(testCases, testCase{ |
| 5245 | name: "Renegotiate-Client-Upgrade", |
| 5246 | renegotiate: 1, |
| 5247 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5248 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5249 | Bugs: ProtocolBugs{ |
| 5250 | NoRenegotiationInfoInInitial: true, |
| 5251 | }, |
| 5252 | }, |
| 5253 | flags: []string{"-renegotiate-freely"}, |
| 5254 | shouldFail: true, |
| 5255 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5256 | }) |
| 5257 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5258 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5259 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5260 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5261 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5262 | Bugs: ProtocolBugs{ |
| 5263 | NoRenegotiationInfo: true, |
| 5264 | }, |
| 5265 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5266 | flags: []string{ |
| 5267 | "-renegotiate-freely", |
| 5268 | "-expect-total-renegotiations", "1", |
| 5269 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5270 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5271 | |
| 5272 | // Test that the server may switch ciphers on renegotiation without |
| 5273 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5274 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5275 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5276 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5277 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5278 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5279 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5280 | }, |
| 5281 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5282 | flags: []string{ |
| 5283 | "-renegotiate-freely", |
| 5284 | "-expect-total-renegotiations", "1", |
| 5285 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5286 | }) |
| 5287 | testCases = append(testCases, testCase{ |
| 5288 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5289 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5290 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5291 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5292 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5293 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5294 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5295 | flags: []string{ |
| 5296 | "-renegotiate-freely", |
| 5297 | "-expect-total-renegotiations", "1", |
| 5298 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5299 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5300 | |
| 5301 | // Test that the server may not switch versions on renegotiation. |
| 5302 | testCases = append(testCases, testCase{ |
| 5303 | name: "Renegotiate-Client-SwitchVersion", |
| 5304 | config: Config{ |
| 5305 | MaxVersion: VersionTLS12, |
| 5306 | // Pick a cipher which exists at both versions. |
| 5307 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 5308 | Bugs: ProtocolBugs{ |
| 5309 | NegotiateVersionOnRenego: VersionTLS11, |
| 5310 | }, |
| 5311 | }, |
| 5312 | renegotiate: 1, |
| 5313 | flags: []string{ |
| 5314 | "-renegotiate-freely", |
| 5315 | "-expect-total-renegotiations", "1", |
| 5316 | }, |
| 5317 | shouldFail: true, |
| 5318 | expectedError: ":WRONG_SSL_VERSION:", |
| 5319 | }) |
| 5320 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5321 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5322 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5323 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5324 | config: Config{ |
| 5325 | MaxVersion: VersionTLS10, |
| 5326 | Bugs: ProtocolBugs{ |
| 5327 | RequireSameRenegoClientVersion: true, |
| 5328 | }, |
| 5329 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5330 | flags: []string{ |
| 5331 | "-renegotiate-freely", |
| 5332 | "-expect-total-renegotiations", "1", |
| 5333 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5334 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5335 | testCases = append(testCases, testCase{ |
| 5336 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5337 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5338 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5339 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5340 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5341 | NextProtos: []string{"foo"}, |
| 5342 | }, |
| 5343 | flags: []string{ |
| 5344 | "-false-start", |
| 5345 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5346 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 5347 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5348 | }, |
| 5349 | shimWritesFirst: true, |
| 5350 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5351 | |
| 5352 | // Client-side renegotiation controls. |
| 5353 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5354 | name: "Renegotiate-Client-Forbidden-1", |
| 5355 | config: Config{ |
| 5356 | MaxVersion: VersionTLS12, |
| 5357 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5358 | renegotiate: 1, |
| 5359 | shouldFail: true, |
| 5360 | expectedError: ":NO_RENEGOTIATION:", |
| 5361 | expectedLocalError: "remote error: no renegotiation", |
| 5362 | }) |
| 5363 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5364 | name: "Renegotiate-Client-Once-1", |
| 5365 | config: Config{ |
| 5366 | MaxVersion: VersionTLS12, |
| 5367 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5368 | renegotiate: 1, |
| 5369 | flags: []string{ |
| 5370 | "-renegotiate-once", |
| 5371 | "-expect-total-renegotiations", "1", |
| 5372 | }, |
| 5373 | }) |
| 5374 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5375 | name: "Renegotiate-Client-Freely-1", |
| 5376 | config: Config{ |
| 5377 | MaxVersion: VersionTLS12, |
| 5378 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5379 | renegotiate: 1, |
| 5380 | flags: []string{ |
| 5381 | "-renegotiate-freely", |
| 5382 | "-expect-total-renegotiations", "1", |
| 5383 | }, |
| 5384 | }) |
| 5385 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5386 | name: "Renegotiate-Client-Once-2", |
| 5387 | config: Config{ |
| 5388 | MaxVersion: VersionTLS12, |
| 5389 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5390 | renegotiate: 2, |
| 5391 | flags: []string{"-renegotiate-once"}, |
| 5392 | shouldFail: true, |
| 5393 | expectedError: ":NO_RENEGOTIATION:", |
| 5394 | expectedLocalError: "remote error: no renegotiation", |
| 5395 | }) |
| 5396 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5397 | name: "Renegotiate-Client-Freely-2", |
| 5398 | config: Config{ |
| 5399 | MaxVersion: VersionTLS12, |
| 5400 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5401 | renegotiate: 2, |
| 5402 | flags: []string{ |
| 5403 | "-renegotiate-freely", |
| 5404 | "-expect-total-renegotiations", "2", |
| 5405 | }, |
| 5406 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5407 | testCases = append(testCases, testCase{ |
| 5408 | name: "Renegotiate-Client-NoIgnore", |
| 5409 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5410 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5411 | Bugs: ProtocolBugs{ |
| 5412 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5413 | }, |
| 5414 | }, |
| 5415 | shouldFail: true, |
| 5416 | expectedError: ":NO_RENEGOTIATION:", |
| 5417 | }) |
| 5418 | testCases = append(testCases, testCase{ |
| 5419 | name: "Renegotiate-Client-Ignore", |
| 5420 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5421 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5422 | Bugs: ProtocolBugs{ |
| 5423 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5424 | }, |
| 5425 | }, |
| 5426 | flags: []string{ |
| 5427 | "-renegotiate-ignore", |
| 5428 | "-expect-total-renegotiations", "0", |
| 5429 | }, |
| 5430 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5431 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5432 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 5433 | testCases = append(testCases, testCase{ |
| 5434 | name: "StrayHelloRequest", |
| 5435 | config: Config{ |
| 5436 | MaxVersion: VersionTLS12, |
| 5437 | Bugs: ProtocolBugs{ |
| 5438 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5439 | }, |
| 5440 | }, |
| 5441 | }) |
| 5442 | testCases = append(testCases, testCase{ |
| 5443 | name: "StrayHelloRequest-Packed", |
| 5444 | config: Config{ |
| 5445 | MaxVersion: VersionTLS12, |
| 5446 | Bugs: ProtocolBugs{ |
| 5447 | PackHandshakeFlight: true, |
| 5448 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5449 | }, |
| 5450 | }, |
| 5451 | }) |
| 5452 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 5453 | // Test renegotiation works if HelloRequest and server Finished come in |
| 5454 | // the same record. |
| 5455 | testCases = append(testCases, testCase{ |
| 5456 | name: "Renegotiate-Client-Packed", |
| 5457 | config: Config{ |
| 5458 | MaxVersion: VersionTLS12, |
| 5459 | Bugs: ProtocolBugs{ |
| 5460 | PackHandshakeFlight: true, |
| 5461 | PackHelloRequestWithFinished: true, |
| 5462 | }, |
| 5463 | }, |
| 5464 | renegotiate: 1, |
| 5465 | flags: []string{ |
| 5466 | "-renegotiate-freely", |
| 5467 | "-expect-total-renegotiations", "1", |
| 5468 | }, |
| 5469 | }) |
| 5470 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5471 | // Renegotiation is forbidden in TLS 1.3. |
| 5472 | testCases = append(testCases, testCase{ |
| 5473 | name: "Renegotiate-Client-TLS13", |
| 5474 | config: Config{ |
| 5475 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5476 | Bugs: ProtocolBugs{ |
| 5477 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5478 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5479 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5480 | flags: []string{ |
| 5481 | "-renegotiate-freely", |
| 5482 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 5483 | shouldFail: true, |
| 5484 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5485 | }) |
| 5486 | |
| 5487 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 5488 | testCases = append(testCases, testCase{ |
| 5489 | name: "StrayHelloRequest-TLS13", |
| 5490 | config: Config{ |
| 5491 | MaxVersion: VersionTLS13, |
| 5492 | Bugs: ProtocolBugs{ |
| 5493 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5494 | }, |
| 5495 | }, |
| 5496 | shouldFail: true, |
| 5497 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 5498 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5499 | } |
| 5500 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5501 | func addDTLSReplayTests() { |
| 5502 | // Test that sequence number replays are detected. |
| 5503 | testCases = append(testCases, testCase{ |
| 5504 | protocol: dtls, |
| 5505 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5506 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5507 | replayWrites: true, |
| 5508 | }) |
| 5509 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5510 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5511 | // than the retransmit window. |
| 5512 | testCases = append(testCases, testCase{ |
| 5513 | protocol: dtls, |
| 5514 | name: "DTLS-Replay-LargeGaps", |
| 5515 | config: Config{ |
| 5516 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5517 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5518 | return in * 127 |
| 5519 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5520 | }, |
| 5521 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5522 | messageCount: 200, |
| 5523 | replayWrites: true, |
| 5524 | }) |
| 5525 | |
| 5526 | // Test the incoming sequence number changing non-monotonically. |
| 5527 | testCases = append(testCases, testCase{ |
| 5528 | protocol: dtls, |
| 5529 | name: "DTLS-Replay-NonMonotonic", |
| 5530 | config: Config{ |
| 5531 | Bugs: ProtocolBugs{ |
| 5532 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5533 | return in ^ 31 |
| 5534 | }, |
| 5535 | }, |
| 5536 | }, |
| 5537 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5538 | replayWrites: true, |
| 5539 | }) |
| 5540 | } |
| 5541 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5542 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5543 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5544 | id signatureAlgorithm |
| 5545 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5546 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5547 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 5548 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 5549 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 5550 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5551 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5552 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 5553 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 5554 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5555 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 5556 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 5557 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5558 | // Tests for key types prior to TLS 1.2. |
| 5559 | {"RSA", 0, testCertRSA}, |
| 5560 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5561 | } |
| 5562 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5563 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 5564 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 5565 | |
| 5566 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5567 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 5568 | // versions a signing cipher. |
| 5569 | signingCiphers := []uint16{ |
| 5570 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 5571 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 5572 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 5573 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 5574 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 5575 | } |
| 5576 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5577 | var allAlgorithms []signatureAlgorithm |
| 5578 | for _, alg := range testSignatureAlgorithms { |
| 5579 | if alg.id != 0 { |
| 5580 | allAlgorithms = append(allAlgorithms, alg.id) |
| 5581 | } |
| 5582 | } |
| 5583 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5584 | // Make sure each signature algorithm works. Include some fake values in |
| 5585 | // the list and ensure they're ignored. |
| 5586 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5587 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5588 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 5589 | continue |
| 5590 | } |
| 5591 | |
| 5592 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 5593 | // or remove it in C. |
| 5594 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5595 | continue |
| 5596 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5597 | |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5598 | var shouldFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5599 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5600 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
| 5601 | shouldFail = true |
| 5602 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 5603 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 5604 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 5605 | shouldFail = true |
| 5606 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5607 | |
| 5608 | var signError, verifyError string |
| 5609 | if shouldFail { |
| 5610 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
| 5611 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5612 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5613 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5614 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 5615 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5616 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5617 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5618 | config: Config{ |
| 5619 | MaxVersion: ver.version, |
| 5620 | ClientAuth: RequireAnyClientCert, |
| 5621 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5622 | fakeSigAlg1, |
| 5623 | alg.id, |
| 5624 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5625 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5626 | }, |
| 5627 | flags: []string{ |
| 5628 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5629 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5630 | "-enable-all-curves", |
| 5631 | }, |
| 5632 | shouldFail: shouldFail, |
| 5633 | expectedError: signError, |
| 5634 | expectedPeerSignatureAlgorithm: alg.id, |
| 5635 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5636 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5637 | testCases = append(testCases, testCase{ |
| 5638 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5639 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5640 | config: Config{ |
| 5641 | MaxVersion: ver.version, |
| 5642 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5643 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5644 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5645 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5646 | Bugs: ProtocolBugs{ |
| 5647 | SkipECDSACurveCheck: shouldFail, |
| 5648 | IgnoreSignatureVersionChecks: shouldFail, |
| 5649 | // The client won't advertise 1.3-only algorithms after |
| 5650 | // version negotiation. |
| 5651 | IgnorePeerSignatureAlgorithmPreferences: shouldFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5652 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5653 | }, |
| 5654 | flags: []string{ |
| 5655 | "-require-any-client-certificate", |
| 5656 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5657 | "-enable-all-curves", |
| 5658 | }, |
| 5659 | shouldFail: shouldFail, |
| 5660 | expectedError: verifyError, |
| 5661 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5662 | |
| 5663 | testCases = append(testCases, testCase{ |
| 5664 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5665 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5666 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5667 | MaxVersion: ver.version, |
| 5668 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5669 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5670 | fakeSigAlg1, |
| 5671 | alg.id, |
| 5672 | fakeSigAlg2, |
| 5673 | }, |
| 5674 | }, |
| 5675 | flags: []string{ |
| 5676 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5677 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5678 | "-enable-all-curves", |
| 5679 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5680 | shouldFail: shouldFail, |
| 5681 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5682 | expectedPeerSignatureAlgorithm: alg.id, |
| 5683 | }) |
| 5684 | |
| 5685 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5686 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5687 | config: Config{ |
| 5688 | MaxVersion: ver.version, |
| 5689 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5690 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5691 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5692 | alg.id, |
| 5693 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5694 | Bugs: ProtocolBugs{ |
| 5695 | SkipECDSACurveCheck: shouldFail, |
| 5696 | IgnoreSignatureVersionChecks: shouldFail, |
| 5697 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5698 | }, |
| 5699 | flags: []string{ |
| 5700 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5701 | "-enable-all-curves", |
| 5702 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5703 | shouldFail: shouldFail, |
| 5704 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5705 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5706 | |
| 5707 | if !shouldFail { |
| 5708 | testCases = append(testCases, testCase{ |
| 5709 | testType: serverTest, |
| 5710 | name: "ClientAuth-InvalidSignature" + suffix, |
| 5711 | config: Config{ |
| 5712 | MaxVersion: ver.version, |
| 5713 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5714 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5715 | alg.id, |
| 5716 | }, |
| 5717 | Bugs: ProtocolBugs{ |
| 5718 | InvalidSignature: true, |
| 5719 | }, |
| 5720 | }, |
| 5721 | flags: []string{ |
| 5722 | "-require-any-client-certificate", |
| 5723 | "-enable-all-curves", |
| 5724 | }, |
| 5725 | shouldFail: true, |
| 5726 | expectedError: ":BAD_SIGNATURE:", |
| 5727 | }) |
| 5728 | |
| 5729 | testCases = append(testCases, testCase{ |
| 5730 | name: "ServerAuth-InvalidSignature" + suffix, |
| 5731 | config: Config{ |
| 5732 | MaxVersion: ver.version, |
| 5733 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5734 | CipherSuites: signingCiphers, |
| 5735 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5736 | alg.id, |
| 5737 | }, |
| 5738 | Bugs: ProtocolBugs{ |
| 5739 | InvalidSignature: true, |
| 5740 | }, |
| 5741 | }, |
| 5742 | flags: []string{"-enable-all-curves"}, |
| 5743 | shouldFail: true, |
| 5744 | expectedError: ":BAD_SIGNATURE:", |
| 5745 | }) |
| 5746 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5747 | |
| 5748 | if ver.version >= VersionTLS12 && !shouldFail { |
| 5749 | testCases = append(testCases, testCase{ |
| 5750 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 5751 | config: Config{ |
| 5752 | MaxVersion: ver.version, |
| 5753 | ClientAuth: RequireAnyClientCert, |
| 5754 | VerifySignatureAlgorithms: allAlgorithms, |
| 5755 | }, |
| 5756 | flags: []string{ |
| 5757 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5758 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5759 | "-enable-all-curves", |
| 5760 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5761 | }, |
| 5762 | expectedPeerSignatureAlgorithm: alg.id, |
| 5763 | }) |
| 5764 | |
| 5765 | testCases = append(testCases, testCase{ |
| 5766 | testType: serverTest, |
| 5767 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 5768 | config: Config{ |
| 5769 | MaxVersion: ver.version, |
| 5770 | CipherSuites: signingCiphers, |
| 5771 | VerifySignatureAlgorithms: allAlgorithms, |
| 5772 | }, |
| 5773 | flags: []string{ |
| 5774 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5775 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5776 | "-enable-all-curves", |
| 5777 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5778 | }, |
| 5779 | expectedPeerSignatureAlgorithm: alg.id, |
| 5780 | }) |
| 5781 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5782 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5783 | } |
| 5784 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5785 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5786 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5787 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5788 | config: Config{ |
| 5789 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5790 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5791 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5792 | signatureECDSAWithP521AndSHA512, |
| 5793 | signatureRSAPKCS1WithSHA384, |
| 5794 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5795 | }, |
| 5796 | }, |
| 5797 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5798 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5799 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5800 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5801 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5802 | }) |
| 5803 | |
| 5804 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5805 | name: "ClientAuth-SignatureType-TLS13", |
| 5806 | config: Config{ |
| 5807 | ClientAuth: RequireAnyClientCert, |
| 5808 | MaxVersion: VersionTLS13, |
| 5809 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5810 | signatureECDSAWithP521AndSHA512, |
| 5811 | signatureRSAPKCS1WithSHA384, |
| 5812 | signatureRSAPSSWithSHA384, |
| 5813 | signatureECDSAWithSHA1, |
| 5814 | }, |
| 5815 | }, |
| 5816 | flags: []string{ |
| 5817 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5818 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5819 | }, |
| 5820 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5821 | }) |
| 5822 | |
| 5823 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5824 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5825 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5826 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5827 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5828 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5829 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5830 | signatureECDSAWithP521AndSHA512, |
| 5831 | signatureRSAPKCS1WithSHA384, |
| 5832 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5833 | }, |
| 5834 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5835 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5836 | }) |
| 5837 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5838 | testCases = append(testCases, testCase{ |
| 5839 | testType: serverTest, |
| 5840 | name: "ServerAuth-SignatureType-TLS13", |
| 5841 | config: Config{ |
| 5842 | MaxVersion: VersionTLS13, |
| 5843 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5844 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5845 | signatureECDSAWithP521AndSHA512, |
| 5846 | signatureRSAPKCS1WithSHA384, |
| 5847 | signatureRSAPSSWithSHA384, |
| 5848 | signatureECDSAWithSHA1, |
| 5849 | }, |
| 5850 | }, |
| 5851 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5852 | }) |
| 5853 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5854 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5855 | testCases = append(testCases, testCase{ |
| 5856 | testType: serverTest, |
| 5857 | name: "Verify-ClientAuth-SignatureType", |
| 5858 | config: Config{ |
| 5859 | MaxVersion: VersionTLS12, |
| 5860 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5861 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5862 | signatureRSAPKCS1WithSHA256, |
| 5863 | }, |
| 5864 | Bugs: ProtocolBugs{ |
| 5865 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5866 | }, |
| 5867 | }, |
| 5868 | flags: []string{ |
| 5869 | "-require-any-client-certificate", |
| 5870 | }, |
| 5871 | shouldFail: true, |
| 5872 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5873 | }) |
| 5874 | |
| 5875 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5876 | testType: serverTest, |
| 5877 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 5878 | config: Config{ |
| 5879 | MaxVersion: VersionTLS13, |
| 5880 | Certificates: []Certificate{rsaCertificate}, |
| 5881 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5882 | signatureRSAPSSWithSHA256, |
| 5883 | }, |
| 5884 | Bugs: ProtocolBugs{ |
| 5885 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5886 | }, |
| 5887 | }, |
| 5888 | flags: []string{ |
| 5889 | "-require-any-client-certificate", |
| 5890 | }, |
| 5891 | shouldFail: true, |
| 5892 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5893 | }) |
| 5894 | |
| 5895 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5896 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5897 | config: Config{ |
| 5898 | MaxVersion: VersionTLS12, |
| 5899 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5900 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5901 | signatureRSAPKCS1WithSHA256, |
| 5902 | }, |
| 5903 | Bugs: ProtocolBugs{ |
| 5904 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5905 | }, |
| 5906 | }, |
| 5907 | shouldFail: true, |
| 5908 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5909 | }) |
| 5910 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5911 | testCases = append(testCases, testCase{ |
| 5912 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 5913 | config: Config{ |
| 5914 | MaxVersion: VersionTLS13, |
| 5915 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5916 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5917 | signatureRSAPSSWithSHA256, |
| 5918 | }, |
| 5919 | Bugs: ProtocolBugs{ |
| 5920 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5921 | }, |
| 5922 | }, |
| 5923 | shouldFail: true, |
| 5924 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5925 | }) |
| 5926 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5927 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 5928 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5929 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5930 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5931 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5932 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5933 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5934 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5935 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5936 | }, |
| 5937 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5938 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5939 | }, |
| 5940 | }, |
| 5941 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5942 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5943 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5944 | }, |
| 5945 | }) |
| 5946 | |
| 5947 | testCases = append(testCases, testCase{ |
| 5948 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5949 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5950 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5951 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5952 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5953 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5954 | }, |
| 5955 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5956 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5957 | }, |
| 5958 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5959 | flags: []string{ |
| 5960 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5961 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5962 | }, |
| 5963 | }) |
| 5964 | |
| 5965 | testCases = append(testCases, testCase{ |
| 5966 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 5967 | config: Config{ |
| 5968 | MaxVersion: VersionTLS12, |
| 5969 | ClientAuth: RequireAnyClientCert, |
| 5970 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5971 | signatureECDSAWithSHA1, |
| 5972 | }, |
| 5973 | Bugs: ProtocolBugs{ |
| 5974 | NoSignatureAlgorithms: true, |
| 5975 | }, |
| 5976 | }, |
| 5977 | flags: []string{ |
| 5978 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 5979 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 5980 | }, |
| 5981 | }) |
| 5982 | |
| 5983 | testCases = append(testCases, testCase{ |
| 5984 | testType: serverTest, |
| 5985 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 5986 | config: Config{ |
| 5987 | MaxVersion: VersionTLS12, |
| 5988 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5989 | signatureECDSAWithSHA1, |
| 5990 | }, |
| 5991 | Bugs: ProtocolBugs{ |
| 5992 | NoSignatureAlgorithms: true, |
| 5993 | }, |
| 5994 | }, |
| 5995 | flags: []string{ |
| 5996 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 5997 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 5998 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5999 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6000 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6001 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6002 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6003 | config: Config{ |
| 6004 | MaxVersion: VersionTLS13, |
| 6005 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6006 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6007 | signatureRSAPKCS1WithSHA1, |
| 6008 | }, |
| 6009 | Bugs: ProtocolBugs{ |
| 6010 | NoSignatureAlgorithms: true, |
| 6011 | }, |
| 6012 | }, |
| 6013 | flags: []string{ |
| 6014 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6015 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6016 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6017 | shouldFail: true, |
| 6018 | // An empty CertificateRequest signature algorithm list is a |
| 6019 | // syntax error in TLS 1.3. |
| 6020 | expectedError: ":DECODE_ERROR:", |
| 6021 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6022 | }) |
| 6023 | |
| 6024 | testCases = append(testCases, testCase{ |
| 6025 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6026 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6027 | config: Config{ |
| 6028 | MaxVersion: VersionTLS13, |
| 6029 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6030 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6031 | signatureRSAPKCS1WithSHA1, |
| 6032 | }, |
| 6033 | Bugs: ProtocolBugs{ |
| 6034 | NoSignatureAlgorithms: true, |
| 6035 | }, |
| 6036 | }, |
| 6037 | shouldFail: true, |
| 6038 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6039 | }) |
| 6040 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6041 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6042 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6043 | testCases = append(testCases, testCase{ |
| 6044 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6045 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6046 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6047 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6048 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6049 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6050 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6051 | }, |
| 6052 | Bugs: ProtocolBugs{ |
| 6053 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6054 | }, |
| 6055 | }, |
| 6056 | flags: []string{"-require-any-client-certificate"}, |
| 6057 | shouldFail: true, |
| 6058 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6059 | }) |
| 6060 | |
| 6061 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6062 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6063 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6064 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6065 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6066 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6067 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6068 | }, |
| 6069 | Bugs: ProtocolBugs{ |
| 6070 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6071 | }, |
| 6072 | }, |
| 6073 | shouldFail: true, |
| 6074 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6075 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6076 | testCases = append(testCases, testCase{ |
| 6077 | testType: serverTest, |
| 6078 | name: "ClientAuth-Enforced-TLS13", |
| 6079 | config: Config{ |
| 6080 | MaxVersion: VersionTLS13, |
| 6081 | Certificates: []Certificate{rsaCertificate}, |
| 6082 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6083 | signatureRSAPKCS1WithMD5, |
| 6084 | }, |
| 6085 | Bugs: ProtocolBugs{ |
| 6086 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6087 | IgnoreSignatureVersionChecks: true, |
| 6088 | }, |
| 6089 | }, |
| 6090 | flags: []string{"-require-any-client-certificate"}, |
| 6091 | shouldFail: true, |
| 6092 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6093 | }) |
| 6094 | |
| 6095 | testCases = append(testCases, testCase{ |
| 6096 | name: "ServerAuth-Enforced-TLS13", |
| 6097 | config: Config{ |
| 6098 | MaxVersion: VersionTLS13, |
| 6099 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6100 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6101 | signatureRSAPKCS1WithMD5, |
| 6102 | }, |
| 6103 | Bugs: ProtocolBugs{ |
| 6104 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6105 | IgnoreSignatureVersionChecks: true, |
| 6106 | }, |
| 6107 | }, |
| 6108 | shouldFail: true, |
| 6109 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6110 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6111 | |
| 6112 | // Test that the agreed upon digest respects the client preferences and |
| 6113 | // the server digests. |
| 6114 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6115 | name: "NoCommonAlgorithms-Digests", |
| 6116 | config: Config{ |
| 6117 | MaxVersion: VersionTLS12, |
| 6118 | ClientAuth: RequireAnyClientCert, |
| 6119 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6120 | signatureRSAPKCS1WithSHA512, |
| 6121 | signatureRSAPKCS1WithSHA1, |
| 6122 | }, |
| 6123 | }, |
| 6124 | flags: []string{ |
| 6125 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6126 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6127 | "-digest-prefs", "SHA256", |
| 6128 | }, |
| 6129 | shouldFail: true, |
| 6130 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6131 | }) |
| 6132 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6133 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6134 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6135 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6136 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6137 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6138 | signatureRSAPKCS1WithSHA512, |
| 6139 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6140 | }, |
| 6141 | }, |
| 6142 | flags: []string{ |
| 6143 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6144 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6145 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6146 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6147 | shouldFail: true, |
| 6148 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6149 | }) |
| 6150 | testCases = append(testCases, testCase{ |
| 6151 | name: "NoCommonAlgorithms-TLS13", |
| 6152 | config: Config{ |
| 6153 | MaxVersion: VersionTLS13, |
| 6154 | ClientAuth: RequireAnyClientCert, |
| 6155 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6156 | signatureRSAPSSWithSHA512, |
| 6157 | signatureRSAPSSWithSHA384, |
| 6158 | }, |
| 6159 | }, |
| 6160 | flags: []string{ |
| 6161 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6162 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6163 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 6164 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6165 | shouldFail: true, |
| 6166 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6167 | }) |
| 6168 | testCases = append(testCases, testCase{ |
| 6169 | name: "Agree-Digest-SHA256", |
| 6170 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6171 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6172 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6173 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6174 | signatureRSAPKCS1WithSHA1, |
| 6175 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6176 | }, |
| 6177 | }, |
| 6178 | flags: []string{ |
| 6179 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6180 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6181 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6182 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6183 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6184 | }) |
| 6185 | testCases = append(testCases, testCase{ |
| 6186 | name: "Agree-Digest-SHA1", |
| 6187 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6188 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6189 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6190 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6191 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6192 | }, |
| 6193 | }, |
| 6194 | flags: []string{ |
| 6195 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6196 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6197 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6198 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6199 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6200 | }) |
| 6201 | testCases = append(testCases, testCase{ |
| 6202 | name: "Agree-Digest-Default", |
| 6203 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6204 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6205 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6206 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6207 | signatureRSAPKCS1WithSHA256, |
| 6208 | signatureECDSAWithP256AndSHA256, |
| 6209 | signatureRSAPKCS1WithSHA1, |
| 6210 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6211 | }, |
| 6212 | }, |
| 6213 | flags: []string{ |
| 6214 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6215 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6216 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6217 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6218 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6219 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6220 | // Test that the signing preference list may include extra algorithms |
| 6221 | // without negotiation problems. |
| 6222 | testCases = append(testCases, testCase{ |
| 6223 | testType: serverTest, |
| 6224 | name: "FilterExtraAlgorithms", |
| 6225 | config: Config{ |
| 6226 | MaxVersion: VersionTLS12, |
| 6227 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6228 | signatureRSAPKCS1WithSHA256, |
| 6229 | }, |
| 6230 | }, |
| 6231 | flags: []string{ |
| 6232 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6233 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6234 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 6235 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 6236 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 6237 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 6238 | }, |
| 6239 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 6240 | }) |
| 6241 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6242 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 6243 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6244 | testCases = append(testCases, testCase{ |
| 6245 | name: "CheckLeafCurve", |
| 6246 | config: Config{ |
| 6247 | MaxVersion: VersionTLS12, |
| 6248 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6249 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6250 | }, |
| 6251 | flags: []string{"-p384-only"}, |
| 6252 | shouldFail: true, |
| 6253 | expectedError: ":BAD_ECC_CERT:", |
| 6254 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 6255 | |
| 6256 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 6257 | testCases = append(testCases, testCase{ |
| 6258 | name: "CheckLeafCurve-TLS13", |
| 6259 | config: Config{ |
| 6260 | MaxVersion: VersionTLS13, |
| 6261 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6262 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 6263 | }, |
| 6264 | flags: []string{"-p384-only"}, |
| 6265 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6266 | |
| 6267 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 6268 | testCases = append(testCases, testCase{ |
| 6269 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 6270 | config: Config{ |
| 6271 | MaxVersion: VersionTLS12, |
| 6272 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6273 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6274 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6275 | signatureECDSAWithP384AndSHA384, |
| 6276 | }, |
| 6277 | }, |
| 6278 | }) |
| 6279 | |
| 6280 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 6281 | testCases = append(testCases, testCase{ |
| 6282 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 6283 | config: Config{ |
| 6284 | MaxVersion: VersionTLS13, |
| 6285 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6286 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6287 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6288 | signatureECDSAWithP384AndSHA384, |
| 6289 | }, |
| 6290 | Bugs: ProtocolBugs{ |
| 6291 | SkipECDSACurveCheck: true, |
| 6292 | }, |
| 6293 | }, |
| 6294 | shouldFail: true, |
| 6295 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6296 | }) |
| 6297 | |
| 6298 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 6299 | // account. |
| 6300 | testCases = append(testCases, testCase{ |
| 6301 | testType: serverTest, |
| 6302 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 6303 | config: Config{ |
| 6304 | MaxVersion: VersionTLS13, |
| 6305 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6306 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6307 | signatureECDSAWithP384AndSHA384, |
| 6308 | signatureECDSAWithP256AndSHA256, |
| 6309 | }, |
| 6310 | }, |
| 6311 | flags: []string{ |
| 6312 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6313 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6314 | }, |
| 6315 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6316 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 6317 | |
| 6318 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 6319 | // server does not attempt to sign in that case. |
| 6320 | testCases = append(testCases, testCase{ |
| 6321 | testType: serverTest, |
| 6322 | name: "RSA-PSS-Large", |
| 6323 | config: Config{ |
| 6324 | MaxVersion: VersionTLS13, |
| 6325 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6326 | signatureRSAPSSWithSHA512, |
| 6327 | }, |
| 6328 | }, |
| 6329 | flags: []string{ |
| 6330 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 6331 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 6332 | }, |
| 6333 | shouldFail: true, |
| 6334 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6335 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 6336 | |
| 6337 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 6338 | testCases = append(testCases, testCase{ |
| 6339 | testType: clientTest, |
| 6340 | name: "RSA-PSS-Default-Verify", |
| 6341 | config: Config{ |
| 6342 | MaxVersion: VersionTLS12, |
| 6343 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6344 | signatureRSAPSSWithSHA256, |
| 6345 | }, |
| 6346 | }, |
| 6347 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6348 | }) |
| 6349 | |
| 6350 | testCases = append(testCases, testCase{ |
| 6351 | testType: serverTest, |
| 6352 | name: "RSA-PSS-Default-Sign", |
| 6353 | config: Config{ |
| 6354 | MaxVersion: VersionTLS12, |
| 6355 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6356 | signatureRSAPSSWithSHA256, |
| 6357 | }, |
| 6358 | }, |
| 6359 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6360 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6361 | } |
| 6362 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6363 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 6364 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 6365 | var timeouts = []time.Duration{ |
| 6366 | 1 * time.Second, |
| 6367 | 2 * time.Second, |
| 6368 | 4 * time.Second, |
| 6369 | 8 * time.Second, |
| 6370 | 16 * time.Second, |
| 6371 | 32 * time.Second, |
| 6372 | 60 * time.Second, |
| 6373 | 60 * time.Second, |
| 6374 | 60 * time.Second, |
| 6375 | 60 * time.Second, |
| 6376 | 60 * time.Second, |
| 6377 | 60 * time.Second, |
| 6378 | 60 * time.Second, |
| 6379 | } |
| 6380 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 6381 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 6382 | // initial timeout duration was set to 250ms. |
| 6383 | var shortTimeouts = []time.Duration{ |
| 6384 | 250 * time.Millisecond, |
| 6385 | 500 * time.Millisecond, |
| 6386 | 1 * time.Second, |
| 6387 | 2 * time.Second, |
| 6388 | 4 * time.Second, |
| 6389 | 8 * time.Second, |
| 6390 | 16 * time.Second, |
| 6391 | 32 * time.Second, |
| 6392 | 60 * time.Second, |
| 6393 | 60 * time.Second, |
| 6394 | 60 * time.Second, |
| 6395 | 60 * time.Second, |
| 6396 | 60 * time.Second, |
| 6397 | } |
| 6398 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6399 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6400 | // These tests work by coordinating some behavior on both the shim and |
| 6401 | // the runner. |
| 6402 | // |
| 6403 | // TimeoutSchedule configures the runner to send a series of timeout |
| 6404 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 6405 | // each peer handshake flight N. The timeout opcode both simulates a |
| 6406 | // timeout in the shim and acts as a synchronization point to help the |
| 6407 | // runner bracket each handshake flight. |
| 6408 | // |
| 6409 | // We assume the shim does not read from the channel eagerly. It must |
| 6410 | // first wait until it has sent flight N and is ready to receive |
| 6411 | // handshake flight N+1. At this point, it will process the timeout |
| 6412 | // opcode. It must then immediately respond with a timeout ACK and act |
| 6413 | // as if the shim was idle for the specified amount of time. |
| 6414 | // |
| 6415 | // The runner then drops all packets received before the ACK and |
| 6416 | // continues waiting for flight N. This ordering results in one attempt |
| 6417 | // at sending flight N to be dropped. For the test to complete, the |
| 6418 | // shim must send flight N again, testing that the shim implements DTLS |
| 6419 | // retransmit on a timeout. |
| 6420 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6421 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6422 | // likely be more epochs to cross and the final message's retransmit may |
| 6423 | // be more complex. |
| 6424 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6425 | for _, async := range []bool{true, false} { |
| 6426 | var tests []testCase |
| 6427 | |
| 6428 | // Test that this is indeed the timeout schedule. Stress all |
| 6429 | // four patterns of handshake. |
| 6430 | for i := 1; i < len(timeouts); i++ { |
| 6431 | number := strconv.Itoa(i) |
| 6432 | tests = append(tests, testCase{ |
| 6433 | protocol: dtls, |
| 6434 | name: "DTLS-Retransmit-Client-" + number, |
| 6435 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6436 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6437 | Bugs: ProtocolBugs{ |
| 6438 | TimeoutSchedule: timeouts[:i], |
| 6439 | }, |
| 6440 | }, |
| 6441 | resumeSession: true, |
| 6442 | }) |
| 6443 | tests = append(tests, testCase{ |
| 6444 | protocol: dtls, |
| 6445 | testType: serverTest, |
| 6446 | name: "DTLS-Retransmit-Server-" + number, |
| 6447 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6448 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6449 | Bugs: ProtocolBugs{ |
| 6450 | TimeoutSchedule: timeouts[:i], |
| 6451 | }, |
| 6452 | }, |
| 6453 | resumeSession: true, |
| 6454 | }) |
| 6455 | } |
| 6456 | |
| 6457 | // Test that exceeding the timeout schedule hits a read |
| 6458 | // timeout. |
| 6459 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6460 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6461 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6462 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6463 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6464 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6465 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6466 | }, |
| 6467 | }, |
| 6468 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6469 | shouldFail: true, |
| 6470 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6471 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6472 | |
| 6473 | if async { |
| 6474 | // Test that timeout handling has a fudge factor, due to API |
| 6475 | // problems. |
| 6476 | tests = append(tests, testCase{ |
| 6477 | protocol: dtls, |
| 6478 | name: "DTLS-Retransmit-Fudge", |
| 6479 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6480 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6481 | Bugs: ProtocolBugs{ |
| 6482 | TimeoutSchedule: []time.Duration{ |
| 6483 | timeouts[0] - 10*time.Millisecond, |
| 6484 | }, |
| 6485 | }, |
| 6486 | }, |
| 6487 | resumeSession: true, |
| 6488 | }) |
| 6489 | } |
| 6490 | |
| 6491 | // Test that the final Finished retransmitting isn't |
| 6492 | // duplicated if the peer badly fragments everything. |
| 6493 | tests = append(tests, testCase{ |
| 6494 | testType: serverTest, |
| 6495 | protocol: dtls, |
| 6496 | name: "DTLS-Retransmit-Fragmented", |
| 6497 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6498 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6499 | Bugs: ProtocolBugs{ |
| 6500 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 6501 | MaxHandshakeRecordLength: 2, |
| 6502 | }, |
| 6503 | }, |
| 6504 | }) |
| 6505 | |
| 6506 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 6507 | tests = append(tests, testCase{ |
| 6508 | protocol: dtls, |
| 6509 | name: "DTLS-Retransmit-Short-Client", |
| 6510 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6511 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6512 | Bugs: ProtocolBugs{ |
| 6513 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 6514 | }, |
| 6515 | }, |
| 6516 | resumeSession: true, |
| 6517 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 6518 | }) |
| 6519 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6520 | protocol: dtls, |
| 6521 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6522 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6523 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6524 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6525 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6526 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6527 | }, |
| 6528 | }, |
| 6529 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6530 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6531 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6532 | |
| 6533 | for _, test := range tests { |
| 6534 | if async { |
| 6535 | test.name += "-Async" |
| 6536 | test.flags = append(test.flags, "-async") |
| 6537 | } |
| 6538 | |
| 6539 | testCases = append(testCases, test) |
| 6540 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6541 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6542 | } |
| 6543 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 6544 | func addExportKeyingMaterialTests() { |
| 6545 | for _, vers := range tlsVersions { |
| 6546 | if vers.version == VersionSSL30 { |
| 6547 | continue |
| 6548 | } |
| 6549 | testCases = append(testCases, testCase{ |
| 6550 | name: "ExportKeyingMaterial-" + vers.name, |
| 6551 | config: Config{ |
| 6552 | MaxVersion: vers.version, |
| 6553 | }, |
| 6554 | exportKeyingMaterial: 1024, |
| 6555 | exportLabel: "label", |
| 6556 | exportContext: "context", |
| 6557 | useExportContext: true, |
| 6558 | }) |
| 6559 | testCases = append(testCases, testCase{ |
| 6560 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 6561 | config: Config{ |
| 6562 | MaxVersion: vers.version, |
| 6563 | }, |
| 6564 | exportKeyingMaterial: 1024, |
| 6565 | }) |
| 6566 | testCases = append(testCases, testCase{ |
| 6567 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 6568 | config: Config{ |
| 6569 | MaxVersion: vers.version, |
| 6570 | }, |
| 6571 | exportKeyingMaterial: 1024, |
| 6572 | useExportContext: true, |
| 6573 | }) |
| 6574 | testCases = append(testCases, testCase{ |
| 6575 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 6576 | config: Config{ |
| 6577 | MaxVersion: vers.version, |
| 6578 | }, |
| 6579 | exportKeyingMaterial: 1, |
| 6580 | exportLabel: "label", |
| 6581 | exportContext: "context", |
| 6582 | useExportContext: true, |
| 6583 | }) |
| 6584 | } |
| 6585 | testCases = append(testCases, testCase{ |
| 6586 | name: "ExportKeyingMaterial-SSL3", |
| 6587 | config: Config{ |
| 6588 | MaxVersion: VersionSSL30, |
| 6589 | }, |
| 6590 | exportKeyingMaterial: 1024, |
| 6591 | exportLabel: "label", |
| 6592 | exportContext: "context", |
| 6593 | useExportContext: true, |
| 6594 | shouldFail: true, |
| 6595 | expectedError: "failed to export keying material", |
| 6596 | }) |
| 6597 | } |
| 6598 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6599 | func addTLSUniqueTests() { |
| 6600 | for _, isClient := range []bool{false, true} { |
| 6601 | for _, isResumption := range []bool{false, true} { |
| 6602 | for _, hasEMS := range []bool{false, true} { |
| 6603 | var suffix string |
| 6604 | if isResumption { |
| 6605 | suffix = "Resume-" |
| 6606 | } else { |
| 6607 | suffix = "Full-" |
| 6608 | } |
| 6609 | |
| 6610 | if hasEMS { |
| 6611 | suffix += "EMS-" |
| 6612 | } else { |
| 6613 | suffix += "NoEMS-" |
| 6614 | } |
| 6615 | |
| 6616 | if isClient { |
| 6617 | suffix += "Client" |
| 6618 | } else { |
| 6619 | suffix += "Server" |
| 6620 | } |
| 6621 | |
| 6622 | test := testCase{ |
| 6623 | name: "TLSUnique-" + suffix, |
| 6624 | testTLSUnique: true, |
| 6625 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6626 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6627 | Bugs: ProtocolBugs{ |
| 6628 | NoExtendedMasterSecret: !hasEMS, |
| 6629 | }, |
| 6630 | }, |
| 6631 | } |
| 6632 | |
| 6633 | if isResumption { |
| 6634 | test.resumeSession = true |
| 6635 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6636 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6637 | Bugs: ProtocolBugs{ |
| 6638 | NoExtendedMasterSecret: !hasEMS, |
| 6639 | }, |
| 6640 | } |
| 6641 | } |
| 6642 | |
| 6643 | if isResumption && !hasEMS { |
| 6644 | test.shouldFail = true |
| 6645 | test.expectedError = "failed to get tls-unique" |
| 6646 | } |
| 6647 | |
| 6648 | testCases = append(testCases, test) |
| 6649 | } |
| 6650 | } |
| 6651 | } |
| 6652 | } |
| 6653 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6654 | func addCustomExtensionTests() { |
| 6655 | expectedContents := "custom extension" |
| 6656 | emptyString := "" |
| 6657 | |
| 6658 | for _, isClient := range []bool{false, true} { |
| 6659 | suffix := "Server" |
| 6660 | flag := "-enable-server-custom-extension" |
| 6661 | testType := serverTest |
| 6662 | if isClient { |
| 6663 | suffix = "Client" |
| 6664 | flag = "-enable-client-custom-extension" |
| 6665 | testType = clientTest |
| 6666 | } |
| 6667 | |
| 6668 | testCases = append(testCases, testCase{ |
| 6669 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6670 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6671 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6672 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6673 | Bugs: ProtocolBugs{ |
| 6674 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6675 | ExpectedCustomExtension: &expectedContents, |
| 6676 | }, |
| 6677 | }, |
| 6678 | flags: []string{flag}, |
| 6679 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6680 | testCases = append(testCases, testCase{ |
| 6681 | testType: testType, |
| 6682 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 6683 | config: Config{ |
| 6684 | MaxVersion: VersionTLS13, |
| 6685 | Bugs: ProtocolBugs{ |
| 6686 | CustomExtension: expectedContents, |
| 6687 | ExpectedCustomExtension: &expectedContents, |
| 6688 | }, |
| 6689 | }, |
| 6690 | flags: []string{flag}, |
| 6691 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6692 | |
| 6693 | // If the parse callback fails, the handshake should also fail. |
| 6694 | testCases = append(testCases, testCase{ |
| 6695 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6696 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6697 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6698 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6699 | Bugs: ProtocolBugs{ |
| 6700 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6701 | ExpectedCustomExtension: &expectedContents, |
| 6702 | }, |
| 6703 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6704 | flags: []string{flag}, |
| 6705 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6706 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6707 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6708 | testCases = append(testCases, testCase{ |
| 6709 | testType: testType, |
| 6710 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 6711 | config: Config{ |
| 6712 | MaxVersion: VersionTLS13, |
| 6713 | Bugs: ProtocolBugs{ |
| 6714 | CustomExtension: expectedContents + "foo", |
| 6715 | ExpectedCustomExtension: &expectedContents, |
| 6716 | }, |
| 6717 | }, |
| 6718 | flags: []string{flag}, |
| 6719 | shouldFail: true, |
| 6720 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6721 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6722 | |
| 6723 | // If the add callback fails, the handshake should also fail. |
| 6724 | testCases = append(testCases, testCase{ |
| 6725 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6726 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6727 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6728 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6729 | Bugs: ProtocolBugs{ |
| 6730 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6731 | ExpectedCustomExtension: &expectedContents, |
| 6732 | }, |
| 6733 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6734 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6735 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6736 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6737 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6738 | testCases = append(testCases, testCase{ |
| 6739 | testType: testType, |
| 6740 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 6741 | config: Config{ |
| 6742 | MaxVersion: VersionTLS13, |
| 6743 | Bugs: ProtocolBugs{ |
| 6744 | CustomExtension: expectedContents, |
| 6745 | ExpectedCustomExtension: &expectedContents, |
| 6746 | }, |
| 6747 | }, |
| 6748 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6749 | shouldFail: true, |
| 6750 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6751 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6752 | |
| 6753 | // If the add callback returns zero, no extension should be |
| 6754 | // added. |
| 6755 | skipCustomExtension := expectedContents |
| 6756 | if isClient { |
| 6757 | // For the case where the client skips sending the |
| 6758 | // custom extension, the server must not “echo” it. |
| 6759 | skipCustomExtension = "" |
| 6760 | } |
| 6761 | testCases = append(testCases, testCase{ |
| 6762 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6763 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6764 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6765 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6766 | Bugs: ProtocolBugs{ |
| 6767 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6768 | ExpectedCustomExtension: &emptyString, |
| 6769 | }, |
| 6770 | }, |
| 6771 | flags: []string{flag, "-custom-extension-skip"}, |
| 6772 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6773 | testCases = append(testCases, testCase{ |
| 6774 | testType: testType, |
| 6775 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 6776 | config: Config{ |
| 6777 | MaxVersion: VersionTLS13, |
| 6778 | Bugs: ProtocolBugs{ |
| 6779 | CustomExtension: skipCustomExtension, |
| 6780 | ExpectedCustomExtension: &emptyString, |
| 6781 | }, |
| 6782 | }, |
| 6783 | flags: []string{flag, "-custom-extension-skip"}, |
| 6784 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6785 | } |
| 6786 | |
| 6787 | // The custom extension add callback should not be called if the client |
| 6788 | // doesn't send the extension. |
| 6789 | testCases = append(testCases, testCase{ |
| 6790 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6791 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6792 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6793 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6794 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6795 | ExpectedCustomExtension: &emptyString, |
| 6796 | }, |
| 6797 | }, |
| 6798 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6799 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6800 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6801 | testCases = append(testCases, testCase{ |
| 6802 | testType: serverTest, |
| 6803 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 6804 | config: Config{ |
| 6805 | MaxVersion: VersionTLS13, |
| 6806 | Bugs: ProtocolBugs{ |
| 6807 | ExpectedCustomExtension: &emptyString, |
| 6808 | }, |
| 6809 | }, |
| 6810 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6811 | }) |
| 6812 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6813 | // Test an unknown extension from the server. |
| 6814 | testCases = append(testCases, testCase{ |
| 6815 | testType: clientTest, |
| 6816 | name: "UnknownExtension-Client", |
| 6817 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6818 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6819 | Bugs: ProtocolBugs{ |
| 6820 | CustomExtension: expectedContents, |
| 6821 | }, |
| 6822 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 6823 | shouldFail: true, |
| 6824 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6825 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6826 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6827 | testCases = append(testCases, testCase{ |
| 6828 | testType: clientTest, |
| 6829 | name: "UnknownExtension-Client-TLS13", |
| 6830 | config: Config{ |
| 6831 | MaxVersion: VersionTLS13, |
| 6832 | Bugs: ProtocolBugs{ |
| 6833 | CustomExtension: expectedContents, |
| 6834 | }, |
| 6835 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 6836 | shouldFail: true, |
| 6837 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6838 | expectedLocalError: "remote error: unsupported extension", |
| 6839 | }) |
| 6840 | |
| 6841 | // Test a known but unoffered extension from the server. |
| 6842 | testCases = append(testCases, testCase{ |
| 6843 | testType: clientTest, |
| 6844 | name: "UnofferedExtension-Client", |
| 6845 | config: Config{ |
| 6846 | MaxVersion: VersionTLS12, |
| 6847 | Bugs: ProtocolBugs{ |
| 6848 | SendALPN: "alpn", |
| 6849 | }, |
| 6850 | }, |
| 6851 | shouldFail: true, |
| 6852 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6853 | expectedLocalError: "remote error: unsupported extension", |
| 6854 | }) |
| 6855 | testCases = append(testCases, testCase{ |
| 6856 | testType: clientTest, |
| 6857 | name: "UnofferedExtension-Client-TLS13", |
| 6858 | config: Config{ |
| 6859 | MaxVersion: VersionTLS13, |
| 6860 | Bugs: ProtocolBugs{ |
| 6861 | SendALPN: "alpn", |
| 6862 | }, |
| 6863 | }, |
| 6864 | shouldFail: true, |
| 6865 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6866 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6867 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6868 | } |
| 6869 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6870 | func addRSAClientKeyExchangeTests() { |
| 6871 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 6872 | testCases = append(testCases, testCase{ |
| 6873 | testType: serverTest, |
| 6874 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 6875 | config: Config{ |
| 6876 | // Ensure the ClientHello version and final |
| 6877 | // version are different, to detect if the |
| 6878 | // server uses the wrong one. |
| 6879 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6880 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6881 | Bugs: ProtocolBugs{ |
| 6882 | BadRSAClientKeyExchange: bad, |
| 6883 | }, |
| 6884 | }, |
| 6885 | shouldFail: true, |
| 6886 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6887 | }) |
| 6888 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 6889 | |
| 6890 | // The server must compare whatever was in ClientHello.version for the |
| 6891 | // RSA premaster. |
| 6892 | testCases = append(testCases, testCase{ |
| 6893 | testType: serverTest, |
| 6894 | name: "SendClientVersion-RSA", |
| 6895 | config: Config{ |
| 6896 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6897 | Bugs: ProtocolBugs{ |
| 6898 | SendClientVersion: 0x1234, |
| 6899 | }, |
| 6900 | }, |
| 6901 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6902 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6903 | } |
| 6904 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6905 | var testCurves = []struct { |
| 6906 | name string |
| 6907 | id CurveID |
| 6908 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6909 | {"P-256", CurveP256}, |
| 6910 | {"P-384", CurveP384}, |
| 6911 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 6912 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6913 | } |
| 6914 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6915 | const bogusCurve = 0x1234 |
| 6916 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6917 | func addCurveTests() { |
| 6918 | for _, curve := range testCurves { |
| 6919 | testCases = append(testCases, testCase{ |
| 6920 | name: "CurveTest-Client-" + curve.name, |
| 6921 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6922 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6923 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6924 | CurvePreferences: []CurveID{curve.id}, |
| 6925 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6926 | flags: []string{ |
| 6927 | "-enable-all-curves", |
| 6928 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6929 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6930 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6931 | }) |
| 6932 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6933 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 6934 | config: Config{ |
| 6935 | MaxVersion: VersionTLS13, |
| 6936 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6937 | CurvePreferences: []CurveID{curve.id}, |
| 6938 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6939 | flags: []string{ |
| 6940 | "-enable-all-curves", |
| 6941 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6942 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6943 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6944 | }) |
| 6945 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6946 | testType: serverTest, |
| 6947 | name: "CurveTest-Server-" + curve.name, |
| 6948 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6949 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6950 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6951 | CurvePreferences: []CurveID{curve.id}, |
| 6952 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6953 | flags: []string{ |
| 6954 | "-enable-all-curves", |
| 6955 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6956 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6957 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6958 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6959 | testCases = append(testCases, testCase{ |
| 6960 | testType: serverTest, |
| 6961 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 6962 | config: Config{ |
| 6963 | MaxVersion: VersionTLS13, |
| 6964 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6965 | CurvePreferences: []CurveID{curve.id}, |
| 6966 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6967 | flags: []string{ |
| 6968 | "-enable-all-curves", |
| 6969 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6970 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6971 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6972 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6973 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 6974 | |
| 6975 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 6976 | testCases = append(testCases, testCase{ |
| 6977 | testType: serverTest, |
| 6978 | name: "UnknownCurve", |
| 6979 | config: Config{ |
| 6980 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6981 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 6982 | }, |
| 6983 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6984 | |
| 6985 | // The server must not consider ECDHE ciphers when there are no |
| 6986 | // supported curves. |
| 6987 | testCases = append(testCases, testCase{ |
| 6988 | testType: serverTest, |
| 6989 | name: "NoSupportedCurves", |
| 6990 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6991 | MaxVersion: VersionTLS12, |
| 6992 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6993 | Bugs: ProtocolBugs{ |
| 6994 | NoSupportedCurves: true, |
| 6995 | }, |
| 6996 | }, |
| 6997 | shouldFail: true, |
| 6998 | expectedError: ":NO_SHARED_CIPHER:", |
| 6999 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7000 | testCases = append(testCases, testCase{ |
| 7001 | testType: serverTest, |
| 7002 | name: "NoSupportedCurves-TLS13", |
| 7003 | config: Config{ |
| 7004 | MaxVersion: VersionTLS13, |
| 7005 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7006 | Bugs: ProtocolBugs{ |
| 7007 | NoSupportedCurves: true, |
| 7008 | }, |
| 7009 | }, |
| 7010 | shouldFail: true, |
| 7011 | expectedError: ":NO_SHARED_CIPHER:", |
| 7012 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7013 | |
| 7014 | // The server must fall back to another cipher when there are no |
| 7015 | // supported curves. |
| 7016 | testCases = append(testCases, testCase{ |
| 7017 | testType: serverTest, |
| 7018 | name: "NoCommonCurves", |
| 7019 | config: Config{ |
| 7020 | MaxVersion: VersionTLS12, |
| 7021 | CipherSuites: []uint16{ |
| 7022 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7023 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7024 | }, |
| 7025 | CurvePreferences: []CurveID{CurveP224}, |
| 7026 | }, |
| 7027 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7028 | }) |
| 7029 | |
| 7030 | // The client must reject bogus curves and disabled curves. |
| 7031 | testCases = append(testCases, testCase{ |
| 7032 | name: "BadECDHECurve", |
| 7033 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7034 | MaxVersion: VersionTLS12, |
| 7035 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7036 | Bugs: ProtocolBugs{ |
| 7037 | SendCurve: bogusCurve, |
| 7038 | }, |
| 7039 | }, |
| 7040 | shouldFail: true, |
| 7041 | expectedError: ":WRONG_CURVE:", |
| 7042 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7043 | testCases = append(testCases, testCase{ |
| 7044 | name: "BadECDHECurve-TLS13", |
| 7045 | config: Config{ |
| 7046 | MaxVersion: VersionTLS13, |
| 7047 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7048 | Bugs: ProtocolBugs{ |
| 7049 | SendCurve: bogusCurve, |
| 7050 | }, |
| 7051 | }, |
| 7052 | shouldFail: true, |
| 7053 | expectedError: ":WRONG_CURVE:", |
| 7054 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7055 | |
| 7056 | testCases = append(testCases, testCase{ |
| 7057 | name: "UnsupportedCurve", |
| 7058 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7059 | MaxVersion: VersionTLS12, |
| 7060 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7061 | CurvePreferences: []CurveID{CurveP256}, |
| 7062 | Bugs: ProtocolBugs{ |
| 7063 | IgnorePeerCurvePreferences: true, |
| 7064 | }, |
| 7065 | }, |
| 7066 | flags: []string{"-p384-only"}, |
| 7067 | shouldFail: true, |
| 7068 | expectedError: ":WRONG_CURVE:", |
| 7069 | }) |
| 7070 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7071 | testCases = append(testCases, testCase{ |
| 7072 | // TODO(davidben): Add a TLS 1.3 version where |
| 7073 | // HelloRetryRequest requests an unsupported curve. |
| 7074 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 7075 | config: Config{ |
| 7076 | MaxVersion: VersionTLS12, |
| 7077 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7078 | CurvePreferences: []CurveID{CurveP384}, |
| 7079 | Bugs: ProtocolBugs{ |
| 7080 | SendCurve: CurveP256, |
| 7081 | }, |
| 7082 | }, |
| 7083 | flags: []string{"-p384-only"}, |
| 7084 | shouldFail: true, |
| 7085 | expectedError: ":WRONG_CURVE:", |
| 7086 | }) |
| 7087 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7088 | // Test invalid curve points. |
| 7089 | testCases = append(testCases, testCase{ |
| 7090 | name: "InvalidECDHPoint-Client", |
| 7091 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7092 | MaxVersion: VersionTLS12, |
| 7093 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7094 | CurvePreferences: []CurveID{CurveP256}, |
| 7095 | Bugs: ProtocolBugs{ |
| 7096 | InvalidECDHPoint: true, |
| 7097 | }, |
| 7098 | }, |
| 7099 | shouldFail: true, |
| 7100 | expectedError: ":INVALID_ENCODING:", |
| 7101 | }) |
| 7102 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7103 | name: "InvalidECDHPoint-Client-TLS13", |
| 7104 | config: Config{ |
| 7105 | MaxVersion: VersionTLS13, |
| 7106 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7107 | CurvePreferences: []CurveID{CurveP256}, |
| 7108 | Bugs: ProtocolBugs{ |
| 7109 | InvalidECDHPoint: true, |
| 7110 | }, |
| 7111 | }, |
| 7112 | shouldFail: true, |
| 7113 | expectedError: ":INVALID_ENCODING:", |
| 7114 | }) |
| 7115 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7116 | testType: serverTest, |
| 7117 | name: "InvalidECDHPoint-Server", |
| 7118 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7119 | MaxVersion: VersionTLS12, |
| 7120 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7121 | CurvePreferences: []CurveID{CurveP256}, |
| 7122 | Bugs: ProtocolBugs{ |
| 7123 | InvalidECDHPoint: true, |
| 7124 | }, |
| 7125 | }, |
| 7126 | shouldFail: true, |
| 7127 | expectedError: ":INVALID_ENCODING:", |
| 7128 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7129 | testCases = append(testCases, testCase{ |
| 7130 | testType: serverTest, |
| 7131 | name: "InvalidECDHPoint-Server-TLS13", |
| 7132 | config: Config{ |
| 7133 | MaxVersion: VersionTLS13, |
| 7134 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7135 | CurvePreferences: []CurveID{CurveP256}, |
| 7136 | Bugs: ProtocolBugs{ |
| 7137 | InvalidECDHPoint: true, |
| 7138 | }, |
| 7139 | }, |
| 7140 | shouldFail: true, |
| 7141 | expectedError: ":INVALID_ENCODING:", |
| 7142 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7143 | } |
| 7144 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7145 | func addCECPQ1Tests() { |
| 7146 | testCases = append(testCases, testCase{ |
| 7147 | testType: clientTest, |
| 7148 | name: "CECPQ1-Client-BadX25519Part", |
| 7149 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7150 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7151 | MinVersion: VersionTLS12, |
| 7152 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7153 | Bugs: ProtocolBugs{ |
| 7154 | CECPQ1BadX25519Part: true, |
| 7155 | }, |
| 7156 | }, |
| 7157 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7158 | shouldFail: true, |
| 7159 | expectedLocalError: "local error: bad record MAC", |
| 7160 | }) |
| 7161 | testCases = append(testCases, testCase{ |
| 7162 | testType: clientTest, |
| 7163 | name: "CECPQ1-Client-BadNewhopePart", |
| 7164 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7165 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7166 | MinVersion: VersionTLS12, |
| 7167 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7168 | Bugs: ProtocolBugs{ |
| 7169 | CECPQ1BadNewhopePart: true, |
| 7170 | }, |
| 7171 | }, |
| 7172 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7173 | shouldFail: true, |
| 7174 | expectedLocalError: "local error: bad record MAC", |
| 7175 | }) |
| 7176 | testCases = append(testCases, testCase{ |
| 7177 | testType: serverTest, |
| 7178 | name: "CECPQ1-Server-BadX25519Part", |
| 7179 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7180 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7181 | MinVersion: VersionTLS12, |
| 7182 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7183 | Bugs: ProtocolBugs{ |
| 7184 | CECPQ1BadX25519Part: true, |
| 7185 | }, |
| 7186 | }, |
| 7187 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7188 | shouldFail: true, |
| 7189 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7190 | }) |
| 7191 | testCases = append(testCases, testCase{ |
| 7192 | testType: serverTest, |
| 7193 | name: "CECPQ1-Server-BadNewhopePart", |
| 7194 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7195 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7196 | MinVersion: VersionTLS12, |
| 7197 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7198 | Bugs: ProtocolBugs{ |
| 7199 | CECPQ1BadNewhopePart: true, |
| 7200 | }, |
| 7201 | }, |
| 7202 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7203 | shouldFail: true, |
| 7204 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7205 | }) |
| 7206 | } |
| 7207 | |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7208 | func addDHEGroupSizeTests() { |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7209 | testCases = append(testCases, testCase{ |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7210 | name: "DHEGroupSize-Client", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7211 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7212 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7213 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7214 | Bugs: ProtocolBugs{ |
| 7215 | // This is a 1234-bit prime number, generated |
| 7216 | // with: |
| 7217 | // openssl gendh 1234 | openssl asn1parse -i |
| 7218 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 7219 | }, |
| 7220 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7221 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7222 | }) |
| 7223 | testCases = append(testCases, testCase{ |
| 7224 | testType: serverTest, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7225 | name: "DHEGroupSize-Server", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7226 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7227 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7228 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7229 | }, |
| 7230 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7231 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7232 | }) |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7233 | } |
| 7234 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 7235 | func addTLS13RecordTests() { |
| 7236 | testCases = append(testCases, testCase{ |
| 7237 | name: "TLS13-RecordPadding", |
| 7238 | config: Config{ |
| 7239 | MaxVersion: VersionTLS13, |
| 7240 | MinVersion: VersionTLS13, |
| 7241 | Bugs: ProtocolBugs{ |
| 7242 | RecordPadding: 10, |
| 7243 | }, |
| 7244 | }, |
| 7245 | }) |
| 7246 | |
| 7247 | testCases = append(testCases, testCase{ |
| 7248 | name: "TLS13-EmptyRecords", |
| 7249 | config: Config{ |
| 7250 | MaxVersion: VersionTLS13, |
| 7251 | MinVersion: VersionTLS13, |
| 7252 | Bugs: ProtocolBugs{ |
| 7253 | OmitRecordContents: true, |
| 7254 | }, |
| 7255 | }, |
| 7256 | shouldFail: true, |
| 7257 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7258 | }) |
| 7259 | |
| 7260 | testCases = append(testCases, testCase{ |
| 7261 | name: "TLS13-OnlyPadding", |
| 7262 | config: Config{ |
| 7263 | MaxVersion: VersionTLS13, |
| 7264 | MinVersion: VersionTLS13, |
| 7265 | Bugs: ProtocolBugs{ |
| 7266 | OmitRecordContents: true, |
| 7267 | RecordPadding: 10, |
| 7268 | }, |
| 7269 | }, |
| 7270 | shouldFail: true, |
| 7271 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7272 | }) |
| 7273 | |
| 7274 | testCases = append(testCases, testCase{ |
| 7275 | name: "TLS13-WrongOuterRecord", |
| 7276 | config: Config{ |
| 7277 | MaxVersion: VersionTLS13, |
| 7278 | MinVersion: VersionTLS13, |
| 7279 | Bugs: ProtocolBugs{ |
| 7280 | OuterRecordType: recordTypeHandshake, |
| 7281 | }, |
| 7282 | }, |
| 7283 | shouldFail: true, |
| 7284 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 7285 | }) |
| 7286 | } |
| 7287 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7288 | func addChangeCipherSpecTests() { |
| 7289 | // Test missing ChangeCipherSpecs. |
| 7290 | testCases = append(testCases, testCase{ |
| 7291 | name: "SkipChangeCipherSpec-Client", |
| 7292 | config: Config{ |
| 7293 | MaxVersion: VersionTLS12, |
| 7294 | Bugs: ProtocolBugs{ |
| 7295 | SkipChangeCipherSpec: true, |
| 7296 | }, |
| 7297 | }, |
| 7298 | shouldFail: true, |
| 7299 | expectedError: ":UNEXPECTED_RECORD:", |
| 7300 | }) |
| 7301 | testCases = append(testCases, testCase{ |
| 7302 | testType: serverTest, |
| 7303 | name: "SkipChangeCipherSpec-Server", |
| 7304 | config: Config{ |
| 7305 | MaxVersion: VersionTLS12, |
| 7306 | Bugs: ProtocolBugs{ |
| 7307 | SkipChangeCipherSpec: true, |
| 7308 | }, |
| 7309 | }, |
| 7310 | shouldFail: true, |
| 7311 | expectedError: ":UNEXPECTED_RECORD:", |
| 7312 | }) |
| 7313 | testCases = append(testCases, testCase{ |
| 7314 | testType: serverTest, |
| 7315 | name: "SkipChangeCipherSpec-Server-NPN", |
| 7316 | config: Config{ |
| 7317 | MaxVersion: VersionTLS12, |
| 7318 | NextProtos: []string{"bar"}, |
| 7319 | Bugs: ProtocolBugs{ |
| 7320 | SkipChangeCipherSpec: true, |
| 7321 | }, |
| 7322 | }, |
| 7323 | flags: []string{ |
| 7324 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 7325 | }, |
| 7326 | shouldFail: true, |
| 7327 | expectedError: ":UNEXPECTED_RECORD:", |
| 7328 | }) |
| 7329 | |
| 7330 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 7331 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 7332 | // rejected. Test both with and without handshake packing to handle both |
| 7333 | // when the partial post-CCS message is in its own record and when it is |
| 7334 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7335 | for _, packed := range []bool{false, true} { |
| 7336 | var suffix string |
| 7337 | if packed { |
| 7338 | suffix = "-Packed" |
| 7339 | } |
| 7340 | |
| 7341 | testCases = append(testCases, testCase{ |
| 7342 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 7343 | config: Config{ |
| 7344 | MaxVersion: VersionTLS12, |
| 7345 | Bugs: ProtocolBugs{ |
| 7346 | FragmentAcrossChangeCipherSpec: true, |
| 7347 | PackHandshakeFlight: packed, |
| 7348 | }, |
| 7349 | }, |
| 7350 | shouldFail: true, |
| 7351 | expectedError: ":UNEXPECTED_RECORD:", |
| 7352 | }) |
| 7353 | testCases = append(testCases, testCase{ |
| 7354 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 7355 | config: Config{ |
| 7356 | MaxVersion: VersionTLS12, |
| 7357 | }, |
| 7358 | resumeSession: true, |
| 7359 | resumeConfig: &Config{ |
| 7360 | MaxVersion: VersionTLS12, |
| 7361 | Bugs: ProtocolBugs{ |
| 7362 | FragmentAcrossChangeCipherSpec: true, |
| 7363 | PackHandshakeFlight: packed, |
| 7364 | }, |
| 7365 | }, |
| 7366 | shouldFail: true, |
| 7367 | expectedError: ":UNEXPECTED_RECORD:", |
| 7368 | }) |
| 7369 | testCases = append(testCases, testCase{ |
| 7370 | testType: serverTest, |
| 7371 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 7372 | config: Config{ |
| 7373 | MaxVersion: VersionTLS12, |
| 7374 | Bugs: ProtocolBugs{ |
| 7375 | FragmentAcrossChangeCipherSpec: true, |
| 7376 | PackHandshakeFlight: packed, |
| 7377 | }, |
| 7378 | }, |
| 7379 | shouldFail: true, |
| 7380 | expectedError: ":UNEXPECTED_RECORD:", |
| 7381 | }) |
| 7382 | testCases = append(testCases, testCase{ |
| 7383 | testType: serverTest, |
| 7384 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 7385 | config: Config{ |
| 7386 | MaxVersion: VersionTLS12, |
| 7387 | }, |
| 7388 | resumeSession: true, |
| 7389 | resumeConfig: &Config{ |
| 7390 | MaxVersion: VersionTLS12, |
| 7391 | Bugs: ProtocolBugs{ |
| 7392 | FragmentAcrossChangeCipherSpec: true, |
| 7393 | PackHandshakeFlight: packed, |
| 7394 | }, |
| 7395 | }, |
| 7396 | shouldFail: true, |
| 7397 | expectedError: ":UNEXPECTED_RECORD:", |
| 7398 | }) |
| 7399 | testCases = append(testCases, testCase{ |
| 7400 | testType: serverTest, |
| 7401 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 7402 | config: Config{ |
| 7403 | MaxVersion: VersionTLS12, |
| 7404 | NextProtos: []string{"bar"}, |
| 7405 | Bugs: ProtocolBugs{ |
| 7406 | FragmentAcrossChangeCipherSpec: true, |
| 7407 | PackHandshakeFlight: packed, |
| 7408 | }, |
| 7409 | }, |
| 7410 | flags: []string{ |
| 7411 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 7412 | }, |
| 7413 | shouldFail: true, |
| 7414 | expectedError: ":UNEXPECTED_RECORD:", |
| 7415 | }) |
| 7416 | } |
| 7417 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 7418 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 7419 | // messages in the handshake queue. Do this by testing the server |
| 7420 | // reading the client Finished, reversing the flight so Finished comes |
| 7421 | // first. |
| 7422 | testCases = append(testCases, testCase{ |
| 7423 | protocol: dtls, |
| 7424 | testType: serverTest, |
| 7425 | name: "SendUnencryptedFinished-DTLS", |
| 7426 | config: Config{ |
| 7427 | MaxVersion: VersionTLS12, |
| 7428 | Bugs: ProtocolBugs{ |
| 7429 | SendUnencryptedFinished: true, |
| 7430 | ReverseHandshakeFragments: true, |
| 7431 | }, |
| 7432 | }, |
| 7433 | shouldFail: true, |
| 7434 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7435 | }) |
| 7436 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7437 | // Test synchronization between encryption changes and the handshake in |
| 7438 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 7439 | testCases = append(testCases, testCase{ |
| 7440 | name: "PartialEncryptedExtensionsWithServerHello", |
| 7441 | config: Config{ |
| 7442 | MaxVersion: VersionTLS13, |
| 7443 | Bugs: ProtocolBugs{ |
| 7444 | PartialEncryptedExtensionsWithServerHello: true, |
| 7445 | }, |
| 7446 | }, |
| 7447 | shouldFail: true, |
| 7448 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7449 | }) |
| 7450 | testCases = append(testCases, testCase{ |
| 7451 | testType: serverTest, |
| 7452 | name: "PartialClientFinishedWithClientHello", |
| 7453 | config: Config{ |
| 7454 | MaxVersion: VersionTLS13, |
| 7455 | Bugs: ProtocolBugs{ |
| 7456 | PartialClientFinishedWithClientHello: true, |
| 7457 | }, |
| 7458 | }, |
| 7459 | shouldFail: true, |
| 7460 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7461 | }) |
| 7462 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7463 | // Test that early ChangeCipherSpecs are handled correctly. |
| 7464 | testCases = append(testCases, testCase{ |
| 7465 | testType: serverTest, |
| 7466 | name: "EarlyChangeCipherSpec-server-1", |
| 7467 | config: Config{ |
| 7468 | MaxVersion: VersionTLS12, |
| 7469 | Bugs: ProtocolBugs{ |
| 7470 | EarlyChangeCipherSpec: 1, |
| 7471 | }, |
| 7472 | }, |
| 7473 | shouldFail: true, |
| 7474 | expectedError: ":UNEXPECTED_RECORD:", |
| 7475 | }) |
| 7476 | testCases = append(testCases, testCase{ |
| 7477 | testType: serverTest, |
| 7478 | name: "EarlyChangeCipherSpec-server-2", |
| 7479 | config: Config{ |
| 7480 | MaxVersion: VersionTLS12, |
| 7481 | Bugs: ProtocolBugs{ |
| 7482 | EarlyChangeCipherSpec: 2, |
| 7483 | }, |
| 7484 | }, |
| 7485 | shouldFail: true, |
| 7486 | expectedError: ":UNEXPECTED_RECORD:", |
| 7487 | }) |
| 7488 | testCases = append(testCases, testCase{ |
| 7489 | protocol: dtls, |
| 7490 | name: "StrayChangeCipherSpec", |
| 7491 | config: Config{ |
| 7492 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 7493 | // that stray ChangeCipherSpec messages are |
| 7494 | // rejected. |
| 7495 | MaxVersion: VersionTLS12, |
| 7496 | Bugs: ProtocolBugs{ |
| 7497 | StrayChangeCipherSpec: true, |
| 7498 | }, |
| 7499 | }, |
| 7500 | }) |
| 7501 | |
| 7502 | // Test that the contents of ChangeCipherSpec are checked. |
| 7503 | testCases = append(testCases, testCase{ |
| 7504 | name: "BadChangeCipherSpec-1", |
| 7505 | config: Config{ |
| 7506 | MaxVersion: VersionTLS12, |
| 7507 | Bugs: ProtocolBugs{ |
| 7508 | BadChangeCipherSpec: []byte{2}, |
| 7509 | }, |
| 7510 | }, |
| 7511 | shouldFail: true, |
| 7512 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7513 | }) |
| 7514 | testCases = append(testCases, testCase{ |
| 7515 | name: "BadChangeCipherSpec-2", |
| 7516 | config: Config{ |
| 7517 | MaxVersion: VersionTLS12, |
| 7518 | Bugs: ProtocolBugs{ |
| 7519 | BadChangeCipherSpec: []byte{1, 1}, |
| 7520 | }, |
| 7521 | }, |
| 7522 | shouldFail: true, |
| 7523 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7524 | }) |
| 7525 | testCases = append(testCases, testCase{ |
| 7526 | protocol: dtls, |
| 7527 | name: "BadChangeCipherSpec-DTLS-1", |
| 7528 | config: Config{ |
| 7529 | MaxVersion: VersionTLS12, |
| 7530 | Bugs: ProtocolBugs{ |
| 7531 | BadChangeCipherSpec: []byte{2}, |
| 7532 | }, |
| 7533 | }, |
| 7534 | shouldFail: true, |
| 7535 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7536 | }) |
| 7537 | testCases = append(testCases, testCase{ |
| 7538 | protocol: dtls, |
| 7539 | name: "BadChangeCipherSpec-DTLS-2", |
| 7540 | config: Config{ |
| 7541 | MaxVersion: VersionTLS12, |
| 7542 | Bugs: ProtocolBugs{ |
| 7543 | BadChangeCipherSpec: []byte{1, 1}, |
| 7544 | }, |
| 7545 | }, |
| 7546 | shouldFail: true, |
| 7547 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7548 | }) |
| 7549 | } |
| 7550 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7551 | type perMessageTest struct { |
| 7552 | messageType uint8 |
| 7553 | test testCase |
| 7554 | } |
| 7555 | |
| 7556 | // makePerMessageTests returns a series of test templates which cover each |
| 7557 | // message in the TLS handshake. These may be used with bugs like |
| 7558 | // WrongMessageType to fully test a per-message bug. |
| 7559 | func makePerMessageTests() []perMessageTest { |
| 7560 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7561 | for _, protocol := range []protocol{tls, dtls} { |
| 7562 | var suffix string |
| 7563 | if protocol == dtls { |
| 7564 | suffix = "-DTLS" |
| 7565 | } |
| 7566 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7567 | ret = append(ret, perMessageTest{ |
| 7568 | messageType: typeClientHello, |
| 7569 | test: testCase{ |
| 7570 | protocol: protocol, |
| 7571 | testType: serverTest, |
| 7572 | name: "ClientHello" + suffix, |
| 7573 | config: Config{ |
| 7574 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7575 | }, |
| 7576 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7577 | }) |
| 7578 | |
| 7579 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7580 | ret = append(ret, perMessageTest{ |
| 7581 | messageType: typeHelloVerifyRequest, |
| 7582 | test: testCase{ |
| 7583 | protocol: protocol, |
| 7584 | name: "HelloVerifyRequest" + suffix, |
| 7585 | config: Config{ |
| 7586 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7587 | }, |
| 7588 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7589 | }) |
| 7590 | } |
| 7591 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7592 | ret = append(ret, perMessageTest{ |
| 7593 | messageType: typeServerHello, |
| 7594 | test: testCase{ |
| 7595 | protocol: protocol, |
| 7596 | name: "ServerHello" + suffix, |
| 7597 | config: Config{ |
| 7598 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7599 | }, |
| 7600 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7601 | }) |
| 7602 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7603 | ret = append(ret, perMessageTest{ |
| 7604 | messageType: typeCertificate, |
| 7605 | test: testCase{ |
| 7606 | protocol: protocol, |
| 7607 | name: "ServerCertificate" + suffix, |
| 7608 | config: Config{ |
| 7609 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7610 | }, |
| 7611 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7612 | }) |
| 7613 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7614 | ret = append(ret, perMessageTest{ |
| 7615 | messageType: typeCertificateStatus, |
| 7616 | test: testCase{ |
| 7617 | protocol: protocol, |
| 7618 | name: "CertificateStatus" + suffix, |
| 7619 | config: Config{ |
| 7620 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7621 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7622 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7623 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7624 | }) |
| 7625 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7626 | ret = append(ret, perMessageTest{ |
| 7627 | messageType: typeServerKeyExchange, |
| 7628 | test: testCase{ |
| 7629 | protocol: protocol, |
| 7630 | name: "ServerKeyExchange" + suffix, |
| 7631 | config: Config{ |
| 7632 | MaxVersion: VersionTLS12, |
| 7633 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7634 | }, |
| 7635 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7636 | }) |
| 7637 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7638 | ret = append(ret, perMessageTest{ |
| 7639 | messageType: typeCertificateRequest, |
| 7640 | test: testCase{ |
| 7641 | protocol: protocol, |
| 7642 | name: "CertificateRequest" + suffix, |
| 7643 | config: Config{ |
| 7644 | MaxVersion: VersionTLS12, |
| 7645 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7646 | }, |
| 7647 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7648 | }) |
| 7649 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7650 | ret = append(ret, perMessageTest{ |
| 7651 | messageType: typeServerHelloDone, |
| 7652 | test: testCase{ |
| 7653 | protocol: protocol, |
| 7654 | name: "ServerHelloDone" + suffix, |
| 7655 | config: Config{ |
| 7656 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7657 | }, |
| 7658 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7659 | }) |
| 7660 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7661 | ret = append(ret, perMessageTest{ |
| 7662 | messageType: typeCertificate, |
| 7663 | test: testCase{ |
| 7664 | testType: serverTest, |
| 7665 | protocol: protocol, |
| 7666 | name: "ClientCertificate" + suffix, |
| 7667 | config: Config{ |
| 7668 | Certificates: []Certificate{rsaCertificate}, |
| 7669 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7670 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7671 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7672 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7673 | }) |
| 7674 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7675 | ret = append(ret, perMessageTest{ |
| 7676 | messageType: typeCertificateVerify, |
| 7677 | test: testCase{ |
| 7678 | testType: serverTest, |
| 7679 | protocol: protocol, |
| 7680 | name: "CertificateVerify" + suffix, |
| 7681 | config: Config{ |
| 7682 | Certificates: []Certificate{rsaCertificate}, |
| 7683 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7684 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7685 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7686 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7687 | }) |
| 7688 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7689 | ret = append(ret, perMessageTest{ |
| 7690 | messageType: typeClientKeyExchange, |
| 7691 | test: testCase{ |
| 7692 | testType: serverTest, |
| 7693 | protocol: protocol, |
| 7694 | name: "ClientKeyExchange" + suffix, |
| 7695 | config: Config{ |
| 7696 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7697 | }, |
| 7698 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7699 | }) |
| 7700 | |
| 7701 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7702 | ret = append(ret, perMessageTest{ |
| 7703 | messageType: typeNextProtocol, |
| 7704 | test: testCase{ |
| 7705 | testType: serverTest, |
| 7706 | protocol: protocol, |
| 7707 | name: "NextProtocol" + suffix, |
| 7708 | config: Config{ |
| 7709 | MaxVersion: VersionTLS12, |
| 7710 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7711 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7712 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7713 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7714 | }) |
| 7715 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7716 | ret = append(ret, perMessageTest{ |
| 7717 | messageType: typeChannelID, |
| 7718 | test: testCase{ |
| 7719 | testType: serverTest, |
| 7720 | protocol: protocol, |
| 7721 | name: "ChannelID" + suffix, |
| 7722 | config: Config{ |
| 7723 | MaxVersion: VersionTLS12, |
| 7724 | ChannelID: channelIDKey, |
| 7725 | }, |
| 7726 | flags: []string{ |
| 7727 | "-expect-channel-id", |
| 7728 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7729 | }, |
| 7730 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7731 | }) |
| 7732 | } |
| 7733 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7734 | ret = append(ret, perMessageTest{ |
| 7735 | messageType: typeFinished, |
| 7736 | test: testCase{ |
| 7737 | testType: serverTest, |
| 7738 | protocol: protocol, |
| 7739 | name: "ClientFinished" + suffix, |
| 7740 | config: Config{ |
| 7741 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7742 | }, |
| 7743 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7744 | }) |
| 7745 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7746 | ret = append(ret, perMessageTest{ |
| 7747 | messageType: typeNewSessionTicket, |
| 7748 | test: testCase{ |
| 7749 | protocol: protocol, |
| 7750 | name: "NewSessionTicket" + suffix, |
| 7751 | config: Config{ |
| 7752 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7753 | }, |
| 7754 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7755 | }) |
| 7756 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7757 | ret = append(ret, perMessageTest{ |
| 7758 | messageType: typeFinished, |
| 7759 | test: testCase{ |
| 7760 | protocol: protocol, |
| 7761 | name: "ServerFinished" + suffix, |
| 7762 | config: Config{ |
| 7763 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7764 | }, |
| 7765 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7766 | }) |
| 7767 | |
| 7768 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7769 | |
| 7770 | ret = append(ret, perMessageTest{ |
| 7771 | messageType: typeClientHello, |
| 7772 | test: testCase{ |
| 7773 | testType: serverTest, |
| 7774 | name: "TLS13-ClientHello", |
| 7775 | config: Config{ |
| 7776 | MaxVersion: VersionTLS13, |
| 7777 | }, |
| 7778 | }, |
| 7779 | }) |
| 7780 | |
| 7781 | ret = append(ret, perMessageTest{ |
| 7782 | messageType: typeServerHello, |
| 7783 | test: testCase{ |
| 7784 | name: "TLS13-ServerHello", |
| 7785 | config: Config{ |
| 7786 | MaxVersion: VersionTLS13, |
| 7787 | }, |
| 7788 | }, |
| 7789 | }) |
| 7790 | |
| 7791 | ret = append(ret, perMessageTest{ |
| 7792 | messageType: typeEncryptedExtensions, |
| 7793 | test: testCase{ |
| 7794 | name: "TLS13-EncryptedExtensions", |
| 7795 | config: Config{ |
| 7796 | MaxVersion: VersionTLS13, |
| 7797 | }, |
| 7798 | }, |
| 7799 | }) |
| 7800 | |
| 7801 | ret = append(ret, perMessageTest{ |
| 7802 | messageType: typeCertificateRequest, |
| 7803 | test: testCase{ |
| 7804 | name: "TLS13-CertificateRequest", |
| 7805 | config: Config{ |
| 7806 | MaxVersion: VersionTLS13, |
| 7807 | ClientAuth: RequireAnyClientCert, |
| 7808 | }, |
| 7809 | }, |
| 7810 | }) |
| 7811 | |
| 7812 | ret = append(ret, perMessageTest{ |
| 7813 | messageType: typeCertificate, |
| 7814 | test: testCase{ |
| 7815 | name: "TLS13-ServerCertificate", |
| 7816 | config: Config{ |
| 7817 | MaxVersion: VersionTLS13, |
| 7818 | }, |
| 7819 | }, |
| 7820 | }) |
| 7821 | |
| 7822 | ret = append(ret, perMessageTest{ |
| 7823 | messageType: typeCertificateVerify, |
| 7824 | test: testCase{ |
| 7825 | name: "TLS13-ServerCertificateVerify", |
| 7826 | config: Config{ |
| 7827 | MaxVersion: VersionTLS13, |
| 7828 | }, |
| 7829 | }, |
| 7830 | }) |
| 7831 | |
| 7832 | ret = append(ret, perMessageTest{ |
| 7833 | messageType: typeFinished, |
| 7834 | test: testCase{ |
| 7835 | name: "TLS13-ServerFinished", |
| 7836 | config: Config{ |
| 7837 | MaxVersion: VersionTLS13, |
| 7838 | }, |
| 7839 | }, |
| 7840 | }) |
| 7841 | |
| 7842 | ret = append(ret, perMessageTest{ |
| 7843 | messageType: typeCertificate, |
| 7844 | test: testCase{ |
| 7845 | testType: serverTest, |
| 7846 | name: "TLS13-ClientCertificate", |
| 7847 | config: Config{ |
| 7848 | Certificates: []Certificate{rsaCertificate}, |
| 7849 | MaxVersion: VersionTLS13, |
| 7850 | }, |
| 7851 | flags: []string{"-require-any-client-certificate"}, |
| 7852 | }, |
| 7853 | }) |
| 7854 | |
| 7855 | ret = append(ret, perMessageTest{ |
| 7856 | messageType: typeCertificateVerify, |
| 7857 | test: testCase{ |
| 7858 | testType: serverTest, |
| 7859 | name: "TLS13-ClientCertificateVerify", |
| 7860 | config: Config{ |
| 7861 | Certificates: []Certificate{rsaCertificate}, |
| 7862 | MaxVersion: VersionTLS13, |
| 7863 | }, |
| 7864 | flags: []string{"-require-any-client-certificate"}, |
| 7865 | }, |
| 7866 | }) |
| 7867 | |
| 7868 | ret = append(ret, perMessageTest{ |
| 7869 | messageType: typeFinished, |
| 7870 | test: testCase{ |
| 7871 | testType: serverTest, |
| 7872 | name: "TLS13-ClientFinished", |
| 7873 | config: Config{ |
| 7874 | MaxVersion: VersionTLS13, |
| 7875 | }, |
| 7876 | }, |
| 7877 | }) |
| 7878 | |
| 7879 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7880 | } |
| 7881 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7882 | func addWrongMessageTypeTests() { |
| 7883 | for _, t := range makePerMessageTests() { |
| 7884 | t.test.name = "WrongMessageType-" + t.test.name |
| 7885 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 7886 | t.test.shouldFail = true |
| 7887 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 7888 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7889 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7890 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 7891 | // In TLS 1.3, a bad ServerHello means the client sends |
| 7892 | // an unencrypted alert while the server expects |
| 7893 | // encryption, so the alert is not readable by runner. |
| 7894 | t.test.expectedLocalError = "local error: bad record MAC" |
| 7895 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7896 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7897 | testCases = append(testCases, t.test) |
| 7898 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7899 | } |
| 7900 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 7901 | func addTrailingMessageDataTests() { |
| 7902 | for _, t := range makePerMessageTests() { |
| 7903 | t.test.name = "TrailingMessageData-" + t.test.name |
| 7904 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 7905 | t.test.shouldFail = true |
| 7906 | t.test.expectedError = ":DECODE_ERROR:" |
| 7907 | t.test.expectedLocalError = "remote error: error decoding message" |
| 7908 | |
| 7909 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 7910 | // In TLS 1.3, a bad ServerHello means the client sends |
| 7911 | // an unencrypted alert while the server expects |
| 7912 | // encryption, so the alert is not readable by runner. |
| 7913 | t.test.expectedLocalError = "local error: bad record MAC" |
| 7914 | } |
| 7915 | |
| 7916 | if t.messageType == typeFinished { |
| 7917 | // Bad Finished messages read as the verify data having |
| 7918 | // the wrong length. |
| 7919 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 7920 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 7921 | } |
| 7922 | |
| 7923 | testCases = append(testCases, t.test) |
| 7924 | } |
| 7925 | } |
| 7926 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7927 | func addTLS13HandshakeTests() { |
| 7928 | testCases = append(testCases, testCase{ |
| 7929 | testType: clientTest, |
| 7930 | name: "MissingKeyShare-Client", |
| 7931 | config: Config{ |
| 7932 | MaxVersion: VersionTLS13, |
| 7933 | Bugs: ProtocolBugs{ |
| 7934 | MissingKeyShare: true, |
| 7935 | }, |
| 7936 | }, |
| 7937 | shouldFail: true, |
| 7938 | expectedError: ":MISSING_KEY_SHARE:", |
| 7939 | }) |
| 7940 | |
| 7941 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7942 | testType: serverTest, |
| 7943 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7944 | config: Config{ |
| 7945 | MaxVersion: VersionTLS13, |
| 7946 | Bugs: ProtocolBugs{ |
| 7947 | MissingKeyShare: true, |
| 7948 | }, |
| 7949 | }, |
| 7950 | shouldFail: true, |
| 7951 | expectedError: ":MISSING_KEY_SHARE:", |
| 7952 | }) |
| 7953 | |
| 7954 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7955 | testType: serverTest, |
| 7956 | name: "DuplicateKeyShares", |
| 7957 | config: Config{ |
| 7958 | MaxVersion: VersionTLS13, |
| 7959 | Bugs: ProtocolBugs{ |
| 7960 | DuplicateKeyShares: true, |
| 7961 | }, |
| 7962 | }, |
| 7963 | }) |
| 7964 | |
| 7965 | testCases = append(testCases, testCase{ |
| 7966 | testType: clientTest, |
| 7967 | name: "EmptyEncryptedExtensions", |
| 7968 | config: Config{ |
| 7969 | MaxVersion: VersionTLS13, |
| 7970 | Bugs: ProtocolBugs{ |
| 7971 | EmptyEncryptedExtensions: true, |
| 7972 | }, |
| 7973 | }, |
| 7974 | shouldFail: true, |
| 7975 | expectedLocalError: "remote error: error decoding message", |
| 7976 | }) |
| 7977 | |
| 7978 | testCases = append(testCases, testCase{ |
| 7979 | testType: clientTest, |
| 7980 | name: "EncryptedExtensionsWithKeyShare", |
| 7981 | config: Config{ |
| 7982 | MaxVersion: VersionTLS13, |
| 7983 | Bugs: ProtocolBugs{ |
| 7984 | EncryptedExtensionsWithKeyShare: true, |
| 7985 | }, |
| 7986 | }, |
| 7987 | shouldFail: true, |
| 7988 | expectedLocalError: "remote error: unsupported extension", |
| 7989 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7990 | |
| 7991 | testCases = append(testCases, testCase{ |
| 7992 | testType: serverTest, |
| 7993 | name: "SendHelloRetryRequest", |
| 7994 | config: Config{ |
| 7995 | MaxVersion: VersionTLS13, |
| 7996 | // Require a HelloRetryRequest for every curve. |
| 7997 | DefaultCurves: []CurveID{}, |
| 7998 | }, |
| 7999 | expectedCurveID: CurveX25519, |
| 8000 | }) |
| 8001 | |
| 8002 | testCases = append(testCases, testCase{ |
| 8003 | testType: serverTest, |
| 8004 | name: "SendHelloRetryRequest-2", |
| 8005 | config: Config{ |
| 8006 | MaxVersion: VersionTLS13, |
| 8007 | DefaultCurves: []CurveID{CurveP384}, |
| 8008 | }, |
| 8009 | // Although the ClientHello did not predict our preferred curve, |
| 8010 | // we always select it whether it is predicted or not. |
| 8011 | expectedCurveID: CurveX25519, |
| 8012 | }) |
| 8013 | |
| 8014 | testCases = append(testCases, testCase{ |
| 8015 | name: "UnknownCurve-HelloRetryRequest", |
| 8016 | config: Config{ |
| 8017 | MaxVersion: VersionTLS13, |
| 8018 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8019 | CurvePreferences: []CurveID{CurveP384}, |
| 8020 | Bugs: ProtocolBugs{ |
| 8021 | SendHelloRetryRequestCurve: bogusCurve, |
| 8022 | }, |
| 8023 | }, |
| 8024 | shouldFail: true, |
| 8025 | expectedError: ":WRONG_CURVE:", |
| 8026 | }) |
| 8027 | |
| 8028 | testCases = append(testCases, testCase{ |
| 8029 | name: "DisabledCurve-HelloRetryRequest", |
| 8030 | config: Config{ |
| 8031 | MaxVersion: VersionTLS13, |
| 8032 | CurvePreferences: []CurveID{CurveP256}, |
| 8033 | Bugs: ProtocolBugs{ |
| 8034 | IgnorePeerCurvePreferences: true, |
| 8035 | }, |
| 8036 | }, |
| 8037 | flags: []string{"-p384-only"}, |
| 8038 | shouldFail: true, |
| 8039 | expectedError: ":WRONG_CURVE:", |
| 8040 | }) |
| 8041 | |
| 8042 | testCases = append(testCases, testCase{ |
| 8043 | name: "UnnecessaryHelloRetryRequest", |
| 8044 | config: Config{ |
| 8045 | MaxVersion: VersionTLS13, |
| 8046 | Bugs: ProtocolBugs{ |
| 8047 | UnnecessaryHelloRetryRequest: true, |
| 8048 | }, |
| 8049 | }, |
| 8050 | shouldFail: true, |
| 8051 | expectedError: ":WRONG_CURVE:", |
| 8052 | }) |
| 8053 | |
| 8054 | testCases = append(testCases, testCase{ |
| 8055 | name: "SecondHelloRetryRequest", |
| 8056 | config: Config{ |
| 8057 | MaxVersion: VersionTLS13, |
| 8058 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8059 | CurvePreferences: []CurveID{CurveP384}, |
| 8060 | Bugs: ProtocolBugs{ |
| 8061 | SecondHelloRetryRequest: true, |
| 8062 | }, |
| 8063 | }, |
| 8064 | shouldFail: true, |
| 8065 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 8066 | }) |
| 8067 | |
| 8068 | testCases = append(testCases, testCase{ |
| 8069 | testType: serverTest, |
| 8070 | name: "SecondClientHelloMissingKeyShare", |
| 8071 | config: Config{ |
| 8072 | MaxVersion: VersionTLS13, |
| 8073 | DefaultCurves: []CurveID{}, |
| 8074 | Bugs: ProtocolBugs{ |
| 8075 | SecondClientHelloMissingKeyShare: true, |
| 8076 | }, |
| 8077 | }, |
| 8078 | shouldFail: true, |
| 8079 | expectedError: ":MISSING_KEY_SHARE:", |
| 8080 | }) |
| 8081 | |
| 8082 | testCases = append(testCases, testCase{ |
| 8083 | testType: serverTest, |
| 8084 | name: "SecondClientHelloWrongCurve", |
| 8085 | config: Config{ |
| 8086 | MaxVersion: VersionTLS13, |
| 8087 | DefaultCurves: []CurveID{}, |
| 8088 | Bugs: ProtocolBugs{ |
| 8089 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 8090 | }, |
| 8091 | }, |
| 8092 | shouldFail: true, |
| 8093 | expectedError: ":WRONG_CURVE:", |
| 8094 | }) |
| 8095 | |
| 8096 | testCases = append(testCases, testCase{ |
| 8097 | name: "HelloRetryRequestVersionMismatch", |
| 8098 | config: Config{ |
| 8099 | MaxVersion: VersionTLS13, |
| 8100 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8101 | CurvePreferences: []CurveID{CurveP384}, |
| 8102 | Bugs: ProtocolBugs{ |
| 8103 | SendServerHelloVersion: 0x0305, |
| 8104 | }, |
| 8105 | }, |
| 8106 | shouldFail: true, |
| 8107 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 8108 | }) |
| 8109 | |
| 8110 | testCases = append(testCases, testCase{ |
| 8111 | name: "HelloRetryRequestCurveMismatch", |
| 8112 | config: Config{ |
| 8113 | MaxVersion: VersionTLS13, |
| 8114 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8115 | CurvePreferences: []CurveID{CurveP384}, |
| 8116 | Bugs: ProtocolBugs{ |
| 8117 | // Send P-384 (correct) in the HelloRetryRequest. |
| 8118 | SendHelloRetryRequestCurve: CurveP384, |
| 8119 | // But send P-256 in the ServerHello. |
| 8120 | SendCurve: CurveP256, |
| 8121 | }, |
| 8122 | }, |
| 8123 | shouldFail: true, |
| 8124 | expectedError: ":WRONG_CURVE:", |
| 8125 | }) |
| 8126 | |
| 8127 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 8128 | // without sending it. |
| 8129 | testCases = append(testCases, testCase{ |
| 8130 | name: "SkipHelloRetryRequest", |
| 8131 | config: Config{ |
| 8132 | MaxVersion: VersionTLS13, |
| 8133 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8134 | CurvePreferences: []CurveID{CurveP384}, |
| 8135 | Bugs: ProtocolBugs{ |
| 8136 | SkipHelloRetryRequest: true, |
| 8137 | }, |
| 8138 | }, |
| 8139 | shouldFail: true, |
| 8140 | expectedError: ":WRONG_CURVE:", |
| 8141 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 8142 | |
| 8143 | testCases = append(testCases, testCase{ |
| 8144 | name: "TLS13-RequestContextInHandshake", |
| 8145 | config: Config{ |
| 8146 | MaxVersion: VersionTLS13, |
| 8147 | MinVersion: VersionTLS13, |
| 8148 | ClientAuth: RequireAnyClientCert, |
| 8149 | Bugs: ProtocolBugs{ |
| 8150 | SendRequestContext: []byte("request context"), |
| 8151 | }, |
| 8152 | }, |
| 8153 | flags: []string{ |
| 8154 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8155 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8156 | }, |
| 8157 | shouldFail: true, |
| 8158 | expectedError: ":DECODE_ERROR:", |
| 8159 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8160 | } |
| 8161 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8162 | 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] | 8163 | defer wg.Done() |
| 8164 | |
| 8165 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8166 | var err error |
| 8167 | |
| 8168 | if *mallocTest < 0 { |
| 8169 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8170 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8171 | } else { |
| 8172 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 8173 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8174 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8175 | if err != nil { |
| 8176 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 8177 | } |
| 8178 | break |
| 8179 | } |
| 8180 | } |
| 8181 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8182 | statusChan <- statusMsg{test: test, err: err} |
| 8183 | } |
| 8184 | } |
| 8185 | |
| 8186 | type statusMsg struct { |
| 8187 | test *testCase |
| 8188 | started bool |
| 8189 | err error |
| 8190 | } |
| 8191 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8192 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8193 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8194 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8195 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8196 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8197 | if !*pipe { |
| 8198 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 8199 | var erase string |
| 8200 | for i := 0; i < lineLen; i++ { |
| 8201 | erase += "\b \b" |
| 8202 | } |
| 8203 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8204 | } |
| 8205 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8206 | if msg.started { |
| 8207 | started++ |
| 8208 | } else { |
| 8209 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8210 | |
| 8211 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8212 | if msg.err == errUnimplemented { |
| 8213 | if *pipe { |
| 8214 | // Print each test instead of a status line. |
| 8215 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 8216 | } |
| 8217 | unimplemented++ |
| 8218 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 8219 | } else { |
| 8220 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 8221 | failed++ |
| 8222 | testOutput.addResult(msg.test.name, "FAIL") |
| 8223 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8224 | } else { |
| 8225 | if *pipe { |
| 8226 | // Print each test instead of a status line. |
| 8227 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 8228 | } |
| 8229 | testOutput.addResult(msg.test.name, "PASS") |
| 8230 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8231 | } |
| 8232 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8233 | if !*pipe { |
| 8234 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8235 | 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] | 8236 | lineLen = len(line) |
| 8237 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8238 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8239 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8240 | |
| 8241 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8242 | } |
| 8243 | |
| 8244 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8245 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8246 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8247 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8248 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8249 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8250 | addCipherSuiteTests() |
| 8251 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8252 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 8253 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 8254 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 8255 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 8256 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 8257 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 8258 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 8259 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 8260 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 8261 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 8262 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8263 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8264 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8265 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8266 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8267 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8268 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8269 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8270 | addCECPQ1Tests() |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8271 | addDHEGroupSizeTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8272 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 8273 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8274 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8275 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8276 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8277 | addTLS13HandshakeTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8278 | |
| 8279 | var wg sync.WaitGroup |
| 8280 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8281 | statusChan := make(chan statusMsg, *numWorkers) |
| 8282 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8283 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8284 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8285 | if len(*shimConfigFile) != 0 { |
| 8286 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 8287 | if err != nil { |
| 8288 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 8289 | os.Exit(1) |
| 8290 | } |
| 8291 | |
| 8292 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 8293 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 8294 | os.Exit(1) |
| 8295 | } |
| 8296 | } |
| 8297 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8298 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8299 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8300 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8301 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8302 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8303 | } |
| 8304 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8305 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8306 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8307 | matched := true |
| 8308 | if len(*testToRun) != 0 { |
| 8309 | var err error |
| 8310 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 8311 | if err != nil { |
| 8312 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 8313 | os.Exit(1) |
| 8314 | } |
| 8315 | } |
| 8316 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8317 | if !*includeDisabled { |
| 8318 | for pattern := range shimConfig.DisabledTests { |
| 8319 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 8320 | if err != nil { |
| 8321 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 8322 | os.Exit(1) |
| 8323 | } |
| 8324 | |
| 8325 | if isDisabled { |
| 8326 | matched = false |
| 8327 | break |
| 8328 | } |
| 8329 | } |
| 8330 | } |
| 8331 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8332 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8333 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8334 | testChan <- &testCases[i] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8335 | } |
| 8336 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8337 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8338 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8339 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8340 | os.Exit(1) |
| 8341 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8342 | |
| 8343 | close(testChan) |
| 8344 | wg.Wait() |
| 8345 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8346 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8347 | |
| 8348 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8349 | |
| 8350 | if *jsonOutput != "" { |
| 8351 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 8352 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 8353 | } |
| 8354 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 8355 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8356 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 8357 | os.Exit(1) |
| 8358 | } |
| 8359 | |
| 8360 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 8361 | os.Exit(1) |
| 8362 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8363 | } |