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 "crypto/crypto_export.h" | 10 #include "crypto/crypto_export.h" |
(...skipping 84 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 | 95 // Open the r/w nssdb that's stored inside the user's encrypted home |
96 // directory. This is the default slot returned by | 96 // directory. This is the default slot returned by |
97 // GetPublicNSSKeySlot(). | 97 // GetPublicNSSKeySlot(). |
98 CRYPTO_EXPORT void OpenPersistentNSSDB(); | 98 CRYPTO_EXPORT void OpenPersistentNSSDB(); |
99 | 99 |
100 // Indicates that NSS should load the Chaps library so that we | 100 // Indicates that NSS should load the Chaps library so that we |
101 // can access the TPM through NSS. Once this is called, | 101 // can access the TPM through NSS. Once this is called, |
102 // GetPrivateNSSKeySlot() will return the TPM slot if one was found. | 102 // GetPrivateNSSKeySlot() will return the TPM slot if one was found. |
103 CRYPTO_EXPORT void EnableTPMTokenForNSS(); | 103 CRYPTO_EXPORT void EnableTPMTokenForNSS(); |
104 | 104 |
105 // 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 | |
107 // EnableTPMTokenForNSS has been called with a non-null delegate. | |
108 CRYPTO_EXPORT void GetTPMTokenInfo(std::string* token_name, | |
109 std::string* user_pin); | |
110 | |
111 // Returns true if the TPM is owned and PKCS#11 initialized with the | 105 // 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 | 106 // user and security officer PINs, and has been enabled in NSS by |
113 // calling EnableTPMForNSS, and Chaps has been successfully | 107 // calling EnableTPMForNSS, and Chaps has been successfully |
114 // loaded into NSS. | 108 // loaded into NSS. |
115 CRYPTO_EXPORT bool IsTPMTokenReady(); | 109 CRYPTO_EXPORT bool IsTPMTokenReady(); |
116 | 110 |
117 // Initialize the TPM token. Does nothing if it is already initialized. | 111 // Initialize the TPM token. Does nothing if it is already initialized. |
118 CRYPTO_EXPORT bool InitializeTPMToken(const std::string& token_name, | 112 CRYPTO_EXPORT bool InitializeTPMToken(int token_slot_id); |
119 int token_slot_id, | |
120 const std::string& user_pin); | |
121 #endif | 113 #endif |
122 | 114 |
123 // Convert a NSS PRTime value into a base::Time object. | 115 // 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. | 116 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. |
125 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); | 117 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); |
126 | 118 |
127 // Convert a base::Time object into a PRTime value. | 119 // Convert a base::Time object into a PRTime value. |
128 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. | 120 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. |
129 CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time); | 121 CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time); |
130 | 122 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 private: | 157 private: |
166 base::Lock *lock_; | 158 base::Lock *lock_; |
167 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); | 159 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); |
168 }; | 160 }; |
169 | 161 |
170 #endif // defined(USE_NSS) | 162 #endif // defined(USE_NSS) |
171 | 163 |
172 } // namespace crypto | 164 } // namespace crypto |
173 | 165 |
174 #endif // CRYPTO_NSS_UTIL_H_ | 166 #endif // CRYPTO_NSS_UTIL_H_ |
OLD | NEW |