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 #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 <pk11pub.h> | 9 #include <pk11pub.h> |
10 #include <plarena.h> | 10 #include <plarena.h> |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 SECStatus rv = SECMOD_UpdateSlotList(chaps_module); | 443 SECStatus rv = SECMOD_UpdateSlotList(chaps_module); |
444 if (rv != SECSuccess) | 444 if (rv != SECSuccess) |
445 PLOG(ERROR) << "SECMOD_UpdateSlotList failed: " << PORT_GetError(); | 445 PLOG(ERROR) << "SECMOD_UpdateSlotList failed: " << PORT_GetError(); |
446 | 446 |
447 PK11SlotInfo* slot = SECMOD_LookupSlot(chaps_module->moduleID, slot_id); | 447 PK11SlotInfo* slot = SECMOD_LookupSlot(chaps_module->moduleID, slot_id); |
448 if (!slot) | 448 if (!slot) |
449 LOG(ERROR) << "TPM slot " << slot_id << " not found."; | 449 LOG(ERROR) << "TPM slot " << slot_id << " not found."; |
450 return crypto::ScopedPK11Slot(slot); | 450 return crypto::ScopedPK11Slot(slot); |
451 } | 451 } |
452 | 452 |
453 bool InitializeNSSForChromeOSUser( | 453 bool InitializeNSSForChromeOSUser(const std::string& username_hash, |
454 const std::string& email, | 454 const base::FilePath& path) { |
455 const std::string& username_hash, | |
456 const base::FilePath& path) { | |
457 DCHECK(thread_checker_.CalledOnValidThread()); | 455 DCHECK(thread_checker_.CalledOnValidThread()); |
458 if (chromeos_user_map_.find(username_hash) != chromeos_user_map_.end()) { | 456 if (chromeos_user_map_.find(username_hash) != chromeos_user_map_.end()) { |
459 // This user already exists in our mapping. | 457 // This user already exists in our mapping. |
460 DVLOG(2) << username_hash << " already initialized."; | 458 DVLOG(2) << username_hash << " already initialized."; |
461 return false; | 459 return false; |
462 } | 460 } |
463 | 461 |
464 DVLOG(2) << "Opening NSS DB " << path.value(); | 462 DVLOG(2) << "Opening NSS DB " << path.value(); |
465 std::string db_name = base::StringPrintf( | 463 std::string db_name = base::StringPrintf( |
466 "%s %s", kUserNSSDatabaseName, username_hash.c_str()); | 464 "%s %s", kUserNSSDatabaseName, username_hash.c_str()); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 return g_nss_singleton.Get().IsTPMTokenReady(callback); | 1036 return g_nss_singleton.Get().IsTPMTokenReady(callback); |
1039 } | 1037 } |
1040 | 1038 |
1041 void InitializeTPMTokenAndSystemSlot( | 1039 void InitializeTPMTokenAndSystemSlot( |
1042 int token_slot_id, | 1040 int token_slot_id, |
1043 const base::Callback<void(bool)>& callback) { | 1041 const base::Callback<void(bool)>& callback) { |
1044 g_nss_singleton.Get().InitializeTPMTokenAndSystemSlot(token_slot_id, | 1042 g_nss_singleton.Get().InitializeTPMTokenAndSystemSlot(token_slot_id, |
1045 callback); | 1043 callback); |
1046 } | 1044 } |
1047 | 1045 |
1048 bool InitializeNSSForChromeOSUser( | 1046 bool InitializeNSSForChromeOSUser(const std::string& username_hash, |
1049 const std::string& email, | 1047 const base::FilePath& path) { |
1050 const std::string& username_hash, | 1048 return g_nss_singleton.Get().InitializeNSSForChromeOSUser(username_hash, |
1051 const base::FilePath& path) { | 1049 path); |
1052 return g_nss_singleton.Get().InitializeNSSForChromeOSUser( | |
1053 email, username_hash, path); | |
1054 } | 1050 } |
1055 | 1051 |
1056 bool ShouldInitializeTPMForChromeOSUser(const std::string& username_hash) { | 1052 bool ShouldInitializeTPMForChromeOSUser(const std::string& username_hash) { |
1057 return g_nss_singleton.Get().ShouldInitializeTPMForChromeOSUser( | 1053 return g_nss_singleton.Get().ShouldInitializeTPMForChromeOSUser( |
1058 username_hash); | 1054 username_hash); |
1059 } | 1055 } |
1060 | 1056 |
1061 void WillInitializeTPMForChromeOSUser(const std::string& username_hash) { | 1057 void WillInitializeTPMForChromeOSUser(const std::string& username_hash) { |
1062 g_nss_singleton.Get().WillInitializeTPMForChromeOSUser(username_hash); | 1058 g_nss_singleton.Get().WillInitializeTPMForChromeOSUser(username_hash); |
1063 } | 1059 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); | 1095 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); |
1100 } | 1096 } |
1101 | 1097 |
1102 #if !defined(OS_CHROMEOS) | 1098 #if !defined(OS_CHROMEOS) |
1103 PK11SlotInfo* GetPersistentNSSKeySlot() { | 1099 PK11SlotInfo* GetPersistentNSSKeySlot() { |
1104 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); | 1100 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); |
1105 } | 1101 } |
1106 #endif | 1102 #endif |
1107 | 1103 |
1108 } // namespace crypto | 1104 } // namespace crypto |
OLD | NEW |