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

Side by Side Diff: crypto/nss_util.cc

Issue 330213002: *wip* NSS: handle chromeos system slot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review #1 changes, remove chromeos/ changes Created 6 years, 6 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 645 }
646 } 646 }
647 #endif 647 #endif
648 // If we weren't supposed to enable the TPM for NSS, then return 648 // If we weren't supposed to enable the TPM for NSS, then return
649 // the software slot. 649 // the software slot.
650 if (software_slot_) 650 if (software_slot_)
651 return PK11_ReferenceSlot(software_slot_); 651 return PK11_ReferenceSlot(software_slot_);
652 return PK11_GetInternalKeySlot(); 652 return PK11_GetInternalKeySlot();
653 } 653 }
654 654
655 #if defined(OS_CHROMEOS)
656 PK11SlotInfo* GetSystemNSSKeySlot() {
657 // TODO: what about when system slot is disabled?
658 // TODO: can GetPrivateNSSKeySlot be removed / disabled ?
659 if (tpm_token_enabled_for_nss_) {
660 if (IsTPMTokenReady(base::Closure())) {
661 return PK11_ReferenceSlot(tpm_slot_);
662 }
663 }
664 // If we were supposed to get the hardware token, but were
665 // unable to, return NULL rather than fall back to sofware.
666 return NULL;
667 }
668 #endif
669
655 #if defined(USE_NSS) 670 #if defined(USE_NSS)
656 base::Lock* write_lock() { 671 base::Lock* write_lock() {
657 return &write_lock_; 672 return &write_lock_;
658 } 673 }
659 #endif // defined(USE_NSS) 674 #endif // defined(USE_NSS)
660 675
661 // This method is used to force NSS to be initialized without a DB. 676 // This method is used to force NSS to be initialized without a DB.
662 // Call this method before NSSInitSingleton() is constructed. 677 // Call this method before NSSInitSingleton() is constructed.
663 static void ForceNoDBInit() { 678 static void ForceNoDBInit() {
664 force_nodb_init_ = true; 679 force_nodb_init_ = true;
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 SECMOD_GetReadLock(lock_); 1078 SECMOD_GetReadLock(lock_);
1064 } 1079 }
1065 1080
1066 AutoSECMODListReadLock::~AutoSECMODListReadLock() { 1081 AutoSECMODListReadLock::~AutoSECMODListReadLock() {
1067 SECMOD_ReleaseReadLock(lock_); 1082 SECMOD_ReleaseReadLock(lock_);
1068 } 1083 }
1069 1084
1070 #endif // defined(USE_NSS) 1085 #endif // defined(USE_NSS)
1071 1086
1072 #if defined(OS_CHROMEOS) 1087 #if defined(OS_CHROMEOS)
1088 PK11SlotInfo* GetSystemNSSKeySlot() {
1089 return g_nss_singleton.Get().GetSystemNSSKeySlot();
1090 }
1091
1073 void OpenPersistentNSSDB() { 1092 void OpenPersistentNSSDB() {
1074 g_nss_singleton.Get().OpenPersistentNSSDB(); 1093 g_nss_singleton.Get().OpenPersistentNSSDB();
1075 } 1094 }
1076 1095
1077 void EnableTPMTokenForNSS() { 1096 void EnableTPMTokenForNSS() {
1078 g_nss_singleton.Get().EnableTPMTokenForNSS(); 1097 g_nss_singleton.Get().EnableTPMTokenForNSS();
1079 } 1098 }
1080 1099
1081 bool IsTPMTokenEnabledForNSS() { 1100 bool IsTPMTokenEnabledForNSS() {
1082 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS(); 1101 return g_nss_singleton.Get().IsTPMTokenEnabledForNSS();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 1171
1153 PK11SlotInfo* GetPublicNSSKeySlot() { 1172 PK11SlotInfo* GetPublicNSSKeySlot() {
1154 return g_nss_singleton.Get().GetPublicNSSKeySlot(); 1173 return g_nss_singleton.Get().GetPublicNSSKeySlot();
1155 } 1174 }
1156 1175
1157 PK11SlotInfo* GetPrivateNSSKeySlot() { 1176 PK11SlotInfo* GetPrivateNSSKeySlot() {
1158 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); 1177 return g_nss_singleton.Get().GetPrivateNSSKeySlot();
1159 } 1178 }
1160 1179
1161 } // namespace crypto 1180 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698