Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: crypto/nss_util.cc

Issue 424523002: Enable system NSS key slot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor changes. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 DCHECK(i != chromeos_user_map_.end()); 572 DCHECK(i != chromeos_user_map_.end());
573 delete i->second; 573 delete i->second;
574 chromeos_user_map_.erase(i); 574 chromeos_user_map_.erase(i);
575 } 575 }
576 576
577 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { 577 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) {
578 // Ensure that a previous value of test_system_slot_ is not overwritten. 578 // Ensure that a previous value of test_system_slot_ is not overwritten.
579 // Unsetting, i.e. setting a NULL, however is allowed. 579 // Unsetting, i.e. setting a NULL, however is allowed.
580 DCHECK(!slot || !test_system_slot_); 580 DCHECK(!slot || !test_system_slot_);
581 test_system_slot_ = slot.Pass(); 581 test_system_slot_ = slot.Pass();
582 if (test_system_slot_) {
583 EnableTPMTokenForNSS();
pneubeck (no reviews) 2014/07/31 06:31:25 This one should actually not be necessary and I'll
584 tpm_slot_.reset(PK11_ReferenceSlot(test_system_slot_.get()));
mattm 2014/07/30 22:57:34 need to call tpm_ready_callback_list_ callbacks to
pneubeck (no reviews) 2014/07/31 06:31:25 These callbacks are usually triggered by a Initial
mattm 2014/07/31 10:29:30 Right, my point was when the test uses software sl
pneubeck (no reviews) 2014/07/31 10:48:54 Setting tpm_slot_ toggles IsTPMTokenReady to true
pneubeck (no reviews) 2014/08/01 10:02:28 Thinking about this again, I see now what you mean
585 } else {
586 tpm_slot_.reset();
587 }
582 } 588 }
583 #endif // defined(OS_CHROMEOS) 589 #endif // defined(OS_CHROMEOS)
584 590
585 #if !defined(OS_CHROMEOS) 591 #if !defined(OS_CHROMEOS)
586 PK11SlotInfo* GetPersistentNSSKeySlot() { 592 PK11SlotInfo* GetPersistentNSSKeySlot() {
587 // TODO(mattm): Change to DCHECK when callers have been fixed. 593 // TODO(mattm): Change to DCHECK when callers have been fixed.
588 if (!thread_checker_.CalledOnValidThread()) { 594 if (!thread_checker_.CalledOnValidThread()) {
589 DVLOG(1) << "Called on wrong thread.\n" 595 DVLOG(1) << "Called on wrong thread.\n"
590 << base::debug::StackTrace().ToString(); 596 << base::debug::StackTrace().ToString();
591 } 597 }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 1013 }
1008 #endif // defined(USE_NSS) 1014 #endif // defined(USE_NSS)
1009 1015
1010 #if defined(OS_CHROMEOS) 1016 #if defined(OS_CHROMEOS)
1011 ScopedPK11Slot GetSystemNSSKeySlot( 1017 ScopedPK11Slot GetSystemNSSKeySlot(
1012 const base::Callback<void(ScopedPK11Slot)>& callback) { 1018 const base::Callback<void(ScopedPK11Slot)>& callback) {
1013 return g_nss_singleton.Get().GetSystemNSSKeySlot(callback); 1019 return g_nss_singleton.Get().GetSystemNSSKeySlot(callback);
1014 } 1020 }
1015 1021
1016 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { 1022 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) {
1017 g_nss_singleton.Get().SetSystemKeySlotForTesting(ScopedPK11Slot()); 1023 g_nss_singleton.Get().SetSystemKeySlotForTesting(slot.Pass());
1018 } 1024 }
1019 1025
1020 void EnableTPMTokenForNSS() { 1026 void EnableTPMTokenForNSS() {
1021 g_nss_singleton.Get().EnableTPMTokenForNSS(); 1027 g_nss_singleton.Get().EnableTPMTokenForNSS();
1022 } 1028 }
1023 1029
1024 bool IsTPMTokenEnabledForNSS() { 1030 bool IsTPMTokenEnabledForNSS() {
1025 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS(); 1031 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS();
1026 } 1032 }
1027 1033
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); 1096 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
1091 } 1097 }
1092 1098
1093 #if !defined(OS_CHROMEOS) 1099 #if !defined(OS_CHROMEOS)
1094 PK11SlotInfo* GetPersistentNSSKeySlot() { 1100 PK11SlotInfo* GetPersistentNSSKeySlot() {
1095 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); 1101 return g_nss_singleton.Get().GetPersistentNSSKeySlot();
1096 } 1102 }
1097 #endif 1103 #endif
1098 1104
1099 } // namespace crypto 1105 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698