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

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: 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 566 }
567 567
568 void CloseChromeOSUserForTesting(const std::string& username_hash) { 568 void CloseChromeOSUserForTesting(const std::string& username_hash) {
569 DCHECK(thread_checker_.CalledOnValidThread()); 569 DCHECK(thread_checker_.CalledOnValidThread());
570 ChromeOSUserMap::iterator i = chromeos_user_map_.find(username_hash); 570 ChromeOSUserMap::iterator i = chromeos_user_map_.find(username_hash);
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(bool skip_tpm_initialization,
577 ScopedPK11Slot slot) {
577 // 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.
578 // Unsetting, i.e. setting a NULL, however is allowed. 579 // Unsetting, i.e. setting a NULL, however is allowed.
579 DCHECK(!slot || !test_system_slot_); 580 DCHECK(!slot || !test_system_slot_);
580 test_system_slot_ = slot.Pass(); 581 test_system_slot_ = slot.Pass();
582 if (skip_tpm_initialization) {
583 EnableTPMTokenForNSS();
584 CHECK(test_system_slot_);
585 tpm_slot_ = PK11_ReferenceSlot(test_system_slot_.get());
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 SECMOD_ReleaseReadLock(lock_); 1014 SECMOD_ReleaseReadLock(lock_);
1009 } 1015 }
1010 #endif // defined(USE_NSS) 1016 #endif // defined(USE_NSS)
1011 1017
1012 #if defined(OS_CHROMEOS) 1018 #if defined(OS_CHROMEOS)
1013 ScopedPK11Slot GetSystemNSSKeySlot( 1019 ScopedPK11Slot GetSystemNSSKeySlot(
1014 const base::Callback<void(ScopedPK11Slot)>& callback) { 1020 const base::Callback<void(ScopedPK11Slot)>& callback) {
1015 return g_nss_singleton.Get().GetSystemNSSKeySlot(callback); 1021 return g_nss_singleton.Get().GetSystemNSSKeySlot(callback);
1016 } 1022 }
1017 1023
1018 void SetSystemKeySlotForTesting(ScopedPK11Slot slot) { 1024 void SetSystemKeySlotForTesting(bool skip_tpm_initialization,
1019 g_nss_singleton.Get().SetSystemKeySlotForTesting(ScopedPK11Slot()); 1025 ScopedPK11Slot slot) {
1026 g_nss_singleton.Get().SetSystemKeySlotForTesting(skip_tpm_initialization,
1027 slot.Pass());
1020 } 1028 }
1021 1029
1022 void EnableTPMTokenForNSS() { 1030 void EnableTPMTokenForNSS() {
1023 g_nss_singleton.Get().EnableTPMTokenForNSS(); 1031 g_nss_singleton.Get().EnableTPMTokenForNSS();
1024 } 1032 }
1025 1033
1026 bool IsTPMTokenEnabledForNSS() { 1034 bool IsTPMTokenEnabledForNSS() {
1027 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS(); 1035 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS();
1028 } 1036 }
1029 1037
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); 1100 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
1093 } 1101 }
1094 1102
1095 #if !defined(OS_CHROMEOS) 1103 #if !defined(OS_CHROMEOS)
1096 PK11SlotInfo* GetPersistentNSSKeySlot() { 1104 PK11SlotInfo* GetPersistentNSSKeySlot() {
1097 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); 1105 return g_nss_singleton.Get().GetPersistentNSSKeySlot();
1098 } 1106 }
1099 #endif 1107 #endif
1100 1108
1101 } // namespace crypto 1109 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698