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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 DCHECK(i != chromeos_user_map_.end()); | 571 DCHECK(i != chromeos_user_map_.end()); |
572 delete i->second; | 572 delete i->second; |
573 chromeos_user_map_.erase(i); | 573 chromeos_user_map_.erase(i); |
574 } | 574 } |
575 | 575 |
576 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { | 576 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { |
577 // Ensure that a previous value of test_system_slot_ is not overwritten. | 577 // Ensure that a previous value of test_system_slot_ is not overwritten. |
578 // Unsetting, i.e. setting a NULL, however is allowed. | 578 // Unsetting, i.e. setting a NULL, however is allowed. |
579 DCHECK(!slot || !test_system_slot_); | 579 DCHECK(!slot || !test_system_slot_); |
580 test_system_slot_ = slot.Pass(); | 580 test_system_slot_ = slot.Pass(); |
| 581 if (test_system_slot_) { |
| 582 EnableTPMTokenForNSS(); |
| 583 tpm_slot_.reset(PK11_ReferenceSlot(test_system_slot_.get())); |
| 584 } else { |
| 585 tpm_slot_.reset(); |
| 586 } |
581 } | 587 } |
582 #endif // defined(OS_CHROMEOS) | 588 #endif // defined(OS_CHROMEOS) |
583 | 589 |
584 #if !defined(OS_CHROMEOS) | 590 #if !defined(OS_CHROMEOS) |
585 PK11SlotInfo* GetPersistentNSSKeySlot() { | 591 PK11SlotInfo* GetPersistentNSSKeySlot() { |
586 // TODO(mattm): Change to DCHECK when callers have been fixed. | 592 // TODO(mattm): Change to DCHECK when callers have been fixed. |
587 if (!thread_checker_.CalledOnValidThread()) { | 593 if (!thread_checker_.CalledOnValidThread()) { |
588 DVLOG(1) << "Called on wrong thread.\n" | 594 DVLOG(1) << "Called on wrong thread.\n" |
589 << base::debug::StackTrace().ToString(); | 595 << base::debug::StackTrace().ToString(); |
590 } | 596 } |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 } | 1012 } |
1007 #endif // defined(USE_NSS) | 1013 #endif // defined(USE_NSS) |
1008 | 1014 |
1009 #if defined(OS_CHROMEOS) | 1015 #if defined(OS_CHROMEOS) |
1010 ScopedPK11Slot GetSystemNSSKeySlot( | 1016 ScopedPK11Slot GetSystemNSSKeySlot( |
1011 const base::Callback<void(ScopedPK11Slot)>& callback) { | 1017 const base::Callback<void(ScopedPK11Slot)>& callback) { |
1012 return g_nss_singleton.Get().GetSystemNSSKeySlot(callback); | 1018 return g_nss_singleton.Get().GetSystemNSSKeySlot(callback); |
1013 } | 1019 } |
1014 | 1020 |
1015 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { | 1021 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { |
1016 g_nss_singleton.Get().SetSystemKeySlotForTesting(ScopedPK11Slot()); | 1022 g_nss_singleton.Get().SetSystemKeySlotForTesting(slot.Pass()); |
1017 } | 1023 } |
1018 | 1024 |
1019 void EnableTPMTokenForNSS() { | 1025 void EnableTPMTokenForNSS() { |
1020 g_nss_singleton.Get().EnableTPMTokenForNSS(); | 1026 g_nss_singleton.Get().EnableTPMTokenForNSS(); |
1021 } | 1027 } |
1022 | 1028 |
1023 bool IsTPMTokenEnabledForNSS() { | 1029 bool IsTPMTokenEnabledForNSS() { |
1024 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS(); | 1030 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS(); |
1025 } | 1031 } |
1026 | 1032 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); | 1095 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); |
1090 } | 1096 } |
1091 | 1097 |
1092 #if !defined(OS_CHROMEOS) | 1098 #if !defined(OS_CHROMEOS) |
1093 PK11SlotInfo* GetPersistentNSSKeySlot() { | 1099 PK11SlotInfo* GetPersistentNSSKeySlot() { |
1094 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); | 1100 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); |
1095 } | 1101 } |
1096 #endif | 1102 #endif |
1097 | 1103 |
1098 } // namespace crypto | 1104 } // namespace crypto |
OLD | NEW |