| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/crypto/proof_verifier_chromium.h" | 5 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 CertPolicyEnforcer* cert_policy_enforcer, | 51 CertPolicyEnforcer* cert_policy_enforcer, |
| 52 TransportSecurityState* transport_security_state, | 52 TransportSecurityState* transport_security_state, |
| 53 int cert_verify_flags, | 53 int cert_verify_flags, |
| 54 const BoundNetLog& net_log); | 54 const BoundNetLog& net_log); |
| 55 | 55 |
| 56 // Starts the proof verification. If |QUIC_PENDING| is returned, then | 56 // Starts the proof verification. If |QUIC_PENDING| is returned, then |
| 57 // |callback| will be invoked asynchronously when the verification completes. | 57 // |callback| will be invoked asynchronously when the verification completes. |
| 58 QuicAsyncStatus VerifyProof(const std::string& hostname, | 58 QuicAsyncStatus VerifyProof(const std::string& hostname, |
| 59 const std::string& server_config, | 59 const std::string& server_config, |
| 60 const std::vector<std::string>& certs, | 60 const std::vector<std::string>& certs, |
| 61 const std::string& cert_sct, |
| 61 const std::string& signature, | 62 const std::string& signature, |
| 62 std::string* error_details, | 63 std::string* error_details, |
| 63 scoped_ptr<ProofVerifyDetails>* verify_details, | 64 scoped_ptr<ProofVerifyDetails>* verify_details, |
| 64 ProofVerifierCallback* callback); | 65 ProofVerifierCallback* callback); |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 enum State { | 68 enum State { |
| 68 STATE_NONE, | 69 STATE_NONE, |
| 69 STATE_VERIFY_CERT, | 70 STATE_VERIFY_CERT, |
| 70 STATE_VERIFY_CERT_COMPLETE, | 71 STATE_VERIFY_CERT_COMPLETE, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 policy_enforcer_(cert_policy_enforcer), | 124 policy_enforcer_(cert_policy_enforcer), |
| 124 transport_security_state_(transport_security_state), | 125 transport_security_state_(transport_security_state), |
| 125 cert_verify_flags_(cert_verify_flags), | 126 cert_verify_flags_(cert_verify_flags), |
| 126 next_state_(STATE_NONE), | 127 next_state_(STATE_NONE), |
| 127 net_log_(net_log) {} | 128 net_log_(net_log) {} |
| 128 | 129 |
| 129 QuicAsyncStatus ProofVerifierChromium::Job::VerifyProof( | 130 QuicAsyncStatus ProofVerifierChromium::Job::VerifyProof( |
| 130 const string& hostname, | 131 const string& hostname, |
| 131 const string& server_config, | 132 const string& server_config, |
| 132 const vector<string>& certs, | 133 const vector<string>& certs, |
| 134 const std::string& cert_sct, |
| 133 const string& signature, | 135 const string& signature, |
| 134 std::string* error_details, | 136 std::string* error_details, |
| 135 scoped_ptr<ProofVerifyDetails>* verify_details, | 137 scoped_ptr<ProofVerifyDetails>* verify_details, |
| 136 ProofVerifierCallback* callback) { | 138 ProofVerifierCallback* callback) { |
| 137 DCHECK(error_details); | 139 DCHECK(error_details); |
| 138 DCHECK(verify_details); | 140 DCHECK(verify_details); |
| 139 DCHECK(callback); | 141 DCHECK(callback); |
| 140 | 142 |
| 141 error_details->clear(); | 143 error_details->clear(); |
| 142 | 144 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 transport_security_state_(transport_security_state) {} | 377 transport_security_state_(transport_security_state) {} |
| 376 | 378 |
| 377 ProofVerifierChromium::~ProofVerifierChromium() { | 379 ProofVerifierChromium::~ProofVerifierChromium() { |
| 378 STLDeleteElements(&active_jobs_); | 380 STLDeleteElements(&active_jobs_); |
| 379 } | 381 } |
| 380 | 382 |
| 381 QuicAsyncStatus ProofVerifierChromium::VerifyProof( | 383 QuicAsyncStatus ProofVerifierChromium::VerifyProof( |
| 382 const std::string& hostname, | 384 const std::string& hostname, |
| 383 const std::string& server_config, | 385 const std::string& server_config, |
| 384 const std::vector<std::string>& certs, | 386 const std::vector<std::string>& certs, |
| 387 const std::string& cert_sct, |
| 385 const std::string& signature, | 388 const std::string& signature, |
| 386 const ProofVerifyContext* verify_context, | 389 const ProofVerifyContext* verify_context, |
| 387 std::string* error_details, | 390 std::string* error_details, |
| 388 scoped_ptr<ProofVerifyDetails>* verify_details, | 391 scoped_ptr<ProofVerifyDetails>* verify_details, |
| 389 ProofVerifierCallback* callback) { | 392 ProofVerifierCallback* callback) { |
| 390 if (!verify_context) { | 393 if (!verify_context) { |
| 391 *error_details = "Missing context"; | 394 *error_details = "Missing context"; |
| 392 return QUIC_FAILURE; | 395 return QUIC_FAILURE; |
| 393 } | 396 } |
| 394 const ProofVerifyContextChromium* chromium_context = | 397 const ProofVerifyContextChromium* chromium_context = |
| 395 reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); | 398 reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); |
| 396 scoped_ptr<Job> job(new Job( | 399 scoped_ptr<Job> job(new Job( |
| 397 this, cert_verifier_, cert_policy_enforcer_, transport_security_state_, | 400 this, cert_verifier_, cert_policy_enforcer_, transport_security_state_, |
| 398 chromium_context->cert_verify_flags, chromium_context->net_log)); | 401 chromium_context->cert_verify_flags, chromium_context->net_log)); |
| 399 QuicAsyncStatus status = | 402 QuicAsyncStatus status = |
| 400 job->VerifyProof(hostname, server_config, certs, signature, error_details, | 403 job->VerifyProof(hostname, server_config, certs, cert_sct, signature, |
| 401 verify_details, callback); | 404 error_details, verify_details, callback); |
| 402 if (status == QUIC_PENDING) { | 405 if (status == QUIC_PENDING) { |
| 403 active_jobs_.insert(job.release()); | 406 active_jobs_.insert(job.release()); |
| 404 } | 407 } |
| 405 return status; | 408 return status; |
| 406 } | 409 } |
| 407 | 410 |
| 408 void ProofVerifierChromium::OnJobComplete(Job* job) { | 411 void ProofVerifierChromium::OnJobComplete(Job* job) { |
| 409 active_jobs_.erase(job); | 412 active_jobs_.erase(job); |
| 410 delete job; | 413 delete job; |
| 411 } | 414 } |
| 412 | 415 |
| 413 } // namespace net | 416 } // namespace net |
| OLD | NEW |