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

Side by Side Diff: net/quic/crypto/proof_verifier_chromium.cc

Issue 18033005: Cleanup of OpenSSL/NSS implementation of ProofVerfifier release. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implemented wtc's comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/proof_verifier_chromium.h ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 ProofVerifierChromium::ProofVerifierChromium(CertVerifier* cert_verifier, 33 ProofVerifierChromium::ProofVerifierChromium(CertVerifier* cert_verifier,
34 const BoundNetLog& net_log) 34 const BoundNetLog& net_log)
35 : cert_verifier_(cert_verifier), 35 : cert_verifier_(cert_verifier),
36 error_details_(NULL), 36 error_details_(NULL),
37 next_state_(STATE_NONE), 37 next_state_(STATE_NONE),
38 net_log_(net_log) { 38 net_log_(net_log) {
39 } 39 }
40 40
41 ProofVerifierChromium::~ProofVerifierChromium() { 41 ProofVerifierChromium::~ProofVerifierChromium() {
42 verifier_.reset(); 42 verifier_.reset();
43
44 // Reset object state.
45 callback_.Reset();
46 cert_verify_result_.Reset();
47 } 43 }
48 44
49 int ProofVerifierChromium::VerifyProof(const string& hostname, 45 int ProofVerifierChromium::VerifyProof(const string& hostname,
50 const string& server_config, 46 const string& server_config,
51 const vector<string>& certs, 47 const vector<string>& certs,
52 const string& signature, 48 const string& signature,
53 std::string* error_details, 49 std::string* error_details,
54 const CompletionCallback& callback) { 50 const CompletionCallback& callback) {
55 DCHECK(error_details); 51 DCHECK(error_details);
56 error_details->clear(); 52 error_details->clear();
(...skipping 11 matching lines...) Expand all
68 return ERR_FAILED; 64 return ERR_FAILED;
69 } 65 }
70 66
71 // Convert certs to X509Certificate. 67 // Convert certs to X509Certificate.
72 vector<StringPiece> cert_pieces(certs.size()); 68 vector<StringPiece> cert_pieces(certs.size());
73 for (unsigned i = 0; i < certs.size(); i++) { 69 for (unsigned i = 0; i < certs.size(); i++) {
74 cert_pieces[i] = base::StringPiece(certs[i]); 70 cert_pieces[i] = base::StringPiece(certs[i]);
75 } 71 }
76 cert_ = X509Certificate::CreateFromDERCertChain(cert_pieces); 72 cert_ = X509Certificate::CreateFromDERCertChain(cert_pieces);
77 if (!cert_.get()) { 73 if (!cert_.get()) {
78 cert_verify_result_.Reset();
79 cert_verify_result_.cert_status = CERT_STATUS_INVALID;
80 *error_details = "Failed to create certificate chain"; 74 *error_details = "Failed to create certificate chain";
81 DLOG(WARNING) << *error_details; 75 DLOG(WARNING) << *error_details;
82 return ERR_FAILED; 76 return ERR_FAILED;
83 } 77 }
84 78
85 // We call VerifySignature first to avoid copying of server_config and 79 // We call VerifySignature first to avoid copying of server_config and
86 // signature. 80 // signature.
87 if (!VerifySignature(server_config, signature, certs[0])) { 81 if (!VerifySignature(server_config, signature, certs[0])) {
88 *error_details = "Failed to verify signature of server config"; 82 *error_details = "Failed to verify signature of server config";
89 DLOG(WARNING) << *error_details; 83 DLOG(WARNING) << *error_details;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::Bind(&ProofVerifierChromium::OnIOComplete, 136 base::Bind(&ProofVerifierChromium::OnIOComplete,
143 base::Unretained(this)), 137 base::Unretained(this)),
144 net_log_); 138 net_log_);
145 } 139 }
146 140
147 int ProofVerifierChromium::DoVerifyCertComplete(int result) { 141 int ProofVerifierChromium::DoVerifyCertComplete(int result) {
148 verifier_.reset(); 142 verifier_.reset();
149 143
150 if (result <= ERR_FAILED) { 144 if (result <= ERR_FAILED) {
151 *error_details_ = StringPrintf("Failed to verify certificate chain: %s", 145 *error_details_ = StringPrintf("Failed to verify certificate chain: %s",
152 ErrorToString(result)); 146 ErrorToString(result));
153 DLOG(WARNING) << *error_details_; 147 DLOG(WARNING) << *error_details_;
154 result = ERR_FAILED; 148 result = ERR_FAILED;
155 } 149 }
156 150
157 // Exit DoLoop and return the result to the caller to VerifyProof. 151 // Exit DoLoop and return the result to the caller to VerifyProof.
158 DCHECK_EQ(STATE_NONE, next_state_); 152 DCHECK_EQ(STATE_NONE, next_state_);
159 return result; 153 return result;
160 } 154 }
161 155
162 bool ProofVerifierChromium::VerifySignature(const string& signed_data, 156 bool ProofVerifierChromium::VerifySignature(const string& signed_data,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (!verifier.VerifyFinal()) { 225 if (!verifier.VerifyFinal()) {
232 DLOG(WARNING) << "VerifyFinal failed"; 226 DLOG(WARNING) << "VerifyFinal failed";
233 return false; 227 return false;
234 } 228 }
235 229
236 DLOG(INFO) << "VerifyFinal success"; 230 DLOG(INFO) << "VerifyFinal success";
237 return true; 231 return true;
238 } 232 }
239 233
240 } // namespace net 234 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/proof_verifier_chromium.h ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698