| 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.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "crypto/crypto_export.h" | 13 #include "crypto/crypto_export.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class FilePath; | 16 class FilePath; |
| 17 class Lock; | 17 class Lock; |
| 18 class Time; | 18 class Time; |
| 19 } // namespace base | 19 } // namespace base |
| 20 | 20 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Returns true if the TPM is owned and PKCS#11 initialized with the | 111 // Returns true if the TPM is owned and PKCS#11 initialized with the |
| 112 // user and security officer PINs, and has been enabled in NSS by | 112 // user and security officer PINs, and has been enabled in NSS by |
| 113 // calling EnableTPMForNSS, and Chaps has been successfully | 113 // calling EnableTPMForNSS, and Chaps has been successfully |
| 114 // loaded into NSS. | 114 // loaded into NSS. |
| 115 // 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 |
| 116 // 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 |
| 117 // returns true. | 117 // returns true. |
| 118 CRYPTO_EXPORT bool IsTPMTokenReady(const base::Closure& callback) | 118 CRYPTO_EXPORT bool IsTPMTokenReady(const base::Closure& callback) |
| 119 WARN_UNUSED_RESULT; | 119 WARN_UNUSED_RESULT; |
| 120 | 120 |
| 121 // Initialize the TPM token. Does nothing if it is already initialized. | 121 // Initialize the TPM token. The |callback| will run on the same thread with |
| 122 CRYPTO_EXPORT bool InitializeTPMToken(int token_slot_id); | 122 // true if the token and slot were successfully loaded or were already |
| 123 // initialized. |callback| will be passed false if loading failed. |
| 124 // Once called, InitializeTPMToken must not be called again until the |callback| |
| 125 // has been run. |
| 126 CRYPTO_EXPORT void InitializeTPMToken( |
| 127 int token_slot_id, |
| 128 const base::Callback<void(bool)>& callback); |
| 123 | 129 |
| 124 // Exposed for unittests only. | 130 // Exposed for unittests only. |
| 125 class CRYPTO_EXPORT_PRIVATE ScopedTestNSSChromeOSUser { | 131 class CRYPTO_EXPORT_PRIVATE ScopedTestNSSChromeOSUser { |
| 126 public: | 132 public: |
| 127 explicit ScopedTestNSSChromeOSUser(const std::string& username_hash); | 133 explicit ScopedTestNSSChromeOSUser(const std::string& username_hash); |
| 128 ~ScopedTestNSSChromeOSUser(); | 134 ~ScopedTestNSSChromeOSUser(); |
| 129 | 135 |
| 130 std::string username_hash() const { return username_hash_; } | 136 std::string username_hash() const { return username_hash_; } |
| 131 bool constructed_successfully() const { return constructed_successfully_; } | 137 bool constructed_successfully() const { return constructed_successfully_; } |
| 132 | 138 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 private: | 193 private: |
| 188 base::Lock *lock_; | 194 base::Lock *lock_; |
| 189 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); | 195 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); |
| 190 }; | 196 }; |
| 191 | 197 |
| 192 #endif // defined(USE_NSS) | 198 #endif // defined(USE_NSS) |
| 193 | 199 |
| 194 } // namespace crypto | 200 } // namespace crypto |
| 195 | 201 |
| 196 #endif // CRYPTO_NSS_UTIL_H_ | 202 #endif // CRYPTO_NSS_UTIL_H_ |
| OLD | NEW |