Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: net/quic/test_tools/crypto_test_utils.cc

Issue 2334363002: Landing Recent QUIC changes until Sat Sep 10 00:32:41 (Closed)
Patch Set: Revase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 QuicCompressedCertsCache* compressed_certs_cache, 285 QuicCompressedCertsCache* compressed_certs_cache,
286 CryptoHandshakeMessage* out) 286 CryptoHandshakeMessage* out)
287 : crypto_config_(crypto_config), 287 : crypto_config_(crypto_config),
288 server_ip_(server_ip), 288 server_ip_(server_ip),
289 client_addr_(client_addr), 289 client_addr_(client_addr),
290 clock_(clock), 290 clock_(clock),
291 proof_(proof), 291 proof_(proof),
292 compressed_certs_cache_(compressed_certs_cache), 292 compressed_certs_cache_(compressed_certs_cache),
293 out_(out) {} 293 out_(out) {}
294 294
295 void RunImpl(const CryptoHandshakeMessage& client_hello, 295 void Run(std::unique_ptr<ValidateClientHelloResultCallback::Result> result,
296 const ValidateClientHelloResultCallback::Result& result, 296 std::unique_ptr<ProofSource::Details> /* details */) override {
297 std::unique_ptr<ProofSource::Details> /* details */) override {
298 QuicCryptoNegotiatedParameters params; 297 QuicCryptoNegotiatedParameters params;
299 string error_details; 298 string error_details;
300 DiversificationNonce diversification_nonce; 299 DiversificationNonce diversification_nonce;
301 CryptoHandshakeMessage rej; 300 CryptoHandshakeMessage rej;
302 crypto_config_->ProcessClientHello( 301 crypto_config_->ProcessClientHello(
303 result, /*reject_only=*/false, /*connection_id=*/1, server_ip_, 302 *result, /*reject_only=*/false, /*connection_id=*/1, server_ip_,
304 client_addr_, AllSupportedVersions().front(), AllSupportedVersions(), 303 client_addr_, AllSupportedVersions().front(), AllSupportedVersions(),
305 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0, 304 /*use_stateless_rejects=*/true, /*server_designated_connection_id=*/0,
306 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, &params, 305 clock_, QuicRandom::GetInstance(), compressed_certs_cache_, &params,
307 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej, 306 proof_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize, &rej,
308 &diversification_nonce, &error_details); 307 &diversification_nonce, &error_details);
309 // Verify output is a REJ or SREJ. 308 // Verify output is a REJ or SREJ.
310 EXPECT_THAT(rej.tag(), 309 EXPECT_THAT(rej.tag(),
311 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ))); 310 testing::AnyOf(testing::Eq(kSREJ), testing::Eq(kREJ)));
312 311
313 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString(); 312 VLOG(1) << "Extract valid STK and SCID from\n" << rej.DebugString();
314 StringPiece srct; 313 StringPiece srct;
315 ASSERT_TRUE(rej.GetStringPiece(kSourceAddressTokenTag, &srct)); 314 ASSERT_TRUE(rej.GetStringPiece(kSourceAddressTokenTag, &srct));
316 315
317 StringPiece scfg; 316 StringPiece scfg;
318 ASSERT_TRUE(rej.GetStringPiece(kSCFG, &scfg)); 317 ASSERT_TRUE(rej.GetStringPiece(kSCFG, &scfg));
319 std::unique_ptr<CryptoHandshakeMessage> server_config( 318 std::unique_ptr<CryptoHandshakeMessage> server_config(
320 CryptoFramer::ParseMessage(scfg)); 319 CryptoFramer::ParseMessage(scfg));
321 320
322 StringPiece scid; 321 StringPiece scid;
323 ASSERT_TRUE(server_config->GetStringPiece(kSCID, &scid)); 322 ASSERT_TRUE(server_config->GetStringPiece(kSCID, &scid));
324 323
325 *out_ = client_hello; 324 *out_ = result->client_hello;
326 out_->SetStringPiece(kSCID, scid); 325 out_->SetStringPiece(kSCID, scid);
327 out_->SetStringPiece(kSourceAddressTokenTag, srct); 326 out_->SetStringPiece(kSourceAddressTokenTag, srct);
328 uint64_t xlct = CryptoTestUtils::LeafCertHashForTesting(); 327 uint64_t xlct = CryptoTestUtils::LeafCertHashForTesting();
329 out_->SetValue(kXLCT, xlct); 328 out_->SetValue(kXLCT, xlct);
330 } 329 }
331 330
332 protected: 331 protected:
333 QuicCryptoServerConfig* crypto_config_; 332 QuicCryptoServerConfig* crypto_config_;
334 IPAddress server_ip_; 333 IPAddress server_ip_;
335 IPEndPoint client_addr_; 334 IPEndPoint client_addr_;
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 IPAddress server_ip, 959 IPAddress server_ip,
961 IPEndPoint client_addr, 960 IPEndPoint client_addr,
962 QuicVersion version, 961 QuicVersion version,
963 const QuicClock* clock, 962 const QuicClock* clock,
964 QuicCryptoProof* proof, 963 QuicCryptoProof* proof,
965 QuicCompressedCertsCache* compressed_certs_cache, 964 QuicCompressedCertsCache* compressed_certs_cache,
966 CryptoHandshakeMessage* out) { 965 CryptoHandshakeMessage* out) {
967 // Pass a inchoate CHLO. 966 // Pass a inchoate CHLO.
968 crypto_config->ValidateClientHello( 967 crypto_config->ValidateClientHello(
969 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, 968 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof,
970 new FullChloGenerator(crypto_config, server_ip, client_addr, clock, proof, 969 std::unique_ptr<FullChloGenerator>(
971 compressed_certs_cache, out)); 970 new FullChloGenerator(crypto_config, server_ip, client_addr, clock,
971 proof, compressed_certs_cache, out)));
972 } 972 }
973 973
974 } // namespace test 974 } // namespace test
975 } // namespace net 975 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream_sequencer_test.cc ('k') | net/quic/test_tools/crypto_test_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698