Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: base/nss_util.h

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Chrome, webkit, remoting and crypto/owners Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_NSS_UTIL_H_
6 #define BASE_NSS_UTIL_H_
7 #pragma once
8
9 #include <string>
10 #include "base/basictypes.h"
11
12 #if defined(USE_NSS)
13 class FilePath;
14 #endif // defined(USE_NSS)
15
16 // This file specifically doesn't depend on any NSS or NSPR headers because it
17 // is included by various (non-crypto) parts of chrome to call the
18 // initialization functions.
19 namespace base {
20
21 class Lock;
22 class Time;
23
24 #if defined(USE_NSS)
25 // EarlySetupForNSSInit performs lightweight setup which must occur before the
26 // process goes multithreaded. This does not initialise NSS. For test, see
27 // EnsureNSSInit.
28 void EarlySetupForNSSInit();
29 #endif
30
31 // Initialize NRPR if it isn't already initialized. This function is
32 // thread-safe, and NSPR will only ever be initialized once. NSPR will be
33 // properly shut down on program exit.
34 void EnsureNSPRInit();
35
36 // Initialize NSS if it isn't already initialized. This must be called before
37 // any other NSS functions. This function is thread-safe, and NSS will only
38 // ever be initialized once. NSS will be properly shut down on program exit.
39 void EnsureNSSInit();
40
41 // Call this before calling EnsureNSSInit() will force NSS to initialize
42 // without a persistent DB. This is used for the special case where access of
43 // persistent DB is prohibited.
44 //
45 // TODO(hclam): Isolate loading default root certs.
46 //
47 // NSS will be initialized without loading any user security modules, including
48 // the built-in root certificates module. User security modules need to be
49 // loaded manually after NSS initialization.
50 //
51 // If EnsureNSSInit() is called before then this function has no effect.
52 //
53 // Calling this method only has effect on Linux.
54 //
55 // WARNING: Use this with caution.
56 void ForceNSSNoDBInit();
57
58 // This methods is used to disable checks in NSS when used in a forked process.
59 // NSS checks whether it is running a forked process to avoid problems when
60 // using user security modules in a forked process. However if we are sure
61 // there are no modules loaded before the process is forked then there is no
62 // harm disabling the check.
63 //
64 // This method must be called before EnsureNSSInit() to take effect.
65 //
66 // WARNING: Use this with caution.
67 void DisableNSSForkCheck();
68
69 // Load NSS library files. This function has no effect on Mac and Windows.
70 // This loads the necessary NSS library files so that NSS can be initialized
71 // after loading additional library files is disallowed, for example when the
72 // sandbox is active.
73 //
74 // Note that this does not load libnssckbi.so which contains the root
75 // certificates.
76 void LoadNSSLibraries();
77
78 // Check if the current NSS version is greater than or equals to |version|.
79 // A sample version string is "3.12.3".
80 bool CheckNSSVersion(const char* version);
81
82 #if defined(OS_CHROMEOS)
83 // Open the r/w nssdb that's stored inside the user's encrypted home
84 // directory. This is the default slot returned by
85 // GetPublicNSSKeySlot().
86 void OpenPersistentNSSDB();
87
88 // Load the opencryptoki library into NSS so that we can access the
89 // TPM through NSS. Once this is called, GetPrivateNSSKeySlot() will
90 // return the TPM slot if one was found. Returns false if it was
91 // unable to load opencryptoki or open the TPM slot.
92 bool EnableTPMForNSS();
93
94 // Get name for the built-in TPM token on ChromeOS.
95 std::string GetTPMTokenName();
96 #endif
97
98 // Convert a NSS PRTime value into a base::Time object.
99 // We use a int64 instead of PRTime here to avoid depending on NSPR headers.
100 Time PRTimeToBaseTime(int64 prtime);
101
102 #if defined(USE_NSS)
103 // Exposed for unittests only. |path| should be an existing directory under
104 // which the DB files will be placed. |description| is a user-visible name for
105 // the DB, as a utf8 string, which will be truncated at 32 bytes.
106 bool OpenTestNSSDB(const FilePath& path, const char* description);
107 void CloseTestNSSDB();
108
109 // NSS has a bug which can cause a deadlock or stall in some cases when writing
110 // to the certDB and keyDB. It also has a bug which causes concurrent key pair
111 // generations to scribble over each other. To work around this, we synchronize
112 // writes to the NSS databases with a global lock. The lock is hidden beneath a
113 // function for easy disabling when the bug is fixed. Callers should allow for
114 // it to return NULL in the future.
115 //
116 // See https://bugzilla.mozilla.org/show_bug.cgi?id=564011
117 Lock* GetNSSWriteLock();
118
119 // A helper class that acquires the NSS write Lock while the AutoNSSWriteLock
120 // is in scope.
121 class AutoNSSWriteLock {
122 public:
123 AutoNSSWriteLock();
124 ~AutoNSSWriteLock();
125 private:
126 Lock *lock_;
127 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock);
128 };
129
130 #endif // defined(USE_NSS)
131
132 } // namespace base
133
134 #endif // BASE_NSS_UTIL_H_
OLDNEW
« no previous file with comments | « base/hmac_win.cc ('k') | base/nss_util.cc » ('j') | crypto/crypto.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698