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

Side by Side Diff: components/cast_certificate/cast_cert_validator.cc

Issue 2289363004: Add error information to VerifySignedData(). (Closed)
Patch Set: rebase onto origin/master Created 4 years, 3 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
« no previous file with comments | « no previous file | components/cast_certificate/cast_crl.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/cast_certificate/cast_cert_validator.h" 5 #include "components/cast_certificate/cast_cert_validator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // SHA-1. 132 // SHA-1.
133 // TODO(eroman): Is it possible to use other hash algorithms? 133 // TODO(eroman): Is it possible to use other hash algorithms?
134 auto signature_algorithm = 134 auto signature_algorithm =
135 net::SignatureAlgorithm::CreateRsaPkcs1(net::DigestAlgorithm::Sha1); 135 net::SignatureAlgorithm::CreateRsaPkcs1(net::DigestAlgorithm::Sha1);
136 136
137 // Use the same policy as was used for verifying signatures in 137 // Use the same policy as was used for verifying signatures in
138 // certificates. This will ensure for instance that the key used is at 138 // certificates. This will ensure for instance that the key used is at
139 // least 2048-bits long. 139 // least 2048-bits long.
140 auto signature_policy = CreateCastSignaturePolicy(); 140 auto signature_policy = CreateCastSignaturePolicy();
141 141
142 net::CertErrors errors;
142 return net::VerifySignedData( 143 return net::VerifySignedData(
143 *signature_algorithm, net::der::Input(data), 144 *signature_algorithm, net::der::Input(data),
144 net::der::BitString(net::der::Input(signature), 0), 145 net::der::BitString(net::der::Input(signature), 0),
145 net::der::Input(&spki_), signature_policy.get()); 146 net::der::Input(&spki_), signature_policy.get(), &errors);
146 } 147 }
147 148
148 std::string GetCommonName() const override { return common_name_; } 149 std::string GetCommonName() const override { return common_name_; }
149 150
150 private: 151 private:
151 std::string spki_; 152 std::string spki_;
152 std::string common_name_; 153 std::string common_name_;
153 }; 154 };
154 155
155 // Helper that extracts the Common Name from a certificate's subject field. On 156 // Helper that extracts the Common Name from a certificate's subject field. On
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 348
348 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( 349 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest(
349 const base::StringPiece& spki) { 350 const base::StringPiece& spki) {
350 // Use a bogus CommonName, since this is just exposed for testing signature 351 // Use a bogus CommonName, since this is just exposed for testing signature
351 // verification by unittests. 352 // verification by unittests.
352 return base::MakeUnique<CertVerificationContextImpl>(net::der::Input(spki), 353 return base::MakeUnique<CertVerificationContextImpl>(net::der::Input(spki),
353 "CommonName"); 354 "CommonName");
354 } 355 }
355 356
356 } // namespace cast_certificate 357 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « no previous file | components/cast_certificate/cast_crl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698