OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "net/base/ip_endpoint.h" | 8 #include "net/base/ip_endpoint.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ASSERT_TRUE(expected_ok); | 83 ASSERT_TRUE(expected_ok); |
84 ASSERT_EQ("", error_details); | 84 ASSERT_EQ("", error_details); |
85 return; | 85 return; |
86 case QUIC_PENDING: | 86 case QUIC_PENDING: |
87 comp_callback.WaitForResult(); | 87 comp_callback.WaitForResult(); |
88 ASSERT_EQ(expected_ok, ok); | 88 ASSERT_EQ(expected_ok, ok); |
89 break; | 89 break; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 // Reads the certificate named "quic_" + |file_name| in the test data directory. | |
94 // The certificate must be PEM encoded. Returns the DER-encoded certificate. | |
95 string LoadTestCert(const string& file_name) { | |
96 base::FilePath certs_dir = GetTestCertsDirectory(); | |
97 scoped_refptr<X509Certificate> cert = | |
98 ImportCertFromFile(certs_dir, "quic_" + file_name); | |
99 CHECK_NE(static_cast<X509Certificate*>(nullptr), cert.get()); | |
100 | |
101 string der_bytes; | |
102 CHECK(X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_bytes)); | |
103 return der_bytes; | |
104 } | |
105 | |
106 class TestCallback : public ProofSource::Callback { | 93 class TestCallback : public ProofSource::Callback { |
107 public: | 94 public: |
108 explicit TestCallback(bool* called, | 95 explicit TestCallback(bool* called, |
109 bool* ok, | 96 bool* ok, |
110 scoped_refptr<ProofSource::Chain>* chain, | 97 scoped_refptr<ProofSource::Chain>* chain, |
111 string* signature, | 98 string* signature, |
112 string* leaf_cert_sct) | 99 string* leaf_cert_sct) |
113 : called_(called), | 100 : called_(called), |
114 ok_(ok), | 101 ok_(ok), |
115 chain_(chain), | 102 chain_(chain), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 151 |
165 ASSERT_TRUE(source->GetProof(server_ip, hostname, server_config, quic_version, | 152 ASSERT_TRUE(source->GetProof(server_ip, hostname, server_config, quic_version, |
166 first_chlo_hash, &first_chain, &first_signature, | 153 first_chlo_hash, &first_chain, &first_signature, |
167 &first_cert_sct)); | 154 &first_cert_sct)); |
168 ASSERT_TRUE(source->GetProof(server_ip, hostname, server_config, quic_version, | 155 ASSERT_TRUE(source->GetProof(server_ip, hostname, server_config, quic_version, |
169 second_chlo_hash, &chain, &signature, | 156 second_chlo_hash, &chain, &signature, |
170 &cert_sct)); | 157 &cert_sct)); |
171 | 158 |
172 // Check that the proof source is caching correctly: | 159 // Check that the proof source is caching correctly: |
173 ASSERT_EQ(first_chain->certs, chain->certs); | 160 ASSERT_EQ(first_chain->certs, chain->certs); |
174 if (GetParam() < QUIC_VERSION_31) { | 161 ASSERT_NE(signature, first_signature); |
175 ASSERT_EQ(signature, first_signature); | |
176 } else { | |
177 // QUIC 31 includes the CHLO hash. | |
178 ASSERT_NE(signature, first_signature); | |
179 } | |
180 ASSERT_EQ(first_cert_sct, cert_sct); | 162 ASSERT_EQ(first_cert_sct, cert_sct); |
181 | 163 |
182 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | 164 RunVerification(verifier.get(), hostname, port, server_config, quic_version, |
183 first_chlo_hash, chain->certs, signature, true); | 165 first_chlo_hash, chain->certs, signature, true); |
184 | 166 |
185 RunVerification(verifier.get(), "foo.com", port, server_config, quic_version, | 167 RunVerification(verifier.get(), "foo.com", port, server_config, quic_version, |
186 first_chlo_hash, chain->certs, signature, false); | 168 first_chlo_hash, chain->certs, signature, false); |
187 | 169 |
188 RunVerification(verifier.get(), server_config.substr(1, string::npos), port, | 170 RunVerification(verifier.get(), server_config.substr(1, string::npos), port, |
189 server_config, quic_version, first_chlo_hash, chain->certs, | 171 server_config, quic_version, first_chlo_hash, chain->certs, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 EXPECT_FALSE(chain->HasOneRef()); | 237 EXPECT_FALSE(chain->HasOneRef()); |
256 source = nullptr; | 238 source = nullptr; |
257 EXPECT_TRUE(chain->HasOneRef()); | 239 EXPECT_TRUE(chain->HasOneRef()); |
258 | 240 |
259 EXPECT_FALSE(chain->certs.empty()); | 241 EXPECT_FALSE(chain->certs.empty()); |
260 for (const string& cert : chain->certs) { | 242 for (const string& cert : chain->certs) { |
261 EXPECT_FALSE(cert.empty()); | 243 EXPECT_FALSE(cert.empty()); |
262 } | 244 } |
263 } | 245 } |
264 | 246 |
265 // A known answer test that allows us to test ProofVerifier without a working | |
266 // ProofSource. | |
267 TEST_P(ProofTest, VerifyRSAKnownAnswerTest) { | |
268 if (GetParam() > QUIC_VERSION_30) { | |
269 return; | |
270 } | |
271 // These sample signatures were generated by running the Proof.Verify test | |
272 // and dumping the bytes of the |signature| output of ProofSource::GetProof(). | |
273 static const unsigned char signature_data_0[] = { | |
274 0x31, 0xd5, 0xfb, 0x40, 0x30, 0x75, 0xd2, 0x7d, 0x61, 0xf9, 0xd7, 0x54, | |
275 0x30, 0x06, 0xaf, 0x54, 0x0d, 0xb0, 0x0a, 0xda, 0x63, 0xca, 0x7e, 0x9e, | |
276 0xce, 0xba, 0x10, 0x05, 0x1b, 0xa6, 0x7f, 0xef, 0x2b, 0xa3, 0xff, 0x3c, | |
277 0xbb, 0x9a, 0xe4, 0xbf, 0xb8, 0x0c, 0xc1, 0xbd, 0xed, 0xc2, 0x90, 0x68, | |
278 0xeb, 0x45, 0x48, 0xea, 0x3c, 0x95, 0xf8, 0xa2, 0xb9, 0xe7, 0x62, 0x29, | |
279 0x00, 0xc3, 0x18, 0xb4, 0x16, 0x6f, 0x5e, 0xb0, 0xc1, 0x26, 0xc0, 0x4b, | |
280 0x84, 0xf5, 0x97, 0xfc, 0x17, 0xf9, 0x1c, 0x43, 0xb8, 0xf2, 0x3f, 0x38, | |
281 0x32, 0xad, 0x36, 0x52, 0x2c, 0x26, 0x92, 0x7a, 0xea, 0x2c, 0xa2, 0xf4, | |
282 0x28, 0x2f, 0x19, 0x4d, 0x1f, 0x11, 0x46, 0x82, 0xd0, 0xc4, 0x86, 0x56, | |
283 0x5c, 0x97, 0x9e, 0xc6, 0x37, 0x8e, 0xaf, 0x9d, 0x69, 0xe9, 0x4f, 0x5a, | |
284 0x6d, 0x70, 0x75, 0xc7, 0x41, 0x95, 0x68, 0x53, 0x94, 0xca, 0x31, 0x63, | |
285 0x61, 0x9f, 0xb8, 0x8c, 0x3b, 0x75, 0x36, 0x8b, 0x69, 0xa2, 0x35, 0xc0, | |
286 0x4b, 0x77, 0x55, 0x08, 0xc2, 0xb4, 0x56, 0xd2, 0x81, 0xce, 0x9e, 0x25, | |
287 0xdb, 0x50, 0x74, 0xb3, 0x8a, 0xd9, 0x20, 0x42, 0x3f, 0x85, 0x2d, 0xaa, | |
288 0xfd, 0x66, 0xfa, 0xd6, 0x95, 0x55, 0x6b, 0x63, 0x63, 0x04, 0xf8, 0x6c, | |
289 0x3e, 0x08, 0x22, 0x39, 0xb9, 0x9a, 0xe0, 0xd7, 0x01, 0xff, 0xeb, 0x8a, | |
290 0xb9, 0xe2, 0x34, 0xa5, 0xa0, 0x51, 0xe9, 0xbe, 0x15, 0x12, 0xbf, 0xbe, | |
291 0x64, 0x3d, 0x3f, 0x98, 0xce, 0xc1, 0xa6, 0x33, 0x32, 0xd3, 0x5c, 0xa8, | |
292 0x39, 0x93, 0xdc, 0x1c, 0xb9, 0xab, 0x3c, 0x80, 0x62, 0xb3, 0x76, 0x21, | |
293 0xdf, 0x47, 0x1e, 0xa9, 0x0e, 0x5e, 0x8a, 0xbe, 0x66, 0x5b, 0x7c, 0x21, | |
294 0xfa, 0x78, 0x2d, 0xd1, 0x1d, 0x5c, 0x35, 0x8a, 0x34, 0xb2, 0x1a, 0xc2, | |
295 0xc4, 0x4b, 0x53, 0x54, | |
296 }; | |
297 static const unsigned char signature_data_1[] = { | |
298 0x01, 0x7b, 0x52, 0x35, 0xe3, 0x51, 0xdd, 0xf1, 0x67, 0x8d, 0x31, 0x5e, | |
299 0xa3, 0x75, 0x1f, 0x68, 0x6c, 0xdd, 0x41, 0x7a, 0x18, 0x25, 0xe0, 0x12, | |
300 0x6e, 0x84, 0x46, 0x5e, 0xb2, 0x98, 0xd7, 0x84, 0xe1, 0x62, 0xe0, 0xc1, | |
301 0xc4, 0xd7, 0x4f, 0x4f, 0x80, 0xc1, 0x92, 0xd6, 0x02, 0xaf, 0xca, 0x28, | |
302 0x9f, 0xe0, 0xf3, 0x74, 0xd7, 0xf1, 0x44, 0x67, 0x59, 0x27, 0xc8, 0xc2, | |
303 0x8b, 0xd4, 0xe5, 0x4a, 0x07, 0xfd, 0x00, 0xd6, 0x8a, 0xbf, 0x8b, 0xcd, | |
304 0x6a, 0xe0, 0x1d, 0xf6, 0x4b, 0x68, 0x0f, 0xcf, 0xb9, 0xd0, 0xa1, 0xbc, | |
305 0x2e, 0xcf, 0x7c, 0x03, 0x47, 0x11, 0xe4, 0x4c, 0xbc, 0x1b, 0x6b, 0xa5, | |
306 0x2a, 0x82, 0x86, 0xa4, 0x7f, 0x1d, 0x85, 0x64, 0x21, 0x10, 0xd2, 0xb2, | |
307 0xa0, 0x31, 0xa2, 0x78, 0xe6, 0xf2, 0xea, 0x96, 0x38, 0x8c, 0x9a, 0xe1, | |
308 0x01, 0xab, 0x8e, 0x95, 0x66, 0xc8, 0xe5, 0xcc, 0x80, 0xa3, 0xbd, 0x16, | |
309 0xa7, 0x79, 0x19, 0x39, 0x61, 0x3d, 0xff, 0x37, 0xca, 0x9f, 0x97, 0x05, | |
310 0xc7, 0xcb, 0xf0, 0xea, 0xaf, 0x64, 0x07, 0xc0, 0xed, 0x2a, 0x98, 0xa4, | |
311 0xaf, 0x04, 0x6f, 0xf2, 0xc9, 0xb2, 0x73, 0x9a, 0x56, 0x85, 0x43, 0x64, | |
312 0x5f, 0xaa, 0xb7, 0xff, 0x31, 0x4c, 0x2e, 0x6c, 0x17, 0xcf, 0xe5, 0xbe, | |
313 0x7f, 0x7e, 0xad, 0xf5, 0x6f, 0x84, 0x50, 0x20, 0x29, 0xb3, 0x57, 0xe7, | |
314 0xb1, 0xdc, 0x2c, 0x95, 0x48, 0xfe, 0xb0, 0xc1, 0x92, 0xda, 0xc5, 0x58, | |
315 0x95, 0xb0, 0x1a, 0x3a, 0x05, 0x71, 0x3c, 0x6d, 0x20, 0x01, 0x4c, 0xa9, | |
316 0xe4, 0x38, 0x08, 0x65, 0xb4, 0xbd, 0x86, 0x76, 0xbd, 0xad, 0x25, 0x06, | |
317 0x74, 0x0b, 0xca, 0x95, 0x27, 0x0c, 0x13, 0x08, 0x7e, 0x30, 0xcf, 0xf6, | |
318 0xb5, 0xc1, 0x2a, 0x08, 0xfc, 0x4b, 0xc6, 0xb5, 0x2f, 0x23, 0x27, 0x32, | |
319 0x89, 0xdb, 0x0e, 0x4a, | |
320 }; | |
321 static const unsigned char signature_data_2[] = { | |
322 0x6d, 0x7d, 0x22, 0x8c, 0x85, 0xc4, 0x8a, 0x80, 0x05, 0xe4, 0x3c, 0xaf, | |
323 0x10, 0x3b, 0xe3, 0x51, 0xb1, 0x86, 0x52, 0x63, 0xb6, 0x17, 0x33, 0xbd, | |
324 0x1b, 0x1e, 0xc4, 0x50, 0x10, 0xfc, 0xcc, 0xea, 0x6b, 0x11, 0xeb, 0x6d, | |
325 0x5e, 0x00, 0xe7, 0xf3, 0x67, 0x99, 0x74, 0x53, 0x12, 0x8f, 0xe4, 0x3e, | |
326 0x20, 0x17, 0x8e, 0x83, 0xe6, 0xdc, 0x83, 0x91, 0x0e, 0xf3, 0x69, 0x22, | |
327 0x95, 0x14, 0xdf, 0xc1, 0xda, 0xb5, 0xdb, 0x6a, 0x1a, 0xb4, 0x4f, 0x26, | |
328 0xd0, 0x32, 0x1d, 0x73, 0x95, 0x1f, 0x39, 0x1d, 0x00, 0xcb, 0xc3, 0x92, | |
329 0x49, 0x53, 0xcb, 0x5c, 0x36, 0x70, 0x19, 0xd9, 0x64, 0x36, 0xda, 0xfb, | |
330 0x20, 0xe5, 0x47, 0xd9, 0x08, 0xc6, 0x5a, 0x9e, 0x87, 0x1a, 0xdb, 0x11, | |
331 0x7b, 0x17, 0xfc, 0x53, 0x7b, 0xc1, 0xa0, 0xc0, 0x33, 0xcf, 0x96, 0xba, | |
332 0x03, 0x79, 0x8e, 0xc6, 0x05, 0xd2, 0xb7, 0xa2, 0xe2, 0xc1, 0x67, 0xb7, | |
333 0x6a, 0xeb, 0xb1, 0x40, 0xbb, 0x7d, 0x57, 0xcb, 0xc2, 0x60, 0x9f, 0xf1, | |
334 0x72, 0xe5, 0xad, 0xce, 0x95, 0x45, 0x7c, 0xbc, 0x75, 0x81, 0x45, 0x19, | |
335 0xe1, 0xa7, 0x2f, 0x05, 0x52, 0xeb, 0xed, 0xdd, 0x19, 0xd9, 0x1a, 0xc9, | |
336 0x5a, 0x06, 0x8e, 0x29, 0x54, 0xb5, 0x4f, 0x80, 0xaa, 0x36, 0x36, 0xc0, | |
337 0xff, 0x64, 0xac, 0xe8, 0x0f, 0x99, 0x35, 0x5e, 0xc6, 0x72, 0x1f, 0x8c, | |
338 0xc4, 0x2b, 0x7d, 0xc1, 0xfb, 0xf0, 0x12, 0x61, 0xb1, 0x18, 0x65, 0xdd, | |
339 0xc2, 0x38, 0x92, 0xba, 0x84, 0xf8, 0xc8, 0x5e, 0x17, 0x63, 0xe0, 0x9c, | |
340 0x2c, 0xe6, 0x70, 0x71, 0xdc, 0xe5, 0xc1, 0xea, 0xb3, 0x9a, 0xb6, 0x91, | |
341 0xdc, 0xc5, 0x56, 0x84, 0x8a, 0x31, 0x31, 0x23, 0x61, 0x94, 0x7e, 0x01, | |
342 0x22, 0x49, 0xf3, 0xcb, 0x0e, 0x31, 0x03, 0x04, 0x1b, 0x14, 0x43, 0x7c, | |
343 0xad, 0x42, 0xe5, 0x55, | |
344 }; | |
345 | |
346 std::unique_ptr<ProofVerifier> verifier( | |
347 CryptoTestUtils::RealProofVerifierForTesting()); | |
348 | |
349 const string server_config = "server config bytes"; | |
350 const string hostname = "test.example.com"; | |
351 const uint16_t port = 8443; | |
352 const string chlo_hash = "proof nonce bytes"; | |
353 const QuicVersion quic_version = GetParam(); | |
354 | |
355 vector<string> certs(2); | |
356 certs[0] = LoadTestCert("test.example.com.crt"); | |
357 certs[1] = LoadTestCert("intermediate.crt"); | |
358 | |
359 // Signatures are nondeterministic, so we test multiple signatures on the | |
360 // same server_config. | |
361 vector<string> signatures(3); | |
362 signatures[0].assign(reinterpret_cast<const char*>(signature_data_0), | |
363 sizeof(signature_data_0)); | |
364 signatures[1].assign(reinterpret_cast<const char*>(signature_data_1), | |
365 sizeof(signature_data_1)); | |
366 signatures[2].assign(reinterpret_cast<const char*>(signature_data_2), | |
367 sizeof(signature_data_2)); | |
368 | |
369 for (size_t i = 0; i < signatures.size(); i++) { | |
370 const string& signature = signatures[i]; | |
371 | |
372 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
373 chlo_hash, certs, signature, true); | |
374 RunVerification(verifier.get(), "foo.com", port, server_config, | |
375 quic_version, chlo_hash, certs, signature, false); | |
376 RunVerification(verifier.get(), hostname, port, | |
377 server_config.substr(1, string::npos), quic_version, | |
378 chlo_hash, certs, signature, false); | |
379 | |
380 const string corrupt_signature = "1" + signature; | |
381 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
382 chlo_hash, certs, corrupt_signature, false); | |
383 | |
384 vector<string> wrong_certs; | |
385 for (size_t i = 1; i < certs.size(); i++) { | |
386 wrong_certs.push_back(certs[i]); | |
387 } | |
388 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
389 chlo_hash, wrong_certs, signature, false); | |
390 } | |
391 } | |
392 | |
393 // A known answer test that allows us to test ProofVerifier without a working | |
394 // ProofSource. | |
395 TEST_P(ProofTest, VerifyECDSAKnownAnswerTest) { | |
396 if (GetParam() > QUIC_VERSION_30) { | |
397 return; | |
398 } | |
399 | |
400 // These sample signatures were generated by running the Proof.Verify test | |
401 // (modified to use ECDSA for signing proofs) and dumping the bytes of the | |
402 // |signature| output of ProofSource::GetProof(). | |
403 static const unsigned char signature_data_0[] = { | |
404 0x30, 0x45, 0x02, 0x21, 0x00, 0x89, 0xc4, 0x7d, 0x08, 0xd1, 0x49, 0x19, | |
405 0x6c, 0xd1, 0x7c, 0xb9, 0x25, 0xe0, 0xe3, 0xbd, 0x6a, 0x5c, 0xd7, 0xaa, | |
406 0x0c, 0xdc, 0x4f, 0x8e, 0xeb, 0xde, 0xbf, 0x32, 0xf8, 0xd1, 0x84, 0x95, | |
407 0x97, 0x02, 0x20, 0x29, 0x3d, 0x49, 0x22, 0x73, 0xed, 0x8b, 0xde, 0x3d, | |
408 0xc2, 0xa4, 0x20, 0xcc, 0xe7, 0xc8, 0x2a, 0x85, 0x20, 0x9b, 0x5b, 0xda, | |
409 0xcd, 0x58, 0x23, 0xbe, 0x89, 0x73, 0x31, 0x87, 0x51, 0xd1, 0x01, | |
410 }; | |
411 static const unsigned char signature_data_1[] = { | |
412 0x30, 0x46, 0x02, 0x21, 0x00, 0xec, 0xdf, 0x69, 0xc8, 0x24, 0x59, 0x93, | |
413 0xda, 0x49, 0xee, 0x37, 0x28, 0xaf, 0xeb, 0x0e, 0x2f, 0x80, 0x17, 0x4b, | |
414 0x3b, 0xf6, 0x54, 0xcd, 0x3b, 0x86, 0xc5, 0x98, 0x0d, 0xff, 0xc6, 0xb1, | |
415 0xe7, 0x02, 0x21, 0x00, 0xe1, 0x36, 0x8c, 0xc0, 0xf4, 0x50, 0x5f, 0xba, | |
416 0xfb, 0xe2, 0xff, 0x1d, 0x5d, 0x64, 0xe4, 0x07, 0xbb, 0x5a, 0x4b, 0x19, | |
417 0xb6, 0x39, 0x7a, 0xc4, 0x12, 0xc6, 0xe5, 0x42, 0xc8, 0x78, 0x33, 0xcd, | |
418 }; | |
419 static const unsigned char signature_data_2[] = { | |
420 0x30, 0x45, 0x02, 0x20, 0x09, 0x51, 0xe9, 0xde, 0xdb, 0x01, 0xfd, 0xb4, | |
421 0xd8, 0x20, 0xbb, 0xad, 0x41, 0xe3, 0xaa, 0xe7, 0xa3, 0xc3, 0x32, 0x10, | |
422 0x9d, 0xfa, 0x37, 0xce, 0x17, 0xd1, 0x29, 0xf9, 0xd4, 0x1d, 0x0d, 0x19, | |
423 0x02, 0x21, 0x00, 0xc6, 0x20, 0xd4, 0x28, 0xf9, 0x70, 0xb5, 0xb4, 0xff, | |
424 0x4a, 0x35, 0xba, 0xa0, 0xf2, 0x8e, 0x00, 0xf7, 0xcb, 0x43, 0xaf, 0x2d, | |
425 0x1f, 0xce, 0x92, 0x05, 0xca, 0x29, 0xfe, 0xd2, 0x8f, 0xd9, 0x31, | |
426 }; | |
427 | |
428 std::unique_ptr<ProofVerifier> verifier( | |
429 CryptoTestUtils::RealProofVerifierForTesting()); | |
430 | |
431 const string server_config = "server config bytes"; | |
432 const string hostname = "test.example.com"; | |
433 const uint16_t port = 8443; | |
434 const string chlo_hash = "chlo_hash nonce bytes"; | |
435 const QuicVersion quic_version = GetParam(); | |
436 | |
437 vector<string> certs(2); | |
438 certs[0] = LoadTestCert("test_ecc.example.com.crt"); | |
439 certs[1] = LoadTestCert("intermediate.crt"); | |
440 | |
441 // Signatures are nondeterministic, so we test multiple signatures on the | |
442 // same server_config. | |
443 vector<string> signatures(3); | |
444 signatures[0].assign(reinterpret_cast<const char*>(signature_data_0), | |
445 sizeof(signature_data_0)); | |
446 signatures[1].assign(reinterpret_cast<const char*>(signature_data_1), | |
447 sizeof(signature_data_1)); | |
448 signatures[2].assign(reinterpret_cast<const char*>(signature_data_2), | |
449 sizeof(signature_data_2)); | |
450 | |
451 for (size_t i = 0; i < signatures.size(); i++) { | |
452 const string& signature = signatures[i]; | |
453 | |
454 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
455 chlo_hash, certs, signature, true); | |
456 RunVerification(verifier.get(), "foo.com", port, server_config, | |
457 quic_version, chlo_hash, certs, signature, false); | |
458 RunVerification(verifier.get(), hostname, port, | |
459 server_config.substr(1, string::npos), quic_version, | |
460 chlo_hash, certs, signature, false); | |
461 | |
462 // An ECDSA signature is DER-encoded. Corrupt the last byte so that the | |
463 // signature can still be DER-decoded correctly. | |
464 string corrupt_signature = signature; | |
465 corrupt_signature.back()++; | |
466 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
467 chlo_hash, certs, corrupt_signature, false); | |
468 | |
469 // Prepending a "1" makes the DER invalid. | |
470 const string bad_der_signature1 = "1" + signature; | |
471 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
472 chlo_hash, certs, bad_der_signature1, false); | |
473 | |
474 vector<string> wrong_certs; | |
475 for (size_t i = 1; i < certs.size(); i++) { | |
476 wrong_certs.push_back(certs[i]); | |
477 } | |
478 RunVerification(verifier.get(), hostname, port, server_config, quic_version, | |
479 chlo_hash, wrong_certs, signature, false); | |
480 } | |
481 } | |
482 | |
483 } // namespace test | 247 } // namespace test |
484 } // namespace net | 248 } // namespace net |
OLD | NEW |