 Chromium Code Reviews
 Chromium Code Reviews Issue 6805019:
  Move crypto files out of base, to a top level directory.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/
    
  
    Issue 6805019:
  Move crypto files out of base, to a top level directory.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/| OLD | NEW | 
|---|---|
| (Empty) | |
| 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 | |
| 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 "base/basictypes.h" | |
| 10 | |
| 11 #if defined(USE_NSS) | |
| 12 class FilePath; | |
| 13 #endif // defined(USE_NSS) | |
| 14 | |
| 15 // This file specifically doesn't depend on any NSS or NSPR headers because it | |
| 16 // is included by various (non-crypto) parts of chrome to call the | |
| 17 // initialization functions. | |
| 18 namespace base { | |
| 19 | |
| 20 class Lock; | |
| 21 class Time; | |
| 22 | |
| 23 #if defined(USE_NSS) | |
| 24 // EarlySetupForNSSInit performs lightweight setup which must occur before the | |
| 25 // process goes multithreaded. This does not initialise NSS. For test, see | |
| 26 // EnsureNSSInit. | |
| 27 void EarlySetupForNSSInit(); | |
| 28 #endif | |
| 29 | |
| 30 // Initialize NRPR if it isn't already initialized. This function is | |
| 31 // thread-safe, and NSPR will only ever be initialized once. NSPR will be | |
| 32 // properly shut down on program exit. | |
| 33 void EnsureNSPRInit(); | |
| 34 | |
| 35 // Initialize NSS if it isn't already initialized. This must be called before | |
| 36 // any other NSS functions. This function is thread-safe, and NSS will only | |
| 37 // ever be initialized once. NSS will be properly shut down on program exit. | |
| 38 void EnsureNSSInit(); | |
| 39 | |
| 40 // Call this before calling EnsureNSSInit() will force NSS to initialize | |
| 41 // without a persistent DB. This is used for the special case where access of | |
| 42 // persistent DB is prohibited. | |
| 43 // | |
| 44 // TODO(hclam): Isolate loading default root certs. | |
| 45 // | |
| 46 // NSS will be initialized without loading any user security modules, including | |
| 47 // the built-in root certificates module. User security modules need to be | |
| 48 // loaded manually after NSS initialization. | |
| 49 // | |
| 50 // If EnsureNSSInit() is called before then this function has no effect. | |
| 51 // | |
| 52 // Calling this method only has effect on Linux. | |
| 53 // | |
| 54 // WARNING: Use this with caution. | |
| 55 void ForceNSSNoDBInit(); | |
| 56 | |
| 57 // This methods is used to disable checks in NSS when used in a forked process. | |
| 58 // NSS checks whether it is running a forked process to avoid problems when | |
| 59 // using user security modules in a forked process. However if we are sure | |
| 60 // there are no modules loaded before the process is forked then there is no | |
| 61 // harm disabling the check. | |
| 62 // | |
| 63 // This method must be called before EnsureNSSInit() to take effect. | |
| 64 // | |
| 65 // WARNING: Use this with caution. | |
| 66 void DisableNSSForkCheck(); | |
| 67 | |
| 68 // Load NSS library files. This function has no effect on Mac and Windows. | |
| 69 // This loads the necessary NSS library files so that NSS can be initialized | |
| 70 // after loading additional library files is disallowed, for example when the | |
| 71 // sandbox is active. | |
| 72 // | |
| 73 // Note that this does not load libnssckbi.so which contains the root | |
| 74 // certificates. | |
| 75 void LoadNSSLibraries(); | |
| 76 | |
| 77 // Check if the current NSS version is greater than or equals to |version|. | |
| 78 // A sample version string is "3.12.3". | |
| 79 bool CheckNSSVersion(const char* version); | |
| 80 | |
| 81 #if defined(OS_CHROMEOS) | |
| 82 // Open the r/w nssdb that's stored inside the user's encrypted home directory. | |
| 83 void OpenPersistentNSSDB(); | |
| 84 #endif | |
| 85 | |
| 86 // Convert a NSS PRTime value into a base::Time object. | |
| 87 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. | |
| 88 Time PRTimeToBaseTime(int64 prtime); | |
| 
wtc
2011/04/07 05:35:53
Can you find out if any code in 'base' calls PRTim
 
rvargas (doing something else)
2011/04/08 21:04:07
Nobody.
 
wtc
2011/04/08 21:14:18
Thank you for checking.  The reason I asked is tha
 | |
| 89 | |
| 90 #if defined(USE_NSS) | |
| 91 // Exposed for unittests only. |path| should be an existing directory under | |
| 92 // which the DB files will be placed. |description| is a user-visible name for | |
| 93 // the DB, as a utf8 string, which will be truncated at 32 bytes. | |
| 94 bool OpenTestNSSDB(const FilePath& path, const char* description); | |
| 95 void CloseTestNSSDB(); | |
| 96 | |
| 97 // NSS has a bug which can cause a deadlock or stall in some cases when writing | |
| 98 // to the certDB and keyDB. It also has a bug which causes concurrent key pair | |
| 99 // generations to scribble over each other. To work around this, we synchronize | |
| 100 // writes to the NSS databases with a global lock. The lock is hidden beneath a | |
| 101 // function for easy disabling when the bug is fixed. Callers should allow for | |
| 102 // it to return NULL in the future. | |
| 103 // | |
| 104 // See https://bugzilla.mozilla.org/show_bug.cgi?id=564011 | |
| 105 Lock* GetNSSWriteLock(); | |
| 106 | |
| 107 // A helper class that acquires the NSS write Lock while the AutoNSSWriteLock | |
| 108 // is in scope. | |
| 109 class AutoNSSWriteLock { | |
| 110 public: | |
| 111 AutoNSSWriteLock(); | |
| 112 ~AutoNSSWriteLock(); | |
| 113 private: | |
| 114 Lock *lock_; | |
| 115 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); | |
| 116 }; | |
| 117 | |
| 118 #endif // defined(USE_NSS) | |
| 119 | |
| 120 } // namespace base | |
| 121 | |
| 122 #endif // BASE_NSS_UTIL_H_ | |
| OLD | NEW |