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 #include "crypto/nss_util.h" | 5 #include "crypto/nss_util.h" |
6 #include "crypto/nss_util_internal.h" | 6 #include "crypto/nss_util_internal.h" |
7 | 7 |
8 #include <nss.h> | 8 #include <nss.h> |
| 9 #include <pk11pub.h> |
9 #include <plarena.h> | 10 #include <plarena.h> |
10 #include <prerror.h> | 11 #include <prerror.h> |
11 #include <prinit.h> | 12 #include <prinit.h> |
12 #include <prtime.h> | 13 #include <prtime.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/nfs_fs.h> | 17 #include <linux/nfs_fs.h> |
18 #include <sys/vfs.h> | 18 #include <sys/vfs.h> |
19 #elif defined(OS_OPENBSD) | 19 #elif defined(OS_OPENBSD) |
20 #include <sys/mount.h> | 20 #include <sys/mount.h> |
21 #include <sys/param.h> | 21 #include <sys/param.h> |
22 #endif | 22 #endif |
23 | 23 |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include "base/debug/alias.h" | 26 #include "base/debug/alias.h" |
27 #include "base/environment.h" | 27 #include "base/environment.h" |
28 #include "base/file_path.h" | 28 #include "base/file_path.h" |
29 #include "base/file_util.h" | 29 #include "base/file_util.h" |
| 30 #include "base/files/scoped_temp_dir.h" |
30 #include "base/lazy_instance.h" | 31 #include "base/lazy_instance.h" |
31 #include "base/logging.h" | 32 #include "base/logging.h" |
32 #include "base/memory/scoped_ptr.h" | 33 #include "base/memory/scoped_ptr.h" |
33 #include "base/native_library.h" | 34 #include "base/native_library.h" |
34 #include "base/scoped_temp_dir.h" | |
35 #include "base/stringprintf.h" | 35 #include "base/stringprintf.h" |
36 #include "base/threading/thread_restrictions.h" | 36 #include "base/threading/thread_restrictions.h" |
37 #include "build/build_config.h" | 37 #include "build/build_config.h" |
38 | 38 |
39 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
40 #include "crypto/symmetric_key.h" | 40 #include "crypto/symmetric_key.h" |
41 #endif | 41 #endif |
42 | 42 |
43 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not | 43 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not |
44 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't | 44 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 LOG(ERROR) << "PR_Cleanup failed; was NSPR initialized on wrong thread?"; | 216 LOG(ERROR) << "PR_Cleanup failed; was NSPR initialized on wrong thread?"; |
217 } | 217 } |
218 }; | 218 }; |
219 | 219 |
220 base::LazyInstance<NSPRInitSingleton>::Leaky | 220 base::LazyInstance<NSPRInitSingleton>::Leaky |
221 g_nspr_singleton = LAZY_INSTANCE_INITIALIZER; | 221 g_nspr_singleton = LAZY_INSTANCE_INITIALIZER; |
222 | 222 |
223 // This is a LazyInstance so that it will be deleted automatically when the | 223 // This is a LazyInstance so that it will be deleted automatically when the |
224 // unittest exits. NSSInitSingleton is a LeakySingleton, so it would not be | 224 // unittest exits. NSSInitSingleton is a LeakySingleton, so it would not be |
225 // deleted if it were a regular member. | 225 // deleted if it were a regular member. |
226 base::LazyInstance<ScopedTempDir> g_test_nss_db_dir = LAZY_INSTANCE_INITIALIZER; | 226 base::LazyInstance<base::ScopedTempDir> g_test_nss_db_dir = |
| 227 LAZY_INSTANCE_INITIALIZER; |
227 | 228 |
228 // Force a crash to debug http://crbug.com/153281. | 229 // Force a crash to debug http://crbug.com/153281. |
229 void CrashWithErrors(int nss_error, int os_error) { | 230 void CrashWithErrors(int nss_error, int os_error) { |
230 base::debug::Alias(&nss_error); | 231 base::debug::Alias(&nss_error); |
231 base::debug::Alias(&os_error); | 232 base::debug::Alias(&os_error); |
232 CHECK(false) << "nss_error=" << nss_error << ", os_error=" << os_error; | 233 CHECK(false) << "nss_error=" << nss_error << ", os_error=" << os_error; |
233 } | 234 } |
234 | 235 |
235 class NSSInitSingleton { | 236 class NSSInitSingleton { |
236 public: | 237 public: |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 797 |
797 PK11SlotInfo* GetPublicNSSKeySlot() { | 798 PK11SlotInfo* GetPublicNSSKeySlot() { |
798 return g_nss_singleton.Get().GetPublicNSSKeySlot(); | 799 return g_nss_singleton.Get().GetPublicNSSKeySlot(); |
799 } | 800 } |
800 | 801 |
801 PK11SlotInfo* GetPrivateNSSKeySlot() { | 802 PK11SlotInfo* GetPrivateNSSKeySlot() { |
802 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); | 803 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); |
803 } | 804 } |
804 | 805 |
805 } // namespace crypto | 806 } // namespace crypto |
OLD | NEW |