| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/ev_root_ca_metadata.h" | 5 #include "net/base/ev_root_ca_metadata.h" |
| 6 | 6 |
| 7 #if defined(USE_NSS) | 7 #if defined(USE_NSS) |
| 8 #include <cert.h> | 8 #include <cert.h> |
| 9 #include <pkcs11n.h> | 9 #include <pkcs11n.h> |
| 10 #include <secerr.h> | 10 #include <secerr.h> |
| 11 #include <secoid.h> | 11 #include <secoid.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/singleton.h" | 15 #include "base/singleton.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 // Raw metadata. | 19 // Raw metadata. |
| 20 struct EVMetadata { | 20 struct EVMetadata { |
| 21 // The SHA-1 fingerprint of the root CA certificate, used as a unique | 21 // The SHA-1 fingerprint of the root CA certificate, used as a unique |
| 22 // identifier for a root CA certificate. | 22 // identifier for a root CA certificate. |
| 23 X509Certificate::Fingerprint fingerprint; | 23 SHA1Fingerprint fingerprint; |
| 24 | 24 |
| 25 // The EV policy OID of the root CA. | 25 // The EV policy OID of the root CA. |
| 26 // Note: a root CA may have multiple EV policies. When that actually | 26 // Note: a root CA may have multiple EV policies. When that actually |
| 27 // happens, we'll need to support that. | 27 // happens, we'll need to support that. |
| 28 const char* policy_oid; | 28 const char* policy_oid; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 static const EVMetadata ev_root_ca_metadata[] = { | 31 static const EVMetadata ev_root_ca_metadata[] = { |
| 32 // AddTrust External CA Root | 32 // AddTrust External CA Root |
| 33 // https://addtrustexternalcaroot-ev.comodoca.com | 33 // https://addtrustexternalcaroot-ev.comodoca.com |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 "2.16.840.1.114404.1.1.2.4.1" | 226 "2.16.840.1.114404.1.1.2.4.1" |
| 227 } | 227 } |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 // static | 230 // static |
| 231 EVRootCAMetadata* EVRootCAMetadata::GetInstance() { | 231 EVRootCAMetadata* EVRootCAMetadata::GetInstance() { |
| 232 return Singleton<EVRootCAMetadata>::get(); | 232 return Singleton<EVRootCAMetadata>::get(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 bool EVRootCAMetadata::GetPolicyOID( | 235 bool EVRootCAMetadata::GetPolicyOID( |
| 236 const X509Certificate::Fingerprint& fingerprint, | 236 const SHA1Fingerprint& fingerprint, |
| 237 PolicyOID* policy_oid) const { | 237 PolicyOID* policy_oid) const { |
| 238 PolicyOidMap::const_iterator iter = ev_policy_.find(fingerprint); | 238 PolicyOidMap::const_iterator iter = ev_policy_.find(fingerprint); |
| 239 if (iter == ev_policy_.end()) | 239 if (iter == ev_policy_.end()) |
| 240 return false; | 240 return false; |
| 241 *policy_oid = iter->second; | 241 *policy_oid = iter->second; |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| 244 | 244 |
| 245 EVRootCAMetadata::EVRootCAMetadata() { | 245 EVRootCAMetadata::EVRootCAMetadata() { |
| 246 // Constructs the object from the raw metadata in ev_root_ca_metadata. | 246 // Constructs the object from the raw metadata in ev_root_ca_metadata. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 275 ev_policy_[metadata.fingerprint] = metadata.policy_oid; | 275 ev_policy_[metadata.fingerprint] = metadata.policy_oid; |
| 276 // Multiple root CA certs may use the same EV policy OID. Having | 276 // Multiple root CA certs may use the same EV policy OID. Having |
| 277 // duplicates in the policy_oids_ array does no harm, so we don't | 277 // duplicates in the policy_oids_ array does no harm, so we don't |
| 278 // bother detecting duplicates. | 278 // bother detecting duplicates. |
| 279 policy_oids_.push_back(metadata.policy_oid); | 279 policy_oids_.push_back(metadata.policy_oid); |
| 280 } | 280 } |
| 281 #endif | 281 #endif |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace net | 284 } // namespace net |
| OLD | NEW |