OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/quic/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
6 | 6 |
7 #include <openssl/bn.h> | 7 #include <openssl/bn.h> |
8 #include <openssl/ec.h> | 8 #include <openssl/ec.h> |
9 #include <openssl/ecdsa.h> | 9 #include <openssl/ecdsa.h> |
10 #include <openssl/evp.h> | 10 #include <openssl/evp.h> |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 QuicCompressedCertsCache* compressed_certs_cache, | 284 QuicCompressedCertsCache* compressed_certs_cache, |
285 CryptoHandshakeMessage* out) | 285 CryptoHandshakeMessage* out) |
286 : crypto_config_(crypto_config), | 286 : crypto_config_(crypto_config), |
287 server_ip_(server_ip), | 287 server_ip_(server_ip), |
288 client_addr_(client_addr), | 288 client_addr_(client_addr), |
289 clock_(clock), | 289 clock_(clock), |
290 proof_(proof), | 290 proof_(proof), |
291 compressed_certs_cache_(compressed_certs_cache), | 291 compressed_certs_cache_(compressed_certs_cache), |
292 out_(out) {} | 292 out_(out) {} |
293 | 293 |
294 void RunImpl(const CryptoHandshakeMessage& client_hello, | 294 void RunImpl( |
295 const ValidateClientHelloResultCallback::Result& result, | 295 std::unique_ptr<ValidateClientHelloResultCallback::Result> result, |
296 std::unique_ptr<ProofSource::Details> /* details */) override { | 296 std::unique_ptr<ProofSource::Details> /* details */) override { |
297 QuicCryptoNegotiatedParameters params; | 297 QuicCryptoNegotiatedParameters params; |
298 string error_details; | 298 string error_details; |
299 DiversificationNonce diversification_nonce; | 299 DiversificationNonce diversification_nonce; |
300 CryptoHandshakeMessage rej; | 300 CryptoHandshakeMessage rej; |
301 crypto_config_->ProcessClientHello( | 301 crypto_config_->ProcessClientHello( |
302 result, /*reject_only=*/false, /*connection_id=*/1, server_ip_, | 302 *result, /*reject_only=*/false, /*connection_id=*/1, server_ip_, |
303 client_addr_, AllSupportedVersions().front(), AllSupportedVersions(), | 303 client_addr_, AllSupportedVersions().front(), AllSupportedVersions(), |
304 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0, | 304 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0, |
305 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, ¶ms, | 305 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, ¶ms, |
306 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej, | 306 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej, |
307 &diversification_nonce, &error_details); | 307 &diversification_nonce, &error_details); |
308 // Verify output is a REJ or SREJ. | 308 // Verify output is a REJ or SREJ. |
309 EXPECT_THAT(rej.tag(), | 309 EXPECT_THAT(rej.tag(), |
310 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ))); | 310 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ))); |
311 | 311 |
312 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString(); | 312 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString(); |
313 StringPiece srct; | 313 StringPiece srct; |
314 ASSERT_TRUE(rej.GetStringPiece(kSourceAddressTokenTag, &srct)); | 314 ASSERT_TRUE(rej.GetStringPiece(kSourceAddressTokenTag, &srct)); |
315 | 315 |
316 StringPiece scfg; | 316 StringPiece scfg; |
317 ASSERT_TRUE(rej.GetStringPiece(kSCFG, &scfg)); | 317 ASSERT_TRUE(rej.GetStringPiece(kSCFG, &scfg)); |
318 std::unique_ptr<CryptoHandshakeMessage> server_config( | 318 std::unique_ptr<CryptoHandshakeMessage> server_config( |
319 CryptoFramer::ParseMessage(scfg)); | 319 CryptoFramer::ParseMessage(scfg)); |
320 | 320 |
321 StringPiece scid; | 321 StringPiece scid; |
322 ASSERT_TRUE(server_config->GetStringPiece(kSCID, &scid)); | 322 ASSERT_TRUE(server_config->GetStringPiece(kSCID, &scid)); |
323 | 323 |
324 *out_ = client_hello; | 324 *out_ = result->client_hello; |
325 out_->SetStringPiece(kSCID, scid); | 325 out_->SetStringPiece(kSCID, scid); |
326 out_->SetStringPiece(kSourceAddressTokenTag, srct); | 326 out_->SetStringPiece(kSourceAddressTokenTag, srct); |
327 uint64_t xlct = CryptoTestUtils::LeafCertHashForTesting(); | 327 uint64_t xlct = CryptoTestUtils::LeafCertHashForTesting(); |
328 out_->SetValue(kXLCT, xlct); | 328 out_->SetValue(kXLCT, xlct); |
329 } | 329 } |
330 | 330 |
331 protected: | 331 protected: |
332 QuicCryptoServerConfig* crypto_config_; | 332 QuicCryptoServerConfig* crypto_config_; |
333 IPAddress server_ip_; | 333 IPAddress server_ip_; |
334 IPEndPoint client_addr_; | 334 IPEndPoint client_addr_; |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 CryptoHandshakeMessage* out) { | 965 CryptoHandshakeMessage* out) { |
966 // Pass a inchoate CHLO. | 966 // Pass a inchoate CHLO. |
967 crypto_config->ValidateClientHello( | 967 crypto_config->ValidateClientHello( |
968 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, | 968 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, |
969 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof, | 969 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof, |
970 compressed_certs_cache, out)); | 970 compressed_certs_cache, out)); |
971 } | 971 } |
972 | 972 |
973 } // namespace test | 973 } // namespace test |
974 } // namespace net | 974 } // namespace net |
OLD | NEW |