Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef NET_CERT_INTERNAL_TRUST_STORE_H_ | 5 #ifndef NET_CERT_INTERNAL_TRUST_STORE_H_ |
| 6 #define NET_CERT_INTERNAL_TRUST_STORE_H_ | 6 #define NET_CERT_INTERNAL_TRUST_STORE_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | |
| 9 #include <vector> | 8 #include <vector> |
| 10 | 9 |
| 11 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 12 #include "base/strings/string_piece.h" | |
| 13 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 14 #include "net/cert/internal/parsed_certificate.h" | 12 #include "net/cert/internal/parsed_certificate.h" |
| 15 | 13 |
| 16 namespace net { | 14 namespace net { |
| 17 | 15 |
| 18 namespace der { | 16 namespace der { |
| 19 class Input; | 17 class Input; |
| 20 } | 18 } |
| 21 | 19 |
| 22 // A TrustAnchor represents a trust anchor used during RFC 5280 path validation. | 20 // A TrustAnchor represents a trust anchor used during RFC 5280 path validation. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 friend class base::RefCountedThreadSafe<TrustAnchor>; | 104 friend class base::RefCountedThreadSafe<TrustAnchor>; |
| 107 TrustAnchor(scoped_refptr<ParsedCertificate>, bool enforces_constraints); | 105 TrustAnchor(scoped_refptr<ParsedCertificate>, bool enforces_constraints); |
| 108 ~TrustAnchor(); | 106 ~TrustAnchor(); |
| 109 | 107 |
| 110 scoped_refptr<ParsedCertificate> cert_; | 108 scoped_refptr<ParsedCertificate> cert_; |
| 111 bool enforces_constraints_ = false; | 109 bool enforces_constraints_ = false; |
| 112 }; | 110 }; |
| 113 | 111 |
| 114 using TrustAnchors = std::vector<scoped_refptr<TrustAnchor>>; | 112 using TrustAnchors = std::vector<scoped_refptr<TrustAnchor>>; |
| 115 | 113 |
| 116 // A very simple implementation of a TrustStore, which contains a set of | 114 // Interface for finding trust anchors. |
| 117 // trust anchors. | |
| 118 // | |
| 119 // TODO(mattm): convert this into an interface, provide implementations that | |
| 120 // interface with OS trust store. | |
| 121 class NET_EXPORT TrustStore { | 115 class NET_EXPORT TrustStore { |
| 122 public: | 116 public: |
| 123 TrustStore(); | 117 TrustStore(); |
| 124 ~TrustStore(); | 118 virtual ~TrustStore(); |
| 125 | |
| 126 // Empties the trust store, resetting it to original state. | |
| 127 void Clear(); | |
| 128 | |
| 129 void AddTrustAnchor(scoped_refptr<TrustAnchor> anchor); | |
| 130 | 119 |
| 131 // Returns the trust anchors that match |name| in |*matches|, if any. | 120 // Returns the trust anchors that match |name| in |*matches|, if any. |
| 132 void FindTrustAnchorsByNormalizedName(const der::Input& normalized_name, | 121 virtual void FindTrustAnchorsByNormalizedName( |
|
eroman
2016/08/18 21:13:38
Do you think we will need to make this async in th
mattm
2016/08/18 22:18:22
yes, I'm saving that for a followup. Just wanted t
| |
| 133 TrustAnchors* matches) const; | 122 const der::Input& normalized_name, |
| 123 TrustAnchors* matches) const = 0; | |
| 134 | 124 |
| 135 private: | 125 private: |
| 136 // Multimap from normalized subject -> TrustAnchor. | |
| 137 std::unordered_multimap<base::StringPiece, | |
| 138 scoped_refptr<TrustAnchor>, | |
| 139 base::StringPieceHash> | |
| 140 anchors_; | |
| 141 | |
| 142 DISALLOW_COPY_AND_ASSIGN(TrustStore); | 126 DISALLOW_COPY_AND_ASSIGN(TrustStore); |
| 143 }; | 127 }; |
| 144 | 128 |
| 145 } // namespace net | 129 } // namespace net |
| 146 | 130 |
| 147 #endif // NET_CERT_INTERNAL_TRUST_STORE_H_ | 131 #endif // NET_CERT_INTERNAL_TRUST_STORE_H_ |
| OLD | NEW |