| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 const std::string& hostname, | 69 const std::string& hostname, |
| 70 const uint16_t port, | 70 const uint16_t port, |
| 71 const std::string& server_config, | 71 const std::string& server_config, |
| 72 QuicVersion quic_version, | 72 QuicVersion quic_version, |
| 73 base::StringPiece chlo_hash, | 73 base::StringPiece chlo_hash, |
| 74 const std::vector<std::string>& certs, | 74 const std::vector<std::string>& certs, |
| 75 const std::string& cert_sct, | 75 const std::string& cert_sct, |
| 76 const std::string& signature, | 76 const std::string& signature, |
| 77 std::string* error_details, | 77 std::string* error_details, |
| 78 std::unique_ptr<ProofVerifyDetails>* verify_details, | 78 std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 79 ProofVerifierCallback* callback); | 79 std::unique_ptr<ProofVerifierCallback> callback); |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 enum State { | 82 enum State { |
| 83 STATE_NONE, | 83 STATE_NONE, |
| 84 STATE_VERIFY_CERT, | 84 STATE_VERIFY_CERT, |
| 85 STATE_VERIFY_CERT_COMPLETE, | 85 STATE_VERIFY_CERT_COMPLETE, |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 int DoLoop(int last_io_result); | 88 int DoLoop(int last_io_result); |
| 89 void OnIOComplete(int result); | 89 void OnIOComplete(int result); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const string& hostname, | 173 const string& hostname, |
| 174 const uint16_t port, | 174 const uint16_t port, |
| 175 const string& server_config, | 175 const string& server_config, |
| 176 QuicVersion quic_version, | 176 QuicVersion quic_version, |
| 177 StringPiece chlo_hash, | 177 StringPiece chlo_hash, |
| 178 const vector<string>& certs, | 178 const vector<string>& certs, |
| 179 const std::string& cert_sct, | 179 const std::string& cert_sct, |
| 180 const string& signature, | 180 const string& signature, |
| 181 std::string* error_details, | 181 std::string* error_details, |
| 182 std::unique_ptr<ProofVerifyDetails>* verify_details, | 182 std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 183 ProofVerifierCallback* callback) { | 183 std::unique_ptr<ProofVerifierCallback> callback) { |
| 184 DCHECK(error_details); | 184 DCHECK(error_details); |
| 185 DCHECK(verify_details); | 185 DCHECK(verify_details); |
| 186 DCHECK(callback); | 186 DCHECK(callback); |
| 187 | 187 |
| 188 error_details->clear(); | 188 error_details->clear(); |
| 189 | 189 |
| 190 if (STATE_NONE != next_state_) { | 190 if (STATE_NONE != next_state_) { |
| 191 *error_details = "Certificate is already set and VerifyProof has begun"; | 191 *error_details = "Certificate is already set and VerifyProof has begun"; |
| 192 DLOG(DFATAL) << *error_details; | 192 DLOG(DFATAL) << *error_details; |
| 193 return QUIC_FAILURE; | 193 return QUIC_FAILURE; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 hostname_ = hostname; | 240 hostname_ = hostname; |
| 241 port_ = port; | 241 port_ = port; |
| 242 | 242 |
| 243 next_state_ = STATE_VERIFY_CERT; | 243 next_state_ = STATE_VERIFY_CERT; |
| 244 switch (DoLoop(OK)) { | 244 switch (DoLoop(OK)) { |
| 245 case OK: | 245 case OK: |
| 246 *verify_details = std::move(verify_details_); | 246 *verify_details = std::move(verify_details_); |
| 247 return QUIC_SUCCESS; | 247 return QUIC_SUCCESS; |
| 248 case ERR_IO_PENDING: | 248 case ERR_IO_PENDING: |
| 249 callback_.reset(callback); | 249 callback_ = std::move(callback); |
| 250 return QUIC_PENDING; | 250 return QUIC_PENDING; |
| 251 default: | 251 default: |
| 252 *error_details = error_details_; | 252 *error_details = error_details_; |
| 253 *verify_details = std::move(verify_details_); | 253 *verify_details = std::move(verify_details_); |
| 254 return QUIC_FAILURE; | 254 return QUIC_FAILURE; |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 int ProofVerifierChromium::Job::DoLoop(int last_result) { | 258 int ProofVerifierChromium::Job::DoLoop(int last_result) { |
| 259 int rv = last_result; | 259 int rv = last_result; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 const uint16_t port, | 484 const uint16_t port, |
| 485 const std::string& server_config, | 485 const std::string& server_config, |
| 486 QuicVersion quic_version, | 486 QuicVersion quic_version, |
| 487 base::StringPiece chlo_hash, | 487 base::StringPiece chlo_hash, |
| 488 const std::vector<std::string>& certs, | 488 const std::vector<std::string>& certs, |
| 489 const std::string& cert_sct, | 489 const std::string& cert_sct, |
| 490 const std::string& signature, | 490 const std::string& signature, |
| 491 const ProofVerifyContext* verify_context, | 491 const ProofVerifyContext* verify_context, |
| 492 std::string* error_details, | 492 std::string* error_details, |
| 493 std::unique_ptr<ProofVerifyDetails>* verify_details, | 493 std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 494 ProofVerifierCallback* callback) { | 494 std::unique_ptr<ProofVerifierCallback> callback) { |
| 495 if (!verify_context) { | 495 if (!verify_context) { |
| 496 *error_details = "Missing context"; | 496 *error_details = "Missing context"; |
| 497 return QUIC_FAILURE; | 497 return QUIC_FAILURE; |
| 498 } | 498 } |
| 499 const ProofVerifyContextChromium* chromium_context = | 499 const ProofVerifyContextChromium* chromium_context = |
| 500 reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); | 500 reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); |
| 501 std::unique_ptr<Job> job( | 501 std::unique_ptr<Job> job( |
| 502 new Job(this, cert_verifier_, ct_policy_enforcer_, | 502 new Job(this, cert_verifier_, ct_policy_enforcer_, |
| 503 transport_security_state_, cert_transparency_verifier_, | 503 transport_security_state_, cert_transparency_verifier_, |
| 504 chromium_context->cert_verify_flags, chromium_context->net_log)); | 504 chromium_context->cert_verify_flags, chromium_context->net_log)); |
| 505 QuicAsyncStatus status = job->VerifyProof( | 505 QuicAsyncStatus status = job->VerifyProof( |
| 506 hostname, port, server_config, quic_version, chlo_hash, certs, cert_sct, | 506 hostname, port, server_config, quic_version, chlo_hash, certs, cert_sct, |
| 507 signature, error_details, verify_details, callback); | 507 signature, error_details, verify_details, std::move(callback)); |
| 508 if (status == QUIC_PENDING) { | 508 if (status == QUIC_PENDING) { |
| 509 active_jobs_.insert(job.release()); | 509 active_jobs_.insert(job.release()); |
| 510 } | 510 } |
| 511 return status; | 511 return status; |
| 512 } | 512 } |
| 513 | 513 |
| 514 void ProofVerifierChromium::OnJobComplete(Job* job) { | 514 void ProofVerifierChromium::OnJobComplete(Job* job) { |
| 515 active_jobs_.erase(job); | 515 active_jobs_.erase(job); |
| 516 delete job; | 516 delete job; |
| 517 } | 517 } |
| 518 | 518 |
| 519 } // namespace net | 519 } // namespace net |
| OLD | NEW |