| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #elif defined(OS_WIN) | 12 #elif defined(OS_WIN) |
| 13 #include <stdlib.h> | 13 #include <stdlib.h> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/singleton.h" | |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| 21 // Raw metadata. | 21 // Raw metadata. |
| 22 struct EVMetadata { | 22 struct EVMetadata { |
| 23 // The SHA-1 fingerprint of the root CA certificate, used as a unique | 23 // The SHA-1 fingerprint of the root CA certificate, used as a unique |
| 24 // identifier for a root CA certificate. | 24 // identifier for a root CA certificate. |
| 25 SHA1Fingerprint fingerprint; | 25 SHA1Fingerprint fingerprint; |
| 26 | 26 |
| 27 // The EV policy OID of the root CA. | 27 // The EV policy OID of the root CA. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 "2.16.840.1.113733.1.7.48.1", | 276 "2.16.840.1.113733.1.7.48.1", |
| 277 "2.16.840.1.114028.10.1.2", | 277 "2.16.840.1.114028.10.1.2", |
| 278 "2.16.840.1.114171.500.9", | 278 "2.16.840.1.114171.500.9", |
| 279 "2.16.840.1.114404.1.1.2.4.1", | 279 "2.16.840.1.114404.1.1.2.4.1", |
| 280 "2.16.840.1.114412.2.1", | 280 "2.16.840.1.114412.2.1", |
| 281 "2.16.840.1.114413.1.7.23.3", | 281 "2.16.840.1.114413.1.7.23.3", |
| 282 "2.16.840.1.114414.1.7.23.3", | 282 "2.16.840.1.114414.1.7.23.3", |
| 283 }; | 283 }; |
| 284 #endif | 284 #endif |
| 285 | 285 |
| 286 static base::LazyInstance<EVRootCAMetadata, |
| 287 base::LeakyLazyInstanceTraits<EVRootCAMetadata> > |
| 288 g_ev_root_ca_metadata(base::LINKER_INITIALIZED); |
| 289 |
| 286 // static | 290 // static |
| 287 EVRootCAMetadata* EVRootCAMetadata::GetInstance() { | 291 EVRootCAMetadata* EVRootCAMetadata::GetInstance() { |
| 288 return Singleton<EVRootCAMetadata>::get(); | 292 return g_ev_root_ca_metadata.Pointer(); |
| 289 } | 293 } |
| 290 | 294 |
| 291 bool EVRootCAMetadata::GetPolicyOID( | 295 bool EVRootCAMetadata::GetPolicyOID( |
| 292 const SHA1Fingerprint& fingerprint, | 296 const SHA1Fingerprint& fingerprint, |
| 293 PolicyOID* policy_oid) const { | 297 PolicyOID* policy_oid) const { |
| 294 PolicyOidMap::const_iterator iter = ev_policy_.find(fingerprint); | 298 PolicyOidMap::const_iterator iter = ev_policy_.find(fingerprint); |
| 295 if (iter == ev_policy_.end()) | 299 if (iter == ev_policy_.end()) |
| 296 return false; | 300 return false; |
| 297 *policy_oid = iter->second; | 301 *policy_oid = iter->second; |
| 298 return true; | 302 return true; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // static | 388 // static |
| 385 bool EVRootCAMetadata::PolicyOIDsAreEqual(PolicyOID a, PolicyOID b) { | 389 bool EVRootCAMetadata::PolicyOIDsAreEqual(PolicyOID a, PolicyOID b) { |
| 386 #if defined(USE_NSS) | 390 #if defined(USE_NSS) |
| 387 return a == b; | 391 return a == b; |
| 388 #else | 392 #else |
| 389 return !strcmp(a, b); | 393 return !strcmp(a, b); |
| 390 #endif | 394 #endif |
| 391 } | 395 } |
| 392 | 396 |
| 393 } // namespace net | 397 } // namespace net |
| OLD | NEW |