| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_EV_ROOT_CA_METADATA_H_ | 5 #ifndef NET_BASE_EV_ROOT_CA_METADATA_H_ |
| 6 #define NET_BASE_EV_ROOT_CA_METADATA_H_ | 6 #define NET_BASE_EV_ROOT_CA_METADATA_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(USE_NSS) | 10 #if defined(USE_NSS) |
| 11 #include <secoidt.h> | 11 #include <secoidt.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <set> | 15 #include <set> |
| 16 #include <string> |
| 16 #include <vector> | 17 #include <vector> |
| 17 | 18 |
| 18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 19 #include "net/base/x509_certificate.h" | 20 #include "net/base/x509_certificate.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 template <typename T> | 23 template <typename T> |
| 23 struct DefaultLazyInstanceTraits; | 24 struct DefaultLazyInstanceTraits; |
| 24 } // namespace base | 25 } // namespace base |
| 25 | 26 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 static EVRootCAMetadata* GetInstance(); | 39 static EVRootCAMetadata* GetInstance(); |
| 39 | 40 |
| 40 #if defined(USE_NSS) || defined(OS_WIN) | 41 #if defined(USE_NSS) || defined(OS_WIN) |
| 41 // Returns true if policy_oid is an EV policy OID of some root CA. | 42 // Returns true if policy_oid is an EV policy OID of some root CA. |
| 42 bool IsEVPolicyOID(PolicyOID policy_oid) const; | 43 bool IsEVPolicyOID(PolicyOID policy_oid) const; |
| 43 | 44 |
| 44 // Returns true if the root CA with the given certificate fingerprint has | 45 // Returns true if the root CA with the given certificate fingerprint has |
| 45 // the EV policy OID policy_oid. | 46 // the EV policy OID policy_oid. |
| 46 bool HasEVPolicyOID(const SHA1Fingerprint& fingerprint, | 47 bool HasEVPolicyOID(const SHA1HashValue& fingerprint, |
| 47 PolicyOID policy_oid) const; | 48 PolicyOID policy_oid) const; |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 // AddEVCA adds an EV CA to the list of known EV CAs with the given policy. | 51 // AddEVCA adds an EV CA to the list of known EV CAs with the given policy. |
| 51 // |policy| is expressed as a string of dotted numbers. It returns true on | 52 // |policy| is expressed as a string of dotted numbers. It returns true on |
| 52 // success. | 53 // success. |
| 53 bool AddEVCA(const SHA1Fingerprint& fingerprint, const char* policy); | 54 bool AddEVCA(const SHA1HashValue& fingerprint, const char* policy); |
| 54 | 55 |
| 55 // RemoveEVCA removes an EV CA that was previously added by AddEVCA. It | 56 // RemoveEVCA removes an EV CA that was previously added by AddEVCA. It |
| 56 // returns true on success. | 57 // returns true on success. |
| 57 bool RemoveEVCA(const SHA1Fingerprint& fingerprint); | 58 bool RemoveEVCA(const SHA1HashValue& fingerprint); |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 friend struct base::DefaultLazyInstanceTraits<EVRootCAMetadata>; | 61 friend struct base::DefaultLazyInstanceTraits<EVRootCAMetadata>; |
| 61 | 62 |
| 62 EVRootCAMetadata(); | 63 EVRootCAMetadata(); |
| 63 ~EVRootCAMetadata(); | 64 ~EVRootCAMetadata(); |
| 64 | 65 |
| 65 #if defined(USE_NSS) | 66 #if defined(USE_NSS) |
| 66 typedef std::map<SHA1Fingerprint, std::vector<PolicyOID>, | 67 typedef std::map<SHA1HashValue, std::vector<PolicyOID>, |
| 67 SHA1FingerprintLessThan> PolicyOIDMap; | 68 SHA1HashValueLessThan> PolicyOIDMap; |
| 68 | 69 |
| 69 // RegisterOID registers |policy|, a policy OID in dotted string form, and | 70 // RegisterOID registers |policy|, a policy OID in dotted string form, and |
| 70 // writes the memoized form to |*out|. It returns true on success. | 71 // writes the memoized form to |*out|. It returns true on success. |
| 71 static bool RegisterOID(const char* policy, PolicyOID* out); | 72 static bool RegisterOID(const char* policy, PolicyOID* out); |
| 72 | 73 |
| 73 PolicyOIDMap ev_policy_; | 74 PolicyOIDMap ev_policy_; |
| 74 std::set<PolicyOID> policy_oids_; | 75 std::set<PolicyOID> policy_oids_; |
| 75 #elif defined(OS_WIN) | 76 #elif defined(OS_WIN) |
| 76 typedef std::map<SHA1Fingerprint, std::string, | 77 typedef std::map<SHA1HashValue, std::string, |
| 77 SHA1FingerprintLessThan> ExtraEVCAMap; | 78 SHA1HashValueLessThan> ExtraEVCAMap; |
| 78 | 79 |
| 79 // extra_cas_ contains any EV CA metadata that was added at runtime. | 80 // extra_cas_ contains any EV CA metadata that was added at runtime. |
| 80 ExtraEVCAMap extra_cas_; | 81 ExtraEVCAMap extra_cas_; |
| 81 #endif | 82 #endif |
| 82 | 83 |
| 83 DISALLOW_COPY_AND_ASSIGN(EVRootCAMetadata); | 84 DISALLOW_COPY_AND_ASSIGN(EVRootCAMetadata); |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 } // namespace net | 87 } // namespace net |
| 87 | 88 |
| 88 #endif // NET_BASE_EV_ROOT_CA_METADATA_H_ | 89 #endif // NET_BASE_EV_ROOT_CA_METADATA_H_ |
| OLD | NEW |