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

Side by Side Diff: net/cert/internal/trust_store.cc

Issue 2245643004: Support trust anchor constraints, by specifying them as a certificate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update gypi 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 | « net/cert/internal/trust_store.h ('k') | net/cert/internal/verify_certificate_chain.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/cert/internal/trust_store.h" 5 #include "net/cert/internal/trust_store.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateNoConstraints( 11 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateNoConstraints(
12 scoped_refptr<ParsedCertificate> cert) { 12 scoped_refptr<ParsedCertificate> cert) {
13 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert))); 13 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), false));
14 }
15
16 scoped_refptr<TrustAnchor> TrustAnchor::CreateFromCertificateWithConstraints(
17 scoped_refptr<ParsedCertificate> cert) {
18 return scoped_refptr<TrustAnchor>(new TrustAnchor(std::move(cert), true));
14 } 19 }
15 20
16 der::Input TrustAnchor::spki() const { 21 der::Input TrustAnchor::spki() const {
17 return cert_->tbs().spki_tlv; 22 return cert_->tbs().spki_tlv;
18 } 23 }
19 24
20 der::Input TrustAnchor::normalized_subject() const { 25 der::Input TrustAnchor::normalized_subject() const {
21 return cert_->normalized_subject(); 26 return cert_->normalized_subject();
22 } 27 }
23 28
24 const scoped_refptr<ParsedCertificate>& TrustAnchor::cert() const { 29 const scoped_refptr<ParsedCertificate>& TrustAnchor::cert() const {
25 return cert_; 30 return cert_;
26 } 31 }
27 32
28 TrustAnchor::TrustAnchor(scoped_refptr<ParsedCertificate> cert) 33 TrustAnchor::TrustAnchor(scoped_refptr<ParsedCertificate> cert,
29 : cert_(std::move(cert)) { 34 bool enforces_constraints)
35 : cert_(std::move(cert)), enforces_constraints_(enforces_constraints) {
30 DCHECK(cert_); 36 DCHECK(cert_);
31 } 37 }
32 38
33 TrustAnchor::~TrustAnchor() {} 39 TrustAnchor::~TrustAnchor() {}
34 40
35 TrustStore::TrustStore() {} 41 TrustStore::TrustStore() {}
36 TrustStore::~TrustStore() {} 42 TrustStore::~TrustStore() {}
37 43
38 void TrustStore::Clear() { 44 void TrustStore::Clear() {
39 anchors_.clear(); 45 anchors_.clear();
40 } 46 }
41 47
42 void TrustStore::AddTrustAnchor(scoped_refptr<TrustAnchor> anchor) { 48 void TrustStore::AddTrustAnchor(scoped_refptr<TrustAnchor> anchor) {
43 // TODO(mattm): should this check for duplicate anchors? 49 // TODO(mattm): should this check for duplicate anchors?
44 anchors_.insert(std::make_pair(anchor->normalized_subject().AsStringPiece(), 50 anchors_.insert(std::make_pair(anchor->normalized_subject().AsStringPiece(),
45 std::move(anchor))); 51 std::move(anchor)));
46 } 52 }
47 53
48 void TrustStore::FindTrustAnchorsByNormalizedName( 54 void TrustStore::FindTrustAnchorsByNormalizedName(
49 const der::Input& normalized_name, 55 const der::Input& normalized_name,
50 TrustAnchors* matches) const { 56 TrustAnchors* matches) const {
51 auto range = anchors_.equal_range(normalized_name.AsStringPiece()); 57 auto range = anchors_.equal_range(normalized_name.AsStringPiece());
52 for (auto it = range.first; it != range.second; ++it) 58 for (auto it = range.first; it != range.second; ++it)
53 matches->push_back(it->second); 59 matches->push_back(it->second);
54 } 60 }
55 61
56 } // namespace net 62 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/trust_store.h ('k') | net/cert/internal/verify_certificate_chain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698