| 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 "crypto/crypto_export.h" | 11 #include "crypto/crypto_export.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class FilePath; | 14 class FilePath; |
| 14 class Lock; | 15 class Lock; |
| 15 class Time; | 16 class Time; |
| 16 } // namespace base | 17 } // namespace base |
| 17 | 18 |
| 18 // This file specifically doesn't depend on any NSS or NSPR headers because it | 19 // This file specifically doesn't depend on any NSS or NSPR headers because it |
| 19 // is included by various (non-crypto) parts of chrome to call the | 20 // is included by various (non-crypto) parts of chrome to call the |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Open the r/w nssdb that's stored inside the user's encrypted home | 96 // Open the r/w nssdb that's stored inside the user's encrypted home |
| 96 // directory. This is the default slot returned by | 97 // directory. This is the default slot returned by |
| 97 // GetPublicNSSKeySlot(). | 98 // GetPublicNSSKeySlot(). |
| 98 CRYPTO_EXPORT void OpenPersistentNSSDB(); | 99 CRYPTO_EXPORT void OpenPersistentNSSDB(); |
| 99 | 100 |
| 100 // Indicates that NSS should load the Chaps library so that we | 101 // Indicates that NSS should load the Chaps library so that we |
| 101 // can access the TPM through NSS. Once this is called, | 102 // can access the TPM through NSS. Once this is called, |
| 102 // GetPrivateNSSKeySlot() will return the TPM slot if one was found. | 103 // GetPrivateNSSKeySlot() will return the TPM slot if one was found. |
| 103 CRYPTO_EXPORT void EnableTPMTokenForNSS(); | 104 CRYPTO_EXPORT void EnableTPMTokenForNSS(); |
| 104 | 105 |
| 106 // Returns true if EnableTPMTokenForNSS has been called. |
| 107 CRYPTO_EXPORT bool IsTPMTokenEnabledForNSS(); |
| 108 |
| 105 // Get name and user PIN for the built-in TPM token on ChromeOS. | 109 // Get name and user PIN for the built-in TPM token on ChromeOS. |
| 106 // Either one can safely be NULL. Should only be called after | 110 // Either one can safely be NULL. Should only be called after |
| 107 // EnableTPMTokenForNSS has been called with a non-null delegate. | 111 // EnableTPMTokenForNSS has been called with a non-null delegate. |
| 108 CRYPTO_EXPORT void GetTPMTokenInfo(std::string* token_name, | 112 CRYPTO_EXPORT void GetTPMTokenInfo(std::string* token_name, |
| 109 std::string* user_pin); | 113 std::string* user_pin); |
| 110 | 114 |
| 111 // Returns true if the TPM is owned and PKCS#11 initialized with the | 115 // 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 | 116 // user and security officer PINs, and has been enabled in NSS by |
| 113 // calling EnableTPMForNSS, and Chaps has been successfully | 117 // calling EnableTPMForNSS, and Chaps has been successfully |
| 114 // loaded into NSS. | 118 // loaded into NSS. |
| 115 CRYPTO_EXPORT bool IsTPMTokenReady(); | 119 CRYPTO_EXPORT bool IsTPMTokenReady(); |
| 116 | 120 |
| 121 // Register a callback to be run when the TPM module is loaded. |
| 122 // If the module is already loaded, the |callback| will be run synchronously. |
| 123 CRYPTO_EXPORT void OnTPMReady(const base::Closure& callback); |
| 124 |
| 117 // Initialize the TPM token. Does nothing if it is already initialized. | 125 // Initialize the TPM token. Does nothing if it is already initialized. |
| 118 CRYPTO_EXPORT bool InitializeTPMToken(const std::string& token_name, | 126 CRYPTO_EXPORT bool InitializeTPMToken(const std::string& token_name, |
| 119 int token_slot_id, | 127 int token_slot_id, |
| 120 const std::string& user_pin); | 128 const std::string& user_pin); |
| 121 #endif | 129 #endif |
| 122 | 130 |
| 123 // Convert a NSS PRTime value into a base::Time object. | 131 // Convert a NSS PRTime value into a base::Time object. |
| 124 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. | 132 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. |
| 125 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); | 133 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); |
| 126 | 134 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 private: | 173 private: |
| 166 base::Lock *lock_; | 174 base::Lock *lock_; |
| 167 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); | 175 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); |
| 168 }; | 176 }; |
| 169 | 177 |
| 170 #endif // defined(USE_NSS) | 178 #endif // defined(USE_NSS) |
| 171 | 179 |
| 172 } // namespace crypto | 180 } // namespace crypto |
| 173 | 181 |
| 174 #endif // CRYPTO_NSS_UTIL_H_ | 182 #endif // CRYPTO_NSS_UTIL_H_ |
| OLD | NEW |