| 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 "base/nss_util.h" | 5 #include "base/nss_util.h" |
| 6 #include "base/nss_util_internal.h" | 6 #include "base/nss_util_internal.h" |
| 7 | 7 |
| 8 #include <nss.h> | 8 #include <nss.h> |
| 9 #include <plarena.h> | 9 #include <plarena.h> |
| 10 #include <prerror.h> | 10 #include <prerror.h> |
| 11 #include <prinit.h> | 11 #include <prinit.h> |
| 12 #include <prtime.h> | 12 #include <prtime.h> |
| 13 #include <pk11pub.h> | 13 #include <pk11pub.h> |
| 14 #include <secmod.h> | 14 #include <secmod.h> |
| 15 | 15 |
| 16 #if defined(OS_LINUX) | 16 #if defined(OS_LINUX) |
| 17 #include <linux/magic.h> | 17 #include <linux/magic.h> |
| 18 #include <sys/vfs.h> | 18 #include <sys/vfs.h> |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
| 22 #include "base/logging.h" | 22 #include "base/logging.h" |
| 23 #include "base/singleton.h" | 23 #include "base/singleton.h" |
| 24 #include "base/string_util.h" | 24 #include "base/stringprintf.h" |
| 25 | 25 |
| 26 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not | 26 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not |
| 27 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't | 27 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't |
| 28 // use NSS for crypto or certificate verification, and we don't use the NSS | 28 // use NSS for crypto or certificate verification, and we don't use the NSS |
| 29 // certificate and key databases. | 29 // certificate and key databases. |
| 30 #if defined(USE_NSS) | 30 #if defined(USE_NSS) |
| 31 #include "base/environment.h" | 31 #include "base/environment.h" |
| 32 #include "base/lock.h" | 32 #include "base/lock.h" |
| 33 #include "base/scoped_ptr.h" | 33 #include "base/scoped_ptr.h" |
| 34 #endif // defined(USE_NSS) | 34 #endif // defined(USE_NSS) |
| 35 | 35 |
| 36 namespace base { |
| 37 |
| 36 namespace { | 38 namespace { |
| 37 | 39 |
| 38 #if defined(USE_NSS) | 40 #if defined(USE_NSS) |
| 39 FilePath GetDefaultConfigDirectory() { | 41 FilePath GetDefaultConfigDirectory() { |
| 40 FilePath dir = file_util::GetHomeDir(); | 42 FilePath dir = file_util::GetHomeDir(); |
| 41 if (dir.empty()) { | 43 if (dir.empty()) { |
| 42 LOG(ERROR) << "Failed to get home directory."; | 44 LOG(ERROR) << "Failed to get home directory."; |
| 43 return dir; | 45 return dir; |
| 44 } | 46 } |
| 45 dir = dir.AppendASCII(".pki").AppendASCII("nssdb"); | 47 dir = dir.AppendASCII(".pki").AppendASCII("nssdb"); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 PK11SlotInfo* test_db_slot_; // Overrides internal key slot and real_db_slot_ | 296 PK11SlotInfo* test_db_slot_; // Overrides internal key slot and real_db_slot_ |
| 295 SECMODModule *root_; | 297 SECMODModule *root_; |
| 296 bool chromeos_user_logged_in_; | 298 bool chromeos_user_logged_in_; |
| 297 #if defined(USE_NSS) | 299 #if defined(USE_NSS) |
| 298 scoped_ptr<Lock> write_lock_; | 300 scoped_ptr<Lock> write_lock_; |
| 299 #endif // defined(USE_NSS) | 301 #endif // defined(USE_NSS) |
| 300 }; | 302 }; |
| 301 | 303 |
| 302 } // namespace | 304 } // namespace |
| 303 | 305 |
| 304 namespace base { | |
| 305 | |
| 306 void EnsureNSPRInit() { | 306 void EnsureNSPRInit() { |
| 307 Singleton<NSPRInitSingleton>::get(); | 307 Singleton<NSPRInitSingleton>::get(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void EnsureNSSInit() { | 310 void EnsureNSSInit() { |
| 311 Singleton<NSSInitSingleton>::get(); | 311 Singleton<NSSInitSingleton>::get(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 #if defined(USE_NSS) | 314 #if defined(USE_NSS) |
| 315 bool OpenTestNSSDB(const FilePath& path, const char* description) { | 315 bool OpenTestNSSDB(const FilePath& path, const char* description) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 exploded.millisecond = prxtime.tm_usec / 1000; | 361 exploded.millisecond = prxtime.tm_usec / 1000; |
| 362 | 362 |
| 363 return Time::FromUTCExploded(exploded); | 363 return Time::FromUTCExploded(exploded); |
| 364 } | 364 } |
| 365 | 365 |
| 366 PK11SlotInfo* GetDefaultNSSKeySlot() { | 366 PK11SlotInfo* GetDefaultNSSKeySlot() { |
| 367 return Singleton<NSSInitSingleton>::get()->GetDefaultKeySlot(); | 367 return Singleton<NSSInitSingleton>::get()->GetDefaultKeySlot(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace base | 370 } // namespace base |
| OLD | NEW |