Index: net/quic/test_tools/crypto_test_utils_chromium.cc |
=================================================================== |
--- net/quic/test_tools/crypto_test_utils_chromium.cc (revision 280648) |
+++ net/quic/test_tools/crypto_test_utils_chromium.cc (working copy) |
@@ -18,6 +18,8 @@ |
namespace test { |
+namespace { |
+ |
class TestProofVerifierChromium : public ProofVerifierChromium { |
public: |
TestProofVerifierChromium(CertVerifier* cert_verifier, |
@@ -36,6 +38,70 @@ |
scoped_ptr<CertVerifier> cert_verifier_; |
}; |
+const char kLeafCert[] = "leaf"; |
+const char kIntermediateCert[] = "intermediate"; |
+const char kSignature[] = "signature"; |
+ |
+class FakeProofSource : public ProofSource { |
+ public: |
+ FakeProofSource() : certs_(2) { |
+ certs_[0] = kLeafCert; |
+ certs_[1] = kIntermediateCert; |
+ } |
+ virtual ~FakeProofSource() {} |
+ |
+ // ProofSource interface |
+ virtual bool GetProof(const std::string& hostname, |
+ const std::string& server_config, |
+ bool ecdsa_ok, |
+ const std::vector<std::string>** out_certs, |
+ std::string* out_signature) OVERRIDE { |
+ *out_certs = &certs_; |
+ *out_signature = kSignature; |
+ return true; |
+ } |
+ |
+ private: |
+ std::vector<std::string> certs_; |
+ DISALLOW_COPY_AND_ASSIGN(FakeProofSource); |
+}; |
+ |
+class FakeProofVerifier : public ProofVerifier { |
+ public: |
+ FakeProofVerifier() {} |
+ virtual ~FakeProofVerifier() {} |
+ |
+ // ProofVerifier interface |
+ virtual QuicAsyncStatus VerifyProof( |
+ const std::string& hostname, |
+ const std::string& server_config, |
+ const std::vector<std::string>& certs, |
+ const std::string& signature, |
+ const ProofVerifyContext* verify_context, |
+ std::string* error_details, |
+ scoped_ptr<ProofVerifyDetails>* verify_details, |
+ ProofVerifierCallback* callback) OVERRIDE { |
+ error_details->clear(); |
+ scoped_ptr<ProofVerifyDetailsChromium> verify_details_chromium( |
+ new ProofVerifyDetailsChromium); |
+ if (certs.size() != 2 || certs[0] != kLeafCert || |
+ certs[1] != kIntermediateCert || signature != kSignature) { |
+ *error_details = "Invalid proof"; |
+ verify_details_chromium->cert_verify_result.cert_status = |
+ CERT_STATUS_INVALID; |
+ *verify_details = verify_details_chromium.Pass(); |
+ return QUIC_FAILURE; |
+ } |
+ *verify_details = verify_details_chromium.Pass(); |
+ return QUIC_SUCCESS; |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(FakeProofVerifier); |
+}; |
+ |
+} // namespace |
+ |
// static |
ProofSource* CryptoTestUtils::ProofSourceForTesting() { |
return new ProofSourceChromium(); |
@@ -53,6 +119,21 @@ |
return new ProofVerifyContextChromium(BoundNetLog()); |
} |
+// static |
+ProofSource* CryptoTestUtils::FakeProofSourceForTesting() { |
+ return new FakeProofSource(); |
+} |
+ |
+// static |
+ProofVerifier* CryptoTestUtils::FakeProofVerifierForTesting() { |
+ return new FakeProofVerifier(); |
+} |
+ |
+// static |
+ProofVerifyContext* CryptoTestUtils::FakeProofVerifyContextForTesting() { |
+ return NULL; |
+} |
+ |
} // namespace test |
} // namespace net |