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

Side by Side Diff: crypto/nss_util.cc

Issue 123633002: ChromeOS: Fix crash if login profile triggers client auth. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 6 years, 11 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
« no previous file with comments | « no previous file | crypto/nss_util_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #include <prerror.h> 11 #include <prerror.h>
12 #include <prinit.h> 12 #include <prinit.h>
13 #include <prtime.h> 13 #include <prtime.h>
14 #include <secmod.h> 14 #include <secmod.h>
15 15
16 #if defined(OS_LINUX) 16 #if defined(OS_LINUX)
17 #include <linux/nfs_fs.h> 17 #include <linux/nfs_fs.h>
18 #include <sys/vfs.h> 18 #include <sys/vfs.h>
19 #elif defined(OS_OPENBSD) 19 #elif defined(OS_OPENBSD)
20 #include <sys/mount.h> 20 #include <sys/mount.h>
21 #include <sys/param.h> 21 #include <sys/param.h>
22 #endif 22 #endif
23 23
24 #include <map> 24 #include <map>
25 #include <vector> 25 #include <vector>
26 26
27 #include "base/bind.h"
27 #include "base/callback.h" 28 #include "base/callback.h"
28 #include "base/cpu.h" 29 #include "base/cpu.h"
29 #include "base/debug/alias.h" 30 #include "base/debug/alias.h"
30 #include "base/debug/stack_trace.h" 31 #include "base/debug/stack_trace.h"
31 #include "base/environment.h" 32 #include "base/environment.h"
32 #include "base/file_util.h" 33 #include "base/file_util.h"
33 #include "base/files/file_path.h" 34 #include "base/files/file_path.h"
34 #include "base/lazy_instance.h" 35 #include "base/lazy_instance.h"
35 #include "base/logging.h" 36 #include "base/logging.h"
36 #include "base/memory/scoped_ptr.h" 37 #include "base/memory/scoped_ptr.h"
38 #include "base/message_loop/message_loop.h"
37 #include "base/metrics/histogram.h" 39 #include "base/metrics/histogram.h"
38 #include "base/native_library.h" 40 #include "base/native_library.h"
39 #include "base/stl_util.h" 41 #include "base/stl_util.h"
40 #include "base/strings/stringprintf.h" 42 #include "base/strings/stringprintf.h"
41 #include "base/threading/thread_checker.h" 43 #include "base/threading/thread_checker.h"
42 #include "base/threading/thread_restrictions.h" 44 #include "base/threading/thread_restrictions.h"
43 #include "build/build_config.h" 45 #include "build/build_config.h"
44 46
45 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not 47 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not
46 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't 48 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 DCHECK(thread_checker_.CalledOnValidThread()); 439 DCHECK(thread_checker_.CalledOnValidThread());
438 LOG(WARNING) << "using software private slot for " << username_hash; 440 LOG(WARNING) << "using software private slot for " << username_hash;
439 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end()); 441 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end());
440 chromeos_user_map_[username_hash]->SetPrivateSlot( 442 chromeos_user_map_[username_hash]->SetPrivateSlot(
441 chromeos_user_map_[username_hash]->GetPublicSlot()); 443 chromeos_user_map_[username_hash]->GetPublicSlot());
442 } 444 }
443 445
444 ScopedPK11Slot GetPublicSlotForChromeOSUser( 446 ScopedPK11Slot GetPublicSlotForChromeOSUser(
445 const std::string& username_hash) { 447 const std::string& username_hash) {
446 DCHECK(thread_checker_.CalledOnValidThread()); 448 DCHECK(thread_checker_.CalledOnValidThread());
449
450 if (username_hash.empty()) {
451 DVLOG(2) << "empty username_hash";
452 return ScopedPK11Slot();
453 }
454
447 if (test_slot_) { 455 if (test_slot_) {
448 DVLOG(2) << "returning test_slot_ for " << username_hash; 456 DVLOG(2) << "returning test_slot_ for " << username_hash;
449 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_)); 457 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_));
450 } 458 }
451 459
452 if (chromeos_user_map_.find(username_hash) == chromeos_user_map_.end()) { 460 if (chromeos_user_map_.find(username_hash) == chromeos_user_map_.end()) {
453 LOG(ERROR) << username_hash << " not initialized."; 461 LOG(ERROR) << username_hash << " not initialized.";
454 return ScopedPK11Slot(); 462 return ScopedPK11Slot();
455 } 463 }
456 return chromeos_user_map_[username_hash]->GetPublicSlot(); 464 return chromeos_user_map_[username_hash]->GetPublicSlot();
457 } 465 }
458 466
459 ScopedPK11Slot GetPrivateSlotForChromeOSUser( 467 ScopedPK11Slot GetPrivateSlotForChromeOSUser(
460 const std::string& username_hash, 468 const std::string& username_hash,
461 const base::Callback<void(ScopedPK11Slot)>& callback) { 469 const base::Callback<void(ScopedPK11Slot)>& callback) {
462 DCHECK(thread_checker_.CalledOnValidThread()); 470 DCHECK(thread_checker_.CalledOnValidThread());
471
472 if (username_hash.empty()) {
473 DVLOG(2) << "empty username_hash";
474 if (!callback.is_null()) {
475 base::MessageLoop::current()->PostTask(
476 FROM_HERE, base::Bind(callback, base::Passed(ScopedPK11Slot())));
477 }
478 return ScopedPK11Slot();
479 }
480
463 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end()); 481 DCHECK(chromeos_user_map_.find(username_hash) != chromeos_user_map_.end());
464 482
465 if (test_slot_) { 483 if (test_slot_) {
466 DVLOG(2) << "returning test_slot_ for " << username_hash; 484 DVLOG(2) << "returning test_slot_ for " << username_hash;
467 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_)); 485 return ScopedPK11Slot(PK11_ReferenceSlot(test_slot_));
468 } 486 }
469 487
470 return chromeos_user_map_[username_hash]->GetPrivateSlot(callback); 488 return chromeos_user_map_[username_hash]->GetPrivateSlot(callback);
471 } 489 }
472 490
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 1069
1052 PK11SlotInfo* GetPublicNSSKeySlot() { 1070 PK11SlotInfo* GetPublicNSSKeySlot() {
1053 return g_nss_singleton.Get().GetPublicNSSKeySlot(); 1071 return g_nss_singleton.Get().GetPublicNSSKeySlot();
1054 } 1072 }
1055 1073
1056 PK11SlotInfo* GetPrivateNSSKeySlot() { 1074 PK11SlotInfo* GetPrivateNSSKeySlot() {
1057 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); 1075 return g_nss_singleton.Get().GetPrivateNSSKeySlot();
1058 } 1076 }
1059 1077
1060 } // namespace crypto 1078 } // namespace crypto
OLDNEW
« no previous file with comments | « no previous file | crypto/nss_util_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698