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 #ifndef CRYPTO_NSS_UTIL_H_ | 5 #ifndef CRYPTO_NSS_UTIL_H_ |
6 #define CRYPTO_NSS_UTIL_H_ | 6 #define CRYPTO_NSS_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/files/scoped_temp_dir.h" |
12 #include "crypto/crypto_export.h" | 13 #include "crypto/crypto_export.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class FilePath; | 16 class FilePath; |
16 class Lock; | 17 class Lock; |
17 class Time; | 18 class Time; |
18 } // namespace base | 19 } // namespace base |
19 | 20 |
20 // This file specifically doesn't depend on any NSS or NSPR headers because it | 21 // This file specifically doesn't depend on any NSS or NSPR headers because it |
21 // is included by various (non-crypto) parts of chrome to call the | 22 // is included by various (non-crypto) parts of chrome to call the |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // calling EnableTPMForNSS, and Chaps has been successfully | 113 // calling EnableTPMForNSS, and Chaps has been successfully |
113 // loaded into NSS. | 114 // loaded into NSS. |
114 // If |callback| is non-null and the function returns false, the |callback| will | 115 // If |callback| is non-null and the function returns false, the |callback| will |
115 // be run once the TPM is ready. |callback| will never be run if the function | 116 // be run once the TPM is ready. |callback| will never be run if the function |
116 // returns true. | 117 // returns true. |
117 CRYPTO_EXPORT bool IsTPMTokenReady(const base::Closure& callback) | 118 CRYPTO_EXPORT bool IsTPMTokenReady(const base::Closure& callback) |
118 WARN_UNUSED_RESULT; | 119 WARN_UNUSED_RESULT; |
119 | 120 |
120 // Initialize the TPM token. Does nothing if it is already initialized. | 121 // Initialize the TPM token. Does nothing if it is already initialized. |
121 CRYPTO_EXPORT bool InitializeTPMToken(int token_slot_id); | 122 CRYPTO_EXPORT bool InitializeTPMToken(int token_slot_id); |
| 123 |
| 124 // Exposed for unittests only. |
| 125 class CRYPTO_EXPORT_PRIVATE ScopedTestNSSChromeOSUser { |
| 126 public: |
| 127 ScopedTestNSSChromeOSUser(const std::string& username_hash); |
| 128 ~ScopedTestNSSChromeOSUser(); |
| 129 |
| 130 std::string username_hash() const { return username_hash_; } |
| 131 bool constructed_successfully() const { return constructed_successfully_; } |
| 132 |
| 133 // Completes initialization of user. Causes any waiting private slot callbacks |
| 134 // to run. |
| 135 void FinishInit(); |
| 136 |
| 137 private: |
| 138 const std::string username_hash_; |
| 139 base::ScopedTempDir temp_dir_; |
| 140 bool constructed_successfully_; |
| 141 DISALLOW_COPY_AND_ASSIGN(ScopedTestNSSChromeOSUser); |
| 142 }; |
122 #endif | 143 #endif |
123 | 144 |
124 // Convert a NSS PRTime value into a base::Time object. | 145 // Convert a NSS PRTime value into a base::Time object. |
125 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. | 146 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. |
126 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); | 147 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); |
127 | 148 |
128 // Convert a base::Time object into a PRTime value. | 149 // Convert a base::Time object into a PRTime value. |
129 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. | 150 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. |
130 CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time); | 151 CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time); |
131 | 152 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 private: | 187 private: |
167 base::Lock *lock_; | 188 base::Lock *lock_; |
168 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); | 189 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); |
169 }; | 190 }; |
170 | 191 |
171 #endif // defined(USE_NSS) | 192 #endif // defined(USE_NSS) |
172 | 193 |
173 } // namespace crypto | 194 } // namespace crypto |
174 | 195 |
175 #endif // CRYPTO_NSS_UTIL_H_ | 196 #endif // CRYPTO_NSS_UTIL_H_ |
OLD | NEW |