| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "crypto/nss_util.h" | 5 #include "crypto/nss_util.h" |
| 6 #include "crypto/nss_util_internal.h" | 6 #include "crypto/nss_util_internal.h" |
| 7 | 7 |
| 8 #include <nss.h> | 8 #include <nss.h> |
| 9 #include <plarena.h> | 9 #include <plarena.h> |
| 10 #include <prerror.h> | 10 #include <prerror.h> |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // provider, which are still read-only (because we initialized | 228 // provider, which are still read-only (because we initialized |
| 229 // NSS before we had a cryptohome mounted). | 229 // NSS before we had a cryptohome mounted). |
| 230 software_slot_ = OpenUserDB(GetDefaultConfigDirectory(), | 230 software_slot_ = OpenUserDB(GetDefaultConfigDirectory(), |
| 231 kNSSDatabaseName); | 231 kNSSDatabaseName); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 void EnableTPMTokenForNSS(TPMTokenInfoDelegate* info_delegate) { | 235 void EnableTPMTokenForNSS(TPMTokenInfoDelegate* info_delegate) { |
| 236 CHECK(info_delegate); | 236 CHECK(info_delegate); |
| 237 tpm_token_info_delegate_.reset(info_delegate); | 237 tpm_token_info_delegate_.reset(info_delegate); |
| 238 // Try to load once to avoid jank later. Ignore the return value, |
| 239 // because if it fails we will try again later. |
| 240 EnsureTPMTokenReady(); |
| 238 } | 241 } |
| 239 | 242 |
| 240 // This is called whenever we want to make sure opencryptoki is | 243 // This is called whenever we want to make sure opencryptoki is |
| 241 // properly loaded, because it can fail shortly after the initial | 244 // properly loaded, because it can fail shortly after the initial |
| 242 // login while the PINs are being initialized, and we want to retry | 245 // login while the PINs are being initialized, and we want to retry |
| 243 // if this happens. | 246 // if this happens. |
| 244 bool EnsureTPMTokenReady() { | 247 bool EnsureTPMTokenReady() { |
| 245 // If EnableTPMTokenForNSS hasn't been called, return false. | 248 // If EnableTPMTokenForNSS hasn't been called, return false. |
| 246 if (tpm_token_info_delegate_.get() == NULL) | 249 if (tpm_token_info_delegate_.get() == NULL) |
| 247 return false; | 250 return false; |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 785 |
| 783 PK11SlotInfo* GetPublicNSSKeySlot() { | 786 PK11SlotInfo* GetPublicNSSKeySlot() { |
| 784 return g_nss_singleton.Get().GetPublicNSSKeySlot(); | 787 return g_nss_singleton.Get().GetPublicNSSKeySlot(); |
| 785 } | 788 } |
| 786 | 789 |
| 787 PK11SlotInfo* GetPrivateNSSKeySlot() { | 790 PK11SlotInfo* GetPrivateNSSKeySlot() { |
| 788 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); | 791 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); |
| 789 } | 792 } |
| 790 | 793 |
| 791 } // namespace crypto | 794 } // namespace crypto |
| OLD | NEW |