1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/quic/test_tools/crypto_test_utils.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "net/base/test_data_directory.h"
10 #include "net/cert/cert_verifier.h"
11 #include "net/cert/test_root_certs.h"
12 #include "net/cert/x509_certificate.h"
13 #include "net/http/transport_security_state.h"
14 #include "net/quic/crypto/proof_source_chromium.h"
15 #include "net/quic/crypto/proof_verifier_chromium.h"
16 #include "net/test/cert_test_util.h"
22 class TestProofVerifierChromium : public ProofVerifierChromium {
24 TestProofVerifierChromium(CertVerifier* cert_verifier,
25 TransportSecurityState* transport_security_state,
26 const std::string& cert_file)
27 : ProofVerifierChromium(cert_verifier, transport_security_state),
28 cert_verifier_(cert_verifier),
29 transport_security_state_(transport_security_state) {
30 // Load and install the root for the validated chain.
31 scoped_refptr<X509Certificate> root_cert =
32 ImportCertFromFile(GetTestCertsDirectory(), cert_file);
33 scoped_root_.Reset(root_cert.get());
35 virtual ~TestProofVerifierChromium() {}
38 ScopedTestRoot scoped_root_;
39 scoped_ptr<CertVerifier> cert_verifier_;
40 scoped_ptr<TransportSecurityState> transport_security_state_;
44 ProofSource* CryptoTestUtils::ProofSourceForTesting() {
45 return new ProofSourceChromium();
49 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() {
50 TestProofVerifierChromium* proof_verifier =
51 new TestProofVerifierChromium(CertVerifier::CreateDefault(),
52 new TransportSecurityState,
54 return proof_verifier;
58 ProofVerifyContext* CryptoTestUtils::ProofVerifyContextForTesting() {
59 return new ProofVerifyContextChromium(BoundNetLog());