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

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

Issue 2011983004: Add a new CryptoTestUtils::LeafCertHashForTesting for generating expected leaf cert hashes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@122750844
Patch Set: Created 4 years, 6 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
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // static 440 // static
441 string CryptoTestUtils::GetValueForTag(const CryptoHandshakeMessage& message, 441 string CryptoTestUtils::GetValueForTag(const CryptoHandshakeMessage& message,
442 QuicTag tag) { 442 QuicTag tag) {
443 QuicTagValueMap::const_iterator it = message.tag_value_map().find(tag); 443 QuicTagValueMap::const_iterator it = message.tag_value_map().find(tag);
444 if (it == message.tag_value_map().end()) { 444 if (it == message.tag_value_map().end()) {
445 return string(); 445 return string();
446 } 446 }
447 return it->second; 447 return it->second;
448 } 448 }
449 449
450 uint64_t CryptoTestUtils::LeafCertHashForTesting() {
451 scoped_refptr<ProofSource::Chain> chain;
452 IPAddress server_ip;
453 string sig;
454 string cert_sct;
455 std::unique_ptr<ProofSource> proof_source(
456 CryptoTestUtils::ProofSourceForTesting());
457 if (!proof_source->GetProof(server_ip, "", "",
458 QuicSupportedVersions().front(), "", false,
459 &chain, &sig, &cert_sct) ||
460 chain->certs.empty()) {
461 DCHECK(false) << "Proof generation failed";
462 return 0;
463 }
464
465 return QuicUtils::FNV1a_64_Hash(chain->certs.at(0).c_str(),
466 chain->certs.at(0).length());
467 }
468
450 class MockCommonCertSets : public CommonCertSets { 469 class MockCommonCertSets : public CommonCertSets {
451 public: 470 public:
452 MockCommonCertSets(StringPiece cert, uint64_t hash, uint32_t index) 471 MockCommonCertSets(StringPiece cert, uint64_t hash, uint32_t index)
453 : cert_(cert.as_string()), hash_(hash), index_(index) {} 472 : cert_(cert.as_string()), hash_(hash), index_(index) {}
454 473
455 StringPiece GetCommonHashes() const override { 474 StringPiece GetCommonHashes() const override {
456 CHECK(false) << "not implemented"; 475 CHECK(false) << "not implemented";
457 return StringPiece(); 476 return StringPiece();
458 } 477 }
459 478
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 821
803 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining()); 822 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining());
804 823
805 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) { 824 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) {
806 dest_stream->OnHandshakeMessage(message); 825 dest_stream->OnHandshakeMessage(message);
807 } 826 }
808 } 827 }
809 828
810 } // namespace test 829 } // namespace test
811 } // namespace net 830 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698