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 |
| 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 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" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 23 | "encoding/pem" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 24 | "flag" |
| 25 | "fmt" |
| 26 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 27 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 28 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 29 | "net" |
| 30 | "os" |
| 31 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 32 | "path" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 33 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 34 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 35 | "strings" |
| 36 | "sync" |
| 37 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 38 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 39 | ) |
| 40 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 41 | var ( |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 42 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 43 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 44 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 45 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 46 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 47 | 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.") |
| 48 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 49 | pipe = flag.Bool("pipe", false, "If true, print status output suitable for piping into another program.") |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 50 | testToRun = flag.String("test", "", "The name of a test to run, or empty to run all tests") |
| 51 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 52 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 53 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
David Benjamin | f2b8363 | 2016-03-01 22:57:46 -0500 | [diff] [blame] | 54 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 55 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 56 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 57 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 58 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 59 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 60 | type testCert int |
| 61 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 62 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 63 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 64 | testCertRSA1024 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 65 | testCertECDSAP256 |
| 66 | testCertECDSAP384 |
| 67 | testCertECDSAP521 |
| 68 | ) |
| 69 | |
| 70 | const ( |
| 71 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 72 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 73 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 74 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 75 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 76 | ) |
| 77 | |
| 78 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 79 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 80 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 81 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 82 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 83 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 84 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 85 | ) |
| 86 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 87 | var ( |
| 88 | rsaCertificate Certificate |
| 89 | rsa1024Certificate Certificate |
| 90 | ecdsaP256Certificate Certificate |
| 91 | ecdsaP384Certificate Certificate |
| 92 | ecdsaP521Certificate Certificate |
| 93 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 94 | |
| 95 | var testCerts = []struct { |
| 96 | id testCert |
| 97 | certFile, keyFile string |
| 98 | cert *Certificate |
| 99 | }{ |
| 100 | { |
| 101 | id: testCertRSA, |
| 102 | certFile: rsaCertificateFile, |
| 103 | keyFile: rsaKeyFile, |
| 104 | cert: &rsaCertificate, |
| 105 | }, |
| 106 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 107 | id: testCertRSA1024, |
| 108 | certFile: rsa1024CertificateFile, |
| 109 | keyFile: rsa1024KeyFile, |
| 110 | cert: &rsa1024Certificate, |
| 111 | }, |
| 112 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 113 | id: testCertECDSAP256, |
| 114 | certFile: ecdsaP256CertificateFile, |
| 115 | keyFile: ecdsaP256KeyFile, |
| 116 | cert: &ecdsaP256Certificate, |
| 117 | }, |
| 118 | { |
| 119 | id: testCertECDSAP384, |
| 120 | certFile: ecdsaP384CertificateFile, |
| 121 | keyFile: ecdsaP384KeyFile, |
| 122 | cert: &ecdsaP384Certificate, |
| 123 | }, |
| 124 | { |
| 125 | id: testCertECDSAP521, |
| 126 | certFile: ecdsaP521CertificateFile, |
| 127 | keyFile: ecdsaP521KeyFile, |
| 128 | cert: &ecdsaP521Certificate, |
| 129 | }, |
| 130 | } |
| 131 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 132 | var channelIDKey *ecdsa.PrivateKey |
| 133 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 134 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 135 | var testOCSPResponse = []byte{1, 2, 3, 4} |
| 136 | var testSCTList = []byte{5, 6, 7, 8} |
| 137 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 138 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 139 | for i := range testCerts { |
| 140 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 141 | if err != nil { |
| 142 | panic(err) |
| 143 | } |
| 144 | cert.OCSPStaple = testOCSPResponse |
| 145 | cert.SignedCertificateTimestampList = testSCTList |
| 146 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 147 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 148 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 149 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 150 | if err != nil { |
| 151 | panic(err) |
| 152 | } |
| 153 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 154 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 155 | panic("bad key type") |
| 156 | } |
| 157 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 158 | if err != nil { |
| 159 | panic(err) |
| 160 | } |
| 161 | if channelIDKey.Curve != elliptic.P256() { |
| 162 | panic("bad curve") |
| 163 | } |
| 164 | |
| 165 | channelIDBytes = make([]byte, 64) |
| 166 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 167 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 168 | } |
| 169 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 170 | func getRunnerCertificate(t testCert) Certificate { |
| 171 | for _, cert := range testCerts { |
| 172 | if cert.id == t { |
| 173 | return *cert.cert |
| 174 | } |
| 175 | } |
| 176 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 177 | } |
| 178 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 179 | func getShimCertificate(t testCert) string { |
| 180 | for _, cert := range testCerts { |
| 181 | if cert.id == t { |
| 182 | return cert.certFile |
| 183 | } |
| 184 | } |
| 185 | panic("Unknown test certificate") |
| 186 | } |
| 187 | |
| 188 | func getShimKey(t testCert) string { |
| 189 | for _, cert := range testCerts { |
| 190 | if cert.id == t { |
| 191 | return cert.keyFile |
| 192 | } |
| 193 | } |
| 194 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 195 | } |
| 196 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 197 | type testType int |
| 198 | |
| 199 | const ( |
| 200 | clientTest testType = iota |
| 201 | serverTest |
| 202 | ) |
| 203 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 204 | type protocol int |
| 205 | |
| 206 | const ( |
| 207 | tls protocol = iota |
| 208 | dtls |
| 209 | ) |
| 210 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 211 | const ( |
| 212 | alpn = 1 |
| 213 | npn = 2 |
| 214 | ) |
| 215 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 217 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 218 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 219 | name string |
| 220 | config Config |
| 221 | shouldFail bool |
| 222 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 223 | // expectedLocalError, if not empty, contains a substring that must be |
| 224 | // found in the local error. |
| 225 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 226 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 227 | // negotiated. |
| 228 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 229 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 230 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 231 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 232 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 233 | // should be negotiated. |
| 234 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 235 | // expectChannelID controls whether the connection should have |
| 236 | // negotiated a Channel ID with channelIDKey. |
| 237 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 238 | // expectedNextProto controls whether the connection should |
| 239 | // negotiate a next protocol via NPN or ALPN. |
| 240 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 241 | // expectNoNextProto, if true, means that no next protocol should be |
| 242 | // negotiated. |
| 243 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 244 | // expectedNextProtoType, if non-zero, is the expected next |
| 245 | // protocol negotiation mechanism. |
| 246 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 247 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 248 | // should be negotiated. If zero, none should be negotiated. |
| 249 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 250 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 251 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 252 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 253 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 254 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 255 | // algorithm that the peer should have used in the handshake. |
| 256 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 257 | // messageLen is the length, in bytes, of the test message that will be |
| 258 | // sent. |
| 259 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 260 | // messageCount is the number of test messages that will be sent. |
| 261 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 262 | // certFile is the path to the certificate to use for the server. |
| 263 | certFile string |
| 264 | // keyFile is the path to the private key to use for the server. |
| 265 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 266 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 267 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 268 | resumeSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 269 | // expectResumeRejected, if true, specifies that the attempted |
| 270 | // resumption must be rejected by the client. This is only valid for a |
| 271 | // serverTest. |
| 272 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 273 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 274 | // resumption. Unless newSessionsOnResume is set, |
| 275 | // SessionTicketKey, ServerSessionCache, and |
| 276 | // ClientSessionCache are copied from the initial connection's |
| 277 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 278 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 279 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 280 | // use a different session resumption context. |
| 281 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 282 | // noSessionCache, if true, will cause the server to run without a |
| 283 | // session cache. |
| 284 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 285 | // sendPrefix sends a prefix on the socket before actually performing a |
| 286 | // handshake. |
| 287 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 288 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 289 | // message before doing a roundtrip with the runner. |
| 290 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 291 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 292 | // connection immediately after the handshake rather than echoing |
| 293 | // messages from the runner. |
| 294 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 295 | // renegotiate indicates the number of times the connection should be |
| 296 | // renegotiated during the exchange. |
| 297 | renegotiate int |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 298 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 299 | // switched in just before renegotiation. |
| 300 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 301 | // replayWrites, if true, configures the underlying transport |
| 302 | // to replay every write it makes in DTLS tests. |
| 303 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 304 | // damageFirstWrite, if true, configures the underlying transport to |
| 305 | // damage the final byte of the first application data write. |
| 306 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 307 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 308 | // keying material and verify they match. |
| 309 | exportKeyingMaterial int |
| 310 | exportLabel string |
| 311 | exportContext string |
| 312 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 313 | // flags, if not empty, contains a list of command-line flags that will |
| 314 | // be passed to the shim program. |
| 315 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 316 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 317 | // which will be compared against the expected value. |
| 318 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 319 | // sendEmptyRecords is the number of consecutive empty records to send |
| 320 | // before and after the test message. |
| 321 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 322 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 323 | // before and after the test message. |
| 324 | sendWarningAlerts int |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 325 | // expectMessageDropped, if true, means the test message is expected to |
| 326 | // be dropped by the client rather than echoed back. |
| 327 | expectMessageDropped bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 330 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 331 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 332 | func writeTranscript(test *testCase, isResume bool, data []byte) { |
| 333 | if len(data) == 0 { |
| 334 | return |
| 335 | } |
| 336 | |
| 337 | protocol := "tls" |
| 338 | if test.protocol == dtls { |
| 339 | protocol = "dtls" |
| 340 | } |
| 341 | |
| 342 | side := "client" |
| 343 | if test.testType == serverTest { |
| 344 | side = "server" |
| 345 | } |
| 346 | |
| 347 | dir := path.Join(*transcriptDir, protocol, side) |
| 348 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 349 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 350 | return |
| 351 | } |
| 352 | |
| 353 | name := test.name |
| 354 | if isResume { |
| 355 | name += "-Resume" |
| 356 | } else { |
| 357 | name += "-Normal" |
| 358 | } |
| 359 | |
| 360 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 361 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 362 | } |
| 363 | } |
| 364 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 365 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 366 | type timeoutConn struct { |
| 367 | net.Conn |
| 368 | timeout time.Duration |
| 369 | } |
| 370 | |
| 371 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 372 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 373 | return 0, err |
| 374 | } |
| 375 | return t.Conn.Read(b) |
| 376 | } |
| 377 | |
| 378 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 379 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 380 | return 0, err |
| 381 | } |
| 382 | return t.Conn.Write(b) |
| 383 | } |
| 384 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 385 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool) error { |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 386 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 387 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 388 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 389 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 390 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 391 | } |
| 392 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 393 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 394 | local, peer := "client", "server" |
| 395 | if test.testType == clientTest { |
| 396 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 397 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 398 | connDebug := &recordingConn{ |
| 399 | Conn: conn, |
| 400 | isDatagram: test.protocol == dtls, |
| 401 | local: local, |
| 402 | peer: peer, |
| 403 | } |
| 404 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 405 | if *flagDebug { |
| 406 | defer connDebug.WriteTo(os.Stdout) |
| 407 | } |
| 408 | if len(*transcriptDir) != 0 { |
| 409 | defer func() { |
| 410 | writeTranscript(test, isResume, connDebug.Transcript()) |
| 411 | }() |
| 412 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 413 | |
| 414 | if config.Bugs.PacketAdaptor != nil { |
| 415 | config.Bugs.PacketAdaptor.debug = connDebug |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | if test.replayWrites { |
| 420 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 421 | } |
| 422 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 423 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 424 | if test.damageFirstWrite { |
| 425 | connDamage = newDamageAdaptor(conn) |
| 426 | conn = connDamage |
| 427 | } |
| 428 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 429 | if test.sendPrefix != "" { |
| 430 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 431 | return err |
| 432 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 433 | } |
| 434 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 435 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 436 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 437 | if test.protocol == dtls { |
| 438 | tlsConn = DTLSServer(conn, config) |
| 439 | } else { |
| 440 | tlsConn = Server(conn, config) |
| 441 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 442 | } else { |
| 443 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 444 | if test.protocol == dtls { |
| 445 | tlsConn = DTLSClient(conn, config) |
| 446 | } else { |
| 447 | tlsConn = Client(conn, config) |
| 448 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 449 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 450 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 451 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 452 | if err := tlsConn.Handshake(); err != nil { |
| 453 | return err |
| 454 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 455 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 456 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 457 | // expectations struct that can be specified separately for the two |
| 458 | // legs. |
| 459 | expectedVersion := test.expectedVersion |
| 460 | if isResume && test.expectedResumeVersion != 0 { |
| 461 | expectedVersion = test.expectedResumeVersion |
| 462 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 463 | connState := tlsConn.ConnectionState() |
| 464 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 465 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 466 | } |
| 467 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 468 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 469 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 470 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 471 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 472 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 473 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 474 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 475 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 476 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 477 | if channelID == nil { |
| 478 | return fmt.Errorf("no channel ID negotiated") |
| 479 | } |
| 480 | if channelID.Curve != channelIDKey.Curve || |
| 481 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 482 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 483 | return fmt.Errorf("incorrect channel ID") |
| 484 | } |
| 485 | } |
| 486 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 487 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 488 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 489 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 490 | } |
| 491 | } |
| 492 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 493 | if test.expectNoNextProto { |
| 494 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 495 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 496 | } |
| 497 | } |
| 498 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 499 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 500 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 501 | return fmt.Errorf("next proto type mismatch") |
| 502 | } |
| 503 | } |
| 504 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 505 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 506 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 507 | } |
| 508 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 509 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
| 510 | return fmt.Errorf("OCSP Response mismatch") |
| 511 | } |
| 512 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 513 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 514 | return fmt.Errorf("SCT list mismatch") |
| 515 | } |
| 516 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 517 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 518 | 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] | 519 | } |
| 520 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 521 | if test.exportKeyingMaterial > 0 { |
| 522 | actual := make([]byte, test.exportKeyingMaterial) |
| 523 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 524 | return err |
| 525 | } |
| 526 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 527 | if err != nil { |
| 528 | return err |
| 529 | } |
| 530 | if !bytes.Equal(actual, expected) { |
| 531 | return fmt.Errorf("keying material mismatch") |
| 532 | } |
| 533 | } |
| 534 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 535 | if test.testTLSUnique { |
| 536 | var peersValue [12]byte |
| 537 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 538 | return err |
| 539 | } |
| 540 | expected := tlsConn.ConnectionState().TLSUnique |
| 541 | if !bytes.Equal(peersValue[:], expected) { |
| 542 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 543 | } |
| 544 | } |
| 545 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 546 | if test.shimWritesFirst { |
| 547 | var buf [5]byte |
| 548 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 549 | if err != nil { |
| 550 | return err |
| 551 | } |
| 552 | if string(buf[:]) != "hello" { |
| 553 | return fmt.Errorf("bad initial message") |
| 554 | } |
| 555 | } |
| 556 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 557 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 558 | tlsConn.Write(nil) |
| 559 | } |
| 560 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 561 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 562 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 563 | } |
| 564 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 565 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 566 | if test.renegotiateCiphers != nil { |
| 567 | config.CipherSuites = test.renegotiateCiphers |
| 568 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 569 | for i := 0; i < test.renegotiate; i++ { |
| 570 | if err := tlsConn.Renegotiate(); err != nil { |
| 571 | return err |
| 572 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 573 | } |
| 574 | } else if test.renegotiateCiphers != nil { |
| 575 | panic("renegotiateCiphers without renegotiate") |
| 576 | } |
| 577 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 578 | if test.damageFirstWrite { |
| 579 | connDamage.setDamage(true) |
| 580 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 581 | connDamage.setDamage(false) |
| 582 | } |
| 583 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 584 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 585 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 586 | if test.protocol == dtls { |
| 587 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 588 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 589 | // Read until EOF. |
| 590 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 591 | return err |
| 592 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 593 | if messageLen == 0 { |
| 594 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 595 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 596 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 597 | messageCount := test.messageCount |
| 598 | if messageCount == 0 { |
| 599 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 600 | } |
| 601 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 602 | for j := 0; j < messageCount; j++ { |
| 603 | testMessage := make([]byte, messageLen) |
| 604 | for i := range testMessage { |
| 605 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 606 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 607 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 608 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 609 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 610 | tlsConn.Write(nil) |
| 611 | } |
| 612 | |
| 613 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 614 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 615 | } |
| 616 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 617 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 618 | // The shim will not respond. |
| 619 | continue |
| 620 | } |
| 621 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 622 | buf := make([]byte, len(testMessage)) |
| 623 | if test.protocol == dtls { |
| 624 | bufTmp := make([]byte, len(buf)+1) |
| 625 | n, err := tlsConn.Read(bufTmp) |
| 626 | if err != nil { |
| 627 | return err |
| 628 | } |
| 629 | if n != len(buf) { |
| 630 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 631 | } |
| 632 | copy(buf, bufTmp) |
| 633 | } else { |
| 634 | _, err := io.ReadFull(tlsConn, buf) |
| 635 | if err != nil { |
| 636 | return err |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | for i, v := range buf { |
| 641 | if v != testMessage[i]^0xff { |
| 642 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 643 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 644 | } |
| 645 | } |
| 646 | |
| 647 | return nil |
| 648 | } |
| 649 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 650 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
| 651 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 652 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 653 | 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] | 654 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 655 | valgrindArgs = append(valgrindArgs, path) |
| 656 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 657 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 658 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 659 | } |
| 660 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 661 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 662 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 663 | xtermArgs = append(xtermArgs, path) |
| 664 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 665 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 666 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 667 | } |
| 668 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 669 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 670 | xtermArgs := []string{"-e", "lldb", "--"} |
| 671 | xtermArgs = append(xtermArgs, path) |
| 672 | xtermArgs = append(xtermArgs, args...) |
| 673 | |
| 674 | return exec.Command("xterm", xtermArgs...) |
| 675 | } |
| 676 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 677 | type moreMallocsError struct{} |
| 678 | |
| 679 | func (moreMallocsError) Error() string { |
| 680 | return "child process did not exhaust all allocation calls" |
| 681 | } |
| 682 | |
| 683 | var errMoreMallocs = moreMallocsError{} |
| 684 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 685 | // accept accepts a connection from listener, unless waitChan signals a process |
| 686 | // exit first. |
| 687 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 688 | type connOrError struct { |
| 689 | conn net.Conn |
| 690 | err error |
| 691 | } |
| 692 | connChan := make(chan connOrError, 1) |
| 693 | go func() { |
| 694 | conn, err := listener.Accept() |
| 695 | connChan <- connOrError{conn, err} |
| 696 | close(connChan) |
| 697 | }() |
| 698 | select { |
| 699 | case result := <-connChan: |
| 700 | return result.conn, result.err |
| 701 | case childErr := <-waitChan: |
| 702 | waitChan <- childErr |
| 703 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 704 | } |
| 705 | } |
| 706 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 707 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 708 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 709 | panic("Error expected without shouldFail in " + test.name) |
| 710 | } |
| 711 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 712 | if test.expectResumeRejected && !test.resumeSession { |
| 713 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 714 | } |
| 715 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 716 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 717 | if err != nil { |
| 718 | panic(err) |
| 719 | } |
| 720 | defer func() { |
| 721 | if listener != nil { |
| 722 | listener.Close() |
| 723 | } |
| 724 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 725 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 726 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 727 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 728 | flags = append(flags, "-server") |
| 729 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 730 | flags = append(flags, "-key-file") |
| 731 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 732 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 733 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 734 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | flags = append(flags, "-cert-file") |
| 738 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 739 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 740 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 741 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 742 | } |
| 743 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 744 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 745 | if test.protocol == dtls { |
| 746 | flags = append(flags, "-dtls") |
| 747 | } |
| 748 | |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 749 | if test.resumeSession { |
| 750 | flags = append(flags, "-resume") |
| 751 | } |
| 752 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 753 | if test.shimWritesFirst { |
| 754 | flags = append(flags, "-shim-writes-first") |
| 755 | } |
| 756 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 757 | if test.shimShutsDown { |
| 758 | flags = append(flags, "-shim-shuts-down") |
| 759 | } |
| 760 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 761 | if test.exportKeyingMaterial > 0 { |
| 762 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 763 | flags = append(flags, "-export-label", test.exportLabel) |
| 764 | flags = append(flags, "-export-context", test.exportContext) |
| 765 | if test.useExportContext { |
| 766 | flags = append(flags, "-use-export-context") |
| 767 | } |
| 768 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 769 | if test.expectResumeRejected { |
| 770 | flags = append(flags, "-expect-session-miss") |
| 771 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 772 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 773 | if test.testTLSUnique { |
| 774 | flags = append(flags, "-tls-unique") |
| 775 | } |
| 776 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 777 | flags = append(flags, test.flags...) |
| 778 | |
| 779 | var shim *exec.Cmd |
| 780 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 781 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 782 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 783 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 784 | } else if *useLLDB { |
| 785 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 786 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 787 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 788 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 789 | shim.Stdin = os.Stdin |
| 790 | var stdoutBuf, stderrBuf bytes.Buffer |
| 791 | shim.Stdout = &stdoutBuf |
| 792 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 793 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 794 | shim.Env = os.Environ() |
| 795 | 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] | 796 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 797 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 798 | } |
| 799 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 800 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 801 | |
| 802 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 803 | panic(err) |
| 804 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 805 | waitChan := make(chan error, 1) |
| 806 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 807 | |
| 808 | config := test.config |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 809 | if !test.noSessionCache { |
| 810 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 811 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 812 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 813 | if test.testType == clientTest { |
| 814 | if len(config.Certificates) == 0 { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 815 | config.Certificates = []Certificate{rsaCertificate} |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 816 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 817 | } else { |
| 818 | // Supply a ServerName to ensure a constant session cache key, |
| 819 | // rather than falling back to net.Conn.RemoteAddr. |
| 820 | if len(config.ServerName) == 0 { |
| 821 | config.ServerName = "test" |
| 822 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 823 | } |
David Benjamin | f2b8363 | 2016-03-01 22:57:46 -0500 | [diff] [blame] | 824 | if *fuzzer { |
| 825 | config.Bugs.NullAllCiphers = true |
| 826 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 827 | if *deterministic { |
| 828 | config.Rand = &deterministicRand{} |
| 829 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 830 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 831 | conn, err := acceptOrWait(listener, waitChan) |
| 832 | if err == nil { |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 833 | err = doExchange(test, &config, conn, false /* not a resumption */) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 834 | conn.Close() |
| 835 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 836 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 837 | if err == nil && test.resumeSession { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 838 | var resumeConfig Config |
| 839 | if test.resumeConfig != nil { |
| 840 | resumeConfig = *test.resumeConfig |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 841 | if len(resumeConfig.ServerName) == 0 { |
| 842 | resumeConfig.ServerName = config.ServerName |
| 843 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 844 | if len(resumeConfig.Certificates) == 0 { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 845 | resumeConfig.Certificates = []Certificate{rsaCertificate} |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 846 | } |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 847 | if test.newSessionsOnResume { |
| 848 | if !test.noSessionCache { |
| 849 | resumeConfig.ClientSessionCache = NewLRUClientSessionCache(1) |
| 850 | resumeConfig.ServerSessionCache = NewLRUServerSessionCache(1) |
| 851 | } |
| 852 | } else { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 853 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 854 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 855 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 856 | } |
David Benjamin | f2b8363 | 2016-03-01 22:57:46 -0500 | [diff] [blame] | 857 | if *fuzzer { |
| 858 | resumeConfig.Bugs.NullAllCiphers = true |
| 859 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 860 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 861 | } else { |
| 862 | resumeConfig = config |
| 863 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 864 | var connResume net.Conn |
| 865 | connResume, err = acceptOrWait(listener, waitChan) |
| 866 | if err == nil { |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 867 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 868 | connResume.Close() |
| 869 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 870 | } |
| 871 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 872 | // Close the listener now. This is to avoid hangs should the shim try to |
| 873 | // open more connections than expected. |
| 874 | listener.Close() |
| 875 | listener = nil |
| 876 | |
| 877 | childErr := <-waitChan |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 878 | if exitError, ok := childErr.(*exec.ExitError); ok { |
| 879 | if exitError.Sys().(syscall.WaitStatus).ExitStatus() == 88 { |
| 880 | return errMoreMallocs |
| 881 | } |
| 882 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 883 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 884 | // Account for Windows line endings. |
| 885 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 886 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 887 | |
| 888 | // Separate the errors from the shim and those from tools like |
| 889 | // AddressSanitizer. |
| 890 | var extraStderr string |
| 891 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 892 | stderr = stderrParts[0] |
| 893 | extraStderr = stderrParts[1] |
| 894 | } |
| 895 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 896 | failed := err != nil || childErr != nil |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 897 | correctFailure := len(test.expectedError) == 0 || strings.Contains(stderr, test.expectedError) |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 898 | localError := "none" |
| 899 | if err != nil { |
| 900 | localError = err.Error() |
| 901 | } |
| 902 | if len(test.expectedLocalError) != 0 { |
| 903 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 904 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 905 | |
| 906 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 907 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 908 | if childErr != nil { |
| 909 | childError = childErr.Error() |
| 910 | } |
| 911 | |
| 912 | var msg string |
| 913 | switch { |
| 914 | case failed && !test.shouldFail: |
| 915 | msg = "unexpected failure" |
| 916 | case !failed && test.shouldFail: |
| 917 | msg = "unexpected success" |
| 918 | case failed && !correctFailure: |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 919 | msg = "bad error (wanted '" + test.expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 920 | default: |
| 921 | panic("internal error") |
| 922 | } |
| 923 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 924 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s", msg, localError, childError, stdout, stderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 925 | } |
| 926 | |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 927 | if !*useValgrind && (len(extraStderr) > 0 || (!failed && len(stderr) > 0)) { |
| 928 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | return nil |
| 932 | } |
| 933 | |
| 934 | var tlsVersions = []struct { |
| 935 | name string |
| 936 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 937 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 938 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 939 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 940 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 941 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 942 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 943 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 944 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | var testCipherSuites = []struct { |
| 948 | name string |
| 949 | id uint16 |
| 950 | }{ |
| 951 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 952 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 953 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 954 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 955 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 956 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 957 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 958 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 959 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 960 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 961 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 962 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 963 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 964 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 965 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 966 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 967 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 968 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 969 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 970 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 971 | {"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] | 972 | {"ECDHE-ECDSA-RC4-SHA", TLS_ECDHE_ECDSA_WITH_RC4_128_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 973 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 974 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 975 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 976 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 977 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 978 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 979 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 980 | {"ECDHE-RSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 981 | {"ECDHE-RSA-RC4-SHA", TLS_ECDHE_RSA_WITH_RC4_128_SHA}, |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 982 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 983 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 984 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 985 | {"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] | 986 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 987 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 988 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 989 | {"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] | 990 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 3084e7b | 2016-06-02 12:07:20 -0400 | [diff] [blame] | 991 | {"ECDHE-PSK-AES128-GCM-SHA256", TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256}, |
| 992 | {"ECDHE-PSK-AES256-GCM-SHA384", TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 993 | {"PSK-RC4-SHA", TLS_PSK_WITH_RC4_128_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 994 | {"RC4-MD5", TLS_RSA_WITH_RC4_128_MD5}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 995 | {"RC4-SHA", TLS_RSA_WITH_RC4_128_SHA}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 996 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 997 | } |
| 998 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 999 | func hasComponent(suiteName, component string) bool { |
| 1000 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1001 | } |
| 1002 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1003 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1004 | return hasComponent(suiteName, "GCM") || |
| 1005 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1006 | hasComponent(suiteName, "SHA384") || |
| 1007 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1008 | } |
| 1009 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1010 | func isTLS13Suite(suiteName string) bool { |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 1011 | // Only AEADs. |
| 1012 | if !hasComponent(suiteName, "GCM") && !hasComponent(suiteName, "POLY1305") { |
| 1013 | return false |
| 1014 | } |
| 1015 | // No old CHACHA20_POLY1305. |
| 1016 | if hasComponent(suiteName, "CHACHA20-POLY1305-OLD") { |
| 1017 | return false |
| 1018 | } |
| 1019 | // Must have ECDHE. |
| 1020 | // TODO(davidben,svaldez): Add pure PSK support. |
| 1021 | if !hasComponent(suiteName, "ECDHE") { |
| 1022 | return false |
| 1023 | } |
| 1024 | // TODO(davidben,svaldez): Add PSK support. |
| 1025 | if hasComponent(suiteName, "PSK") { |
| 1026 | return false |
| 1027 | } |
| 1028 | return true |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1029 | } |
| 1030 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1031 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1032 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1033 | } |
| 1034 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1035 | func bigFromHex(hex string) *big.Int { |
| 1036 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1037 | if !ok { |
| 1038 | panic("failed to parse hex number 0x" + hex) |
| 1039 | } |
| 1040 | return ret |
| 1041 | } |
| 1042 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1043 | func addBasicTests() { |
| 1044 | basicTests := []testCase{ |
| 1045 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1046 | name: "NoFallbackSCSV", |
| 1047 | config: Config{ |
| 1048 | Bugs: ProtocolBugs{ |
| 1049 | FailIfNotFallbackSCSV: true, |
| 1050 | }, |
| 1051 | }, |
| 1052 | shouldFail: true, |
| 1053 | expectedLocalError: "no fallback SCSV found", |
| 1054 | }, |
| 1055 | { |
| 1056 | name: "SendFallbackSCSV", |
| 1057 | config: Config{ |
| 1058 | Bugs: ProtocolBugs{ |
| 1059 | FailIfNotFallbackSCSV: true, |
| 1060 | }, |
| 1061 | }, |
| 1062 | flags: []string{"-fallback-scsv"}, |
| 1063 | }, |
| 1064 | { |
| 1065 | name: "ClientCertificateTypes", |
| 1066 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1067 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1068 | ClientAuth: RequestClientCert, |
| 1069 | ClientCertificateTypes: []byte{ |
| 1070 | CertTypeDSSSign, |
| 1071 | CertTypeRSASign, |
| 1072 | CertTypeECDSASign, |
| 1073 | }, |
| 1074 | }, |
| 1075 | flags: []string{ |
| 1076 | "-expect-certificate-types", |
| 1077 | base64.StdEncoding.EncodeToString([]byte{ |
| 1078 | CertTypeDSSSign, |
| 1079 | CertTypeRSASign, |
| 1080 | CertTypeECDSASign, |
| 1081 | }), |
| 1082 | }, |
| 1083 | }, |
| 1084 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1085 | name: "UnauthenticatedECDH", |
| 1086 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1087 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1088 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1089 | Bugs: ProtocolBugs{ |
| 1090 | UnauthenticatedECDH: true, |
| 1091 | }, |
| 1092 | }, |
| 1093 | shouldFail: true, |
| 1094 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1095 | }, |
| 1096 | { |
| 1097 | name: "SkipCertificateStatus", |
| 1098 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1099 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1100 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1101 | Bugs: ProtocolBugs{ |
| 1102 | SkipCertificateStatus: true, |
| 1103 | }, |
| 1104 | }, |
| 1105 | flags: []string{ |
| 1106 | "-enable-ocsp-stapling", |
| 1107 | }, |
| 1108 | }, |
| 1109 | { |
| 1110 | name: "SkipServerKeyExchange", |
| 1111 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1112 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1113 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1114 | Bugs: ProtocolBugs{ |
| 1115 | SkipServerKeyExchange: true, |
| 1116 | }, |
| 1117 | }, |
| 1118 | shouldFail: true, |
| 1119 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1120 | }, |
| 1121 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1122 | testType: serverTest, |
| 1123 | name: "Alert", |
| 1124 | config: Config{ |
| 1125 | Bugs: ProtocolBugs{ |
| 1126 | SendSpuriousAlert: alertRecordOverflow, |
| 1127 | }, |
| 1128 | }, |
| 1129 | shouldFail: true, |
| 1130 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1131 | }, |
| 1132 | { |
| 1133 | protocol: dtls, |
| 1134 | testType: serverTest, |
| 1135 | name: "Alert-DTLS", |
| 1136 | config: Config{ |
| 1137 | Bugs: ProtocolBugs{ |
| 1138 | SendSpuriousAlert: alertRecordOverflow, |
| 1139 | }, |
| 1140 | }, |
| 1141 | shouldFail: true, |
| 1142 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1143 | }, |
| 1144 | { |
| 1145 | testType: serverTest, |
| 1146 | name: "FragmentAlert", |
| 1147 | config: Config{ |
| 1148 | Bugs: ProtocolBugs{ |
| 1149 | FragmentAlert: true, |
| 1150 | SendSpuriousAlert: alertRecordOverflow, |
| 1151 | }, |
| 1152 | }, |
| 1153 | shouldFail: true, |
| 1154 | expectedError: ":BAD_ALERT:", |
| 1155 | }, |
| 1156 | { |
| 1157 | protocol: dtls, |
| 1158 | testType: serverTest, |
| 1159 | name: "FragmentAlert-DTLS", |
| 1160 | config: Config{ |
| 1161 | Bugs: ProtocolBugs{ |
| 1162 | FragmentAlert: true, |
| 1163 | SendSpuriousAlert: alertRecordOverflow, |
| 1164 | }, |
| 1165 | }, |
| 1166 | shouldFail: true, |
| 1167 | expectedError: ":BAD_ALERT:", |
| 1168 | }, |
| 1169 | { |
| 1170 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1171 | name: "DoubleAlert", |
| 1172 | config: Config{ |
| 1173 | Bugs: ProtocolBugs{ |
| 1174 | DoubleAlert: true, |
| 1175 | SendSpuriousAlert: alertRecordOverflow, |
| 1176 | }, |
| 1177 | }, |
| 1178 | shouldFail: true, |
| 1179 | expectedError: ":BAD_ALERT:", |
| 1180 | }, |
| 1181 | { |
| 1182 | protocol: dtls, |
| 1183 | testType: serverTest, |
| 1184 | name: "DoubleAlert-DTLS", |
| 1185 | config: Config{ |
| 1186 | Bugs: ProtocolBugs{ |
| 1187 | DoubleAlert: true, |
| 1188 | SendSpuriousAlert: alertRecordOverflow, |
| 1189 | }, |
| 1190 | }, |
| 1191 | shouldFail: true, |
| 1192 | expectedError: ":BAD_ALERT:", |
| 1193 | }, |
| 1194 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1195 | name: "SkipNewSessionTicket", |
| 1196 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1197 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1198 | Bugs: ProtocolBugs{ |
| 1199 | SkipNewSessionTicket: true, |
| 1200 | }, |
| 1201 | }, |
| 1202 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1203 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1204 | }, |
| 1205 | { |
| 1206 | testType: serverTest, |
| 1207 | name: "FallbackSCSV", |
| 1208 | config: Config{ |
| 1209 | MaxVersion: VersionTLS11, |
| 1210 | Bugs: ProtocolBugs{ |
| 1211 | SendFallbackSCSV: true, |
| 1212 | }, |
| 1213 | }, |
| 1214 | shouldFail: true, |
| 1215 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1216 | }, |
| 1217 | { |
| 1218 | testType: serverTest, |
| 1219 | name: "FallbackSCSV-VersionMatch", |
| 1220 | config: Config{ |
| 1221 | Bugs: ProtocolBugs{ |
| 1222 | SendFallbackSCSV: true, |
| 1223 | }, |
| 1224 | }, |
| 1225 | }, |
| 1226 | { |
| 1227 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1228 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1229 | config: Config{ |
| 1230 | MaxVersion: VersionTLS12, |
| 1231 | Bugs: ProtocolBugs{ |
| 1232 | SendFallbackSCSV: true, |
| 1233 | }, |
| 1234 | }, |
| 1235 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1236 | }, |
| 1237 | { |
| 1238 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1239 | name: "FragmentedClientVersion", |
| 1240 | config: Config{ |
| 1241 | Bugs: ProtocolBugs{ |
| 1242 | MaxHandshakeRecordLength: 1, |
| 1243 | FragmentClientVersion: true, |
| 1244 | }, |
| 1245 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1246 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1247 | }, |
| 1248 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1249 | testType: serverTest, |
| 1250 | name: "HttpGET", |
| 1251 | sendPrefix: "GET / HTTP/1.0\n", |
| 1252 | shouldFail: true, |
| 1253 | expectedError: ":HTTP_REQUEST:", |
| 1254 | }, |
| 1255 | { |
| 1256 | testType: serverTest, |
| 1257 | name: "HttpPOST", |
| 1258 | sendPrefix: "POST / HTTP/1.0\n", |
| 1259 | shouldFail: true, |
| 1260 | expectedError: ":HTTP_REQUEST:", |
| 1261 | }, |
| 1262 | { |
| 1263 | testType: serverTest, |
| 1264 | name: "HttpHEAD", |
| 1265 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1266 | shouldFail: true, |
| 1267 | expectedError: ":HTTP_REQUEST:", |
| 1268 | }, |
| 1269 | { |
| 1270 | testType: serverTest, |
| 1271 | name: "HttpPUT", |
| 1272 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1273 | shouldFail: true, |
| 1274 | expectedError: ":HTTP_REQUEST:", |
| 1275 | }, |
| 1276 | { |
| 1277 | testType: serverTest, |
| 1278 | name: "HttpCONNECT", |
| 1279 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1280 | shouldFail: true, |
| 1281 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1282 | }, |
| 1283 | { |
| 1284 | testType: serverTest, |
| 1285 | name: "Garbage", |
| 1286 | sendPrefix: "blah", |
| 1287 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1288 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1289 | }, |
| 1290 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1291 | name: "RSAEphemeralKey", |
| 1292 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1293 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1294 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1295 | Bugs: ProtocolBugs{ |
| 1296 | RSAEphemeralKey: true, |
| 1297 | }, |
| 1298 | }, |
| 1299 | shouldFail: true, |
| 1300 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1301 | }, |
| 1302 | { |
| 1303 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1304 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1305 | shouldFail: true, |
| 1306 | expectedError: ":WRONG_SSL_VERSION:", |
| 1307 | }, |
| 1308 | { |
| 1309 | protocol: dtls, |
| 1310 | name: "DisableEverything-DTLS", |
| 1311 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1312 | shouldFail: true, |
| 1313 | expectedError: ":WRONG_SSL_VERSION:", |
| 1314 | }, |
| 1315 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1316 | protocol: dtls, |
| 1317 | testType: serverTest, |
| 1318 | name: "MTU", |
| 1319 | config: Config{ |
| 1320 | Bugs: ProtocolBugs{ |
| 1321 | MaxPacketLength: 256, |
| 1322 | }, |
| 1323 | }, |
| 1324 | flags: []string{"-mtu", "256"}, |
| 1325 | }, |
| 1326 | { |
| 1327 | protocol: dtls, |
| 1328 | testType: serverTest, |
| 1329 | name: "MTUExceeded", |
| 1330 | config: Config{ |
| 1331 | Bugs: ProtocolBugs{ |
| 1332 | MaxPacketLength: 255, |
| 1333 | }, |
| 1334 | }, |
| 1335 | flags: []string{"-mtu", "256"}, |
| 1336 | shouldFail: true, |
| 1337 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1338 | }, |
| 1339 | { |
| 1340 | name: "CertMismatchRSA", |
| 1341 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1342 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1343 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1344 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1345 | Bugs: ProtocolBugs{ |
| 1346 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1347 | }, |
| 1348 | }, |
| 1349 | shouldFail: true, |
| 1350 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1351 | }, |
| 1352 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 1353 | name: "CertMismatchRSA-TLS13", |
| 1354 | config: Config{ |
| 1355 | MaxVersion: VersionTLS13, |
| 1356 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1357 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 1358 | Bugs: ProtocolBugs{ |
| 1359 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1360 | }, |
| 1361 | }, |
| 1362 | shouldFail: true, |
| 1363 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1364 | }, |
| 1365 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1366 | name: "CertMismatchECDSA", |
| 1367 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1368 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1369 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1370 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1371 | Bugs: ProtocolBugs{ |
| 1372 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1373 | }, |
| 1374 | }, |
| 1375 | shouldFail: true, |
| 1376 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1377 | }, |
| 1378 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 1379 | name: "CertMismatchECDSA-TLS13", |
| 1380 | config: Config{ |
| 1381 | MaxVersion: VersionTLS13, |
| 1382 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1383 | Certificates: []Certificate{rsaCertificate}, |
| 1384 | Bugs: ProtocolBugs{ |
| 1385 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1386 | }, |
| 1387 | }, |
| 1388 | shouldFail: true, |
| 1389 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1390 | }, |
| 1391 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1392 | name: "EmptyCertificateList", |
| 1393 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1394 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1395 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1396 | Bugs: ProtocolBugs{ |
| 1397 | EmptyCertificateList: true, |
| 1398 | }, |
| 1399 | }, |
| 1400 | shouldFail: true, |
| 1401 | expectedError: ":DECODE_ERROR:", |
| 1402 | }, |
| 1403 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1404 | name: "EmptyCertificateList-TLS13", |
| 1405 | config: Config{ |
| 1406 | MaxVersion: VersionTLS13, |
| 1407 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1408 | Bugs: ProtocolBugs{ |
| 1409 | EmptyCertificateList: true, |
| 1410 | }, |
| 1411 | }, |
| 1412 | shouldFail: true, |
| 1413 | expectedError: ":DECODE_ERROR:", |
| 1414 | }, |
| 1415 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1416 | name: "TLSFatalBadPackets", |
| 1417 | damageFirstWrite: true, |
| 1418 | shouldFail: true, |
| 1419 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1420 | }, |
| 1421 | { |
| 1422 | protocol: dtls, |
| 1423 | name: "DTLSIgnoreBadPackets", |
| 1424 | damageFirstWrite: true, |
| 1425 | }, |
| 1426 | { |
| 1427 | protocol: dtls, |
| 1428 | name: "DTLSIgnoreBadPackets-Async", |
| 1429 | damageFirstWrite: true, |
| 1430 | flags: []string{"-async"}, |
| 1431 | }, |
| 1432 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1433 | name: "AppDataBeforeHandshake", |
| 1434 | config: Config{ |
| 1435 | Bugs: ProtocolBugs{ |
| 1436 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1437 | }, |
| 1438 | }, |
| 1439 | shouldFail: true, |
| 1440 | expectedError: ":UNEXPECTED_RECORD:", |
| 1441 | }, |
| 1442 | { |
| 1443 | name: "AppDataBeforeHandshake-Empty", |
| 1444 | config: Config{ |
| 1445 | Bugs: ProtocolBugs{ |
| 1446 | AppDataBeforeHandshake: []byte{}, |
| 1447 | }, |
| 1448 | }, |
| 1449 | shouldFail: true, |
| 1450 | expectedError: ":UNEXPECTED_RECORD:", |
| 1451 | }, |
| 1452 | { |
| 1453 | protocol: dtls, |
| 1454 | name: "AppDataBeforeHandshake-DTLS", |
| 1455 | config: Config{ |
| 1456 | Bugs: ProtocolBugs{ |
| 1457 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1458 | }, |
| 1459 | }, |
| 1460 | shouldFail: true, |
| 1461 | expectedError: ":UNEXPECTED_RECORD:", |
| 1462 | }, |
| 1463 | { |
| 1464 | protocol: dtls, |
| 1465 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1466 | config: Config{ |
| 1467 | Bugs: ProtocolBugs{ |
| 1468 | AppDataBeforeHandshake: []byte{}, |
| 1469 | }, |
| 1470 | }, |
| 1471 | shouldFail: true, |
| 1472 | expectedError: ":UNEXPECTED_RECORD:", |
| 1473 | }, |
| 1474 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1475 | name: "AppDataAfterChangeCipherSpec", |
| 1476 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1477 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1478 | Bugs: ProtocolBugs{ |
| 1479 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1480 | }, |
| 1481 | }, |
| 1482 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1483 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1484 | }, |
| 1485 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1486 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1487 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1488 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1489 | Bugs: ProtocolBugs{ |
| 1490 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1491 | }, |
| 1492 | }, |
| 1493 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1494 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1495 | }, |
| 1496 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1497 | protocol: dtls, |
| 1498 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1499 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1500 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1501 | Bugs: ProtocolBugs{ |
| 1502 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1503 | }, |
| 1504 | }, |
| 1505 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1506 | // application data. |
| 1507 | }, |
| 1508 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1509 | protocol: dtls, |
| 1510 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1511 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1512 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1513 | Bugs: ProtocolBugs{ |
| 1514 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1515 | }, |
| 1516 | }, |
| 1517 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1518 | // application data. |
| 1519 | }, |
| 1520 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1521 | name: "AlertAfterChangeCipherSpec", |
| 1522 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1523 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1524 | Bugs: ProtocolBugs{ |
| 1525 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1526 | }, |
| 1527 | }, |
| 1528 | shouldFail: true, |
| 1529 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1530 | }, |
| 1531 | { |
| 1532 | protocol: dtls, |
| 1533 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1534 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1535 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1536 | Bugs: ProtocolBugs{ |
| 1537 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1538 | }, |
| 1539 | }, |
| 1540 | shouldFail: true, |
| 1541 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1542 | }, |
| 1543 | { |
| 1544 | protocol: dtls, |
| 1545 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1546 | config: Config{ |
| 1547 | Bugs: ProtocolBugs{ |
| 1548 | ReorderHandshakeFragments: true, |
| 1549 | // Small enough that every handshake message is |
| 1550 | // fragmented. |
| 1551 | MaxHandshakeRecordLength: 2, |
| 1552 | }, |
| 1553 | }, |
| 1554 | }, |
| 1555 | { |
| 1556 | protocol: dtls, |
| 1557 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1558 | config: Config{ |
| 1559 | Bugs: ProtocolBugs{ |
| 1560 | ReorderHandshakeFragments: true, |
| 1561 | // Large enough that no handshake message is |
| 1562 | // fragmented. |
| 1563 | MaxHandshakeRecordLength: 2048, |
| 1564 | }, |
| 1565 | }, |
| 1566 | }, |
| 1567 | { |
| 1568 | protocol: dtls, |
| 1569 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1570 | config: Config{ |
| 1571 | Bugs: ProtocolBugs{ |
| 1572 | ReorderHandshakeFragments: true, |
| 1573 | MixCompleteMessageWithFragments: true, |
| 1574 | MaxHandshakeRecordLength: 2, |
| 1575 | }, |
| 1576 | }, |
| 1577 | }, |
| 1578 | { |
| 1579 | name: "SendInvalidRecordType", |
| 1580 | config: Config{ |
| 1581 | Bugs: ProtocolBugs{ |
| 1582 | SendInvalidRecordType: true, |
| 1583 | }, |
| 1584 | }, |
| 1585 | shouldFail: true, |
| 1586 | expectedError: ":UNEXPECTED_RECORD:", |
| 1587 | }, |
| 1588 | { |
| 1589 | protocol: dtls, |
| 1590 | name: "SendInvalidRecordType-DTLS", |
| 1591 | config: Config{ |
| 1592 | Bugs: ProtocolBugs{ |
| 1593 | SendInvalidRecordType: true, |
| 1594 | }, |
| 1595 | }, |
| 1596 | shouldFail: true, |
| 1597 | expectedError: ":UNEXPECTED_RECORD:", |
| 1598 | }, |
| 1599 | { |
| 1600 | name: "FalseStart-SkipServerSecondLeg", |
| 1601 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1602 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1603 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1604 | NextProtos: []string{"foo"}, |
| 1605 | Bugs: ProtocolBugs{ |
| 1606 | SkipNewSessionTicket: true, |
| 1607 | SkipChangeCipherSpec: true, |
| 1608 | SkipFinished: true, |
| 1609 | ExpectFalseStart: true, |
| 1610 | }, |
| 1611 | }, |
| 1612 | flags: []string{ |
| 1613 | "-false-start", |
| 1614 | "-handshake-never-done", |
| 1615 | "-advertise-alpn", "\x03foo", |
| 1616 | }, |
| 1617 | shimWritesFirst: true, |
| 1618 | shouldFail: true, |
| 1619 | expectedError: ":UNEXPECTED_RECORD:", |
| 1620 | }, |
| 1621 | { |
| 1622 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1623 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1624 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1625 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1626 | NextProtos: []string{"foo"}, |
| 1627 | Bugs: ProtocolBugs{ |
| 1628 | SkipNewSessionTicket: true, |
| 1629 | SkipChangeCipherSpec: true, |
| 1630 | SkipFinished: true, |
| 1631 | }, |
| 1632 | }, |
| 1633 | flags: []string{ |
| 1634 | "-implicit-handshake", |
| 1635 | "-false-start", |
| 1636 | "-handshake-never-done", |
| 1637 | "-advertise-alpn", "\x03foo", |
| 1638 | }, |
| 1639 | shouldFail: true, |
| 1640 | expectedError: ":UNEXPECTED_RECORD:", |
| 1641 | }, |
| 1642 | { |
| 1643 | testType: serverTest, |
| 1644 | name: "FailEarlyCallback", |
| 1645 | flags: []string{"-fail-early-callback"}, |
| 1646 | shouldFail: true, |
| 1647 | expectedError: ":CONNECTION_REJECTED:", |
| 1648 | expectedLocalError: "remote error: access denied", |
| 1649 | }, |
| 1650 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1651 | protocol: dtls, |
| 1652 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1653 | config: Config{ |
| 1654 | Bugs: ProtocolBugs{ |
| 1655 | MaxHandshakeRecordLength: 2, |
| 1656 | FragmentMessageTypeMismatch: true, |
| 1657 | }, |
| 1658 | }, |
| 1659 | shouldFail: true, |
| 1660 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1661 | }, |
| 1662 | { |
| 1663 | protocol: dtls, |
| 1664 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1665 | config: Config{ |
| 1666 | Bugs: ProtocolBugs{ |
| 1667 | MaxHandshakeRecordLength: 2, |
| 1668 | FragmentMessageLengthMismatch: true, |
| 1669 | }, |
| 1670 | }, |
| 1671 | shouldFail: true, |
| 1672 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1673 | }, |
| 1674 | { |
| 1675 | protocol: dtls, |
| 1676 | name: "SplitFragments-Header-DTLS", |
| 1677 | config: Config{ |
| 1678 | Bugs: ProtocolBugs{ |
| 1679 | SplitFragments: 2, |
| 1680 | }, |
| 1681 | }, |
| 1682 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1683 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1684 | }, |
| 1685 | { |
| 1686 | protocol: dtls, |
| 1687 | name: "SplitFragments-Boundary-DTLS", |
| 1688 | config: Config{ |
| 1689 | Bugs: ProtocolBugs{ |
| 1690 | SplitFragments: dtlsRecordHeaderLen, |
| 1691 | }, |
| 1692 | }, |
| 1693 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1694 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1695 | }, |
| 1696 | { |
| 1697 | protocol: dtls, |
| 1698 | name: "SplitFragments-Body-DTLS", |
| 1699 | config: Config{ |
| 1700 | Bugs: ProtocolBugs{ |
| 1701 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1702 | }, |
| 1703 | }, |
| 1704 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1705 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1706 | }, |
| 1707 | { |
| 1708 | protocol: dtls, |
| 1709 | name: "SendEmptyFragments-DTLS", |
| 1710 | config: Config{ |
| 1711 | Bugs: ProtocolBugs{ |
| 1712 | SendEmptyFragments: true, |
| 1713 | }, |
| 1714 | }, |
| 1715 | }, |
| 1716 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1717 | name: "BadFinished-Client", |
| 1718 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1719 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1720 | Bugs: ProtocolBugs{ |
| 1721 | BadFinished: true, |
| 1722 | }, |
| 1723 | }, |
| 1724 | shouldFail: true, |
| 1725 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1726 | }, |
| 1727 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 1728 | name: "BadFinished-Client-TLS13", |
| 1729 | config: Config{ |
| 1730 | MaxVersion: VersionTLS13, |
| 1731 | Bugs: ProtocolBugs{ |
| 1732 | BadFinished: true, |
| 1733 | }, |
| 1734 | }, |
| 1735 | shouldFail: true, |
| 1736 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1737 | }, |
| 1738 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1739 | testType: serverTest, |
| 1740 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1741 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1742 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1743 | Bugs: ProtocolBugs{ |
| 1744 | BadFinished: true, |
| 1745 | }, |
| 1746 | }, |
| 1747 | shouldFail: true, |
| 1748 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1749 | }, |
| 1750 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 1751 | testType: serverTest, |
| 1752 | name: "BadFinished-Server-TLS13", |
| 1753 | config: Config{ |
| 1754 | MaxVersion: VersionTLS13, |
| 1755 | Bugs: ProtocolBugs{ |
| 1756 | BadFinished: true, |
| 1757 | }, |
| 1758 | }, |
| 1759 | shouldFail: true, |
| 1760 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1761 | }, |
| 1762 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1763 | name: "FalseStart-BadFinished", |
| 1764 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1765 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1766 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1767 | NextProtos: []string{"foo"}, |
| 1768 | Bugs: ProtocolBugs{ |
| 1769 | BadFinished: true, |
| 1770 | ExpectFalseStart: true, |
| 1771 | }, |
| 1772 | }, |
| 1773 | flags: []string{ |
| 1774 | "-false-start", |
| 1775 | "-handshake-never-done", |
| 1776 | "-advertise-alpn", "\x03foo", |
| 1777 | }, |
| 1778 | shimWritesFirst: true, |
| 1779 | shouldFail: true, |
| 1780 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1781 | }, |
| 1782 | { |
| 1783 | name: "NoFalseStart-NoALPN", |
| 1784 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1785 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1786 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1787 | Bugs: ProtocolBugs{ |
| 1788 | ExpectFalseStart: true, |
| 1789 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1790 | }, |
| 1791 | }, |
| 1792 | flags: []string{ |
| 1793 | "-false-start", |
| 1794 | }, |
| 1795 | shimWritesFirst: true, |
| 1796 | shouldFail: true, |
| 1797 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1798 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1799 | }, |
| 1800 | { |
| 1801 | name: "NoFalseStart-NoAEAD", |
| 1802 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1803 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1804 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1805 | NextProtos: []string{"foo"}, |
| 1806 | Bugs: ProtocolBugs{ |
| 1807 | ExpectFalseStart: true, |
| 1808 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1809 | }, |
| 1810 | }, |
| 1811 | flags: []string{ |
| 1812 | "-false-start", |
| 1813 | "-advertise-alpn", "\x03foo", |
| 1814 | }, |
| 1815 | shimWritesFirst: true, |
| 1816 | shouldFail: true, |
| 1817 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1818 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1819 | }, |
| 1820 | { |
| 1821 | name: "NoFalseStart-RSA", |
| 1822 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1823 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1824 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1825 | NextProtos: []string{"foo"}, |
| 1826 | Bugs: ProtocolBugs{ |
| 1827 | ExpectFalseStart: true, |
| 1828 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1829 | }, |
| 1830 | }, |
| 1831 | flags: []string{ |
| 1832 | "-false-start", |
| 1833 | "-advertise-alpn", "\x03foo", |
| 1834 | }, |
| 1835 | shimWritesFirst: true, |
| 1836 | shouldFail: true, |
| 1837 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1838 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1839 | }, |
| 1840 | { |
| 1841 | name: "NoFalseStart-DHE_RSA", |
| 1842 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1843 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1844 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1845 | NextProtos: []string{"foo"}, |
| 1846 | Bugs: ProtocolBugs{ |
| 1847 | ExpectFalseStart: true, |
| 1848 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1849 | }, |
| 1850 | }, |
| 1851 | flags: []string{ |
| 1852 | "-false-start", |
| 1853 | "-advertise-alpn", "\x03foo", |
| 1854 | }, |
| 1855 | shimWritesFirst: true, |
| 1856 | shouldFail: true, |
| 1857 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1858 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1859 | }, |
| 1860 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1861 | protocol: dtls, |
| 1862 | name: "SendSplitAlert-Sync", |
| 1863 | config: Config{ |
| 1864 | Bugs: ProtocolBugs{ |
| 1865 | SendSplitAlert: true, |
| 1866 | }, |
| 1867 | }, |
| 1868 | }, |
| 1869 | { |
| 1870 | protocol: dtls, |
| 1871 | name: "SendSplitAlert-Async", |
| 1872 | config: Config{ |
| 1873 | Bugs: ProtocolBugs{ |
| 1874 | SendSplitAlert: true, |
| 1875 | }, |
| 1876 | }, |
| 1877 | flags: []string{"-async"}, |
| 1878 | }, |
| 1879 | { |
| 1880 | protocol: dtls, |
| 1881 | name: "PackDTLSHandshake", |
| 1882 | config: Config{ |
| 1883 | Bugs: ProtocolBugs{ |
| 1884 | MaxHandshakeRecordLength: 2, |
| 1885 | PackHandshakeFragments: 20, |
| 1886 | PackHandshakeRecords: 200, |
| 1887 | }, |
| 1888 | }, |
| 1889 | }, |
| 1890 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1891 | name: "SendEmptyRecords-Pass", |
| 1892 | sendEmptyRecords: 32, |
| 1893 | }, |
| 1894 | { |
| 1895 | name: "SendEmptyRecords", |
| 1896 | sendEmptyRecords: 33, |
| 1897 | shouldFail: true, |
| 1898 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1899 | }, |
| 1900 | { |
| 1901 | name: "SendEmptyRecords-Async", |
| 1902 | sendEmptyRecords: 33, |
| 1903 | flags: []string{"-async"}, |
| 1904 | shouldFail: true, |
| 1905 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1906 | }, |
| 1907 | { |
| 1908 | name: "SendWarningAlerts-Pass", |
| 1909 | sendWarningAlerts: 4, |
| 1910 | }, |
| 1911 | { |
| 1912 | protocol: dtls, |
| 1913 | name: "SendWarningAlerts-DTLS-Pass", |
| 1914 | sendWarningAlerts: 4, |
| 1915 | }, |
| 1916 | { |
| 1917 | name: "SendWarningAlerts", |
| 1918 | sendWarningAlerts: 5, |
| 1919 | shouldFail: true, |
| 1920 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 1921 | }, |
| 1922 | { |
| 1923 | name: "SendWarningAlerts-Async", |
| 1924 | sendWarningAlerts: 5, |
| 1925 | flags: []string{"-async"}, |
| 1926 | shouldFail: true, |
| 1927 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 1928 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1929 | { |
| 1930 | name: "EmptySessionID", |
| 1931 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1932 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1933 | SessionTicketsDisabled: true, |
| 1934 | }, |
| 1935 | noSessionCache: true, |
| 1936 | flags: []string{"-expect-no-session"}, |
| 1937 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1938 | { |
| 1939 | name: "Unclean-Shutdown", |
| 1940 | config: Config{ |
| 1941 | Bugs: ProtocolBugs{ |
| 1942 | NoCloseNotify: true, |
| 1943 | ExpectCloseNotify: true, |
| 1944 | }, |
| 1945 | }, |
| 1946 | shimShutsDown: true, |
| 1947 | flags: []string{"-check-close-notify"}, |
| 1948 | shouldFail: true, |
| 1949 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 1950 | }, |
| 1951 | { |
| 1952 | name: "Unclean-Shutdown-Ignored", |
| 1953 | config: Config{ |
| 1954 | Bugs: ProtocolBugs{ |
| 1955 | NoCloseNotify: true, |
| 1956 | }, |
| 1957 | }, |
| 1958 | shimShutsDown: true, |
| 1959 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 1960 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 1961 | name: "Unclean-Shutdown-Alert", |
| 1962 | config: Config{ |
| 1963 | Bugs: ProtocolBugs{ |
| 1964 | SendAlertOnShutdown: alertDecompressionFailure, |
| 1965 | ExpectCloseNotify: true, |
| 1966 | }, |
| 1967 | }, |
| 1968 | shimShutsDown: true, |
| 1969 | flags: []string{"-check-close-notify"}, |
| 1970 | shouldFail: true, |
| 1971 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 1972 | }, |
| 1973 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 1974 | name: "LargePlaintext", |
| 1975 | config: Config{ |
| 1976 | Bugs: ProtocolBugs{ |
| 1977 | SendLargeRecords: true, |
| 1978 | }, |
| 1979 | }, |
| 1980 | messageLen: maxPlaintext + 1, |
| 1981 | shouldFail: true, |
| 1982 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 1983 | }, |
| 1984 | { |
| 1985 | protocol: dtls, |
| 1986 | name: "LargePlaintext-DTLS", |
| 1987 | config: Config{ |
| 1988 | Bugs: ProtocolBugs{ |
| 1989 | SendLargeRecords: true, |
| 1990 | }, |
| 1991 | }, |
| 1992 | messageLen: maxPlaintext + 1, |
| 1993 | shouldFail: true, |
| 1994 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 1995 | }, |
| 1996 | { |
| 1997 | name: "LargeCiphertext", |
| 1998 | config: Config{ |
| 1999 | Bugs: ProtocolBugs{ |
| 2000 | SendLargeRecords: true, |
| 2001 | }, |
| 2002 | }, |
| 2003 | messageLen: maxPlaintext * 2, |
| 2004 | shouldFail: true, |
| 2005 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2006 | }, |
| 2007 | { |
| 2008 | protocol: dtls, |
| 2009 | name: "LargeCiphertext-DTLS", |
| 2010 | config: Config{ |
| 2011 | Bugs: ProtocolBugs{ |
| 2012 | SendLargeRecords: true, |
| 2013 | }, |
| 2014 | }, |
| 2015 | messageLen: maxPlaintext * 2, |
| 2016 | // Unlike the other four cases, DTLS drops records which |
| 2017 | // are invalid before authentication, so the connection |
| 2018 | // does not fail. |
| 2019 | expectMessageDropped: true, |
| 2020 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2021 | { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2022 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 2023 | // mean the server changed its mind on sending a ticket. |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2024 | name: "SendEmptySessionTicket", |
| 2025 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2026 | MaxVersion: VersionTLS12, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2027 | Bugs: ProtocolBugs{ |
| 2028 | SendEmptySessionTicket: true, |
| 2029 | FailIfSessionOffered: true, |
| 2030 | }, |
| 2031 | }, |
| 2032 | flags: []string{"-expect-no-session"}, |
| 2033 | resumeSession: true, |
| 2034 | expectResumeRejected: true, |
| 2035 | }, |
David Benjamin | 99fdfb9 | 2015-11-02 12:11:35 -0500 | [diff] [blame] | 2036 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2037 | name: "BadHelloRequest-1", |
| 2038 | renegotiate: 1, |
| 2039 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2040 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2041 | Bugs: ProtocolBugs{ |
| 2042 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2043 | }, |
| 2044 | }, |
| 2045 | flags: []string{ |
| 2046 | "-renegotiate-freely", |
| 2047 | "-expect-total-renegotiations", "1", |
| 2048 | }, |
| 2049 | shouldFail: true, |
| 2050 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2051 | }, |
| 2052 | { |
| 2053 | name: "BadHelloRequest-2", |
| 2054 | renegotiate: 1, |
| 2055 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2056 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2057 | Bugs: ProtocolBugs{ |
| 2058 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2059 | }, |
| 2060 | }, |
| 2061 | flags: []string{ |
| 2062 | "-renegotiate-freely", |
| 2063 | "-expect-total-renegotiations", "1", |
| 2064 | }, |
| 2065 | shouldFail: true, |
| 2066 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2067 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2068 | { |
| 2069 | testType: serverTest, |
| 2070 | name: "SupportTicketsWithSessionID", |
| 2071 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2072 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2073 | SessionTicketsDisabled: true, |
| 2074 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2075 | resumeConfig: &Config{ |
| 2076 | MaxVersion: VersionTLS12, |
| 2077 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2078 | resumeSession: true, |
| 2079 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2080 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2081 | testCases = append(testCases, basicTests...) |
| 2082 | } |
| 2083 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2084 | func addCipherSuiteTests() { |
| 2085 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2086 | const psk = "12345" |
| 2087 | const pskIdentity = "luggage combo" |
| 2088 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2089 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2090 | var certFile string |
| 2091 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2092 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2093 | cert = ecdsaP256Certificate |
| 2094 | certFile = ecdsaP256CertificateFile |
| 2095 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2096 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2097 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2098 | certFile = rsaCertificateFile |
| 2099 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2100 | } |
| 2101 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2102 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2103 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2104 | flags = append(flags, |
| 2105 | "-psk", psk, |
| 2106 | "-psk-identity", pskIdentity) |
| 2107 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2108 | if hasComponent(suite.name, "NULL") { |
| 2109 | // NULL ciphers must be explicitly enabled. |
| 2110 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2111 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2112 | if hasComponent(suite.name, "CECPQ1") { |
| 2113 | // CECPQ1 ciphers must be explicitly enabled. |
| 2114 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2115 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2116 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2117 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2118 | for _, protocol := range []protocol{tls, dtls} { |
| 2119 | var prefix string |
| 2120 | if protocol == dtls { |
| 2121 | if !ver.hasDTLS { |
| 2122 | continue |
| 2123 | } |
| 2124 | prefix = "D" |
| 2125 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2126 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2127 | var shouldServerFail, shouldClientFail bool |
| 2128 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2129 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2130 | // a BoringSSL server will never select it |
| 2131 | // because the extension is missing. |
| 2132 | shouldServerFail = true |
| 2133 | } |
| 2134 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2135 | shouldClientFail = true |
| 2136 | shouldServerFail = true |
| 2137 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2138 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2139 | shouldClientFail = true |
| 2140 | shouldServerFail = true |
| 2141 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2142 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2143 | shouldClientFail = true |
| 2144 | shouldServerFail = true |
| 2145 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2146 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2147 | var expectedServerError, expectedClientError string |
| 2148 | if shouldServerFail { |
| 2149 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2150 | } |
| 2151 | if shouldClientFail { |
| 2152 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2153 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2154 | |
David Benjamin | 9deb117 | 2016-07-13 17:13:49 -0400 | [diff] [blame] | 2155 | // TODO(davidben,svaldez): Implement resumption for TLS 1.3. |
| 2156 | resumeSession := ver.version < VersionTLS13 |
| 2157 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2158 | testCases = append(testCases, testCase{ |
| 2159 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2160 | protocol: protocol, |
| 2161 | |
| 2162 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2163 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2164 | MinVersion: ver.version, |
| 2165 | MaxVersion: ver.version, |
| 2166 | CipherSuites: []uint16{suite.id}, |
| 2167 | Certificates: []Certificate{cert}, |
| 2168 | PreSharedKey: []byte(psk), |
| 2169 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2170 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2171 | EnableAllCiphers: shouldServerFail, |
| 2172 | IgnorePeerCipherPreferences: shouldServerFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2173 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2174 | }, |
| 2175 | certFile: certFile, |
| 2176 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2177 | flags: flags, |
David Benjamin | 9deb117 | 2016-07-13 17:13:49 -0400 | [diff] [blame] | 2178 | resumeSession: resumeSession, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2179 | shouldFail: shouldServerFail, |
| 2180 | expectedError: expectedServerError, |
| 2181 | }) |
| 2182 | |
| 2183 | testCases = append(testCases, testCase{ |
| 2184 | testType: clientTest, |
| 2185 | protocol: protocol, |
| 2186 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2187 | config: Config{ |
| 2188 | MinVersion: ver.version, |
| 2189 | MaxVersion: ver.version, |
| 2190 | CipherSuites: []uint16{suite.id}, |
| 2191 | Certificates: []Certificate{cert}, |
| 2192 | PreSharedKey: []byte(psk), |
| 2193 | PreSharedKeyIdentity: pskIdentity, |
| 2194 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2195 | EnableAllCiphers: shouldClientFail, |
| 2196 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2197 | }, |
| 2198 | }, |
| 2199 | flags: flags, |
David Benjamin | 9deb117 | 2016-07-13 17:13:49 -0400 | [diff] [blame] | 2200 | resumeSession: resumeSession, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2201 | shouldFail: shouldClientFail, |
| 2202 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2203 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2204 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2205 | if !shouldClientFail { |
| 2206 | // Ensure the maximum record size is accepted. |
| 2207 | testCases = append(testCases, testCase{ |
| 2208 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2209 | config: Config{ |
| 2210 | MinVersion: ver.version, |
| 2211 | MaxVersion: ver.version, |
| 2212 | CipherSuites: []uint16{suite.id}, |
| 2213 | Certificates: []Certificate{cert}, |
| 2214 | PreSharedKey: []byte(psk), |
| 2215 | PreSharedKeyIdentity: pskIdentity, |
| 2216 | }, |
| 2217 | flags: flags, |
| 2218 | messageLen: maxPlaintext, |
| 2219 | }) |
| 2220 | } |
| 2221 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2222 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2223 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2224 | |
| 2225 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2226 | name: "NoSharedCipher", |
| 2227 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2228 | MaxVersion: VersionTLS12, |
| 2229 | CipherSuites: []uint16{}, |
| 2230 | }, |
| 2231 | shouldFail: true, |
| 2232 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2233 | }) |
| 2234 | |
| 2235 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 2236 | name: "NoSharedCipher-TLS13", |
| 2237 | config: Config{ |
| 2238 | MaxVersion: VersionTLS13, |
| 2239 | CipherSuites: []uint16{}, |
| 2240 | }, |
| 2241 | shouldFail: true, |
| 2242 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2243 | }) |
| 2244 | |
| 2245 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2246 | name: "UnsupportedCipherSuite", |
| 2247 | config: Config{ |
| 2248 | MaxVersion: VersionTLS12, |
| 2249 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 2250 | Bugs: ProtocolBugs{ |
| 2251 | IgnorePeerCipherPreferences: true, |
| 2252 | }, |
| 2253 | }, |
| 2254 | flags: []string{"-cipher", "DEFAULT:!RC4"}, |
| 2255 | shouldFail: true, |
| 2256 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2257 | }) |
| 2258 | |
| 2259 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2260 | name: "WeakDH", |
| 2261 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2262 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2263 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2264 | Bugs: ProtocolBugs{ |
| 2265 | // This is a 1023-bit prime number, generated |
| 2266 | // with: |
| 2267 | // openssl gendh 1023 | openssl asn1parse -i |
| 2268 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2269 | }, |
| 2270 | }, |
| 2271 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2272 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2273 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2274 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2275 | testCases = append(testCases, testCase{ |
| 2276 | name: "SillyDH", |
| 2277 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2278 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2279 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2280 | Bugs: ProtocolBugs{ |
| 2281 | // This is a 4097-bit prime number, generated |
| 2282 | // with: |
| 2283 | // openssl gendh 4097 | openssl asn1parse -i |
| 2284 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2285 | }, |
| 2286 | }, |
| 2287 | shouldFail: true, |
| 2288 | expectedError: ":DH_P_TOO_LONG:", |
| 2289 | }) |
| 2290 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2291 | // This test ensures that Diffie-Hellman public values are padded with |
| 2292 | // zeros so that they're the same length as the prime. This is to avoid |
| 2293 | // hitting a bug in yaSSL. |
| 2294 | testCases = append(testCases, testCase{ |
| 2295 | testType: serverTest, |
| 2296 | name: "DHPublicValuePadded", |
| 2297 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2298 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2299 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2300 | Bugs: ProtocolBugs{ |
| 2301 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2302 | }, |
| 2303 | }, |
| 2304 | flags: []string{"-use-sparse-dh-prime"}, |
| 2305 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2306 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2307 | // The server must be tolerant to bogus ciphers. |
| 2308 | const bogusCipher = 0x1234 |
| 2309 | testCases = append(testCases, testCase{ |
| 2310 | testType: serverTest, |
| 2311 | name: "UnknownCipher", |
| 2312 | config: Config{ |
| 2313 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2314 | }, |
| 2315 | }) |
| 2316 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2317 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2318 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2319 | // cipher lists and then a connection is made for each member of |
| 2320 | // expectations. The cipher suite that the server selects must match |
| 2321 | // the specified one. |
| 2322 | var versionSpecificCiphersTest = []struct { |
| 2323 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2324 | // expectations is a map from TLS version to cipher suite id. |
| 2325 | expectations map[uint16]uint16 |
| 2326 | }{ |
| 2327 | { |
| 2328 | // Test that the null case (where no version-specific ciphers are set) |
| 2329 | // works as expected. |
| 2330 | "RC4-SHA:AES128-SHA", // default ciphers |
| 2331 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2332 | "", // no ciphers specifically for TLS ≥ 1.1 |
| 2333 | map[uint16]uint16{ |
| 2334 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2335 | VersionTLS10: TLS_RSA_WITH_RC4_128_SHA, |
| 2336 | VersionTLS11: TLS_RSA_WITH_RC4_128_SHA, |
| 2337 | VersionTLS12: TLS_RSA_WITH_RC4_128_SHA, |
| 2338 | }, |
| 2339 | }, |
| 2340 | { |
| 2341 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2342 | // cipher. |
| 2343 | "RC4-SHA:AES128-SHA", // default |
| 2344 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2345 | "", // no ciphers specifically for TLS ≥ 1.1 |
| 2346 | map[uint16]uint16{ |
| 2347 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2348 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2349 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2350 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2351 | }, |
| 2352 | }, |
| 2353 | { |
| 2354 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2355 | // cipher. |
| 2356 | "RC4-SHA:AES128-SHA", // default |
| 2357 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2358 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
| 2359 | map[uint16]uint16{ |
| 2360 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2361 | VersionTLS10: TLS_RSA_WITH_RC4_128_SHA, |
| 2362 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2363 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2364 | }, |
| 2365 | }, |
| 2366 | { |
| 2367 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2368 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
| 2369 | "RC4-SHA:AES128-SHA", // default |
| 2370 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2371 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
| 2372 | map[uint16]uint16{ |
| 2373 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2374 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2375 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2376 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2377 | }, |
| 2378 | }, |
| 2379 | } |
| 2380 | |
| 2381 | for i, test := range versionSpecificCiphersTest { |
| 2382 | for version, expectedCipherSuite := range test.expectations { |
| 2383 | flags := []string{"-cipher", test.ciphersDefault} |
| 2384 | if len(test.ciphersTLS10) > 0 { |
| 2385 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2386 | } |
| 2387 | if len(test.ciphersTLS11) > 0 { |
| 2388 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2389 | } |
| 2390 | |
| 2391 | testCases = append(testCases, testCase{ |
| 2392 | testType: serverTest, |
| 2393 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2394 | config: Config{ |
| 2395 | MaxVersion: version, |
| 2396 | MinVersion: version, |
| 2397 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA}, |
| 2398 | }, |
| 2399 | flags: flags, |
| 2400 | expectedCipher: expectedCipherSuite, |
| 2401 | }) |
| 2402 | } |
| 2403 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2404 | } |
| 2405 | |
| 2406 | func addBadECDSASignatureTests() { |
| 2407 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2408 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2409 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2410 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2411 | config: Config{ |
| 2412 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2413 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2414 | Bugs: ProtocolBugs{ |
| 2415 | BadECDSAR: badR, |
| 2416 | BadECDSAS: badS, |
| 2417 | }, |
| 2418 | }, |
| 2419 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2420 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2421 | }) |
| 2422 | } |
| 2423 | } |
| 2424 | } |
| 2425 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2426 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2427 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2428 | name: "MaxCBCPadding", |
| 2429 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2430 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2431 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2432 | Bugs: ProtocolBugs{ |
| 2433 | MaxPadding: true, |
| 2434 | }, |
| 2435 | }, |
| 2436 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2437 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2438 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2439 | name: "BadCBCPadding", |
| 2440 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2441 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2442 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2443 | Bugs: ProtocolBugs{ |
| 2444 | PaddingFirstByteBad: true, |
| 2445 | }, |
| 2446 | }, |
| 2447 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2448 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2449 | }) |
| 2450 | // OpenSSL previously had an issue where the first byte of padding in |
| 2451 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2452 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2453 | name: "BadCBCPadding255", |
| 2454 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2455 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2456 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2457 | Bugs: ProtocolBugs{ |
| 2458 | MaxPadding: true, |
| 2459 | PaddingFirstByteBadIf255: true, |
| 2460 | }, |
| 2461 | }, |
| 2462 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2463 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2464 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2465 | }) |
| 2466 | } |
| 2467 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2468 | func addCBCSplittingTests() { |
| 2469 | testCases = append(testCases, testCase{ |
| 2470 | name: "CBCRecordSplitting", |
| 2471 | config: Config{ |
| 2472 | MaxVersion: VersionTLS10, |
| 2473 | MinVersion: VersionTLS10, |
| 2474 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2475 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2476 | messageLen: -1, // read until EOF |
| 2477 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2478 | flags: []string{ |
| 2479 | "-async", |
| 2480 | "-write-different-record-sizes", |
| 2481 | "-cbc-record-splitting", |
| 2482 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2483 | }) |
| 2484 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2485 | name: "CBCRecordSplittingPartialWrite", |
| 2486 | config: Config{ |
| 2487 | MaxVersion: VersionTLS10, |
| 2488 | MinVersion: VersionTLS10, |
| 2489 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2490 | }, |
| 2491 | messageLen: -1, // read until EOF |
| 2492 | flags: []string{ |
| 2493 | "-async", |
| 2494 | "-write-different-record-sizes", |
| 2495 | "-cbc-record-splitting", |
| 2496 | "-partial-write", |
| 2497 | }, |
| 2498 | }) |
| 2499 | } |
| 2500 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2501 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2502 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2503 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2504 | certPool := x509.NewCertPool() |
| 2505 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2506 | if err != nil { |
| 2507 | panic(err) |
| 2508 | } |
| 2509 | certPool.AddCert(cert) |
| 2510 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2511 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2512 | testCases = append(testCases, testCase{ |
| 2513 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2514 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2515 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2516 | MinVersion: ver.version, |
| 2517 | MaxVersion: ver.version, |
| 2518 | ClientAuth: RequireAnyClientCert, |
| 2519 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2520 | }, |
| 2521 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2522 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2523 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2524 | }, |
| 2525 | }) |
| 2526 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2527 | testType: serverTest, |
| 2528 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2529 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2530 | MinVersion: ver.version, |
| 2531 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2532 | Certificates: []Certificate{rsaCertificate}, |
| 2533 | }, |
| 2534 | flags: []string{"-require-any-client-certificate"}, |
| 2535 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2536 | if ver.version != VersionSSL30 { |
| 2537 | testCases = append(testCases, testCase{ |
| 2538 | testType: serverTest, |
| 2539 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 2540 | config: Config{ |
| 2541 | MinVersion: ver.version, |
| 2542 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2543 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2544 | }, |
| 2545 | flags: []string{"-require-any-client-certificate"}, |
| 2546 | }) |
| 2547 | testCases = append(testCases, testCase{ |
| 2548 | testType: clientTest, |
| 2549 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 2550 | config: Config{ |
| 2551 | MinVersion: ver.version, |
| 2552 | MaxVersion: ver.version, |
| 2553 | ClientAuth: RequireAnyClientCert, |
| 2554 | ClientCAs: certPool, |
| 2555 | }, |
| 2556 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2557 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2558 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2559 | }, |
| 2560 | }) |
| 2561 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2562 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2563 | |
| 2564 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2565 | name: "NoClientCertificate", |
| 2566 | config: Config{ |
| 2567 | MaxVersion: VersionTLS12, |
| 2568 | ClientAuth: RequireAnyClientCert, |
| 2569 | }, |
| 2570 | shouldFail: true, |
| 2571 | expectedLocalError: "client didn't provide a certificate", |
| 2572 | }) |
| 2573 | |
| 2574 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 2575 | name: "NoClientCertificate-TLS13", |
| 2576 | config: Config{ |
| 2577 | MaxVersion: VersionTLS13, |
| 2578 | ClientAuth: RequireAnyClientCert, |
| 2579 | }, |
| 2580 | shouldFail: true, |
| 2581 | expectedLocalError: "client didn't provide a certificate", |
| 2582 | }) |
| 2583 | |
| 2584 | testCases = append(testCases, testCase{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2585 | testType: serverTest, |
| 2586 | name: "RequireAnyClientCertificate", |
| 2587 | config: Config{ |
| 2588 | MaxVersion: VersionTLS12, |
| 2589 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2590 | flags: []string{"-require-any-client-certificate"}, |
| 2591 | shouldFail: true, |
| 2592 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2593 | }) |
| 2594 | |
| 2595 | testCases = append(testCases, testCase{ |
| 2596 | testType: serverTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 2597 | name: "RequireAnyClientCertificate-TLS13", |
| 2598 | config: Config{ |
| 2599 | MaxVersion: VersionTLS13, |
| 2600 | }, |
| 2601 | flags: []string{"-require-any-client-certificate"}, |
| 2602 | shouldFail: true, |
| 2603 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2604 | }) |
| 2605 | |
| 2606 | testCases = append(testCases, testCase{ |
| 2607 | testType: serverTest, |
David Benjamin | df28c3a | 2016-03-10 16:11:51 -0500 | [diff] [blame] | 2608 | name: "RequireAnyClientCertificate-SSL3", |
| 2609 | config: Config{ |
| 2610 | MaxVersion: VersionSSL30, |
| 2611 | }, |
| 2612 | flags: []string{"-require-any-client-certificate"}, |
| 2613 | shouldFail: true, |
| 2614 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2615 | }) |
| 2616 | |
| 2617 | testCases = append(testCases, testCase{ |
| 2618 | testType: serverTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2619 | name: "SkipClientCertificate", |
| 2620 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2621 | MaxVersion: VersionTLS12, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2622 | Bugs: ProtocolBugs{ |
| 2623 | SkipClientCertificate: true, |
| 2624 | }, |
| 2625 | }, |
| 2626 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2627 | flags: []string{"-verify-peer"}, |
| 2628 | shouldFail: true, |
David Benjamin | df28c3a | 2016-03-10 16:11:51 -0500 | [diff] [blame] | 2629 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2630 | }) |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2631 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 2632 | testCases = append(testCases, testCase{ |
| 2633 | testType: serverTest, |
| 2634 | name: "SkipClientCertificate-TLS13", |
| 2635 | config: Config{ |
| 2636 | MaxVersion: VersionTLS13, |
| 2637 | Bugs: ProtocolBugs{ |
| 2638 | SkipClientCertificate: true, |
| 2639 | }, |
| 2640 | }, |
| 2641 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2642 | flags: []string{"-verify-peer"}, |
| 2643 | shouldFail: true, |
| 2644 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2645 | }) |
| 2646 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2647 | // Client auth is only legal in certificate-based ciphers. |
| 2648 | testCases = append(testCases, testCase{ |
| 2649 | testType: clientTest, |
| 2650 | name: "ClientAuth-PSK", |
| 2651 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2652 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2653 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2654 | PreSharedKey: []byte("secret"), |
| 2655 | ClientAuth: RequireAnyClientCert, |
| 2656 | }, |
| 2657 | flags: []string{ |
| 2658 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2659 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2660 | "-psk", "secret", |
| 2661 | }, |
| 2662 | shouldFail: true, |
| 2663 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2664 | }) |
| 2665 | testCases = append(testCases, testCase{ |
| 2666 | testType: clientTest, |
| 2667 | name: "ClientAuth-ECDHE_PSK", |
| 2668 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2669 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2670 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2671 | PreSharedKey: []byte("secret"), |
| 2672 | ClientAuth: RequireAnyClientCert, |
| 2673 | }, |
| 2674 | flags: []string{ |
| 2675 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2676 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2677 | "-psk", "secret", |
| 2678 | }, |
| 2679 | shouldFail: true, |
| 2680 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2681 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 2682 | |
| 2683 | // Regression test for a bug where the client CA list, if explicitly |
| 2684 | // set to NULL, was mis-encoded. |
| 2685 | testCases = append(testCases, testCase{ |
| 2686 | testType: serverTest, |
| 2687 | name: "Null-Client-CA-List", |
| 2688 | config: Config{ |
| 2689 | MaxVersion: VersionTLS12, |
| 2690 | Certificates: []Certificate{rsaCertificate}, |
| 2691 | }, |
| 2692 | flags: []string{ |
| 2693 | "-require-any-client-certificate", |
| 2694 | "-use-null-client-ca-list", |
| 2695 | }, |
| 2696 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2697 | } |
| 2698 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2699 | func addExtendedMasterSecretTests() { |
| 2700 | const expectEMSFlag = "-expect-extended-master-secret" |
| 2701 | |
| 2702 | for _, with := range []bool{false, true} { |
| 2703 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2704 | if with { |
| 2705 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2706 | } |
| 2707 | |
| 2708 | for _, isClient := range []bool{false, true} { |
| 2709 | suffix := "-Server" |
| 2710 | testType := serverTest |
| 2711 | if isClient { |
| 2712 | suffix = "-Client" |
| 2713 | testType = clientTest |
| 2714 | } |
| 2715 | |
| 2716 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 2717 | // In TLS 1.3, the extension is irrelevant and |
| 2718 | // always reports as enabled. |
| 2719 | var flags []string |
| 2720 | if with || ver.version >= VersionTLS13 { |
| 2721 | flags = []string{expectEMSFlag} |
| 2722 | } |
| 2723 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2724 | test := testCase{ |
| 2725 | testType: testType, |
| 2726 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 2727 | config: Config{ |
| 2728 | MinVersion: ver.version, |
| 2729 | MaxVersion: ver.version, |
| 2730 | Bugs: ProtocolBugs{ |
| 2731 | NoExtendedMasterSecret: !with, |
| 2732 | RequireExtendedMasterSecret: with, |
| 2733 | }, |
| 2734 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2735 | flags: flags, |
| 2736 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2737 | } |
| 2738 | if test.shouldFail { |
| 2739 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 2740 | } |
| 2741 | testCases = append(testCases, test) |
| 2742 | } |
| 2743 | } |
| 2744 | } |
| 2745 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 2746 | for _, isClient := range []bool{false, true} { |
| 2747 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 2748 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 2749 | boolToWord := func(b bool) string { |
| 2750 | if b { |
| 2751 | return "Yes" |
| 2752 | } |
| 2753 | return "No" |
| 2754 | } |
| 2755 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 2756 | if isClient { |
| 2757 | suffix += "Client" |
| 2758 | } else { |
| 2759 | suffix += "Server" |
| 2760 | } |
| 2761 | |
| 2762 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2763 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 2764 | Bugs: ProtocolBugs{ |
| 2765 | RequireExtendedMasterSecret: true, |
| 2766 | }, |
| 2767 | } |
| 2768 | |
| 2769 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2770 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 2771 | Bugs: ProtocolBugs{ |
| 2772 | NoExtendedMasterSecret: true, |
| 2773 | }, |
| 2774 | } |
| 2775 | |
| 2776 | test := testCase{ |
| 2777 | name: "ExtendedMasterSecret-" + suffix, |
| 2778 | resumeSession: true, |
| 2779 | } |
| 2780 | |
| 2781 | if !isClient { |
| 2782 | test.testType = serverTest |
| 2783 | } |
| 2784 | |
| 2785 | if supportedInFirstConnection { |
| 2786 | test.config = supportedConfig |
| 2787 | } else { |
| 2788 | test.config = noSupportConfig |
| 2789 | } |
| 2790 | |
| 2791 | if supportedInResumeConnection { |
| 2792 | test.resumeConfig = &supportedConfig |
| 2793 | } else { |
| 2794 | test.resumeConfig = &noSupportConfig |
| 2795 | } |
| 2796 | |
| 2797 | switch suffix { |
| 2798 | case "YesToYes-Client", "YesToYes-Server": |
| 2799 | // When a session is resumed, it should |
| 2800 | // still be aware that its master |
| 2801 | // secret was generated via EMS and |
| 2802 | // thus it's safe to use tls-unique. |
| 2803 | test.flags = []string{expectEMSFlag} |
| 2804 | case "NoToYes-Server": |
| 2805 | // If an original connection did not |
| 2806 | // contain EMS, but a resumption |
| 2807 | // handshake does, then a server should |
| 2808 | // not resume the session. |
| 2809 | test.expectResumeRejected = true |
| 2810 | case "YesToNo-Server": |
| 2811 | // Resuming an EMS session without the |
| 2812 | // EMS extension should cause the |
| 2813 | // server to abort the connection. |
| 2814 | test.shouldFail = true |
| 2815 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 2816 | case "NoToYes-Client": |
| 2817 | // A client should abort a connection |
| 2818 | // where the server resumed a non-EMS |
| 2819 | // session but echoed the EMS |
| 2820 | // extension. |
| 2821 | test.shouldFail = true |
| 2822 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 2823 | case "YesToNo-Client": |
| 2824 | // A client should abort a connection |
| 2825 | // where the server didn't echo EMS |
| 2826 | // when the session used it. |
| 2827 | test.shouldFail = true |
| 2828 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 2829 | } |
| 2830 | |
| 2831 | testCases = append(testCases, test) |
| 2832 | } |
| 2833 | } |
| 2834 | } |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2835 | } |
| 2836 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 2837 | type stateMachineTestConfig struct { |
| 2838 | protocol protocol |
| 2839 | async bool |
| 2840 | splitHandshake, packHandshakeFlight bool |
| 2841 | } |
| 2842 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 2843 | // Adds tests that try to cover the range of the handshake state machine, under |
| 2844 | // various conditions. Some of these are redundant with other tests, but they |
| 2845 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 2846 | func addAllStateMachineCoverageTests() { |
| 2847 | for _, async := range []bool{false, true} { |
| 2848 | for _, protocol := range []protocol{tls, dtls} { |
| 2849 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 2850 | protocol: protocol, |
| 2851 | async: async, |
| 2852 | }) |
| 2853 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 2854 | protocol: protocol, |
| 2855 | async: async, |
| 2856 | splitHandshake: true, |
| 2857 | }) |
| 2858 | if protocol == tls { |
| 2859 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 2860 | protocol: protocol, |
| 2861 | async: async, |
| 2862 | packHandshakeFlight: true, |
| 2863 | }) |
| 2864 | } |
| 2865 | } |
| 2866 | } |
| 2867 | } |
| 2868 | |
| 2869 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2870 | var tests []testCase |
| 2871 | |
| 2872 | // Basic handshake, with resumption. Client and server, |
| 2873 | // session ID and session ticket. |
| 2874 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2875 | name: "Basic-Client", |
| 2876 | config: Config{ |
| 2877 | MaxVersion: VersionTLS12, |
| 2878 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2879 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2880 | // Ensure session tickets are used, not session IDs. |
| 2881 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2882 | }) |
| 2883 | tests = append(tests, testCase{ |
| 2884 | name: "Basic-Client-RenewTicket", |
| 2885 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2886 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2887 | Bugs: ProtocolBugs{ |
| 2888 | RenewTicketOnResume: true, |
| 2889 | }, |
| 2890 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2891 | flags: []string{"-expect-ticket-renewal"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2892 | resumeSession: true, |
| 2893 | }) |
| 2894 | tests = append(tests, testCase{ |
| 2895 | name: "Basic-Client-NoTicket", |
| 2896 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2897 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2898 | SessionTicketsDisabled: true, |
| 2899 | }, |
| 2900 | resumeSession: true, |
| 2901 | }) |
| 2902 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2903 | name: "Basic-Client-Implicit", |
| 2904 | config: Config{ |
| 2905 | MaxVersion: VersionTLS12, |
| 2906 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2907 | flags: []string{"-implicit-handshake"}, |
| 2908 | resumeSession: true, |
| 2909 | }) |
| 2910 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2911 | testType: serverTest, |
| 2912 | name: "Basic-Server", |
| 2913 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2914 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2915 | Bugs: ProtocolBugs{ |
| 2916 | RequireSessionTickets: true, |
| 2917 | }, |
| 2918 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2919 | resumeSession: true, |
| 2920 | }) |
| 2921 | tests = append(tests, testCase{ |
| 2922 | testType: serverTest, |
| 2923 | name: "Basic-Server-NoTickets", |
| 2924 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2925 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2926 | SessionTicketsDisabled: true, |
| 2927 | }, |
| 2928 | resumeSession: true, |
| 2929 | }) |
| 2930 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2931 | testType: serverTest, |
| 2932 | name: "Basic-Server-Implicit", |
| 2933 | config: Config{ |
| 2934 | MaxVersion: VersionTLS12, |
| 2935 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2936 | flags: []string{"-implicit-handshake"}, |
| 2937 | resumeSession: true, |
| 2938 | }) |
| 2939 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2940 | testType: serverTest, |
| 2941 | name: "Basic-Server-EarlyCallback", |
| 2942 | config: Config{ |
| 2943 | MaxVersion: VersionTLS12, |
| 2944 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2945 | flags: []string{"-use-early-callback"}, |
| 2946 | resumeSession: true, |
| 2947 | }) |
| 2948 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 2949 | // TLS 1.3 basic handshake shapes. |
| 2950 | tests = append(tests, testCase{ |
| 2951 | name: "TLS13-1RTT-Client", |
| 2952 | config: Config{ |
| 2953 | MaxVersion: VersionTLS13, |
| 2954 | }, |
| 2955 | }) |
| 2956 | tests = append(tests, testCase{ |
| 2957 | testType: serverTest, |
| 2958 | name: "TLS13-1RTT-Server", |
| 2959 | config: Config{ |
| 2960 | MaxVersion: VersionTLS13, |
| 2961 | }, |
| 2962 | }) |
| 2963 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2964 | // TLS client auth. |
| 2965 | tests = append(tests, testCase{ |
| 2966 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2967 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 2968 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2969 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 2970 | ClientAuth: RequestClientCert, |
| 2971 | }, |
| 2972 | }) |
| 2973 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2974 | testType: serverTest, |
| 2975 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2976 | config: Config{ |
| 2977 | MaxVersion: VersionTLS12, |
| 2978 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2979 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2980 | flags: []string{"-verify-peer"}, |
| 2981 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 2982 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2983 | tests = append(tests, testCase{ |
| 2984 | testType: clientTest, |
| 2985 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 2986 | config: Config{ |
| 2987 | MaxVersion: VersionSSL30, |
| 2988 | ClientAuth: RequestClientCert, |
| 2989 | }, |
| 2990 | }) |
| 2991 | tests = append(tests, testCase{ |
| 2992 | testType: serverTest, |
| 2993 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 2994 | config: Config{ |
| 2995 | MaxVersion: VersionSSL30, |
| 2996 | }, |
| 2997 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2998 | flags: []string{"-verify-peer"}, |
| 2999 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3000 | tests = append(tests, testCase{ |
| 3001 | testType: clientTest, |
| 3002 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3003 | config: Config{ |
| 3004 | MaxVersion: VersionTLS13, |
| 3005 | ClientAuth: RequestClientCert, |
| 3006 | }, |
| 3007 | }) |
| 3008 | tests = append(tests, testCase{ |
| 3009 | testType: serverTest, |
| 3010 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3011 | config: Config{ |
| 3012 | MaxVersion: VersionTLS13, |
| 3013 | }, |
| 3014 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3015 | flags: []string{"-verify-peer"}, |
| 3016 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3017 | } |
| 3018 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3019 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3020 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3021 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3022 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3023 | ClientAuth: RequireAnyClientCert, |
| 3024 | }, |
| 3025 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3026 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3027 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3028 | }, |
| 3029 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3030 | tests = append(tests, testCase{ |
| 3031 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3032 | name: "ClientAuth-RSA-Client-TLS13", |
| 3033 | config: Config{ |
| 3034 | MaxVersion: VersionTLS13, |
| 3035 | ClientAuth: RequireAnyClientCert, |
| 3036 | }, |
| 3037 | flags: []string{ |
| 3038 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3039 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3040 | }, |
| 3041 | }) |
| 3042 | tests = append(tests, testCase{ |
| 3043 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3044 | name: "ClientAuth-ECDSA-Client", |
| 3045 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3046 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3047 | ClientAuth: RequireAnyClientCert, |
| 3048 | }, |
| 3049 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3050 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3051 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3052 | }, |
| 3053 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3054 | tests = append(tests, testCase{ |
| 3055 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3056 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3057 | config: Config{ |
| 3058 | MaxVersion: VersionTLS13, |
| 3059 | ClientAuth: RequireAnyClientCert, |
| 3060 | }, |
| 3061 | flags: []string{ |
| 3062 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3063 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3064 | }, |
| 3065 | }) |
| 3066 | tests = append(tests, testCase{ |
| 3067 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3068 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3069 | config: Config{ |
| 3070 | MaxVersion: VersionTLS12, |
| 3071 | ClientAuth: RequestClientCert, |
| 3072 | }, |
| 3073 | flags: []string{"-use-old-client-cert-callback"}, |
| 3074 | }) |
| 3075 | tests = append(tests, testCase{ |
| 3076 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3077 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3078 | config: Config{ |
| 3079 | MaxVersion: VersionTLS13, |
| 3080 | ClientAuth: RequestClientCert, |
| 3081 | }, |
| 3082 | flags: []string{"-use-old-client-cert-callback"}, |
| 3083 | }) |
| 3084 | tests = append(tests, testCase{ |
| 3085 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3086 | name: "ClientAuth-OldCallback", |
| 3087 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3088 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3089 | ClientAuth: RequireAnyClientCert, |
| 3090 | }, |
| 3091 | flags: []string{ |
| 3092 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3093 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3094 | "-use-old-client-cert-callback", |
| 3095 | }, |
| 3096 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3097 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3098 | testType: clientTest, |
| 3099 | name: "ClientAuth-OldCallback-TLS13", |
| 3100 | config: Config{ |
| 3101 | MaxVersion: VersionTLS13, |
| 3102 | ClientAuth: RequireAnyClientCert, |
| 3103 | }, |
| 3104 | flags: []string{ |
| 3105 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3106 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3107 | "-use-old-client-cert-callback", |
| 3108 | }, |
| 3109 | }) |
| 3110 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3111 | testType: serverTest, |
| 3112 | name: "ClientAuth-Server", |
| 3113 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3114 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3115 | Certificates: []Certificate{rsaCertificate}, |
| 3116 | }, |
| 3117 | flags: []string{"-require-any-client-certificate"}, |
| 3118 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3119 | tests = append(tests, testCase{ |
| 3120 | testType: serverTest, |
| 3121 | name: "ClientAuth-Server-TLS13", |
| 3122 | config: Config{ |
| 3123 | MaxVersion: VersionTLS13, |
| 3124 | Certificates: []Certificate{rsaCertificate}, |
| 3125 | }, |
| 3126 | flags: []string{"-require-any-client-certificate"}, |
| 3127 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3128 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3129 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3130 | tests = append(tests, testCase{ |
| 3131 | testType: serverTest, |
| 3132 | name: "Basic-Server-RSA", |
| 3133 | config: Config{ |
| 3134 | MaxVersion: VersionTLS12, |
| 3135 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3136 | }, |
| 3137 | flags: []string{ |
| 3138 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3139 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3140 | }, |
| 3141 | }) |
| 3142 | tests = append(tests, testCase{ |
| 3143 | testType: serverTest, |
| 3144 | name: "Basic-Server-ECDHE-RSA", |
| 3145 | config: Config{ |
| 3146 | MaxVersion: VersionTLS12, |
| 3147 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3148 | }, |
| 3149 | flags: []string{ |
| 3150 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3151 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3152 | }, |
| 3153 | }) |
| 3154 | tests = append(tests, testCase{ |
| 3155 | testType: serverTest, |
| 3156 | name: "Basic-Server-ECDHE-ECDSA", |
| 3157 | config: Config{ |
| 3158 | MaxVersion: VersionTLS12, |
| 3159 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3160 | }, |
| 3161 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3162 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3163 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3164 | }, |
| 3165 | }) |
| 3166 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3167 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3168 | tests = append(tests, testCase{ |
| 3169 | name: "SessionTicketsDisabled-Client", |
| 3170 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3171 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3172 | SessionTicketsDisabled: true, |
| 3173 | }, |
| 3174 | }) |
| 3175 | tests = append(tests, testCase{ |
| 3176 | testType: serverTest, |
| 3177 | name: "SessionTicketsDisabled-Server", |
| 3178 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3179 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3180 | SessionTicketsDisabled: true, |
| 3181 | }, |
| 3182 | }) |
| 3183 | |
| 3184 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3185 | // identity hint. |
| 3186 | tests = append(tests, testCase{ |
| 3187 | name: "EmptyPSKHint-Client", |
| 3188 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3189 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3190 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3191 | PreSharedKey: []byte("secret"), |
| 3192 | }, |
| 3193 | flags: []string{"-psk", "secret"}, |
| 3194 | }) |
| 3195 | tests = append(tests, testCase{ |
| 3196 | testType: serverTest, |
| 3197 | name: "EmptyPSKHint-Server", |
| 3198 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3199 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3200 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3201 | PreSharedKey: []byte("secret"), |
| 3202 | }, |
| 3203 | flags: []string{"-psk", "secret"}, |
| 3204 | }) |
| 3205 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3206 | // OCSP stapling tests. |
| 3207 | // |
| 3208 | // TODO(davidben): Test the TLS 1.3 version of OCSP stapling. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3209 | tests = append(tests, testCase{ |
| 3210 | testType: clientTest, |
| 3211 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3212 | config: Config{ |
| 3213 | MaxVersion: VersionTLS12, |
| 3214 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3215 | flags: []string{ |
| 3216 | "-enable-ocsp-stapling", |
| 3217 | "-expect-ocsp-response", |
| 3218 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3219 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3220 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3221 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3222 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3223 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3224 | testType: serverTest, |
| 3225 | name: "OCSPStapling-Server", |
| 3226 | config: Config{ |
| 3227 | MaxVersion: VersionTLS12, |
| 3228 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3229 | expectedOCSPResponse: testOCSPResponse, |
| 3230 | flags: []string{ |
| 3231 | "-ocsp-response", |
| 3232 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3233 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3234 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3235 | }) |
| 3236 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3237 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3238 | for _, vers := range tlsVersions { |
| 3239 | if config.protocol == dtls && !vers.hasDTLS { |
| 3240 | continue |
| 3241 | } |
| 3242 | tests = append(tests, testCase{ |
| 3243 | testType: clientTest, |
| 3244 | name: "CertificateVerificationSucceed-" + vers.name, |
| 3245 | config: Config{ |
| 3246 | MaxVersion: vers.version, |
| 3247 | }, |
| 3248 | flags: []string{ |
| 3249 | "-verify-peer", |
| 3250 | }, |
| 3251 | }) |
| 3252 | tests = append(tests, testCase{ |
| 3253 | testType: clientTest, |
| 3254 | name: "CertificateVerificationFail-" + vers.name, |
| 3255 | config: Config{ |
| 3256 | MaxVersion: vers.version, |
| 3257 | }, |
| 3258 | flags: []string{ |
| 3259 | "-verify-fail", |
| 3260 | "-verify-peer", |
| 3261 | }, |
| 3262 | shouldFail: true, |
| 3263 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3264 | }) |
| 3265 | tests = append(tests, testCase{ |
| 3266 | testType: clientTest, |
| 3267 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3268 | config: Config{ |
| 3269 | MaxVersion: vers.version, |
| 3270 | }, |
| 3271 | flags: []string{ |
| 3272 | "-verify-fail", |
| 3273 | "-expect-verify-result", |
| 3274 | }, |
| 3275 | }) |
| 3276 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3277 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3278 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3279 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3280 | name: "Renegotiate-Client", |
| 3281 | config: Config{ |
| 3282 | MaxVersion: VersionTLS12, |
| 3283 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3284 | renegotiate: 1, |
| 3285 | flags: []string{ |
| 3286 | "-renegotiate-freely", |
| 3287 | "-expect-total-renegotiations", "1", |
| 3288 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3289 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3290 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3291 | // NPN on client and server; results in post-handshake message. |
| 3292 | tests = append(tests, testCase{ |
| 3293 | name: "NPN-Client", |
| 3294 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3295 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3296 | NextProtos: []string{"foo"}, |
| 3297 | }, |
| 3298 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3299 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3300 | expectedNextProto: "foo", |
| 3301 | expectedNextProtoType: npn, |
| 3302 | }) |
| 3303 | tests = append(tests, testCase{ |
| 3304 | testType: serverTest, |
| 3305 | name: "NPN-Server", |
| 3306 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3307 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3308 | NextProtos: []string{"bar"}, |
| 3309 | }, |
| 3310 | flags: []string{ |
| 3311 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3312 | "-expect-next-proto", "bar", |
| 3313 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3314 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3315 | expectedNextProto: "bar", |
| 3316 | expectedNextProtoType: npn, |
| 3317 | }) |
| 3318 | |
| 3319 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3320 | |
| 3321 | // Client does False Start and negotiates NPN. |
| 3322 | tests = append(tests, testCase{ |
| 3323 | name: "FalseStart", |
| 3324 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3325 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3326 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3327 | NextProtos: []string{"foo"}, |
| 3328 | Bugs: ProtocolBugs{ |
| 3329 | ExpectFalseStart: true, |
| 3330 | }, |
| 3331 | }, |
| 3332 | flags: []string{ |
| 3333 | "-false-start", |
| 3334 | "-select-next-proto", "foo", |
| 3335 | }, |
| 3336 | shimWritesFirst: true, |
| 3337 | resumeSession: true, |
| 3338 | }) |
| 3339 | |
| 3340 | // Client does False Start and negotiates ALPN. |
| 3341 | tests = append(tests, testCase{ |
| 3342 | name: "FalseStart-ALPN", |
| 3343 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3344 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3345 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3346 | NextProtos: []string{"foo"}, |
| 3347 | Bugs: ProtocolBugs{ |
| 3348 | ExpectFalseStart: true, |
| 3349 | }, |
| 3350 | }, |
| 3351 | flags: []string{ |
| 3352 | "-false-start", |
| 3353 | "-advertise-alpn", "\x03foo", |
| 3354 | }, |
| 3355 | shimWritesFirst: true, |
| 3356 | resumeSession: true, |
| 3357 | }) |
| 3358 | |
| 3359 | // Client does False Start but doesn't explicitly call |
| 3360 | // SSL_connect. |
| 3361 | tests = append(tests, testCase{ |
| 3362 | name: "FalseStart-Implicit", |
| 3363 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3364 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3365 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3366 | NextProtos: []string{"foo"}, |
| 3367 | }, |
| 3368 | flags: []string{ |
| 3369 | "-implicit-handshake", |
| 3370 | "-false-start", |
| 3371 | "-advertise-alpn", "\x03foo", |
| 3372 | }, |
| 3373 | }) |
| 3374 | |
| 3375 | // False Start without session tickets. |
| 3376 | tests = append(tests, testCase{ |
| 3377 | name: "FalseStart-SessionTicketsDisabled", |
| 3378 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3379 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3380 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3381 | NextProtos: []string{"foo"}, |
| 3382 | SessionTicketsDisabled: true, |
| 3383 | Bugs: ProtocolBugs{ |
| 3384 | ExpectFalseStart: true, |
| 3385 | }, |
| 3386 | }, |
| 3387 | flags: []string{ |
| 3388 | "-false-start", |
| 3389 | "-select-next-proto", "foo", |
| 3390 | }, |
| 3391 | shimWritesFirst: true, |
| 3392 | }) |
| 3393 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 3394 | tests = append(tests, testCase{ |
| 3395 | name: "FalseStart-CECPQ1", |
| 3396 | config: Config{ |
| 3397 | MaxVersion: VersionTLS12, |
| 3398 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 3399 | NextProtos: []string{"foo"}, |
| 3400 | Bugs: ProtocolBugs{ |
| 3401 | ExpectFalseStart: true, |
| 3402 | }, |
| 3403 | }, |
| 3404 | flags: []string{ |
| 3405 | "-false-start", |
| 3406 | "-cipher", "DEFAULT:kCECPQ1", |
| 3407 | "-select-next-proto", "foo", |
| 3408 | }, |
| 3409 | shimWritesFirst: true, |
| 3410 | resumeSession: true, |
| 3411 | }) |
| 3412 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3413 | // Server parses a V2ClientHello. |
| 3414 | tests = append(tests, testCase{ |
| 3415 | testType: serverTest, |
| 3416 | name: "SendV2ClientHello", |
| 3417 | config: Config{ |
| 3418 | // Choose a cipher suite that does not involve |
| 3419 | // elliptic curves, so no extensions are |
| 3420 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3421 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3422 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 3423 | Bugs: ProtocolBugs{ |
| 3424 | SendV2ClientHello: true, |
| 3425 | }, |
| 3426 | }, |
| 3427 | }) |
| 3428 | |
| 3429 | // Client sends a Channel ID. |
| 3430 | tests = append(tests, testCase{ |
| 3431 | name: "ChannelID-Client", |
| 3432 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3433 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3434 | RequestChannelID: true, |
| 3435 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3436 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3437 | resumeSession: true, |
| 3438 | expectChannelID: true, |
| 3439 | }) |
| 3440 | |
| 3441 | // Server accepts a Channel ID. |
| 3442 | tests = append(tests, testCase{ |
| 3443 | testType: serverTest, |
| 3444 | name: "ChannelID-Server", |
| 3445 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3446 | MaxVersion: VersionTLS12, |
| 3447 | ChannelID: channelIDKey, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3448 | }, |
| 3449 | flags: []string{ |
| 3450 | "-expect-channel-id", |
| 3451 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3452 | }, |
| 3453 | resumeSession: true, |
| 3454 | expectChannelID: true, |
| 3455 | }) |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3456 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3457 | // Channel ID and NPN at the same time, to ensure their relative |
| 3458 | // ordering is correct. |
| 3459 | tests = append(tests, testCase{ |
| 3460 | name: "ChannelID-NPN-Client", |
| 3461 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3462 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3463 | RequestChannelID: true, |
| 3464 | NextProtos: []string{"foo"}, |
| 3465 | }, |
| 3466 | flags: []string{ |
| 3467 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 3468 | "-select-next-proto", "foo", |
| 3469 | }, |
| 3470 | resumeSession: true, |
| 3471 | expectChannelID: true, |
| 3472 | expectedNextProto: "foo", |
| 3473 | expectedNextProtoType: npn, |
| 3474 | }) |
| 3475 | tests = append(tests, testCase{ |
| 3476 | testType: serverTest, |
| 3477 | name: "ChannelID-NPN-Server", |
| 3478 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3479 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3480 | ChannelID: channelIDKey, |
| 3481 | NextProtos: []string{"bar"}, |
| 3482 | }, |
| 3483 | flags: []string{ |
| 3484 | "-expect-channel-id", |
| 3485 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3486 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3487 | "-expect-next-proto", "bar", |
| 3488 | }, |
| 3489 | resumeSession: true, |
| 3490 | expectChannelID: true, |
| 3491 | expectedNextProto: "bar", |
| 3492 | expectedNextProtoType: npn, |
| 3493 | }) |
| 3494 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3495 | // Bidirectional shutdown with the runner initiating. |
| 3496 | tests = append(tests, testCase{ |
| 3497 | name: "Shutdown-Runner", |
| 3498 | config: Config{ |
| 3499 | Bugs: ProtocolBugs{ |
| 3500 | ExpectCloseNotify: true, |
| 3501 | }, |
| 3502 | }, |
| 3503 | flags: []string{"-check-close-notify"}, |
| 3504 | }) |
| 3505 | |
| 3506 | // Bidirectional shutdown with the shim initiating. The runner, |
| 3507 | // in the meantime, sends garbage before the close_notify which |
| 3508 | // the shim must ignore. |
| 3509 | tests = append(tests, testCase{ |
| 3510 | name: "Shutdown-Shim", |
| 3511 | config: Config{ |
| 3512 | Bugs: ProtocolBugs{ |
| 3513 | ExpectCloseNotify: true, |
| 3514 | }, |
| 3515 | }, |
| 3516 | shimShutsDown: true, |
| 3517 | sendEmptyRecords: 1, |
| 3518 | sendWarningAlerts: 1, |
| 3519 | flags: []string{"-check-close-notify"}, |
| 3520 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3521 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3522 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 3523 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3524 | tests = append(tests, testCase{ |
| 3525 | name: "SkipHelloVerifyRequest", |
| 3526 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3527 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3528 | Bugs: ProtocolBugs{ |
| 3529 | SkipHelloVerifyRequest: true, |
| 3530 | }, |
| 3531 | }, |
| 3532 | }) |
| 3533 | } |
| 3534 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3535 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3536 | test.protocol = config.protocol |
| 3537 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3538 | test.name += "-DTLS" |
| 3539 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3540 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3541 | test.name += "-Async" |
| 3542 | test.flags = append(test.flags, "-async") |
| 3543 | } else { |
| 3544 | test.name += "-Sync" |
| 3545 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3546 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3547 | test.name += "-SplitHandshakeRecords" |
| 3548 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3549 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3550 | test.config.Bugs.MaxPacketLength = 256 |
| 3551 | test.flags = append(test.flags, "-mtu", "256") |
| 3552 | } |
| 3553 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3554 | if config.packHandshakeFlight { |
| 3555 | test.name += "-PackHandshakeFlight" |
| 3556 | test.config.Bugs.PackHandshakeFlight = true |
| 3557 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3558 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 3559 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3560 | } |
| 3561 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3562 | func addDDoSCallbackTests() { |
| 3563 | // DDoS callback. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3564 | // TODO(davidben): Implement DDoS resumption tests for TLS 1.3. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3565 | for _, resume := range []bool{false, true} { |
| 3566 | suffix := "Resume" |
| 3567 | if resume { |
| 3568 | suffix = "No" + suffix |
| 3569 | } |
| 3570 | |
| 3571 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3572 | testType: serverTest, |
| 3573 | name: "Server-DDoS-OK-" + suffix, |
| 3574 | config: Config{ |
| 3575 | MaxVersion: VersionTLS12, |
| 3576 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3577 | flags: []string{"-install-ddos-callback"}, |
| 3578 | resumeSession: resume, |
| 3579 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3580 | if !resume { |
| 3581 | testCases = append(testCases, testCase{ |
| 3582 | testType: serverTest, |
| 3583 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 3584 | config: Config{ |
| 3585 | MaxVersion: VersionTLS13, |
| 3586 | }, |
| 3587 | flags: []string{"-install-ddos-callback"}, |
| 3588 | resumeSession: resume, |
| 3589 | }) |
| 3590 | } |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3591 | |
| 3592 | failFlag := "-fail-ddos-callback" |
| 3593 | if resume { |
| 3594 | failFlag = "-fail-second-ddos-callback" |
| 3595 | } |
| 3596 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3597 | testType: serverTest, |
| 3598 | name: "Server-DDoS-Reject-" + suffix, |
| 3599 | config: Config{ |
| 3600 | MaxVersion: VersionTLS12, |
| 3601 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3602 | flags: []string{"-install-ddos-callback", failFlag}, |
| 3603 | resumeSession: resume, |
| 3604 | shouldFail: true, |
| 3605 | expectedError: ":CONNECTION_REJECTED:", |
| 3606 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 3607 | if !resume { |
| 3608 | testCases = append(testCases, testCase{ |
| 3609 | testType: serverTest, |
| 3610 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 3611 | config: Config{ |
| 3612 | MaxVersion: VersionTLS13, |
| 3613 | }, |
| 3614 | flags: []string{"-install-ddos-callback", failFlag}, |
| 3615 | resumeSession: resume, |
| 3616 | shouldFail: true, |
| 3617 | expectedError: ":CONNECTION_REJECTED:", |
| 3618 | }) |
| 3619 | } |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3620 | } |
| 3621 | } |
| 3622 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3623 | func addVersionNegotiationTests() { |
| 3624 | for i, shimVers := range tlsVersions { |
| 3625 | // Assemble flags to disable all newer versions on the shim. |
| 3626 | var flags []string |
| 3627 | for _, vers := range tlsVersions[i+1:] { |
| 3628 | flags = append(flags, vers.flag) |
| 3629 | } |
| 3630 | |
| 3631 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3632 | protocols := []protocol{tls} |
| 3633 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 3634 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3635 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3636 | for _, protocol := range protocols { |
| 3637 | expectedVersion := shimVers.version |
| 3638 | if runnerVers.version < shimVers.version { |
| 3639 | expectedVersion = runnerVers.version |
| 3640 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3641 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3642 | suffix := shimVers.name + "-" + runnerVers.name |
| 3643 | if protocol == dtls { |
| 3644 | suffix += "-DTLS" |
| 3645 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3646 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3647 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 3648 | |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3649 | clientVers := shimVers.version |
| 3650 | if clientVers > VersionTLS10 { |
| 3651 | clientVers = VersionTLS10 |
| 3652 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3653 | serverVers := expectedVersion |
| 3654 | if expectedVersion >= VersionTLS13 { |
| 3655 | serverVers = VersionTLS10 |
| 3656 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3657 | testCases = append(testCases, testCase{ |
| 3658 | protocol: protocol, |
| 3659 | testType: clientTest, |
| 3660 | name: "VersionNegotiation-Client-" + suffix, |
| 3661 | config: Config{ |
| 3662 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3663 | Bugs: ProtocolBugs{ |
| 3664 | ExpectInitialRecordVersion: clientVers, |
| 3665 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3666 | }, |
| 3667 | flags: flags, |
| 3668 | expectedVersion: expectedVersion, |
| 3669 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3670 | testCases = append(testCases, testCase{ |
| 3671 | protocol: protocol, |
| 3672 | testType: clientTest, |
| 3673 | name: "VersionNegotiation-Client2-" + suffix, |
| 3674 | config: Config{ |
| 3675 | MaxVersion: runnerVers.version, |
| 3676 | Bugs: ProtocolBugs{ |
| 3677 | ExpectInitialRecordVersion: clientVers, |
| 3678 | }, |
| 3679 | }, |
| 3680 | flags: []string{"-max-version", shimVersFlag}, |
| 3681 | expectedVersion: expectedVersion, |
| 3682 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3683 | |
| 3684 | testCases = append(testCases, testCase{ |
| 3685 | protocol: protocol, |
| 3686 | testType: serverTest, |
| 3687 | name: "VersionNegotiation-Server-" + suffix, |
| 3688 | config: Config{ |
| 3689 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3690 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3691 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3692 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3693 | }, |
| 3694 | flags: flags, |
| 3695 | expectedVersion: expectedVersion, |
| 3696 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3697 | testCases = append(testCases, testCase{ |
| 3698 | protocol: protocol, |
| 3699 | testType: serverTest, |
| 3700 | name: "VersionNegotiation-Server2-" + suffix, |
| 3701 | config: Config{ |
| 3702 | MaxVersion: runnerVers.version, |
| 3703 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3704 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3705 | }, |
| 3706 | }, |
| 3707 | flags: []string{"-max-version", shimVersFlag}, |
| 3708 | expectedVersion: expectedVersion, |
| 3709 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3710 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3711 | } |
| 3712 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 3713 | |
| 3714 | // Test for version tolerance. |
| 3715 | testCases = append(testCases, testCase{ |
| 3716 | testType: serverTest, |
| 3717 | name: "MinorVersionTolerance", |
| 3718 | config: Config{ |
| 3719 | Bugs: ProtocolBugs{ |
| 3720 | SendClientVersion: 0x03ff, |
| 3721 | }, |
| 3722 | }, |
| 3723 | expectedVersion: VersionTLS13, |
| 3724 | }) |
| 3725 | testCases = append(testCases, testCase{ |
| 3726 | testType: serverTest, |
| 3727 | name: "MajorVersionTolerance", |
| 3728 | config: Config{ |
| 3729 | Bugs: ProtocolBugs{ |
| 3730 | SendClientVersion: 0x0400, |
| 3731 | }, |
| 3732 | }, |
| 3733 | expectedVersion: VersionTLS13, |
| 3734 | }) |
| 3735 | testCases = append(testCases, testCase{ |
| 3736 | protocol: dtls, |
| 3737 | testType: serverTest, |
| 3738 | name: "MinorVersionTolerance-DTLS", |
| 3739 | config: Config{ |
| 3740 | Bugs: ProtocolBugs{ |
| 3741 | SendClientVersion: 0x03ff, |
| 3742 | }, |
| 3743 | }, |
| 3744 | expectedVersion: VersionTLS12, |
| 3745 | }) |
| 3746 | testCases = append(testCases, testCase{ |
| 3747 | protocol: dtls, |
| 3748 | testType: serverTest, |
| 3749 | name: "MajorVersionTolerance-DTLS", |
| 3750 | config: Config{ |
| 3751 | Bugs: ProtocolBugs{ |
| 3752 | SendClientVersion: 0x0400, |
| 3753 | }, |
| 3754 | }, |
| 3755 | expectedVersion: VersionTLS12, |
| 3756 | }) |
| 3757 | |
| 3758 | // Test that versions below 3.0 are rejected. |
| 3759 | testCases = append(testCases, testCase{ |
| 3760 | testType: serverTest, |
| 3761 | name: "VersionTooLow", |
| 3762 | config: Config{ |
| 3763 | Bugs: ProtocolBugs{ |
| 3764 | SendClientVersion: 0x0200, |
| 3765 | }, |
| 3766 | }, |
| 3767 | shouldFail: true, |
| 3768 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 3769 | }) |
| 3770 | testCases = append(testCases, testCase{ |
| 3771 | protocol: dtls, |
| 3772 | testType: serverTest, |
| 3773 | name: "VersionTooLow-DTLS", |
| 3774 | config: Config{ |
| 3775 | Bugs: ProtocolBugs{ |
| 3776 | // 0x0201 is the lowest version expressable in |
| 3777 | // DTLS. |
| 3778 | SendClientVersion: 0x0201, |
| 3779 | }, |
| 3780 | }, |
| 3781 | shouldFail: true, |
| 3782 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 3783 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 3784 | |
| 3785 | // Test TLS 1.3's downgrade signal. |
| 3786 | testCases = append(testCases, testCase{ |
| 3787 | name: "Downgrade-TLS12-Client", |
| 3788 | config: Config{ |
| 3789 | Bugs: ProtocolBugs{ |
| 3790 | NegotiateVersion: VersionTLS12, |
| 3791 | }, |
| 3792 | }, |
| 3793 | shouldFail: true, |
| 3794 | expectedError: ":DOWNGRADE_DETECTED:", |
| 3795 | }) |
| 3796 | testCases = append(testCases, testCase{ |
| 3797 | testType: serverTest, |
| 3798 | name: "Downgrade-TLS12-Server", |
| 3799 | config: Config{ |
| 3800 | Bugs: ProtocolBugs{ |
| 3801 | SendClientVersion: VersionTLS12, |
| 3802 | }, |
| 3803 | }, |
| 3804 | shouldFail: true, |
| 3805 | expectedLocalError: "tls: downgrade from TLS 1.3 detected", |
| 3806 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3807 | } |
| 3808 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3809 | func addMinimumVersionTests() { |
| 3810 | for i, shimVers := range tlsVersions { |
| 3811 | // Assemble flags to disable all older versions on the shim. |
| 3812 | var flags []string |
| 3813 | for _, vers := range tlsVersions[:i] { |
| 3814 | flags = append(flags, vers.flag) |
| 3815 | } |
| 3816 | |
| 3817 | for _, runnerVers := range tlsVersions { |
| 3818 | protocols := []protocol{tls} |
| 3819 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 3820 | protocols = append(protocols, dtls) |
| 3821 | } |
| 3822 | for _, protocol := range protocols { |
| 3823 | suffix := shimVers.name + "-" + runnerVers.name |
| 3824 | if protocol == dtls { |
| 3825 | suffix += "-DTLS" |
| 3826 | } |
| 3827 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 3828 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3829 | var expectedVersion uint16 |
| 3830 | var shouldFail bool |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3831 | var expectedClientError, expectedServerError string |
| 3832 | var expectedClientLocalError, expectedServerLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3833 | if runnerVers.version >= shimVers.version { |
| 3834 | expectedVersion = runnerVers.version |
| 3835 | } else { |
| 3836 | shouldFail = true |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3837 | expectedServerError = ":UNSUPPORTED_PROTOCOL:" |
| 3838 | expectedServerLocalError = "remote error: protocol version not supported" |
| 3839 | if shimVers.version >= VersionTLS13 && runnerVers.version <= VersionTLS11 { |
| 3840 | // If the client's minimum version is TLS 1.3 and the runner's |
| 3841 | // maximum is below TLS 1.2, the runner will fail to select a |
| 3842 | // cipher before the shim rejects the selected version. |
| 3843 | expectedClientError = ":SSLV3_ALERT_HANDSHAKE_FAILURE:" |
| 3844 | expectedClientLocalError = "tls: no cipher suite supported by both client and server" |
| 3845 | } else { |
| 3846 | expectedClientError = expectedServerError |
| 3847 | expectedClientLocalError = expectedServerLocalError |
| 3848 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3849 | } |
| 3850 | |
| 3851 | testCases = append(testCases, testCase{ |
| 3852 | protocol: protocol, |
| 3853 | testType: clientTest, |
| 3854 | name: "MinimumVersion-Client-" + suffix, |
| 3855 | config: Config{ |
| 3856 | MaxVersion: runnerVers.version, |
| 3857 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 3858 | flags: flags, |
| 3859 | expectedVersion: expectedVersion, |
| 3860 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3861 | expectedError: expectedClientError, |
| 3862 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3863 | }) |
| 3864 | testCases = append(testCases, testCase{ |
| 3865 | protocol: protocol, |
| 3866 | testType: clientTest, |
| 3867 | name: "MinimumVersion-Client2-" + suffix, |
| 3868 | config: Config{ |
| 3869 | MaxVersion: runnerVers.version, |
| 3870 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 3871 | flags: []string{"-min-version", shimVersFlag}, |
| 3872 | expectedVersion: expectedVersion, |
| 3873 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3874 | expectedError: expectedClientError, |
| 3875 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3876 | }) |
| 3877 | |
| 3878 | testCases = append(testCases, testCase{ |
| 3879 | protocol: protocol, |
| 3880 | testType: serverTest, |
| 3881 | name: "MinimumVersion-Server-" + suffix, |
| 3882 | config: Config{ |
| 3883 | MaxVersion: runnerVers.version, |
| 3884 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 3885 | flags: flags, |
| 3886 | expectedVersion: expectedVersion, |
| 3887 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3888 | expectedError: expectedServerError, |
| 3889 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3890 | }) |
| 3891 | testCases = append(testCases, testCase{ |
| 3892 | protocol: protocol, |
| 3893 | testType: serverTest, |
| 3894 | name: "MinimumVersion-Server2-" + suffix, |
| 3895 | config: Config{ |
| 3896 | MaxVersion: runnerVers.version, |
| 3897 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 3898 | flags: []string{"-min-version", shimVersFlag}, |
| 3899 | expectedVersion: expectedVersion, |
| 3900 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3901 | expectedError: expectedServerError, |
| 3902 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3903 | }) |
| 3904 | } |
| 3905 | } |
| 3906 | } |
| 3907 | } |
| 3908 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 3909 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3910 | // TODO(davidben): Extensions, where applicable, all move their server |
| 3911 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 3912 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 3913 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3914 | // Repeat extensions tests all versions except SSL 3.0. |
| 3915 | for _, ver := range tlsVersions { |
| 3916 | if ver.version == VersionSSL30 { |
| 3917 | continue |
| 3918 | } |
| 3919 | |
| 3920 | // TODO(davidben): Implement resumption in TLS 1.3. |
| 3921 | resumeSession := ver.version < VersionTLS13 |
| 3922 | |
| 3923 | // Test that duplicate extensions are rejected. |
| 3924 | testCases = append(testCases, testCase{ |
| 3925 | testType: clientTest, |
| 3926 | name: "DuplicateExtensionClient-" + ver.name, |
| 3927 | config: Config{ |
| 3928 | MaxVersion: ver.version, |
| 3929 | Bugs: ProtocolBugs{ |
| 3930 | DuplicateExtension: true, |
| 3931 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 3932 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3933 | shouldFail: true, |
| 3934 | expectedLocalError: "remote error: error decoding message", |
| 3935 | }) |
| 3936 | testCases = append(testCases, testCase{ |
| 3937 | testType: serverTest, |
| 3938 | name: "DuplicateExtensionServer-" + ver.name, |
| 3939 | config: Config{ |
| 3940 | MaxVersion: ver.version, |
| 3941 | Bugs: ProtocolBugs{ |
| 3942 | DuplicateExtension: true, |
| 3943 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 3944 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3945 | shouldFail: true, |
| 3946 | expectedLocalError: "remote error: error decoding message", |
| 3947 | }) |
| 3948 | |
| 3949 | // Test SNI. |
| 3950 | testCases = append(testCases, testCase{ |
| 3951 | testType: clientTest, |
| 3952 | name: "ServerNameExtensionClient-" + ver.name, |
| 3953 | config: Config{ |
| 3954 | MaxVersion: ver.version, |
| 3955 | Bugs: ProtocolBugs{ |
| 3956 | ExpectServerName: "example.com", |
| 3957 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 3958 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3959 | flags: []string{"-host-name", "example.com"}, |
| 3960 | }) |
| 3961 | testCases = append(testCases, testCase{ |
| 3962 | testType: clientTest, |
| 3963 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 3964 | config: Config{ |
| 3965 | MaxVersion: ver.version, |
| 3966 | Bugs: ProtocolBugs{ |
| 3967 | ExpectServerName: "mismatch.com", |
| 3968 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 3969 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3970 | flags: []string{"-host-name", "example.com"}, |
| 3971 | shouldFail: true, |
| 3972 | expectedLocalError: "tls: unexpected server name", |
| 3973 | }) |
| 3974 | testCases = append(testCases, testCase{ |
| 3975 | testType: clientTest, |
| 3976 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 3977 | config: Config{ |
| 3978 | MaxVersion: ver.version, |
| 3979 | Bugs: ProtocolBugs{ |
| 3980 | ExpectServerName: "missing.com", |
| 3981 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 3982 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3983 | shouldFail: true, |
| 3984 | expectedLocalError: "tls: unexpected server name", |
| 3985 | }) |
| 3986 | testCases = append(testCases, testCase{ |
| 3987 | testType: serverTest, |
| 3988 | name: "ServerNameExtensionServer-" + ver.name, |
| 3989 | config: Config{ |
| 3990 | MaxVersion: ver.version, |
| 3991 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 3992 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 3993 | flags: []string{"-expect-server-name", "example.com"}, |
| 3994 | resumeSession: resumeSession, |
| 3995 | }) |
| 3996 | |
| 3997 | // Test ALPN. |
| 3998 | testCases = append(testCases, testCase{ |
| 3999 | testType: clientTest, |
| 4000 | name: "ALPNClient-" + ver.name, |
| 4001 | config: Config{ |
| 4002 | MaxVersion: ver.version, |
| 4003 | NextProtos: []string{"foo"}, |
| 4004 | }, |
| 4005 | flags: []string{ |
| 4006 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4007 | "-expect-alpn", "foo", |
| 4008 | }, |
| 4009 | expectedNextProto: "foo", |
| 4010 | expectedNextProtoType: alpn, |
| 4011 | resumeSession: resumeSession, |
| 4012 | }) |
| 4013 | testCases = append(testCases, testCase{ |
| 4014 | testType: serverTest, |
| 4015 | name: "ALPNServer-" + ver.name, |
| 4016 | config: Config{ |
| 4017 | MaxVersion: ver.version, |
| 4018 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4019 | }, |
| 4020 | flags: []string{ |
| 4021 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4022 | "-select-alpn", "foo", |
| 4023 | }, |
| 4024 | expectedNextProto: "foo", |
| 4025 | expectedNextProtoType: alpn, |
| 4026 | resumeSession: resumeSession, |
| 4027 | }) |
| 4028 | testCases = append(testCases, testCase{ |
| 4029 | testType: serverTest, |
| 4030 | name: "ALPNServer-Decline-" + ver.name, |
| 4031 | config: Config{ |
| 4032 | MaxVersion: ver.version, |
| 4033 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4034 | }, |
| 4035 | flags: []string{"-decline-alpn"}, |
| 4036 | expectNoNextProto: true, |
| 4037 | resumeSession: resumeSession, |
| 4038 | }) |
| 4039 | |
| 4040 | var emptyString string |
| 4041 | testCases = append(testCases, testCase{ |
| 4042 | testType: clientTest, |
| 4043 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4044 | config: Config{ |
| 4045 | MaxVersion: ver.version, |
| 4046 | NextProtos: []string{""}, |
| 4047 | Bugs: ProtocolBugs{ |
| 4048 | // A server returning an empty ALPN protocol |
| 4049 | // should be rejected. |
| 4050 | ALPNProtocol: &emptyString, |
| 4051 | }, |
| 4052 | }, |
| 4053 | flags: []string{ |
| 4054 | "-advertise-alpn", "\x03foo", |
| 4055 | }, |
| 4056 | shouldFail: true, |
| 4057 | expectedError: ":PARSE_TLSEXT:", |
| 4058 | }) |
| 4059 | testCases = append(testCases, testCase{ |
| 4060 | testType: serverTest, |
| 4061 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4062 | config: Config{ |
| 4063 | MaxVersion: ver.version, |
| 4064 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4065 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4066 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4067 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4068 | flags: []string{ |
| 4069 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4070 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4071 | shouldFail: true, |
| 4072 | expectedError: ":PARSE_TLSEXT:", |
| 4073 | }) |
| 4074 | |
| 4075 | // Test NPN and the interaction with ALPN. |
| 4076 | if ver.version < VersionTLS13 { |
| 4077 | // Test that the server prefers ALPN over NPN. |
| 4078 | testCases = append(testCases, testCase{ |
| 4079 | testType: serverTest, |
| 4080 | name: "ALPNServer-Preferred-" + ver.name, |
| 4081 | config: Config{ |
| 4082 | MaxVersion: ver.version, |
| 4083 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4084 | }, |
| 4085 | flags: []string{ |
| 4086 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4087 | "-select-alpn", "foo", |
| 4088 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4089 | }, |
| 4090 | expectedNextProto: "foo", |
| 4091 | expectedNextProtoType: alpn, |
| 4092 | resumeSession: resumeSession, |
| 4093 | }) |
| 4094 | testCases = append(testCases, testCase{ |
| 4095 | testType: serverTest, |
| 4096 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4097 | config: Config{ |
| 4098 | MaxVersion: ver.version, |
| 4099 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4100 | Bugs: ProtocolBugs{ |
| 4101 | SwapNPNAndALPN: true, |
| 4102 | }, |
| 4103 | }, |
| 4104 | flags: []string{ |
| 4105 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4106 | "-select-alpn", "foo", |
| 4107 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4108 | }, |
| 4109 | expectedNextProto: "foo", |
| 4110 | expectedNextProtoType: alpn, |
| 4111 | resumeSession: resumeSession, |
| 4112 | }) |
| 4113 | |
| 4114 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4115 | testCases = append(testCases, testCase{ |
| 4116 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4117 | config: Config{ |
| 4118 | MaxVersion: ver.version, |
| 4119 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4120 | Bugs: ProtocolBugs{ |
| 4121 | NegotiateALPNAndNPN: true, |
| 4122 | }, |
| 4123 | }, |
| 4124 | flags: []string{ |
| 4125 | "-advertise-alpn", "\x03foo", |
| 4126 | "-select-next-proto", "foo", |
| 4127 | }, |
| 4128 | shouldFail: true, |
| 4129 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4130 | }) |
| 4131 | testCases = append(testCases, testCase{ |
| 4132 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4133 | config: Config{ |
| 4134 | MaxVersion: ver.version, |
| 4135 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4136 | Bugs: ProtocolBugs{ |
| 4137 | NegotiateALPNAndNPN: true, |
| 4138 | SwapNPNAndALPN: true, |
| 4139 | }, |
| 4140 | }, |
| 4141 | flags: []string{ |
| 4142 | "-advertise-alpn", "\x03foo", |
| 4143 | "-select-next-proto", "foo", |
| 4144 | }, |
| 4145 | shouldFail: true, |
| 4146 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4147 | }) |
| 4148 | |
| 4149 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4150 | testCases = append(testCases, testCase{ |
| 4151 | name: "DisableNPN-" + ver.name, |
| 4152 | config: Config{ |
| 4153 | MaxVersion: ver.version, |
| 4154 | NextProtos: []string{"foo"}, |
| 4155 | }, |
| 4156 | flags: []string{ |
| 4157 | "-select-next-proto", "foo", |
| 4158 | "-disable-npn", |
| 4159 | }, |
| 4160 | expectNoNextProto: true, |
| 4161 | }) |
| 4162 | } |
| 4163 | |
| 4164 | // Test ticket behavior. |
| 4165 | // |
| 4166 | // TODO(davidben): Add TLS 1.3 versions of these. |
| 4167 | if ver.version < VersionTLS13 { |
| 4168 | // Resume with a corrupt ticket. |
| 4169 | testCases = append(testCases, testCase{ |
| 4170 | testType: serverTest, |
| 4171 | name: "CorruptTicket-" + ver.name, |
| 4172 | config: Config{ |
| 4173 | MaxVersion: ver.version, |
| 4174 | Bugs: ProtocolBugs{ |
| 4175 | CorruptTicket: true, |
| 4176 | }, |
| 4177 | }, |
| 4178 | resumeSession: true, |
| 4179 | expectResumeRejected: true, |
| 4180 | }) |
| 4181 | // Test the ticket callback, with and without renewal. |
| 4182 | testCases = append(testCases, testCase{ |
| 4183 | testType: serverTest, |
| 4184 | name: "TicketCallback-" + ver.name, |
| 4185 | config: Config{ |
| 4186 | MaxVersion: ver.version, |
| 4187 | }, |
| 4188 | resumeSession: true, |
| 4189 | flags: []string{"-use-ticket-callback"}, |
| 4190 | }) |
| 4191 | testCases = append(testCases, testCase{ |
| 4192 | testType: serverTest, |
| 4193 | name: "TicketCallback-Renew-" + ver.name, |
| 4194 | config: Config{ |
| 4195 | MaxVersion: ver.version, |
| 4196 | Bugs: ProtocolBugs{ |
| 4197 | ExpectNewTicket: true, |
| 4198 | }, |
| 4199 | }, |
| 4200 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 4201 | resumeSession: true, |
| 4202 | }) |
| 4203 | |
| 4204 | // Resume with an oversized session id. |
| 4205 | testCases = append(testCases, testCase{ |
| 4206 | testType: serverTest, |
| 4207 | name: "OversizedSessionId-" + ver.name, |
| 4208 | config: Config{ |
| 4209 | MaxVersion: ver.version, |
| 4210 | Bugs: ProtocolBugs{ |
| 4211 | OversizedSessionId: true, |
| 4212 | }, |
| 4213 | }, |
| 4214 | resumeSession: true, |
| 4215 | shouldFail: true, |
| 4216 | expectedError: ":DECODE_ERROR:", |
| 4217 | }) |
| 4218 | } |
| 4219 | |
| 4220 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 4221 | // are ignored. |
| 4222 | if ver.hasDTLS { |
| 4223 | testCases = append(testCases, testCase{ |
| 4224 | protocol: dtls, |
| 4225 | name: "SRTP-Client-" + ver.name, |
| 4226 | config: Config{ |
| 4227 | MaxVersion: ver.version, |
| 4228 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4229 | }, |
| 4230 | flags: []string{ |
| 4231 | "-srtp-profiles", |
| 4232 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4233 | }, |
| 4234 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4235 | }) |
| 4236 | testCases = append(testCases, testCase{ |
| 4237 | protocol: dtls, |
| 4238 | testType: serverTest, |
| 4239 | name: "SRTP-Server-" + ver.name, |
| 4240 | config: Config{ |
| 4241 | MaxVersion: ver.version, |
| 4242 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4243 | }, |
| 4244 | flags: []string{ |
| 4245 | "-srtp-profiles", |
| 4246 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4247 | }, |
| 4248 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4249 | }) |
| 4250 | // Test that the MKI is ignored. |
| 4251 | testCases = append(testCases, testCase{ |
| 4252 | protocol: dtls, |
| 4253 | testType: serverTest, |
| 4254 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 4255 | config: Config{ |
| 4256 | MaxVersion: ver.version, |
| 4257 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 4258 | Bugs: ProtocolBugs{ |
| 4259 | SRTPMasterKeyIdentifer: "bogus", |
| 4260 | }, |
| 4261 | }, |
| 4262 | flags: []string{ |
| 4263 | "-srtp-profiles", |
| 4264 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4265 | }, |
| 4266 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4267 | }) |
| 4268 | // Test that SRTP isn't negotiated on the server if there were |
| 4269 | // no matching profiles. |
| 4270 | testCases = append(testCases, testCase{ |
| 4271 | protocol: dtls, |
| 4272 | testType: serverTest, |
| 4273 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 4274 | config: Config{ |
| 4275 | MaxVersion: ver.version, |
| 4276 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 4277 | }, |
| 4278 | flags: []string{ |
| 4279 | "-srtp-profiles", |
| 4280 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4281 | }, |
| 4282 | expectedSRTPProtectionProfile: 0, |
| 4283 | }) |
| 4284 | // Test that the server returning an invalid SRTP profile is |
| 4285 | // flagged as an error by the client. |
| 4286 | testCases = append(testCases, testCase{ |
| 4287 | protocol: dtls, |
| 4288 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 4289 | config: Config{ |
| 4290 | MaxVersion: ver.version, |
| 4291 | Bugs: ProtocolBugs{ |
| 4292 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 4293 | }, |
| 4294 | }, |
| 4295 | flags: []string{ |
| 4296 | "-srtp-profiles", |
| 4297 | "SRTP_AES128_CM_SHA1_80", |
| 4298 | }, |
| 4299 | shouldFail: true, |
| 4300 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 4301 | }) |
| 4302 | } |
| 4303 | |
| 4304 | // Test SCT list. |
| 4305 | testCases = append(testCases, testCase{ |
| 4306 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 4307 | testType: clientTest, |
| 4308 | config: Config{ |
| 4309 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4310 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4311 | flags: []string{ |
| 4312 | "-enable-signed-cert-timestamps", |
| 4313 | "-expect-signed-cert-timestamps", |
| 4314 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4315 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4316 | resumeSession: resumeSession, |
| 4317 | }) |
| 4318 | testCases = append(testCases, testCase{ |
| 4319 | name: "SendSCTListOnResume-" + ver.name, |
| 4320 | config: Config{ |
| 4321 | MaxVersion: ver.version, |
| 4322 | Bugs: ProtocolBugs{ |
| 4323 | SendSCTListOnResume: []byte("bogus"), |
| 4324 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 4325 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4326 | flags: []string{ |
| 4327 | "-enable-signed-cert-timestamps", |
| 4328 | "-expect-signed-cert-timestamps", |
| 4329 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4330 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4331 | resumeSession: resumeSession, |
| 4332 | }) |
| 4333 | testCases = append(testCases, testCase{ |
| 4334 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 4335 | testType: serverTest, |
| 4336 | config: Config{ |
| 4337 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4338 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4339 | flags: []string{ |
| 4340 | "-signed-cert-timestamps", |
| 4341 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4342 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4343 | expectedSCTList: testSCTList, |
| 4344 | resumeSession: resumeSession, |
| 4345 | }) |
| 4346 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4347 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 4348 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 4349 | testType: clientTest, |
| 4350 | name: "ClientHelloPadding", |
| 4351 | config: Config{ |
| 4352 | Bugs: ProtocolBugs{ |
| 4353 | RequireClientHelloSize: 512, |
| 4354 | }, |
| 4355 | }, |
| 4356 | // This hostname just needs to be long enough to push the |
| 4357 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 4358 | // long. |
| 4359 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 4360 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 4361 | |
| 4362 | // Extensions should not function in SSL 3.0. |
| 4363 | testCases = append(testCases, testCase{ |
| 4364 | testType: serverTest, |
| 4365 | name: "SSLv3Extensions-NoALPN", |
| 4366 | config: Config{ |
| 4367 | MaxVersion: VersionSSL30, |
| 4368 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4369 | }, |
| 4370 | flags: []string{ |
| 4371 | "-select-alpn", "foo", |
| 4372 | }, |
| 4373 | expectNoNextProto: true, |
| 4374 | }) |
| 4375 | |
| 4376 | // Test session tickets separately as they follow a different codepath. |
| 4377 | testCases = append(testCases, testCase{ |
| 4378 | testType: serverTest, |
| 4379 | name: "SSLv3Extensions-NoTickets", |
| 4380 | config: Config{ |
| 4381 | MaxVersion: VersionSSL30, |
| 4382 | Bugs: ProtocolBugs{ |
| 4383 | // Historically, session tickets in SSL 3.0 |
| 4384 | // failed in different ways depending on whether |
| 4385 | // the client supported renegotiation_info. |
| 4386 | NoRenegotiationInfo: true, |
| 4387 | }, |
| 4388 | }, |
| 4389 | resumeSession: true, |
| 4390 | }) |
| 4391 | testCases = append(testCases, testCase{ |
| 4392 | testType: serverTest, |
| 4393 | name: "SSLv3Extensions-NoTickets2", |
| 4394 | config: Config{ |
| 4395 | MaxVersion: VersionSSL30, |
| 4396 | }, |
| 4397 | resumeSession: true, |
| 4398 | }) |
| 4399 | |
| 4400 | // But SSL 3.0 does send and process renegotiation_info. |
| 4401 | testCases = append(testCases, testCase{ |
| 4402 | testType: serverTest, |
| 4403 | name: "SSLv3Extensions-RenegotiationInfo", |
| 4404 | config: Config{ |
| 4405 | MaxVersion: VersionSSL30, |
| 4406 | Bugs: ProtocolBugs{ |
| 4407 | RequireRenegotiationInfo: true, |
| 4408 | }, |
| 4409 | }, |
| 4410 | }) |
| 4411 | testCases = append(testCases, testCase{ |
| 4412 | testType: serverTest, |
| 4413 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 4414 | config: Config{ |
| 4415 | MaxVersion: VersionSSL30, |
| 4416 | Bugs: ProtocolBugs{ |
| 4417 | NoRenegotiationInfo: true, |
| 4418 | SendRenegotiationSCSV: true, |
| 4419 | RequireRenegotiationInfo: true, |
| 4420 | }, |
| 4421 | }, |
| 4422 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 4423 | |
| 4424 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 4425 | // in ServerHello. |
| 4426 | testCases = append(testCases, testCase{ |
| 4427 | name: "NPN-Forbidden-TLS13", |
| 4428 | config: Config{ |
| 4429 | MaxVersion: VersionTLS13, |
| 4430 | NextProtos: []string{"foo"}, |
| 4431 | Bugs: ProtocolBugs{ |
| 4432 | NegotiateNPNAtAllVersions: true, |
| 4433 | }, |
| 4434 | }, |
| 4435 | flags: []string{"-select-next-proto", "foo"}, |
| 4436 | shouldFail: true, |
| 4437 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4438 | }) |
| 4439 | testCases = append(testCases, testCase{ |
| 4440 | name: "EMS-Forbidden-TLS13", |
| 4441 | config: Config{ |
| 4442 | MaxVersion: VersionTLS13, |
| 4443 | Bugs: ProtocolBugs{ |
| 4444 | NegotiateEMSAtAllVersions: true, |
| 4445 | }, |
| 4446 | }, |
| 4447 | shouldFail: true, |
| 4448 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4449 | }) |
| 4450 | testCases = append(testCases, testCase{ |
| 4451 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 4452 | config: Config{ |
| 4453 | MaxVersion: VersionTLS13, |
| 4454 | Bugs: ProtocolBugs{ |
| 4455 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 4456 | }, |
| 4457 | }, |
| 4458 | shouldFail: true, |
| 4459 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4460 | }) |
| 4461 | testCases = append(testCases, testCase{ |
| 4462 | name: "ChannelID-Forbidden-TLS13", |
| 4463 | config: Config{ |
| 4464 | MaxVersion: VersionTLS13, |
| 4465 | RequestChannelID: true, |
| 4466 | Bugs: ProtocolBugs{ |
| 4467 | NegotiateChannelIDAtAllVersions: true, |
| 4468 | }, |
| 4469 | }, |
| 4470 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4471 | shouldFail: true, |
| 4472 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4473 | }) |
| 4474 | testCases = append(testCases, testCase{ |
| 4475 | name: "Ticket-Forbidden-TLS13", |
| 4476 | config: Config{ |
| 4477 | MaxVersion: VersionTLS12, |
| 4478 | }, |
| 4479 | resumeConfig: &Config{ |
| 4480 | MaxVersion: VersionTLS13, |
| 4481 | Bugs: ProtocolBugs{ |
| 4482 | AdvertiseTicketExtension: true, |
| 4483 | }, |
| 4484 | }, |
| 4485 | resumeSession: true, |
| 4486 | shouldFail: true, |
| 4487 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4488 | }) |
| 4489 | |
| 4490 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 4491 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 4492 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 4493 | // implicit in every test.) |
| 4494 | testCases = append(testCases, testCase{ |
| 4495 | testType: serverTest, |
| 4496 | name: "ChannelID-Declined-TLS13", |
| 4497 | config: Config{ |
| 4498 | MaxVersion: VersionTLS13, |
| 4499 | ChannelID: channelIDKey, |
| 4500 | }, |
| 4501 | flags: []string{"-enable-channel-id"}, |
| 4502 | }) |
| 4503 | testCases = append(testCases, testCase{ |
| 4504 | testType: serverTest, |
| 4505 | name: "NPN-Server", |
| 4506 | config: Config{ |
| 4507 | MaxVersion: VersionTLS13, |
| 4508 | NextProtos: []string{"bar"}, |
| 4509 | }, |
| 4510 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 4511 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4512 | } |
| 4513 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4514 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4515 | for _, sessionVers := range tlsVersions { |
David Benjamin | 6e6abe1 | 2016-07-13 20:57:22 -0400 | [diff] [blame] | 4516 | // TODO(davidben,svaldez): Implement resumption in TLS 1.3. |
| 4517 | if sessionVers.version >= VersionTLS13 { |
| 4518 | continue |
| 4519 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4520 | for _, resumeVers := range tlsVersions { |
David Benjamin | 6e6abe1 | 2016-07-13 20:57:22 -0400 | [diff] [blame] | 4521 | if resumeVers.version >= VersionTLS13 { |
| 4522 | continue |
| 4523 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4524 | cipher := TLS_RSA_WITH_AES_128_CBC_SHA |
| 4525 | if sessionVers.version >= VersionTLS13 || resumeVers.version >= VersionTLS13 { |
| 4526 | // TLS 1.3 only shares ciphers with TLS 1.2, so |
| 4527 | // we skip certain combinations and use a |
| 4528 | // different cipher to test with. |
| 4529 | cipher = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 |
| 4530 | if sessionVers.version < VersionTLS12 || resumeVers.version < VersionTLS12 { |
| 4531 | continue |
| 4532 | } |
| 4533 | } |
| 4534 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4535 | protocols := []protocol{tls} |
| 4536 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 4537 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 4538 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4539 | for _, protocol := range protocols { |
| 4540 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 4541 | if protocol == dtls { |
| 4542 | suffix += "-DTLS" |
| 4543 | } |
| 4544 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4545 | if sessionVers.version == resumeVers.version { |
| 4546 | testCases = append(testCases, testCase{ |
| 4547 | protocol: protocol, |
| 4548 | name: "Resume-Client" + suffix, |
| 4549 | resumeSession: true, |
| 4550 | config: Config{ |
| 4551 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4552 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4553 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4554 | expectedVersion: sessionVers.version, |
| 4555 | expectedResumeVersion: resumeVers.version, |
| 4556 | }) |
| 4557 | } else { |
| 4558 | testCases = append(testCases, testCase{ |
| 4559 | protocol: protocol, |
| 4560 | name: "Resume-Client-Mismatch" + suffix, |
| 4561 | resumeSession: true, |
| 4562 | config: Config{ |
| 4563 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4564 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4565 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4566 | expectedVersion: sessionVers.version, |
| 4567 | resumeConfig: &Config{ |
| 4568 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4569 | CipherSuites: []uint16{cipher}, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4570 | Bugs: ProtocolBugs{ |
| 4571 | AllowSessionVersionMismatch: true, |
| 4572 | }, |
| 4573 | }, |
| 4574 | expectedResumeVersion: resumeVers.version, |
| 4575 | shouldFail: true, |
| 4576 | expectedError: ":OLD_SESSION_VERSION_NOT_RETURNED:", |
| 4577 | }) |
| 4578 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4579 | |
| 4580 | testCases = append(testCases, testCase{ |
| 4581 | protocol: protocol, |
| 4582 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4583 | resumeSession: true, |
| 4584 | config: Config{ |
| 4585 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4586 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4587 | }, |
| 4588 | expectedVersion: sessionVers.version, |
| 4589 | resumeConfig: &Config{ |
| 4590 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4591 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4592 | }, |
| 4593 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 4594 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4595 | expectedResumeVersion: resumeVers.version, |
| 4596 | }) |
| 4597 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4598 | testCases = append(testCases, testCase{ |
| 4599 | protocol: protocol, |
| 4600 | testType: serverTest, |
| 4601 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4602 | resumeSession: true, |
| 4603 | config: Config{ |
| 4604 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4605 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4606 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 4607 | expectedVersion: sessionVers.version, |
| 4608 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4609 | resumeConfig: &Config{ |
| 4610 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4611 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4612 | }, |
| 4613 | expectedResumeVersion: resumeVers.version, |
| 4614 | }) |
| 4615 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4616 | } |
| 4617 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4618 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4619 | // TODO(davidben): This test should have a TLS 1.3 variant later. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4620 | testCases = append(testCases, testCase{ |
| 4621 | name: "Resume-Client-CipherMismatch", |
| 4622 | resumeSession: true, |
| 4623 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4624 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4625 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4626 | }, |
| 4627 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4628 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4629 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4630 | Bugs: ProtocolBugs{ |
| 4631 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 4632 | }, |
| 4633 | }, |
| 4634 | shouldFail: true, |
| 4635 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 4636 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4637 | } |
| 4638 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 4639 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 4640 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 4641 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4642 | testType: serverTest, |
| 4643 | name: "Renegotiate-Server-Forbidden", |
| 4644 | config: Config{ |
| 4645 | MaxVersion: VersionTLS12, |
| 4646 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4647 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 4648 | shouldFail: true, |
| 4649 | expectedError: ":NO_RENEGOTIATION:", |
| 4650 | expectedLocalError: "remote error: no renegotiation", |
| 4651 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 4652 | // The server shouldn't echo the renegotiation extension unless |
| 4653 | // requested by the client. |
| 4654 | testCases = append(testCases, testCase{ |
| 4655 | testType: serverTest, |
| 4656 | name: "Renegotiate-Server-NoExt", |
| 4657 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4658 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 4659 | Bugs: ProtocolBugs{ |
| 4660 | NoRenegotiationInfo: true, |
| 4661 | RequireRenegotiationInfo: true, |
| 4662 | }, |
| 4663 | }, |
| 4664 | shouldFail: true, |
| 4665 | expectedLocalError: "renegotiation extension missing", |
| 4666 | }) |
| 4667 | // The renegotiation SCSV should be sufficient for the server to echo |
| 4668 | // the extension. |
| 4669 | testCases = append(testCases, testCase{ |
| 4670 | testType: serverTest, |
| 4671 | name: "Renegotiate-Server-NoExt-SCSV", |
| 4672 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4673 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 4674 | Bugs: ProtocolBugs{ |
| 4675 | NoRenegotiationInfo: true, |
| 4676 | SendRenegotiationSCSV: true, |
| 4677 | RequireRenegotiationInfo: true, |
| 4678 | }, |
| 4679 | }, |
| 4680 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4681 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 4682 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4683 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4684 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4685 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 4686 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4687 | }, |
| 4688 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4689 | renegotiate: 1, |
| 4690 | flags: []string{ |
| 4691 | "-renegotiate-freely", |
| 4692 | "-expect-total-renegotiations", "1", |
| 4693 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4694 | }) |
| 4695 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4696 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4697 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4698 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4699 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4700 | Bugs: ProtocolBugs{ |
| 4701 | EmptyRenegotiationInfo: true, |
| 4702 | }, |
| 4703 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4704 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4705 | shouldFail: true, |
| 4706 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4707 | }) |
| 4708 | testCases = append(testCases, testCase{ |
| 4709 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4710 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4711 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4712 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4713 | Bugs: ProtocolBugs{ |
| 4714 | BadRenegotiationInfo: true, |
| 4715 | }, |
| 4716 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4717 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4718 | shouldFail: true, |
| 4719 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4720 | }) |
| 4721 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 4722 | name: "Renegotiate-Client-Downgrade", |
| 4723 | renegotiate: 1, |
| 4724 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4725 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 4726 | Bugs: ProtocolBugs{ |
| 4727 | NoRenegotiationInfoAfterInitial: true, |
| 4728 | }, |
| 4729 | }, |
| 4730 | flags: []string{"-renegotiate-freely"}, |
| 4731 | shouldFail: true, |
| 4732 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4733 | }) |
| 4734 | testCases = append(testCases, testCase{ |
| 4735 | name: "Renegotiate-Client-Upgrade", |
| 4736 | renegotiate: 1, |
| 4737 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4738 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 4739 | Bugs: ProtocolBugs{ |
| 4740 | NoRenegotiationInfoInInitial: true, |
| 4741 | }, |
| 4742 | }, |
| 4743 | flags: []string{"-renegotiate-freely"}, |
| 4744 | shouldFail: true, |
| 4745 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4746 | }) |
| 4747 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4748 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4749 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4750 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4751 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4752 | Bugs: ProtocolBugs{ |
| 4753 | NoRenegotiationInfo: true, |
| 4754 | }, |
| 4755 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4756 | flags: []string{ |
| 4757 | "-renegotiate-freely", |
| 4758 | "-expect-total-renegotiations", "1", |
| 4759 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4760 | }) |
| 4761 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4762 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4763 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4764 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4765 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4766 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 4767 | }, |
| 4768 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4769 | flags: []string{ |
| 4770 | "-renegotiate-freely", |
| 4771 | "-expect-total-renegotiations", "1", |
| 4772 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4773 | }) |
| 4774 | testCases = append(testCases, testCase{ |
| 4775 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4776 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4777 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4778 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4779 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4780 | }, |
| 4781 | renegotiateCiphers: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4782 | flags: []string{ |
| 4783 | "-renegotiate-freely", |
| 4784 | "-expect-total-renegotiations", "1", |
| 4785 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 4786 | }) |
| 4787 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 4788 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4789 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 4790 | config: Config{ |
| 4791 | MaxVersion: VersionTLS10, |
| 4792 | Bugs: ProtocolBugs{ |
| 4793 | RequireSameRenegoClientVersion: true, |
| 4794 | }, |
| 4795 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4796 | flags: []string{ |
| 4797 | "-renegotiate-freely", |
| 4798 | "-expect-total-renegotiations", "1", |
| 4799 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 4800 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4801 | testCases = append(testCases, testCase{ |
| 4802 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4803 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4804 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4805 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4806 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4807 | NextProtos: []string{"foo"}, |
| 4808 | }, |
| 4809 | flags: []string{ |
| 4810 | "-false-start", |
| 4811 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4812 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 4813 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4814 | }, |
| 4815 | shimWritesFirst: true, |
| 4816 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4817 | |
| 4818 | // Client-side renegotiation controls. |
| 4819 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4820 | name: "Renegotiate-Client-Forbidden-1", |
| 4821 | config: Config{ |
| 4822 | MaxVersion: VersionTLS12, |
| 4823 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4824 | renegotiate: 1, |
| 4825 | shouldFail: true, |
| 4826 | expectedError: ":NO_RENEGOTIATION:", |
| 4827 | expectedLocalError: "remote error: no renegotiation", |
| 4828 | }) |
| 4829 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4830 | name: "Renegotiate-Client-Once-1", |
| 4831 | config: Config{ |
| 4832 | MaxVersion: VersionTLS12, |
| 4833 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4834 | renegotiate: 1, |
| 4835 | flags: []string{ |
| 4836 | "-renegotiate-once", |
| 4837 | "-expect-total-renegotiations", "1", |
| 4838 | }, |
| 4839 | }) |
| 4840 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4841 | name: "Renegotiate-Client-Freely-1", |
| 4842 | config: Config{ |
| 4843 | MaxVersion: VersionTLS12, |
| 4844 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4845 | renegotiate: 1, |
| 4846 | flags: []string{ |
| 4847 | "-renegotiate-freely", |
| 4848 | "-expect-total-renegotiations", "1", |
| 4849 | }, |
| 4850 | }) |
| 4851 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4852 | name: "Renegotiate-Client-Once-2", |
| 4853 | config: Config{ |
| 4854 | MaxVersion: VersionTLS12, |
| 4855 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4856 | renegotiate: 2, |
| 4857 | flags: []string{"-renegotiate-once"}, |
| 4858 | shouldFail: true, |
| 4859 | expectedError: ":NO_RENEGOTIATION:", |
| 4860 | expectedLocalError: "remote error: no renegotiation", |
| 4861 | }) |
| 4862 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4863 | name: "Renegotiate-Client-Freely-2", |
| 4864 | config: Config{ |
| 4865 | MaxVersion: VersionTLS12, |
| 4866 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4867 | renegotiate: 2, |
| 4868 | flags: []string{ |
| 4869 | "-renegotiate-freely", |
| 4870 | "-expect-total-renegotiations", "2", |
| 4871 | }, |
| 4872 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 4873 | testCases = append(testCases, testCase{ |
| 4874 | name: "Renegotiate-Client-NoIgnore", |
| 4875 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4876 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 4877 | Bugs: ProtocolBugs{ |
| 4878 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 4879 | }, |
| 4880 | }, |
| 4881 | shouldFail: true, |
| 4882 | expectedError: ":NO_RENEGOTIATION:", |
| 4883 | }) |
| 4884 | testCases = append(testCases, testCase{ |
| 4885 | name: "Renegotiate-Client-Ignore", |
| 4886 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4887 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 4888 | Bugs: ProtocolBugs{ |
| 4889 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 4890 | }, |
| 4891 | }, |
| 4892 | flags: []string{ |
| 4893 | "-renegotiate-ignore", |
| 4894 | "-expect-total-renegotiations", "0", |
| 4895 | }, |
| 4896 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4897 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 4898 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 4899 | testCases = append(testCases, testCase{ |
| 4900 | name: "StrayHelloRequest", |
| 4901 | config: Config{ |
| 4902 | MaxVersion: VersionTLS12, |
| 4903 | Bugs: ProtocolBugs{ |
| 4904 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 4905 | }, |
| 4906 | }, |
| 4907 | }) |
| 4908 | testCases = append(testCases, testCase{ |
| 4909 | name: "StrayHelloRequest-Packed", |
| 4910 | config: Config{ |
| 4911 | MaxVersion: VersionTLS12, |
| 4912 | Bugs: ProtocolBugs{ |
| 4913 | PackHandshakeFlight: true, |
| 4914 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 4915 | }, |
| 4916 | }, |
| 4917 | }) |
| 4918 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 4919 | // Renegotiation is forbidden in TLS 1.3. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 4920 | // |
| 4921 | // TODO(davidben): This test current asserts that we ignore |
| 4922 | // HelloRequests, but we actually should hard reject them. Fix this |
| 4923 | // test once we actually parse post-handshake messages. |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 4924 | testCases = append(testCases, testCase{ |
| 4925 | name: "Renegotiate-Client-TLS13", |
| 4926 | config: Config{ |
| 4927 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 4928 | Bugs: ProtocolBugs{ |
| 4929 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 4930 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 4931 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 4932 | flags: []string{ |
| 4933 | "-renegotiate-freely", |
| 4934 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 4935 | }) |
| 4936 | |
| 4937 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 4938 | testCases = append(testCases, testCase{ |
| 4939 | name: "StrayHelloRequest-TLS13", |
| 4940 | config: Config{ |
| 4941 | MaxVersion: VersionTLS13, |
| 4942 | Bugs: ProtocolBugs{ |
| 4943 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 4944 | }, |
| 4945 | }, |
| 4946 | shouldFail: true, |
| 4947 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 4948 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 4949 | } |
| 4950 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 4951 | func addDTLSReplayTests() { |
| 4952 | // Test that sequence number replays are detected. |
| 4953 | testCases = append(testCases, testCase{ |
| 4954 | protocol: dtls, |
| 4955 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 4956 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 4957 | replayWrites: true, |
| 4958 | }) |
| 4959 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 4960 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 4961 | // than the retransmit window. |
| 4962 | testCases = append(testCases, testCase{ |
| 4963 | protocol: dtls, |
| 4964 | name: "DTLS-Replay-LargeGaps", |
| 4965 | config: Config{ |
| 4966 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 4967 | SequenceNumberMapping: func(in uint64) uint64 { |
| 4968 | return in * 127 |
| 4969 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 4970 | }, |
| 4971 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 4972 | messageCount: 200, |
| 4973 | replayWrites: true, |
| 4974 | }) |
| 4975 | |
| 4976 | // Test the incoming sequence number changing non-monotonically. |
| 4977 | testCases = append(testCases, testCase{ |
| 4978 | protocol: dtls, |
| 4979 | name: "DTLS-Replay-NonMonotonic", |
| 4980 | config: Config{ |
| 4981 | Bugs: ProtocolBugs{ |
| 4982 | SequenceNumberMapping: func(in uint64) uint64 { |
| 4983 | return in ^ 31 |
| 4984 | }, |
| 4985 | }, |
| 4986 | }, |
| 4987 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 4988 | replayWrites: true, |
| 4989 | }) |
| 4990 | } |
| 4991 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 4992 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 4993 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 4994 | id signatureAlgorithm |
| 4995 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 4996 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 4997 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 4998 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 4999 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 5000 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5001 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5002 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 5003 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 5004 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5005 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 5006 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 5007 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5008 | // Tests for key types prior to TLS 1.2. |
| 5009 | {"RSA", 0, testCertRSA}, |
| 5010 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5011 | } |
| 5012 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5013 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 5014 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 5015 | |
| 5016 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5017 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 5018 | // versions a signing cipher. |
| 5019 | signingCiphers := []uint16{ |
| 5020 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 5021 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 5022 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 5023 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 5024 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 5025 | } |
| 5026 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5027 | var allAlgorithms []signatureAlgorithm |
| 5028 | for _, alg := range testSignatureAlgorithms { |
| 5029 | if alg.id != 0 { |
| 5030 | allAlgorithms = append(allAlgorithms, alg.id) |
| 5031 | } |
| 5032 | } |
| 5033 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5034 | // Make sure each signature algorithm works. Include some fake values in |
| 5035 | // the list and ensure they're ignored. |
| 5036 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5037 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5038 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 5039 | continue |
| 5040 | } |
| 5041 | |
| 5042 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 5043 | // or remove it in C. |
| 5044 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5045 | continue |
| 5046 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5047 | |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5048 | var shouldFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5049 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5050 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
| 5051 | shouldFail = true |
| 5052 | } |
| 5053 | // RSA-PSS does not exist in TLS 1.2. |
| 5054 | if ver.version == VersionTLS12 && hasComponent(alg.name, "PSS") { |
| 5055 | shouldFail = true |
| 5056 | } |
| 5057 | |
| 5058 | var signError, verifyError string |
| 5059 | if shouldFail { |
| 5060 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
| 5061 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5062 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5063 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5064 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 5065 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5066 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5067 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5068 | config: Config{ |
| 5069 | MaxVersion: ver.version, |
| 5070 | ClientAuth: RequireAnyClientCert, |
| 5071 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5072 | fakeSigAlg1, |
| 5073 | alg.id, |
| 5074 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5075 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5076 | }, |
| 5077 | flags: []string{ |
| 5078 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5079 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5080 | "-enable-all-curves", |
| 5081 | }, |
| 5082 | shouldFail: shouldFail, |
| 5083 | expectedError: signError, |
| 5084 | expectedPeerSignatureAlgorithm: alg.id, |
| 5085 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5086 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5087 | testCases = append(testCases, testCase{ |
| 5088 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5089 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5090 | config: Config{ |
| 5091 | MaxVersion: ver.version, |
| 5092 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5093 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5094 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5095 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5096 | Bugs: ProtocolBugs{ |
| 5097 | SkipECDSACurveCheck: shouldFail, |
| 5098 | IgnoreSignatureVersionChecks: shouldFail, |
| 5099 | // The client won't advertise 1.3-only algorithms after |
| 5100 | // version negotiation. |
| 5101 | IgnorePeerSignatureAlgorithmPreferences: shouldFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5102 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5103 | }, |
| 5104 | flags: []string{ |
| 5105 | "-require-any-client-certificate", |
| 5106 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5107 | "-enable-all-curves", |
| 5108 | }, |
| 5109 | shouldFail: shouldFail, |
| 5110 | expectedError: verifyError, |
| 5111 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5112 | |
| 5113 | testCases = append(testCases, testCase{ |
| 5114 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5115 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5116 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5117 | MaxVersion: ver.version, |
| 5118 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5119 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5120 | fakeSigAlg1, |
| 5121 | alg.id, |
| 5122 | fakeSigAlg2, |
| 5123 | }, |
| 5124 | }, |
| 5125 | flags: []string{ |
| 5126 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5127 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5128 | "-enable-all-curves", |
| 5129 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5130 | shouldFail: shouldFail, |
| 5131 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5132 | expectedPeerSignatureAlgorithm: alg.id, |
| 5133 | }) |
| 5134 | |
| 5135 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5136 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5137 | config: Config{ |
| 5138 | MaxVersion: ver.version, |
| 5139 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5140 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5141 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5142 | alg.id, |
| 5143 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5144 | Bugs: ProtocolBugs{ |
| 5145 | SkipECDSACurveCheck: shouldFail, |
| 5146 | IgnoreSignatureVersionChecks: shouldFail, |
| 5147 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5148 | }, |
| 5149 | flags: []string{ |
| 5150 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5151 | "-enable-all-curves", |
| 5152 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5153 | shouldFail: shouldFail, |
| 5154 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5155 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5156 | |
| 5157 | if !shouldFail { |
| 5158 | testCases = append(testCases, testCase{ |
| 5159 | testType: serverTest, |
| 5160 | name: "ClientAuth-InvalidSignature" + suffix, |
| 5161 | config: Config{ |
| 5162 | MaxVersion: ver.version, |
| 5163 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5164 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5165 | alg.id, |
| 5166 | }, |
| 5167 | Bugs: ProtocolBugs{ |
| 5168 | InvalidSignature: true, |
| 5169 | }, |
| 5170 | }, |
| 5171 | flags: []string{ |
| 5172 | "-require-any-client-certificate", |
| 5173 | "-enable-all-curves", |
| 5174 | }, |
| 5175 | shouldFail: true, |
| 5176 | expectedError: ":BAD_SIGNATURE:", |
| 5177 | }) |
| 5178 | |
| 5179 | testCases = append(testCases, testCase{ |
| 5180 | name: "ServerAuth-InvalidSignature" + suffix, |
| 5181 | config: Config{ |
| 5182 | MaxVersion: ver.version, |
| 5183 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5184 | CipherSuites: signingCiphers, |
| 5185 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5186 | alg.id, |
| 5187 | }, |
| 5188 | Bugs: ProtocolBugs{ |
| 5189 | InvalidSignature: true, |
| 5190 | }, |
| 5191 | }, |
| 5192 | flags: []string{"-enable-all-curves"}, |
| 5193 | shouldFail: true, |
| 5194 | expectedError: ":BAD_SIGNATURE:", |
| 5195 | }) |
| 5196 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5197 | |
| 5198 | if ver.version >= VersionTLS12 && !shouldFail { |
| 5199 | testCases = append(testCases, testCase{ |
| 5200 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 5201 | config: Config{ |
| 5202 | MaxVersion: ver.version, |
| 5203 | ClientAuth: RequireAnyClientCert, |
| 5204 | VerifySignatureAlgorithms: allAlgorithms, |
| 5205 | }, |
| 5206 | flags: []string{ |
| 5207 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5208 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5209 | "-enable-all-curves", |
| 5210 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5211 | }, |
| 5212 | expectedPeerSignatureAlgorithm: alg.id, |
| 5213 | }) |
| 5214 | |
| 5215 | testCases = append(testCases, testCase{ |
| 5216 | testType: serverTest, |
| 5217 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 5218 | config: Config{ |
| 5219 | MaxVersion: ver.version, |
| 5220 | CipherSuites: signingCiphers, |
| 5221 | VerifySignatureAlgorithms: allAlgorithms, |
| 5222 | }, |
| 5223 | flags: []string{ |
| 5224 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5225 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5226 | "-enable-all-curves", |
| 5227 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5228 | }, |
| 5229 | expectedPeerSignatureAlgorithm: alg.id, |
| 5230 | }) |
| 5231 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5232 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5233 | } |
| 5234 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5235 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5236 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5237 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5238 | config: Config{ |
| 5239 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5240 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5241 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5242 | signatureECDSAWithP521AndSHA512, |
| 5243 | signatureRSAPKCS1WithSHA384, |
| 5244 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5245 | }, |
| 5246 | }, |
| 5247 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5248 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5249 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5250 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5251 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5252 | }) |
| 5253 | |
| 5254 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 5255 | name: "ClientAuth-SignatureType-TLS13", |
| 5256 | config: Config{ |
| 5257 | ClientAuth: RequireAnyClientCert, |
| 5258 | MaxVersion: VersionTLS13, |
| 5259 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5260 | signatureECDSAWithP521AndSHA512, |
| 5261 | signatureRSAPKCS1WithSHA384, |
| 5262 | signatureRSAPSSWithSHA384, |
| 5263 | signatureECDSAWithSHA1, |
| 5264 | }, |
| 5265 | }, |
| 5266 | flags: []string{ |
| 5267 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5268 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5269 | }, |
| 5270 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5271 | }) |
| 5272 | |
| 5273 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5274 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5275 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5276 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5277 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5278 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5279 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5280 | signatureECDSAWithP521AndSHA512, |
| 5281 | signatureRSAPKCS1WithSHA384, |
| 5282 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5283 | }, |
| 5284 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5285 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5286 | }) |
| 5287 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 5288 | testCases = append(testCases, testCase{ |
| 5289 | testType: serverTest, |
| 5290 | name: "ServerAuth-SignatureType-TLS13", |
| 5291 | config: Config{ |
| 5292 | MaxVersion: VersionTLS13, |
| 5293 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5294 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5295 | signatureECDSAWithP521AndSHA512, |
| 5296 | signatureRSAPKCS1WithSHA384, |
| 5297 | signatureRSAPSSWithSHA384, |
| 5298 | signatureECDSAWithSHA1, |
| 5299 | }, |
| 5300 | }, |
| 5301 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5302 | }) |
| 5303 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5304 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5305 | testCases = append(testCases, testCase{ |
| 5306 | testType: serverTest, |
| 5307 | name: "Verify-ClientAuth-SignatureType", |
| 5308 | config: Config{ |
| 5309 | MaxVersion: VersionTLS12, |
| 5310 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5311 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5312 | signatureRSAPKCS1WithSHA256, |
| 5313 | }, |
| 5314 | Bugs: ProtocolBugs{ |
| 5315 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5316 | }, |
| 5317 | }, |
| 5318 | flags: []string{ |
| 5319 | "-require-any-client-certificate", |
| 5320 | }, |
| 5321 | shouldFail: true, |
| 5322 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5323 | }) |
| 5324 | |
| 5325 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 5326 | testType: serverTest, |
| 5327 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 5328 | config: Config{ |
| 5329 | MaxVersion: VersionTLS13, |
| 5330 | Certificates: []Certificate{rsaCertificate}, |
| 5331 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5332 | signatureRSAPSSWithSHA256, |
| 5333 | }, |
| 5334 | Bugs: ProtocolBugs{ |
| 5335 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5336 | }, |
| 5337 | }, |
| 5338 | flags: []string{ |
| 5339 | "-require-any-client-certificate", |
| 5340 | }, |
| 5341 | shouldFail: true, |
| 5342 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5343 | }) |
| 5344 | |
| 5345 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5346 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5347 | config: Config{ |
| 5348 | MaxVersion: VersionTLS12, |
| 5349 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5350 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5351 | signatureRSAPKCS1WithSHA256, |
| 5352 | }, |
| 5353 | Bugs: ProtocolBugs{ |
| 5354 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5355 | }, |
| 5356 | }, |
| 5357 | shouldFail: true, |
| 5358 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5359 | }) |
| 5360 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 5361 | testCases = append(testCases, testCase{ |
| 5362 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 5363 | config: Config{ |
| 5364 | MaxVersion: VersionTLS13, |
| 5365 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5366 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5367 | signatureRSAPSSWithSHA256, |
| 5368 | }, |
| 5369 | Bugs: ProtocolBugs{ |
| 5370 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5371 | }, |
| 5372 | }, |
| 5373 | shouldFail: true, |
| 5374 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5375 | }) |
| 5376 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5377 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 5378 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5379 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5380 | name: "ClientAuth-SHA1-Fallback", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5381 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5382 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5383 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5384 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5385 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5386 | }, |
| 5387 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5388 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5389 | }, |
| 5390 | }, |
| 5391 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5392 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5393 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5394 | }, |
| 5395 | }) |
| 5396 | |
| 5397 | testCases = append(testCases, testCase{ |
| 5398 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5399 | name: "ServerAuth-SHA1-Fallback", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5400 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5401 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5402 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5403 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5404 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5405 | }, |
| 5406 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5407 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5408 | }, |
| 5409 | }, |
| 5410 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5411 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5412 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5413 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5414 | config: Config{ |
| 5415 | MaxVersion: VersionTLS13, |
| 5416 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5417 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5418 | signatureRSAPKCS1WithSHA1, |
| 5419 | }, |
| 5420 | Bugs: ProtocolBugs{ |
| 5421 | NoSignatureAlgorithms: true, |
| 5422 | }, |
| 5423 | }, |
| 5424 | flags: []string{ |
| 5425 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5426 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5427 | }, |
| 5428 | shouldFail: true, |
| 5429 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5430 | }) |
| 5431 | |
| 5432 | testCases = append(testCases, testCase{ |
| 5433 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5434 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5435 | config: Config{ |
| 5436 | MaxVersion: VersionTLS13, |
| 5437 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5438 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5439 | signatureRSAPKCS1WithSHA1, |
| 5440 | }, |
| 5441 | Bugs: ProtocolBugs{ |
| 5442 | NoSignatureAlgorithms: true, |
| 5443 | }, |
| 5444 | }, |
| 5445 | shouldFail: true, |
| 5446 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5447 | }) |
| 5448 | |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5449 | // Test that hash preferences are enforced. BoringSSL defaults to |
| 5450 | // rejecting MD5 signatures. |
| 5451 | testCases = append(testCases, testCase{ |
| 5452 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5453 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5454 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5455 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5456 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5457 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5458 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5459 | // Advertise SHA-1 so the handshake will |
| 5460 | // proceed, but the shim's preferences will be |
| 5461 | // ignored in CertificateVerify generation, so |
| 5462 | // MD5 will be chosen. |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5463 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5464 | }, |
| 5465 | Bugs: ProtocolBugs{ |
| 5466 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 5467 | }, |
| 5468 | }, |
| 5469 | flags: []string{"-require-any-client-certificate"}, |
| 5470 | shouldFail: true, |
| 5471 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5472 | }) |
| 5473 | |
| 5474 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5475 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5476 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5477 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5478 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5479 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5480 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5481 | }, |
| 5482 | Bugs: ProtocolBugs{ |
| 5483 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 5484 | }, |
| 5485 | }, |
| 5486 | shouldFail: true, |
| 5487 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5488 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5489 | |
| 5490 | // Test that the agreed upon digest respects the client preferences and |
| 5491 | // the server digests. |
| 5492 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5493 | name: "NoCommonAlgorithms-Digests", |
| 5494 | config: Config{ |
| 5495 | MaxVersion: VersionTLS12, |
| 5496 | ClientAuth: RequireAnyClientCert, |
| 5497 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5498 | signatureRSAPKCS1WithSHA512, |
| 5499 | signatureRSAPKCS1WithSHA1, |
| 5500 | }, |
| 5501 | }, |
| 5502 | flags: []string{ |
| 5503 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5504 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5505 | "-digest-prefs", "SHA256", |
| 5506 | }, |
| 5507 | shouldFail: true, |
| 5508 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5509 | }) |
| 5510 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 5511 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5512 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5513 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5514 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5515 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5516 | signatureRSAPKCS1WithSHA512, |
| 5517 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5518 | }, |
| 5519 | }, |
| 5520 | flags: []string{ |
| 5521 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5522 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5523 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5524 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5525 | shouldFail: true, |
| 5526 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5527 | }) |
| 5528 | testCases = append(testCases, testCase{ |
| 5529 | name: "NoCommonAlgorithms-TLS13", |
| 5530 | config: Config{ |
| 5531 | MaxVersion: VersionTLS13, |
| 5532 | ClientAuth: RequireAnyClientCert, |
| 5533 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5534 | signatureRSAPSSWithSHA512, |
| 5535 | signatureRSAPSSWithSHA384, |
| 5536 | }, |
| 5537 | }, |
| 5538 | flags: []string{ |
| 5539 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5540 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5541 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 5542 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 5543 | shouldFail: true, |
| 5544 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5545 | }) |
| 5546 | testCases = append(testCases, testCase{ |
| 5547 | name: "Agree-Digest-SHA256", |
| 5548 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5549 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5550 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5551 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5552 | signatureRSAPKCS1WithSHA1, |
| 5553 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5554 | }, |
| 5555 | }, |
| 5556 | flags: []string{ |
| 5557 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5558 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5559 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5560 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5561 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5562 | }) |
| 5563 | testCases = append(testCases, testCase{ |
| 5564 | name: "Agree-Digest-SHA1", |
| 5565 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5566 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5567 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5568 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5569 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5570 | }, |
| 5571 | }, |
| 5572 | flags: []string{ |
| 5573 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5574 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5575 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5576 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5577 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5578 | }) |
| 5579 | testCases = append(testCases, testCase{ |
| 5580 | name: "Agree-Digest-Default", |
| 5581 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5582 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5583 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5584 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5585 | signatureRSAPKCS1WithSHA256, |
| 5586 | signatureECDSAWithP256AndSHA256, |
| 5587 | signatureRSAPKCS1WithSHA1, |
| 5588 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5589 | }, |
| 5590 | }, |
| 5591 | flags: []string{ |
| 5592 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5593 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5594 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5595 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5596 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5597 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5598 | // Test that the signing preference list may include extra algorithms |
| 5599 | // without negotiation problems. |
| 5600 | testCases = append(testCases, testCase{ |
| 5601 | testType: serverTest, |
| 5602 | name: "FilterExtraAlgorithms", |
| 5603 | config: Config{ |
| 5604 | MaxVersion: VersionTLS12, |
| 5605 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5606 | signatureRSAPKCS1WithSHA256, |
| 5607 | }, |
| 5608 | }, |
| 5609 | flags: []string{ |
| 5610 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5611 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5612 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 5613 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 5614 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 5615 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 5616 | }, |
| 5617 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 5618 | }) |
| 5619 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5620 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 5621 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5622 | testCases = append(testCases, testCase{ |
| 5623 | name: "CheckLeafCurve", |
| 5624 | config: Config{ |
| 5625 | MaxVersion: VersionTLS12, |
| 5626 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5627 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5628 | }, |
| 5629 | flags: []string{"-p384-only"}, |
| 5630 | shouldFail: true, |
| 5631 | expectedError: ":BAD_ECC_CERT:", |
| 5632 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 5633 | |
| 5634 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 5635 | testCases = append(testCases, testCase{ |
| 5636 | name: "CheckLeafCurve-TLS13", |
| 5637 | config: Config{ |
| 5638 | MaxVersion: VersionTLS13, |
| 5639 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 5640 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 5641 | }, |
| 5642 | flags: []string{"-p384-only"}, |
| 5643 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5644 | |
| 5645 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 5646 | testCases = append(testCases, testCase{ |
| 5647 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 5648 | config: Config{ |
| 5649 | MaxVersion: VersionTLS12, |
| 5650 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 5651 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5652 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5653 | signatureECDSAWithP384AndSHA384, |
| 5654 | }, |
| 5655 | }, |
| 5656 | }) |
| 5657 | |
| 5658 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 5659 | testCases = append(testCases, testCase{ |
| 5660 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 5661 | config: Config{ |
| 5662 | MaxVersion: VersionTLS13, |
| 5663 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 5664 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5665 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5666 | signatureECDSAWithP384AndSHA384, |
| 5667 | }, |
| 5668 | Bugs: ProtocolBugs{ |
| 5669 | SkipECDSACurveCheck: true, |
| 5670 | }, |
| 5671 | }, |
| 5672 | shouldFail: true, |
| 5673 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5674 | }) |
| 5675 | |
| 5676 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 5677 | // account. |
| 5678 | testCases = append(testCases, testCase{ |
| 5679 | testType: serverTest, |
| 5680 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 5681 | config: Config{ |
| 5682 | MaxVersion: VersionTLS13, |
| 5683 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5684 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5685 | signatureECDSAWithP384AndSHA384, |
| 5686 | signatureECDSAWithP256AndSHA256, |
| 5687 | }, |
| 5688 | }, |
| 5689 | flags: []string{ |
| 5690 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 5691 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 5692 | }, |
| 5693 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5694 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 5695 | |
| 5696 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 5697 | // server does not attempt to sign in that case. |
| 5698 | testCases = append(testCases, testCase{ |
| 5699 | testType: serverTest, |
| 5700 | name: "RSA-PSS-Large", |
| 5701 | config: Config{ |
| 5702 | MaxVersion: VersionTLS13, |
| 5703 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5704 | signatureRSAPSSWithSHA512, |
| 5705 | }, |
| 5706 | }, |
| 5707 | flags: []string{ |
| 5708 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 5709 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 5710 | }, |
| 5711 | shouldFail: true, |
| 5712 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5713 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5714 | } |
| 5715 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5716 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 5717 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 5718 | var timeouts = []time.Duration{ |
| 5719 | 1 * time.Second, |
| 5720 | 2 * time.Second, |
| 5721 | 4 * time.Second, |
| 5722 | 8 * time.Second, |
| 5723 | 16 * time.Second, |
| 5724 | 32 * time.Second, |
| 5725 | 60 * time.Second, |
| 5726 | 60 * time.Second, |
| 5727 | 60 * time.Second, |
| 5728 | 60 * time.Second, |
| 5729 | 60 * time.Second, |
| 5730 | 60 * time.Second, |
| 5731 | 60 * time.Second, |
| 5732 | } |
| 5733 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 5734 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 5735 | // initial timeout duration was set to 250ms. |
| 5736 | var shortTimeouts = []time.Duration{ |
| 5737 | 250 * time.Millisecond, |
| 5738 | 500 * time.Millisecond, |
| 5739 | 1 * time.Second, |
| 5740 | 2 * time.Second, |
| 5741 | 4 * time.Second, |
| 5742 | 8 * time.Second, |
| 5743 | 16 * time.Second, |
| 5744 | 32 * time.Second, |
| 5745 | 60 * time.Second, |
| 5746 | 60 * time.Second, |
| 5747 | 60 * time.Second, |
| 5748 | 60 * time.Second, |
| 5749 | 60 * time.Second, |
| 5750 | } |
| 5751 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5752 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5753 | // These tests work by coordinating some behavior on both the shim and |
| 5754 | // the runner. |
| 5755 | // |
| 5756 | // TimeoutSchedule configures the runner to send a series of timeout |
| 5757 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 5758 | // each peer handshake flight N. The timeout opcode both simulates a |
| 5759 | // timeout in the shim and acts as a synchronization point to help the |
| 5760 | // runner bracket each handshake flight. |
| 5761 | // |
| 5762 | // We assume the shim does not read from the channel eagerly. It must |
| 5763 | // first wait until it has sent flight N and is ready to receive |
| 5764 | // handshake flight N+1. At this point, it will process the timeout |
| 5765 | // opcode. It must then immediately respond with a timeout ACK and act |
| 5766 | // as if the shim was idle for the specified amount of time. |
| 5767 | // |
| 5768 | // The runner then drops all packets received before the ACK and |
| 5769 | // continues waiting for flight N. This ordering results in one attempt |
| 5770 | // at sending flight N to be dropped. For the test to complete, the |
| 5771 | // shim must send flight N again, testing that the shim implements DTLS |
| 5772 | // retransmit on a timeout. |
| 5773 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 5774 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5775 | // likely be more epochs to cross and the final message's retransmit may |
| 5776 | // be more complex. |
| 5777 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5778 | for _, async := range []bool{true, false} { |
| 5779 | var tests []testCase |
| 5780 | |
| 5781 | // Test that this is indeed the timeout schedule. Stress all |
| 5782 | // four patterns of handshake. |
| 5783 | for i := 1; i < len(timeouts); i++ { |
| 5784 | number := strconv.Itoa(i) |
| 5785 | tests = append(tests, testCase{ |
| 5786 | protocol: dtls, |
| 5787 | name: "DTLS-Retransmit-Client-" + number, |
| 5788 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5789 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5790 | Bugs: ProtocolBugs{ |
| 5791 | TimeoutSchedule: timeouts[:i], |
| 5792 | }, |
| 5793 | }, |
| 5794 | resumeSession: true, |
| 5795 | }) |
| 5796 | tests = append(tests, testCase{ |
| 5797 | protocol: dtls, |
| 5798 | testType: serverTest, |
| 5799 | name: "DTLS-Retransmit-Server-" + number, |
| 5800 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5801 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5802 | Bugs: ProtocolBugs{ |
| 5803 | TimeoutSchedule: timeouts[:i], |
| 5804 | }, |
| 5805 | }, |
| 5806 | resumeSession: true, |
| 5807 | }) |
| 5808 | } |
| 5809 | |
| 5810 | // Test that exceeding the timeout schedule hits a read |
| 5811 | // timeout. |
| 5812 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5813 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5814 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5815 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5816 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5817 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5818 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5819 | }, |
| 5820 | }, |
| 5821 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5822 | shouldFail: true, |
| 5823 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5824 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5825 | |
| 5826 | if async { |
| 5827 | // Test that timeout handling has a fudge factor, due to API |
| 5828 | // problems. |
| 5829 | tests = append(tests, testCase{ |
| 5830 | protocol: dtls, |
| 5831 | name: "DTLS-Retransmit-Fudge", |
| 5832 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5833 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5834 | Bugs: ProtocolBugs{ |
| 5835 | TimeoutSchedule: []time.Duration{ |
| 5836 | timeouts[0] - 10*time.Millisecond, |
| 5837 | }, |
| 5838 | }, |
| 5839 | }, |
| 5840 | resumeSession: true, |
| 5841 | }) |
| 5842 | } |
| 5843 | |
| 5844 | // Test that the final Finished retransmitting isn't |
| 5845 | // duplicated if the peer badly fragments everything. |
| 5846 | tests = append(tests, testCase{ |
| 5847 | testType: serverTest, |
| 5848 | protocol: dtls, |
| 5849 | name: "DTLS-Retransmit-Fragmented", |
| 5850 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5851 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5852 | Bugs: ProtocolBugs{ |
| 5853 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 5854 | MaxHandshakeRecordLength: 2, |
| 5855 | }, |
| 5856 | }, |
| 5857 | }) |
| 5858 | |
| 5859 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 5860 | tests = append(tests, testCase{ |
| 5861 | protocol: dtls, |
| 5862 | name: "DTLS-Retransmit-Short-Client", |
| 5863 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5864 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5865 | Bugs: ProtocolBugs{ |
| 5866 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 5867 | }, |
| 5868 | }, |
| 5869 | resumeSession: true, |
| 5870 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 5871 | }) |
| 5872 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5873 | protocol: dtls, |
| 5874 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5875 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5876 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5877 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5878 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5879 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5880 | }, |
| 5881 | }, |
| 5882 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5883 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5884 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5885 | |
| 5886 | for _, test := range tests { |
| 5887 | if async { |
| 5888 | test.name += "-Async" |
| 5889 | test.flags = append(test.flags, "-async") |
| 5890 | } |
| 5891 | |
| 5892 | testCases = append(testCases, test) |
| 5893 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5894 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5895 | } |
| 5896 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 5897 | func addExportKeyingMaterialTests() { |
| 5898 | for _, vers := range tlsVersions { |
| 5899 | if vers.version == VersionSSL30 { |
| 5900 | continue |
| 5901 | } |
| 5902 | testCases = append(testCases, testCase{ |
| 5903 | name: "ExportKeyingMaterial-" + vers.name, |
| 5904 | config: Config{ |
| 5905 | MaxVersion: vers.version, |
| 5906 | }, |
| 5907 | exportKeyingMaterial: 1024, |
| 5908 | exportLabel: "label", |
| 5909 | exportContext: "context", |
| 5910 | useExportContext: true, |
| 5911 | }) |
| 5912 | testCases = append(testCases, testCase{ |
| 5913 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 5914 | config: Config{ |
| 5915 | MaxVersion: vers.version, |
| 5916 | }, |
| 5917 | exportKeyingMaterial: 1024, |
| 5918 | }) |
| 5919 | testCases = append(testCases, testCase{ |
| 5920 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 5921 | config: Config{ |
| 5922 | MaxVersion: vers.version, |
| 5923 | }, |
| 5924 | exportKeyingMaterial: 1024, |
| 5925 | useExportContext: true, |
| 5926 | }) |
| 5927 | testCases = append(testCases, testCase{ |
| 5928 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 5929 | config: Config{ |
| 5930 | MaxVersion: vers.version, |
| 5931 | }, |
| 5932 | exportKeyingMaterial: 1, |
| 5933 | exportLabel: "label", |
| 5934 | exportContext: "context", |
| 5935 | useExportContext: true, |
| 5936 | }) |
| 5937 | } |
| 5938 | testCases = append(testCases, testCase{ |
| 5939 | name: "ExportKeyingMaterial-SSL3", |
| 5940 | config: Config{ |
| 5941 | MaxVersion: VersionSSL30, |
| 5942 | }, |
| 5943 | exportKeyingMaterial: 1024, |
| 5944 | exportLabel: "label", |
| 5945 | exportContext: "context", |
| 5946 | useExportContext: true, |
| 5947 | shouldFail: true, |
| 5948 | expectedError: "failed to export keying material", |
| 5949 | }) |
| 5950 | } |
| 5951 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 5952 | func addTLSUniqueTests() { |
| 5953 | for _, isClient := range []bool{false, true} { |
| 5954 | for _, isResumption := range []bool{false, true} { |
| 5955 | for _, hasEMS := range []bool{false, true} { |
| 5956 | var suffix string |
| 5957 | if isResumption { |
| 5958 | suffix = "Resume-" |
| 5959 | } else { |
| 5960 | suffix = "Full-" |
| 5961 | } |
| 5962 | |
| 5963 | if hasEMS { |
| 5964 | suffix += "EMS-" |
| 5965 | } else { |
| 5966 | suffix += "NoEMS-" |
| 5967 | } |
| 5968 | |
| 5969 | if isClient { |
| 5970 | suffix += "Client" |
| 5971 | } else { |
| 5972 | suffix += "Server" |
| 5973 | } |
| 5974 | |
| 5975 | test := testCase{ |
| 5976 | name: "TLSUnique-" + suffix, |
| 5977 | testTLSUnique: true, |
| 5978 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5979 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 5980 | Bugs: ProtocolBugs{ |
| 5981 | NoExtendedMasterSecret: !hasEMS, |
| 5982 | }, |
| 5983 | }, |
| 5984 | } |
| 5985 | |
| 5986 | if isResumption { |
| 5987 | test.resumeSession = true |
| 5988 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5989 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 5990 | Bugs: ProtocolBugs{ |
| 5991 | NoExtendedMasterSecret: !hasEMS, |
| 5992 | }, |
| 5993 | } |
| 5994 | } |
| 5995 | |
| 5996 | if isResumption && !hasEMS { |
| 5997 | test.shouldFail = true |
| 5998 | test.expectedError = "failed to get tls-unique" |
| 5999 | } |
| 6000 | |
| 6001 | testCases = append(testCases, test) |
| 6002 | } |
| 6003 | } |
| 6004 | } |
| 6005 | } |
| 6006 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6007 | func addCustomExtensionTests() { |
| 6008 | expectedContents := "custom extension" |
| 6009 | emptyString := "" |
| 6010 | |
| 6011 | for _, isClient := range []bool{false, true} { |
| 6012 | suffix := "Server" |
| 6013 | flag := "-enable-server-custom-extension" |
| 6014 | testType := serverTest |
| 6015 | if isClient { |
| 6016 | suffix = "Client" |
| 6017 | flag = "-enable-client-custom-extension" |
| 6018 | testType = clientTest |
| 6019 | } |
| 6020 | |
| 6021 | testCases = append(testCases, testCase{ |
| 6022 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6023 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6024 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6025 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6026 | Bugs: ProtocolBugs{ |
| 6027 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6028 | ExpectedCustomExtension: &expectedContents, |
| 6029 | }, |
| 6030 | }, |
| 6031 | flags: []string{flag}, |
| 6032 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6033 | testCases = append(testCases, testCase{ |
| 6034 | testType: testType, |
| 6035 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 6036 | config: Config{ |
| 6037 | MaxVersion: VersionTLS13, |
| 6038 | Bugs: ProtocolBugs{ |
| 6039 | CustomExtension: expectedContents, |
| 6040 | ExpectedCustomExtension: &expectedContents, |
| 6041 | }, |
| 6042 | }, |
| 6043 | flags: []string{flag}, |
| 6044 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6045 | |
| 6046 | // If the parse callback fails, the handshake should also fail. |
| 6047 | testCases = append(testCases, testCase{ |
| 6048 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6049 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6050 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6051 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6052 | Bugs: ProtocolBugs{ |
| 6053 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6054 | ExpectedCustomExtension: &expectedContents, |
| 6055 | }, |
| 6056 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6057 | flags: []string{flag}, |
| 6058 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6059 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6060 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6061 | testCases = append(testCases, testCase{ |
| 6062 | testType: testType, |
| 6063 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 6064 | config: Config{ |
| 6065 | MaxVersion: VersionTLS13, |
| 6066 | Bugs: ProtocolBugs{ |
| 6067 | CustomExtension: expectedContents + "foo", |
| 6068 | ExpectedCustomExtension: &expectedContents, |
| 6069 | }, |
| 6070 | }, |
| 6071 | flags: []string{flag}, |
| 6072 | shouldFail: true, |
| 6073 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6074 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6075 | |
| 6076 | // If the add callback fails, the handshake should also fail. |
| 6077 | testCases = append(testCases, testCase{ |
| 6078 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6079 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6080 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6081 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6082 | Bugs: ProtocolBugs{ |
| 6083 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6084 | ExpectedCustomExtension: &expectedContents, |
| 6085 | }, |
| 6086 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6087 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6088 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6089 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6090 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6091 | testCases = append(testCases, testCase{ |
| 6092 | testType: testType, |
| 6093 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 6094 | config: Config{ |
| 6095 | MaxVersion: VersionTLS13, |
| 6096 | Bugs: ProtocolBugs{ |
| 6097 | CustomExtension: expectedContents, |
| 6098 | ExpectedCustomExtension: &expectedContents, |
| 6099 | }, |
| 6100 | }, |
| 6101 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6102 | shouldFail: true, |
| 6103 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6104 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6105 | |
| 6106 | // If the add callback returns zero, no extension should be |
| 6107 | // added. |
| 6108 | skipCustomExtension := expectedContents |
| 6109 | if isClient { |
| 6110 | // For the case where the client skips sending the |
| 6111 | // custom extension, the server must not “echo” it. |
| 6112 | skipCustomExtension = "" |
| 6113 | } |
| 6114 | testCases = append(testCases, testCase{ |
| 6115 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6116 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6117 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6118 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6119 | Bugs: ProtocolBugs{ |
| 6120 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6121 | ExpectedCustomExtension: &emptyString, |
| 6122 | }, |
| 6123 | }, |
| 6124 | flags: []string{flag, "-custom-extension-skip"}, |
| 6125 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6126 | testCases = append(testCases, testCase{ |
| 6127 | testType: testType, |
| 6128 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 6129 | config: Config{ |
| 6130 | MaxVersion: VersionTLS13, |
| 6131 | Bugs: ProtocolBugs{ |
| 6132 | CustomExtension: skipCustomExtension, |
| 6133 | ExpectedCustomExtension: &emptyString, |
| 6134 | }, |
| 6135 | }, |
| 6136 | flags: []string{flag, "-custom-extension-skip"}, |
| 6137 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6138 | } |
| 6139 | |
| 6140 | // The custom extension add callback should not be called if the client |
| 6141 | // doesn't send the extension. |
| 6142 | testCases = append(testCases, testCase{ |
| 6143 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6144 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6145 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6146 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6147 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6148 | ExpectedCustomExtension: &emptyString, |
| 6149 | }, |
| 6150 | }, |
| 6151 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6152 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6153 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6154 | testCases = append(testCases, testCase{ |
| 6155 | testType: serverTest, |
| 6156 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 6157 | config: Config{ |
| 6158 | MaxVersion: VersionTLS13, |
| 6159 | Bugs: ProtocolBugs{ |
| 6160 | ExpectedCustomExtension: &emptyString, |
| 6161 | }, |
| 6162 | }, |
| 6163 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6164 | }) |
| 6165 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6166 | // Test an unknown extension from the server. |
| 6167 | testCases = append(testCases, testCase{ |
| 6168 | testType: clientTest, |
| 6169 | name: "UnknownExtension-Client", |
| 6170 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6171 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6172 | Bugs: ProtocolBugs{ |
| 6173 | CustomExtension: expectedContents, |
| 6174 | }, |
| 6175 | }, |
| 6176 | shouldFail: true, |
| 6177 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6178 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6179 | testCases = append(testCases, testCase{ |
| 6180 | testType: clientTest, |
| 6181 | name: "UnknownExtension-Client-TLS13", |
| 6182 | config: Config{ |
| 6183 | MaxVersion: VersionTLS13, |
| 6184 | Bugs: ProtocolBugs{ |
| 6185 | CustomExtension: expectedContents, |
| 6186 | }, |
| 6187 | }, |
| 6188 | shouldFail: true, |
| 6189 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6190 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6191 | } |
| 6192 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6193 | func addRSAClientKeyExchangeTests() { |
| 6194 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 6195 | testCases = append(testCases, testCase{ |
| 6196 | testType: serverTest, |
| 6197 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 6198 | config: Config{ |
| 6199 | // Ensure the ClientHello version and final |
| 6200 | // version are different, to detect if the |
| 6201 | // server uses the wrong one. |
| 6202 | MaxVersion: VersionTLS11, |
| 6203 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 6204 | Bugs: ProtocolBugs{ |
| 6205 | BadRSAClientKeyExchange: bad, |
| 6206 | }, |
| 6207 | }, |
| 6208 | shouldFail: true, |
| 6209 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6210 | }) |
| 6211 | } |
| 6212 | } |
| 6213 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6214 | var testCurves = []struct { |
| 6215 | name string |
| 6216 | id CurveID |
| 6217 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6218 | {"P-256", CurveP256}, |
| 6219 | {"P-384", CurveP384}, |
| 6220 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 6221 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6222 | } |
| 6223 | |
| 6224 | func addCurveTests() { |
| 6225 | for _, curve := range testCurves { |
| 6226 | testCases = append(testCases, testCase{ |
| 6227 | name: "CurveTest-Client-" + curve.name, |
| 6228 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6229 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6230 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6231 | CurvePreferences: []CurveID{curve.id}, |
| 6232 | }, |
| 6233 | flags: []string{"-enable-all-curves"}, |
| 6234 | }) |
| 6235 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6236 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 6237 | config: Config{ |
| 6238 | MaxVersion: VersionTLS13, |
| 6239 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6240 | CurvePreferences: []CurveID{curve.id}, |
| 6241 | }, |
| 6242 | flags: []string{"-enable-all-curves"}, |
| 6243 | }) |
| 6244 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6245 | testType: serverTest, |
| 6246 | name: "CurveTest-Server-" + curve.name, |
| 6247 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6248 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6249 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6250 | CurvePreferences: []CurveID{curve.id}, |
| 6251 | }, |
| 6252 | flags: []string{"-enable-all-curves"}, |
| 6253 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6254 | testCases = append(testCases, testCase{ |
| 6255 | testType: serverTest, |
| 6256 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 6257 | config: Config{ |
| 6258 | MaxVersion: VersionTLS13, |
| 6259 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6260 | CurvePreferences: []CurveID{curve.id}, |
| 6261 | }, |
| 6262 | flags: []string{"-enable-all-curves"}, |
| 6263 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6264 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 6265 | |
| 6266 | // The server must be tolerant to bogus curves. |
| 6267 | const bogusCurve = 0x1234 |
| 6268 | testCases = append(testCases, testCase{ |
| 6269 | testType: serverTest, |
| 6270 | name: "UnknownCurve", |
| 6271 | config: Config{ |
| 6272 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6273 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 6274 | }, |
| 6275 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6276 | |
| 6277 | // The server must not consider ECDHE ciphers when there are no |
| 6278 | // supported curves. |
| 6279 | testCases = append(testCases, testCase{ |
| 6280 | testType: serverTest, |
| 6281 | name: "NoSupportedCurves", |
| 6282 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6283 | MaxVersion: VersionTLS12, |
| 6284 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6285 | Bugs: ProtocolBugs{ |
| 6286 | NoSupportedCurves: true, |
| 6287 | }, |
| 6288 | }, |
| 6289 | shouldFail: true, |
| 6290 | expectedError: ":NO_SHARED_CIPHER:", |
| 6291 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6292 | testCases = append(testCases, testCase{ |
| 6293 | testType: serverTest, |
| 6294 | name: "NoSupportedCurves-TLS13", |
| 6295 | config: Config{ |
| 6296 | MaxVersion: VersionTLS13, |
| 6297 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6298 | Bugs: ProtocolBugs{ |
| 6299 | NoSupportedCurves: true, |
| 6300 | }, |
| 6301 | }, |
| 6302 | shouldFail: true, |
| 6303 | expectedError: ":NO_SHARED_CIPHER:", |
| 6304 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6305 | |
| 6306 | // The server must fall back to another cipher when there are no |
| 6307 | // supported curves. |
| 6308 | testCases = append(testCases, testCase{ |
| 6309 | testType: serverTest, |
| 6310 | name: "NoCommonCurves", |
| 6311 | config: Config{ |
| 6312 | MaxVersion: VersionTLS12, |
| 6313 | CipherSuites: []uint16{ |
| 6314 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6315 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6316 | }, |
| 6317 | CurvePreferences: []CurveID{CurveP224}, |
| 6318 | }, |
| 6319 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6320 | }) |
| 6321 | |
| 6322 | // The client must reject bogus curves and disabled curves. |
| 6323 | testCases = append(testCases, testCase{ |
| 6324 | name: "BadECDHECurve", |
| 6325 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6326 | MaxVersion: VersionTLS12, |
| 6327 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6328 | Bugs: ProtocolBugs{ |
| 6329 | SendCurve: bogusCurve, |
| 6330 | }, |
| 6331 | }, |
| 6332 | shouldFail: true, |
| 6333 | expectedError: ":WRONG_CURVE:", |
| 6334 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6335 | testCases = append(testCases, testCase{ |
| 6336 | name: "BadECDHECurve-TLS13", |
| 6337 | config: Config{ |
| 6338 | MaxVersion: VersionTLS13, |
| 6339 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6340 | Bugs: ProtocolBugs{ |
| 6341 | SendCurve: bogusCurve, |
| 6342 | }, |
| 6343 | }, |
| 6344 | shouldFail: true, |
| 6345 | expectedError: ":WRONG_CURVE:", |
| 6346 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6347 | |
| 6348 | testCases = append(testCases, testCase{ |
| 6349 | name: "UnsupportedCurve", |
| 6350 | config: Config{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6351 | // TODO(davidben): Add a TLS 1.3 version of this test. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6352 | MaxVersion: VersionTLS12, |
| 6353 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6354 | CurvePreferences: []CurveID{CurveP256}, |
| 6355 | Bugs: ProtocolBugs{ |
| 6356 | IgnorePeerCurvePreferences: true, |
| 6357 | }, |
| 6358 | }, |
| 6359 | flags: []string{"-p384-only"}, |
| 6360 | shouldFail: true, |
| 6361 | expectedError: ":WRONG_CURVE:", |
| 6362 | }) |
| 6363 | |
| 6364 | // Test invalid curve points. |
| 6365 | testCases = append(testCases, testCase{ |
| 6366 | name: "InvalidECDHPoint-Client", |
| 6367 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6368 | MaxVersion: VersionTLS12, |
| 6369 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6370 | CurvePreferences: []CurveID{CurveP256}, |
| 6371 | Bugs: ProtocolBugs{ |
| 6372 | InvalidECDHPoint: true, |
| 6373 | }, |
| 6374 | }, |
| 6375 | shouldFail: true, |
| 6376 | expectedError: ":INVALID_ENCODING:", |
| 6377 | }) |
| 6378 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6379 | name: "InvalidECDHPoint-Client-TLS13", |
| 6380 | config: Config{ |
| 6381 | MaxVersion: VersionTLS13, |
| 6382 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6383 | CurvePreferences: []CurveID{CurveP256}, |
| 6384 | Bugs: ProtocolBugs{ |
| 6385 | InvalidECDHPoint: true, |
| 6386 | }, |
| 6387 | }, |
| 6388 | shouldFail: true, |
| 6389 | expectedError: ":INVALID_ENCODING:", |
| 6390 | }) |
| 6391 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6392 | testType: serverTest, |
| 6393 | name: "InvalidECDHPoint-Server", |
| 6394 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6395 | MaxVersion: VersionTLS12, |
| 6396 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6397 | CurvePreferences: []CurveID{CurveP256}, |
| 6398 | Bugs: ProtocolBugs{ |
| 6399 | InvalidECDHPoint: true, |
| 6400 | }, |
| 6401 | }, |
| 6402 | shouldFail: true, |
| 6403 | expectedError: ":INVALID_ENCODING:", |
| 6404 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6405 | testCases = append(testCases, testCase{ |
| 6406 | testType: serverTest, |
| 6407 | name: "InvalidECDHPoint-Server-TLS13", |
| 6408 | config: Config{ |
| 6409 | MaxVersion: VersionTLS13, |
| 6410 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6411 | CurvePreferences: []CurveID{CurveP256}, |
| 6412 | Bugs: ProtocolBugs{ |
| 6413 | InvalidECDHPoint: true, |
| 6414 | }, |
| 6415 | }, |
| 6416 | shouldFail: true, |
| 6417 | expectedError: ":INVALID_ENCODING:", |
| 6418 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6419 | } |
| 6420 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6421 | func addCECPQ1Tests() { |
| 6422 | testCases = append(testCases, testCase{ |
| 6423 | testType: clientTest, |
| 6424 | name: "CECPQ1-Client-BadX25519Part", |
| 6425 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6426 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6427 | MinVersion: VersionTLS12, |
| 6428 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6429 | Bugs: ProtocolBugs{ |
| 6430 | CECPQ1BadX25519Part: true, |
| 6431 | }, |
| 6432 | }, |
| 6433 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6434 | shouldFail: true, |
| 6435 | expectedLocalError: "local error: bad record MAC", |
| 6436 | }) |
| 6437 | testCases = append(testCases, testCase{ |
| 6438 | testType: clientTest, |
| 6439 | name: "CECPQ1-Client-BadNewhopePart", |
| 6440 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6441 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6442 | MinVersion: VersionTLS12, |
| 6443 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6444 | Bugs: ProtocolBugs{ |
| 6445 | CECPQ1BadNewhopePart: true, |
| 6446 | }, |
| 6447 | }, |
| 6448 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6449 | shouldFail: true, |
| 6450 | expectedLocalError: "local error: bad record MAC", |
| 6451 | }) |
| 6452 | testCases = append(testCases, testCase{ |
| 6453 | testType: serverTest, |
| 6454 | name: "CECPQ1-Server-BadX25519Part", |
| 6455 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6456 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6457 | MinVersion: VersionTLS12, |
| 6458 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6459 | Bugs: ProtocolBugs{ |
| 6460 | CECPQ1BadX25519Part: true, |
| 6461 | }, |
| 6462 | }, |
| 6463 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6464 | shouldFail: true, |
| 6465 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6466 | }) |
| 6467 | testCases = append(testCases, testCase{ |
| 6468 | testType: serverTest, |
| 6469 | name: "CECPQ1-Server-BadNewhopePart", |
| 6470 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6471 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6472 | MinVersion: VersionTLS12, |
| 6473 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6474 | Bugs: ProtocolBugs{ |
| 6475 | CECPQ1BadNewhopePart: true, |
| 6476 | }, |
| 6477 | }, |
| 6478 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6479 | shouldFail: true, |
| 6480 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6481 | }) |
| 6482 | } |
| 6483 | |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6484 | func addKeyExchangeInfoTests() { |
| 6485 | testCases = append(testCases, testCase{ |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6486 | name: "KeyExchangeInfo-DHE-Client", |
| 6487 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6488 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6489 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6490 | Bugs: ProtocolBugs{ |
| 6491 | // This is a 1234-bit prime number, generated |
| 6492 | // with: |
| 6493 | // openssl gendh 1234 | openssl asn1parse -i |
| 6494 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 6495 | }, |
| 6496 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6497 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6498 | }) |
| 6499 | testCases = append(testCases, testCase{ |
| 6500 | testType: serverTest, |
| 6501 | name: "KeyExchangeInfo-DHE-Server", |
| 6502 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6503 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6504 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6505 | }, |
| 6506 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6507 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6508 | }) |
| 6509 | |
| 6510 | testCases = append(testCases, testCase{ |
| 6511 | name: "KeyExchangeInfo-ECDHE-Client", |
| 6512 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6513 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6514 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6515 | CurvePreferences: []CurveID{CurveX25519}, |
| 6516 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6517 | flags: []string{"-expect-curve-id", "29", "-enable-all-curves"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6518 | }) |
| 6519 | testCases = append(testCases, testCase{ |
| 6520 | testType: serverTest, |
| 6521 | name: "KeyExchangeInfo-ECDHE-Server", |
| 6522 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6523 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6524 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6525 | CurvePreferences: []CurveID{CurveX25519}, |
| 6526 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6527 | flags: []string{"-expect-curve-id", "29", "-enable-all-curves"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6528 | }) |
| 6529 | } |
| 6530 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 6531 | func addTLS13RecordTests() { |
| 6532 | testCases = append(testCases, testCase{ |
| 6533 | name: "TLS13-RecordPadding", |
| 6534 | config: Config{ |
| 6535 | MaxVersion: VersionTLS13, |
| 6536 | MinVersion: VersionTLS13, |
| 6537 | Bugs: ProtocolBugs{ |
| 6538 | RecordPadding: 10, |
| 6539 | }, |
| 6540 | }, |
| 6541 | }) |
| 6542 | |
| 6543 | testCases = append(testCases, testCase{ |
| 6544 | name: "TLS13-EmptyRecords", |
| 6545 | config: Config{ |
| 6546 | MaxVersion: VersionTLS13, |
| 6547 | MinVersion: VersionTLS13, |
| 6548 | Bugs: ProtocolBugs{ |
| 6549 | OmitRecordContents: true, |
| 6550 | }, |
| 6551 | }, |
| 6552 | shouldFail: true, |
| 6553 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6554 | }) |
| 6555 | |
| 6556 | testCases = append(testCases, testCase{ |
| 6557 | name: "TLS13-OnlyPadding", |
| 6558 | config: Config{ |
| 6559 | MaxVersion: VersionTLS13, |
| 6560 | MinVersion: VersionTLS13, |
| 6561 | Bugs: ProtocolBugs{ |
| 6562 | OmitRecordContents: true, |
| 6563 | RecordPadding: 10, |
| 6564 | }, |
| 6565 | }, |
| 6566 | shouldFail: true, |
| 6567 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6568 | }) |
| 6569 | |
| 6570 | testCases = append(testCases, testCase{ |
| 6571 | name: "TLS13-WrongOuterRecord", |
| 6572 | config: Config{ |
| 6573 | MaxVersion: VersionTLS13, |
| 6574 | MinVersion: VersionTLS13, |
| 6575 | Bugs: ProtocolBugs{ |
| 6576 | OuterRecordType: recordTypeHandshake, |
| 6577 | }, |
| 6578 | }, |
| 6579 | shouldFail: true, |
| 6580 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 6581 | }) |
| 6582 | } |
| 6583 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 6584 | func addChangeCipherSpecTests() { |
| 6585 | // Test missing ChangeCipherSpecs. |
| 6586 | testCases = append(testCases, testCase{ |
| 6587 | name: "SkipChangeCipherSpec-Client", |
| 6588 | config: Config{ |
| 6589 | MaxVersion: VersionTLS12, |
| 6590 | Bugs: ProtocolBugs{ |
| 6591 | SkipChangeCipherSpec: true, |
| 6592 | }, |
| 6593 | }, |
| 6594 | shouldFail: true, |
| 6595 | expectedError: ":UNEXPECTED_RECORD:", |
| 6596 | }) |
| 6597 | testCases = append(testCases, testCase{ |
| 6598 | testType: serverTest, |
| 6599 | name: "SkipChangeCipherSpec-Server", |
| 6600 | config: Config{ |
| 6601 | MaxVersion: VersionTLS12, |
| 6602 | Bugs: ProtocolBugs{ |
| 6603 | SkipChangeCipherSpec: true, |
| 6604 | }, |
| 6605 | }, |
| 6606 | shouldFail: true, |
| 6607 | expectedError: ":UNEXPECTED_RECORD:", |
| 6608 | }) |
| 6609 | testCases = append(testCases, testCase{ |
| 6610 | testType: serverTest, |
| 6611 | name: "SkipChangeCipherSpec-Server-NPN", |
| 6612 | config: Config{ |
| 6613 | MaxVersion: VersionTLS12, |
| 6614 | NextProtos: []string{"bar"}, |
| 6615 | Bugs: ProtocolBugs{ |
| 6616 | SkipChangeCipherSpec: true, |
| 6617 | }, |
| 6618 | }, |
| 6619 | flags: []string{ |
| 6620 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 6621 | }, |
| 6622 | shouldFail: true, |
| 6623 | expectedError: ":UNEXPECTED_RECORD:", |
| 6624 | }) |
| 6625 | |
| 6626 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 6627 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 6628 | // rejected. Test both with and without handshake packing to handle both |
| 6629 | // when the partial post-CCS message is in its own record and when it is |
| 6630 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 6631 | for _, packed := range []bool{false, true} { |
| 6632 | var suffix string |
| 6633 | if packed { |
| 6634 | suffix = "-Packed" |
| 6635 | } |
| 6636 | |
| 6637 | testCases = append(testCases, testCase{ |
| 6638 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 6639 | config: Config{ |
| 6640 | MaxVersion: VersionTLS12, |
| 6641 | Bugs: ProtocolBugs{ |
| 6642 | FragmentAcrossChangeCipherSpec: true, |
| 6643 | PackHandshakeFlight: packed, |
| 6644 | }, |
| 6645 | }, |
| 6646 | shouldFail: true, |
| 6647 | expectedError: ":UNEXPECTED_RECORD:", |
| 6648 | }) |
| 6649 | testCases = append(testCases, testCase{ |
| 6650 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 6651 | config: Config{ |
| 6652 | MaxVersion: VersionTLS12, |
| 6653 | }, |
| 6654 | resumeSession: true, |
| 6655 | resumeConfig: &Config{ |
| 6656 | MaxVersion: VersionTLS12, |
| 6657 | Bugs: ProtocolBugs{ |
| 6658 | FragmentAcrossChangeCipherSpec: true, |
| 6659 | PackHandshakeFlight: packed, |
| 6660 | }, |
| 6661 | }, |
| 6662 | shouldFail: true, |
| 6663 | expectedError: ":UNEXPECTED_RECORD:", |
| 6664 | }) |
| 6665 | testCases = append(testCases, testCase{ |
| 6666 | testType: serverTest, |
| 6667 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 6668 | config: Config{ |
| 6669 | MaxVersion: VersionTLS12, |
| 6670 | Bugs: ProtocolBugs{ |
| 6671 | FragmentAcrossChangeCipherSpec: true, |
| 6672 | PackHandshakeFlight: packed, |
| 6673 | }, |
| 6674 | }, |
| 6675 | shouldFail: true, |
| 6676 | expectedError: ":UNEXPECTED_RECORD:", |
| 6677 | }) |
| 6678 | testCases = append(testCases, testCase{ |
| 6679 | testType: serverTest, |
| 6680 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 6681 | config: Config{ |
| 6682 | MaxVersion: VersionTLS12, |
| 6683 | }, |
| 6684 | resumeSession: true, |
| 6685 | resumeConfig: &Config{ |
| 6686 | MaxVersion: VersionTLS12, |
| 6687 | Bugs: ProtocolBugs{ |
| 6688 | FragmentAcrossChangeCipherSpec: true, |
| 6689 | PackHandshakeFlight: packed, |
| 6690 | }, |
| 6691 | }, |
| 6692 | shouldFail: true, |
| 6693 | expectedError: ":UNEXPECTED_RECORD:", |
| 6694 | }) |
| 6695 | testCases = append(testCases, testCase{ |
| 6696 | testType: serverTest, |
| 6697 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 6698 | config: Config{ |
| 6699 | MaxVersion: VersionTLS12, |
| 6700 | NextProtos: []string{"bar"}, |
| 6701 | Bugs: ProtocolBugs{ |
| 6702 | FragmentAcrossChangeCipherSpec: true, |
| 6703 | PackHandshakeFlight: packed, |
| 6704 | }, |
| 6705 | }, |
| 6706 | flags: []string{ |
| 6707 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 6708 | }, |
| 6709 | shouldFail: true, |
| 6710 | expectedError: ":UNEXPECTED_RECORD:", |
| 6711 | }) |
| 6712 | } |
| 6713 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 6714 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 6715 | // messages in the handshake queue. Do this by testing the server |
| 6716 | // reading the client Finished, reversing the flight so Finished comes |
| 6717 | // first. |
| 6718 | testCases = append(testCases, testCase{ |
| 6719 | protocol: dtls, |
| 6720 | testType: serverTest, |
| 6721 | name: "SendUnencryptedFinished-DTLS", |
| 6722 | config: Config{ |
| 6723 | MaxVersion: VersionTLS12, |
| 6724 | Bugs: ProtocolBugs{ |
| 6725 | SendUnencryptedFinished: true, |
| 6726 | ReverseHandshakeFragments: true, |
| 6727 | }, |
| 6728 | }, |
| 6729 | shouldFail: true, |
| 6730 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 6731 | }) |
| 6732 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 6733 | // Test synchronization between encryption changes and the handshake in |
| 6734 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 6735 | testCases = append(testCases, testCase{ |
| 6736 | name: "PartialEncryptedExtensionsWithServerHello", |
| 6737 | config: Config{ |
| 6738 | MaxVersion: VersionTLS13, |
| 6739 | Bugs: ProtocolBugs{ |
| 6740 | PartialEncryptedExtensionsWithServerHello: true, |
| 6741 | }, |
| 6742 | }, |
| 6743 | shouldFail: true, |
| 6744 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 6745 | }) |
| 6746 | testCases = append(testCases, testCase{ |
| 6747 | testType: serverTest, |
| 6748 | name: "PartialClientFinishedWithClientHello", |
| 6749 | config: Config{ |
| 6750 | MaxVersion: VersionTLS13, |
| 6751 | Bugs: ProtocolBugs{ |
| 6752 | PartialClientFinishedWithClientHello: true, |
| 6753 | }, |
| 6754 | }, |
| 6755 | shouldFail: true, |
| 6756 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 6757 | }) |
| 6758 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 6759 | // Test that early ChangeCipherSpecs are handled correctly. |
| 6760 | testCases = append(testCases, testCase{ |
| 6761 | testType: serverTest, |
| 6762 | name: "EarlyChangeCipherSpec-server-1", |
| 6763 | config: Config{ |
| 6764 | MaxVersion: VersionTLS12, |
| 6765 | Bugs: ProtocolBugs{ |
| 6766 | EarlyChangeCipherSpec: 1, |
| 6767 | }, |
| 6768 | }, |
| 6769 | shouldFail: true, |
| 6770 | expectedError: ":UNEXPECTED_RECORD:", |
| 6771 | }) |
| 6772 | testCases = append(testCases, testCase{ |
| 6773 | testType: serverTest, |
| 6774 | name: "EarlyChangeCipherSpec-server-2", |
| 6775 | config: Config{ |
| 6776 | MaxVersion: VersionTLS12, |
| 6777 | Bugs: ProtocolBugs{ |
| 6778 | EarlyChangeCipherSpec: 2, |
| 6779 | }, |
| 6780 | }, |
| 6781 | shouldFail: true, |
| 6782 | expectedError: ":UNEXPECTED_RECORD:", |
| 6783 | }) |
| 6784 | testCases = append(testCases, testCase{ |
| 6785 | protocol: dtls, |
| 6786 | name: "StrayChangeCipherSpec", |
| 6787 | config: Config{ |
| 6788 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 6789 | // that stray ChangeCipherSpec messages are |
| 6790 | // rejected. |
| 6791 | MaxVersion: VersionTLS12, |
| 6792 | Bugs: ProtocolBugs{ |
| 6793 | StrayChangeCipherSpec: true, |
| 6794 | }, |
| 6795 | }, |
| 6796 | }) |
| 6797 | |
| 6798 | // Test that the contents of ChangeCipherSpec are checked. |
| 6799 | testCases = append(testCases, testCase{ |
| 6800 | name: "BadChangeCipherSpec-1", |
| 6801 | config: Config{ |
| 6802 | MaxVersion: VersionTLS12, |
| 6803 | Bugs: ProtocolBugs{ |
| 6804 | BadChangeCipherSpec: []byte{2}, |
| 6805 | }, |
| 6806 | }, |
| 6807 | shouldFail: true, |
| 6808 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 6809 | }) |
| 6810 | testCases = append(testCases, testCase{ |
| 6811 | name: "BadChangeCipherSpec-2", |
| 6812 | config: Config{ |
| 6813 | MaxVersion: VersionTLS12, |
| 6814 | Bugs: ProtocolBugs{ |
| 6815 | BadChangeCipherSpec: []byte{1, 1}, |
| 6816 | }, |
| 6817 | }, |
| 6818 | shouldFail: true, |
| 6819 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 6820 | }) |
| 6821 | testCases = append(testCases, testCase{ |
| 6822 | protocol: dtls, |
| 6823 | name: "BadChangeCipherSpec-DTLS-1", |
| 6824 | config: Config{ |
| 6825 | MaxVersion: VersionTLS12, |
| 6826 | Bugs: ProtocolBugs{ |
| 6827 | BadChangeCipherSpec: []byte{2}, |
| 6828 | }, |
| 6829 | }, |
| 6830 | shouldFail: true, |
| 6831 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 6832 | }) |
| 6833 | testCases = append(testCases, testCase{ |
| 6834 | protocol: dtls, |
| 6835 | name: "BadChangeCipherSpec-DTLS-2", |
| 6836 | config: Config{ |
| 6837 | MaxVersion: VersionTLS12, |
| 6838 | Bugs: ProtocolBugs{ |
| 6839 | BadChangeCipherSpec: []byte{1, 1}, |
| 6840 | }, |
| 6841 | }, |
| 6842 | shouldFail: true, |
| 6843 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 6844 | }) |
| 6845 | } |
| 6846 | |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 6847 | func addWrongMessageTypeTests() { |
| 6848 | for _, protocol := range []protocol{tls, dtls} { |
| 6849 | var suffix string |
| 6850 | if protocol == dtls { |
| 6851 | suffix = "-DTLS" |
| 6852 | } |
| 6853 | |
| 6854 | testCases = append(testCases, testCase{ |
| 6855 | protocol: protocol, |
| 6856 | testType: serverTest, |
| 6857 | name: "WrongMessageType-ClientHello" + suffix, |
| 6858 | config: Config{ |
| 6859 | MaxVersion: VersionTLS12, |
| 6860 | Bugs: ProtocolBugs{ |
| 6861 | SendWrongMessageType: typeClientHello, |
| 6862 | }, |
| 6863 | }, |
| 6864 | shouldFail: true, |
| 6865 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6866 | expectedLocalError: "remote error: unexpected message", |
| 6867 | }) |
| 6868 | |
| 6869 | if protocol == dtls { |
| 6870 | testCases = append(testCases, testCase{ |
| 6871 | protocol: protocol, |
| 6872 | name: "WrongMessageType-HelloVerifyRequest" + suffix, |
| 6873 | config: Config{ |
| 6874 | MaxVersion: VersionTLS12, |
| 6875 | Bugs: ProtocolBugs{ |
| 6876 | SendWrongMessageType: typeHelloVerifyRequest, |
| 6877 | }, |
| 6878 | }, |
| 6879 | shouldFail: true, |
| 6880 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6881 | expectedLocalError: "remote error: unexpected message", |
| 6882 | }) |
| 6883 | } |
| 6884 | |
| 6885 | testCases = append(testCases, testCase{ |
| 6886 | protocol: protocol, |
| 6887 | name: "WrongMessageType-ServerHello" + suffix, |
| 6888 | config: Config{ |
| 6889 | MaxVersion: VersionTLS12, |
| 6890 | Bugs: ProtocolBugs{ |
| 6891 | SendWrongMessageType: typeServerHello, |
| 6892 | }, |
| 6893 | }, |
| 6894 | shouldFail: true, |
| 6895 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6896 | expectedLocalError: "remote error: unexpected message", |
| 6897 | }) |
| 6898 | |
| 6899 | testCases = append(testCases, testCase{ |
| 6900 | protocol: protocol, |
| 6901 | name: "WrongMessageType-ServerCertificate" + suffix, |
| 6902 | config: Config{ |
| 6903 | MaxVersion: VersionTLS12, |
| 6904 | Bugs: ProtocolBugs{ |
| 6905 | SendWrongMessageType: typeCertificate, |
| 6906 | }, |
| 6907 | }, |
| 6908 | shouldFail: true, |
| 6909 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6910 | expectedLocalError: "remote error: unexpected message", |
| 6911 | }) |
| 6912 | |
| 6913 | testCases = append(testCases, testCase{ |
| 6914 | protocol: protocol, |
| 6915 | name: "WrongMessageType-CertificateStatus" + suffix, |
| 6916 | config: Config{ |
| 6917 | MaxVersion: VersionTLS12, |
| 6918 | Bugs: ProtocolBugs{ |
| 6919 | SendWrongMessageType: typeCertificateStatus, |
| 6920 | }, |
| 6921 | }, |
| 6922 | flags: []string{"-enable-ocsp-stapling"}, |
| 6923 | shouldFail: true, |
| 6924 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6925 | expectedLocalError: "remote error: unexpected message", |
| 6926 | }) |
| 6927 | |
| 6928 | testCases = append(testCases, testCase{ |
| 6929 | protocol: protocol, |
| 6930 | name: "WrongMessageType-ServerKeyExchange" + suffix, |
| 6931 | config: Config{ |
| 6932 | MaxVersion: VersionTLS12, |
| 6933 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6934 | Bugs: ProtocolBugs{ |
| 6935 | SendWrongMessageType: typeServerKeyExchange, |
| 6936 | }, |
| 6937 | }, |
| 6938 | shouldFail: true, |
| 6939 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6940 | expectedLocalError: "remote error: unexpected message", |
| 6941 | }) |
| 6942 | |
| 6943 | testCases = append(testCases, testCase{ |
| 6944 | protocol: protocol, |
| 6945 | name: "WrongMessageType-CertificateRequest" + suffix, |
| 6946 | config: Config{ |
| 6947 | MaxVersion: VersionTLS12, |
| 6948 | ClientAuth: RequireAnyClientCert, |
| 6949 | Bugs: ProtocolBugs{ |
| 6950 | SendWrongMessageType: typeCertificateRequest, |
| 6951 | }, |
| 6952 | }, |
| 6953 | shouldFail: true, |
| 6954 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6955 | expectedLocalError: "remote error: unexpected message", |
| 6956 | }) |
| 6957 | |
| 6958 | testCases = append(testCases, testCase{ |
| 6959 | protocol: protocol, |
| 6960 | name: "WrongMessageType-ServerHelloDone" + suffix, |
| 6961 | config: Config{ |
| 6962 | MaxVersion: VersionTLS12, |
| 6963 | Bugs: ProtocolBugs{ |
| 6964 | SendWrongMessageType: typeServerHelloDone, |
| 6965 | }, |
| 6966 | }, |
| 6967 | shouldFail: true, |
| 6968 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6969 | expectedLocalError: "remote error: unexpected message", |
| 6970 | }) |
| 6971 | |
| 6972 | testCases = append(testCases, testCase{ |
| 6973 | testType: serverTest, |
| 6974 | protocol: protocol, |
| 6975 | name: "WrongMessageType-ClientCertificate" + suffix, |
| 6976 | config: Config{ |
| 6977 | Certificates: []Certificate{rsaCertificate}, |
| 6978 | MaxVersion: VersionTLS12, |
| 6979 | Bugs: ProtocolBugs{ |
| 6980 | SendWrongMessageType: typeCertificate, |
| 6981 | }, |
| 6982 | }, |
| 6983 | flags: []string{"-require-any-client-certificate"}, |
| 6984 | shouldFail: true, |
| 6985 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6986 | expectedLocalError: "remote error: unexpected message", |
| 6987 | }) |
| 6988 | |
| 6989 | testCases = append(testCases, testCase{ |
| 6990 | testType: serverTest, |
| 6991 | protocol: protocol, |
| 6992 | name: "WrongMessageType-CertificateVerify" + suffix, |
| 6993 | config: Config{ |
| 6994 | Certificates: []Certificate{rsaCertificate}, |
| 6995 | MaxVersion: VersionTLS12, |
| 6996 | Bugs: ProtocolBugs{ |
| 6997 | SendWrongMessageType: typeCertificateVerify, |
| 6998 | }, |
| 6999 | }, |
| 7000 | flags: []string{"-require-any-client-certificate"}, |
| 7001 | shouldFail: true, |
| 7002 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7003 | expectedLocalError: "remote error: unexpected message", |
| 7004 | }) |
| 7005 | |
| 7006 | testCases = append(testCases, testCase{ |
| 7007 | testType: serverTest, |
| 7008 | protocol: protocol, |
| 7009 | name: "WrongMessageType-ClientKeyExchange" + suffix, |
| 7010 | config: Config{ |
| 7011 | MaxVersion: VersionTLS12, |
| 7012 | Bugs: ProtocolBugs{ |
| 7013 | SendWrongMessageType: typeClientKeyExchange, |
| 7014 | }, |
| 7015 | }, |
| 7016 | shouldFail: true, |
| 7017 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7018 | expectedLocalError: "remote error: unexpected message", |
| 7019 | }) |
| 7020 | |
| 7021 | if protocol != dtls { |
| 7022 | testCases = append(testCases, testCase{ |
| 7023 | testType: serverTest, |
| 7024 | protocol: protocol, |
| 7025 | name: "WrongMessageType-NextProtocol" + suffix, |
| 7026 | config: Config{ |
| 7027 | MaxVersion: VersionTLS12, |
| 7028 | NextProtos: []string{"bar"}, |
| 7029 | Bugs: ProtocolBugs{ |
| 7030 | SendWrongMessageType: typeNextProtocol, |
| 7031 | }, |
| 7032 | }, |
| 7033 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 7034 | shouldFail: true, |
| 7035 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7036 | expectedLocalError: "remote error: unexpected message", |
| 7037 | }) |
| 7038 | |
| 7039 | testCases = append(testCases, testCase{ |
| 7040 | testType: serverTest, |
| 7041 | protocol: protocol, |
| 7042 | name: "WrongMessageType-ChannelID" + suffix, |
| 7043 | config: Config{ |
| 7044 | MaxVersion: VersionTLS12, |
| 7045 | ChannelID: channelIDKey, |
| 7046 | Bugs: ProtocolBugs{ |
| 7047 | SendWrongMessageType: typeChannelID, |
| 7048 | }, |
| 7049 | }, |
| 7050 | flags: []string{ |
| 7051 | "-expect-channel-id", |
| 7052 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 7053 | }, |
| 7054 | shouldFail: true, |
| 7055 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7056 | expectedLocalError: "remote error: unexpected message", |
| 7057 | }) |
| 7058 | } |
| 7059 | |
| 7060 | testCases = append(testCases, testCase{ |
| 7061 | testType: serverTest, |
| 7062 | protocol: protocol, |
| 7063 | name: "WrongMessageType-ClientFinished" + suffix, |
| 7064 | config: Config{ |
| 7065 | MaxVersion: VersionTLS12, |
| 7066 | Bugs: ProtocolBugs{ |
| 7067 | SendWrongMessageType: typeFinished, |
| 7068 | }, |
| 7069 | }, |
| 7070 | shouldFail: true, |
| 7071 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7072 | expectedLocalError: "remote error: unexpected message", |
| 7073 | }) |
| 7074 | |
| 7075 | testCases = append(testCases, testCase{ |
| 7076 | protocol: protocol, |
| 7077 | name: "WrongMessageType-NewSessionTicket" + suffix, |
| 7078 | config: Config{ |
| 7079 | MaxVersion: VersionTLS12, |
| 7080 | Bugs: ProtocolBugs{ |
| 7081 | SendWrongMessageType: typeNewSessionTicket, |
| 7082 | }, |
| 7083 | }, |
| 7084 | shouldFail: true, |
| 7085 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7086 | expectedLocalError: "remote error: unexpected message", |
| 7087 | }) |
| 7088 | |
| 7089 | testCases = append(testCases, testCase{ |
| 7090 | protocol: protocol, |
| 7091 | name: "WrongMessageType-ServerFinished" + suffix, |
| 7092 | config: Config{ |
| 7093 | MaxVersion: VersionTLS12, |
| 7094 | Bugs: ProtocolBugs{ |
| 7095 | SendWrongMessageType: typeFinished, |
| 7096 | }, |
| 7097 | }, |
| 7098 | shouldFail: true, |
| 7099 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7100 | expectedLocalError: "remote error: unexpected message", |
| 7101 | }) |
| 7102 | |
| 7103 | } |
| 7104 | } |
| 7105 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 7106 | func addTLS13WrongMessageTypeTests() { |
| 7107 | testCases = append(testCases, testCase{ |
| 7108 | testType: serverTest, |
| 7109 | name: "WrongMessageType-TLS13-ClientHello", |
| 7110 | config: Config{ |
| 7111 | MaxVersion: VersionTLS13, |
| 7112 | Bugs: ProtocolBugs{ |
| 7113 | SendWrongMessageType: typeClientHello, |
| 7114 | }, |
| 7115 | }, |
| 7116 | shouldFail: true, |
| 7117 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7118 | expectedLocalError: "remote error: unexpected message", |
| 7119 | }) |
| 7120 | |
| 7121 | testCases = append(testCases, testCase{ |
| 7122 | name: "WrongMessageType-TLS13-ServerHello", |
| 7123 | config: Config{ |
| 7124 | MaxVersion: VersionTLS13, |
| 7125 | Bugs: ProtocolBugs{ |
| 7126 | SendWrongMessageType: typeServerHello, |
| 7127 | }, |
| 7128 | }, |
| 7129 | shouldFail: true, |
| 7130 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7131 | // The alert comes in with the wrong encryption. |
| 7132 | expectedLocalError: "local error: bad record MAC", |
| 7133 | }) |
| 7134 | |
| 7135 | testCases = append(testCases, testCase{ |
| 7136 | name: "WrongMessageType-TLS13-EncryptedExtensions", |
| 7137 | config: Config{ |
| 7138 | MaxVersion: VersionTLS13, |
| 7139 | Bugs: ProtocolBugs{ |
| 7140 | SendWrongMessageType: typeEncryptedExtensions, |
| 7141 | }, |
| 7142 | }, |
| 7143 | shouldFail: true, |
| 7144 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7145 | expectedLocalError: "remote error: unexpected message", |
| 7146 | }) |
| 7147 | |
| 7148 | testCases = append(testCases, testCase{ |
| 7149 | name: "WrongMessageType-TLS13-CertificateRequest", |
| 7150 | config: Config{ |
| 7151 | MaxVersion: VersionTLS13, |
| 7152 | ClientAuth: RequireAnyClientCert, |
| 7153 | Bugs: ProtocolBugs{ |
| 7154 | SendWrongMessageType: typeCertificateRequest, |
| 7155 | }, |
| 7156 | }, |
| 7157 | shouldFail: true, |
| 7158 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7159 | expectedLocalError: "remote error: unexpected message", |
| 7160 | }) |
| 7161 | |
| 7162 | testCases = append(testCases, testCase{ |
| 7163 | name: "WrongMessageType-TLS13-ServerCertificate", |
| 7164 | config: Config{ |
| 7165 | MaxVersion: VersionTLS13, |
| 7166 | Bugs: ProtocolBugs{ |
| 7167 | SendWrongMessageType: typeCertificate, |
| 7168 | }, |
| 7169 | }, |
| 7170 | shouldFail: true, |
| 7171 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7172 | expectedLocalError: "remote error: unexpected message", |
| 7173 | }) |
| 7174 | |
| 7175 | testCases = append(testCases, testCase{ |
| 7176 | name: "WrongMessageType-TLS13-ServerCertificateVerify", |
| 7177 | config: Config{ |
| 7178 | MaxVersion: VersionTLS13, |
| 7179 | Bugs: ProtocolBugs{ |
| 7180 | SendWrongMessageType: typeCertificateVerify, |
| 7181 | }, |
| 7182 | }, |
| 7183 | shouldFail: true, |
| 7184 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7185 | expectedLocalError: "remote error: unexpected message", |
| 7186 | }) |
| 7187 | |
| 7188 | testCases = append(testCases, testCase{ |
| 7189 | name: "WrongMessageType-TLS13-ServerFinished", |
| 7190 | config: Config{ |
| 7191 | MaxVersion: VersionTLS13, |
| 7192 | Bugs: ProtocolBugs{ |
| 7193 | SendWrongMessageType: typeFinished, |
| 7194 | }, |
| 7195 | }, |
| 7196 | shouldFail: true, |
| 7197 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7198 | expectedLocalError: "remote error: unexpected message", |
| 7199 | }) |
| 7200 | |
| 7201 | testCases = append(testCases, testCase{ |
| 7202 | testType: serverTest, |
| 7203 | name: "WrongMessageType-TLS13-ClientCertificate", |
| 7204 | config: Config{ |
| 7205 | Certificates: []Certificate{rsaCertificate}, |
| 7206 | MaxVersion: VersionTLS13, |
| 7207 | Bugs: ProtocolBugs{ |
| 7208 | SendWrongMessageType: typeCertificate, |
| 7209 | }, |
| 7210 | }, |
| 7211 | flags: []string{"-require-any-client-certificate"}, |
| 7212 | shouldFail: true, |
| 7213 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7214 | expectedLocalError: "remote error: unexpected message", |
| 7215 | }) |
| 7216 | |
| 7217 | testCases = append(testCases, testCase{ |
| 7218 | testType: serverTest, |
| 7219 | name: "WrongMessageType-TLS13-ClientCertificateVerify", |
| 7220 | config: Config{ |
| 7221 | Certificates: []Certificate{rsaCertificate}, |
| 7222 | MaxVersion: VersionTLS13, |
| 7223 | Bugs: ProtocolBugs{ |
| 7224 | SendWrongMessageType: typeCertificateVerify, |
| 7225 | }, |
| 7226 | }, |
| 7227 | flags: []string{"-require-any-client-certificate"}, |
| 7228 | shouldFail: true, |
| 7229 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7230 | expectedLocalError: "remote error: unexpected message", |
| 7231 | }) |
| 7232 | |
| 7233 | testCases = append(testCases, testCase{ |
| 7234 | testType: serverTest, |
| 7235 | name: "WrongMessageType-TLS13-ClientFinished", |
| 7236 | config: Config{ |
| 7237 | MaxVersion: VersionTLS13, |
| 7238 | Bugs: ProtocolBugs{ |
| 7239 | SendWrongMessageType: typeFinished, |
| 7240 | }, |
| 7241 | }, |
| 7242 | shouldFail: true, |
| 7243 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7244 | expectedLocalError: "remote error: unexpected message", |
| 7245 | }) |
| 7246 | } |
| 7247 | |
| 7248 | func addTLS13HandshakeTests() { |
| 7249 | testCases = append(testCases, testCase{ |
| 7250 | testType: clientTest, |
| 7251 | name: "MissingKeyShare-Client", |
| 7252 | config: Config{ |
| 7253 | MaxVersion: VersionTLS13, |
| 7254 | Bugs: ProtocolBugs{ |
| 7255 | MissingKeyShare: true, |
| 7256 | }, |
| 7257 | }, |
| 7258 | shouldFail: true, |
| 7259 | expectedError: ":MISSING_KEY_SHARE:", |
| 7260 | }) |
| 7261 | |
| 7262 | testCases = append(testCases, testCase{ |
| 7263 | name: "MissingKeyShare-Server", |
| 7264 | config: Config{ |
| 7265 | MaxVersion: VersionTLS13, |
| 7266 | Bugs: ProtocolBugs{ |
| 7267 | MissingKeyShare: true, |
| 7268 | }, |
| 7269 | }, |
| 7270 | shouldFail: true, |
| 7271 | expectedError: ":MISSING_KEY_SHARE:", |
| 7272 | }) |
| 7273 | |
| 7274 | testCases = append(testCases, testCase{ |
| 7275 | testType: clientTest, |
| 7276 | name: "ClientHelloMissingKeyShare", |
| 7277 | config: Config{ |
| 7278 | MaxVersion: VersionTLS13, |
| 7279 | Bugs: ProtocolBugs{ |
| 7280 | MissingKeyShare: true, |
| 7281 | }, |
| 7282 | }, |
| 7283 | shouldFail: true, |
| 7284 | expectedError: ":MISSING_KEY_SHARE:", |
| 7285 | }) |
| 7286 | |
| 7287 | testCases = append(testCases, testCase{ |
| 7288 | testType: clientTest, |
| 7289 | name: "MissingKeyShare", |
| 7290 | config: Config{ |
| 7291 | MaxVersion: VersionTLS13, |
| 7292 | Bugs: ProtocolBugs{ |
| 7293 | MissingKeyShare: true, |
| 7294 | }, |
| 7295 | }, |
| 7296 | shouldFail: true, |
| 7297 | expectedError: ":MISSING_KEY_SHARE:", |
| 7298 | }) |
| 7299 | |
| 7300 | testCases = append(testCases, testCase{ |
| 7301 | testType: serverTest, |
| 7302 | name: "DuplicateKeyShares", |
| 7303 | config: Config{ |
| 7304 | MaxVersion: VersionTLS13, |
| 7305 | Bugs: ProtocolBugs{ |
| 7306 | DuplicateKeyShares: true, |
| 7307 | }, |
| 7308 | }, |
| 7309 | }) |
| 7310 | |
| 7311 | testCases = append(testCases, testCase{ |
| 7312 | testType: clientTest, |
| 7313 | name: "EmptyEncryptedExtensions", |
| 7314 | config: Config{ |
| 7315 | MaxVersion: VersionTLS13, |
| 7316 | Bugs: ProtocolBugs{ |
| 7317 | EmptyEncryptedExtensions: true, |
| 7318 | }, |
| 7319 | }, |
| 7320 | shouldFail: true, |
| 7321 | expectedLocalError: "remote error: error decoding message", |
| 7322 | }) |
| 7323 | |
| 7324 | testCases = append(testCases, testCase{ |
| 7325 | testType: clientTest, |
| 7326 | name: "EncryptedExtensionsWithKeyShare", |
| 7327 | config: Config{ |
| 7328 | MaxVersion: VersionTLS13, |
| 7329 | Bugs: ProtocolBugs{ |
| 7330 | EncryptedExtensionsWithKeyShare: true, |
| 7331 | }, |
| 7332 | }, |
| 7333 | shouldFail: true, |
| 7334 | expectedLocalError: "remote error: unsupported extension", |
| 7335 | }) |
| 7336 | } |
| 7337 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7338 | 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] | 7339 | defer wg.Done() |
| 7340 | |
| 7341 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 7342 | var err error |
| 7343 | |
| 7344 | if *mallocTest < 0 { |
| 7345 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7346 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 7347 | } else { |
| 7348 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 7349 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7350 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 7351 | if err != nil { |
| 7352 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 7353 | } |
| 7354 | break |
| 7355 | } |
| 7356 | } |
| 7357 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7358 | statusChan <- statusMsg{test: test, err: err} |
| 7359 | } |
| 7360 | } |
| 7361 | |
| 7362 | type statusMsg struct { |
| 7363 | test *testCase |
| 7364 | started bool |
| 7365 | err error |
| 7366 | } |
| 7367 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7368 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7369 | var started, done, failed, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7370 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7371 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7372 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7373 | if !*pipe { |
| 7374 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 7375 | var erase string |
| 7376 | for i := 0; i < lineLen; i++ { |
| 7377 | erase += "\b \b" |
| 7378 | } |
| 7379 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7380 | } |
| 7381 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7382 | if msg.started { |
| 7383 | started++ |
| 7384 | } else { |
| 7385 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7386 | |
| 7387 | if msg.err != nil { |
| 7388 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 7389 | failed++ |
| 7390 | testOutput.addResult(msg.test.name, "FAIL") |
| 7391 | } else { |
| 7392 | if *pipe { |
| 7393 | // Print each test instead of a status line. |
| 7394 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 7395 | } |
| 7396 | testOutput.addResult(msg.test.name, "PASS") |
| 7397 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7398 | } |
| 7399 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7400 | if !*pipe { |
| 7401 | // Print a new status line. |
| 7402 | line := fmt.Sprintf("%d/%d/%d/%d", failed, done, started, total) |
| 7403 | lineLen = len(line) |
| 7404 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7405 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7406 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7407 | |
| 7408 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7409 | } |
| 7410 | |
| 7411 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7412 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7413 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7414 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7415 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7416 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7417 | addCipherSuiteTests() |
| 7418 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7419 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 7420 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 7421 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 7422 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 7423 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 7424 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 7425 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 7426 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 7427 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7428 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7429 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7430 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7431 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7432 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7433 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7434 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7435 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7436 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7437 | addCECPQ1Tests() |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7438 | addKeyExchangeInfoTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 7439 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 7440 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7441 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7442 | addWrongMessageTypeTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame^] | 7443 | addTLS13WrongMessageTypeTests() |
| 7444 | addTLS13HandshakeTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7445 | |
| 7446 | var wg sync.WaitGroup |
| 7447 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7448 | statusChan := make(chan statusMsg, *numWorkers) |
| 7449 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7450 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7451 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 7452 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7453 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7454 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7455 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7456 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7457 | } |
| 7458 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7459 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 7460 | for i := range testCases { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7461 | if len(*testToRun) == 0 || *testToRun == testCases[i].name { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7462 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 7463 | testChan <- &testCases[i] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7464 | } |
| 7465 | } |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7466 | if !foundTest { |
| 7467 | fmt.Fprintf(os.Stderr, "No test named '%s'\n", *testToRun) |
| 7468 | os.Exit(1) |
| 7469 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7470 | |
| 7471 | close(testChan) |
| 7472 | wg.Wait() |
| 7473 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7474 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7475 | |
| 7476 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7477 | |
| 7478 | if *jsonOutput != "" { |
| 7479 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 7480 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 7481 | } |
| 7482 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 7483 | |
| 7484 | if !testOutput.allPassed { |
| 7485 | os.Exit(1) |
| 7486 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7487 | } |