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

Side by Side Diff: crypto/nss_util.cc

Issue 112533002: Add ClientCertStoreChromeOS which only returns the certs for a given user. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 13 matching lines...) Expand all
24 #include <map> 24 #include <map>
25 #include <vector> 25 #include <vector>
26 26
27 #include "base/callback.h" 27 #include "base/callback.h"
28 #include "base/cpu.h" 28 #include "base/cpu.h"
29 #include "base/debug/alias.h" 29 #include "base/debug/alias.h"
30 #include "base/debug/stack_trace.h" 30 #include "base/debug/stack_trace.h"
31 #include "base/environment.h" 31 #include "base/environment.h"
32 #include "base/file_util.h" 32 #include "base/file_util.h"
33 #include "base/files/file_path.h" 33 #include "base/files/file_path.h"
34 #include "base/files/scoped_temp_dir.h"
35 #include "base/lazy_instance.h" 34 #include "base/lazy_instance.h"
36 #include "base/logging.h" 35 #include "base/logging.h"
37 #include "base/memory/scoped_ptr.h" 36 #include "base/memory/scoped_ptr.h"
38 #include "base/metrics/histogram.h" 37 #include "base/metrics/histogram.h"
39 #include "base/native_library.h" 38 #include "base/native_library.h"
40 #include "base/stl_util.h" 39 #include "base/stl_util.h"
41 #include "base/strings/stringprintf.h" 40 #include "base/strings/stringprintf.h"
42 #include "base/threading/thread_checker.h" 41 #include "base/threading/thread_checker.h"
43 #include "base/threading/thread_restrictions.h" 42 #include "base/threading/thread_restrictions.h"
44 #include "build/build_config.h" 43 #include "build/build_config.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 DCHECK(thread_checker_.CalledOnValidThread()); 462 DCHECK(thread_checker_.CalledOnValidThread());
464 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end()); 463 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end());
465 464
466 if (test_slot_) { 465 if (test_slot_) {
467 DVLOG(2) << "returning test_slot_ for " << username_hash; 466 DVLOG(2) << "returning test_slot_ for " << username_hash;
468 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_)); 467 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_));
469 } 468 }
470 469
471 return chromeos_user_map_[username_hash]->GetPrivateSlot(callback); 470 return chromeos_user_map_[username_hash]->GetPrivateSlot(callback);
472 } 471 }
472
473 void CloseTestChromeOSUser(const std::string& username_hash) {
474 DCHECK(thread_checker_.CalledOnValidThread());
475 ChromeOSUserMap::iterator i = chromeos_user_map_.find(username_hash);
476 DCHECK(i != chromeos_user_map_.end());
477 delete i->second;
478 chromeos_user_map_.erase(i);
479 }
473 #endif // defined(OS_CHROMEOS) 480 #endif // defined(OS_CHROMEOS)
474 481
475 482
476 bool OpenTestNSSDB() { 483 bool OpenTestNSSDB() {
477 DCHECK(thread_checker_.CalledOnValidThread()); 484 DCHECK(thread_checker_.CalledOnValidThread());
478 // NSS is allowed to do IO on the current thread since dispatching 485 // NSS is allowed to do IO on the current thread since dispatching
479 // to a dedicated thread would still have the affect of blocking 486 // to a dedicated thread would still have the affect of blocking
480 // the current thread, due to NSS's internal locking requirements 487 // the current thread, due to NSS's internal locking requirements
481 base::ThreadRestrictions::ScopedAllowIO allow_io; 488 base::ThreadRestrictions::ScopedAllowIO allow_io;
482 489
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 } 979 }
973 980
974 bool IsTPMTokenReady(const base::Closure& callback) { 981 bool IsTPMTokenReady(const base::Closure& callback) {
975 return g_nss_singleton.Get().IsTPMTokenReady(callback); 982 return g_nss_singleton.Get().IsTPMTokenReady(callback);
976 } 983 }
977 984
978 bool InitializeTPMToken(int token_slot_id) { 985 bool InitializeTPMToken(int token_slot_id) {
979 return g_nss_singleton.Get().InitializeTPMToken(token_slot_id); 986 return g_nss_singleton.Get().InitializeTPMToken(token_slot_id);
980 } 987 }
981 988
989 ScopedTestNSSChromeOSUser::ScopedTestNSSChromeOSUser(
990 const std::string& username_hash)
991 : username_hash_(username_hash), constructed_successfully_(false) {
992 if (!temp_dir_.CreateUniqueTempDir())
993 return;
994 constructed_successfully_ =
995 InitializeNSSForChromeOSUser(username_hash,
996 username_hash,
997 false /* is_primary_user */,
998 temp_dir_.path());
999 }
1000
1001 ScopedTestNSSChromeOSUser::~ScopedTestNSSChromeOSUser() {
1002 if (constructed_successfully_)
1003 g_nss_singleton.Get().CloseTestChromeOSUser(username_hash_);
1004 }
1005
1006 void ScopedTestNSSChromeOSUser::FinishInit() {
1007 InitializePrivateSoftwareSlotForChromeOSUser(username_hash_);
1008 }
1009
982 bool InitializeNSSForChromeOSUser( 1010 bool InitializeNSSForChromeOSUser(
983 const std::string& email, 1011 const std::string& email,
984 const std::string& username_hash, 1012 const std::string& username_hash,
985 bool is_primary_user, 1013 bool is_primary_user,
986 const base::FilePath& path) { 1014 const base::FilePath& path) {
987 return g_nss_singleton.Get().InitializeNSSForChromeOSUser( 1015 return g_nss_singleton.Get().InitializeNSSForChromeOSUser(
988 email, username_hash, is_primary_user, path); 1016 email, username_hash, is_primary_user, path);
989 } 1017 }
990 void InitializeTPMForChromeOSUser( 1018 void InitializeTPMForChromeOSUser(
991 const std::string& username_hash, 1019 const std::string& username_hash,
(...skipping 27 matching lines...) Expand all
1019 1047
1020 PK11SlotInfo* GetPublicNSSKeySlot() { 1048 PK11SlotInfo* GetPublicNSSKeySlot() {
1021 return g_nss_singleton.Get().GetPublicNSSKeySlot(); 1049 return g_nss_singleton.Get().GetPublicNSSKeySlot();
1022 } 1050 }
1023 1051
1024 PK11SlotInfo* GetPrivateNSSKeySlot() { 1052 PK11SlotInfo* GetPrivateNSSKeySlot() {
1025 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); 1053 return g_nss_singleton.Get().GetPrivateNSSKeySlot();
1026 } 1054 }
1027 1055
1028 } // namespace crypto 1056 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698