Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2016, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 14 | |
Adam Langley | dc7e9c4 | 2015-09-29 15:21:04 -0700 | [diff] [blame] | 15 | package runner |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 19 | "crypto/ecdsa" |
| 20 | "crypto/elliptic" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 21 | "crypto/x509" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 22 | "encoding/base64" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 23 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 24 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 25 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 26 | "flag" |
| 27 | "fmt" |
| 28 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 29 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 30 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 31 | "net" |
| 32 | "os" |
| 33 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 34 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 35 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 36 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 37 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 38 | "strings" |
| 39 | "sync" |
| 40 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 41 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 42 | ) |
| 43 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 44 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 45 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 46 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 47 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 48 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 49 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 50 | mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask bssl_shim to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.") |
| 51 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 52 | pipe = flag.Bool("pipe", false, "If true, print status output suitable for piping into another program.") |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 53 | testToRun = flag.String("test", "", "The pattern to filter tests to run, or empty to run all tests") |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 54 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 55 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 56 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 57 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 58 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 59 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 60 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 61 | allowUnimplemented = flag.Bool("allow-unimplemented", false, "If true, report pass even if some tests are unimplemented.") |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 62 | looseErrors = flag.Bool("loose-errors", false, "If true, allow shims to report an untranslated error code.") |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 63 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 64 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 65 | repeatUntilFailure = flag.Bool("repeat-until-failure", false, "If true, the first selected test will be run repeatedly until failure.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 66 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 67 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 68 | // ShimConfigurations is used with the “json” package and represents a shim |
| 69 | // config file. |
| 70 | type ShimConfiguration struct { |
| 71 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 72 | // The glob pattern is used to exclude tests from being run and the |
| 73 | // freeform string is unparsed but expected to explain why the test is |
| 74 | // disabled. |
| 75 | DisabledTests map[string]string |
| 76 | |
| 77 | // ErrorMap maps from expected error strings to the correct error |
| 78 | // string for the shim in question. For example, it might map |
| 79 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 80 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 81 | ErrorMap map[string]string |
| 82 | } |
| 83 | |
| 84 | var shimConfig ShimConfiguration |
| 85 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 86 | type testCert int |
| 87 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 88 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 89 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 90 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 91 | testCertRSAChain |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 92 | testCertECDSAP256 |
| 93 | testCertECDSAP384 |
| 94 | testCertECDSAP521 |
| 95 | ) |
| 96 | |
| 97 | const ( |
| 98 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 99 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 100 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 101 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 102 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 103 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 104 | ) |
| 105 | |
| 106 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 107 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 108 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 109 | rsaChainKeyFile = "rsa_chain_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 110 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 111 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 112 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 113 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 114 | ) |
| 115 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 116 | var ( |
| 117 | rsaCertificate Certificate |
| 118 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 119 | rsaChainCertificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 120 | ecdsaP256Certificate Certificate |
| 121 | ecdsaP384Certificate Certificate |
| 122 | ecdsaP521Certificate Certificate |
| 123 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 124 | |
| 125 | var testCerts = []struct { |
| 126 | id testCert |
| 127 | certFile, keyFile string |
| 128 | cert *Certificate |
| 129 | }{ |
| 130 | { |
| 131 | id: testCertRSA, |
| 132 | certFile: rsaCertificateFile, |
| 133 | keyFile: rsaKeyFile, |
| 134 | cert: &rsaCertificate, |
| 135 | }, |
| 136 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 137 | id: testCertRSA1024, |
| 138 | certFile: rsa1024CertificateFile, |
| 139 | keyFile: rsa1024KeyFile, |
| 140 | cert: &rsa1024Certificate, |
| 141 | }, |
| 142 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 143 | id: testCertRSAChain, |
| 144 | certFile: rsaChainCertificateFile, |
| 145 | keyFile: rsaChainKeyFile, |
| 146 | cert: &rsaChainCertificate, |
| 147 | }, |
| 148 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 149 | id: testCertECDSAP256, |
| 150 | certFile: ecdsaP256CertificateFile, |
| 151 | keyFile: ecdsaP256KeyFile, |
| 152 | cert: &ecdsaP256Certificate, |
| 153 | }, |
| 154 | { |
| 155 | id: testCertECDSAP384, |
| 156 | certFile: ecdsaP384CertificateFile, |
| 157 | keyFile: ecdsaP384KeyFile, |
| 158 | cert: &ecdsaP384Certificate, |
| 159 | }, |
| 160 | { |
| 161 | id: testCertECDSAP521, |
| 162 | certFile: ecdsaP521CertificateFile, |
| 163 | keyFile: ecdsaP521KeyFile, |
| 164 | cert: &ecdsaP521Certificate, |
| 165 | }, |
| 166 | } |
| 167 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 168 | var channelIDKey *ecdsa.PrivateKey |
| 169 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 170 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 171 | var testOCSPResponse = []byte{1, 2, 3, 4} |
| 172 | var testSCTList = []byte{5, 6, 7, 8} |
| 173 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 174 | var testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) |
| 175 | var testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, 4}, testSCTList...) |
| 176 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 177 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 178 | for i := range testCerts { |
| 179 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 180 | if err != nil { |
| 181 | panic(err) |
| 182 | } |
| 183 | cert.OCSPStaple = testOCSPResponse |
| 184 | cert.SignedCertificateTimestampList = testSCTList |
| 185 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 186 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 187 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 188 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 189 | if err != nil { |
| 190 | panic(err) |
| 191 | } |
| 192 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 193 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 194 | panic("bad key type") |
| 195 | } |
| 196 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 197 | if err != nil { |
| 198 | panic(err) |
| 199 | } |
| 200 | if channelIDKey.Curve != elliptic.P256() { |
| 201 | panic("bad curve") |
| 202 | } |
| 203 | |
| 204 | channelIDBytes = make([]byte, 64) |
| 205 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 206 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | } |
| 208 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 209 | func getRunnerCertificate(t testCert) Certificate { |
| 210 | for _, cert := range testCerts { |
| 211 | if cert.id == t { |
| 212 | return *cert.cert |
| 213 | } |
| 214 | } |
| 215 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | } |
| 217 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 218 | func getShimCertificate(t testCert) string { |
| 219 | for _, cert := range testCerts { |
| 220 | if cert.id == t { |
| 221 | return cert.certFile |
| 222 | } |
| 223 | } |
| 224 | panic("Unknown test certificate") |
| 225 | } |
| 226 | |
| 227 | func getShimKey(t testCert) string { |
| 228 | for _, cert := range testCerts { |
| 229 | if cert.id == t { |
| 230 | return cert.keyFile |
| 231 | } |
| 232 | } |
| 233 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 234 | } |
| 235 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 236 | type testType int |
| 237 | |
| 238 | const ( |
| 239 | clientTest testType = iota |
| 240 | serverTest |
| 241 | ) |
| 242 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 243 | type protocol int |
| 244 | |
| 245 | const ( |
| 246 | tls protocol = iota |
| 247 | dtls |
| 248 | ) |
| 249 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 250 | const ( |
| 251 | alpn = 1 |
| 252 | npn = 2 |
| 253 | ) |
| 254 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 255 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 256 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 257 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 258 | name string |
| 259 | config Config |
| 260 | shouldFail bool |
| 261 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 262 | // expectedLocalError, if not empty, contains a substring that must be |
| 263 | // found in the local error. |
| 264 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 265 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 266 | // negotiated. |
| 267 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 268 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 269 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 270 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 271 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 272 | // should be negotiated. |
| 273 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 274 | // expectChannelID controls whether the connection should have |
| 275 | // negotiated a Channel ID with channelIDKey. |
| 276 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 277 | // expectedNextProto controls whether the connection should |
| 278 | // negotiate a next protocol via NPN or ALPN. |
| 279 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 280 | // expectNoNextProto, if true, means that no next protocol should be |
| 281 | // negotiated. |
| 282 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 283 | // expectedNextProtoType, if non-zero, is the expected next |
| 284 | // protocol negotiation mechanism. |
| 285 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 286 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 287 | // should be negotiated. If zero, none should be negotiated. |
| 288 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 289 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 290 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 291 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 292 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 293 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 294 | // algorithm that the peer should have used in the handshake. |
| 295 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 296 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 297 | // have used. |
| 298 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 299 | // messageLen is the length, in bytes, of the test message that will be |
| 300 | // sent. |
| 301 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 302 | // messageCount is the number of test messages that will be sent. |
| 303 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 304 | // certFile is the path to the certificate to use for the server. |
| 305 | certFile string |
| 306 | // keyFile is the path to the private key to use for the server. |
| 307 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 308 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 309 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 310 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 311 | // resumeRenewedSession controls whether a third connection should be |
| 312 | // tested which attempts to resume the second connection's session. |
| 313 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 314 | // expectResumeRejected, if true, specifies that the attempted |
| 315 | // resumption must be rejected by the client. This is only valid for a |
| 316 | // serverTest. |
| 317 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 318 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 319 | // resumption. Unless newSessionsOnResume is set, |
| 320 | // SessionTicketKey, ServerSessionCache, and |
| 321 | // ClientSessionCache are copied from the initial connection's |
| 322 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 323 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 324 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 325 | // use a different session resumption context. |
| 326 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 327 | // noSessionCache, if true, will cause the server to run without a |
| 328 | // session cache. |
| 329 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 330 | // sendPrefix sends a prefix on the socket before actually performing a |
| 331 | // handshake. |
| 332 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 333 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 334 | // message before doing a roundtrip with the runner. |
| 335 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 336 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 337 | // connection immediately after the handshake rather than echoing |
| 338 | // messages from the runner. |
| 339 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 340 | // renegotiate indicates the number of times the connection should be |
| 341 | // renegotiated during the exchange. |
| 342 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 343 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 344 | // HelloRequest when the handshake completes. |
| 345 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 346 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 347 | // switched in just before renegotiation. |
| 348 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 349 | // replayWrites, if true, configures the underlying transport |
| 350 | // to replay every write it makes in DTLS tests. |
| 351 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 352 | // damageFirstWrite, if true, configures the underlying transport to |
| 353 | // damage the final byte of the first application data write. |
| 354 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 355 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 356 | // keying material and verify they match. |
| 357 | exportKeyingMaterial int |
| 358 | exportLabel string |
| 359 | exportContext string |
| 360 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 361 | // flags, if not empty, contains a list of command-line flags that will |
| 362 | // be passed to the shim program. |
| 363 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 364 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 365 | // which will be compared against the expected value. |
| 366 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 367 | // sendEmptyRecords is the number of consecutive empty records to send |
| 368 | // before and after the test message. |
| 369 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 370 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 371 | // before and after the test message. |
| 372 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 373 | // sendKeyUpdates is the number of consecutive key updates to send |
| 374 | // before and after the test message. |
| 375 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 376 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 377 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 378 | // expectMessageDropped, if true, means the test message is expected to |
| 379 | // be dropped by the client rather than echoed back. |
| 380 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 381 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 382 | // is expected to send. |
| 383 | expectPeerCertificate *Certificate |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 386 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 387 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 388 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 389 | if len(data) == 0 { |
| 390 | return |
| 391 | } |
| 392 | |
| 393 | protocol := "tls" |
| 394 | if test.protocol == dtls { |
| 395 | protocol = "dtls" |
| 396 | } |
| 397 | |
| 398 | side := "client" |
| 399 | if test.testType == serverTest { |
| 400 | side = "server" |
| 401 | } |
| 402 | |
| 403 | dir := path.Join(*transcriptDir, protocol, side) |
| 404 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 405 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 406 | return |
| 407 | } |
| 408 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 409 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 410 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 411 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 412 | } |
| 413 | } |
| 414 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 415 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 416 | type timeoutConn struct { |
| 417 | net.Conn |
| 418 | timeout time.Duration |
| 419 | } |
| 420 | |
| 421 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 422 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 423 | return 0, err |
| 424 | } |
| 425 | return t.Conn.Read(b) |
| 426 | } |
| 427 | |
| 428 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 429 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 430 | return 0, err |
| 431 | } |
| 432 | return t.Conn.Write(b) |
| 433 | } |
| 434 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 435 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 436 | if !test.noSessionCache { |
| 437 | if config.ClientSessionCache == nil { |
| 438 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 439 | } |
| 440 | if config.ServerSessionCache == nil { |
| 441 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 442 | } |
| 443 | } |
| 444 | if test.testType == clientTest { |
| 445 | if len(config.Certificates) == 0 { |
| 446 | config.Certificates = []Certificate{rsaCertificate} |
| 447 | } |
| 448 | } else { |
| 449 | // Supply a ServerName to ensure a constant session cache key, |
| 450 | // rather than falling back to net.Conn.RemoteAddr. |
| 451 | if len(config.ServerName) == 0 { |
| 452 | config.ServerName = "test" |
| 453 | } |
| 454 | } |
| 455 | if *fuzzer { |
| 456 | config.Bugs.NullAllCiphers = true |
| 457 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 458 | if *deterministic { |
| 459 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 460 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 461 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 462 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 463 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 464 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 465 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 466 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 467 | } |
| 468 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 469 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 470 | local, peer := "client", "server" |
| 471 | if test.testType == clientTest { |
| 472 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 473 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 474 | connDebug := &recordingConn{ |
| 475 | Conn: conn, |
| 476 | isDatagram: test.protocol == dtls, |
| 477 | local: local, |
| 478 | peer: peer, |
| 479 | } |
| 480 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | if *flagDebug { |
| 482 | defer connDebug.WriteTo(os.Stdout) |
| 483 | } |
| 484 | if len(*transcriptDir) != 0 { |
| 485 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 486 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 487 | }() |
| 488 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 489 | |
| 490 | if config.Bugs.PacketAdaptor != nil { |
| 491 | config.Bugs.PacketAdaptor.debug = connDebug |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | if test.replayWrites { |
| 496 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 497 | } |
| 498 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 499 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 500 | if test.damageFirstWrite { |
| 501 | connDamage = newDamageAdaptor(conn) |
| 502 | conn = connDamage |
| 503 | } |
| 504 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 505 | if test.sendPrefix != "" { |
| 506 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 507 | return err |
| 508 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 509 | } |
| 510 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 511 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 512 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 513 | if test.protocol == dtls { |
| 514 | tlsConn = DTLSServer(conn, config) |
| 515 | } else { |
| 516 | tlsConn = Server(conn, config) |
| 517 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 518 | } else { |
| 519 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 520 | if test.protocol == dtls { |
| 521 | tlsConn = DTLSClient(conn, config) |
| 522 | } else { |
| 523 | tlsConn = Client(conn, config) |
| 524 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 525 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 526 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 527 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 528 | if err := tlsConn.Handshake(); err != nil { |
| 529 | return err |
| 530 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 531 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 532 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 533 | // expectations struct that can be specified separately for the two |
| 534 | // legs. |
| 535 | expectedVersion := test.expectedVersion |
| 536 | if isResume && test.expectedResumeVersion != 0 { |
| 537 | expectedVersion = test.expectedResumeVersion |
| 538 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 539 | connState := tlsConn.ConnectionState() |
| 540 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 541 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 542 | } |
| 543 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 544 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 545 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 546 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 547 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 548 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 549 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 550 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 551 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 552 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 553 | if channelID == nil { |
| 554 | return fmt.Errorf("no channel ID negotiated") |
| 555 | } |
| 556 | if channelID.Curve != channelIDKey.Curve || |
| 557 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 558 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 559 | return fmt.Errorf("incorrect channel ID") |
| 560 | } |
| 561 | } |
| 562 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 563 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 564 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 565 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 566 | } |
| 567 | } |
| 568 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 569 | if test.expectNoNextProto { |
| 570 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 571 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 572 | } |
| 573 | } |
| 574 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 575 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 576 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 577 | return fmt.Errorf("next proto type mismatch") |
| 578 | } |
| 579 | } |
| 580 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 581 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 582 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 583 | } |
| 584 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 585 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 586 | return fmt.Errorf("OCSP Response mismatch: got %x, wanted %x", tlsConn.OCSPResponse(), test.expectedOCSPResponse) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 587 | } |
| 588 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 589 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 590 | return fmt.Errorf("SCT list mismatch") |
| 591 | } |
| 592 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 593 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 594 | return fmt.Errorf("expected peer to use signature algorithm %04x, but got %04x", expected, connState.PeerSignatureAlgorithm) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 595 | } |
| 596 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 597 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 598 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 599 | } |
| 600 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 601 | if test.expectPeerCertificate != nil { |
| 602 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 603 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 604 | } |
| 605 | for i, cert := range connState.PeerCertificates { |
| 606 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 607 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 612 | if test.exportKeyingMaterial > 0 { |
| 613 | actual := make([]byte, test.exportKeyingMaterial) |
| 614 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 615 | return err |
| 616 | } |
| 617 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 618 | if err != nil { |
| 619 | return err |
| 620 | } |
| 621 | if !bytes.Equal(actual, expected) { |
| 622 | return fmt.Errorf("keying material mismatch") |
| 623 | } |
| 624 | } |
| 625 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 626 | if test.testTLSUnique { |
| 627 | var peersValue [12]byte |
| 628 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 629 | return err |
| 630 | } |
| 631 | expected := tlsConn.ConnectionState().TLSUnique |
| 632 | if !bytes.Equal(peersValue[:], expected) { |
| 633 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 634 | } |
| 635 | } |
| 636 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 637 | if test.shimWritesFirst { |
| 638 | var buf [5]byte |
| 639 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 640 | if err != nil { |
| 641 | return err |
| 642 | } |
| 643 | if string(buf[:]) != "hello" { |
| 644 | return fmt.Errorf("bad initial message") |
| 645 | } |
| 646 | } |
| 647 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 648 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 649 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 650 | return err |
| 651 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 652 | } |
| 653 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 654 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 655 | tlsConn.Write(nil) |
| 656 | } |
| 657 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 658 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 659 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 660 | } |
| 661 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 662 | if test.sendHalfHelloRequest { |
| 663 | tlsConn.SendHalfHelloRequest() |
| 664 | } |
| 665 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 666 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 667 | if test.renegotiateCiphers != nil { |
| 668 | config.CipherSuites = test.renegotiateCiphers |
| 669 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 670 | for i := 0; i < test.renegotiate; i++ { |
| 671 | if err := tlsConn.Renegotiate(); err != nil { |
| 672 | return err |
| 673 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 674 | } |
| 675 | } else if test.renegotiateCiphers != nil { |
| 676 | panic("renegotiateCiphers without renegotiate") |
| 677 | } |
| 678 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 679 | if test.damageFirstWrite { |
| 680 | connDamage.setDamage(true) |
| 681 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 682 | connDamage.setDamage(false) |
| 683 | } |
| 684 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 685 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 686 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 687 | if test.protocol == dtls { |
| 688 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 689 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 690 | // Read until EOF. |
| 691 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 692 | return err |
| 693 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 694 | if messageLen == 0 { |
| 695 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 696 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 697 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 698 | messageCount := test.messageCount |
| 699 | if messageCount == 0 { |
| 700 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 701 | } |
| 702 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 703 | for j := 0; j < messageCount; j++ { |
| 704 | testMessage := make([]byte, messageLen) |
| 705 | for i := range testMessage { |
| 706 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 707 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 708 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 709 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 710 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 711 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 712 | } |
| 713 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 714 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 715 | tlsConn.Write(nil) |
| 716 | } |
| 717 | |
| 718 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 719 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 720 | } |
| 721 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 722 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 723 | // The shim will not respond. |
| 724 | continue |
| 725 | } |
| 726 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 727 | buf := make([]byte, len(testMessage)) |
| 728 | if test.protocol == dtls { |
| 729 | bufTmp := make([]byte, len(buf)+1) |
| 730 | n, err := tlsConn.Read(bufTmp) |
| 731 | if err != nil { |
| 732 | return err |
| 733 | } |
| 734 | if n != len(buf) { |
| 735 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 736 | } |
| 737 | copy(buf, bufTmp) |
| 738 | } else { |
| 739 | _, err := io.ReadFull(tlsConn, buf) |
| 740 | if err != nil { |
| 741 | return err |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | for i, v := range buf { |
| 746 | if v != testMessage[i]^0xff { |
| 747 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 748 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 749 | } |
| 750 | } |
| 751 | |
| 752 | return nil |
| 753 | } |
| 754 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 755 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 756 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 757 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 758 | valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 759 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 760 | valgrindArgs = append(valgrindArgs, path) |
| 761 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 762 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 763 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 764 | } |
| 765 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 766 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 767 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 768 | xtermArgs = append(xtermArgs, path) |
| 769 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 770 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 771 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 772 | } |
| 773 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 774 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 775 | xtermArgs := []string{"-e", "lldb", "--"} |
| 776 | xtermArgs = append(xtermArgs, path) |
| 777 | xtermArgs = append(xtermArgs, args...) |
| 778 | |
| 779 | return exec.Command("xterm", xtermArgs...) |
| 780 | } |
| 781 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 782 | var ( |
| 783 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 784 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 785 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 786 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 787 | // accept accepts a connection from listener, unless waitChan signals a process |
| 788 | // exit first. |
| 789 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 790 | type connOrError struct { |
| 791 | conn net.Conn |
| 792 | err error |
| 793 | } |
| 794 | connChan := make(chan connOrError, 1) |
| 795 | go func() { |
| 796 | conn, err := listener.Accept() |
| 797 | connChan <- connOrError{conn, err} |
| 798 | close(connChan) |
| 799 | }() |
| 800 | select { |
| 801 | case result := <-connChan: |
| 802 | return result.conn, result.err |
| 803 | case childErr := <-waitChan: |
| 804 | waitChan <- childErr |
| 805 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 806 | } |
| 807 | } |
| 808 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 809 | func translateExpectedError(errorStr string) string { |
| 810 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 811 | return translated |
| 812 | } |
| 813 | |
| 814 | if *looseErrors { |
| 815 | return "" |
| 816 | } |
| 817 | |
| 818 | return errorStr |
| 819 | } |
| 820 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 821 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 822 | // Help debugging panics on the Go side. |
| 823 | defer func() { |
| 824 | if r := recover(); r != nil { |
| 825 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 826 | panic(r) |
| 827 | } |
| 828 | }() |
| 829 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 830 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 831 | panic("Error expected without shouldFail in " + test.name) |
| 832 | } |
| 833 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 834 | if test.expectResumeRejected && !test.resumeSession { |
| 835 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 836 | } |
| 837 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 838 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 839 | if err != nil { |
| 840 | panic(err) |
| 841 | } |
| 842 | defer func() { |
| 843 | if listener != nil { |
| 844 | listener.Close() |
| 845 | } |
| 846 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 847 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 848 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 849 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 850 | flags = append(flags, "-server") |
| 851 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 852 | flags = append(flags, "-key-file") |
| 853 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 854 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 855 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 856 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | flags = append(flags, "-cert-file") |
| 860 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 861 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 862 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 863 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 864 | } |
| 865 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 866 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 867 | if test.protocol == dtls { |
| 868 | flags = append(flags, "-dtls") |
| 869 | } |
| 870 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 871 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 872 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 873 | resumeCount++ |
| 874 | if test.resumeRenewedSession { |
| 875 | resumeCount++ |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | if resumeCount > 0 { |
| 880 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 881 | } |
| 882 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 883 | if test.shimWritesFirst { |
| 884 | flags = append(flags, "-shim-writes-first") |
| 885 | } |
| 886 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 887 | if test.shimShutsDown { |
| 888 | flags = append(flags, "-shim-shuts-down") |
| 889 | } |
| 890 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 891 | if test.exportKeyingMaterial > 0 { |
| 892 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 893 | flags = append(flags, "-export-label", test.exportLabel) |
| 894 | flags = append(flags, "-export-context", test.exportContext) |
| 895 | if test.useExportContext { |
| 896 | flags = append(flags, "-use-export-context") |
| 897 | } |
| 898 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 899 | if test.expectResumeRejected { |
| 900 | flags = append(flags, "-expect-session-miss") |
| 901 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 902 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 903 | if test.testTLSUnique { |
| 904 | flags = append(flags, "-tls-unique") |
| 905 | } |
| 906 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 907 | flags = append(flags, test.flags...) |
| 908 | |
| 909 | var shim *exec.Cmd |
| 910 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 911 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 912 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 913 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 914 | } else if *useLLDB { |
| 915 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 916 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 917 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 918 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 919 | shim.Stdin = os.Stdin |
| 920 | var stdoutBuf, stderrBuf bytes.Buffer |
| 921 | shim.Stdout = &stdoutBuf |
| 922 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 923 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 924 | shim.Env = os.Environ() |
| 925 | 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] | 926 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 927 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 928 | } |
| 929 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 930 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 931 | |
| 932 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 933 | panic(err) |
| 934 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 935 | waitChan := make(chan error, 1) |
| 936 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 937 | |
| 938 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 939 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 940 | if *deterministic { |
| 941 | config.Rand = &deterministicRand{} |
| 942 | } |
| 943 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 944 | conn, err := acceptOrWait(listener, waitChan) |
| 945 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 946 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 947 | conn.Close() |
| 948 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 949 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 950 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 951 | var resumeConfig Config |
| 952 | if test.resumeConfig != nil { |
| 953 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 954 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 955 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 956 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 957 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 958 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 959 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 960 | } else { |
| 961 | resumeConfig = config |
| 962 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 963 | var connResume net.Conn |
| 964 | connResume, err = acceptOrWait(listener, waitChan) |
| 965 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 966 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 967 | connResume.Close() |
| 968 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 969 | } |
| 970 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 971 | // Close the listener now. This is to avoid hangs should the shim try to |
| 972 | // open more connections than expected. |
| 973 | listener.Close() |
| 974 | listener = nil |
| 975 | |
| 976 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 977 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 978 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 979 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 980 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 981 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 982 | case 89: |
| 983 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 984 | case 99: |
| 985 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 986 | } |
| 987 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 988 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 989 | // Account for Windows line endings. |
| 990 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 991 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 992 | |
| 993 | // Separate the errors from the shim and those from tools like |
| 994 | // AddressSanitizer. |
| 995 | var extraStderr string |
| 996 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 997 | stderr = stderrParts[0] |
| 998 | extraStderr = stderrParts[1] |
| 999 | } |
| 1000 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1001 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1002 | expectedError := translateExpectedError(test.expectedError) |
| 1003 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1004 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1005 | localError := "none" |
| 1006 | if err != nil { |
| 1007 | localError = err.Error() |
| 1008 | } |
| 1009 | if len(test.expectedLocalError) != 0 { |
| 1010 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1011 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1012 | |
| 1013 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1014 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1015 | if childErr != nil { |
| 1016 | childError = childErr.Error() |
| 1017 | } |
| 1018 | |
| 1019 | var msg string |
| 1020 | switch { |
| 1021 | case failed && !test.shouldFail: |
| 1022 | msg = "unexpected failure" |
| 1023 | case !failed && test.shouldFail: |
| 1024 | msg = "unexpected success" |
| 1025 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1026 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1027 | default: |
| 1028 | panic("internal error") |
| 1029 | } |
| 1030 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1031 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s\n%s", msg, localError, childError, stdout, stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1034 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1035 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1038 | if *useValgrind && isValgrindError { |
| 1039 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1040 | } |
| 1041 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1042 | return nil |
| 1043 | } |
| 1044 | |
| 1045 | var tlsVersions = []struct { |
| 1046 | name string |
| 1047 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1048 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1049 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1050 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1051 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1052 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1053 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1054 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1055 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | var testCipherSuites = []struct { |
| 1059 | name string |
| 1060 | id uint16 |
| 1061 | }{ |
| 1062 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1063 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1064 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1065 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1066 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1067 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1068 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1069 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1070 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1071 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1072 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1073 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1074 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1075 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1076 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1077 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1078 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1079 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1080 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1081 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1082 | {"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] | 1083 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1084 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1085 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1086 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1087 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1088 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1089 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1090 | {"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] | 1091 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1092 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1093 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1094 | {"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] | 1095 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1096 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1097 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1098 | {"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] | 1099 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1100 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1101 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1102 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1103 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1104 | } |
| 1105 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1106 | func hasComponent(suiteName, component string) bool { |
| 1107 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1108 | } |
| 1109 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1110 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1111 | return hasComponent(suiteName, "GCM") || |
| 1112 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1113 | hasComponent(suiteName, "SHA384") || |
| 1114 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1115 | } |
| 1116 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1117 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1118 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1121 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1122 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1123 | } |
| 1124 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1125 | func bigFromHex(hex string) *big.Int { |
| 1126 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1127 | if !ok { |
| 1128 | panic("failed to parse hex number 0x" + hex) |
| 1129 | } |
| 1130 | return ret |
| 1131 | } |
| 1132 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1133 | func addBasicTests() { |
| 1134 | basicTests := []testCase{ |
| 1135 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1136 | name: "NoFallbackSCSV", |
| 1137 | config: Config{ |
| 1138 | Bugs: ProtocolBugs{ |
| 1139 | FailIfNotFallbackSCSV: true, |
| 1140 | }, |
| 1141 | }, |
| 1142 | shouldFail: true, |
| 1143 | expectedLocalError: "no fallback SCSV found", |
| 1144 | }, |
| 1145 | { |
| 1146 | name: "SendFallbackSCSV", |
| 1147 | config: Config{ |
| 1148 | Bugs: ProtocolBugs{ |
| 1149 | FailIfNotFallbackSCSV: true, |
| 1150 | }, |
| 1151 | }, |
| 1152 | flags: []string{"-fallback-scsv"}, |
| 1153 | }, |
| 1154 | { |
| 1155 | name: "ClientCertificateTypes", |
| 1156 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1157 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1158 | ClientAuth: RequestClientCert, |
| 1159 | ClientCertificateTypes: []byte{ |
| 1160 | CertTypeDSSSign, |
| 1161 | CertTypeRSASign, |
| 1162 | CertTypeECDSASign, |
| 1163 | }, |
| 1164 | }, |
| 1165 | flags: []string{ |
| 1166 | "-expect-certificate-types", |
| 1167 | base64.StdEncoding.EncodeToString([]byte{ |
| 1168 | CertTypeDSSSign, |
| 1169 | CertTypeRSASign, |
| 1170 | CertTypeECDSASign, |
| 1171 | }), |
| 1172 | }, |
| 1173 | }, |
| 1174 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1175 | name: "UnauthenticatedECDH", |
| 1176 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1177 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1178 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1179 | Bugs: ProtocolBugs{ |
| 1180 | UnauthenticatedECDH: true, |
| 1181 | }, |
| 1182 | }, |
| 1183 | shouldFail: true, |
| 1184 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1185 | }, |
| 1186 | { |
| 1187 | name: "SkipCertificateStatus", |
| 1188 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1189 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1190 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1191 | Bugs: ProtocolBugs{ |
| 1192 | SkipCertificateStatus: true, |
| 1193 | }, |
| 1194 | }, |
| 1195 | flags: []string{ |
| 1196 | "-enable-ocsp-stapling", |
| 1197 | }, |
| 1198 | }, |
| 1199 | { |
| 1200 | name: "SkipServerKeyExchange", |
| 1201 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1202 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1203 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1204 | Bugs: ProtocolBugs{ |
| 1205 | SkipServerKeyExchange: true, |
| 1206 | }, |
| 1207 | }, |
| 1208 | shouldFail: true, |
| 1209 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1210 | }, |
| 1211 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1212 | testType: serverTest, |
| 1213 | name: "Alert", |
| 1214 | config: Config{ |
| 1215 | Bugs: ProtocolBugs{ |
| 1216 | SendSpuriousAlert: alertRecordOverflow, |
| 1217 | }, |
| 1218 | }, |
| 1219 | shouldFail: true, |
| 1220 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1221 | }, |
| 1222 | { |
| 1223 | protocol: dtls, |
| 1224 | testType: serverTest, |
| 1225 | name: "Alert-DTLS", |
| 1226 | config: Config{ |
| 1227 | Bugs: ProtocolBugs{ |
| 1228 | SendSpuriousAlert: alertRecordOverflow, |
| 1229 | }, |
| 1230 | }, |
| 1231 | shouldFail: true, |
| 1232 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1233 | }, |
| 1234 | { |
| 1235 | testType: serverTest, |
| 1236 | name: "FragmentAlert", |
| 1237 | config: Config{ |
| 1238 | Bugs: ProtocolBugs{ |
| 1239 | FragmentAlert: true, |
| 1240 | SendSpuriousAlert: alertRecordOverflow, |
| 1241 | }, |
| 1242 | }, |
| 1243 | shouldFail: true, |
| 1244 | expectedError: ":BAD_ALERT:", |
| 1245 | }, |
| 1246 | { |
| 1247 | protocol: dtls, |
| 1248 | testType: serverTest, |
| 1249 | name: "FragmentAlert-DTLS", |
| 1250 | config: Config{ |
| 1251 | Bugs: ProtocolBugs{ |
| 1252 | FragmentAlert: true, |
| 1253 | SendSpuriousAlert: alertRecordOverflow, |
| 1254 | }, |
| 1255 | }, |
| 1256 | shouldFail: true, |
| 1257 | expectedError: ":BAD_ALERT:", |
| 1258 | }, |
| 1259 | { |
| 1260 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1261 | name: "DoubleAlert", |
| 1262 | config: Config{ |
| 1263 | Bugs: ProtocolBugs{ |
| 1264 | DoubleAlert: true, |
| 1265 | SendSpuriousAlert: alertRecordOverflow, |
| 1266 | }, |
| 1267 | }, |
| 1268 | shouldFail: true, |
| 1269 | expectedError: ":BAD_ALERT:", |
| 1270 | }, |
| 1271 | { |
| 1272 | protocol: dtls, |
| 1273 | testType: serverTest, |
| 1274 | name: "DoubleAlert-DTLS", |
| 1275 | config: Config{ |
| 1276 | Bugs: ProtocolBugs{ |
| 1277 | DoubleAlert: true, |
| 1278 | SendSpuriousAlert: alertRecordOverflow, |
| 1279 | }, |
| 1280 | }, |
| 1281 | shouldFail: true, |
| 1282 | expectedError: ":BAD_ALERT:", |
| 1283 | }, |
| 1284 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1285 | name: "SkipNewSessionTicket", |
| 1286 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1287 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1288 | Bugs: ProtocolBugs{ |
| 1289 | SkipNewSessionTicket: true, |
| 1290 | }, |
| 1291 | }, |
| 1292 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1293 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1294 | }, |
| 1295 | { |
| 1296 | testType: serverTest, |
| 1297 | name: "FallbackSCSV", |
| 1298 | config: Config{ |
| 1299 | MaxVersion: VersionTLS11, |
| 1300 | Bugs: ProtocolBugs{ |
| 1301 | SendFallbackSCSV: true, |
| 1302 | }, |
| 1303 | }, |
| 1304 | shouldFail: true, |
| 1305 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1306 | }, |
| 1307 | { |
| 1308 | testType: serverTest, |
| 1309 | name: "FallbackSCSV-VersionMatch", |
| 1310 | config: Config{ |
| 1311 | Bugs: ProtocolBugs{ |
| 1312 | SendFallbackSCSV: true, |
| 1313 | }, |
| 1314 | }, |
| 1315 | }, |
| 1316 | { |
| 1317 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1318 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1319 | config: Config{ |
| 1320 | MaxVersion: VersionTLS12, |
| 1321 | Bugs: ProtocolBugs{ |
| 1322 | SendFallbackSCSV: true, |
| 1323 | }, |
| 1324 | }, |
| 1325 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1326 | }, |
| 1327 | { |
| 1328 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1329 | name: "FragmentedClientVersion", |
| 1330 | config: Config{ |
| 1331 | Bugs: ProtocolBugs{ |
| 1332 | MaxHandshakeRecordLength: 1, |
| 1333 | FragmentClientVersion: true, |
| 1334 | }, |
| 1335 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1336 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1337 | }, |
| 1338 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1339 | testType: serverTest, |
| 1340 | name: "HttpGET", |
| 1341 | sendPrefix: "GET / HTTP/1.0\n", |
| 1342 | shouldFail: true, |
| 1343 | expectedError: ":HTTP_REQUEST:", |
| 1344 | }, |
| 1345 | { |
| 1346 | testType: serverTest, |
| 1347 | name: "HttpPOST", |
| 1348 | sendPrefix: "POST / HTTP/1.0\n", |
| 1349 | shouldFail: true, |
| 1350 | expectedError: ":HTTP_REQUEST:", |
| 1351 | }, |
| 1352 | { |
| 1353 | testType: serverTest, |
| 1354 | name: "HttpHEAD", |
| 1355 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1356 | shouldFail: true, |
| 1357 | expectedError: ":HTTP_REQUEST:", |
| 1358 | }, |
| 1359 | { |
| 1360 | testType: serverTest, |
| 1361 | name: "HttpPUT", |
| 1362 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1363 | shouldFail: true, |
| 1364 | expectedError: ":HTTP_REQUEST:", |
| 1365 | }, |
| 1366 | { |
| 1367 | testType: serverTest, |
| 1368 | name: "HttpCONNECT", |
| 1369 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1370 | shouldFail: true, |
| 1371 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1372 | }, |
| 1373 | { |
| 1374 | testType: serverTest, |
| 1375 | name: "Garbage", |
| 1376 | sendPrefix: "blah", |
| 1377 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1378 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1379 | }, |
| 1380 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1381 | name: "RSAEphemeralKey", |
| 1382 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1383 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1384 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1385 | Bugs: ProtocolBugs{ |
| 1386 | RSAEphemeralKey: true, |
| 1387 | }, |
| 1388 | }, |
| 1389 | shouldFail: true, |
| 1390 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1391 | }, |
| 1392 | { |
| 1393 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1394 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1395 | shouldFail: true, |
| 1396 | expectedError: ":WRONG_SSL_VERSION:", |
| 1397 | }, |
| 1398 | { |
| 1399 | protocol: dtls, |
| 1400 | name: "DisableEverything-DTLS", |
| 1401 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1402 | shouldFail: true, |
| 1403 | expectedError: ":WRONG_SSL_VERSION:", |
| 1404 | }, |
| 1405 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1406 | protocol: dtls, |
| 1407 | testType: serverTest, |
| 1408 | name: "MTU", |
| 1409 | config: Config{ |
| 1410 | Bugs: ProtocolBugs{ |
| 1411 | MaxPacketLength: 256, |
| 1412 | }, |
| 1413 | }, |
| 1414 | flags: []string{"-mtu", "256"}, |
| 1415 | }, |
| 1416 | { |
| 1417 | protocol: dtls, |
| 1418 | testType: serverTest, |
| 1419 | name: "MTUExceeded", |
| 1420 | config: Config{ |
| 1421 | Bugs: ProtocolBugs{ |
| 1422 | MaxPacketLength: 255, |
| 1423 | }, |
| 1424 | }, |
| 1425 | flags: []string{"-mtu", "256"}, |
| 1426 | shouldFail: true, |
| 1427 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1428 | }, |
| 1429 | { |
| 1430 | name: "CertMismatchRSA", |
| 1431 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1432 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1433 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1434 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1435 | Bugs: ProtocolBugs{ |
| 1436 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1437 | }, |
| 1438 | }, |
| 1439 | shouldFail: true, |
| 1440 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1441 | }, |
| 1442 | { |
| 1443 | name: "CertMismatchECDSA", |
| 1444 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1445 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1446 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1447 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1448 | Bugs: ProtocolBugs{ |
| 1449 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1450 | }, |
| 1451 | }, |
| 1452 | shouldFail: true, |
| 1453 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1454 | }, |
| 1455 | { |
| 1456 | name: "EmptyCertificateList", |
| 1457 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1458 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1459 | Bugs: ProtocolBugs{ |
| 1460 | EmptyCertificateList: true, |
| 1461 | }, |
| 1462 | }, |
| 1463 | shouldFail: true, |
| 1464 | expectedError: ":DECODE_ERROR:", |
| 1465 | }, |
| 1466 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1467 | name: "EmptyCertificateList-TLS13", |
| 1468 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1469 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 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 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1713 | name: "FailCertCallback-Client-TLS12", |
| 1714 | config: Config{ |
| 1715 | MaxVersion: VersionTLS12, |
| 1716 | ClientAuth: RequestClientCert, |
| 1717 | }, |
| 1718 | flags: []string{"-fail-cert-callback"}, |
| 1719 | shouldFail: true, |
| 1720 | expectedError: ":CERT_CB_ERROR:", |
| 1721 | expectedLocalError: "remote error: internal error", |
| 1722 | }, |
| 1723 | { |
| 1724 | testType: serverTest, |
| 1725 | name: "FailCertCallback-Server-TLS12", |
| 1726 | config: Config{ |
| 1727 | MaxVersion: VersionTLS12, |
| 1728 | }, |
| 1729 | flags: []string{"-fail-cert-callback"}, |
| 1730 | shouldFail: true, |
| 1731 | expectedError: ":CERT_CB_ERROR:", |
| 1732 | expectedLocalError: "remote error: internal error", |
| 1733 | }, |
| 1734 | { |
| 1735 | name: "FailCertCallback-Client-TLS13", |
| 1736 | config: Config{ |
| 1737 | MaxVersion: VersionTLS13, |
| 1738 | ClientAuth: RequestClientCert, |
| 1739 | }, |
| 1740 | flags: []string{"-fail-cert-callback"}, |
| 1741 | shouldFail: true, |
| 1742 | expectedError: ":CERT_CB_ERROR:", |
| 1743 | expectedLocalError: "remote error: internal error", |
| 1744 | }, |
| 1745 | { |
| 1746 | testType: serverTest, |
| 1747 | name: "FailCertCallback-Server-TLS13", |
| 1748 | config: Config{ |
| 1749 | MaxVersion: VersionTLS13, |
| 1750 | }, |
| 1751 | flags: []string{"-fail-cert-callback"}, |
| 1752 | shouldFail: true, |
| 1753 | expectedError: ":CERT_CB_ERROR:", |
| 1754 | expectedLocalError: "remote error: internal error", |
| 1755 | }, |
| 1756 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1757 | protocol: dtls, |
| 1758 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1759 | config: Config{ |
| 1760 | Bugs: ProtocolBugs{ |
| 1761 | MaxHandshakeRecordLength: 2, |
| 1762 | FragmentMessageTypeMismatch: true, |
| 1763 | }, |
| 1764 | }, |
| 1765 | shouldFail: true, |
| 1766 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1767 | }, |
| 1768 | { |
| 1769 | protocol: dtls, |
| 1770 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1771 | config: Config{ |
| 1772 | Bugs: ProtocolBugs{ |
| 1773 | MaxHandshakeRecordLength: 2, |
| 1774 | FragmentMessageLengthMismatch: true, |
| 1775 | }, |
| 1776 | }, |
| 1777 | shouldFail: true, |
| 1778 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1779 | }, |
| 1780 | { |
| 1781 | protocol: dtls, |
| 1782 | name: "SplitFragments-Header-DTLS", |
| 1783 | config: Config{ |
| 1784 | Bugs: ProtocolBugs{ |
| 1785 | SplitFragments: 2, |
| 1786 | }, |
| 1787 | }, |
| 1788 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1789 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1790 | }, |
| 1791 | { |
| 1792 | protocol: dtls, |
| 1793 | name: "SplitFragments-Boundary-DTLS", |
| 1794 | config: Config{ |
| 1795 | Bugs: ProtocolBugs{ |
| 1796 | SplitFragments: dtlsRecordHeaderLen, |
| 1797 | }, |
| 1798 | }, |
| 1799 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1800 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1801 | }, |
| 1802 | { |
| 1803 | protocol: dtls, |
| 1804 | name: "SplitFragments-Body-DTLS", |
| 1805 | config: Config{ |
| 1806 | Bugs: ProtocolBugs{ |
| 1807 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1808 | }, |
| 1809 | }, |
| 1810 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1811 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1812 | }, |
| 1813 | { |
| 1814 | protocol: dtls, |
| 1815 | name: "SendEmptyFragments-DTLS", |
| 1816 | config: Config{ |
| 1817 | Bugs: ProtocolBugs{ |
| 1818 | SendEmptyFragments: true, |
| 1819 | }, |
| 1820 | }, |
| 1821 | }, |
| 1822 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1823 | name: "BadFinished-Client", |
| 1824 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1825 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1826 | Bugs: ProtocolBugs{ |
| 1827 | BadFinished: true, |
| 1828 | }, |
| 1829 | }, |
| 1830 | shouldFail: true, |
| 1831 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1832 | }, |
| 1833 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1834 | name: "BadFinished-Client-TLS13", |
| 1835 | config: Config{ |
| 1836 | MaxVersion: VersionTLS13, |
| 1837 | Bugs: ProtocolBugs{ |
| 1838 | BadFinished: true, |
| 1839 | }, |
| 1840 | }, |
| 1841 | shouldFail: true, |
| 1842 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1843 | }, |
| 1844 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1845 | testType: serverTest, |
| 1846 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1847 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1848 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1849 | Bugs: ProtocolBugs{ |
| 1850 | BadFinished: true, |
| 1851 | }, |
| 1852 | }, |
| 1853 | shouldFail: true, |
| 1854 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1855 | }, |
| 1856 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1857 | testType: serverTest, |
| 1858 | name: "BadFinished-Server-TLS13", |
| 1859 | config: Config{ |
| 1860 | MaxVersion: VersionTLS13, |
| 1861 | Bugs: ProtocolBugs{ |
| 1862 | BadFinished: true, |
| 1863 | }, |
| 1864 | }, |
| 1865 | shouldFail: true, |
| 1866 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1867 | }, |
| 1868 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1869 | name: "FalseStart-BadFinished", |
| 1870 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1871 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1872 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1873 | NextProtos: []string{"foo"}, |
| 1874 | Bugs: ProtocolBugs{ |
| 1875 | BadFinished: true, |
| 1876 | ExpectFalseStart: true, |
| 1877 | }, |
| 1878 | }, |
| 1879 | flags: []string{ |
| 1880 | "-false-start", |
| 1881 | "-handshake-never-done", |
| 1882 | "-advertise-alpn", "\x03foo", |
| 1883 | }, |
| 1884 | shimWritesFirst: true, |
| 1885 | shouldFail: true, |
| 1886 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1887 | }, |
| 1888 | { |
| 1889 | name: "NoFalseStart-NoALPN", |
| 1890 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1891 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1892 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1893 | Bugs: ProtocolBugs{ |
| 1894 | ExpectFalseStart: true, |
| 1895 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1896 | }, |
| 1897 | }, |
| 1898 | flags: []string{ |
| 1899 | "-false-start", |
| 1900 | }, |
| 1901 | shimWritesFirst: true, |
| 1902 | shouldFail: true, |
| 1903 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1904 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1905 | }, |
| 1906 | { |
| 1907 | name: "NoFalseStart-NoAEAD", |
| 1908 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1909 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1910 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1911 | NextProtos: []string{"foo"}, |
| 1912 | Bugs: ProtocolBugs{ |
| 1913 | ExpectFalseStart: true, |
| 1914 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1915 | }, |
| 1916 | }, |
| 1917 | flags: []string{ |
| 1918 | "-false-start", |
| 1919 | "-advertise-alpn", "\x03foo", |
| 1920 | }, |
| 1921 | shimWritesFirst: true, |
| 1922 | shouldFail: true, |
| 1923 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1924 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1925 | }, |
| 1926 | { |
| 1927 | name: "NoFalseStart-RSA", |
| 1928 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1929 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1930 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1931 | NextProtos: []string{"foo"}, |
| 1932 | Bugs: ProtocolBugs{ |
| 1933 | ExpectFalseStart: true, |
| 1934 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1935 | }, |
| 1936 | }, |
| 1937 | flags: []string{ |
| 1938 | "-false-start", |
| 1939 | "-advertise-alpn", "\x03foo", |
| 1940 | }, |
| 1941 | shimWritesFirst: true, |
| 1942 | shouldFail: true, |
| 1943 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1944 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1945 | }, |
| 1946 | { |
| 1947 | name: "NoFalseStart-DHE_RSA", |
| 1948 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1949 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1950 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1951 | NextProtos: []string{"foo"}, |
| 1952 | Bugs: ProtocolBugs{ |
| 1953 | ExpectFalseStart: true, |
| 1954 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1955 | }, |
| 1956 | }, |
| 1957 | flags: []string{ |
| 1958 | "-false-start", |
| 1959 | "-advertise-alpn", "\x03foo", |
| 1960 | }, |
| 1961 | shimWritesFirst: true, |
| 1962 | shouldFail: true, |
| 1963 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1964 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1965 | }, |
| 1966 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1967 | protocol: dtls, |
| 1968 | name: "SendSplitAlert-Sync", |
| 1969 | config: Config{ |
| 1970 | Bugs: ProtocolBugs{ |
| 1971 | SendSplitAlert: true, |
| 1972 | }, |
| 1973 | }, |
| 1974 | }, |
| 1975 | { |
| 1976 | protocol: dtls, |
| 1977 | name: "SendSplitAlert-Async", |
| 1978 | config: Config{ |
| 1979 | Bugs: ProtocolBugs{ |
| 1980 | SendSplitAlert: true, |
| 1981 | }, |
| 1982 | }, |
| 1983 | flags: []string{"-async"}, |
| 1984 | }, |
| 1985 | { |
| 1986 | protocol: dtls, |
| 1987 | name: "PackDTLSHandshake", |
| 1988 | config: Config{ |
| 1989 | Bugs: ProtocolBugs{ |
| 1990 | MaxHandshakeRecordLength: 2, |
| 1991 | PackHandshakeFragments: 20, |
| 1992 | PackHandshakeRecords: 200, |
| 1993 | }, |
| 1994 | }, |
| 1995 | }, |
| 1996 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1997 | name: "SendEmptyRecords-Pass", |
| 1998 | sendEmptyRecords: 32, |
| 1999 | }, |
| 2000 | { |
| 2001 | name: "SendEmptyRecords", |
| 2002 | sendEmptyRecords: 33, |
| 2003 | shouldFail: true, |
| 2004 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2005 | }, |
| 2006 | { |
| 2007 | name: "SendEmptyRecords-Async", |
| 2008 | sendEmptyRecords: 33, |
| 2009 | flags: []string{"-async"}, |
| 2010 | shouldFail: true, |
| 2011 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2012 | }, |
| 2013 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2014 | name: "SendWarningAlerts-Pass", |
| 2015 | config: Config{ |
| 2016 | MaxVersion: VersionTLS12, |
| 2017 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2018 | sendWarningAlerts: 4, |
| 2019 | }, |
| 2020 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2021 | protocol: dtls, |
| 2022 | name: "SendWarningAlerts-DTLS-Pass", |
| 2023 | config: Config{ |
| 2024 | MaxVersion: VersionTLS12, |
| 2025 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2026 | sendWarningAlerts: 4, |
| 2027 | }, |
| 2028 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2029 | name: "SendWarningAlerts-TLS13", |
| 2030 | config: Config{ |
| 2031 | MaxVersion: VersionTLS13, |
| 2032 | }, |
| 2033 | sendWarningAlerts: 4, |
| 2034 | shouldFail: true, |
| 2035 | expectedError: ":BAD_ALERT:", |
| 2036 | expectedLocalError: "remote error: error decoding message", |
| 2037 | }, |
| 2038 | { |
| 2039 | name: "SendWarningAlerts", |
| 2040 | config: Config{ |
| 2041 | MaxVersion: VersionTLS12, |
| 2042 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2043 | sendWarningAlerts: 5, |
| 2044 | shouldFail: true, |
| 2045 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2046 | }, |
| 2047 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2048 | name: "SendWarningAlerts-Async", |
| 2049 | config: Config{ |
| 2050 | MaxVersion: VersionTLS12, |
| 2051 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2052 | sendWarningAlerts: 5, |
| 2053 | flags: []string{"-async"}, |
| 2054 | shouldFail: true, |
| 2055 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2056 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2057 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2058 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2059 | config: Config{ |
| 2060 | MaxVersion: VersionTLS13, |
| 2061 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2062 | sendKeyUpdates: 33, |
| 2063 | keyUpdateRequest: keyUpdateNotRequested, |
| 2064 | shouldFail: true, |
| 2065 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2066 | }, |
| 2067 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2068 | name: "EmptySessionID", |
| 2069 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2070 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2071 | SessionTicketsDisabled: true, |
| 2072 | }, |
| 2073 | noSessionCache: true, |
| 2074 | flags: []string{"-expect-no-session"}, |
| 2075 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2076 | { |
| 2077 | name: "Unclean-Shutdown", |
| 2078 | config: Config{ |
| 2079 | Bugs: ProtocolBugs{ |
| 2080 | NoCloseNotify: true, |
| 2081 | ExpectCloseNotify: true, |
| 2082 | }, |
| 2083 | }, |
| 2084 | shimShutsDown: true, |
| 2085 | flags: []string{"-check-close-notify"}, |
| 2086 | shouldFail: true, |
| 2087 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2088 | }, |
| 2089 | { |
| 2090 | name: "Unclean-Shutdown-Ignored", |
| 2091 | config: Config{ |
| 2092 | Bugs: ProtocolBugs{ |
| 2093 | NoCloseNotify: true, |
| 2094 | }, |
| 2095 | }, |
| 2096 | shimShutsDown: true, |
| 2097 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2098 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2099 | name: "Unclean-Shutdown-Alert", |
| 2100 | config: Config{ |
| 2101 | Bugs: ProtocolBugs{ |
| 2102 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2103 | ExpectCloseNotify: true, |
| 2104 | }, |
| 2105 | }, |
| 2106 | shimShutsDown: true, |
| 2107 | flags: []string{"-check-close-notify"}, |
| 2108 | shouldFail: true, |
| 2109 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2110 | }, |
| 2111 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2112 | name: "LargePlaintext", |
| 2113 | config: Config{ |
| 2114 | Bugs: ProtocolBugs{ |
| 2115 | SendLargeRecords: true, |
| 2116 | }, |
| 2117 | }, |
| 2118 | messageLen: maxPlaintext + 1, |
| 2119 | shouldFail: true, |
| 2120 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2121 | }, |
| 2122 | { |
| 2123 | protocol: dtls, |
| 2124 | name: "LargePlaintext-DTLS", |
| 2125 | config: Config{ |
| 2126 | Bugs: ProtocolBugs{ |
| 2127 | SendLargeRecords: true, |
| 2128 | }, |
| 2129 | }, |
| 2130 | messageLen: maxPlaintext + 1, |
| 2131 | shouldFail: true, |
| 2132 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2133 | }, |
| 2134 | { |
| 2135 | name: "LargeCiphertext", |
| 2136 | config: Config{ |
| 2137 | Bugs: ProtocolBugs{ |
| 2138 | SendLargeRecords: true, |
| 2139 | }, |
| 2140 | }, |
| 2141 | messageLen: maxPlaintext * 2, |
| 2142 | shouldFail: true, |
| 2143 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2144 | }, |
| 2145 | { |
| 2146 | protocol: dtls, |
| 2147 | name: "LargeCiphertext-DTLS", |
| 2148 | config: Config{ |
| 2149 | Bugs: ProtocolBugs{ |
| 2150 | SendLargeRecords: true, |
| 2151 | }, |
| 2152 | }, |
| 2153 | messageLen: maxPlaintext * 2, |
| 2154 | // Unlike the other four cases, DTLS drops records which |
| 2155 | // are invalid before authentication, so the connection |
| 2156 | // does not fail. |
| 2157 | expectMessageDropped: true, |
| 2158 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2159 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2160 | name: "BadHelloRequest-1", |
| 2161 | renegotiate: 1, |
| 2162 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2163 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2164 | Bugs: ProtocolBugs{ |
| 2165 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2166 | }, |
| 2167 | }, |
| 2168 | flags: []string{ |
| 2169 | "-renegotiate-freely", |
| 2170 | "-expect-total-renegotiations", "1", |
| 2171 | }, |
| 2172 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2173 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2174 | }, |
| 2175 | { |
| 2176 | name: "BadHelloRequest-2", |
| 2177 | renegotiate: 1, |
| 2178 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2179 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2180 | Bugs: ProtocolBugs{ |
| 2181 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2182 | }, |
| 2183 | }, |
| 2184 | flags: []string{ |
| 2185 | "-renegotiate-freely", |
| 2186 | "-expect-total-renegotiations", "1", |
| 2187 | }, |
| 2188 | shouldFail: true, |
| 2189 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2190 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2191 | { |
| 2192 | testType: serverTest, |
| 2193 | name: "SupportTicketsWithSessionID", |
| 2194 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2195 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2196 | SessionTicketsDisabled: true, |
| 2197 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2198 | resumeConfig: &Config{ |
| 2199 | MaxVersion: VersionTLS12, |
| 2200 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2201 | resumeSession: true, |
| 2202 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2203 | { |
| 2204 | protocol: dtls, |
| 2205 | name: "DTLS-SendExtraFinished", |
| 2206 | config: Config{ |
| 2207 | Bugs: ProtocolBugs{ |
| 2208 | SendExtraFinished: true, |
| 2209 | }, |
| 2210 | }, |
| 2211 | shouldFail: true, |
| 2212 | expectedError: ":UNEXPECTED_RECORD:", |
| 2213 | }, |
| 2214 | { |
| 2215 | protocol: dtls, |
| 2216 | name: "DTLS-SendExtraFinished-Reordered", |
| 2217 | config: Config{ |
| 2218 | Bugs: ProtocolBugs{ |
| 2219 | MaxHandshakeRecordLength: 2, |
| 2220 | ReorderHandshakeFragments: true, |
| 2221 | SendExtraFinished: true, |
| 2222 | }, |
| 2223 | }, |
| 2224 | shouldFail: true, |
| 2225 | expectedError: ":UNEXPECTED_RECORD:", |
| 2226 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2227 | { |
| 2228 | testType: serverTest, |
| 2229 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2230 | config: Config{ |
| 2231 | // Choose a cipher suite that does not involve |
| 2232 | // elliptic curves, so no extensions are |
| 2233 | // involved. |
| 2234 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2235 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2236 | Bugs: ProtocolBugs{ |
| 2237 | SendV2ClientHello: true, |
| 2238 | }, |
| 2239 | }, |
| 2240 | sendPrefix: string([]byte{ |
| 2241 | byte(recordTypeHandshake), |
| 2242 | 3, 1, // version |
| 2243 | 0, 0, // length |
| 2244 | }), |
| 2245 | // A no-op empty record may not be sent before V2ClientHello. |
| 2246 | shouldFail: true, |
| 2247 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2248 | }, |
| 2249 | { |
| 2250 | testType: serverTest, |
| 2251 | name: "V2ClientHello-WarningAlertPrefix", |
| 2252 | config: Config{ |
| 2253 | // Choose a cipher suite that does not involve |
| 2254 | // elliptic curves, so no extensions are |
| 2255 | // involved. |
| 2256 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2257 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2258 | Bugs: ProtocolBugs{ |
| 2259 | SendV2ClientHello: true, |
| 2260 | }, |
| 2261 | }, |
| 2262 | sendPrefix: string([]byte{ |
| 2263 | byte(recordTypeAlert), |
| 2264 | 3, 1, // version |
| 2265 | 0, 2, // length |
| 2266 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2267 | }), |
| 2268 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2269 | shouldFail: true, |
| 2270 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2271 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2272 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2273 | name: "KeyUpdate", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2274 | config: Config{ |
| 2275 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2276 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2277 | sendKeyUpdates: 1, |
| 2278 | keyUpdateRequest: keyUpdateNotRequested, |
| 2279 | }, |
| 2280 | { |
| 2281 | name: "KeyUpdate-InvalidRequestMode", |
| 2282 | config: Config{ |
| 2283 | MaxVersion: VersionTLS13, |
| 2284 | }, |
| 2285 | sendKeyUpdates: 1, |
| 2286 | keyUpdateRequest: 42, |
| 2287 | shouldFail: true, |
| 2288 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2289 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2290 | { |
| 2291 | name: "SendSNIWarningAlert", |
| 2292 | config: Config{ |
| 2293 | MaxVersion: VersionTLS12, |
| 2294 | Bugs: ProtocolBugs{ |
| 2295 | SendSNIWarningAlert: true, |
| 2296 | }, |
| 2297 | }, |
| 2298 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2299 | { |
| 2300 | testType: serverTest, |
| 2301 | name: "ExtraCompressionMethods-TLS12", |
| 2302 | config: Config{ |
| 2303 | MaxVersion: VersionTLS12, |
| 2304 | Bugs: ProtocolBugs{ |
| 2305 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2306 | }, |
| 2307 | }, |
| 2308 | }, |
| 2309 | { |
| 2310 | testType: serverTest, |
| 2311 | name: "ExtraCompressionMethods-TLS13", |
| 2312 | config: Config{ |
| 2313 | MaxVersion: VersionTLS13, |
| 2314 | Bugs: ProtocolBugs{ |
| 2315 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2316 | }, |
| 2317 | }, |
| 2318 | shouldFail: true, |
| 2319 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2320 | expectedLocalError: "remote error: illegal parameter", |
| 2321 | }, |
| 2322 | { |
| 2323 | testType: serverTest, |
| 2324 | name: "NoNullCompression-TLS12", |
| 2325 | config: Config{ |
| 2326 | MaxVersion: VersionTLS12, |
| 2327 | Bugs: ProtocolBugs{ |
| 2328 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2329 | }, |
| 2330 | }, |
| 2331 | shouldFail: true, |
| 2332 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2333 | expectedLocalError: "remote error: illegal parameter", |
| 2334 | }, |
| 2335 | { |
| 2336 | testType: serverTest, |
| 2337 | name: "NoNullCompression-TLS13", |
| 2338 | config: Config{ |
| 2339 | MaxVersion: VersionTLS13, |
| 2340 | Bugs: ProtocolBugs{ |
| 2341 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2342 | }, |
| 2343 | }, |
| 2344 | shouldFail: true, |
| 2345 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2346 | expectedLocalError: "remote error: illegal parameter", |
| 2347 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2348 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2349 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2350 | config: Config{ |
| 2351 | MaxVersion: VersionTLS12, |
| 2352 | Bugs: ProtocolBugs{ |
| 2353 | ExpectGREASE: true, |
| 2354 | }, |
| 2355 | }, |
| 2356 | flags: []string{"-enable-grease"}, |
| 2357 | }, |
| 2358 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2359 | name: "GREASE-Client-TLS13", |
| 2360 | config: Config{ |
| 2361 | MaxVersion: VersionTLS13, |
| 2362 | Bugs: ProtocolBugs{ |
| 2363 | ExpectGREASE: true, |
| 2364 | }, |
| 2365 | }, |
| 2366 | flags: []string{"-enable-grease"}, |
| 2367 | }, |
| 2368 | { |
| 2369 | testType: serverTest, |
| 2370 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2371 | config: Config{ |
| 2372 | MaxVersion: VersionTLS13, |
| 2373 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2374 | // TLS 1.3 servers are expected to |
| 2375 | // always enable GREASE. TLS 1.3 is new, |
| 2376 | // so there is no existing ecosystem to |
| 2377 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2378 | ExpectGREASE: true, |
| 2379 | }, |
| 2380 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2381 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2382 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2383 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2384 | |
| 2385 | // Test that very large messages can be received. |
| 2386 | cert := rsaCertificate |
| 2387 | for i := 0; i < 50; i++ { |
| 2388 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2389 | } |
| 2390 | testCases = append(testCases, testCase{ |
| 2391 | name: "LargeMessage", |
| 2392 | config: Config{ |
| 2393 | Certificates: []Certificate{cert}, |
| 2394 | }, |
| 2395 | }) |
| 2396 | testCases = append(testCases, testCase{ |
| 2397 | protocol: dtls, |
| 2398 | name: "LargeMessage-DTLS", |
| 2399 | config: Config{ |
| 2400 | Certificates: []Certificate{cert}, |
| 2401 | }, |
| 2402 | }) |
| 2403 | |
| 2404 | // They are rejected if the maximum certificate chain length is capped. |
| 2405 | testCases = append(testCases, testCase{ |
| 2406 | name: "LargeMessage-Reject", |
| 2407 | config: Config{ |
| 2408 | Certificates: []Certificate{cert}, |
| 2409 | }, |
| 2410 | flags: []string{"-max-cert-list", "16384"}, |
| 2411 | shouldFail: true, |
| 2412 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2413 | }) |
| 2414 | testCases = append(testCases, testCase{ |
| 2415 | protocol: dtls, |
| 2416 | name: "LargeMessage-Reject-DTLS", |
| 2417 | config: Config{ |
| 2418 | Certificates: []Certificate{cert}, |
| 2419 | }, |
| 2420 | flags: []string{"-max-cert-list", "16384"}, |
| 2421 | shouldFail: true, |
| 2422 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2423 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2424 | } |
| 2425 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2426 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2427 | const bogusCipher = 0xfe00 |
| 2428 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2429 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2430 | const psk = "12345" |
| 2431 | const pskIdentity = "luggage combo" |
| 2432 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2433 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2434 | var certFile string |
| 2435 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2436 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2437 | cert = ecdsaP256Certificate |
| 2438 | certFile = ecdsaP256CertificateFile |
| 2439 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2440 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2441 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2442 | certFile = rsaCertificateFile |
| 2443 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2444 | } |
| 2445 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2446 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2447 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2448 | flags = append(flags, |
| 2449 | "-psk", psk, |
| 2450 | "-psk-identity", pskIdentity) |
| 2451 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2452 | if hasComponent(suite.name, "NULL") { |
| 2453 | // NULL ciphers must be explicitly enabled. |
| 2454 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2455 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2456 | if hasComponent(suite.name, "CECPQ1") { |
| 2457 | // CECPQ1 ciphers must be explicitly enabled. |
| 2458 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2459 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2460 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2461 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2462 | // for now. |
| 2463 | flags = append(flags, "-cipher", suite.name) |
| 2464 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2465 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2466 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2467 | for _, protocol := range []protocol{tls, dtls} { |
| 2468 | var prefix string |
| 2469 | if protocol == dtls { |
| 2470 | if !ver.hasDTLS { |
| 2471 | continue |
| 2472 | } |
| 2473 | prefix = "D" |
| 2474 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2475 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2476 | var shouldServerFail, shouldClientFail bool |
| 2477 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2478 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2479 | // a BoringSSL server will never select it |
| 2480 | // because the extension is missing. |
| 2481 | shouldServerFail = true |
| 2482 | } |
| 2483 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2484 | shouldClientFail = true |
| 2485 | shouldServerFail = true |
| 2486 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2487 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2488 | shouldClientFail = true |
| 2489 | shouldServerFail = true |
| 2490 | } |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2491 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2492 | shouldClientFail = true |
| 2493 | shouldServerFail = true |
| 2494 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2495 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2496 | shouldClientFail = true |
| 2497 | shouldServerFail = true |
| 2498 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2499 | |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2500 | var sendCipherSuite uint16 |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2501 | var expectedServerError, expectedClientError string |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2502 | serverCipherSuites := []uint16{suite.id} |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2503 | if shouldServerFail { |
| 2504 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2505 | } |
| 2506 | if shouldClientFail { |
| 2507 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2508 | // Configure the server to select ciphers as normal but |
| 2509 | // select an incompatible cipher in ServerHello. |
| 2510 | serverCipherSuites = nil |
| 2511 | sendCipherSuite = suite.id |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2512 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2513 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2514 | testCases = append(testCases, testCase{ |
| 2515 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2516 | protocol: protocol, |
| 2517 | |
| 2518 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2519 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2520 | MinVersion: ver.version, |
| 2521 | MaxVersion: ver.version, |
| 2522 | CipherSuites: []uint16{suite.id}, |
| 2523 | Certificates: []Certificate{cert}, |
| 2524 | PreSharedKey: []byte(psk), |
| 2525 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2526 | Bugs: ProtocolBugs{ |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2527 | AdvertiseAllConfiguredCiphers: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2528 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2529 | }, |
| 2530 | certFile: certFile, |
| 2531 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2532 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2533 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2534 | shouldFail: shouldServerFail, |
| 2535 | expectedError: expectedServerError, |
| 2536 | }) |
| 2537 | |
| 2538 | testCases = append(testCases, testCase{ |
| 2539 | testType: clientTest, |
| 2540 | protocol: protocol, |
| 2541 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2542 | config: Config{ |
| 2543 | MinVersion: ver.version, |
| 2544 | MaxVersion: ver.version, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2545 | CipherSuites: serverCipherSuites, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2546 | Certificates: []Certificate{cert}, |
| 2547 | PreSharedKey: []byte(psk), |
| 2548 | PreSharedKeyIdentity: pskIdentity, |
| 2549 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2550 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2551 | SendCipherSuite: sendCipherSuite, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2552 | }, |
| 2553 | }, |
| 2554 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2555 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2556 | shouldFail: shouldClientFail, |
| 2557 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2558 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2559 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2560 | if !shouldClientFail { |
| 2561 | // Ensure the maximum record size is accepted. |
| 2562 | testCases = append(testCases, testCase{ |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2563 | protocol: protocol, |
| 2564 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2565 | config: Config{ |
| 2566 | MinVersion: ver.version, |
| 2567 | MaxVersion: ver.version, |
| 2568 | CipherSuites: []uint16{suite.id}, |
| 2569 | Certificates: []Certificate{cert}, |
| 2570 | PreSharedKey: []byte(psk), |
| 2571 | PreSharedKeyIdentity: pskIdentity, |
| 2572 | }, |
| 2573 | flags: flags, |
| 2574 | messageLen: maxPlaintext, |
| 2575 | }) |
David Benjamin | 231a475 | 2016-11-10 10:46:00 -0500 | [diff] [blame] | 2576 | |
| 2577 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2578 | // and ignored in DTLS. |
| 2579 | var shouldFail bool |
| 2580 | var expectedError string |
| 2581 | if protocol == tls { |
| 2582 | shouldFail = true |
| 2583 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2584 | } |
| 2585 | |
| 2586 | testCases = append(testCases, testCase{ |
| 2587 | protocol: protocol, |
| 2588 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2589 | config: Config{ |
| 2590 | MinVersion: ver.version, |
| 2591 | MaxVersion: ver.version, |
| 2592 | CipherSuites: []uint16{suite.id}, |
| 2593 | Certificates: []Certificate{cert}, |
| 2594 | PreSharedKey: []byte(psk), |
| 2595 | PreSharedKeyIdentity: pskIdentity, |
| 2596 | }, |
| 2597 | flags: flags, |
| 2598 | damageFirstWrite: true, |
| 2599 | messageLen: maxPlaintext, |
| 2600 | shouldFail: shouldFail, |
| 2601 | expectedError: expectedError, |
| 2602 | }) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2603 | } |
| 2604 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2605 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2606 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2607 | |
| 2608 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2609 | name: "NoSharedCipher", |
| 2610 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2611 | MaxVersion: VersionTLS12, |
| 2612 | CipherSuites: []uint16{}, |
| 2613 | }, |
| 2614 | shouldFail: true, |
| 2615 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2616 | }) |
| 2617 | |
| 2618 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2619 | name: "NoSharedCipher-TLS13", |
| 2620 | config: Config{ |
| 2621 | MaxVersion: VersionTLS13, |
| 2622 | CipherSuites: []uint16{}, |
| 2623 | }, |
| 2624 | shouldFail: true, |
| 2625 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2626 | }) |
| 2627 | |
| 2628 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2629 | name: "UnsupportedCipherSuite", |
| 2630 | config: Config{ |
| 2631 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2632 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2633 | Bugs: ProtocolBugs{ |
| 2634 | IgnorePeerCipherPreferences: true, |
| 2635 | }, |
| 2636 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2637 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2638 | shouldFail: true, |
| 2639 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2640 | }) |
| 2641 | |
| 2642 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2643 | name: "ServerHelloBogusCipher", |
| 2644 | config: Config{ |
| 2645 | MaxVersion: VersionTLS12, |
| 2646 | Bugs: ProtocolBugs{ |
| 2647 | SendCipherSuite: bogusCipher, |
| 2648 | }, |
| 2649 | }, |
| 2650 | shouldFail: true, |
| 2651 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2652 | }) |
| 2653 | testCases = append(testCases, testCase{ |
| 2654 | name: "ServerHelloBogusCipher-TLS13", |
| 2655 | config: Config{ |
| 2656 | MaxVersion: VersionTLS13, |
| 2657 | Bugs: ProtocolBugs{ |
| 2658 | SendCipherSuite: bogusCipher, |
| 2659 | }, |
| 2660 | }, |
| 2661 | shouldFail: true, |
| 2662 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2663 | }) |
| 2664 | |
| 2665 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2666 | name: "WeakDH", |
| 2667 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2668 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2669 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2670 | Bugs: ProtocolBugs{ |
| 2671 | // This is a 1023-bit prime number, generated |
| 2672 | // with: |
| 2673 | // openssl gendh 1023 | openssl asn1parse -i |
| 2674 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2675 | }, |
| 2676 | }, |
| 2677 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2678 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2679 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2680 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2681 | testCases = append(testCases, testCase{ |
| 2682 | name: "SillyDH", |
| 2683 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2684 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2685 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2686 | Bugs: ProtocolBugs{ |
| 2687 | // This is a 4097-bit prime number, generated |
| 2688 | // with: |
| 2689 | // openssl gendh 4097 | openssl asn1parse -i |
| 2690 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2691 | }, |
| 2692 | }, |
| 2693 | shouldFail: true, |
| 2694 | expectedError: ":DH_P_TOO_LONG:", |
| 2695 | }) |
| 2696 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2697 | // This test ensures that Diffie-Hellman public values are padded with |
| 2698 | // zeros so that they're the same length as the prime. This is to avoid |
| 2699 | // hitting a bug in yaSSL. |
| 2700 | testCases = append(testCases, testCase{ |
| 2701 | testType: serverTest, |
| 2702 | name: "DHPublicValuePadded", |
| 2703 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2704 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2705 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2706 | Bugs: ProtocolBugs{ |
| 2707 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2708 | }, |
| 2709 | }, |
| 2710 | flags: []string{"-use-sparse-dh-prime"}, |
| 2711 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2712 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2713 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2714 | testCases = append(testCases, testCase{ |
| 2715 | testType: serverTest, |
| 2716 | name: "UnknownCipher", |
| 2717 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2718 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2719 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2720 | Bugs: ProtocolBugs{ |
| 2721 | AdvertiseAllConfiguredCiphers: true, |
| 2722 | }, |
| 2723 | }, |
| 2724 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2725 | |
| 2726 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2727 | testCases = append(testCases, testCase{ |
| 2728 | testType: serverTest, |
| 2729 | name: "UnknownCipher-TLS13", |
| 2730 | config: Config{ |
| 2731 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2732 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2733 | Bugs: ProtocolBugs{ |
| 2734 | AdvertiseAllConfiguredCiphers: true, |
| 2735 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2736 | }, |
| 2737 | }) |
| 2738 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2739 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2740 | testCases = append(testCases, testCase{ |
| 2741 | name: "EmptyECDHEPSKHint", |
| 2742 | config: Config{ |
| 2743 | MaxVersion: VersionTLS12, |
| 2744 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2745 | PreSharedKey: []byte("secret"), |
| 2746 | }, |
| 2747 | flags: []string{"-psk", "secret"}, |
| 2748 | }) |
| 2749 | |
| 2750 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2751 | // ServerKeyExchange is sent. |
| 2752 | testCases = append(testCases, testCase{ |
| 2753 | name: "ExplicitEmptyPSKHint", |
| 2754 | config: Config{ |
| 2755 | MaxVersion: VersionTLS12, |
| 2756 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2757 | PreSharedKey: []byte("secret"), |
| 2758 | Bugs: ProtocolBugs{ |
| 2759 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2760 | }, |
| 2761 | }, |
| 2762 | flags: []string{"-psk", "secret"}, |
| 2763 | }) |
| 2764 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2765 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2766 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2767 | // cipher lists and then a connection is made for each member of |
| 2768 | // expectations. The cipher suite that the server selects must match |
| 2769 | // the specified one. |
| 2770 | var versionSpecificCiphersTest = []struct { |
| 2771 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2772 | // expectations is a map from TLS version to cipher suite id. |
| 2773 | expectations map[uint16]uint16 |
| 2774 | }{ |
| 2775 | { |
| 2776 | // Test that the null case (where no version-specific ciphers are set) |
| 2777 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2778 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2779 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2780 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2781 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2782 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2783 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2784 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2785 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2786 | }, |
| 2787 | }, |
| 2788 | { |
| 2789 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2790 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2791 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2792 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2793 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2794 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2795 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2796 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2797 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2798 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2799 | }, |
| 2800 | }, |
| 2801 | { |
| 2802 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2803 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2804 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2805 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2806 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2807 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2808 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2809 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2810 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2811 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2812 | }, |
| 2813 | }, |
| 2814 | { |
| 2815 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2816 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2817 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2818 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2819 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2820 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2821 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2822 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2823 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2824 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2825 | }, |
| 2826 | }, |
| 2827 | } |
| 2828 | |
| 2829 | for i, test := range versionSpecificCiphersTest { |
| 2830 | for version, expectedCipherSuite := range test.expectations { |
| 2831 | flags := []string{"-cipher", test.ciphersDefault} |
| 2832 | if len(test.ciphersTLS10) > 0 { |
| 2833 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2834 | } |
| 2835 | if len(test.ciphersTLS11) > 0 { |
| 2836 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2837 | } |
| 2838 | |
| 2839 | testCases = append(testCases, testCase{ |
| 2840 | testType: serverTest, |
| 2841 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2842 | config: Config{ |
| 2843 | MaxVersion: version, |
| 2844 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2845 | 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] | 2846 | }, |
| 2847 | flags: flags, |
| 2848 | expectedCipher: expectedCipherSuite, |
| 2849 | }) |
| 2850 | } |
| 2851 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | func addBadECDSASignatureTests() { |
| 2855 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2856 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2857 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2858 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2859 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2860 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2861 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2862 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2863 | Bugs: ProtocolBugs{ |
| 2864 | BadECDSAR: badR, |
| 2865 | BadECDSAS: badS, |
| 2866 | }, |
| 2867 | }, |
| 2868 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2869 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2870 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2871 | testCases = append(testCases, testCase{ |
| 2872 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2873 | config: Config{ |
| 2874 | MaxVersion: VersionTLS13, |
| 2875 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2876 | Bugs: ProtocolBugs{ |
| 2877 | BadECDSAR: badR, |
| 2878 | BadECDSAS: badS, |
| 2879 | }, |
| 2880 | }, |
| 2881 | shouldFail: true, |
| 2882 | expectedError: ":BAD_SIGNATURE:", |
| 2883 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2884 | } |
| 2885 | } |
| 2886 | } |
| 2887 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2888 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2889 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2890 | name: "MaxCBCPadding", |
| 2891 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2892 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2893 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2894 | Bugs: ProtocolBugs{ |
| 2895 | MaxPadding: true, |
| 2896 | }, |
| 2897 | }, |
| 2898 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2899 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2900 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2901 | name: "BadCBCPadding", |
| 2902 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2903 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2904 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2905 | Bugs: ProtocolBugs{ |
| 2906 | PaddingFirstByteBad: true, |
| 2907 | }, |
| 2908 | }, |
| 2909 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2910 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2911 | }) |
| 2912 | // OpenSSL previously had an issue where the first byte of padding in |
| 2913 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2914 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2915 | name: "BadCBCPadding255", |
| 2916 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2917 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2918 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2919 | Bugs: ProtocolBugs{ |
| 2920 | MaxPadding: true, |
| 2921 | PaddingFirstByteBadIf255: true, |
| 2922 | }, |
| 2923 | }, |
| 2924 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2925 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2926 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2927 | }) |
| 2928 | } |
| 2929 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2930 | func addCBCSplittingTests() { |
| 2931 | testCases = append(testCases, testCase{ |
| 2932 | name: "CBCRecordSplitting", |
| 2933 | config: Config{ |
| 2934 | MaxVersion: VersionTLS10, |
| 2935 | MinVersion: VersionTLS10, |
| 2936 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2937 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2938 | messageLen: -1, // read until EOF |
| 2939 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2940 | flags: []string{ |
| 2941 | "-async", |
| 2942 | "-write-different-record-sizes", |
| 2943 | "-cbc-record-splitting", |
| 2944 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2945 | }) |
| 2946 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2947 | name: "CBCRecordSplittingPartialWrite", |
| 2948 | config: Config{ |
| 2949 | MaxVersion: VersionTLS10, |
| 2950 | MinVersion: VersionTLS10, |
| 2951 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2952 | }, |
| 2953 | messageLen: -1, // read until EOF |
| 2954 | flags: []string{ |
| 2955 | "-async", |
| 2956 | "-write-different-record-sizes", |
| 2957 | "-cbc-record-splitting", |
| 2958 | "-partial-write", |
| 2959 | }, |
| 2960 | }) |
| 2961 | } |
| 2962 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2963 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2964 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2965 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2966 | certPool := x509.NewCertPool() |
| 2967 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2968 | if err != nil { |
| 2969 | panic(err) |
| 2970 | } |
| 2971 | certPool.AddCert(cert) |
| 2972 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2973 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2974 | testCases = append(testCases, testCase{ |
| 2975 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2976 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2977 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2978 | MinVersion: ver.version, |
| 2979 | MaxVersion: ver.version, |
| 2980 | ClientAuth: RequireAnyClientCert, |
| 2981 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2982 | }, |
| 2983 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2984 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2985 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2986 | }, |
| 2987 | }) |
| 2988 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2989 | testType: serverTest, |
| 2990 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2991 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2992 | MinVersion: ver.version, |
| 2993 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2994 | Certificates: []Certificate{rsaCertificate}, |
| 2995 | }, |
| 2996 | flags: []string{"-require-any-client-certificate"}, |
| 2997 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2998 | if ver.version != VersionSSL30 { |
| 2999 | testCases = append(testCases, testCase{ |
| 3000 | testType: serverTest, |
| 3001 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3002 | config: Config{ |
| 3003 | MinVersion: ver.version, |
| 3004 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3005 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3006 | }, |
| 3007 | flags: []string{"-require-any-client-certificate"}, |
| 3008 | }) |
| 3009 | testCases = append(testCases, testCase{ |
| 3010 | testType: clientTest, |
| 3011 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3012 | config: Config{ |
| 3013 | MinVersion: ver.version, |
| 3014 | MaxVersion: ver.version, |
| 3015 | ClientAuth: RequireAnyClientCert, |
| 3016 | ClientCAs: certPool, |
| 3017 | }, |
| 3018 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3019 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3020 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3021 | }, |
| 3022 | }) |
| 3023 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3024 | |
| 3025 | testCases = append(testCases, testCase{ |
| 3026 | name: "NoClientCertificate-" + ver.name, |
| 3027 | config: Config{ |
| 3028 | MinVersion: ver.version, |
| 3029 | MaxVersion: ver.version, |
| 3030 | ClientAuth: RequireAnyClientCert, |
| 3031 | }, |
| 3032 | shouldFail: true, |
| 3033 | expectedLocalError: "client didn't provide a certificate", |
| 3034 | }) |
| 3035 | |
| 3036 | testCases = append(testCases, testCase{ |
| 3037 | // Even if not configured to expect a certificate, OpenSSL will |
| 3038 | // return X509_V_OK as the verify_result. |
| 3039 | testType: serverTest, |
| 3040 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3041 | config: Config{ |
| 3042 | MinVersion: ver.version, |
| 3043 | MaxVersion: ver.version, |
| 3044 | }, |
| 3045 | flags: []string{ |
| 3046 | "-expect-verify-result", |
| 3047 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3048 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3049 | }) |
| 3050 | |
| 3051 | testCases = append(testCases, testCase{ |
| 3052 | // If a client certificate is not provided, OpenSSL will still |
| 3053 | // return X509_V_OK as the verify_result. |
| 3054 | testType: serverTest, |
| 3055 | name: "NoClientCertificate-Server-" + ver.name, |
| 3056 | config: Config{ |
| 3057 | MinVersion: ver.version, |
| 3058 | MaxVersion: ver.version, |
| 3059 | }, |
| 3060 | flags: []string{ |
| 3061 | "-expect-verify-result", |
| 3062 | "-verify-peer", |
| 3063 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3064 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3065 | }) |
| 3066 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3067 | certificateRequired := "remote error: certificate required" |
| 3068 | if ver.version < VersionTLS13 { |
| 3069 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3070 | // was used. |
| 3071 | certificateRequired = "remote error: handshake failure" |
| 3072 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3073 | testCases = append(testCases, testCase{ |
| 3074 | testType: serverTest, |
| 3075 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3076 | config: Config{ |
| 3077 | MinVersion: ver.version, |
| 3078 | MaxVersion: ver.version, |
| 3079 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3080 | flags: []string{"-require-any-client-certificate"}, |
| 3081 | shouldFail: true, |
| 3082 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3083 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3084 | }) |
| 3085 | |
| 3086 | if ver.version != VersionSSL30 { |
| 3087 | testCases = append(testCases, testCase{ |
| 3088 | testType: serverTest, |
| 3089 | name: "SkipClientCertificate-" + ver.name, |
| 3090 | config: Config{ |
| 3091 | MinVersion: ver.version, |
| 3092 | MaxVersion: ver.version, |
| 3093 | Bugs: ProtocolBugs{ |
| 3094 | SkipClientCertificate: true, |
| 3095 | }, |
| 3096 | }, |
| 3097 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3098 | flags: []string{"-verify-peer"}, |
| 3099 | shouldFail: true, |
| 3100 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3101 | }) |
| 3102 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3103 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3104 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3105 | // Client auth is only legal in certificate-based ciphers. |
| 3106 | testCases = append(testCases, testCase{ |
| 3107 | testType: clientTest, |
| 3108 | name: "ClientAuth-PSK", |
| 3109 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3110 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3111 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3112 | PreSharedKey: []byte("secret"), |
| 3113 | ClientAuth: RequireAnyClientCert, |
| 3114 | }, |
| 3115 | flags: []string{ |
| 3116 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3117 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3118 | "-psk", "secret", |
| 3119 | }, |
| 3120 | shouldFail: true, |
| 3121 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3122 | }) |
| 3123 | testCases = append(testCases, testCase{ |
| 3124 | testType: clientTest, |
| 3125 | name: "ClientAuth-ECDHE_PSK", |
| 3126 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3127 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3128 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3129 | PreSharedKey: []byte("secret"), |
| 3130 | ClientAuth: RequireAnyClientCert, |
| 3131 | }, |
| 3132 | flags: []string{ |
| 3133 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3134 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3135 | "-psk", "secret", |
| 3136 | }, |
| 3137 | shouldFail: true, |
| 3138 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3139 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3140 | |
| 3141 | // Regression test for a bug where the client CA list, if explicitly |
| 3142 | // set to NULL, was mis-encoded. |
| 3143 | testCases = append(testCases, testCase{ |
| 3144 | testType: serverTest, |
| 3145 | name: "Null-Client-CA-List", |
| 3146 | config: Config{ |
| 3147 | MaxVersion: VersionTLS12, |
| 3148 | Certificates: []Certificate{rsaCertificate}, |
| 3149 | }, |
| 3150 | flags: []string{ |
| 3151 | "-require-any-client-certificate", |
| 3152 | "-use-null-client-ca-list", |
| 3153 | }, |
| 3154 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3155 | } |
| 3156 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3157 | func addExtendedMasterSecretTests() { |
| 3158 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3159 | |
| 3160 | for _, with := range []bool{false, true} { |
| 3161 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3162 | if with { |
| 3163 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3164 | } |
| 3165 | |
| 3166 | for _, isClient := range []bool{false, true} { |
| 3167 | suffix := "-Server" |
| 3168 | testType := serverTest |
| 3169 | if isClient { |
| 3170 | suffix = "-Client" |
| 3171 | testType = clientTest |
| 3172 | } |
| 3173 | |
| 3174 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3175 | // In TLS 1.3, the extension is irrelevant and |
| 3176 | // always reports as enabled. |
| 3177 | var flags []string |
| 3178 | if with || ver.version >= VersionTLS13 { |
| 3179 | flags = []string{expectEMSFlag} |
| 3180 | } |
| 3181 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3182 | test := testCase{ |
| 3183 | testType: testType, |
| 3184 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3185 | config: Config{ |
| 3186 | MinVersion: ver.version, |
| 3187 | MaxVersion: ver.version, |
| 3188 | Bugs: ProtocolBugs{ |
| 3189 | NoExtendedMasterSecret: !with, |
| 3190 | RequireExtendedMasterSecret: with, |
| 3191 | }, |
| 3192 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3193 | flags: flags, |
| 3194 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3195 | } |
| 3196 | if test.shouldFail { |
| 3197 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3198 | } |
| 3199 | testCases = append(testCases, test) |
| 3200 | } |
| 3201 | } |
| 3202 | } |
| 3203 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3204 | for _, isClient := range []bool{false, true} { |
| 3205 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3206 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3207 | boolToWord := func(b bool) string { |
| 3208 | if b { |
| 3209 | return "Yes" |
| 3210 | } |
| 3211 | return "No" |
| 3212 | } |
| 3213 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3214 | if isClient { |
| 3215 | suffix += "Client" |
| 3216 | } else { |
| 3217 | suffix += "Server" |
| 3218 | } |
| 3219 | |
| 3220 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3221 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3222 | Bugs: ProtocolBugs{ |
| 3223 | RequireExtendedMasterSecret: true, |
| 3224 | }, |
| 3225 | } |
| 3226 | |
| 3227 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3228 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3229 | Bugs: ProtocolBugs{ |
| 3230 | NoExtendedMasterSecret: true, |
| 3231 | }, |
| 3232 | } |
| 3233 | |
| 3234 | test := testCase{ |
| 3235 | name: "ExtendedMasterSecret-" + suffix, |
| 3236 | resumeSession: true, |
| 3237 | } |
| 3238 | |
| 3239 | if !isClient { |
| 3240 | test.testType = serverTest |
| 3241 | } |
| 3242 | |
| 3243 | if supportedInFirstConnection { |
| 3244 | test.config = supportedConfig |
| 3245 | } else { |
| 3246 | test.config = noSupportConfig |
| 3247 | } |
| 3248 | |
| 3249 | if supportedInResumeConnection { |
| 3250 | test.resumeConfig = &supportedConfig |
| 3251 | } else { |
| 3252 | test.resumeConfig = &noSupportConfig |
| 3253 | } |
| 3254 | |
| 3255 | switch suffix { |
| 3256 | case "YesToYes-Client", "YesToYes-Server": |
| 3257 | // When a session is resumed, it should |
| 3258 | // still be aware that its master |
| 3259 | // secret was generated via EMS and |
| 3260 | // thus it's safe to use tls-unique. |
| 3261 | test.flags = []string{expectEMSFlag} |
| 3262 | case "NoToYes-Server": |
| 3263 | // If an original connection did not |
| 3264 | // contain EMS, but a resumption |
| 3265 | // handshake does, then a server should |
| 3266 | // not resume the session. |
| 3267 | test.expectResumeRejected = true |
| 3268 | case "YesToNo-Server": |
| 3269 | // Resuming an EMS session without the |
| 3270 | // EMS extension should cause the |
| 3271 | // server to abort the connection. |
| 3272 | test.shouldFail = true |
| 3273 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3274 | case "NoToYes-Client": |
| 3275 | // A client should abort a connection |
| 3276 | // where the server resumed a non-EMS |
| 3277 | // session but echoed the EMS |
| 3278 | // extension. |
| 3279 | test.shouldFail = true |
| 3280 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3281 | case "YesToNo-Client": |
| 3282 | // A client should abort a connection |
| 3283 | // where the server didn't echo EMS |
| 3284 | // when the session used it. |
| 3285 | test.shouldFail = true |
| 3286 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3287 | } |
| 3288 | |
| 3289 | testCases = append(testCases, test) |
| 3290 | } |
| 3291 | } |
| 3292 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3293 | |
| 3294 | // Switching EMS on renegotiation is forbidden. |
| 3295 | testCases = append(testCases, testCase{ |
| 3296 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3297 | config: Config{ |
| 3298 | MaxVersion: VersionTLS12, |
| 3299 | Bugs: ProtocolBugs{ |
| 3300 | NoExtendedMasterSecret: true, |
| 3301 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3302 | }, |
| 3303 | }, |
| 3304 | renegotiate: 1, |
| 3305 | flags: []string{ |
| 3306 | "-renegotiate-freely", |
| 3307 | "-expect-total-renegotiations", "1", |
| 3308 | }, |
| 3309 | }) |
| 3310 | |
| 3311 | testCases = append(testCases, testCase{ |
| 3312 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3313 | config: Config{ |
| 3314 | MaxVersion: VersionTLS12, |
| 3315 | Bugs: ProtocolBugs{ |
| 3316 | NoExtendedMasterSecret: true, |
| 3317 | }, |
| 3318 | }, |
| 3319 | renegotiate: 1, |
| 3320 | flags: []string{ |
| 3321 | "-renegotiate-freely", |
| 3322 | "-expect-total-renegotiations", "1", |
| 3323 | }, |
| 3324 | shouldFail: true, |
| 3325 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3326 | }) |
| 3327 | |
| 3328 | testCases = append(testCases, testCase{ |
| 3329 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3330 | config: Config{ |
| 3331 | MaxVersion: VersionTLS12, |
| 3332 | Bugs: ProtocolBugs{ |
| 3333 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3334 | }, |
| 3335 | }, |
| 3336 | renegotiate: 1, |
| 3337 | flags: []string{ |
| 3338 | "-renegotiate-freely", |
| 3339 | "-expect-total-renegotiations", "1", |
| 3340 | }, |
| 3341 | shouldFail: true, |
| 3342 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3343 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3344 | } |
| 3345 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3346 | type stateMachineTestConfig struct { |
| 3347 | protocol protocol |
| 3348 | async bool |
| 3349 | splitHandshake, packHandshakeFlight bool |
| 3350 | } |
| 3351 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3352 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3353 | // various conditions. Some of these are redundant with other tests, but they |
| 3354 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3355 | func addAllStateMachineCoverageTests() { |
| 3356 | for _, async := range []bool{false, true} { |
| 3357 | for _, protocol := range []protocol{tls, dtls} { |
| 3358 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3359 | protocol: protocol, |
| 3360 | async: async, |
| 3361 | }) |
| 3362 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3363 | protocol: protocol, |
| 3364 | async: async, |
| 3365 | splitHandshake: true, |
| 3366 | }) |
| 3367 | if protocol == tls { |
| 3368 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3369 | protocol: protocol, |
| 3370 | async: async, |
| 3371 | packHandshakeFlight: true, |
| 3372 | }) |
| 3373 | } |
| 3374 | } |
| 3375 | } |
| 3376 | } |
| 3377 | |
| 3378 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3379 | var tests []testCase |
| 3380 | |
| 3381 | // Basic handshake, with resumption. Client and server, |
| 3382 | // session ID and session ticket. |
| 3383 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3384 | name: "Basic-Client", |
| 3385 | config: Config{ |
| 3386 | MaxVersion: VersionTLS12, |
| 3387 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3388 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3389 | // Ensure session tickets are used, not session IDs. |
| 3390 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3391 | }) |
| 3392 | tests = append(tests, testCase{ |
| 3393 | name: "Basic-Client-RenewTicket", |
| 3394 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3395 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3396 | Bugs: ProtocolBugs{ |
| 3397 | RenewTicketOnResume: true, |
| 3398 | }, |
| 3399 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3400 | flags: []string{"-expect-ticket-renewal"}, |
| 3401 | resumeSession: true, |
| 3402 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3403 | }) |
| 3404 | tests = append(tests, testCase{ |
| 3405 | name: "Basic-Client-NoTicket", |
| 3406 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3407 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3408 | SessionTicketsDisabled: true, |
| 3409 | }, |
| 3410 | resumeSession: true, |
| 3411 | }) |
| 3412 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3413 | name: "Basic-Client-Implicit", |
| 3414 | config: Config{ |
| 3415 | MaxVersion: VersionTLS12, |
| 3416 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3417 | flags: []string{"-implicit-handshake"}, |
| 3418 | resumeSession: true, |
| 3419 | }) |
| 3420 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3421 | testType: serverTest, |
| 3422 | name: "Basic-Server", |
| 3423 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3424 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3425 | Bugs: ProtocolBugs{ |
| 3426 | RequireSessionTickets: true, |
| 3427 | }, |
| 3428 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3429 | resumeSession: true, |
| 3430 | }) |
| 3431 | tests = append(tests, testCase{ |
| 3432 | testType: serverTest, |
| 3433 | name: "Basic-Server-NoTickets", |
| 3434 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3435 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3436 | SessionTicketsDisabled: true, |
| 3437 | }, |
| 3438 | resumeSession: true, |
| 3439 | }) |
| 3440 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3441 | testType: serverTest, |
| 3442 | name: "Basic-Server-Implicit", |
| 3443 | config: Config{ |
| 3444 | MaxVersion: VersionTLS12, |
| 3445 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3446 | flags: []string{"-implicit-handshake"}, |
| 3447 | resumeSession: true, |
| 3448 | }) |
| 3449 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3450 | testType: serverTest, |
| 3451 | name: "Basic-Server-EarlyCallback", |
| 3452 | config: Config{ |
| 3453 | MaxVersion: VersionTLS12, |
| 3454 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3455 | flags: []string{"-use-early-callback"}, |
| 3456 | resumeSession: true, |
| 3457 | }) |
| 3458 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3459 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3460 | if config.protocol == tls { |
| 3461 | tests = append(tests, testCase{ |
| 3462 | name: "TLS13-1RTT-Client", |
| 3463 | config: Config{ |
| 3464 | MaxVersion: VersionTLS13, |
| 3465 | MinVersion: VersionTLS13, |
| 3466 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3467 | resumeSession: true, |
| 3468 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3469 | }) |
| 3470 | |
| 3471 | tests = append(tests, testCase{ |
| 3472 | testType: serverTest, |
| 3473 | name: "TLS13-1RTT-Server", |
| 3474 | config: Config{ |
| 3475 | MaxVersion: VersionTLS13, |
| 3476 | MinVersion: VersionTLS13, |
| 3477 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3478 | resumeSession: true, |
| 3479 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3480 | }) |
| 3481 | |
| 3482 | tests = append(tests, testCase{ |
| 3483 | name: "TLS13-HelloRetryRequest-Client", |
| 3484 | config: Config{ |
| 3485 | MaxVersion: VersionTLS13, |
| 3486 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3487 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3488 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3489 | CurvePreferences: []CurveID{CurveP384}, |
| 3490 | Bugs: ProtocolBugs{ |
| 3491 | ExpectMissingKeyShare: true, |
| 3492 | }, |
| 3493 | }, |
| 3494 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3495 | resumeSession: true, |
| 3496 | }) |
| 3497 | |
| 3498 | tests = append(tests, testCase{ |
| 3499 | testType: serverTest, |
| 3500 | name: "TLS13-HelloRetryRequest-Server", |
| 3501 | config: Config{ |
| 3502 | MaxVersion: VersionTLS13, |
| 3503 | MinVersion: VersionTLS13, |
| 3504 | // Require a HelloRetryRequest for every curve. |
| 3505 | DefaultCurves: []CurveID{}, |
| 3506 | }, |
| 3507 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3508 | resumeSession: true, |
| 3509 | }) |
| 3510 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3511 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3512 | // TLS client auth. |
| 3513 | tests = append(tests, testCase{ |
| 3514 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3515 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3516 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3517 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3518 | ClientAuth: RequestClientCert, |
| 3519 | }, |
| 3520 | }) |
| 3521 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3522 | testType: serverTest, |
| 3523 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3524 | config: Config{ |
| 3525 | MaxVersion: VersionTLS12, |
| 3526 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3527 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3528 | flags: []string{"-verify-peer"}, |
| 3529 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3530 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3531 | tests = append(tests, testCase{ |
| 3532 | testType: clientTest, |
| 3533 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3534 | config: Config{ |
| 3535 | MaxVersion: VersionSSL30, |
| 3536 | ClientAuth: RequestClientCert, |
| 3537 | }, |
| 3538 | }) |
| 3539 | tests = append(tests, testCase{ |
| 3540 | testType: serverTest, |
| 3541 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3542 | config: Config{ |
| 3543 | MaxVersion: VersionSSL30, |
| 3544 | }, |
| 3545 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3546 | flags: []string{"-verify-peer"}, |
| 3547 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3548 | tests = append(tests, testCase{ |
| 3549 | testType: clientTest, |
| 3550 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3551 | config: Config{ |
| 3552 | MaxVersion: VersionTLS13, |
| 3553 | ClientAuth: RequestClientCert, |
| 3554 | }, |
| 3555 | }) |
| 3556 | tests = append(tests, testCase{ |
| 3557 | testType: serverTest, |
| 3558 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3559 | config: Config{ |
| 3560 | MaxVersion: VersionTLS13, |
| 3561 | }, |
| 3562 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3563 | flags: []string{"-verify-peer"}, |
| 3564 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3565 | } |
| 3566 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3567 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3568 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3569 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3570 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3571 | ClientAuth: RequireAnyClientCert, |
| 3572 | }, |
| 3573 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3574 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3575 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3576 | }, |
| 3577 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3578 | tests = append(tests, testCase{ |
| 3579 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3580 | name: "ClientAuth-RSA-Client-TLS13", |
| 3581 | config: Config{ |
| 3582 | MaxVersion: VersionTLS13, |
| 3583 | ClientAuth: RequireAnyClientCert, |
| 3584 | }, |
| 3585 | flags: []string{ |
| 3586 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3587 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3588 | }, |
| 3589 | }) |
| 3590 | tests = append(tests, testCase{ |
| 3591 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3592 | name: "ClientAuth-ECDSA-Client", |
| 3593 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3594 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3595 | ClientAuth: RequireAnyClientCert, |
| 3596 | }, |
| 3597 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3598 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3599 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3600 | }, |
| 3601 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3602 | tests = append(tests, testCase{ |
| 3603 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3604 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3605 | config: Config{ |
| 3606 | MaxVersion: VersionTLS13, |
| 3607 | ClientAuth: RequireAnyClientCert, |
| 3608 | }, |
| 3609 | flags: []string{ |
| 3610 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3611 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3612 | }, |
| 3613 | }) |
| 3614 | tests = append(tests, testCase{ |
| 3615 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3616 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3617 | config: Config{ |
| 3618 | MaxVersion: VersionTLS12, |
| 3619 | ClientAuth: RequestClientCert, |
| 3620 | }, |
| 3621 | flags: []string{"-use-old-client-cert-callback"}, |
| 3622 | }) |
| 3623 | tests = append(tests, testCase{ |
| 3624 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3625 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3626 | config: Config{ |
| 3627 | MaxVersion: VersionTLS13, |
| 3628 | ClientAuth: RequestClientCert, |
| 3629 | }, |
| 3630 | flags: []string{"-use-old-client-cert-callback"}, |
| 3631 | }) |
| 3632 | tests = append(tests, testCase{ |
| 3633 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3634 | name: "ClientAuth-OldCallback", |
| 3635 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3636 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3637 | ClientAuth: RequireAnyClientCert, |
| 3638 | }, |
| 3639 | flags: []string{ |
| 3640 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3641 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3642 | "-use-old-client-cert-callback", |
| 3643 | }, |
| 3644 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3645 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3646 | testType: clientTest, |
| 3647 | name: "ClientAuth-OldCallback-TLS13", |
| 3648 | config: Config{ |
| 3649 | MaxVersion: VersionTLS13, |
| 3650 | ClientAuth: RequireAnyClientCert, |
| 3651 | }, |
| 3652 | flags: []string{ |
| 3653 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3654 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3655 | "-use-old-client-cert-callback", |
| 3656 | }, |
| 3657 | }) |
| 3658 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3659 | testType: serverTest, |
| 3660 | name: "ClientAuth-Server", |
| 3661 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3662 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3663 | Certificates: []Certificate{rsaCertificate}, |
| 3664 | }, |
| 3665 | flags: []string{"-require-any-client-certificate"}, |
| 3666 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3667 | tests = append(tests, testCase{ |
| 3668 | testType: serverTest, |
| 3669 | name: "ClientAuth-Server-TLS13", |
| 3670 | config: Config{ |
| 3671 | MaxVersion: VersionTLS13, |
| 3672 | Certificates: []Certificate{rsaCertificate}, |
| 3673 | }, |
| 3674 | flags: []string{"-require-any-client-certificate"}, |
| 3675 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3676 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3677 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3678 | tests = append(tests, testCase{ |
| 3679 | testType: serverTest, |
| 3680 | name: "Basic-Server-RSA", |
| 3681 | config: Config{ |
| 3682 | MaxVersion: VersionTLS12, |
| 3683 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3684 | }, |
| 3685 | flags: []string{ |
| 3686 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3687 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3688 | }, |
| 3689 | }) |
| 3690 | tests = append(tests, testCase{ |
| 3691 | testType: serverTest, |
| 3692 | name: "Basic-Server-ECDHE-RSA", |
| 3693 | config: Config{ |
| 3694 | MaxVersion: VersionTLS12, |
| 3695 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3696 | }, |
| 3697 | flags: []string{ |
| 3698 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3699 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3700 | }, |
| 3701 | }) |
| 3702 | tests = append(tests, testCase{ |
| 3703 | testType: serverTest, |
| 3704 | name: "Basic-Server-ECDHE-ECDSA", |
| 3705 | config: Config{ |
| 3706 | MaxVersion: VersionTLS12, |
| 3707 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3708 | }, |
| 3709 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3710 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3711 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3712 | }, |
| 3713 | }) |
| 3714 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3715 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3716 | tests = append(tests, testCase{ |
| 3717 | name: "SessionTicketsDisabled-Client", |
| 3718 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3719 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3720 | SessionTicketsDisabled: true, |
| 3721 | }, |
| 3722 | }) |
| 3723 | tests = append(tests, testCase{ |
| 3724 | testType: serverTest, |
| 3725 | name: "SessionTicketsDisabled-Server", |
| 3726 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3727 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3728 | SessionTicketsDisabled: true, |
| 3729 | }, |
| 3730 | }) |
| 3731 | |
| 3732 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3733 | // identity hint. |
| 3734 | tests = append(tests, testCase{ |
| 3735 | name: "EmptyPSKHint-Client", |
| 3736 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3737 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3738 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3739 | PreSharedKey: []byte("secret"), |
| 3740 | }, |
| 3741 | flags: []string{"-psk", "secret"}, |
| 3742 | }) |
| 3743 | tests = append(tests, testCase{ |
| 3744 | testType: serverTest, |
| 3745 | name: "EmptyPSKHint-Server", |
| 3746 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3747 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3748 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3749 | PreSharedKey: []byte("secret"), |
| 3750 | }, |
| 3751 | flags: []string{"-psk", "secret"}, |
| 3752 | }) |
| 3753 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3754 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3755 | tests = append(tests, testCase{ |
| 3756 | testType: clientTest, |
| 3757 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3758 | config: Config{ |
| 3759 | MaxVersion: VersionTLS12, |
| 3760 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3761 | flags: []string{ |
| 3762 | "-enable-ocsp-stapling", |
| 3763 | "-expect-ocsp-response", |
| 3764 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3765 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3766 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3767 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3768 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3769 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3770 | testType: serverTest, |
| 3771 | name: "OCSPStapling-Server", |
| 3772 | config: Config{ |
| 3773 | MaxVersion: VersionTLS12, |
| 3774 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3775 | expectedOCSPResponse: testOCSPResponse, |
| 3776 | flags: []string{ |
| 3777 | "-ocsp-response", |
| 3778 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3779 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3780 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3781 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3782 | tests = append(tests, testCase{ |
| 3783 | testType: clientTest, |
| 3784 | name: "OCSPStapling-Client-TLS13", |
| 3785 | config: Config{ |
| 3786 | MaxVersion: VersionTLS13, |
| 3787 | }, |
| 3788 | flags: []string{ |
| 3789 | "-enable-ocsp-stapling", |
| 3790 | "-expect-ocsp-response", |
| 3791 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3792 | "-verify-peer", |
| 3793 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3794 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3795 | }) |
| 3796 | tests = append(tests, testCase{ |
| 3797 | testType: serverTest, |
| 3798 | name: "OCSPStapling-Server-TLS13", |
| 3799 | config: Config{ |
| 3800 | MaxVersion: VersionTLS13, |
| 3801 | }, |
| 3802 | expectedOCSPResponse: testOCSPResponse, |
| 3803 | flags: []string{ |
| 3804 | "-ocsp-response", |
| 3805 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3806 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3807 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3808 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3809 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3810 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3811 | for _, vers := range tlsVersions { |
| 3812 | if config.protocol == dtls && !vers.hasDTLS { |
| 3813 | continue |
| 3814 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3815 | for _, testType := range []testType{clientTest, serverTest} { |
| 3816 | suffix := "-Client" |
| 3817 | if testType == serverTest { |
| 3818 | suffix = "-Server" |
| 3819 | } |
| 3820 | suffix += "-" + vers.name |
| 3821 | |
| 3822 | flag := "-verify-peer" |
| 3823 | if testType == serverTest { |
| 3824 | flag = "-require-any-client-certificate" |
| 3825 | } |
| 3826 | |
| 3827 | tests = append(tests, testCase{ |
| 3828 | testType: testType, |
| 3829 | name: "CertificateVerificationSucceed" + suffix, |
| 3830 | config: Config{ |
| 3831 | MaxVersion: vers.version, |
| 3832 | Certificates: []Certificate{rsaCertificate}, |
| 3833 | }, |
| 3834 | flags: []string{ |
| 3835 | flag, |
| 3836 | "-expect-verify-result", |
| 3837 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3838 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3839 | }) |
| 3840 | tests = append(tests, testCase{ |
| 3841 | testType: testType, |
| 3842 | name: "CertificateVerificationFail" + suffix, |
| 3843 | config: Config{ |
| 3844 | MaxVersion: vers.version, |
| 3845 | Certificates: []Certificate{rsaCertificate}, |
| 3846 | }, |
| 3847 | flags: []string{ |
| 3848 | flag, |
| 3849 | "-verify-fail", |
| 3850 | }, |
| 3851 | shouldFail: true, |
| 3852 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3853 | }) |
| 3854 | } |
| 3855 | |
| 3856 | // By default, the client is in a soft fail mode where the peer |
| 3857 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3858 | tests = append(tests, testCase{ |
| 3859 | testType: clientTest, |
| 3860 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3861 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3862 | MaxVersion: vers.version, |
| 3863 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3864 | }, |
| 3865 | flags: []string{ |
| 3866 | "-verify-fail", |
| 3867 | "-expect-verify-result", |
| 3868 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3869 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3870 | }) |
| 3871 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3872 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3873 | tests = append(tests, testCase{ |
| 3874 | name: "ShimSendAlert", |
| 3875 | flags: []string{"-send-alert"}, |
| 3876 | shimWritesFirst: true, |
| 3877 | shouldFail: true, |
| 3878 | expectedLocalError: "remote error: decompression failure", |
| 3879 | }) |
| 3880 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3881 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3882 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3883 | name: "Renegotiate-Client", |
| 3884 | config: Config{ |
| 3885 | MaxVersion: VersionTLS12, |
| 3886 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3887 | renegotiate: 1, |
| 3888 | flags: []string{ |
| 3889 | "-renegotiate-freely", |
| 3890 | "-expect-total-renegotiations", "1", |
| 3891 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3892 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3893 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3894 | tests = append(tests, testCase{ |
| 3895 | name: "SendHalfHelloRequest", |
| 3896 | config: Config{ |
| 3897 | MaxVersion: VersionTLS12, |
| 3898 | Bugs: ProtocolBugs{ |
| 3899 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3900 | }, |
| 3901 | }, |
| 3902 | sendHalfHelloRequest: true, |
| 3903 | flags: []string{"-renegotiate-ignore"}, |
| 3904 | shouldFail: true, |
| 3905 | expectedError: ":UNEXPECTED_RECORD:", |
| 3906 | }) |
| 3907 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3908 | // NPN on client and server; results in post-handshake message. |
| 3909 | tests = append(tests, testCase{ |
| 3910 | name: "NPN-Client", |
| 3911 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3912 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3913 | NextProtos: []string{"foo"}, |
| 3914 | }, |
| 3915 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3916 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3917 | expectedNextProto: "foo", |
| 3918 | expectedNextProtoType: npn, |
| 3919 | }) |
| 3920 | tests = append(tests, testCase{ |
| 3921 | testType: serverTest, |
| 3922 | name: "NPN-Server", |
| 3923 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3924 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3925 | NextProtos: []string{"bar"}, |
| 3926 | }, |
| 3927 | flags: []string{ |
| 3928 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3929 | "-expect-next-proto", "bar", |
| 3930 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3931 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3932 | expectedNextProto: "bar", |
| 3933 | expectedNextProtoType: npn, |
| 3934 | }) |
| 3935 | |
| 3936 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3937 | |
| 3938 | // Client does False Start and negotiates NPN. |
| 3939 | tests = append(tests, testCase{ |
| 3940 | name: "FalseStart", |
| 3941 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3942 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3943 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3944 | NextProtos: []string{"foo"}, |
| 3945 | Bugs: ProtocolBugs{ |
| 3946 | ExpectFalseStart: true, |
| 3947 | }, |
| 3948 | }, |
| 3949 | flags: []string{ |
| 3950 | "-false-start", |
| 3951 | "-select-next-proto", "foo", |
| 3952 | }, |
| 3953 | shimWritesFirst: true, |
| 3954 | resumeSession: true, |
| 3955 | }) |
| 3956 | |
| 3957 | // Client does False Start and negotiates ALPN. |
| 3958 | tests = append(tests, testCase{ |
| 3959 | name: "FalseStart-ALPN", |
| 3960 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3961 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3962 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3963 | NextProtos: []string{"foo"}, |
| 3964 | Bugs: ProtocolBugs{ |
| 3965 | ExpectFalseStart: true, |
| 3966 | }, |
| 3967 | }, |
| 3968 | flags: []string{ |
| 3969 | "-false-start", |
| 3970 | "-advertise-alpn", "\x03foo", |
| 3971 | }, |
| 3972 | shimWritesFirst: true, |
| 3973 | resumeSession: true, |
| 3974 | }) |
| 3975 | |
| 3976 | // Client does False Start but doesn't explicitly call |
| 3977 | // SSL_connect. |
| 3978 | tests = append(tests, testCase{ |
| 3979 | name: "FalseStart-Implicit", |
| 3980 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3981 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3982 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3983 | NextProtos: []string{"foo"}, |
| 3984 | }, |
| 3985 | flags: []string{ |
| 3986 | "-implicit-handshake", |
| 3987 | "-false-start", |
| 3988 | "-advertise-alpn", "\x03foo", |
| 3989 | }, |
| 3990 | }) |
| 3991 | |
| 3992 | // False Start without session tickets. |
| 3993 | tests = append(tests, testCase{ |
| 3994 | name: "FalseStart-SessionTicketsDisabled", |
| 3995 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3996 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3997 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3998 | NextProtos: []string{"foo"}, |
| 3999 | SessionTicketsDisabled: true, |
| 4000 | Bugs: ProtocolBugs{ |
| 4001 | ExpectFalseStart: true, |
| 4002 | }, |
| 4003 | }, |
| 4004 | flags: []string{ |
| 4005 | "-false-start", |
| 4006 | "-select-next-proto", "foo", |
| 4007 | }, |
| 4008 | shimWritesFirst: true, |
| 4009 | }) |
| 4010 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 4011 | tests = append(tests, testCase{ |
| 4012 | name: "FalseStart-CECPQ1", |
| 4013 | config: Config{ |
| 4014 | MaxVersion: VersionTLS12, |
| 4015 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 4016 | NextProtos: []string{"foo"}, |
| 4017 | Bugs: ProtocolBugs{ |
| 4018 | ExpectFalseStart: true, |
| 4019 | }, |
| 4020 | }, |
| 4021 | flags: []string{ |
| 4022 | "-false-start", |
| 4023 | "-cipher", "DEFAULT:kCECPQ1", |
| 4024 | "-select-next-proto", "foo", |
| 4025 | }, |
| 4026 | shimWritesFirst: true, |
| 4027 | resumeSession: true, |
| 4028 | }) |
| 4029 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4030 | // Server parses a V2ClientHello. |
| 4031 | tests = append(tests, testCase{ |
| 4032 | testType: serverTest, |
| 4033 | name: "SendV2ClientHello", |
| 4034 | config: Config{ |
| 4035 | // Choose a cipher suite that does not involve |
| 4036 | // elliptic curves, so no extensions are |
| 4037 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4038 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4039 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4040 | Bugs: ProtocolBugs{ |
| 4041 | SendV2ClientHello: true, |
| 4042 | }, |
| 4043 | }, |
| 4044 | }) |
| 4045 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4046 | // Test Channel ID |
| 4047 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4048 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4049 | continue |
| 4050 | } |
| 4051 | // Client sends a Channel ID. |
| 4052 | tests = append(tests, testCase{ |
| 4053 | name: "ChannelID-Client-" + ver.name, |
| 4054 | config: Config{ |
| 4055 | MaxVersion: ver.version, |
| 4056 | RequestChannelID: true, |
| 4057 | }, |
| 4058 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4059 | resumeSession: true, |
| 4060 | expectChannelID: true, |
| 4061 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4062 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4063 | // Server accepts a Channel ID. |
| 4064 | tests = append(tests, testCase{ |
| 4065 | testType: serverTest, |
| 4066 | name: "ChannelID-Server-" + ver.name, |
| 4067 | config: Config{ |
| 4068 | MaxVersion: ver.version, |
| 4069 | ChannelID: channelIDKey, |
| 4070 | }, |
| 4071 | flags: []string{ |
| 4072 | "-expect-channel-id", |
| 4073 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4074 | }, |
| 4075 | resumeSession: true, |
| 4076 | expectChannelID: true, |
| 4077 | }) |
| 4078 | |
| 4079 | tests = append(tests, testCase{ |
| 4080 | testType: serverTest, |
| 4081 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4082 | config: Config{ |
| 4083 | MaxVersion: ver.version, |
| 4084 | ChannelID: channelIDKey, |
| 4085 | Bugs: ProtocolBugs{ |
| 4086 | InvalidChannelIDSignature: true, |
| 4087 | }, |
| 4088 | }, |
| 4089 | flags: []string{"-enable-channel-id"}, |
| 4090 | shouldFail: true, |
| 4091 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4092 | }) |
| 4093 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4094 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4095 | // Channel ID and NPN at the same time, to ensure their relative |
| 4096 | // ordering is correct. |
| 4097 | tests = append(tests, testCase{ |
| 4098 | name: "ChannelID-NPN-Client", |
| 4099 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4100 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4101 | RequestChannelID: true, |
| 4102 | NextProtos: []string{"foo"}, |
| 4103 | }, |
| 4104 | flags: []string{ |
| 4105 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4106 | "-select-next-proto", "foo", |
| 4107 | }, |
| 4108 | resumeSession: true, |
| 4109 | expectChannelID: true, |
| 4110 | expectedNextProto: "foo", |
| 4111 | expectedNextProtoType: npn, |
| 4112 | }) |
| 4113 | tests = append(tests, testCase{ |
| 4114 | testType: serverTest, |
| 4115 | name: "ChannelID-NPN-Server", |
| 4116 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4117 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4118 | ChannelID: channelIDKey, |
| 4119 | NextProtos: []string{"bar"}, |
| 4120 | }, |
| 4121 | flags: []string{ |
| 4122 | "-expect-channel-id", |
| 4123 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4124 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4125 | "-expect-next-proto", "bar", |
| 4126 | }, |
| 4127 | resumeSession: true, |
| 4128 | expectChannelID: true, |
| 4129 | expectedNextProto: "bar", |
| 4130 | expectedNextProtoType: npn, |
| 4131 | }) |
| 4132 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4133 | // Bidirectional shutdown with the runner initiating. |
| 4134 | tests = append(tests, testCase{ |
| 4135 | name: "Shutdown-Runner", |
| 4136 | config: Config{ |
| 4137 | Bugs: ProtocolBugs{ |
| 4138 | ExpectCloseNotify: true, |
| 4139 | }, |
| 4140 | }, |
| 4141 | flags: []string{"-check-close-notify"}, |
| 4142 | }) |
| 4143 | |
| 4144 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4145 | // in the meantime, sends garbage before the close_notify which |
| 4146 | // the shim must ignore. |
| 4147 | tests = append(tests, testCase{ |
| 4148 | name: "Shutdown-Shim", |
| 4149 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 4150 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4151 | Bugs: ProtocolBugs{ |
| 4152 | ExpectCloseNotify: true, |
| 4153 | }, |
| 4154 | }, |
| 4155 | shimShutsDown: true, |
| 4156 | sendEmptyRecords: 1, |
| 4157 | sendWarningAlerts: 1, |
| 4158 | flags: []string{"-check-close-notify"}, |
| 4159 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4160 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4161 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4162 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4163 | tests = append(tests, testCase{ |
| 4164 | name: "SkipHelloVerifyRequest", |
| 4165 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4166 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4167 | Bugs: ProtocolBugs{ |
| 4168 | SkipHelloVerifyRequest: true, |
| 4169 | }, |
| 4170 | }, |
| 4171 | }) |
| 4172 | } |
| 4173 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4174 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4175 | test.protocol = config.protocol |
| 4176 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4177 | test.name += "-DTLS" |
| 4178 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4179 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4180 | test.name += "-Async" |
| 4181 | test.flags = append(test.flags, "-async") |
| 4182 | } else { |
| 4183 | test.name += "-Sync" |
| 4184 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4185 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4186 | test.name += "-SplitHandshakeRecords" |
| 4187 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4188 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4189 | test.config.Bugs.MaxPacketLength = 256 |
| 4190 | test.flags = append(test.flags, "-mtu", "256") |
| 4191 | } |
| 4192 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4193 | if config.packHandshakeFlight { |
| 4194 | test.name += "-PackHandshakeFlight" |
| 4195 | test.config.Bugs.PackHandshakeFlight = true |
| 4196 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4197 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4198 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4199 | } |
| 4200 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4201 | func addDDoSCallbackTests() { |
| 4202 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4203 | for _, resume := range []bool{false, true} { |
| 4204 | suffix := "Resume" |
| 4205 | if resume { |
| 4206 | suffix = "No" + suffix |
| 4207 | } |
| 4208 | |
| 4209 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4210 | testType: serverTest, |
| 4211 | name: "Server-DDoS-OK-" + suffix, |
| 4212 | config: Config{ |
| 4213 | MaxVersion: VersionTLS12, |
| 4214 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4215 | flags: []string{"-install-ddos-callback"}, |
| 4216 | resumeSession: resume, |
| 4217 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4218 | testCases = append(testCases, testCase{ |
| 4219 | testType: serverTest, |
| 4220 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4221 | config: Config{ |
| 4222 | MaxVersion: VersionTLS13, |
| 4223 | }, |
| 4224 | flags: []string{"-install-ddos-callback"}, |
| 4225 | resumeSession: resume, |
| 4226 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4227 | |
| 4228 | failFlag := "-fail-ddos-callback" |
| 4229 | if resume { |
| 4230 | failFlag = "-fail-second-ddos-callback" |
| 4231 | } |
| 4232 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4233 | testType: serverTest, |
| 4234 | name: "Server-DDoS-Reject-" + suffix, |
| 4235 | config: Config{ |
| 4236 | MaxVersion: VersionTLS12, |
| 4237 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4238 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4239 | resumeSession: resume, |
| 4240 | shouldFail: true, |
| 4241 | expectedError: ":CONNECTION_REJECTED:", |
| 4242 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4243 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4244 | testCases = append(testCases, testCase{ |
| 4245 | testType: serverTest, |
| 4246 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4247 | config: Config{ |
| 4248 | MaxVersion: VersionTLS13, |
| 4249 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4250 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4251 | resumeSession: resume, |
| 4252 | shouldFail: true, |
| 4253 | expectedError: ":CONNECTION_REJECTED:", |
| 4254 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4255 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4256 | } |
| 4257 | } |
| 4258 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4259 | func addVersionNegotiationTests() { |
| 4260 | for i, shimVers := range tlsVersions { |
| 4261 | // Assemble flags to disable all newer versions on the shim. |
| 4262 | var flags []string |
| 4263 | for _, vers := range tlsVersions[i+1:] { |
| 4264 | flags = append(flags, vers.flag) |
| 4265 | } |
| 4266 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4267 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4268 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4269 | protocols := []protocol{tls} |
| 4270 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4271 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4272 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4273 | for _, protocol := range protocols { |
| 4274 | expectedVersion := shimVers.version |
| 4275 | if runnerVers.version < shimVers.version { |
| 4276 | expectedVersion = runnerVers.version |
| 4277 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4278 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4279 | suffix := shimVers.name + "-" + runnerVers.name |
| 4280 | if protocol == dtls { |
| 4281 | suffix += "-DTLS" |
| 4282 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4283 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4284 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4285 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4286 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4287 | clientVers := shimVers.version |
| 4288 | if clientVers > VersionTLS10 { |
| 4289 | clientVers = VersionTLS10 |
| 4290 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4291 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4292 | serverVers := expectedVersion |
| 4293 | if expectedVersion >= VersionTLS13 { |
| 4294 | serverVers = VersionTLS10 |
| 4295 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4296 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4297 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4298 | testCases = append(testCases, testCase{ |
| 4299 | protocol: protocol, |
| 4300 | testType: clientTest, |
| 4301 | name: "VersionNegotiation-Client-" + suffix, |
| 4302 | config: Config{ |
| 4303 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4304 | Bugs: ProtocolBugs{ |
| 4305 | ExpectInitialRecordVersion: clientVers, |
| 4306 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4307 | }, |
| 4308 | flags: flags, |
| 4309 | expectedVersion: expectedVersion, |
| 4310 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4311 | testCases = append(testCases, testCase{ |
| 4312 | protocol: protocol, |
| 4313 | testType: clientTest, |
| 4314 | name: "VersionNegotiation-Client2-" + suffix, |
| 4315 | config: Config{ |
| 4316 | MaxVersion: runnerVers.version, |
| 4317 | Bugs: ProtocolBugs{ |
| 4318 | ExpectInitialRecordVersion: clientVers, |
| 4319 | }, |
| 4320 | }, |
| 4321 | flags: []string{"-max-version", shimVersFlag}, |
| 4322 | expectedVersion: expectedVersion, |
| 4323 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4324 | |
| 4325 | testCases = append(testCases, testCase{ |
| 4326 | protocol: protocol, |
| 4327 | testType: serverTest, |
| 4328 | name: "VersionNegotiation-Server-" + suffix, |
| 4329 | config: Config{ |
| 4330 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4331 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4332 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4333 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4334 | }, |
| 4335 | flags: flags, |
| 4336 | expectedVersion: expectedVersion, |
| 4337 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4338 | testCases = append(testCases, testCase{ |
| 4339 | protocol: protocol, |
| 4340 | testType: serverTest, |
| 4341 | name: "VersionNegotiation-Server2-" + suffix, |
| 4342 | config: Config{ |
| 4343 | MaxVersion: runnerVers.version, |
| 4344 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4345 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4346 | }, |
| 4347 | }, |
| 4348 | flags: []string{"-max-version", shimVersFlag}, |
| 4349 | expectedVersion: expectedVersion, |
| 4350 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4351 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4352 | } |
| 4353 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4354 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4355 | // Test the version extension at all versions. |
| 4356 | for _, vers := range tlsVersions { |
| 4357 | protocols := []protocol{tls} |
| 4358 | if vers.hasDTLS { |
| 4359 | protocols = append(protocols, dtls) |
| 4360 | } |
| 4361 | for _, protocol := range protocols { |
| 4362 | suffix := vers.name |
| 4363 | if protocol == dtls { |
| 4364 | suffix += "-DTLS" |
| 4365 | } |
| 4366 | |
| 4367 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4368 | testCases = append(testCases, testCase{ |
| 4369 | protocol: protocol, |
| 4370 | testType: serverTest, |
| 4371 | name: "VersionNegotiationExtension-" + suffix, |
| 4372 | config: Config{ |
| 4373 | Bugs: ProtocolBugs{ |
| 4374 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4375 | }, |
| 4376 | }, |
| 4377 | expectedVersion: vers.version, |
| 4378 | }) |
| 4379 | } |
| 4380 | |
| 4381 | } |
| 4382 | |
| 4383 | // If all versions are unknown, negotiation fails. |
| 4384 | testCases = append(testCases, testCase{ |
| 4385 | testType: serverTest, |
| 4386 | name: "NoSupportedVersions", |
| 4387 | config: Config{ |
| 4388 | Bugs: ProtocolBugs{ |
| 4389 | SendSupportedVersions: []uint16{0x1111}, |
| 4390 | }, |
| 4391 | }, |
| 4392 | shouldFail: true, |
| 4393 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4394 | }) |
| 4395 | testCases = append(testCases, testCase{ |
| 4396 | protocol: dtls, |
| 4397 | testType: serverTest, |
| 4398 | name: "NoSupportedVersions-DTLS", |
| 4399 | config: Config{ |
| 4400 | Bugs: ProtocolBugs{ |
| 4401 | SendSupportedVersions: []uint16{0x1111}, |
| 4402 | }, |
| 4403 | }, |
| 4404 | shouldFail: true, |
| 4405 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4406 | }) |
| 4407 | |
| 4408 | testCases = append(testCases, testCase{ |
| 4409 | testType: serverTest, |
| 4410 | name: "ClientHelloVersionTooHigh", |
| 4411 | config: Config{ |
| 4412 | MaxVersion: VersionTLS13, |
| 4413 | Bugs: ProtocolBugs{ |
| 4414 | SendClientVersion: 0x0304, |
| 4415 | OmitSupportedVersions: true, |
| 4416 | }, |
| 4417 | }, |
| 4418 | expectedVersion: VersionTLS12, |
| 4419 | }) |
| 4420 | |
| 4421 | testCases = append(testCases, testCase{ |
| 4422 | testType: serverTest, |
| 4423 | name: "ConflictingVersionNegotiation", |
| 4424 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4425 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4426 | SendClientVersion: VersionTLS12, |
| 4427 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4428 | }, |
| 4429 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4430 | // The extension takes precedence over the ClientHello version. |
| 4431 | expectedVersion: VersionTLS11, |
| 4432 | }) |
| 4433 | |
| 4434 | testCases = append(testCases, testCase{ |
| 4435 | testType: serverTest, |
| 4436 | name: "ConflictingVersionNegotiation-2", |
| 4437 | config: Config{ |
| 4438 | Bugs: ProtocolBugs{ |
| 4439 | SendClientVersion: VersionTLS11, |
| 4440 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4441 | }, |
| 4442 | }, |
| 4443 | // The extension takes precedence over the ClientHello version. |
| 4444 | expectedVersion: VersionTLS12, |
| 4445 | }) |
| 4446 | |
| 4447 | testCases = append(testCases, testCase{ |
| 4448 | testType: serverTest, |
| 4449 | name: "RejectFinalTLS13", |
| 4450 | config: Config{ |
| 4451 | Bugs: ProtocolBugs{ |
| 4452 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4453 | }, |
| 4454 | }, |
| 4455 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4456 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4457 | expectedVersion: VersionTLS12, |
| 4458 | }) |
| 4459 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4460 | // Test that the maximum version is selected regardless of the |
| 4461 | // client-sent order. |
| 4462 | testCases = append(testCases, testCase{ |
| 4463 | testType: serverTest, |
| 4464 | name: "IgnoreClientVersionOrder", |
| 4465 | config: Config{ |
| 4466 | Bugs: ProtocolBugs{ |
| 4467 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4468 | }, |
| 4469 | }, |
| 4470 | expectedVersion: VersionTLS13, |
| 4471 | }) |
| 4472 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4473 | // Test for version tolerance. |
| 4474 | testCases = append(testCases, testCase{ |
| 4475 | testType: serverTest, |
| 4476 | name: "MinorVersionTolerance", |
| 4477 | config: Config{ |
| 4478 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4479 | SendClientVersion: 0x03ff, |
| 4480 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4481 | }, |
| 4482 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4483 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4484 | }) |
| 4485 | testCases = append(testCases, testCase{ |
| 4486 | testType: serverTest, |
| 4487 | name: "MajorVersionTolerance", |
| 4488 | config: Config{ |
| 4489 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4490 | SendClientVersion: 0x0400, |
| 4491 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4492 | }, |
| 4493 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4494 | // TLS 1.3 must be negotiated with the supported_versions |
| 4495 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4496 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4497 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4498 | testCases = append(testCases, testCase{ |
| 4499 | testType: serverTest, |
| 4500 | name: "VersionTolerance-TLS13", |
| 4501 | config: Config{ |
| 4502 | Bugs: ProtocolBugs{ |
| 4503 | // Although TLS 1.3 does not use |
| 4504 | // ClientHello.version, it still tolerates high |
| 4505 | // values there. |
| 4506 | SendClientVersion: 0x0400, |
| 4507 | }, |
| 4508 | }, |
| 4509 | expectedVersion: VersionTLS13, |
| 4510 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4511 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4512 | testCases = append(testCases, testCase{ |
| 4513 | protocol: dtls, |
| 4514 | testType: serverTest, |
| 4515 | name: "MinorVersionTolerance-DTLS", |
| 4516 | config: Config{ |
| 4517 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4518 | SendClientVersion: 0xfe00, |
| 4519 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4520 | }, |
| 4521 | }, |
| 4522 | expectedVersion: VersionTLS12, |
| 4523 | }) |
| 4524 | testCases = append(testCases, testCase{ |
| 4525 | protocol: dtls, |
| 4526 | testType: serverTest, |
| 4527 | name: "MajorVersionTolerance-DTLS", |
| 4528 | config: Config{ |
| 4529 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4530 | SendClientVersion: 0xfdff, |
| 4531 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4532 | }, |
| 4533 | }, |
| 4534 | expectedVersion: VersionTLS12, |
| 4535 | }) |
| 4536 | |
| 4537 | // Test that versions below 3.0 are rejected. |
| 4538 | testCases = append(testCases, testCase{ |
| 4539 | testType: serverTest, |
| 4540 | name: "VersionTooLow", |
| 4541 | config: Config{ |
| 4542 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4543 | SendClientVersion: 0x0200, |
| 4544 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4545 | }, |
| 4546 | }, |
| 4547 | shouldFail: true, |
| 4548 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4549 | }) |
| 4550 | testCases = append(testCases, testCase{ |
| 4551 | protocol: dtls, |
| 4552 | testType: serverTest, |
| 4553 | name: "VersionTooLow-DTLS", |
| 4554 | config: Config{ |
| 4555 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4556 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4557 | }, |
| 4558 | }, |
| 4559 | shouldFail: true, |
| 4560 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4561 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4562 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4563 | testCases = append(testCases, testCase{ |
| 4564 | name: "ServerBogusVersion", |
| 4565 | config: Config{ |
| 4566 | Bugs: ProtocolBugs{ |
| 4567 | SendServerHelloVersion: 0x1234, |
| 4568 | }, |
| 4569 | }, |
| 4570 | shouldFail: true, |
| 4571 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4572 | }) |
| 4573 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4574 | // Test TLS 1.3's downgrade signal. |
| 4575 | testCases = append(testCases, testCase{ |
| 4576 | name: "Downgrade-TLS12-Client", |
| 4577 | config: Config{ |
| 4578 | Bugs: ProtocolBugs{ |
| 4579 | NegotiateVersion: VersionTLS12, |
| 4580 | }, |
| 4581 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4582 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4583 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4584 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4585 | }) |
| 4586 | testCases = append(testCases, testCase{ |
| 4587 | testType: serverTest, |
| 4588 | name: "Downgrade-TLS12-Server", |
| 4589 | config: Config{ |
| 4590 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4591 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4592 | }, |
| 4593 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4594 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4595 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4596 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4597 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4598 | } |
| 4599 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4600 | func addMinimumVersionTests() { |
| 4601 | for i, shimVers := range tlsVersions { |
| 4602 | // Assemble flags to disable all older versions on the shim. |
| 4603 | var flags []string |
| 4604 | for _, vers := range tlsVersions[:i] { |
| 4605 | flags = append(flags, vers.flag) |
| 4606 | } |
| 4607 | |
| 4608 | for _, runnerVers := range tlsVersions { |
| 4609 | protocols := []protocol{tls} |
| 4610 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4611 | protocols = append(protocols, dtls) |
| 4612 | } |
| 4613 | for _, protocol := range protocols { |
| 4614 | suffix := shimVers.name + "-" + runnerVers.name |
| 4615 | if protocol == dtls { |
| 4616 | suffix += "-DTLS" |
| 4617 | } |
| 4618 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4619 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4620 | var expectedVersion uint16 |
| 4621 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4622 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4623 | if runnerVers.version >= shimVers.version { |
| 4624 | expectedVersion = runnerVers.version |
| 4625 | } else { |
| 4626 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4627 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4628 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4629 | } |
| 4630 | |
| 4631 | testCases = append(testCases, testCase{ |
| 4632 | protocol: protocol, |
| 4633 | testType: clientTest, |
| 4634 | name: "MinimumVersion-Client-" + suffix, |
| 4635 | config: Config{ |
| 4636 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4637 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4638 | // Ensure the server does not decline to |
| 4639 | // select a version (versions extension) or |
| 4640 | // cipher (some ciphers depend on versions). |
| 4641 | NegotiateVersion: runnerVers.version, |
| 4642 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4643 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4644 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4645 | flags: flags, |
| 4646 | expectedVersion: expectedVersion, |
| 4647 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4648 | expectedError: expectedError, |
| 4649 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4650 | }) |
| 4651 | testCases = append(testCases, testCase{ |
| 4652 | protocol: protocol, |
| 4653 | testType: clientTest, |
| 4654 | name: "MinimumVersion-Client2-" + suffix, |
| 4655 | config: Config{ |
| 4656 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4657 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4658 | // Ensure the server does not decline to |
| 4659 | // select a version (versions extension) or |
| 4660 | // cipher (some ciphers depend on versions). |
| 4661 | NegotiateVersion: runnerVers.version, |
| 4662 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4663 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4664 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4665 | flags: []string{"-min-version", shimVersFlag}, |
| 4666 | expectedVersion: expectedVersion, |
| 4667 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4668 | expectedError: expectedError, |
| 4669 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4670 | }) |
| 4671 | |
| 4672 | testCases = append(testCases, testCase{ |
| 4673 | protocol: protocol, |
| 4674 | testType: serverTest, |
| 4675 | name: "MinimumVersion-Server-" + suffix, |
| 4676 | config: Config{ |
| 4677 | MaxVersion: runnerVers.version, |
| 4678 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4679 | flags: flags, |
| 4680 | expectedVersion: expectedVersion, |
| 4681 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4682 | expectedError: expectedError, |
| 4683 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4684 | }) |
| 4685 | testCases = append(testCases, testCase{ |
| 4686 | protocol: protocol, |
| 4687 | testType: serverTest, |
| 4688 | name: "MinimumVersion-Server2-" + suffix, |
| 4689 | config: Config{ |
| 4690 | MaxVersion: runnerVers.version, |
| 4691 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4692 | flags: []string{"-min-version", shimVersFlag}, |
| 4693 | expectedVersion: expectedVersion, |
| 4694 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4695 | expectedError: expectedError, |
| 4696 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4697 | }) |
| 4698 | } |
| 4699 | } |
| 4700 | } |
| 4701 | } |
| 4702 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4703 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4704 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4705 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4706 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4707 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4708 | // Repeat extensions tests all versions except SSL 3.0. |
| 4709 | for _, ver := range tlsVersions { |
| 4710 | if ver.version == VersionSSL30 { |
| 4711 | continue |
| 4712 | } |
| 4713 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4714 | // Test that duplicate extensions are rejected. |
| 4715 | testCases = append(testCases, testCase{ |
| 4716 | testType: clientTest, |
| 4717 | name: "DuplicateExtensionClient-" + ver.name, |
| 4718 | config: Config{ |
| 4719 | MaxVersion: ver.version, |
| 4720 | Bugs: ProtocolBugs{ |
| 4721 | DuplicateExtension: true, |
| 4722 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4723 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4724 | shouldFail: true, |
| 4725 | expectedLocalError: "remote error: error decoding message", |
| 4726 | }) |
| 4727 | testCases = append(testCases, testCase{ |
| 4728 | testType: serverTest, |
| 4729 | name: "DuplicateExtensionServer-" + ver.name, |
| 4730 | config: Config{ |
| 4731 | MaxVersion: ver.version, |
| 4732 | Bugs: ProtocolBugs{ |
| 4733 | DuplicateExtension: true, |
| 4734 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4735 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4736 | shouldFail: true, |
| 4737 | expectedLocalError: "remote error: error decoding message", |
| 4738 | }) |
| 4739 | |
| 4740 | // Test SNI. |
| 4741 | testCases = append(testCases, testCase{ |
| 4742 | testType: clientTest, |
| 4743 | name: "ServerNameExtensionClient-" + ver.name, |
| 4744 | config: Config{ |
| 4745 | MaxVersion: ver.version, |
| 4746 | Bugs: ProtocolBugs{ |
| 4747 | ExpectServerName: "example.com", |
| 4748 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4749 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4750 | flags: []string{"-host-name", "example.com"}, |
| 4751 | }) |
| 4752 | testCases = append(testCases, testCase{ |
| 4753 | testType: clientTest, |
| 4754 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4755 | config: Config{ |
| 4756 | MaxVersion: ver.version, |
| 4757 | Bugs: ProtocolBugs{ |
| 4758 | ExpectServerName: "mismatch.com", |
| 4759 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4760 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4761 | flags: []string{"-host-name", "example.com"}, |
| 4762 | shouldFail: true, |
| 4763 | expectedLocalError: "tls: unexpected server name", |
| 4764 | }) |
| 4765 | testCases = append(testCases, testCase{ |
| 4766 | testType: clientTest, |
| 4767 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4768 | config: Config{ |
| 4769 | MaxVersion: ver.version, |
| 4770 | Bugs: ProtocolBugs{ |
| 4771 | ExpectServerName: "missing.com", |
| 4772 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4773 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4774 | shouldFail: true, |
| 4775 | expectedLocalError: "tls: unexpected server name", |
| 4776 | }) |
| 4777 | testCases = append(testCases, testCase{ |
| 4778 | testType: serverTest, |
| 4779 | name: "ServerNameExtensionServer-" + ver.name, |
| 4780 | config: Config{ |
| 4781 | MaxVersion: ver.version, |
| 4782 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4783 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4784 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4785 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4786 | }) |
| 4787 | |
| 4788 | // Test ALPN. |
| 4789 | testCases = append(testCases, testCase{ |
| 4790 | testType: clientTest, |
| 4791 | name: "ALPNClient-" + ver.name, |
| 4792 | config: Config{ |
| 4793 | MaxVersion: ver.version, |
| 4794 | NextProtos: []string{"foo"}, |
| 4795 | }, |
| 4796 | flags: []string{ |
| 4797 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4798 | "-expect-alpn", "foo", |
| 4799 | }, |
| 4800 | expectedNextProto: "foo", |
| 4801 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4802 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4803 | }) |
| 4804 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4805 | testType: clientTest, |
| 4806 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4807 | config: Config{ |
| 4808 | MaxVersion: ver.version, |
| 4809 | Bugs: ProtocolBugs{ |
| 4810 | SendALPN: "baz", |
| 4811 | }, |
| 4812 | }, |
| 4813 | flags: []string{ |
| 4814 | "-advertise-alpn", "\x03foo\x03bar", |
| 4815 | }, |
| 4816 | shouldFail: true, |
| 4817 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4818 | expectedLocalError: "remote error: illegal parameter", |
| 4819 | }) |
| 4820 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4821 | testType: serverTest, |
| 4822 | name: "ALPNServer-" + ver.name, |
| 4823 | config: Config{ |
| 4824 | MaxVersion: ver.version, |
| 4825 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4826 | }, |
| 4827 | flags: []string{ |
| 4828 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4829 | "-select-alpn", "foo", |
| 4830 | }, |
| 4831 | expectedNextProto: "foo", |
| 4832 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4833 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4834 | }) |
| 4835 | testCases = append(testCases, testCase{ |
| 4836 | testType: serverTest, |
| 4837 | name: "ALPNServer-Decline-" + ver.name, |
| 4838 | config: Config{ |
| 4839 | MaxVersion: ver.version, |
| 4840 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4841 | }, |
| 4842 | flags: []string{"-decline-alpn"}, |
| 4843 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4844 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4845 | }) |
| 4846 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4847 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4848 | // called once. |
| 4849 | testCases = append(testCases, testCase{ |
| 4850 | testType: serverTest, |
| 4851 | name: "ALPNServer-Async-" + ver.name, |
| 4852 | config: Config{ |
| 4853 | MaxVersion: ver.version, |
| 4854 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4855 | }, |
| 4856 | flags: []string{ |
| 4857 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4858 | "-select-alpn", "foo", |
| 4859 | "-async", |
| 4860 | }, |
| 4861 | expectedNextProto: "foo", |
| 4862 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4863 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4864 | }) |
| 4865 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4866 | var emptyString string |
| 4867 | testCases = append(testCases, testCase{ |
| 4868 | testType: clientTest, |
| 4869 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4870 | config: Config{ |
| 4871 | MaxVersion: ver.version, |
| 4872 | NextProtos: []string{""}, |
| 4873 | Bugs: ProtocolBugs{ |
| 4874 | // A server returning an empty ALPN protocol |
| 4875 | // should be rejected. |
| 4876 | ALPNProtocol: &emptyString, |
| 4877 | }, |
| 4878 | }, |
| 4879 | flags: []string{ |
| 4880 | "-advertise-alpn", "\x03foo", |
| 4881 | }, |
| 4882 | shouldFail: true, |
| 4883 | expectedError: ":PARSE_TLSEXT:", |
| 4884 | }) |
| 4885 | testCases = append(testCases, testCase{ |
| 4886 | testType: serverTest, |
| 4887 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4888 | config: Config{ |
| 4889 | MaxVersion: ver.version, |
| 4890 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4891 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4892 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4893 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4894 | flags: []string{ |
| 4895 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4896 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4897 | shouldFail: true, |
| 4898 | expectedError: ":PARSE_TLSEXT:", |
| 4899 | }) |
| 4900 | |
| 4901 | // Test NPN and the interaction with ALPN. |
| 4902 | if ver.version < VersionTLS13 { |
| 4903 | // Test that the server prefers ALPN over NPN. |
| 4904 | testCases = append(testCases, testCase{ |
| 4905 | testType: serverTest, |
| 4906 | name: "ALPNServer-Preferred-" + ver.name, |
| 4907 | config: Config{ |
| 4908 | MaxVersion: ver.version, |
| 4909 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4910 | }, |
| 4911 | flags: []string{ |
| 4912 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4913 | "-select-alpn", "foo", |
| 4914 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4915 | }, |
| 4916 | expectedNextProto: "foo", |
| 4917 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4918 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4919 | }) |
| 4920 | testCases = append(testCases, testCase{ |
| 4921 | testType: serverTest, |
| 4922 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4923 | config: Config{ |
| 4924 | MaxVersion: ver.version, |
| 4925 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4926 | Bugs: ProtocolBugs{ |
| 4927 | SwapNPNAndALPN: true, |
| 4928 | }, |
| 4929 | }, |
| 4930 | flags: []string{ |
| 4931 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4932 | "-select-alpn", "foo", |
| 4933 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4934 | }, |
| 4935 | expectedNextProto: "foo", |
| 4936 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4937 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4938 | }) |
| 4939 | |
| 4940 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4941 | testCases = append(testCases, testCase{ |
| 4942 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4943 | config: Config{ |
| 4944 | MaxVersion: ver.version, |
| 4945 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4946 | Bugs: ProtocolBugs{ |
| 4947 | NegotiateALPNAndNPN: true, |
| 4948 | }, |
| 4949 | }, |
| 4950 | flags: []string{ |
| 4951 | "-advertise-alpn", "\x03foo", |
| 4952 | "-select-next-proto", "foo", |
| 4953 | }, |
| 4954 | shouldFail: true, |
| 4955 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4956 | }) |
| 4957 | testCases = append(testCases, testCase{ |
| 4958 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4959 | config: Config{ |
| 4960 | MaxVersion: ver.version, |
| 4961 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4962 | Bugs: ProtocolBugs{ |
| 4963 | NegotiateALPNAndNPN: true, |
| 4964 | SwapNPNAndALPN: true, |
| 4965 | }, |
| 4966 | }, |
| 4967 | flags: []string{ |
| 4968 | "-advertise-alpn", "\x03foo", |
| 4969 | "-select-next-proto", "foo", |
| 4970 | }, |
| 4971 | shouldFail: true, |
| 4972 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4973 | }) |
| 4974 | |
| 4975 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4976 | testCases = append(testCases, testCase{ |
| 4977 | name: "DisableNPN-" + ver.name, |
| 4978 | config: Config{ |
| 4979 | MaxVersion: ver.version, |
| 4980 | NextProtos: []string{"foo"}, |
| 4981 | }, |
| 4982 | flags: []string{ |
| 4983 | "-select-next-proto", "foo", |
| 4984 | "-disable-npn", |
| 4985 | }, |
| 4986 | expectNoNextProto: true, |
| 4987 | }) |
| 4988 | } |
| 4989 | |
| 4990 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4991 | |
| 4992 | // Resume with a corrupt ticket. |
| 4993 | testCases = append(testCases, testCase{ |
| 4994 | testType: serverTest, |
| 4995 | name: "CorruptTicket-" + ver.name, |
| 4996 | config: Config{ |
| 4997 | MaxVersion: ver.version, |
| 4998 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 4999 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5000 | in[len(in)-1] ^= 1 |
| 5001 | return in, nil |
| 5002 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5003 | }, |
| 5004 | }, |
| 5005 | resumeSession: true, |
| 5006 | expectResumeRejected: true, |
| 5007 | }) |
| 5008 | // Test the ticket callback, with and without renewal. |
| 5009 | testCases = append(testCases, testCase{ |
| 5010 | testType: serverTest, |
| 5011 | name: "TicketCallback-" + ver.name, |
| 5012 | config: Config{ |
| 5013 | MaxVersion: ver.version, |
| 5014 | }, |
| 5015 | resumeSession: true, |
| 5016 | flags: []string{"-use-ticket-callback"}, |
| 5017 | }) |
| 5018 | testCases = append(testCases, testCase{ |
| 5019 | testType: serverTest, |
| 5020 | name: "TicketCallback-Renew-" + ver.name, |
| 5021 | config: Config{ |
| 5022 | MaxVersion: ver.version, |
| 5023 | Bugs: ProtocolBugs{ |
| 5024 | ExpectNewTicket: true, |
| 5025 | }, |
| 5026 | }, |
| 5027 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5028 | resumeSession: true, |
| 5029 | }) |
| 5030 | |
| 5031 | // Test that the ticket callback is only called once when everything before |
| 5032 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5033 | // certificate selection callbacks run. |
| 5034 | testCases = append(testCases, testCase{ |
| 5035 | testType: serverTest, |
| 5036 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5037 | config: Config{ |
| 5038 | MaxVersion: ver.version, |
| 5039 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5040 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5041 | in[len(in)-1] ^= 1 |
| 5042 | return in, nil |
| 5043 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5044 | }, |
| 5045 | }, |
| 5046 | resumeSession: true, |
| 5047 | expectResumeRejected: true, |
| 5048 | flags: []string{ |
| 5049 | "-use-ticket-callback", |
| 5050 | "-async", |
| 5051 | }, |
| 5052 | }) |
| 5053 | |
| 5054 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5055 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5056 | testCases = append(testCases, testCase{ |
| 5057 | testType: serverTest, |
| 5058 | name: "OversizedSessionId-" + ver.name, |
| 5059 | config: Config{ |
| 5060 | MaxVersion: ver.version, |
| 5061 | Bugs: ProtocolBugs{ |
| 5062 | OversizedSessionId: true, |
| 5063 | }, |
| 5064 | }, |
| 5065 | resumeSession: true, |
| 5066 | shouldFail: true, |
| 5067 | expectedError: ":DECODE_ERROR:", |
| 5068 | }) |
| 5069 | } |
| 5070 | |
| 5071 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5072 | // are ignored. |
| 5073 | if ver.hasDTLS { |
| 5074 | testCases = append(testCases, testCase{ |
| 5075 | protocol: dtls, |
| 5076 | name: "SRTP-Client-" + ver.name, |
| 5077 | config: Config{ |
| 5078 | MaxVersion: ver.version, |
| 5079 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5080 | }, |
| 5081 | flags: []string{ |
| 5082 | "-srtp-profiles", |
| 5083 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5084 | }, |
| 5085 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5086 | }) |
| 5087 | testCases = append(testCases, testCase{ |
| 5088 | protocol: dtls, |
| 5089 | testType: serverTest, |
| 5090 | name: "SRTP-Server-" + ver.name, |
| 5091 | config: Config{ |
| 5092 | MaxVersion: ver.version, |
| 5093 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5094 | }, |
| 5095 | flags: []string{ |
| 5096 | "-srtp-profiles", |
| 5097 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5098 | }, |
| 5099 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5100 | }) |
| 5101 | // Test that the MKI is ignored. |
| 5102 | testCases = append(testCases, testCase{ |
| 5103 | protocol: dtls, |
| 5104 | testType: serverTest, |
| 5105 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5106 | config: Config{ |
| 5107 | MaxVersion: ver.version, |
| 5108 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5109 | Bugs: ProtocolBugs{ |
| 5110 | SRTPMasterKeyIdentifer: "bogus", |
| 5111 | }, |
| 5112 | }, |
| 5113 | flags: []string{ |
| 5114 | "-srtp-profiles", |
| 5115 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5116 | }, |
| 5117 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5118 | }) |
| 5119 | // Test that SRTP isn't negotiated on the server if there were |
| 5120 | // no matching profiles. |
| 5121 | testCases = append(testCases, testCase{ |
| 5122 | protocol: dtls, |
| 5123 | testType: serverTest, |
| 5124 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5125 | config: Config{ |
| 5126 | MaxVersion: ver.version, |
| 5127 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5128 | }, |
| 5129 | flags: []string{ |
| 5130 | "-srtp-profiles", |
| 5131 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5132 | }, |
| 5133 | expectedSRTPProtectionProfile: 0, |
| 5134 | }) |
| 5135 | // Test that the server returning an invalid SRTP profile is |
| 5136 | // flagged as an error by the client. |
| 5137 | testCases = append(testCases, testCase{ |
| 5138 | protocol: dtls, |
| 5139 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5140 | config: Config{ |
| 5141 | MaxVersion: ver.version, |
| 5142 | Bugs: ProtocolBugs{ |
| 5143 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5144 | }, |
| 5145 | }, |
| 5146 | flags: []string{ |
| 5147 | "-srtp-profiles", |
| 5148 | "SRTP_AES128_CM_SHA1_80", |
| 5149 | }, |
| 5150 | shouldFail: true, |
| 5151 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5152 | }) |
| 5153 | } |
| 5154 | |
| 5155 | // Test SCT list. |
| 5156 | testCases = append(testCases, testCase{ |
| 5157 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5158 | testType: clientTest, |
| 5159 | config: Config{ |
| 5160 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5161 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5162 | flags: []string{ |
| 5163 | "-enable-signed-cert-timestamps", |
| 5164 | "-expect-signed-cert-timestamps", |
| 5165 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5166 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5167 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5168 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5169 | |
| 5170 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5171 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5172 | testCases = append(testCases, testCase{ |
| 5173 | name: "SendSCTListOnResume-" + ver.name, |
| 5174 | config: Config{ |
| 5175 | MaxVersion: ver.version, |
| 5176 | Bugs: ProtocolBugs{ |
| 5177 | SendSCTListOnResume: []byte("bogus"), |
| 5178 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5179 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5180 | flags: []string{ |
| 5181 | "-enable-signed-cert-timestamps", |
| 5182 | "-expect-signed-cert-timestamps", |
| 5183 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5184 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5185 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5186 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5187 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5188 | testCases = append(testCases, testCase{ |
| 5189 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5190 | testType: serverTest, |
| 5191 | config: Config{ |
| 5192 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5193 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5194 | flags: []string{ |
| 5195 | "-signed-cert-timestamps", |
| 5196 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5197 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5198 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5199 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5200 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5201 | |
| 5202 | // Test that certificate-related extensions are not sent unsolicited. |
| 5203 | testCases = append(testCases, testCase{ |
| 5204 | testType: serverTest, |
| 5205 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5206 | config: Config{ |
| 5207 | MaxVersion: ver.version, |
| 5208 | Bugs: ProtocolBugs{ |
| 5209 | NoOCSPStapling: true, |
| 5210 | NoSignedCertificateTimestamps: true, |
| 5211 | }, |
| 5212 | }, |
| 5213 | flags: []string{ |
| 5214 | "-ocsp-response", |
| 5215 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5216 | "-signed-cert-timestamps", |
| 5217 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5218 | }, |
| 5219 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5220 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5221 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5222 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5223 | testType: clientTest, |
| 5224 | name: "ClientHelloPadding", |
| 5225 | config: Config{ |
| 5226 | Bugs: ProtocolBugs{ |
| 5227 | RequireClientHelloSize: 512, |
| 5228 | }, |
| 5229 | }, |
| 5230 | // This hostname just needs to be long enough to push the |
| 5231 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5232 | // long. |
| 5233 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5234 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5235 | |
| 5236 | // Extensions should not function in SSL 3.0. |
| 5237 | testCases = append(testCases, testCase{ |
| 5238 | testType: serverTest, |
| 5239 | name: "SSLv3Extensions-NoALPN", |
| 5240 | config: Config{ |
| 5241 | MaxVersion: VersionSSL30, |
| 5242 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5243 | }, |
| 5244 | flags: []string{ |
| 5245 | "-select-alpn", "foo", |
| 5246 | }, |
| 5247 | expectNoNextProto: true, |
| 5248 | }) |
| 5249 | |
| 5250 | // Test session tickets separately as they follow a different codepath. |
| 5251 | testCases = append(testCases, testCase{ |
| 5252 | testType: serverTest, |
| 5253 | name: "SSLv3Extensions-NoTickets", |
| 5254 | config: Config{ |
| 5255 | MaxVersion: VersionSSL30, |
| 5256 | Bugs: ProtocolBugs{ |
| 5257 | // Historically, session tickets in SSL 3.0 |
| 5258 | // failed in different ways depending on whether |
| 5259 | // the client supported renegotiation_info. |
| 5260 | NoRenegotiationInfo: true, |
| 5261 | }, |
| 5262 | }, |
| 5263 | resumeSession: true, |
| 5264 | }) |
| 5265 | testCases = append(testCases, testCase{ |
| 5266 | testType: serverTest, |
| 5267 | name: "SSLv3Extensions-NoTickets2", |
| 5268 | config: Config{ |
| 5269 | MaxVersion: VersionSSL30, |
| 5270 | }, |
| 5271 | resumeSession: true, |
| 5272 | }) |
| 5273 | |
| 5274 | // But SSL 3.0 does send and process renegotiation_info. |
| 5275 | testCases = append(testCases, testCase{ |
| 5276 | testType: serverTest, |
| 5277 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5278 | config: Config{ |
| 5279 | MaxVersion: VersionSSL30, |
| 5280 | Bugs: ProtocolBugs{ |
| 5281 | RequireRenegotiationInfo: true, |
| 5282 | }, |
| 5283 | }, |
| 5284 | }) |
| 5285 | testCases = append(testCases, testCase{ |
| 5286 | testType: serverTest, |
| 5287 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5288 | config: Config{ |
| 5289 | MaxVersion: VersionSSL30, |
| 5290 | Bugs: ProtocolBugs{ |
| 5291 | NoRenegotiationInfo: true, |
| 5292 | SendRenegotiationSCSV: true, |
| 5293 | RequireRenegotiationInfo: true, |
| 5294 | }, |
| 5295 | }, |
| 5296 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5297 | |
| 5298 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5299 | // in ServerHello. |
| 5300 | testCases = append(testCases, testCase{ |
| 5301 | name: "NPN-Forbidden-TLS13", |
| 5302 | config: Config{ |
| 5303 | MaxVersion: VersionTLS13, |
| 5304 | NextProtos: []string{"foo"}, |
| 5305 | Bugs: ProtocolBugs{ |
| 5306 | NegotiateNPNAtAllVersions: true, |
| 5307 | }, |
| 5308 | }, |
| 5309 | flags: []string{"-select-next-proto", "foo"}, |
| 5310 | shouldFail: true, |
| 5311 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5312 | }) |
| 5313 | testCases = append(testCases, testCase{ |
| 5314 | name: "EMS-Forbidden-TLS13", |
| 5315 | config: Config{ |
| 5316 | MaxVersion: VersionTLS13, |
| 5317 | Bugs: ProtocolBugs{ |
| 5318 | NegotiateEMSAtAllVersions: true, |
| 5319 | }, |
| 5320 | }, |
| 5321 | shouldFail: true, |
| 5322 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5323 | }) |
| 5324 | testCases = append(testCases, testCase{ |
| 5325 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5326 | config: Config{ |
| 5327 | MaxVersion: VersionTLS13, |
| 5328 | Bugs: ProtocolBugs{ |
| 5329 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5330 | }, |
| 5331 | }, |
| 5332 | shouldFail: true, |
| 5333 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5334 | }) |
| 5335 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5336 | name: "Ticket-Forbidden-TLS13", |
| 5337 | config: Config{ |
| 5338 | MaxVersion: VersionTLS12, |
| 5339 | }, |
| 5340 | resumeConfig: &Config{ |
| 5341 | MaxVersion: VersionTLS13, |
| 5342 | Bugs: ProtocolBugs{ |
| 5343 | AdvertiseTicketExtension: true, |
| 5344 | }, |
| 5345 | }, |
| 5346 | resumeSession: true, |
| 5347 | shouldFail: true, |
| 5348 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5349 | }) |
| 5350 | |
| 5351 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5352 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5353 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5354 | // implicit in every test.) |
| 5355 | testCases = append(testCases, testCase{ |
| 5356 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5357 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5358 | config: Config{ |
| 5359 | MaxVersion: VersionTLS13, |
| 5360 | NextProtos: []string{"bar"}, |
| 5361 | }, |
| 5362 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5363 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5364 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5365 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5366 | // tolerated. |
| 5367 | testCases = append(testCases, testCase{ |
| 5368 | name: "SendOCSPResponseOnResume-TLS12", |
| 5369 | config: Config{ |
| 5370 | MaxVersion: VersionTLS12, |
| 5371 | Bugs: ProtocolBugs{ |
| 5372 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5373 | }, |
| 5374 | }, |
| 5375 | flags: []string{ |
| 5376 | "-enable-ocsp-stapling", |
| 5377 | "-expect-ocsp-response", |
| 5378 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5379 | }, |
| 5380 | resumeSession: true, |
| 5381 | }) |
| 5382 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5383 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5384 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5385 | config: Config{ |
| 5386 | MaxVersion: VersionTLS13, |
| 5387 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5388 | SendExtensionOnCertificate: testOCSPExtension, |
| 5389 | }, |
| 5390 | }, |
| 5391 | shouldFail: true, |
| 5392 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5393 | }) |
| 5394 | |
| 5395 | testCases = append(testCases, testCase{ |
| 5396 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5397 | config: Config{ |
| 5398 | MaxVersion: VersionTLS13, |
| 5399 | Bugs: ProtocolBugs{ |
| 5400 | SendExtensionOnCertificate: testSCTExtension, |
| 5401 | }, |
| 5402 | }, |
| 5403 | shouldFail: true, |
| 5404 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5405 | }) |
| 5406 | |
| 5407 | // Test that extensions on client certificates are never accepted. |
| 5408 | testCases = append(testCases, testCase{ |
| 5409 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5410 | testType: serverTest, |
| 5411 | config: Config{ |
| 5412 | MaxVersion: VersionTLS13, |
| 5413 | Certificates: []Certificate{rsaCertificate}, |
| 5414 | Bugs: ProtocolBugs{ |
| 5415 | SendExtensionOnCertificate: testOCSPExtension, |
| 5416 | }, |
| 5417 | }, |
| 5418 | flags: []string{ |
| 5419 | "-enable-ocsp-stapling", |
| 5420 | "-require-any-client-certificate", |
| 5421 | }, |
| 5422 | shouldFail: true, |
| 5423 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5424 | }) |
| 5425 | |
| 5426 | testCases = append(testCases, testCase{ |
| 5427 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5428 | config: Config{ |
| 5429 | MaxVersion: VersionTLS13, |
| 5430 | Bugs: ProtocolBugs{ |
| 5431 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5432 | }, |
| 5433 | }, |
| 5434 | shouldFail: true, |
| 5435 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5436 | }) |
| 5437 | |
| 5438 | // Test that extensions on intermediates are allowed but ignored. |
| 5439 | testCases = append(testCases, testCase{ |
| 5440 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5441 | config: Config{ |
| 5442 | MaxVersion: VersionTLS13, |
| 5443 | Certificates: []Certificate{rsaChainCertificate}, |
| 5444 | Bugs: ProtocolBugs{ |
| 5445 | // Send different values on the intermediate. This tests |
| 5446 | // the intermediate's extensions do not override the |
| 5447 | // leaf's. |
| 5448 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
| 5449 | SendSCTOnIntermediates: []byte{1, 3, 3, 7}, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5450 | }, |
| 5451 | }, |
| 5452 | flags: []string{ |
| 5453 | "-enable-ocsp-stapling", |
| 5454 | "-expect-ocsp-response", |
| 5455 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5456 | "-enable-signed-cert-timestamps", |
| 5457 | "-expect-signed-cert-timestamps", |
| 5458 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5459 | }, |
| 5460 | resumeSession: true, |
| 5461 | }) |
| 5462 | |
| 5463 | // Test that extensions are not sent on intermediates when configured |
| 5464 | // only for a leaf. |
| 5465 | testCases = append(testCases, testCase{ |
| 5466 | testType: serverTest, |
| 5467 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5468 | config: Config{ |
| 5469 | MaxVersion: VersionTLS13, |
| 5470 | Bugs: ProtocolBugs{ |
| 5471 | ExpectNoExtensionsOnIntermediate: true, |
| 5472 | }, |
| 5473 | }, |
| 5474 | flags: []string{ |
| 5475 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5476 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5477 | "-ocsp-response", |
| 5478 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5479 | "-signed-cert-timestamps", |
| 5480 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5481 | }, |
| 5482 | }) |
| 5483 | |
| 5484 | // Test that extensions are not sent on client certificates. |
| 5485 | testCases = append(testCases, testCase{ |
| 5486 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5487 | config: Config{ |
| 5488 | MaxVersion: VersionTLS13, |
| 5489 | ClientAuth: RequireAnyClientCert, |
| 5490 | }, |
| 5491 | flags: []string{ |
| 5492 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5493 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5494 | "-ocsp-response", |
| 5495 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5496 | "-signed-cert-timestamps", |
| 5497 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5498 | }, |
| 5499 | }) |
| 5500 | |
| 5501 | testCases = append(testCases, testCase{ |
| 5502 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5503 | config: Config{ |
| 5504 | MaxVersion: VersionTLS13, |
| 5505 | Bugs: ProtocolBugs{ |
| 5506 | SendDuplicateCertExtensions: true, |
| 5507 | }, |
| 5508 | }, |
| 5509 | flags: []string{ |
| 5510 | "-enable-ocsp-stapling", |
| 5511 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5512 | }, |
| 5513 | resumeSession: true, |
| 5514 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5515 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5516 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5517 | } |
| 5518 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5519 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5520 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5521 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5522 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5523 | // have session IDs, so skip their cross-resumption |
| 5524 | // tests. |
| 5525 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5526 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5527 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5528 | } |
| 5529 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5530 | protocols := []protocol{tls} |
| 5531 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5532 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5533 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5534 | for _, protocol := range protocols { |
| 5535 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5536 | if protocol == dtls { |
| 5537 | suffix += "-DTLS" |
| 5538 | } |
| 5539 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5540 | if sessionVers.version == resumeVers.version { |
| 5541 | testCases = append(testCases, testCase{ |
| 5542 | protocol: protocol, |
| 5543 | name: "Resume-Client" + suffix, |
| 5544 | resumeSession: true, |
| 5545 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5546 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5547 | Bugs: ProtocolBugs{ |
| 5548 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5549 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5550 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5551 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5552 | expectedVersion: sessionVers.version, |
| 5553 | expectedResumeVersion: resumeVers.version, |
| 5554 | }) |
| 5555 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5556 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5557 | |
| 5558 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5559 | // there is no way to convince a non-lookahead client the |
| 5560 | // session was resumed. It will appear to the client that a |
| 5561 | // stray ChangeCipherSpec was sent. |
| 5562 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5563 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5564 | } |
| 5565 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5566 | testCases = append(testCases, testCase{ |
| 5567 | protocol: protocol, |
| 5568 | name: "Resume-Client-Mismatch" + suffix, |
| 5569 | resumeSession: true, |
| 5570 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5571 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5572 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5573 | expectedVersion: sessionVers.version, |
| 5574 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5575 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5576 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5577 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5578 | }, |
| 5579 | }, |
| 5580 | expectedResumeVersion: resumeVers.version, |
| 5581 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5582 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5583 | }) |
| 5584 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5585 | |
| 5586 | testCases = append(testCases, testCase{ |
| 5587 | protocol: protocol, |
| 5588 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5589 | resumeSession: true, |
| 5590 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5591 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5592 | }, |
| 5593 | expectedVersion: sessionVers.version, |
| 5594 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5595 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5596 | }, |
| 5597 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5598 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5599 | expectedResumeVersion: resumeVers.version, |
| 5600 | }) |
| 5601 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5602 | testCases = append(testCases, testCase{ |
| 5603 | protocol: protocol, |
| 5604 | testType: serverTest, |
| 5605 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5606 | resumeSession: true, |
| 5607 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5608 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5609 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5610 | expectedVersion: sessionVers.version, |
| 5611 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5612 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5613 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5614 | Bugs: ProtocolBugs{ |
| 5615 | SendBothTickets: true, |
| 5616 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5617 | }, |
| 5618 | expectedResumeVersion: resumeVers.version, |
| 5619 | }) |
| 5620 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5621 | } |
| 5622 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5623 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5624 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5625 | testCases = append(testCases, testCase{ |
| 5626 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5627 | name: "ShimTicketRewritable", |
| 5628 | resumeSession: true, |
| 5629 | config: Config{ |
| 5630 | MaxVersion: VersionTLS12, |
| 5631 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5632 | Bugs: ProtocolBugs{ |
| 5633 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5634 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5635 | if err != nil { |
| 5636 | return nil, err |
| 5637 | } |
| 5638 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5639 | }, |
| 5640 | }, |
| 5641 | }, |
| 5642 | flags: []string{ |
| 5643 | "-ticket-key", |
| 5644 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5645 | }, |
| 5646 | }) |
| 5647 | |
| 5648 | // Resumptions are declined if the version does not match. |
| 5649 | testCases = append(testCases, testCase{ |
| 5650 | testType: serverTest, |
| 5651 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5652 | resumeSession: true, |
| 5653 | config: Config{ |
| 5654 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5655 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5656 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5657 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5658 | return SetShimTicketVersion(in, VersionTLS13) |
| 5659 | }, |
| 5660 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5661 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5662 | flags: []string{ |
| 5663 | "-ticket-key", |
| 5664 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5665 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5666 | expectResumeRejected: true, |
| 5667 | }) |
| 5668 | |
| 5669 | testCases = append(testCases, testCase{ |
| 5670 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5671 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5672 | resumeSession: true, |
| 5673 | config: Config{ |
| 5674 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5675 | Bugs: ProtocolBugs{ |
| 5676 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5677 | return SetShimTicketVersion(in, VersionTLS12) |
| 5678 | }, |
| 5679 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5680 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5681 | flags: []string{ |
| 5682 | "-ticket-key", |
| 5683 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5684 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5685 | expectResumeRejected: true, |
| 5686 | }) |
| 5687 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5688 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5689 | testCases = append(testCases, testCase{ |
| 5690 | testType: serverTest, |
| 5691 | name: "Resume-Server-DeclineBadCipher", |
| 5692 | resumeSession: true, |
| 5693 | config: Config{ |
| 5694 | MaxVersion: VersionTLS12, |
| 5695 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5696 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5697 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5698 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5699 | }, |
| 5700 | }, |
| 5701 | }, |
| 5702 | flags: []string{ |
| 5703 | "-ticket-key", |
| 5704 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5705 | }, |
| 5706 | expectResumeRejected: true, |
| 5707 | }) |
| 5708 | |
| 5709 | testCases = append(testCases, testCase{ |
| 5710 | testType: serverTest, |
| 5711 | name: "Resume-Server-DeclineBadCipher-2", |
| 5712 | resumeSession: true, |
| 5713 | config: Config{ |
| 5714 | MaxVersion: VersionTLS12, |
| 5715 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5716 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5717 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5718 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5719 | }, |
| 5720 | }, |
| 5721 | }, |
| 5722 | flags: []string{ |
| 5723 | "-cipher", "AES128", |
| 5724 | "-ticket-key", |
| 5725 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5726 | }, |
| 5727 | expectResumeRejected: true, |
| 5728 | }) |
| 5729 | |
| 5730 | testCases = append(testCases, testCase{ |
| 5731 | testType: serverTest, |
| 5732 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5733 | resumeSession: true, |
| 5734 | config: Config{ |
| 5735 | MaxVersion: VersionTLS13, |
| 5736 | Bugs: ProtocolBugs{ |
| 5737 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5738 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5739 | }, |
| 5740 | }, |
| 5741 | }, |
| 5742 | flags: []string{ |
| 5743 | "-ticket-key", |
| 5744 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5745 | }, |
| 5746 | expectResumeRejected: true, |
| 5747 | }) |
| 5748 | |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5749 | // Clients must not advertise a session without also advertising the |
| 5750 | // cipher. |
| 5751 | testCases = append(testCases, testCase{ |
| 5752 | testType: serverTest, |
| 5753 | name: "Resume-Server-UnofferedCipher", |
| 5754 | resumeSession: true, |
| 5755 | config: Config{ |
| 5756 | MaxVersion: VersionTLS12, |
| 5757 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5758 | }, |
| 5759 | resumeConfig: &Config{ |
| 5760 | MaxVersion: VersionTLS12, |
| 5761 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5762 | Bugs: ProtocolBugs{ |
| 5763 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5764 | }, |
| 5765 | }, |
| 5766 | shouldFail: true, |
| 5767 | expectedError: ":REQUIRED_CIPHER_MISSING:", |
| 5768 | }) |
| 5769 | |
| 5770 | testCases = append(testCases, testCase{ |
| 5771 | testType: serverTest, |
| 5772 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5773 | resumeSession: true, |
| 5774 | config: Config{ |
| 5775 | MaxVersion: VersionTLS13, |
| 5776 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5777 | }, |
| 5778 | resumeConfig: &Config{ |
| 5779 | MaxVersion: VersionTLS13, |
| 5780 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5781 | Bugs: ProtocolBugs{ |
| 5782 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5783 | }, |
| 5784 | }, |
| 5785 | shouldFail: true, |
| 5786 | expectedError: ":REQUIRED_CIPHER_MISSING:", |
| 5787 | }) |
| 5788 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5789 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5790 | testCases = append(testCases, testCase{ |
| 5791 | name: "Resume-Client-CipherMismatch", |
| 5792 | resumeSession: true, |
| 5793 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5794 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5795 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5796 | }, |
| 5797 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5798 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5799 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5800 | Bugs: ProtocolBugs{ |
| 5801 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5802 | }, |
| 5803 | }, |
| 5804 | shouldFail: true, |
| 5805 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5806 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5807 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5808 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 5809 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5810 | testCases = append(testCases, testCase{ |
| 5811 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5812 | resumeSession: true, |
| 5813 | config: Config{ |
| 5814 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5815 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5816 | }, |
| 5817 | resumeConfig: &Config{ |
| 5818 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5819 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5820 | }, |
| 5821 | }) |
| 5822 | |
| 5823 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 5824 | testCases = append(testCases, testCase{ |
| 5825 | name: "Resume-Client-PRFMismatch-TLS13", |
| 5826 | resumeSession: true, |
| 5827 | config: Config{ |
| 5828 | MaxVersion: VersionTLS13, |
| 5829 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5830 | }, |
| 5831 | resumeConfig: &Config{ |
| 5832 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5833 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5834 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5835 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5836 | }, |
| 5837 | }, |
| 5838 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 5839 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5840 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5841 | |
| 5842 | testCases = append(testCases, testCase{ |
| 5843 | testType: serverTest, |
| 5844 | name: "Resume-Server-BinderWrongLength", |
| 5845 | resumeSession: true, |
| 5846 | config: Config{ |
| 5847 | MaxVersion: VersionTLS13, |
| 5848 | Bugs: ProtocolBugs{ |
| 5849 | SendShortPSKBinder: true, |
| 5850 | }, |
| 5851 | }, |
| 5852 | shouldFail: true, |
| 5853 | expectedLocalError: "remote error: error decrypting message", |
| 5854 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5855 | }) |
| 5856 | |
| 5857 | testCases = append(testCases, testCase{ |
| 5858 | testType: serverTest, |
| 5859 | name: "Resume-Server-NoPSKBinder", |
| 5860 | resumeSession: true, |
| 5861 | config: Config{ |
| 5862 | MaxVersion: VersionTLS13, |
| 5863 | Bugs: ProtocolBugs{ |
| 5864 | SendNoPSKBinder: true, |
| 5865 | }, |
| 5866 | }, |
| 5867 | shouldFail: true, |
| 5868 | expectedLocalError: "remote error: error decoding message", |
| 5869 | expectedError: ":DECODE_ERROR:", |
| 5870 | }) |
| 5871 | |
| 5872 | testCases = append(testCases, testCase{ |
| 5873 | testType: serverTest, |
| 5874 | name: "Resume-Server-InvalidPSKBinder", |
| 5875 | resumeSession: true, |
| 5876 | config: Config{ |
| 5877 | MaxVersion: VersionTLS13, |
| 5878 | Bugs: ProtocolBugs{ |
| 5879 | SendInvalidPSKBinder: true, |
| 5880 | }, |
| 5881 | }, |
| 5882 | shouldFail: true, |
| 5883 | expectedLocalError: "remote error: error decrypting message", |
| 5884 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 5885 | }) |
| 5886 | |
| 5887 | testCases = append(testCases, testCase{ |
| 5888 | testType: serverTest, |
| 5889 | name: "Resume-Server-PSKBinderFirstExtension", |
| 5890 | resumeSession: true, |
| 5891 | config: Config{ |
| 5892 | MaxVersion: VersionTLS13, |
| 5893 | Bugs: ProtocolBugs{ |
| 5894 | PSKBinderFirst: true, |
| 5895 | }, |
| 5896 | }, |
| 5897 | shouldFail: true, |
| 5898 | expectedLocalError: "remote error: illegal parameter", |
| 5899 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 5900 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5901 | } |
| 5902 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5903 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 5904 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5905 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5906 | testType: serverTest, |
| 5907 | name: "Renegotiate-Server-Forbidden", |
| 5908 | config: Config{ |
| 5909 | MaxVersion: VersionTLS12, |
| 5910 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5911 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5912 | shouldFail: true, |
| 5913 | expectedError: ":NO_RENEGOTIATION:", |
| 5914 | expectedLocalError: "remote error: no renegotiation", |
| 5915 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5916 | // The server shouldn't echo the renegotiation extension unless |
| 5917 | // requested by the client. |
| 5918 | testCases = append(testCases, testCase{ |
| 5919 | testType: serverTest, |
| 5920 | name: "Renegotiate-Server-NoExt", |
| 5921 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5922 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5923 | Bugs: ProtocolBugs{ |
| 5924 | NoRenegotiationInfo: true, |
| 5925 | RequireRenegotiationInfo: true, |
| 5926 | }, |
| 5927 | }, |
| 5928 | shouldFail: true, |
| 5929 | expectedLocalError: "renegotiation extension missing", |
| 5930 | }) |
| 5931 | // The renegotiation SCSV should be sufficient for the server to echo |
| 5932 | // the extension. |
| 5933 | testCases = append(testCases, testCase{ |
| 5934 | testType: serverTest, |
| 5935 | name: "Renegotiate-Server-NoExt-SCSV", |
| 5936 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5937 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5938 | Bugs: ProtocolBugs{ |
| 5939 | NoRenegotiationInfo: true, |
| 5940 | SendRenegotiationSCSV: true, |
| 5941 | RequireRenegotiationInfo: true, |
| 5942 | }, |
| 5943 | }, |
| 5944 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5945 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5946 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5947 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5948 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5949 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5950 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5951 | }, |
| 5952 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5953 | renegotiate: 1, |
| 5954 | flags: []string{ |
| 5955 | "-renegotiate-freely", |
| 5956 | "-expect-total-renegotiations", "1", |
| 5957 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5958 | }) |
| 5959 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5960 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5961 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5962 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5963 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5964 | Bugs: ProtocolBugs{ |
| 5965 | EmptyRenegotiationInfo: true, |
| 5966 | }, |
| 5967 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5968 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5969 | shouldFail: true, |
| 5970 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5971 | }) |
| 5972 | testCases = append(testCases, testCase{ |
| 5973 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5974 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5975 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5976 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5977 | Bugs: ProtocolBugs{ |
| 5978 | BadRenegotiationInfo: true, |
| 5979 | }, |
| 5980 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5981 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5982 | shouldFail: true, |
| 5983 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5984 | }) |
| 5985 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5986 | name: "Renegotiate-Client-Downgrade", |
| 5987 | renegotiate: 1, |
| 5988 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5989 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5990 | Bugs: ProtocolBugs{ |
| 5991 | NoRenegotiationInfoAfterInitial: true, |
| 5992 | }, |
| 5993 | }, |
| 5994 | flags: []string{"-renegotiate-freely"}, |
| 5995 | shouldFail: true, |
| 5996 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5997 | }) |
| 5998 | testCases = append(testCases, testCase{ |
| 5999 | name: "Renegotiate-Client-Upgrade", |
| 6000 | renegotiate: 1, |
| 6001 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6002 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6003 | Bugs: ProtocolBugs{ |
| 6004 | NoRenegotiationInfoInInitial: true, |
| 6005 | }, |
| 6006 | }, |
| 6007 | flags: []string{"-renegotiate-freely"}, |
| 6008 | shouldFail: true, |
| 6009 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6010 | }) |
| 6011 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6012 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6013 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6014 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6015 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6016 | Bugs: ProtocolBugs{ |
| 6017 | NoRenegotiationInfo: true, |
| 6018 | }, |
| 6019 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6020 | flags: []string{ |
| 6021 | "-renegotiate-freely", |
| 6022 | "-expect-total-renegotiations", "1", |
| 6023 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6024 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6025 | |
| 6026 | // Test that the server may switch ciphers on renegotiation without |
| 6027 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6028 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6029 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6030 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6031 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6032 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6033 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6034 | }, |
| 6035 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6036 | flags: []string{ |
| 6037 | "-renegotiate-freely", |
| 6038 | "-expect-total-renegotiations", "1", |
| 6039 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6040 | }) |
| 6041 | testCases = append(testCases, testCase{ |
| 6042 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6043 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6044 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6045 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6046 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6047 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6048 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6049 | flags: []string{ |
| 6050 | "-renegotiate-freely", |
| 6051 | "-expect-total-renegotiations", "1", |
| 6052 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6053 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6054 | |
| 6055 | // Test that the server may not switch versions on renegotiation. |
| 6056 | testCases = append(testCases, testCase{ |
| 6057 | name: "Renegotiate-Client-SwitchVersion", |
| 6058 | config: Config{ |
| 6059 | MaxVersion: VersionTLS12, |
| 6060 | // Pick a cipher which exists at both versions. |
| 6061 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6062 | Bugs: ProtocolBugs{ |
| 6063 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6064 | // Avoid failing early at the record layer. |
| 6065 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6066 | }, |
| 6067 | }, |
| 6068 | renegotiate: 1, |
| 6069 | flags: []string{ |
| 6070 | "-renegotiate-freely", |
| 6071 | "-expect-total-renegotiations", "1", |
| 6072 | }, |
| 6073 | shouldFail: true, |
| 6074 | expectedError: ":WRONG_SSL_VERSION:", |
| 6075 | }) |
| 6076 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6077 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6078 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6079 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6080 | config: Config{ |
| 6081 | MaxVersion: VersionTLS10, |
| 6082 | Bugs: ProtocolBugs{ |
| 6083 | RequireSameRenegoClientVersion: true, |
| 6084 | }, |
| 6085 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6086 | flags: []string{ |
| 6087 | "-renegotiate-freely", |
| 6088 | "-expect-total-renegotiations", "1", |
| 6089 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6090 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6091 | testCases = append(testCases, testCase{ |
| 6092 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6093 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6094 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6095 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6096 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6097 | NextProtos: []string{"foo"}, |
| 6098 | }, |
| 6099 | flags: []string{ |
| 6100 | "-false-start", |
| 6101 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6102 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6103 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6104 | }, |
| 6105 | shimWritesFirst: true, |
| 6106 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6107 | |
| 6108 | // Client-side renegotiation controls. |
| 6109 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6110 | name: "Renegotiate-Client-Forbidden-1", |
| 6111 | config: Config{ |
| 6112 | MaxVersion: VersionTLS12, |
| 6113 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6114 | renegotiate: 1, |
| 6115 | shouldFail: true, |
| 6116 | expectedError: ":NO_RENEGOTIATION:", |
| 6117 | expectedLocalError: "remote error: no renegotiation", |
| 6118 | }) |
| 6119 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6120 | name: "Renegotiate-Client-Once-1", |
| 6121 | config: Config{ |
| 6122 | MaxVersion: VersionTLS12, |
| 6123 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6124 | renegotiate: 1, |
| 6125 | flags: []string{ |
| 6126 | "-renegotiate-once", |
| 6127 | "-expect-total-renegotiations", "1", |
| 6128 | }, |
| 6129 | }) |
| 6130 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6131 | name: "Renegotiate-Client-Freely-1", |
| 6132 | config: Config{ |
| 6133 | MaxVersion: VersionTLS12, |
| 6134 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6135 | renegotiate: 1, |
| 6136 | flags: []string{ |
| 6137 | "-renegotiate-freely", |
| 6138 | "-expect-total-renegotiations", "1", |
| 6139 | }, |
| 6140 | }) |
| 6141 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6142 | name: "Renegotiate-Client-Once-2", |
| 6143 | config: Config{ |
| 6144 | MaxVersion: VersionTLS12, |
| 6145 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6146 | renegotiate: 2, |
| 6147 | flags: []string{"-renegotiate-once"}, |
| 6148 | shouldFail: true, |
| 6149 | expectedError: ":NO_RENEGOTIATION:", |
| 6150 | expectedLocalError: "remote error: no renegotiation", |
| 6151 | }) |
| 6152 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6153 | name: "Renegotiate-Client-Freely-2", |
| 6154 | config: Config{ |
| 6155 | MaxVersion: VersionTLS12, |
| 6156 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6157 | renegotiate: 2, |
| 6158 | flags: []string{ |
| 6159 | "-renegotiate-freely", |
| 6160 | "-expect-total-renegotiations", "2", |
| 6161 | }, |
| 6162 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6163 | testCases = append(testCases, testCase{ |
| 6164 | name: "Renegotiate-Client-NoIgnore", |
| 6165 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6166 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6167 | Bugs: ProtocolBugs{ |
| 6168 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6169 | }, |
| 6170 | }, |
| 6171 | shouldFail: true, |
| 6172 | expectedError: ":NO_RENEGOTIATION:", |
| 6173 | }) |
| 6174 | testCases = append(testCases, testCase{ |
| 6175 | name: "Renegotiate-Client-Ignore", |
| 6176 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6177 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6178 | Bugs: ProtocolBugs{ |
| 6179 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6180 | }, |
| 6181 | }, |
| 6182 | flags: []string{ |
| 6183 | "-renegotiate-ignore", |
| 6184 | "-expect-total-renegotiations", "0", |
| 6185 | }, |
| 6186 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6187 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6188 | // Renegotiation is not allowed at SSL 3.0. |
| 6189 | testCases = append(testCases, testCase{ |
| 6190 | name: "Renegotiate-Client-SSL3", |
| 6191 | config: Config{ |
| 6192 | MaxVersion: VersionSSL30, |
| 6193 | }, |
| 6194 | renegotiate: 1, |
| 6195 | flags: []string{ |
| 6196 | "-renegotiate-freely", |
| 6197 | "-expect-total-renegotiations", "1", |
| 6198 | }, |
| 6199 | shouldFail: true, |
| 6200 | expectedError: ":NO_RENEGOTIATION:", |
| 6201 | expectedLocalError: "remote error: no renegotiation", |
| 6202 | }) |
| 6203 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6204 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6205 | testCases = append(testCases, testCase{ |
| 6206 | name: "StrayHelloRequest", |
| 6207 | config: Config{ |
| 6208 | MaxVersion: VersionTLS12, |
| 6209 | Bugs: ProtocolBugs{ |
| 6210 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6211 | }, |
| 6212 | }, |
| 6213 | }) |
| 6214 | testCases = append(testCases, testCase{ |
| 6215 | name: "StrayHelloRequest-Packed", |
| 6216 | config: Config{ |
| 6217 | MaxVersion: VersionTLS12, |
| 6218 | Bugs: ProtocolBugs{ |
| 6219 | PackHandshakeFlight: true, |
| 6220 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6221 | }, |
| 6222 | }, |
| 6223 | }) |
| 6224 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6225 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6226 | // the same record. |
| 6227 | testCases = append(testCases, testCase{ |
| 6228 | name: "Renegotiate-Client-Packed", |
| 6229 | config: Config{ |
| 6230 | MaxVersion: VersionTLS12, |
| 6231 | Bugs: ProtocolBugs{ |
| 6232 | PackHandshakeFlight: true, |
| 6233 | PackHelloRequestWithFinished: true, |
| 6234 | }, |
| 6235 | }, |
| 6236 | renegotiate: 1, |
| 6237 | flags: []string{ |
| 6238 | "-renegotiate-freely", |
| 6239 | "-expect-total-renegotiations", "1", |
| 6240 | }, |
| 6241 | }) |
| 6242 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6243 | // Renegotiation is forbidden in TLS 1.3. |
| 6244 | testCases = append(testCases, testCase{ |
| 6245 | name: "Renegotiate-Client-TLS13", |
| 6246 | config: Config{ |
| 6247 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6248 | Bugs: ProtocolBugs{ |
| 6249 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6250 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6251 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6252 | flags: []string{ |
| 6253 | "-renegotiate-freely", |
| 6254 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6255 | shouldFail: true, |
| 6256 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6257 | }) |
| 6258 | |
| 6259 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6260 | testCases = append(testCases, testCase{ |
| 6261 | name: "StrayHelloRequest-TLS13", |
| 6262 | config: Config{ |
| 6263 | MaxVersion: VersionTLS13, |
| 6264 | Bugs: ProtocolBugs{ |
| 6265 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6266 | }, |
| 6267 | }, |
| 6268 | shouldFail: true, |
| 6269 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6270 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6271 | } |
| 6272 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6273 | func addDTLSReplayTests() { |
| 6274 | // Test that sequence number replays are detected. |
| 6275 | testCases = append(testCases, testCase{ |
| 6276 | protocol: dtls, |
| 6277 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6278 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6279 | replayWrites: true, |
| 6280 | }) |
| 6281 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6282 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6283 | // than the retransmit window. |
| 6284 | testCases = append(testCases, testCase{ |
| 6285 | protocol: dtls, |
| 6286 | name: "DTLS-Replay-LargeGaps", |
| 6287 | config: Config{ |
| 6288 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6289 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6290 | return in * 127 |
| 6291 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6292 | }, |
| 6293 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6294 | messageCount: 200, |
| 6295 | replayWrites: true, |
| 6296 | }) |
| 6297 | |
| 6298 | // Test the incoming sequence number changing non-monotonically. |
| 6299 | testCases = append(testCases, testCase{ |
| 6300 | protocol: dtls, |
| 6301 | name: "DTLS-Replay-NonMonotonic", |
| 6302 | config: Config{ |
| 6303 | Bugs: ProtocolBugs{ |
| 6304 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6305 | return in ^ 31 |
| 6306 | }, |
| 6307 | }, |
| 6308 | }, |
| 6309 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6310 | replayWrites: true, |
| 6311 | }) |
| 6312 | } |
| 6313 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6314 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6315 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6316 | id signatureAlgorithm |
| 6317 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6318 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6319 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6320 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6321 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6322 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6323 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6324 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6325 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6326 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6327 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6328 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6329 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6330 | // Tests for key types prior to TLS 1.2. |
| 6331 | {"RSA", 0, testCertRSA}, |
| 6332 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6333 | } |
| 6334 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6335 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6336 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6337 | |
| 6338 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6339 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6340 | // versions a signing cipher. |
| 6341 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6342 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6343 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6344 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6345 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6346 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 6347 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 6348 | } |
| 6349 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6350 | var allAlgorithms []signatureAlgorithm |
| 6351 | for _, alg := range testSignatureAlgorithms { |
| 6352 | if alg.id != 0 { |
| 6353 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6354 | } |
| 6355 | } |
| 6356 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6357 | // Make sure each signature algorithm works. Include some fake values in |
| 6358 | // the list and ensure they're ignored. |
| 6359 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6360 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6361 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6362 | continue |
| 6363 | } |
| 6364 | |
| 6365 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6366 | // or remove it in C. |
| 6367 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6368 | continue |
| 6369 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6370 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6371 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6372 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6373 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6374 | shouldSignFail = true |
| 6375 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6376 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6377 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6378 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6379 | shouldSignFail = true |
| 6380 | shouldVerifyFail = true |
| 6381 | } |
| 6382 | |
| 6383 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6384 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6385 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6386 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6387 | |
| 6388 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6389 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6390 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6391 | } |
| 6392 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6393 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6394 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6395 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6396 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6397 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6398 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6399 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6400 | config: Config{ |
| 6401 | MaxVersion: ver.version, |
| 6402 | ClientAuth: RequireAnyClientCert, |
| 6403 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6404 | fakeSigAlg1, |
| 6405 | alg.id, |
| 6406 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6407 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6408 | }, |
| 6409 | flags: []string{ |
| 6410 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6411 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6412 | "-enable-all-curves", |
| 6413 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6414 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6415 | expectedError: signError, |
| 6416 | expectedPeerSignatureAlgorithm: alg.id, |
| 6417 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6418 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6419 | testCases = append(testCases, testCase{ |
| 6420 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6421 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6422 | config: Config{ |
| 6423 | MaxVersion: ver.version, |
| 6424 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6425 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6426 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6427 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6428 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6429 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6430 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6431 | // Some signature algorithms may not be advertised. |
| 6432 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6433 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6434 | }, |
| 6435 | flags: []string{ |
| 6436 | "-require-any-client-certificate", |
| 6437 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6438 | "-enable-all-curves", |
| 6439 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6440 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6441 | expectedError: verifyError, |
| 6442 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6443 | |
| 6444 | testCases = append(testCases, testCase{ |
| 6445 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6446 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6447 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6448 | MaxVersion: ver.version, |
| 6449 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6450 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6451 | fakeSigAlg1, |
| 6452 | alg.id, |
| 6453 | fakeSigAlg2, |
| 6454 | }, |
| 6455 | }, |
| 6456 | flags: []string{ |
| 6457 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6458 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6459 | "-enable-all-curves", |
| 6460 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6461 | shouldFail: shouldSignFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6462 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6463 | expectedPeerSignatureAlgorithm: alg.id, |
| 6464 | }) |
| 6465 | |
| 6466 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6467 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6468 | config: Config{ |
| 6469 | MaxVersion: ver.version, |
| 6470 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6471 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6472 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6473 | alg.id, |
| 6474 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6475 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6476 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6477 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6478 | // Some signature algorithms may not be advertised. |
| 6479 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6480 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6481 | }, |
| 6482 | flags: []string{ |
| 6483 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6484 | "-enable-all-curves", |
| 6485 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6486 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6487 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6488 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6489 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6490 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6491 | testCases = append(testCases, testCase{ |
| 6492 | testType: serverTest, |
| 6493 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6494 | config: Config{ |
| 6495 | MaxVersion: ver.version, |
| 6496 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6497 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6498 | alg.id, |
| 6499 | }, |
| 6500 | Bugs: ProtocolBugs{ |
| 6501 | InvalidSignature: true, |
| 6502 | }, |
| 6503 | }, |
| 6504 | flags: []string{ |
| 6505 | "-require-any-client-certificate", |
| 6506 | "-enable-all-curves", |
| 6507 | }, |
| 6508 | shouldFail: true, |
| 6509 | expectedError: ":BAD_SIGNATURE:", |
| 6510 | }) |
| 6511 | |
| 6512 | testCases = append(testCases, testCase{ |
| 6513 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6514 | config: Config{ |
| 6515 | MaxVersion: ver.version, |
| 6516 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6517 | CipherSuites: signingCiphers, |
| 6518 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6519 | alg.id, |
| 6520 | }, |
| 6521 | Bugs: ProtocolBugs{ |
| 6522 | InvalidSignature: true, |
| 6523 | }, |
| 6524 | }, |
| 6525 | flags: []string{"-enable-all-curves"}, |
| 6526 | shouldFail: true, |
| 6527 | expectedError: ":BAD_SIGNATURE:", |
| 6528 | }) |
| 6529 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6530 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6531 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6532 | testCases = append(testCases, testCase{ |
| 6533 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6534 | config: Config{ |
| 6535 | MaxVersion: ver.version, |
| 6536 | ClientAuth: RequireAnyClientCert, |
| 6537 | VerifySignatureAlgorithms: allAlgorithms, |
| 6538 | }, |
| 6539 | flags: []string{ |
| 6540 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6541 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6542 | "-enable-all-curves", |
| 6543 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6544 | }, |
| 6545 | expectedPeerSignatureAlgorithm: alg.id, |
| 6546 | }) |
| 6547 | |
| 6548 | testCases = append(testCases, testCase{ |
| 6549 | testType: serverTest, |
| 6550 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6551 | config: Config{ |
| 6552 | MaxVersion: ver.version, |
| 6553 | CipherSuites: signingCiphers, |
| 6554 | VerifySignatureAlgorithms: allAlgorithms, |
| 6555 | }, |
| 6556 | flags: []string{ |
| 6557 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6558 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6559 | "-enable-all-curves", |
| 6560 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6561 | }, |
| 6562 | expectedPeerSignatureAlgorithm: alg.id, |
| 6563 | }) |
| 6564 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6565 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6566 | } |
| 6567 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6568 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6569 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6570 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6571 | config: Config{ |
| 6572 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6573 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6574 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6575 | signatureECDSAWithP521AndSHA512, |
| 6576 | signatureRSAPKCS1WithSHA384, |
| 6577 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6578 | }, |
| 6579 | }, |
| 6580 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6581 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6582 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6583 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6584 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6585 | }) |
| 6586 | |
| 6587 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6588 | name: "ClientAuth-SignatureType-TLS13", |
| 6589 | config: Config{ |
| 6590 | ClientAuth: RequireAnyClientCert, |
| 6591 | MaxVersion: VersionTLS13, |
| 6592 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6593 | signatureECDSAWithP521AndSHA512, |
| 6594 | signatureRSAPKCS1WithSHA384, |
| 6595 | signatureRSAPSSWithSHA384, |
| 6596 | signatureECDSAWithSHA1, |
| 6597 | }, |
| 6598 | }, |
| 6599 | flags: []string{ |
| 6600 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6601 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6602 | }, |
| 6603 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6604 | }) |
| 6605 | |
| 6606 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6607 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6608 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6609 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6610 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6611 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6612 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6613 | signatureECDSAWithP521AndSHA512, |
| 6614 | signatureRSAPKCS1WithSHA384, |
| 6615 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6616 | }, |
| 6617 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6618 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6619 | }) |
| 6620 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6621 | testCases = append(testCases, testCase{ |
| 6622 | testType: serverTest, |
| 6623 | name: "ServerAuth-SignatureType-TLS13", |
| 6624 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6625 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6626 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6627 | signatureECDSAWithP521AndSHA512, |
| 6628 | signatureRSAPKCS1WithSHA384, |
| 6629 | signatureRSAPSSWithSHA384, |
| 6630 | signatureECDSAWithSHA1, |
| 6631 | }, |
| 6632 | }, |
| 6633 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6634 | }) |
| 6635 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6636 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6637 | testCases = append(testCases, testCase{ |
| 6638 | testType: serverTest, |
| 6639 | name: "Verify-ClientAuth-SignatureType", |
| 6640 | config: Config{ |
| 6641 | MaxVersion: VersionTLS12, |
| 6642 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6643 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6644 | signatureRSAPKCS1WithSHA256, |
| 6645 | }, |
| 6646 | Bugs: ProtocolBugs{ |
| 6647 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6648 | }, |
| 6649 | }, |
| 6650 | flags: []string{ |
| 6651 | "-require-any-client-certificate", |
| 6652 | }, |
| 6653 | shouldFail: true, |
| 6654 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6655 | }) |
| 6656 | |
| 6657 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6658 | testType: serverTest, |
| 6659 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 6660 | config: Config{ |
| 6661 | MaxVersion: VersionTLS13, |
| 6662 | Certificates: []Certificate{rsaCertificate}, |
| 6663 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6664 | signatureRSAPSSWithSHA256, |
| 6665 | }, |
| 6666 | Bugs: ProtocolBugs{ |
| 6667 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6668 | }, |
| 6669 | }, |
| 6670 | flags: []string{ |
| 6671 | "-require-any-client-certificate", |
| 6672 | }, |
| 6673 | shouldFail: true, |
| 6674 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6675 | }) |
| 6676 | |
| 6677 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6678 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6679 | config: Config{ |
| 6680 | MaxVersion: VersionTLS12, |
| 6681 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6682 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6683 | signatureRSAPKCS1WithSHA256, |
| 6684 | }, |
| 6685 | Bugs: ProtocolBugs{ |
| 6686 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6687 | }, |
| 6688 | }, |
| 6689 | shouldFail: true, |
| 6690 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6691 | }) |
| 6692 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6693 | testCases = append(testCases, testCase{ |
| 6694 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 6695 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6696 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6697 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6698 | signatureRSAPSSWithSHA256, |
| 6699 | }, |
| 6700 | Bugs: ProtocolBugs{ |
| 6701 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6702 | }, |
| 6703 | }, |
| 6704 | shouldFail: true, |
| 6705 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6706 | }) |
| 6707 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6708 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 6709 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6710 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6711 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6712 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6713 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6714 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6715 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6716 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6717 | }, |
| 6718 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6719 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6720 | }, |
| 6721 | }, |
| 6722 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6723 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6724 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6725 | }, |
| 6726 | }) |
| 6727 | |
| 6728 | testCases = append(testCases, testCase{ |
| 6729 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6730 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6731 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6732 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6733 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6734 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6735 | }, |
| 6736 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6737 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6738 | }, |
| 6739 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 6740 | flags: []string{ |
| 6741 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6742 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6743 | }, |
| 6744 | }) |
| 6745 | |
| 6746 | testCases = append(testCases, testCase{ |
| 6747 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 6748 | config: Config{ |
| 6749 | MaxVersion: VersionTLS12, |
| 6750 | ClientAuth: RequireAnyClientCert, |
| 6751 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6752 | signatureECDSAWithSHA1, |
| 6753 | }, |
| 6754 | Bugs: ProtocolBugs{ |
| 6755 | NoSignatureAlgorithms: true, |
| 6756 | }, |
| 6757 | }, |
| 6758 | flags: []string{ |
| 6759 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6760 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6761 | }, |
| 6762 | }) |
| 6763 | |
| 6764 | testCases = append(testCases, testCase{ |
| 6765 | testType: serverTest, |
| 6766 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6767 | config: Config{ |
| 6768 | MaxVersion: VersionTLS12, |
| 6769 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6770 | signatureECDSAWithSHA1, |
| 6771 | }, |
| 6772 | Bugs: ProtocolBugs{ |
| 6773 | NoSignatureAlgorithms: true, |
| 6774 | }, |
| 6775 | }, |
| 6776 | flags: []string{ |
| 6777 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6778 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6779 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6780 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6781 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6782 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6783 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6784 | config: Config{ |
| 6785 | MaxVersion: VersionTLS13, |
| 6786 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6787 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6788 | signatureRSAPKCS1WithSHA1, |
| 6789 | }, |
| 6790 | Bugs: ProtocolBugs{ |
| 6791 | NoSignatureAlgorithms: true, |
| 6792 | }, |
| 6793 | }, |
| 6794 | flags: []string{ |
| 6795 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6796 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6797 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6798 | shouldFail: true, |
| 6799 | // An empty CertificateRequest signature algorithm list is a |
| 6800 | // syntax error in TLS 1.3. |
| 6801 | expectedError: ":DECODE_ERROR:", |
| 6802 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6803 | }) |
| 6804 | |
| 6805 | testCases = append(testCases, testCase{ |
| 6806 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6807 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6808 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6809 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6810 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6811 | signatureRSAPKCS1WithSHA1, |
| 6812 | }, |
| 6813 | Bugs: ProtocolBugs{ |
| 6814 | NoSignatureAlgorithms: true, |
| 6815 | }, |
| 6816 | }, |
| 6817 | shouldFail: true, |
| 6818 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6819 | }) |
| 6820 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6821 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6822 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6823 | testCases = append(testCases, testCase{ |
| 6824 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6825 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6826 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6827 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6828 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6829 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6830 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6831 | }, |
| 6832 | Bugs: ProtocolBugs{ |
| 6833 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6834 | }, |
| 6835 | }, |
| 6836 | flags: []string{"-require-any-client-certificate"}, |
| 6837 | shouldFail: true, |
| 6838 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6839 | }) |
| 6840 | |
| 6841 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6842 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6843 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6844 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6845 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6846 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6847 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6848 | }, |
| 6849 | Bugs: ProtocolBugs{ |
| 6850 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6851 | }, |
| 6852 | }, |
| 6853 | shouldFail: true, |
| 6854 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6855 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6856 | testCases = append(testCases, testCase{ |
| 6857 | testType: serverTest, |
| 6858 | name: "ClientAuth-Enforced-TLS13", |
| 6859 | config: Config{ |
| 6860 | MaxVersion: VersionTLS13, |
| 6861 | Certificates: []Certificate{rsaCertificate}, |
| 6862 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6863 | signatureRSAPKCS1WithMD5, |
| 6864 | }, |
| 6865 | Bugs: ProtocolBugs{ |
| 6866 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6867 | IgnoreSignatureVersionChecks: true, |
| 6868 | }, |
| 6869 | }, |
| 6870 | flags: []string{"-require-any-client-certificate"}, |
| 6871 | shouldFail: true, |
| 6872 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6873 | }) |
| 6874 | |
| 6875 | testCases = append(testCases, testCase{ |
| 6876 | name: "ServerAuth-Enforced-TLS13", |
| 6877 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6878 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6879 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6880 | signatureRSAPKCS1WithMD5, |
| 6881 | }, |
| 6882 | Bugs: ProtocolBugs{ |
| 6883 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6884 | IgnoreSignatureVersionChecks: true, |
| 6885 | }, |
| 6886 | }, |
| 6887 | shouldFail: true, |
| 6888 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6889 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6890 | |
| 6891 | // Test that the agreed upon digest respects the client preferences and |
| 6892 | // the server digests. |
| 6893 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6894 | name: "NoCommonAlgorithms-Digests", |
| 6895 | config: Config{ |
| 6896 | MaxVersion: VersionTLS12, |
| 6897 | ClientAuth: RequireAnyClientCert, |
| 6898 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6899 | signatureRSAPKCS1WithSHA512, |
| 6900 | signatureRSAPKCS1WithSHA1, |
| 6901 | }, |
| 6902 | }, |
| 6903 | flags: []string{ |
| 6904 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6905 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6906 | "-digest-prefs", "SHA256", |
| 6907 | }, |
| 6908 | shouldFail: true, |
| 6909 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6910 | }) |
| 6911 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6912 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6913 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6914 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6915 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6916 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6917 | signatureRSAPKCS1WithSHA512, |
| 6918 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6919 | }, |
| 6920 | }, |
| 6921 | flags: []string{ |
| 6922 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6923 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6924 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6925 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6926 | shouldFail: true, |
| 6927 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6928 | }) |
| 6929 | testCases = append(testCases, testCase{ |
| 6930 | name: "NoCommonAlgorithms-TLS13", |
| 6931 | config: Config{ |
| 6932 | MaxVersion: VersionTLS13, |
| 6933 | ClientAuth: RequireAnyClientCert, |
| 6934 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6935 | signatureRSAPSSWithSHA512, |
| 6936 | signatureRSAPSSWithSHA384, |
| 6937 | }, |
| 6938 | }, |
| 6939 | flags: []string{ |
| 6940 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6941 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6942 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 6943 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6944 | shouldFail: true, |
| 6945 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6946 | }) |
| 6947 | testCases = append(testCases, testCase{ |
| 6948 | name: "Agree-Digest-SHA256", |
| 6949 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6950 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6951 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6952 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6953 | signatureRSAPKCS1WithSHA1, |
| 6954 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6955 | }, |
| 6956 | }, |
| 6957 | flags: []string{ |
| 6958 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6959 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6960 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6961 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6962 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6963 | }) |
| 6964 | testCases = append(testCases, testCase{ |
| 6965 | name: "Agree-Digest-SHA1", |
| 6966 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6967 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6968 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6969 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6970 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6971 | }, |
| 6972 | }, |
| 6973 | flags: []string{ |
| 6974 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6975 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6976 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6977 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6978 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6979 | }) |
| 6980 | testCases = append(testCases, testCase{ |
| 6981 | name: "Agree-Digest-Default", |
| 6982 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6983 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6984 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6985 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6986 | signatureRSAPKCS1WithSHA256, |
| 6987 | signatureECDSAWithP256AndSHA256, |
| 6988 | signatureRSAPKCS1WithSHA1, |
| 6989 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6990 | }, |
| 6991 | }, |
| 6992 | flags: []string{ |
| 6993 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6994 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6995 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6996 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6997 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6998 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6999 | // Test that the signing preference list may include extra algorithms |
| 7000 | // without negotiation problems. |
| 7001 | testCases = append(testCases, testCase{ |
| 7002 | testType: serverTest, |
| 7003 | name: "FilterExtraAlgorithms", |
| 7004 | config: Config{ |
| 7005 | MaxVersion: VersionTLS12, |
| 7006 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7007 | signatureRSAPKCS1WithSHA256, |
| 7008 | }, |
| 7009 | }, |
| 7010 | flags: []string{ |
| 7011 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7012 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7013 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7014 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7015 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7016 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7017 | }, |
| 7018 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7019 | }) |
| 7020 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7021 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7022 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7023 | testCases = append(testCases, testCase{ |
| 7024 | name: "CheckLeafCurve", |
| 7025 | config: Config{ |
| 7026 | MaxVersion: VersionTLS12, |
| 7027 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7028 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7029 | }, |
| 7030 | flags: []string{"-p384-only"}, |
| 7031 | shouldFail: true, |
| 7032 | expectedError: ":BAD_ECC_CERT:", |
| 7033 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7034 | |
| 7035 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7036 | testCases = append(testCases, testCase{ |
| 7037 | name: "CheckLeafCurve-TLS13", |
| 7038 | config: Config{ |
| 7039 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7040 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7041 | }, |
| 7042 | flags: []string{"-p384-only"}, |
| 7043 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7044 | |
| 7045 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7046 | testCases = append(testCases, testCase{ |
| 7047 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7048 | config: Config{ |
| 7049 | MaxVersion: VersionTLS12, |
| 7050 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7051 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7052 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7053 | signatureECDSAWithP384AndSHA384, |
| 7054 | }, |
| 7055 | }, |
| 7056 | }) |
| 7057 | |
| 7058 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7059 | testCases = append(testCases, testCase{ |
| 7060 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7061 | config: Config{ |
| 7062 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7063 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7064 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7065 | signatureECDSAWithP384AndSHA384, |
| 7066 | }, |
| 7067 | Bugs: ProtocolBugs{ |
| 7068 | SkipECDSACurveCheck: true, |
| 7069 | }, |
| 7070 | }, |
| 7071 | shouldFail: true, |
| 7072 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7073 | }) |
| 7074 | |
| 7075 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7076 | // account. |
| 7077 | testCases = append(testCases, testCase{ |
| 7078 | testType: serverTest, |
| 7079 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7080 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7081 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7082 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7083 | signatureECDSAWithP384AndSHA384, |
| 7084 | signatureECDSAWithP256AndSHA256, |
| 7085 | }, |
| 7086 | }, |
| 7087 | flags: []string{ |
| 7088 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7089 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7090 | }, |
| 7091 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7092 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7093 | |
| 7094 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7095 | // server does not attempt to sign in that case. |
| 7096 | testCases = append(testCases, testCase{ |
| 7097 | testType: serverTest, |
| 7098 | name: "RSA-PSS-Large", |
| 7099 | config: Config{ |
| 7100 | MaxVersion: VersionTLS13, |
| 7101 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7102 | signatureRSAPSSWithSHA512, |
| 7103 | }, |
| 7104 | }, |
| 7105 | flags: []string{ |
| 7106 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7107 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7108 | }, |
| 7109 | shouldFail: true, |
| 7110 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7111 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7112 | |
| 7113 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7114 | testCases = append(testCases, testCase{ |
| 7115 | testType: clientTest, |
| 7116 | name: "RSA-PSS-Default-Verify", |
| 7117 | config: Config{ |
| 7118 | MaxVersion: VersionTLS12, |
| 7119 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7120 | signatureRSAPSSWithSHA256, |
| 7121 | }, |
| 7122 | }, |
| 7123 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7124 | }) |
| 7125 | |
| 7126 | testCases = append(testCases, testCase{ |
| 7127 | testType: serverTest, |
| 7128 | name: "RSA-PSS-Default-Sign", |
| 7129 | config: Config{ |
| 7130 | MaxVersion: VersionTLS12, |
| 7131 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7132 | signatureRSAPSSWithSHA256, |
| 7133 | }, |
| 7134 | }, |
| 7135 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7136 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7137 | } |
| 7138 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7139 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7140 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7141 | var timeouts = []time.Duration{ |
| 7142 | 1 * time.Second, |
| 7143 | 2 * time.Second, |
| 7144 | 4 * time.Second, |
| 7145 | 8 * time.Second, |
| 7146 | 16 * time.Second, |
| 7147 | 32 * time.Second, |
| 7148 | 60 * time.Second, |
| 7149 | 60 * time.Second, |
| 7150 | 60 * time.Second, |
| 7151 | 60 * time.Second, |
| 7152 | 60 * time.Second, |
| 7153 | 60 * time.Second, |
| 7154 | 60 * time.Second, |
| 7155 | } |
| 7156 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7157 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7158 | // initial timeout duration was set to 250ms. |
| 7159 | var shortTimeouts = []time.Duration{ |
| 7160 | 250 * time.Millisecond, |
| 7161 | 500 * time.Millisecond, |
| 7162 | 1 * time.Second, |
| 7163 | 2 * time.Second, |
| 7164 | 4 * time.Second, |
| 7165 | 8 * time.Second, |
| 7166 | 16 * time.Second, |
| 7167 | 32 * time.Second, |
| 7168 | 60 * time.Second, |
| 7169 | 60 * time.Second, |
| 7170 | 60 * time.Second, |
| 7171 | 60 * time.Second, |
| 7172 | 60 * time.Second, |
| 7173 | } |
| 7174 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7175 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7176 | // These tests work by coordinating some behavior on both the shim and |
| 7177 | // the runner. |
| 7178 | // |
| 7179 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7180 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7181 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7182 | // timeout in the shim and acts as a synchronization point to help the |
| 7183 | // runner bracket each handshake flight. |
| 7184 | // |
| 7185 | // We assume the shim does not read from the channel eagerly. It must |
| 7186 | // first wait until it has sent flight N and is ready to receive |
| 7187 | // handshake flight N+1. At this point, it will process the timeout |
| 7188 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7189 | // as if the shim was idle for the specified amount of time. |
| 7190 | // |
| 7191 | // The runner then drops all packets received before the ACK and |
| 7192 | // continues waiting for flight N. This ordering results in one attempt |
| 7193 | // at sending flight N to be dropped. For the test to complete, the |
| 7194 | // shim must send flight N again, testing that the shim implements DTLS |
| 7195 | // retransmit on a timeout. |
| 7196 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7197 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7198 | // likely be more epochs to cross and the final message's retransmit may |
| 7199 | // be more complex. |
| 7200 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7201 | for _, async := range []bool{true, false} { |
| 7202 | var tests []testCase |
| 7203 | |
| 7204 | // Test that this is indeed the timeout schedule. Stress all |
| 7205 | // four patterns of handshake. |
| 7206 | for i := 1; i < len(timeouts); i++ { |
| 7207 | number := strconv.Itoa(i) |
| 7208 | tests = append(tests, testCase{ |
| 7209 | protocol: dtls, |
| 7210 | name: "DTLS-Retransmit-Client-" + number, |
| 7211 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7212 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7213 | Bugs: ProtocolBugs{ |
| 7214 | TimeoutSchedule: timeouts[:i], |
| 7215 | }, |
| 7216 | }, |
| 7217 | resumeSession: true, |
| 7218 | }) |
| 7219 | tests = append(tests, testCase{ |
| 7220 | protocol: dtls, |
| 7221 | testType: serverTest, |
| 7222 | name: "DTLS-Retransmit-Server-" + number, |
| 7223 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7224 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7225 | Bugs: ProtocolBugs{ |
| 7226 | TimeoutSchedule: timeouts[:i], |
| 7227 | }, |
| 7228 | }, |
| 7229 | resumeSession: true, |
| 7230 | }) |
| 7231 | } |
| 7232 | |
| 7233 | // Test that exceeding the timeout schedule hits a read |
| 7234 | // timeout. |
| 7235 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7236 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7237 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7238 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7239 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7240 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7241 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7242 | }, |
| 7243 | }, |
| 7244 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7245 | shouldFail: true, |
| 7246 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7247 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7248 | |
| 7249 | if async { |
| 7250 | // Test that timeout handling has a fudge factor, due to API |
| 7251 | // problems. |
| 7252 | tests = append(tests, testCase{ |
| 7253 | protocol: dtls, |
| 7254 | name: "DTLS-Retransmit-Fudge", |
| 7255 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7256 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7257 | Bugs: ProtocolBugs{ |
| 7258 | TimeoutSchedule: []time.Duration{ |
| 7259 | timeouts[0] - 10*time.Millisecond, |
| 7260 | }, |
| 7261 | }, |
| 7262 | }, |
| 7263 | resumeSession: true, |
| 7264 | }) |
| 7265 | } |
| 7266 | |
| 7267 | // Test that the final Finished retransmitting isn't |
| 7268 | // duplicated if the peer badly fragments everything. |
| 7269 | tests = append(tests, testCase{ |
| 7270 | testType: serverTest, |
| 7271 | protocol: dtls, |
| 7272 | name: "DTLS-Retransmit-Fragmented", |
| 7273 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7274 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7275 | Bugs: ProtocolBugs{ |
| 7276 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7277 | MaxHandshakeRecordLength: 2, |
| 7278 | }, |
| 7279 | }, |
| 7280 | }) |
| 7281 | |
| 7282 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7283 | tests = append(tests, testCase{ |
| 7284 | protocol: dtls, |
| 7285 | name: "DTLS-Retransmit-Short-Client", |
| 7286 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7287 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7288 | Bugs: ProtocolBugs{ |
| 7289 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7290 | }, |
| 7291 | }, |
| 7292 | resumeSession: true, |
| 7293 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 7294 | }) |
| 7295 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7296 | protocol: dtls, |
| 7297 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7298 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7299 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7300 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7301 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7302 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7303 | }, |
| 7304 | }, |
| 7305 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7306 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7307 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7308 | |
| 7309 | for _, test := range tests { |
| 7310 | if async { |
| 7311 | test.name += "-Async" |
| 7312 | test.flags = append(test.flags, "-async") |
| 7313 | } |
| 7314 | |
| 7315 | testCases = append(testCases, test) |
| 7316 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7317 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7318 | } |
| 7319 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7320 | func addExportKeyingMaterialTests() { |
| 7321 | for _, vers := range tlsVersions { |
| 7322 | if vers.version == VersionSSL30 { |
| 7323 | continue |
| 7324 | } |
| 7325 | testCases = append(testCases, testCase{ |
| 7326 | name: "ExportKeyingMaterial-" + vers.name, |
| 7327 | config: Config{ |
| 7328 | MaxVersion: vers.version, |
| 7329 | }, |
| 7330 | exportKeyingMaterial: 1024, |
| 7331 | exportLabel: "label", |
| 7332 | exportContext: "context", |
| 7333 | useExportContext: true, |
| 7334 | }) |
| 7335 | testCases = append(testCases, testCase{ |
| 7336 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7337 | config: Config{ |
| 7338 | MaxVersion: vers.version, |
| 7339 | }, |
| 7340 | exportKeyingMaterial: 1024, |
| 7341 | }) |
| 7342 | testCases = append(testCases, testCase{ |
| 7343 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7344 | config: Config{ |
| 7345 | MaxVersion: vers.version, |
| 7346 | }, |
| 7347 | exportKeyingMaterial: 1024, |
| 7348 | useExportContext: true, |
| 7349 | }) |
| 7350 | testCases = append(testCases, testCase{ |
| 7351 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7352 | config: Config{ |
| 7353 | MaxVersion: vers.version, |
| 7354 | }, |
| 7355 | exportKeyingMaterial: 1, |
| 7356 | exportLabel: "label", |
| 7357 | exportContext: "context", |
| 7358 | useExportContext: true, |
| 7359 | }) |
| 7360 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7361 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7362 | testCases = append(testCases, testCase{ |
| 7363 | name: "ExportKeyingMaterial-SSL3", |
| 7364 | config: Config{ |
| 7365 | MaxVersion: VersionSSL30, |
| 7366 | }, |
| 7367 | exportKeyingMaterial: 1024, |
| 7368 | exportLabel: "label", |
| 7369 | exportContext: "context", |
| 7370 | useExportContext: true, |
| 7371 | shouldFail: true, |
| 7372 | expectedError: "failed to export keying material", |
| 7373 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7374 | |
| 7375 | // Exporters work during a False Start. |
| 7376 | testCases = append(testCases, testCase{ |
| 7377 | name: "ExportKeyingMaterial-FalseStart", |
| 7378 | config: Config{ |
| 7379 | MaxVersion: VersionTLS12, |
| 7380 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7381 | NextProtos: []string{"foo"}, |
| 7382 | Bugs: ProtocolBugs{ |
| 7383 | ExpectFalseStart: true, |
| 7384 | }, |
| 7385 | }, |
| 7386 | flags: []string{ |
| 7387 | "-false-start", |
| 7388 | "-advertise-alpn", "\x03foo", |
| 7389 | }, |
| 7390 | shimWritesFirst: true, |
| 7391 | exportKeyingMaterial: 1024, |
| 7392 | exportLabel: "label", |
| 7393 | exportContext: "context", |
| 7394 | useExportContext: true, |
| 7395 | }) |
| 7396 | |
| 7397 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7398 | // triggering the exporter after every SSL_read call and configuring the |
| 7399 | // shim to run asynchronously. |
| 7400 | testCases = append(testCases, testCase{ |
| 7401 | name: "ExportKeyingMaterial-Renegotiate", |
| 7402 | config: Config{ |
| 7403 | MaxVersion: VersionTLS12, |
| 7404 | }, |
| 7405 | renegotiate: 1, |
| 7406 | flags: []string{ |
| 7407 | "-async", |
| 7408 | "-use-exporter-between-reads", |
| 7409 | "-renegotiate-freely", |
| 7410 | "-expect-total-renegotiations", "1", |
| 7411 | }, |
| 7412 | shouldFail: true, |
| 7413 | expectedError: "failed to export keying material", |
| 7414 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7415 | } |
| 7416 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7417 | func addTLSUniqueTests() { |
| 7418 | for _, isClient := range []bool{false, true} { |
| 7419 | for _, isResumption := range []bool{false, true} { |
| 7420 | for _, hasEMS := range []bool{false, true} { |
| 7421 | var suffix string |
| 7422 | if isResumption { |
| 7423 | suffix = "Resume-" |
| 7424 | } else { |
| 7425 | suffix = "Full-" |
| 7426 | } |
| 7427 | |
| 7428 | if hasEMS { |
| 7429 | suffix += "EMS-" |
| 7430 | } else { |
| 7431 | suffix += "NoEMS-" |
| 7432 | } |
| 7433 | |
| 7434 | if isClient { |
| 7435 | suffix += "Client" |
| 7436 | } else { |
| 7437 | suffix += "Server" |
| 7438 | } |
| 7439 | |
| 7440 | test := testCase{ |
| 7441 | name: "TLSUnique-" + suffix, |
| 7442 | testTLSUnique: true, |
| 7443 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7444 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7445 | Bugs: ProtocolBugs{ |
| 7446 | NoExtendedMasterSecret: !hasEMS, |
| 7447 | }, |
| 7448 | }, |
| 7449 | } |
| 7450 | |
| 7451 | if isResumption { |
| 7452 | test.resumeSession = true |
| 7453 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7454 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7455 | Bugs: ProtocolBugs{ |
| 7456 | NoExtendedMasterSecret: !hasEMS, |
| 7457 | }, |
| 7458 | } |
| 7459 | } |
| 7460 | |
| 7461 | if isResumption && !hasEMS { |
| 7462 | test.shouldFail = true |
| 7463 | test.expectedError = "failed to get tls-unique" |
| 7464 | } |
| 7465 | |
| 7466 | testCases = append(testCases, test) |
| 7467 | } |
| 7468 | } |
| 7469 | } |
| 7470 | } |
| 7471 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7472 | func addCustomExtensionTests() { |
| 7473 | expectedContents := "custom extension" |
| 7474 | emptyString := "" |
| 7475 | |
| 7476 | for _, isClient := range []bool{false, true} { |
| 7477 | suffix := "Server" |
| 7478 | flag := "-enable-server-custom-extension" |
| 7479 | testType := serverTest |
| 7480 | if isClient { |
| 7481 | suffix = "Client" |
| 7482 | flag = "-enable-client-custom-extension" |
| 7483 | testType = clientTest |
| 7484 | } |
| 7485 | |
| 7486 | testCases = append(testCases, testCase{ |
| 7487 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7488 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7489 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7490 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7491 | Bugs: ProtocolBugs{ |
| 7492 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7493 | ExpectedCustomExtension: &expectedContents, |
| 7494 | }, |
| 7495 | }, |
| 7496 | flags: []string{flag}, |
| 7497 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7498 | testCases = append(testCases, testCase{ |
| 7499 | testType: testType, |
| 7500 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7501 | config: Config{ |
| 7502 | MaxVersion: VersionTLS13, |
| 7503 | Bugs: ProtocolBugs{ |
| 7504 | CustomExtension: expectedContents, |
| 7505 | ExpectedCustomExtension: &expectedContents, |
| 7506 | }, |
| 7507 | }, |
| 7508 | flags: []string{flag}, |
| 7509 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7510 | |
| 7511 | // If the parse callback fails, the handshake should also fail. |
| 7512 | testCases = append(testCases, testCase{ |
| 7513 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7514 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7515 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7516 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7517 | Bugs: ProtocolBugs{ |
| 7518 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7519 | ExpectedCustomExtension: &expectedContents, |
| 7520 | }, |
| 7521 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7522 | flags: []string{flag}, |
| 7523 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7524 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7525 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7526 | testCases = append(testCases, testCase{ |
| 7527 | testType: testType, |
| 7528 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7529 | config: Config{ |
| 7530 | MaxVersion: VersionTLS13, |
| 7531 | Bugs: ProtocolBugs{ |
| 7532 | CustomExtension: expectedContents + "foo", |
| 7533 | ExpectedCustomExtension: &expectedContents, |
| 7534 | }, |
| 7535 | }, |
| 7536 | flags: []string{flag}, |
| 7537 | shouldFail: true, |
| 7538 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7539 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7540 | |
| 7541 | // If the add callback fails, the handshake should also fail. |
| 7542 | testCases = append(testCases, testCase{ |
| 7543 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7544 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7545 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7546 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7547 | Bugs: ProtocolBugs{ |
| 7548 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7549 | ExpectedCustomExtension: &expectedContents, |
| 7550 | }, |
| 7551 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7552 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7553 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7554 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7555 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7556 | testCases = append(testCases, testCase{ |
| 7557 | testType: testType, |
| 7558 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7559 | config: Config{ |
| 7560 | MaxVersion: VersionTLS13, |
| 7561 | Bugs: ProtocolBugs{ |
| 7562 | CustomExtension: expectedContents, |
| 7563 | ExpectedCustomExtension: &expectedContents, |
| 7564 | }, |
| 7565 | }, |
| 7566 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7567 | shouldFail: true, |
| 7568 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7569 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7570 | |
| 7571 | // If the add callback returns zero, no extension should be |
| 7572 | // added. |
| 7573 | skipCustomExtension := expectedContents |
| 7574 | if isClient { |
| 7575 | // For the case where the client skips sending the |
| 7576 | // custom extension, the server must not “echo” it. |
| 7577 | skipCustomExtension = "" |
| 7578 | } |
| 7579 | testCases = append(testCases, testCase{ |
| 7580 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7581 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7582 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7583 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7584 | Bugs: ProtocolBugs{ |
| 7585 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7586 | ExpectedCustomExtension: &emptyString, |
| 7587 | }, |
| 7588 | }, |
| 7589 | flags: []string{flag, "-custom-extension-skip"}, |
| 7590 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7591 | testCases = append(testCases, testCase{ |
| 7592 | testType: testType, |
| 7593 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7594 | config: Config{ |
| 7595 | MaxVersion: VersionTLS13, |
| 7596 | Bugs: ProtocolBugs{ |
| 7597 | CustomExtension: skipCustomExtension, |
| 7598 | ExpectedCustomExtension: &emptyString, |
| 7599 | }, |
| 7600 | }, |
| 7601 | flags: []string{flag, "-custom-extension-skip"}, |
| 7602 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7603 | } |
| 7604 | |
| 7605 | // The custom extension add callback should not be called if the client |
| 7606 | // doesn't send the extension. |
| 7607 | testCases = append(testCases, testCase{ |
| 7608 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7609 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7610 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7611 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7612 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7613 | ExpectedCustomExtension: &emptyString, |
| 7614 | }, |
| 7615 | }, |
| 7616 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7617 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7618 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7619 | testCases = append(testCases, testCase{ |
| 7620 | testType: serverTest, |
| 7621 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 7622 | config: Config{ |
| 7623 | MaxVersion: VersionTLS13, |
| 7624 | Bugs: ProtocolBugs{ |
| 7625 | ExpectedCustomExtension: &emptyString, |
| 7626 | }, |
| 7627 | }, |
| 7628 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 7629 | }) |
| 7630 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7631 | // Test an unknown extension from the server. |
| 7632 | testCases = append(testCases, testCase{ |
| 7633 | testType: clientTest, |
| 7634 | name: "UnknownExtension-Client", |
| 7635 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7636 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7637 | Bugs: ProtocolBugs{ |
| 7638 | CustomExtension: expectedContents, |
| 7639 | }, |
| 7640 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7641 | shouldFail: true, |
| 7642 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7643 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 7644 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7645 | testCases = append(testCases, testCase{ |
| 7646 | testType: clientTest, |
| 7647 | name: "UnknownExtension-Client-TLS13", |
| 7648 | config: Config{ |
| 7649 | MaxVersion: VersionTLS13, |
| 7650 | Bugs: ProtocolBugs{ |
| 7651 | CustomExtension: expectedContents, |
| 7652 | }, |
| 7653 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7654 | shouldFail: true, |
| 7655 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7656 | expectedLocalError: "remote error: unsupported extension", |
| 7657 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 7658 | testCases = append(testCases, testCase{ |
| 7659 | testType: clientTest, |
| 7660 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 7661 | config: Config{ |
| 7662 | MaxVersion: VersionTLS13, |
| 7663 | Bugs: ProtocolBugs{ |
| 7664 | CustomUnencryptedExtension: expectedContents, |
| 7665 | }, |
| 7666 | }, |
| 7667 | shouldFail: true, |
| 7668 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7669 | // The shim must send an alert, but alerts at this point do not |
| 7670 | // get successfully decrypted by the runner. |
| 7671 | expectedLocalError: "local error: bad record MAC", |
| 7672 | }) |
| 7673 | testCases = append(testCases, testCase{ |
| 7674 | testType: clientTest, |
| 7675 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 7676 | config: Config{ |
| 7677 | MaxVersion: VersionTLS13, |
| 7678 | Bugs: ProtocolBugs{ |
| 7679 | SendUnencryptedALPN: "foo", |
| 7680 | }, |
| 7681 | }, |
| 7682 | flags: []string{ |
| 7683 | "-advertise-alpn", "\x03foo\x03bar", |
| 7684 | }, |
| 7685 | shouldFail: true, |
| 7686 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7687 | // The shim must send an alert, but alerts at this point do not |
| 7688 | // get successfully decrypted by the runner. |
| 7689 | expectedLocalError: "local error: bad record MAC", |
| 7690 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 7691 | |
| 7692 | // Test a known but unoffered extension from the server. |
| 7693 | testCases = append(testCases, testCase{ |
| 7694 | testType: clientTest, |
| 7695 | name: "UnofferedExtension-Client", |
| 7696 | config: Config{ |
| 7697 | MaxVersion: VersionTLS12, |
| 7698 | Bugs: ProtocolBugs{ |
| 7699 | SendALPN: "alpn", |
| 7700 | }, |
| 7701 | }, |
| 7702 | shouldFail: true, |
| 7703 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7704 | expectedLocalError: "remote error: unsupported extension", |
| 7705 | }) |
| 7706 | testCases = append(testCases, testCase{ |
| 7707 | testType: clientTest, |
| 7708 | name: "UnofferedExtension-Client-TLS13", |
| 7709 | config: Config{ |
| 7710 | MaxVersion: VersionTLS13, |
| 7711 | Bugs: ProtocolBugs{ |
| 7712 | SendALPN: "alpn", |
| 7713 | }, |
| 7714 | }, |
| 7715 | shouldFail: true, |
| 7716 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7717 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7718 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7719 | } |
| 7720 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7721 | func addRSAClientKeyExchangeTests() { |
| 7722 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 7723 | testCases = append(testCases, testCase{ |
| 7724 | testType: serverTest, |
| 7725 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 7726 | config: Config{ |
| 7727 | // Ensure the ClientHello version and final |
| 7728 | // version are different, to detect if the |
| 7729 | // server uses the wrong one. |
| 7730 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7731 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7732 | Bugs: ProtocolBugs{ |
| 7733 | BadRSAClientKeyExchange: bad, |
| 7734 | }, |
| 7735 | }, |
| 7736 | shouldFail: true, |
| 7737 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7738 | }) |
| 7739 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 7740 | |
| 7741 | // The server must compare whatever was in ClientHello.version for the |
| 7742 | // RSA premaster. |
| 7743 | testCases = append(testCases, testCase{ |
| 7744 | testType: serverTest, |
| 7745 | name: "SendClientVersion-RSA", |
| 7746 | config: Config{ |
| 7747 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 7748 | Bugs: ProtocolBugs{ |
| 7749 | SendClientVersion: 0x1234, |
| 7750 | }, |
| 7751 | }, |
| 7752 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7753 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7754 | } |
| 7755 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7756 | var testCurves = []struct { |
| 7757 | name string |
| 7758 | id CurveID |
| 7759 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7760 | {"P-256", CurveP256}, |
| 7761 | {"P-384", CurveP384}, |
| 7762 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 7763 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7764 | } |
| 7765 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7766 | const bogusCurve = 0x1234 |
| 7767 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7768 | func addCurveTests() { |
| 7769 | for _, curve := range testCurves { |
| 7770 | testCases = append(testCases, testCase{ |
| 7771 | name: "CurveTest-Client-" + curve.name, |
| 7772 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7773 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7774 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7775 | CurvePreferences: []CurveID{curve.id}, |
| 7776 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7777 | flags: []string{ |
| 7778 | "-enable-all-curves", |
| 7779 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7780 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7781 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7782 | }) |
| 7783 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7784 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 7785 | config: Config{ |
| 7786 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7787 | CurvePreferences: []CurveID{curve.id}, |
| 7788 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7789 | flags: []string{ |
| 7790 | "-enable-all-curves", |
| 7791 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7792 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7793 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7794 | }) |
| 7795 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7796 | testType: serverTest, |
| 7797 | name: "CurveTest-Server-" + curve.name, |
| 7798 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7799 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7800 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7801 | CurvePreferences: []CurveID{curve.id}, |
| 7802 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7803 | flags: []string{ |
| 7804 | "-enable-all-curves", |
| 7805 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7806 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7807 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7808 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7809 | testCases = append(testCases, testCase{ |
| 7810 | testType: serverTest, |
| 7811 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 7812 | config: Config{ |
| 7813 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7814 | CurvePreferences: []CurveID{curve.id}, |
| 7815 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7816 | flags: []string{ |
| 7817 | "-enable-all-curves", |
| 7818 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7819 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7820 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7821 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7822 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7823 | |
| 7824 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7825 | testCases = append(testCases, testCase{ |
| 7826 | testType: serverTest, |
| 7827 | name: "UnknownCurve", |
| 7828 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7829 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7830 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7831 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7832 | }, |
| 7833 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7834 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7835 | // The server must be tolerant to bogus curves. |
| 7836 | testCases = append(testCases, testCase{ |
| 7837 | testType: serverTest, |
| 7838 | name: "UnknownCurve-TLS13", |
| 7839 | config: Config{ |
| 7840 | MaxVersion: VersionTLS13, |
| 7841 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7842 | }, |
| 7843 | }) |
| 7844 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7845 | // The server must not consider ECDHE ciphers when there are no |
| 7846 | // supported curves. |
| 7847 | testCases = append(testCases, testCase{ |
| 7848 | testType: serverTest, |
| 7849 | name: "NoSupportedCurves", |
| 7850 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7851 | MaxVersion: VersionTLS12, |
| 7852 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7853 | Bugs: ProtocolBugs{ |
| 7854 | NoSupportedCurves: true, |
| 7855 | }, |
| 7856 | }, |
| 7857 | shouldFail: true, |
| 7858 | expectedError: ":NO_SHARED_CIPHER:", |
| 7859 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7860 | testCases = append(testCases, testCase{ |
| 7861 | testType: serverTest, |
| 7862 | name: "NoSupportedCurves-TLS13", |
| 7863 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7864 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7865 | Bugs: ProtocolBugs{ |
| 7866 | NoSupportedCurves: true, |
| 7867 | }, |
| 7868 | }, |
| 7869 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7870 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7871 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7872 | |
| 7873 | // The server must fall back to another cipher when there are no |
| 7874 | // supported curves. |
| 7875 | testCases = append(testCases, testCase{ |
| 7876 | testType: serverTest, |
| 7877 | name: "NoCommonCurves", |
| 7878 | config: Config{ |
| 7879 | MaxVersion: VersionTLS12, |
| 7880 | CipherSuites: []uint16{ |
| 7881 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7882 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7883 | }, |
| 7884 | CurvePreferences: []CurveID{CurveP224}, |
| 7885 | }, |
| 7886 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7887 | }) |
| 7888 | |
| 7889 | // The client must reject bogus curves and disabled curves. |
| 7890 | testCases = append(testCases, testCase{ |
| 7891 | name: "BadECDHECurve", |
| 7892 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7893 | MaxVersion: VersionTLS12, |
| 7894 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7895 | Bugs: ProtocolBugs{ |
| 7896 | SendCurve: bogusCurve, |
| 7897 | }, |
| 7898 | }, |
| 7899 | shouldFail: true, |
| 7900 | expectedError: ":WRONG_CURVE:", |
| 7901 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7902 | testCases = append(testCases, testCase{ |
| 7903 | name: "BadECDHECurve-TLS13", |
| 7904 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7905 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7906 | Bugs: ProtocolBugs{ |
| 7907 | SendCurve: bogusCurve, |
| 7908 | }, |
| 7909 | }, |
| 7910 | shouldFail: true, |
| 7911 | expectedError: ":WRONG_CURVE:", |
| 7912 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7913 | |
| 7914 | testCases = append(testCases, testCase{ |
| 7915 | name: "UnsupportedCurve", |
| 7916 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7917 | MaxVersion: VersionTLS12, |
| 7918 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7919 | CurvePreferences: []CurveID{CurveP256}, |
| 7920 | Bugs: ProtocolBugs{ |
| 7921 | IgnorePeerCurvePreferences: true, |
| 7922 | }, |
| 7923 | }, |
| 7924 | flags: []string{"-p384-only"}, |
| 7925 | shouldFail: true, |
| 7926 | expectedError: ":WRONG_CURVE:", |
| 7927 | }) |
| 7928 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7929 | testCases = append(testCases, testCase{ |
| 7930 | // TODO(davidben): Add a TLS 1.3 version where |
| 7931 | // HelloRetryRequest requests an unsupported curve. |
| 7932 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 7933 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7934 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7935 | CurvePreferences: []CurveID{CurveP384}, |
| 7936 | Bugs: ProtocolBugs{ |
| 7937 | SendCurve: CurveP256, |
| 7938 | }, |
| 7939 | }, |
| 7940 | flags: []string{"-p384-only"}, |
| 7941 | shouldFail: true, |
| 7942 | expectedError: ":WRONG_CURVE:", |
| 7943 | }) |
| 7944 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7945 | // Test invalid curve points. |
| 7946 | testCases = append(testCases, testCase{ |
| 7947 | name: "InvalidECDHPoint-Client", |
| 7948 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7949 | MaxVersion: VersionTLS12, |
| 7950 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7951 | CurvePreferences: []CurveID{CurveP256}, |
| 7952 | Bugs: ProtocolBugs{ |
| 7953 | InvalidECDHPoint: true, |
| 7954 | }, |
| 7955 | }, |
| 7956 | shouldFail: true, |
| 7957 | expectedError: ":INVALID_ENCODING:", |
| 7958 | }) |
| 7959 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7960 | name: "InvalidECDHPoint-Client-TLS13", |
| 7961 | config: Config{ |
| 7962 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7963 | CurvePreferences: []CurveID{CurveP256}, |
| 7964 | Bugs: ProtocolBugs{ |
| 7965 | InvalidECDHPoint: true, |
| 7966 | }, |
| 7967 | }, |
| 7968 | shouldFail: true, |
| 7969 | expectedError: ":INVALID_ENCODING:", |
| 7970 | }) |
| 7971 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7972 | testType: serverTest, |
| 7973 | name: "InvalidECDHPoint-Server", |
| 7974 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7975 | MaxVersion: VersionTLS12, |
| 7976 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7977 | CurvePreferences: []CurveID{CurveP256}, |
| 7978 | Bugs: ProtocolBugs{ |
| 7979 | InvalidECDHPoint: true, |
| 7980 | }, |
| 7981 | }, |
| 7982 | shouldFail: true, |
| 7983 | expectedError: ":INVALID_ENCODING:", |
| 7984 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7985 | testCases = append(testCases, testCase{ |
| 7986 | testType: serverTest, |
| 7987 | name: "InvalidECDHPoint-Server-TLS13", |
| 7988 | config: Config{ |
| 7989 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7990 | CurvePreferences: []CurveID{CurveP256}, |
| 7991 | Bugs: ProtocolBugs{ |
| 7992 | InvalidECDHPoint: true, |
| 7993 | }, |
| 7994 | }, |
| 7995 | shouldFail: true, |
| 7996 | expectedError: ":INVALID_ENCODING:", |
| 7997 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7998 | } |
| 7999 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8000 | func addCECPQ1Tests() { |
| 8001 | testCases = append(testCases, testCase{ |
| 8002 | testType: clientTest, |
| 8003 | name: "CECPQ1-Client-BadX25519Part", |
| 8004 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8005 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8006 | MinVersion: VersionTLS12, |
| 8007 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8008 | Bugs: ProtocolBugs{ |
| 8009 | CECPQ1BadX25519Part: true, |
| 8010 | }, |
| 8011 | }, |
| 8012 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8013 | shouldFail: true, |
| 8014 | expectedLocalError: "local error: bad record MAC", |
| 8015 | }) |
| 8016 | testCases = append(testCases, testCase{ |
| 8017 | testType: clientTest, |
| 8018 | name: "CECPQ1-Client-BadNewhopePart", |
| 8019 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8020 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8021 | MinVersion: VersionTLS12, |
| 8022 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8023 | Bugs: ProtocolBugs{ |
| 8024 | CECPQ1BadNewhopePart: true, |
| 8025 | }, |
| 8026 | }, |
| 8027 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8028 | shouldFail: true, |
| 8029 | expectedLocalError: "local error: bad record MAC", |
| 8030 | }) |
| 8031 | testCases = append(testCases, testCase{ |
| 8032 | testType: serverTest, |
| 8033 | name: "CECPQ1-Server-BadX25519Part", |
| 8034 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8035 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8036 | MinVersion: VersionTLS12, |
| 8037 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8038 | Bugs: ProtocolBugs{ |
| 8039 | CECPQ1BadX25519Part: true, |
| 8040 | }, |
| 8041 | }, |
| 8042 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8043 | shouldFail: true, |
| 8044 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8045 | }) |
| 8046 | testCases = append(testCases, testCase{ |
| 8047 | testType: serverTest, |
| 8048 | name: "CECPQ1-Server-BadNewhopePart", |
| 8049 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8050 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8051 | MinVersion: VersionTLS12, |
| 8052 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 8053 | Bugs: ProtocolBugs{ |
| 8054 | CECPQ1BadNewhopePart: true, |
| 8055 | }, |
| 8056 | }, |
| 8057 | flags: []string{"-cipher", "kCECPQ1"}, |
| 8058 | shouldFail: true, |
| 8059 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8060 | }) |
| 8061 | } |
| 8062 | |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8063 | func addDHEGroupSizeTests() { |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8064 | testCases = append(testCases, testCase{ |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8065 | name: "DHEGroupSize-Client", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8066 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8067 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8068 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8069 | Bugs: ProtocolBugs{ |
| 8070 | // This is a 1234-bit prime number, generated |
| 8071 | // with: |
| 8072 | // openssl gendh 1234 | openssl asn1parse -i |
| 8073 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 8074 | }, |
| 8075 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 8076 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8077 | }) |
| 8078 | testCases = append(testCases, testCase{ |
| 8079 | testType: serverTest, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8080 | name: "DHEGroupSize-Server", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8081 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 8082 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8083 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8084 | }, |
| 8085 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 8086 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8087 | }) |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 8088 | } |
| 8089 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8090 | func addTLS13RecordTests() { |
| 8091 | testCases = append(testCases, testCase{ |
| 8092 | name: "TLS13-RecordPadding", |
| 8093 | config: Config{ |
| 8094 | MaxVersion: VersionTLS13, |
| 8095 | MinVersion: VersionTLS13, |
| 8096 | Bugs: ProtocolBugs{ |
| 8097 | RecordPadding: 10, |
| 8098 | }, |
| 8099 | }, |
| 8100 | }) |
| 8101 | |
| 8102 | testCases = append(testCases, testCase{ |
| 8103 | name: "TLS13-EmptyRecords", |
| 8104 | config: Config{ |
| 8105 | MaxVersion: VersionTLS13, |
| 8106 | MinVersion: VersionTLS13, |
| 8107 | Bugs: ProtocolBugs{ |
| 8108 | OmitRecordContents: true, |
| 8109 | }, |
| 8110 | }, |
| 8111 | shouldFail: true, |
| 8112 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8113 | }) |
| 8114 | |
| 8115 | testCases = append(testCases, testCase{ |
| 8116 | name: "TLS13-OnlyPadding", |
| 8117 | config: Config{ |
| 8118 | MaxVersion: VersionTLS13, |
| 8119 | MinVersion: VersionTLS13, |
| 8120 | Bugs: ProtocolBugs{ |
| 8121 | OmitRecordContents: true, |
| 8122 | RecordPadding: 10, |
| 8123 | }, |
| 8124 | }, |
| 8125 | shouldFail: true, |
| 8126 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8127 | }) |
| 8128 | |
| 8129 | testCases = append(testCases, testCase{ |
| 8130 | name: "TLS13-WrongOuterRecord", |
| 8131 | config: Config{ |
| 8132 | MaxVersion: VersionTLS13, |
| 8133 | MinVersion: VersionTLS13, |
| 8134 | Bugs: ProtocolBugs{ |
| 8135 | OuterRecordType: recordTypeHandshake, |
| 8136 | }, |
| 8137 | }, |
| 8138 | shouldFail: true, |
| 8139 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8140 | }) |
| 8141 | } |
| 8142 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8143 | func addSessionTicketTests() { |
| 8144 | testCases = append(testCases, testCase{ |
| 8145 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8146 | // mean the server changed its mind on sending a ticket. |
| 8147 | name: "SendEmptySessionTicket", |
| 8148 | config: Config{ |
| 8149 | MaxVersion: VersionTLS12, |
| 8150 | Bugs: ProtocolBugs{ |
| 8151 | SendEmptySessionTicket: true, |
| 8152 | }, |
| 8153 | }, |
| 8154 | flags: []string{"-expect-no-session"}, |
| 8155 | }) |
| 8156 | |
| 8157 | // Test that the server ignores unknown PSK modes. |
| 8158 | testCases = append(testCases, testCase{ |
| 8159 | testType: serverTest, |
| 8160 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8161 | config: Config{ |
| 8162 | MaxVersion: VersionTLS13, |
| 8163 | Bugs: ProtocolBugs{ |
| 8164 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8165 | }, |
| 8166 | }, |
| 8167 | resumeSession: true, |
| 8168 | expectedResumeVersion: VersionTLS13, |
| 8169 | }) |
| 8170 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8171 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8172 | testCases = append(testCases, testCase{ |
| 8173 | testType: serverTest, |
| 8174 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8175 | config: Config{ |
| 8176 | MaxVersion: VersionTLS13, |
| 8177 | Bugs: ProtocolBugs{ |
| 8178 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8179 | ExpectNoNewSessionTicket: true, |
| 8180 | }, |
| 8181 | }, |
| 8182 | }) |
| 8183 | |
| 8184 | // Test that the server does not accept a session with no matching key exchange mode. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8185 | testCases = append(testCases, testCase{ |
| 8186 | testType: serverTest, |
| 8187 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8188 | config: Config{ |
| 8189 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8190 | }, |
| 8191 | resumeConfig: &Config{ |
| 8192 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8193 | Bugs: ProtocolBugs{ |
| 8194 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8195 | }, |
| 8196 | }, |
| 8197 | resumeSession: true, |
| 8198 | expectResumeRejected: true, |
| 8199 | }) |
| 8200 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8201 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8202 | testCases = append(testCases, testCase{ |
| 8203 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8204 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8205 | config: Config{ |
| 8206 | MaxVersion: VersionTLS13, |
| 8207 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8208 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8209 | }, |
| 8210 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8211 | resumeSession: true, |
| 8212 | flags: []string{ |
| 8213 | "-resumption-delay", "10", |
| 8214 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8215 | }) |
| 8216 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8217 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8218 | testCases = append(testCases, testCase{ |
| 8219 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8220 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8221 | config: Config{ |
| 8222 | MaxVersion: VersionTLS13, |
| 8223 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8224 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8225 | }, |
| 8226 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8227 | resumeSession: true, |
| 8228 | shouldFail: true, |
| 8229 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8230 | }) |
| 8231 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8232 | } |
| 8233 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8234 | func addChangeCipherSpecTests() { |
| 8235 | // Test missing ChangeCipherSpecs. |
| 8236 | testCases = append(testCases, testCase{ |
| 8237 | name: "SkipChangeCipherSpec-Client", |
| 8238 | config: Config{ |
| 8239 | MaxVersion: VersionTLS12, |
| 8240 | Bugs: ProtocolBugs{ |
| 8241 | SkipChangeCipherSpec: true, |
| 8242 | }, |
| 8243 | }, |
| 8244 | shouldFail: true, |
| 8245 | expectedError: ":UNEXPECTED_RECORD:", |
| 8246 | }) |
| 8247 | testCases = append(testCases, testCase{ |
| 8248 | testType: serverTest, |
| 8249 | name: "SkipChangeCipherSpec-Server", |
| 8250 | config: Config{ |
| 8251 | MaxVersion: VersionTLS12, |
| 8252 | Bugs: ProtocolBugs{ |
| 8253 | SkipChangeCipherSpec: true, |
| 8254 | }, |
| 8255 | }, |
| 8256 | shouldFail: true, |
| 8257 | expectedError: ":UNEXPECTED_RECORD:", |
| 8258 | }) |
| 8259 | testCases = append(testCases, testCase{ |
| 8260 | testType: serverTest, |
| 8261 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8262 | config: Config{ |
| 8263 | MaxVersion: VersionTLS12, |
| 8264 | NextProtos: []string{"bar"}, |
| 8265 | Bugs: ProtocolBugs{ |
| 8266 | SkipChangeCipherSpec: true, |
| 8267 | }, |
| 8268 | }, |
| 8269 | flags: []string{ |
| 8270 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8271 | }, |
| 8272 | shouldFail: true, |
| 8273 | expectedError: ":UNEXPECTED_RECORD:", |
| 8274 | }) |
| 8275 | |
| 8276 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8277 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8278 | // rejected. Test both with and without handshake packing to handle both |
| 8279 | // when the partial post-CCS message is in its own record and when it is |
| 8280 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8281 | for _, packed := range []bool{false, true} { |
| 8282 | var suffix string |
| 8283 | if packed { |
| 8284 | suffix = "-Packed" |
| 8285 | } |
| 8286 | |
| 8287 | testCases = append(testCases, testCase{ |
| 8288 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8289 | config: Config{ |
| 8290 | MaxVersion: VersionTLS12, |
| 8291 | Bugs: ProtocolBugs{ |
| 8292 | FragmentAcrossChangeCipherSpec: true, |
| 8293 | PackHandshakeFlight: packed, |
| 8294 | }, |
| 8295 | }, |
| 8296 | shouldFail: true, |
| 8297 | expectedError: ":UNEXPECTED_RECORD:", |
| 8298 | }) |
| 8299 | testCases = append(testCases, testCase{ |
| 8300 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8301 | config: Config{ |
| 8302 | MaxVersion: VersionTLS12, |
| 8303 | }, |
| 8304 | resumeSession: true, |
| 8305 | resumeConfig: &Config{ |
| 8306 | MaxVersion: VersionTLS12, |
| 8307 | Bugs: ProtocolBugs{ |
| 8308 | FragmentAcrossChangeCipherSpec: true, |
| 8309 | PackHandshakeFlight: packed, |
| 8310 | }, |
| 8311 | }, |
| 8312 | shouldFail: true, |
| 8313 | expectedError: ":UNEXPECTED_RECORD:", |
| 8314 | }) |
| 8315 | testCases = append(testCases, testCase{ |
| 8316 | testType: serverTest, |
| 8317 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8318 | config: Config{ |
| 8319 | MaxVersion: VersionTLS12, |
| 8320 | Bugs: ProtocolBugs{ |
| 8321 | FragmentAcrossChangeCipherSpec: true, |
| 8322 | PackHandshakeFlight: packed, |
| 8323 | }, |
| 8324 | }, |
| 8325 | shouldFail: true, |
| 8326 | expectedError: ":UNEXPECTED_RECORD:", |
| 8327 | }) |
| 8328 | testCases = append(testCases, testCase{ |
| 8329 | testType: serverTest, |
| 8330 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8331 | config: Config{ |
| 8332 | MaxVersion: VersionTLS12, |
| 8333 | }, |
| 8334 | resumeSession: true, |
| 8335 | resumeConfig: &Config{ |
| 8336 | MaxVersion: VersionTLS12, |
| 8337 | Bugs: ProtocolBugs{ |
| 8338 | FragmentAcrossChangeCipherSpec: true, |
| 8339 | PackHandshakeFlight: packed, |
| 8340 | }, |
| 8341 | }, |
| 8342 | shouldFail: true, |
| 8343 | expectedError: ":UNEXPECTED_RECORD:", |
| 8344 | }) |
| 8345 | testCases = append(testCases, testCase{ |
| 8346 | testType: serverTest, |
| 8347 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8348 | config: Config{ |
| 8349 | MaxVersion: VersionTLS12, |
| 8350 | NextProtos: []string{"bar"}, |
| 8351 | Bugs: ProtocolBugs{ |
| 8352 | FragmentAcrossChangeCipherSpec: true, |
| 8353 | PackHandshakeFlight: packed, |
| 8354 | }, |
| 8355 | }, |
| 8356 | flags: []string{ |
| 8357 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8358 | }, |
| 8359 | shouldFail: true, |
| 8360 | expectedError: ":UNEXPECTED_RECORD:", |
| 8361 | }) |
| 8362 | } |
| 8363 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8364 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8365 | // messages in the handshake queue. Do this by testing the server |
| 8366 | // reading the client Finished, reversing the flight so Finished comes |
| 8367 | // first. |
| 8368 | testCases = append(testCases, testCase{ |
| 8369 | protocol: dtls, |
| 8370 | testType: serverTest, |
| 8371 | name: "SendUnencryptedFinished-DTLS", |
| 8372 | config: Config{ |
| 8373 | MaxVersion: VersionTLS12, |
| 8374 | Bugs: ProtocolBugs{ |
| 8375 | SendUnencryptedFinished: true, |
| 8376 | ReverseHandshakeFragments: true, |
| 8377 | }, |
| 8378 | }, |
| 8379 | shouldFail: true, |
| 8380 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8381 | }) |
| 8382 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8383 | // Test synchronization between encryption changes and the handshake in |
| 8384 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8385 | testCases = append(testCases, testCase{ |
| 8386 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8387 | config: Config{ |
| 8388 | MaxVersion: VersionTLS13, |
| 8389 | Bugs: ProtocolBugs{ |
| 8390 | PartialEncryptedExtensionsWithServerHello: true, |
| 8391 | }, |
| 8392 | }, |
| 8393 | shouldFail: true, |
| 8394 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8395 | }) |
| 8396 | testCases = append(testCases, testCase{ |
| 8397 | testType: serverTest, |
| 8398 | name: "PartialClientFinishedWithClientHello", |
| 8399 | config: Config{ |
| 8400 | MaxVersion: VersionTLS13, |
| 8401 | Bugs: ProtocolBugs{ |
| 8402 | PartialClientFinishedWithClientHello: true, |
| 8403 | }, |
| 8404 | }, |
| 8405 | shouldFail: true, |
| 8406 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8407 | }) |
| 8408 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8409 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8410 | testCases = append(testCases, testCase{ |
| 8411 | testType: serverTest, |
| 8412 | name: "EarlyChangeCipherSpec-server-1", |
| 8413 | config: Config{ |
| 8414 | MaxVersion: VersionTLS12, |
| 8415 | Bugs: ProtocolBugs{ |
| 8416 | EarlyChangeCipherSpec: 1, |
| 8417 | }, |
| 8418 | }, |
| 8419 | shouldFail: true, |
| 8420 | expectedError: ":UNEXPECTED_RECORD:", |
| 8421 | }) |
| 8422 | testCases = append(testCases, testCase{ |
| 8423 | testType: serverTest, |
| 8424 | name: "EarlyChangeCipherSpec-server-2", |
| 8425 | config: Config{ |
| 8426 | MaxVersion: VersionTLS12, |
| 8427 | Bugs: ProtocolBugs{ |
| 8428 | EarlyChangeCipherSpec: 2, |
| 8429 | }, |
| 8430 | }, |
| 8431 | shouldFail: true, |
| 8432 | expectedError: ":UNEXPECTED_RECORD:", |
| 8433 | }) |
| 8434 | testCases = append(testCases, testCase{ |
| 8435 | protocol: dtls, |
| 8436 | name: "StrayChangeCipherSpec", |
| 8437 | config: Config{ |
| 8438 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 8439 | // that stray ChangeCipherSpec messages are |
| 8440 | // rejected. |
| 8441 | MaxVersion: VersionTLS12, |
| 8442 | Bugs: ProtocolBugs{ |
| 8443 | StrayChangeCipherSpec: true, |
| 8444 | }, |
| 8445 | }, |
| 8446 | }) |
| 8447 | |
| 8448 | // Test that the contents of ChangeCipherSpec are checked. |
| 8449 | testCases = append(testCases, testCase{ |
| 8450 | name: "BadChangeCipherSpec-1", |
| 8451 | config: Config{ |
| 8452 | MaxVersion: VersionTLS12, |
| 8453 | Bugs: ProtocolBugs{ |
| 8454 | BadChangeCipherSpec: []byte{2}, |
| 8455 | }, |
| 8456 | }, |
| 8457 | shouldFail: true, |
| 8458 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8459 | }) |
| 8460 | testCases = append(testCases, testCase{ |
| 8461 | name: "BadChangeCipherSpec-2", |
| 8462 | config: Config{ |
| 8463 | MaxVersion: VersionTLS12, |
| 8464 | Bugs: ProtocolBugs{ |
| 8465 | BadChangeCipherSpec: []byte{1, 1}, |
| 8466 | }, |
| 8467 | }, |
| 8468 | shouldFail: true, |
| 8469 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8470 | }) |
| 8471 | testCases = append(testCases, testCase{ |
| 8472 | protocol: dtls, |
| 8473 | name: "BadChangeCipherSpec-DTLS-1", |
| 8474 | config: Config{ |
| 8475 | MaxVersion: VersionTLS12, |
| 8476 | Bugs: ProtocolBugs{ |
| 8477 | BadChangeCipherSpec: []byte{2}, |
| 8478 | }, |
| 8479 | }, |
| 8480 | shouldFail: true, |
| 8481 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8482 | }) |
| 8483 | testCases = append(testCases, testCase{ |
| 8484 | protocol: dtls, |
| 8485 | name: "BadChangeCipherSpec-DTLS-2", |
| 8486 | config: Config{ |
| 8487 | MaxVersion: VersionTLS12, |
| 8488 | Bugs: ProtocolBugs{ |
| 8489 | BadChangeCipherSpec: []byte{1, 1}, |
| 8490 | }, |
| 8491 | }, |
| 8492 | shouldFail: true, |
| 8493 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 8494 | }) |
| 8495 | } |
| 8496 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8497 | type perMessageTest struct { |
| 8498 | messageType uint8 |
| 8499 | test testCase |
| 8500 | } |
| 8501 | |
| 8502 | // makePerMessageTests returns a series of test templates which cover each |
| 8503 | // message in the TLS handshake. These may be used with bugs like |
| 8504 | // WrongMessageType to fully test a per-message bug. |
| 8505 | func makePerMessageTests() []perMessageTest { |
| 8506 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8507 | for _, protocol := range []protocol{tls, dtls} { |
| 8508 | var suffix string |
| 8509 | if protocol == dtls { |
| 8510 | suffix = "-DTLS" |
| 8511 | } |
| 8512 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8513 | ret = append(ret, perMessageTest{ |
| 8514 | messageType: typeClientHello, |
| 8515 | test: testCase{ |
| 8516 | protocol: protocol, |
| 8517 | testType: serverTest, |
| 8518 | name: "ClientHello" + suffix, |
| 8519 | config: Config{ |
| 8520 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8521 | }, |
| 8522 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8523 | }) |
| 8524 | |
| 8525 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8526 | ret = append(ret, perMessageTest{ |
| 8527 | messageType: typeHelloVerifyRequest, |
| 8528 | test: testCase{ |
| 8529 | protocol: protocol, |
| 8530 | name: "HelloVerifyRequest" + suffix, |
| 8531 | config: Config{ |
| 8532 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8533 | }, |
| 8534 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8535 | }) |
| 8536 | } |
| 8537 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8538 | ret = append(ret, perMessageTest{ |
| 8539 | messageType: typeServerHello, |
| 8540 | test: testCase{ |
| 8541 | protocol: protocol, |
| 8542 | name: "ServerHello" + suffix, |
| 8543 | config: Config{ |
| 8544 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8545 | }, |
| 8546 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8547 | }) |
| 8548 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8549 | ret = append(ret, perMessageTest{ |
| 8550 | messageType: typeCertificate, |
| 8551 | test: testCase{ |
| 8552 | protocol: protocol, |
| 8553 | name: "ServerCertificate" + suffix, |
| 8554 | config: Config{ |
| 8555 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8556 | }, |
| 8557 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8558 | }) |
| 8559 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8560 | ret = append(ret, perMessageTest{ |
| 8561 | messageType: typeCertificateStatus, |
| 8562 | test: testCase{ |
| 8563 | protocol: protocol, |
| 8564 | name: "CertificateStatus" + suffix, |
| 8565 | config: Config{ |
| 8566 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8567 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8568 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8569 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8570 | }) |
| 8571 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8572 | ret = append(ret, perMessageTest{ |
| 8573 | messageType: typeServerKeyExchange, |
| 8574 | test: testCase{ |
| 8575 | protocol: protocol, |
| 8576 | name: "ServerKeyExchange" + suffix, |
| 8577 | config: Config{ |
| 8578 | MaxVersion: VersionTLS12, |
| 8579 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8580 | }, |
| 8581 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8582 | }) |
| 8583 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8584 | ret = append(ret, perMessageTest{ |
| 8585 | messageType: typeCertificateRequest, |
| 8586 | test: testCase{ |
| 8587 | protocol: protocol, |
| 8588 | name: "CertificateRequest" + suffix, |
| 8589 | config: Config{ |
| 8590 | MaxVersion: VersionTLS12, |
| 8591 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8592 | }, |
| 8593 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8594 | }) |
| 8595 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8596 | ret = append(ret, perMessageTest{ |
| 8597 | messageType: typeServerHelloDone, |
| 8598 | test: testCase{ |
| 8599 | protocol: protocol, |
| 8600 | name: "ServerHelloDone" + suffix, |
| 8601 | config: Config{ |
| 8602 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8603 | }, |
| 8604 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8605 | }) |
| 8606 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8607 | ret = append(ret, perMessageTest{ |
| 8608 | messageType: typeCertificate, |
| 8609 | test: testCase{ |
| 8610 | testType: serverTest, |
| 8611 | protocol: protocol, |
| 8612 | name: "ClientCertificate" + suffix, |
| 8613 | config: Config{ |
| 8614 | Certificates: []Certificate{rsaCertificate}, |
| 8615 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8616 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8617 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8618 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8619 | }) |
| 8620 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8621 | ret = append(ret, perMessageTest{ |
| 8622 | messageType: typeCertificateVerify, |
| 8623 | test: testCase{ |
| 8624 | testType: serverTest, |
| 8625 | protocol: protocol, |
| 8626 | name: "CertificateVerify" + suffix, |
| 8627 | config: Config{ |
| 8628 | Certificates: []Certificate{rsaCertificate}, |
| 8629 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8630 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8631 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8632 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8633 | }) |
| 8634 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8635 | ret = append(ret, perMessageTest{ |
| 8636 | messageType: typeClientKeyExchange, |
| 8637 | test: testCase{ |
| 8638 | testType: serverTest, |
| 8639 | protocol: protocol, |
| 8640 | name: "ClientKeyExchange" + suffix, |
| 8641 | config: Config{ |
| 8642 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8643 | }, |
| 8644 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8645 | }) |
| 8646 | |
| 8647 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8648 | ret = append(ret, perMessageTest{ |
| 8649 | messageType: typeNextProtocol, |
| 8650 | test: testCase{ |
| 8651 | testType: serverTest, |
| 8652 | protocol: protocol, |
| 8653 | name: "NextProtocol" + suffix, |
| 8654 | config: Config{ |
| 8655 | MaxVersion: VersionTLS12, |
| 8656 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8657 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8658 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8659 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8660 | }) |
| 8661 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8662 | ret = append(ret, perMessageTest{ |
| 8663 | messageType: typeChannelID, |
| 8664 | test: testCase{ |
| 8665 | testType: serverTest, |
| 8666 | protocol: protocol, |
| 8667 | name: "ChannelID" + suffix, |
| 8668 | config: Config{ |
| 8669 | MaxVersion: VersionTLS12, |
| 8670 | ChannelID: channelIDKey, |
| 8671 | }, |
| 8672 | flags: []string{ |
| 8673 | "-expect-channel-id", |
| 8674 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8675 | }, |
| 8676 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8677 | }) |
| 8678 | } |
| 8679 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8680 | ret = append(ret, perMessageTest{ |
| 8681 | messageType: typeFinished, |
| 8682 | test: testCase{ |
| 8683 | testType: serverTest, |
| 8684 | protocol: protocol, |
| 8685 | name: "ClientFinished" + suffix, |
| 8686 | config: Config{ |
| 8687 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8688 | }, |
| 8689 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8690 | }) |
| 8691 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8692 | ret = append(ret, perMessageTest{ |
| 8693 | messageType: typeNewSessionTicket, |
| 8694 | test: testCase{ |
| 8695 | protocol: protocol, |
| 8696 | name: "NewSessionTicket" + suffix, |
| 8697 | config: Config{ |
| 8698 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8699 | }, |
| 8700 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8701 | }) |
| 8702 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8703 | ret = append(ret, perMessageTest{ |
| 8704 | messageType: typeFinished, |
| 8705 | test: testCase{ |
| 8706 | protocol: protocol, |
| 8707 | name: "ServerFinished" + suffix, |
| 8708 | config: Config{ |
| 8709 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8710 | }, |
| 8711 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8712 | }) |
| 8713 | |
| 8714 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8715 | |
| 8716 | ret = append(ret, perMessageTest{ |
| 8717 | messageType: typeClientHello, |
| 8718 | test: testCase{ |
| 8719 | testType: serverTest, |
| 8720 | name: "TLS13-ClientHello", |
| 8721 | config: Config{ |
| 8722 | MaxVersion: VersionTLS13, |
| 8723 | }, |
| 8724 | }, |
| 8725 | }) |
| 8726 | |
| 8727 | ret = append(ret, perMessageTest{ |
| 8728 | messageType: typeServerHello, |
| 8729 | test: testCase{ |
| 8730 | name: "TLS13-ServerHello", |
| 8731 | config: Config{ |
| 8732 | MaxVersion: VersionTLS13, |
| 8733 | }, |
| 8734 | }, |
| 8735 | }) |
| 8736 | |
| 8737 | ret = append(ret, perMessageTest{ |
| 8738 | messageType: typeEncryptedExtensions, |
| 8739 | test: testCase{ |
| 8740 | name: "TLS13-EncryptedExtensions", |
| 8741 | config: Config{ |
| 8742 | MaxVersion: VersionTLS13, |
| 8743 | }, |
| 8744 | }, |
| 8745 | }) |
| 8746 | |
| 8747 | ret = append(ret, perMessageTest{ |
| 8748 | messageType: typeCertificateRequest, |
| 8749 | test: testCase{ |
| 8750 | name: "TLS13-CertificateRequest", |
| 8751 | config: Config{ |
| 8752 | MaxVersion: VersionTLS13, |
| 8753 | ClientAuth: RequireAnyClientCert, |
| 8754 | }, |
| 8755 | }, |
| 8756 | }) |
| 8757 | |
| 8758 | ret = append(ret, perMessageTest{ |
| 8759 | messageType: typeCertificate, |
| 8760 | test: testCase{ |
| 8761 | name: "TLS13-ServerCertificate", |
| 8762 | config: Config{ |
| 8763 | MaxVersion: VersionTLS13, |
| 8764 | }, |
| 8765 | }, |
| 8766 | }) |
| 8767 | |
| 8768 | ret = append(ret, perMessageTest{ |
| 8769 | messageType: typeCertificateVerify, |
| 8770 | test: testCase{ |
| 8771 | name: "TLS13-ServerCertificateVerify", |
| 8772 | config: Config{ |
| 8773 | MaxVersion: VersionTLS13, |
| 8774 | }, |
| 8775 | }, |
| 8776 | }) |
| 8777 | |
| 8778 | ret = append(ret, perMessageTest{ |
| 8779 | messageType: typeFinished, |
| 8780 | test: testCase{ |
| 8781 | name: "TLS13-ServerFinished", |
| 8782 | config: Config{ |
| 8783 | MaxVersion: VersionTLS13, |
| 8784 | }, |
| 8785 | }, |
| 8786 | }) |
| 8787 | |
| 8788 | ret = append(ret, perMessageTest{ |
| 8789 | messageType: typeCertificate, |
| 8790 | test: testCase{ |
| 8791 | testType: serverTest, |
| 8792 | name: "TLS13-ClientCertificate", |
| 8793 | config: Config{ |
| 8794 | Certificates: []Certificate{rsaCertificate}, |
| 8795 | MaxVersion: VersionTLS13, |
| 8796 | }, |
| 8797 | flags: []string{"-require-any-client-certificate"}, |
| 8798 | }, |
| 8799 | }) |
| 8800 | |
| 8801 | ret = append(ret, perMessageTest{ |
| 8802 | messageType: typeCertificateVerify, |
| 8803 | test: testCase{ |
| 8804 | testType: serverTest, |
| 8805 | name: "TLS13-ClientCertificateVerify", |
| 8806 | config: Config{ |
| 8807 | Certificates: []Certificate{rsaCertificate}, |
| 8808 | MaxVersion: VersionTLS13, |
| 8809 | }, |
| 8810 | flags: []string{"-require-any-client-certificate"}, |
| 8811 | }, |
| 8812 | }) |
| 8813 | |
| 8814 | ret = append(ret, perMessageTest{ |
| 8815 | messageType: typeFinished, |
| 8816 | test: testCase{ |
| 8817 | testType: serverTest, |
| 8818 | name: "TLS13-ClientFinished", |
| 8819 | config: Config{ |
| 8820 | MaxVersion: VersionTLS13, |
| 8821 | }, |
| 8822 | }, |
| 8823 | }) |
| 8824 | |
| 8825 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8826 | } |
| 8827 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8828 | func addWrongMessageTypeTests() { |
| 8829 | for _, t := range makePerMessageTests() { |
| 8830 | t.test.name = "WrongMessageType-" + t.test.name |
| 8831 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 8832 | t.test.shouldFail = true |
| 8833 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 8834 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8835 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8836 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8837 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8838 | // an unencrypted alert while the server expects |
| 8839 | // encryption, so the alert is not readable by runner. |
| 8840 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8841 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8842 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 8843 | testCases = append(testCases, t.test) |
| 8844 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8845 | } |
| 8846 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8847 | func addTrailingMessageDataTests() { |
| 8848 | for _, t := range makePerMessageTests() { |
| 8849 | t.test.name = "TrailingMessageData-" + t.test.name |
| 8850 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 8851 | t.test.shouldFail = true |
| 8852 | t.test.expectedError = ":DECODE_ERROR:" |
| 8853 | t.test.expectedLocalError = "remote error: error decoding message" |
| 8854 | |
| 8855 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 8856 | // In TLS 1.3, a bad ServerHello means the client sends |
| 8857 | // an unencrypted alert while the server expects |
| 8858 | // encryption, so the alert is not readable by runner. |
| 8859 | t.test.expectedLocalError = "local error: bad record MAC" |
| 8860 | } |
| 8861 | |
| 8862 | if t.messageType == typeFinished { |
| 8863 | // Bad Finished messages read as the verify data having |
| 8864 | // the wrong length. |
| 8865 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 8866 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 8867 | } |
| 8868 | |
| 8869 | testCases = append(testCases, t.test) |
| 8870 | } |
| 8871 | } |
| 8872 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8873 | func addTLS13HandshakeTests() { |
| 8874 | testCases = append(testCases, testCase{ |
| 8875 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8876 | name: "NegotiatePSKResumption-TLS13", |
| 8877 | config: Config{ |
| 8878 | MaxVersion: VersionTLS13, |
| 8879 | Bugs: ProtocolBugs{ |
| 8880 | NegotiatePSKResumption: true, |
| 8881 | }, |
| 8882 | }, |
| 8883 | resumeSession: true, |
| 8884 | shouldFail: true, |
| 8885 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8886 | }) |
| 8887 | |
| 8888 | testCases = append(testCases, testCase{ |
| 8889 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8890 | name: "MissingKeyShare-Client", |
| 8891 | config: Config{ |
| 8892 | MaxVersion: VersionTLS13, |
| 8893 | Bugs: ProtocolBugs{ |
| 8894 | MissingKeyShare: true, |
| 8895 | }, |
| 8896 | }, |
| 8897 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8898 | expectedError: ":UNEXPECTED_EXTENSION:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8899 | }) |
| 8900 | |
| 8901 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8902 | testType: serverTest, |
| 8903 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8904 | config: Config{ |
| 8905 | MaxVersion: VersionTLS13, |
| 8906 | Bugs: ProtocolBugs{ |
| 8907 | MissingKeyShare: true, |
| 8908 | }, |
| 8909 | }, |
| 8910 | shouldFail: true, |
| 8911 | expectedError: ":MISSING_KEY_SHARE:", |
| 8912 | }) |
| 8913 | |
| 8914 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8915 | testType: serverTest, |
| 8916 | name: "DuplicateKeyShares", |
| 8917 | config: Config{ |
| 8918 | MaxVersion: VersionTLS13, |
| 8919 | Bugs: ProtocolBugs{ |
| 8920 | DuplicateKeyShares: true, |
| 8921 | }, |
| 8922 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 8923 | shouldFail: true, |
| 8924 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8925 | }) |
| 8926 | |
| 8927 | testCases = append(testCases, testCase{ |
| 8928 | testType: clientTest, |
| 8929 | name: "EmptyEncryptedExtensions", |
| 8930 | config: Config{ |
| 8931 | MaxVersion: VersionTLS13, |
| 8932 | Bugs: ProtocolBugs{ |
| 8933 | EmptyEncryptedExtensions: true, |
| 8934 | }, |
| 8935 | }, |
| 8936 | shouldFail: true, |
| 8937 | expectedLocalError: "remote error: error decoding message", |
| 8938 | }) |
| 8939 | |
| 8940 | testCases = append(testCases, testCase{ |
| 8941 | testType: clientTest, |
| 8942 | name: "EncryptedExtensionsWithKeyShare", |
| 8943 | config: Config{ |
| 8944 | MaxVersion: VersionTLS13, |
| 8945 | Bugs: ProtocolBugs{ |
| 8946 | EncryptedExtensionsWithKeyShare: true, |
| 8947 | }, |
| 8948 | }, |
| 8949 | shouldFail: true, |
| 8950 | expectedLocalError: "remote error: unsupported extension", |
| 8951 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8952 | |
| 8953 | testCases = append(testCases, testCase{ |
| 8954 | testType: serverTest, |
| 8955 | name: "SendHelloRetryRequest", |
| 8956 | config: Config{ |
| 8957 | MaxVersion: VersionTLS13, |
| 8958 | // Require a HelloRetryRequest for every curve. |
| 8959 | DefaultCurves: []CurveID{}, |
| 8960 | }, |
| 8961 | expectedCurveID: CurveX25519, |
| 8962 | }) |
| 8963 | |
| 8964 | testCases = append(testCases, testCase{ |
| 8965 | testType: serverTest, |
| 8966 | name: "SendHelloRetryRequest-2", |
| 8967 | config: Config{ |
| 8968 | MaxVersion: VersionTLS13, |
| 8969 | DefaultCurves: []CurveID{CurveP384}, |
| 8970 | }, |
| 8971 | // Although the ClientHello did not predict our preferred curve, |
| 8972 | // we always select it whether it is predicted or not. |
| 8973 | expectedCurveID: CurveX25519, |
| 8974 | }) |
| 8975 | |
| 8976 | testCases = append(testCases, testCase{ |
| 8977 | name: "UnknownCurve-HelloRetryRequest", |
| 8978 | config: Config{ |
| 8979 | MaxVersion: VersionTLS13, |
| 8980 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8981 | CurvePreferences: []CurveID{CurveP384}, |
| 8982 | Bugs: ProtocolBugs{ |
| 8983 | SendHelloRetryRequestCurve: bogusCurve, |
| 8984 | }, |
| 8985 | }, |
| 8986 | shouldFail: true, |
| 8987 | expectedError: ":WRONG_CURVE:", |
| 8988 | }) |
| 8989 | |
| 8990 | testCases = append(testCases, testCase{ |
| 8991 | name: "DisabledCurve-HelloRetryRequest", |
| 8992 | config: Config{ |
| 8993 | MaxVersion: VersionTLS13, |
| 8994 | CurvePreferences: []CurveID{CurveP256}, |
| 8995 | Bugs: ProtocolBugs{ |
| 8996 | IgnorePeerCurvePreferences: true, |
| 8997 | }, |
| 8998 | }, |
| 8999 | flags: []string{"-p384-only"}, |
| 9000 | shouldFail: true, |
| 9001 | expectedError: ":WRONG_CURVE:", |
| 9002 | }) |
| 9003 | |
| 9004 | testCases = append(testCases, testCase{ |
| 9005 | name: "UnnecessaryHelloRetryRequest", |
| 9006 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9007 | MaxVersion: VersionTLS13, |
| 9008 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9009 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9010 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9011 | }, |
| 9012 | }, |
| 9013 | shouldFail: true, |
| 9014 | expectedError: ":WRONG_CURVE:", |
| 9015 | }) |
| 9016 | |
| 9017 | testCases = append(testCases, testCase{ |
| 9018 | name: "SecondHelloRetryRequest", |
| 9019 | config: Config{ |
| 9020 | MaxVersion: VersionTLS13, |
| 9021 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9022 | CurvePreferences: []CurveID{CurveP384}, |
| 9023 | Bugs: ProtocolBugs{ |
| 9024 | SecondHelloRetryRequest: true, |
| 9025 | }, |
| 9026 | }, |
| 9027 | shouldFail: true, |
| 9028 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9029 | }) |
| 9030 | |
| 9031 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9032 | name: "HelloRetryRequest-Empty", |
| 9033 | config: Config{ |
| 9034 | MaxVersion: VersionTLS13, |
| 9035 | Bugs: ProtocolBugs{ |
| 9036 | AlwaysSendHelloRetryRequest: true, |
| 9037 | }, |
| 9038 | }, |
| 9039 | shouldFail: true, |
| 9040 | expectedError: ":DECODE_ERROR:", |
| 9041 | }) |
| 9042 | |
| 9043 | testCases = append(testCases, testCase{ |
| 9044 | name: "HelloRetryRequest-DuplicateCurve", |
| 9045 | config: Config{ |
| 9046 | MaxVersion: VersionTLS13, |
| 9047 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9048 | // configuration. Assert this ExpectMissingKeyShare. |
| 9049 | CurvePreferences: []CurveID{CurveP384}, |
| 9050 | Bugs: ProtocolBugs{ |
| 9051 | ExpectMissingKeyShare: true, |
| 9052 | DuplicateHelloRetryRequestExtensions: true, |
| 9053 | }, |
| 9054 | }, |
| 9055 | shouldFail: true, |
| 9056 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9057 | expectedLocalError: "remote error: illegal parameter", |
| 9058 | }) |
| 9059 | |
| 9060 | testCases = append(testCases, testCase{ |
| 9061 | name: "HelloRetryRequest-Cookie", |
| 9062 | config: Config{ |
| 9063 | MaxVersion: VersionTLS13, |
| 9064 | Bugs: ProtocolBugs{ |
| 9065 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9066 | }, |
| 9067 | }, |
| 9068 | }) |
| 9069 | |
| 9070 | testCases = append(testCases, testCase{ |
| 9071 | name: "HelloRetryRequest-DuplicateCookie", |
| 9072 | config: Config{ |
| 9073 | MaxVersion: VersionTLS13, |
| 9074 | Bugs: ProtocolBugs{ |
| 9075 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9076 | DuplicateHelloRetryRequestExtensions: true, |
| 9077 | }, |
| 9078 | }, |
| 9079 | shouldFail: true, |
| 9080 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9081 | expectedLocalError: "remote error: illegal parameter", |
| 9082 | }) |
| 9083 | |
| 9084 | testCases = append(testCases, testCase{ |
| 9085 | name: "HelloRetryRequest-EmptyCookie", |
| 9086 | config: Config{ |
| 9087 | MaxVersion: VersionTLS13, |
| 9088 | Bugs: ProtocolBugs{ |
| 9089 | SendHelloRetryRequestCookie: []byte{}, |
| 9090 | }, |
| 9091 | }, |
| 9092 | shouldFail: true, |
| 9093 | expectedError: ":DECODE_ERROR:", |
| 9094 | }) |
| 9095 | |
| 9096 | testCases = append(testCases, testCase{ |
| 9097 | name: "HelloRetryRequest-Cookie-Curve", |
| 9098 | config: Config{ |
| 9099 | MaxVersion: VersionTLS13, |
| 9100 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9101 | CurvePreferences: []CurveID{CurveP384}, |
| 9102 | Bugs: ProtocolBugs{ |
| 9103 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9104 | ExpectMissingKeyShare: true, |
| 9105 | }, |
| 9106 | }, |
| 9107 | }) |
| 9108 | |
| 9109 | testCases = append(testCases, testCase{ |
| 9110 | name: "HelloRetryRequest-Unknown", |
| 9111 | config: Config{ |
| 9112 | MaxVersion: VersionTLS13, |
| 9113 | Bugs: ProtocolBugs{ |
| 9114 | CustomHelloRetryRequestExtension: "extension", |
| 9115 | }, |
| 9116 | }, |
| 9117 | shouldFail: true, |
| 9118 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9119 | expectedLocalError: "remote error: unsupported extension", |
| 9120 | }) |
| 9121 | |
| 9122 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9123 | testType: serverTest, |
| 9124 | name: "SecondClientHelloMissingKeyShare", |
| 9125 | config: Config{ |
| 9126 | MaxVersion: VersionTLS13, |
| 9127 | DefaultCurves: []CurveID{}, |
| 9128 | Bugs: ProtocolBugs{ |
| 9129 | SecondClientHelloMissingKeyShare: true, |
| 9130 | }, |
| 9131 | }, |
| 9132 | shouldFail: true, |
| 9133 | expectedError: ":MISSING_KEY_SHARE:", |
| 9134 | }) |
| 9135 | |
| 9136 | testCases = append(testCases, testCase{ |
| 9137 | testType: serverTest, |
| 9138 | name: "SecondClientHelloWrongCurve", |
| 9139 | config: Config{ |
| 9140 | MaxVersion: VersionTLS13, |
| 9141 | DefaultCurves: []CurveID{}, |
| 9142 | Bugs: ProtocolBugs{ |
| 9143 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9144 | }, |
| 9145 | }, |
| 9146 | shouldFail: true, |
| 9147 | expectedError: ":WRONG_CURVE:", |
| 9148 | }) |
| 9149 | |
| 9150 | testCases = append(testCases, testCase{ |
| 9151 | name: "HelloRetryRequestVersionMismatch", |
| 9152 | config: Config{ |
| 9153 | MaxVersion: VersionTLS13, |
| 9154 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9155 | CurvePreferences: []CurveID{CurveP384}, |
| 9156 | Bugs: ProtocolBugs{ |
| 9157 | SendServerHelloVersion: 0x0305, |
| 9158 | }, |
| 9159 | }, |
| 9160 | shouldFail: true, |
| 9161 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9162 | }) |
| 9163 | |
| 9164 | testCases = append(testCases, testCase{ |
| 9165 | name: "HelloRetryRequestCurveMismatch", |
| 9166 | config: Config{ |
| 9167 | MaxVersion: VersionTLS13, |
| 9168 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9169 | CurvePreferences: []CurveID{CurveP384}, |
| 9170 | Bugs: ProtocolBugs{ |
| 9171 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9172 | SendHelloRetryRequestCurve: CurveP384, |
| 9173 | // But send P-256 in the ServerHello. |
| 9174 | SendCurve: CurveP256, |
| 9175 | }, |
| 9176 | }, |
| 9177 | shouldFail: true, |
| 9178 | expectedError: ":WRONG_CURVE:", |
| 9179 | }) |
| 9180 | |
| 9181 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9182 | // without sending it. |
| 9183 | testCases = append(testCases, testCase{ |
| 9184 | name: "SkipHelloRetryRequest", |
| 9185 | config: Config{ |
| 9186 | MaxVersion: VersionTLS13, |
| 9187 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9188 | CurvePreferences: []CurveID{CurveP384}, |
| 9189 | Bugs: ProtocolBugs{ |
| 9190 | SkipHelloRetryRequest: true, |
| 9191 | }, |
| 9192 | }, |
| 9193 | shouldFail: true, |
| 9194 | expectedError: ":WRONG_CURVE:", |
| 9195 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9196 | |
| 9197 | testCases = append(testCases, testCase{ |
| 9198 | name: "TLS13-RequestContextInHandshake", |
| 9199 | config: Config{ |
| 9200 | MaxVersion: VersionTLS13, |
| 9201 | MinVersion: VersionTLS13, |
| 9202 | ClientAuth: RequireAnyClientCert, |
| 9203 | Bugs: ProtocolBugs{ |
| 9204 | SendRequestContext: []byte("request context"), |
| 9205 | }, |
| 9206 | }, |
| 9207 | flags: []string{ |
| 9208 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9209 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9210 | }, |
| 9211 | shouldFail: true, |
| 9212 | expectedError: ":DECODE_ERROR:", |
| 9213 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9214 | |
| 9215 | testCases = append(testCases, testCase{ |
| 9216 | testType: serverTest, |
| 9217 | name: "TLS13-TrailingKeyShareData", |
| 9218 | config: Config{ |
| 9219 | MaxVersion: VersionTLS13, |
| 9220 | Bugs: ProtocolBugs{ |
| 9221 | TrailingKeyShareData: true, |
| 9222 | }, |
| 9223 | }, |
| 9224 | shouldFail: true, |
| 9225 | expectedError: ":DECODE_ERROR:", |
| 9226 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9227 | |
| 9228 | testCases = append(testCases, testCase{ |
| 9229 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9230 | config: Config{ |
| 9231 | MaxVersion: VersionTLS13, |
| 9232 | Bugs: ProtocolBugs{ |
| 9233 | AlwaysSelectPSKIdentity: true, |
| 9234 | }, |
| 9235 | }, |
| 9236 | shouldFail: true, |
| 9237 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9238 | }) |
| 9239 | |
| 9240 | testCases = append(testCases, testCase{ |
| 9241 | name: "TLS13-InvalidPSKIdentity", |
| 9242 | config: Config{ |
| 9243 | MaxVersion: VersionTLS13, |
| 9244 | Bugs: ProtocolBugs{ |
| 9245 | SelectPSKIdentityOnResume: 1, |
| 9246 | }, |
| 9247 | }, |
| 9248 | resumeSession: true, |
| 9249 | shouldFail: true, |
| 9250 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9251 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9252 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9253 | testCases = append(testCases, testCase{ |
| 9254 | testType: serverTest, |
| 9255 | name: "TLS13-ExtraPSKIdentity", |
| 9256 | config: Config{ |
| 9257 | MaxVersion: VersionTLS13, |
| 9258 | Bugs: ProtocolBugs{ |
| 9259 | ExtraPSKIdentity: true, |
| 9260 | }, |
| 9261 | }, |
| 9262 | resumeSession: true, |
| 9263 | }) |
| 9264 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9265 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9266 | testCases = append(testCases, testCase{ |
| 9267 | name: "TLS13-CustomTicketExtension", |
| 9268 | config: Config{ |
| 9269 | MaxVersion: VersionTLS13, |
| 9270 | Bugs: ProtocolBugs{ |
| 9271 | CustomTicketExtension: "1234", |
| 9272 | }, |
| 9273 | }, |
| 9274 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9275 | } |
| 9276 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9277 | func addTLS13CipherPreferenceTests() { |
| 9278 | // Test that client preference is honored if the shim has AES hardware |
| 9279 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 9280 | testCases = append(testCases, testCase{ |
| 9281 | testType: serverTest, |
| 9282 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 9283 | config: Config{ |
| 9284 | MaxVersion: VersionTLS13, |
| 9285 | CipherSuites: []uint16{ |
| 9286 | TLS_CHACHA20_POLY1305_SHA256, |
| 9287 | TLS_AES_128_GCM_SHA256, |
| 9288 | }, |
| 9289 | }, |
| 9290 | flags: []string{ |
| 9291 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9292 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9293 | }, |
| 9294 | }) |
| 9295 | |
| 9296 | testCases = append(testCases, testCase{ |
| 9297 | testType: serverTest, |
| 9298 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 9299 | config: Config{ |
| 9300 | MaxVersion: VersionTLS13, |
| 9301 | CipherSuites: []uint16{ |
| 9302 | TLS_AES_128_GCM_SHA256, |
| 9303 | TLS_CHACHA20_POLY1305_SHA256, |
| 9304 | }, |
| 9305 | }, |
| 9306 | flags: []string{ |
| 9307 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9308 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9309 | }, |
| 9310 | }) |
| 9311 | |
| 9312 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 9313 | // whether it has AES hardware. |
| 9314 | testCases = append(testCases, testCase{ |
| 9315 | name: "TLS13-CipherPreference-Client", |
| 9316 | config: Config{ |
| 9317 | MaxVersion: VersionTLS13, |
| 9318 | // Use the client cipher order. (This is the default but |
| 9319 | // is listed to be explicit.) |
| 9320 | PreferServerCipherSuites: false, |
| 9321 | }, |
| 9322 | flags: []string{ |
| 9323 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 9324 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 9325 | }, |
| 9326 | }) |
| 9327 | } |
| 9328 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9329 | func addPeekTests() { |
| 9330 | // Test SSL_peek works, including on empty records. |
| 9331 | testCases = append(testCases, testCase{ |
| 9332 | name: "Peek-Basic", |
| 9333 | sendEmptyRecords: 1, |
| 9334 | flags: []string{"-peek-then-read"}, |
| 9335 | }) |
| 9336 | |
| 9337 | // Test SSL_peek can drive the initial handshake. |
| 9338 | testCases = append(testCases, testCase{ |
| 9339 | name: "Peek-ImplicitHandshake", |
| 9340 | flags: []string{ |
| 9341 | "-peek-then-read", |
| 9342 | "-implicit-handshake", |
| 9343 | }, |
| 9344 | }) |
| 9345 | |
| 9346 | // Test SSL_peek can discover and drive a renegotiation. |
| 9347 | testCases = append(testCases, testCase{ |
| 9348 | name: "Peek-Renegotiate", |
| 9349 | config: Config{ |
| 9350 | MaxVersion: VersionTLS12, |
| 9351 | }, |
| 9352 | renegotiate: 1, |
| 9353 | flags: []string{ |
| 9354 | "-peek-then-read", |
| 9355 | "-renegotiate-freely", |
| 9356 | "-expect-total-renegotiations", "1", |
| 9357 | }, |
| 9358 | }) |
| 9359 | |
| 9360 | // Test SSL_peek can discover a close_notify. |
| 9361 | testCases = append(testCases, testCase{ |
| 9362 | name: "Peek-Shutdown", |
| 9363 | config: Config{ |
| 9364 | Bugs: ProtocolBugs{ |
| 9365 | ExpectCloseNotify: true, |
| 9366 | }, |
| 9367 | }, |
| 9368 | flags: []string{ |
| 9369 | "-peek-then-read", |
| 9370 | "-check-close-notify", |
| 9371 | }, |
| 9372 | }) |
| 9373 | |
| 9374 | // Test SSL_peek can discover an alert. |
| 9375 | testCases = append(testCases, testCase{ |
| 9376 | name: "Peek-Alert", |
| 9377 | config: Config{ |
| 9378 | Bugs: ProtocolBugs{ |
| 9379 | SendSpuriousAlert: alertRecordOverflow, |
| 9380 | }, |
| 9381 | }, |
| 9382 | flags: []string{"-peek-then-read"}, |
| 9383 | shouldFail: true, |
| 9384 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 9385 | }) |
| 9386 | |
| 9387 | // Test SSL_peek can handle KeyUpdate. |
| 9388 | testCases = append(testCases, testCase{ |
| 9389 | name: "Peek-KeyUpdate", |
| 9390 | config: Config{ |
| 9391 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9392 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 9393 | sendKeyUpdates: 1, |
| 9394 | keyUpdateRequest: keyUpdateNotRequested, |
| 9395 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9396 | }) |
| 9397 | } |
| 9398 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9399 | func addRecordVersionTests() { |
| 9400 | for _, ver := range tlsVersions { |
| 9401 | // Test that the record version is enforced. |
| 9402 | testCases = append(testCases, testCase{ |
| 9403 | name: "CheckRecordVersion-" + ver.name, |
| 9404 | config: Config{ |
| 9405 | MinVersion: ver.version, |
| 9406 | MaxVersion: ver.version, |
| 9407 | Bugs: ProtocolBugs{ |
| 9408 | SendRecordVersion: 0x03ff, |
| 9409 | }, |
| 9410 | }, |
| 9411 | shouldFail: true, |
| 9412 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9413 | }) |
| 9414 | |
| 9415 | // Test that the ClientHello may use any record version, for |
| 9416 | // compatibility reasons. |
| 9417 | testCases = append(testCases, testCase{ |
| 9418 | testType: serverTest, |
| 9419 | name: "LooseInitialRecordVersion-" + ver.name, |
| 9420 | config: Config{ |
| 9421 | MinVersion: ver.version, |
| 9422 | MaxVersion: ver.version, |
| 9423 | Bugs: ProtocolBugs{ |
| 9424 | SendInitialRecordVersion: 0x03ff, |
| 9425 | }, |
| 9426 | }, |
| 9427 | }) |
| 9428 | |
| 9429 | // Test that garbage ClientHello record versions are rejected. |
| 9430 | testCases = append(testCases, testCase{ |
| 9431 | testType: serverTest, |
| 9432 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 9433 | config: Config{ |
| 9434 | MinVersion: ver.version, |
| 9435 | MaxVersion: ver.version, |
| 9436 | Bugs: ProtocolBugs{ |
| 9437 | SendInitialRecordVersion: 0xffff, |
| 9438 | }, |
| 9439 | }, |
| 9440 | shouldFail: true, |
| 9441 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9442 | }) |
| 9443 | } |
| 9444 | } |
| 9445 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9446 | func addCertificateTests() { |
| 9447 | // Test that a certificate chain with intermediate may be sent and |
| 9448 | // received as both client and server. |
| 9449 | for _, ver := range tlsVersions { |
| 9450 | testCases = append(testCases, testCase{ |
| 9451 | testType: clientTest, |
| 9452 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 9453 | config: Config{ |
| 9454 | Certificates: []Certificate{rsaChainCertificate}, |
| 9455 | ClientAuth: RequireAnyClientCert, |
| 9456 | }, |
| 9457 | expectPeerCertificate: &rsaChainCertificate, |
| 9458 | flags: []string{ |
| 9459 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9460 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9461 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9462 | }, |
| 9463 | }) |
| 9464 | |
| 9465 | testCases = append(testCases, testCase{ |
| 9466 | testType: serverTest, |
| 9467 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 9468 | config: Config{ |
| 9469 | Certificates: []Certificate{rsaChainCertificate}, |
| 9470 | }, |
| 9471 | expectPeerCertificate: &rsaChainCertificate, |
| 9472 | flags: []string{ |
| 9473 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9474 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 9475 | "-require-any-client-certificate", |
| 9476 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 9477 | }, |
| 9478 | }) |
| 9479 | } |
| 9480 | } |
| 9481 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9482 | 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] | 9483 | defer wg.Done() |
| 9484 | |
| 9485 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9486 | var err error |
| 9487 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9488 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9489 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 9490 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9491 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9492 | if err != nil { |
| 9493 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 9494 | } |
| 9495 | break |
| 9496 | } |
| 9497 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9498 | } else if *repeatUntilFailure { |
| 9499 | for err == nil { |
| 9500 | statusChan <- statusMsg{test: test, started: true} |
| 9501 | err = runTest(test, shimPath, -1) |
| 9502 | } |
| 9503 | } else { |
| 9504 | statusChan <- statusMsg{test: test, started: true} |
| 9505 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 9506 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9507 | statusChan <- statusMsg{test: test, err: err} |
| 9508 | } |
| 9509 | } |
| 9510 | |
| 9511 | type statusMsg struct { |
| 9512 | test *testCase |
| 9513 | started bool |
| 9514 | err error |
| 9515 | } |
| 9516 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9517 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9518 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9519 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9520 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9521 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9522 | if !*pipe { |
| 9523 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 9524 | var erase string |
| 9525 | for i := 0; i < lineLen; i++ { |
| 9526 | erase += "\b \b" |
| 9527 | } |
| 9528 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9529 | } |
| 9530 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9531 | if msg.started { |
| 9532 | started++ |
| 9533 | } else { |
| 9534 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9535 | |
| 9536 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9537 | if msg.err == errUnimplemented { |
| 9538 | if *pipe { |
| 9539 | // Print each test instead of a status line. |
| 9540 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 9541 | } |
| 9542 | unimplemented++ |
| 9543 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 9544 | } else { |
| 9545 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 9546 | failed++ |
| 9547 | testOutput.addResult(msg.test.name, "FAIL") |
| 9548 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9549 | } else { |
| 9550 | if *pipe { |
| 9551 | // Print each test instead of a status line. |
| 9552 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 9553 | } |
| 9554 | testOutput.addResult(msg.test.name, "PASS") |
| 9555 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9556 | } |
| 9557 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9558 | if !*pipe { |
| 9559 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9560 | 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] | 9561 | lineLen = len(line) |
| 9562 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9563 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9564 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9565 | |
| 9566 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9567 | } |
| 9568 | |
| 9569 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9570 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9571 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 9572 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9573 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9574 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9575 | addCipherSuiteTests() |
| 9576 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9577 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 9578 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 9579 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 9580 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 9581 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 9582 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 9583 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 9584 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 9585 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 9586 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 9587 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 9588 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 9589 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 9590 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 9591 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9592 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9593 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9594 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 9595 | addCECPQ1Tests() |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9596 | addDHEGroupSizeTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9597 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9598 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 9599 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9600 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9601 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9602 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9603 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 9604 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 9605 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 9606 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 9607 | addCertificateTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9608 | |
| 9609 | var wg sync.WaitGroup |
| 9610 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9611 | statusChan := make(chan statusMsg, *numWorkers) |
| 9612 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9613 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9614 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9615 | if len(*shimConfigFile) != 0 { |
| 9616 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 9617 | if err != nil { |
| 9618 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 9619 | os.Exit(1) |
| 9620 | } |
| 9621 | |
| 9622 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 9623 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 9624 | os.Exit(1) |
| 9625 | } |
| 9626 | } |
| 9627 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9628 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9629 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9630 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9631 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 9632 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9633 | } |
| 9634 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9635 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9636 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9637 | matched := true |
| 9638 | if len(*testToRun) != 0 { |
| 9639 | var err error |
| 9640 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 9641 | if err != nil { |
| 9642 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 9643 | os.Exit(1) |
| 9644 | } |
| 9645 | } |
| 9646 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9647 | if !*includeDisabled { |
| 9648 | for pattern := range shimConfig.DisabledTests { |
| 9649 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 9650 | if err != nil { |
| 9651 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 9652 | os.Exit(1) |
| 9653 | } |
| 9654 | |
| 9655 | if isDisabled { |
| 9656 | matched = false |
| 9657 | break |
| 9658 | } |
| 9659 | } |
| 9660 | } |
| 9661 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9662 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9663 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 9664 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 9665 | |
| 9666 | // Only run one test if repeating until failure. |
| 9667 | if *repeatUntilFailure { |
| 9668 | break |
| 9669 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9670 | } |
| 9671 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 9672 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9673 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 9674 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 9675 | os.Exit(1) |
| 9676 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9677 | |
| 9678 | close(testChan) |
| 9679 | wg.Wait() |
| 9680 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9681 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9682 | |
| 9683 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 9684 | |
| 9685 | if *jsonOutput != "" { |
| 9686 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 9687 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 9688 | } |
| 9689 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9690 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 9691 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 9692 | os.Exit(1) |
| 9693 | } |
| 9694 | |
| 9695 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 9696 | os.Exit(1) |
| 9697 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 9698 | } |