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

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

Issue 2252933002: Make TrustStore into an interface, move impl to TrustStoreInMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update cast_cert_validator_unittest.cc Created 4 years, 4 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_cert_validator_unittest.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>
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "net/cert/internal/cert_issuer_source_static.h" 16 #include "net/cert/internal/cert_issuer_source_static.h"
17 #include "components/cast_certificate/cast_crl.h" 17 #include "components/cast_certificate/cast_crl.h"
18 #include "net/cert/internal/certificate_policies.h" 18 #include "net/cert/internal/certificate_policies.h"
19 #include "net/cert/internal/extended_key_usage.h" 19 #include "net/cert/internal/extended_key_usage.h"
20 #include "net/cert/internal/parse_certificate.h" 20 #include "net/cert/internal/parse_certificate.h"
21 #include "net/cert/internal/parse_name.h" 21 #include "net/cert/internal/parse_name.h"
22 #include "net/cert/internal/parsed_certificate.h" 22 #include "net/cert/internal/parsed_certificate.h"
23 #include "net/cert/internal/path_builder.h" 23 #include "net/cert/internal/path_builder.h"
24 #include "net/cert/internal/signature_algorithm.h" 24 #include "net/cert/internal/signature_algorithm.h"
25 #include "net/cert/internal/signature_policy.h" 25 #include "net/cert/internal/signature_policy.h"
26 #include "net/cert/internal/trust_store.h" 26 #include "net/cert/internal/trust_store_in_memory.h"
27 #include "net/cert/internal/verify_signed_data.h" 27 #include "net/cert/internal/verify_signed_data.h"
28 #include "net/der/encode_values.h" 28 #include "net/der/encode_values.h"
29 #include "net/der/input.h" 29 #include "net/der/input.h"
30 30
31 namespace cast_certificate { 31 namespace cast_certificate {
32 namespace { 32 namespace {
33 33
34 // ------------------------------------------------------------------------- 34 // -------------------------------------------------------------------------
35 // Cast trust anchors. 35 // Cast trust anchors.
36 // ------------------------------------------------------------------------- 36 // -------------------------------------------------------------------------
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 net::ParsedCertificate::CreateFromCertificateData( 71 net::ParsedCertificate::CreateFromCertificateData(
72 data, N, net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, 72 data, N, net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE,
73 {}); 73 {});
74 CHECK(cert); 74 CHECK(cert);
75 // Enforce pathlen constraints and policies defined on the root certificate. 75 // Enforce pathlen constraints and policies defined on the root certificate.
76 scoped_refptr<net::TrustAnchor> anchor = 76 scoped_refptr<net::TrustAnchor> anchor =
77 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); 77 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert));
78 store_.AddTrustAnchor(std::move(anchor)); 78 store_.AddTrustAnchor(std::move(anchor));
79 } 79 }
80 80
81 net::TrustStore store_; 81 net::TrustStoreInMemory store_;
82 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); 82 DISALLOW_COPY_AND_ASSIGN(CastTrustStore);
83 }; 83 };
84 84
85 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>; 85 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>;
86 86
87 // Helper that looks up an extension by OID given a map of extensions. 87 // Helper that looks up an extension by OID given a map of extensions.
88 bool GetExtensionValue(const ExtensionsMap& extensions, 88 bool GetExtensionValue(const ExtensionsMap& extensions,
89 const net::der::Input& oid, 89 const net::der::Input& oid,
90 net::der::Input* value) { 90 net::der::Input* value) {
91 auto it = extensions.find(oid); 91 auto it = extensions.find(oid);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( 351 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest(
352 const base::StringPiece& spki) { 352 const base::StringPiece& spki) {
353 // Use a bogus CommonName, since this is just exposed for testing signature 353 // Use a bogus CommonName, since this is just exposed for testing signature
354 // verification by unittests. 354 // verification by unittests.
355 return base::WrapUnique( 355 return base::WrapUnique(
356 new CertVerificationContextImpl(net::der::Input(spki), "CommonName")); 356 new CertVerificationContextImpl(net::der::Input(spki), "CommonName"));
357 } 357 }
358 358
359 } // namespace cast_certificate 359 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « no previous file | components/cast_certificate/cast_cert_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698