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

Side by Side Diff: net/base/keygen_handler_nss.cc

Issue 384413004: Remove default key slot from KeygenHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments: adding ifdefs. Created 6 years, 5 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 | net/base/keygen_handler_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/base/keygen_handler.h" 5 #include "net/base/keygen_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "crypto/nss_crypto_module_delegate.h" 8 #include "crypto/nss_crypto_module_delegate.h"
9 #include "crypto/nss_util.h" 9 #include "crypto/nss_util.h"
10 #include "crypto/nss_util_internal.h"
11 #include "crypto/scoped_nss_types.h" 10 #include "crypto/scoped_nss_types.h"
12 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h" 11 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h"
13 12
14 // PSM = Mozilla's Personal Security Manager. 13 // PSM = Mozilla's Personal Security Manager.
15 namespace psm = mozilla_security_manager; 14 namespace psm = mozilla_security_manager;
16 15
17 namespace net { 16 namespace net {
18 17
19 std::string KeygenHandler::GenKeyAndSignChallenge() { 18 std::string KeygenHandler::GenKeyAndSignChallenge() {
20 // Ensure NSS is initialized.
21 crypto::EnsureNSSInit(); 19 crypto::EnsureNSSInit();
22 20
23 crypto::ScopedPK11Slot slot; 21 crypto::ScopedPK11Slot slot;
24 if (crypto_module_delegate_) 22 if (crypto_module_delegate_) {
25 slot = crypto_module_delegate_->RequestSlot().Pass(); 23 slot = crypto_module_delegate_->RequestSlot().Pass();
26 else 24 } else {
27 slot.reset(crypto::GetPersistentNSSKeySlot()); 25 LOG(ERROR) << "Could not get an NSS key slot.";
28 if (!slot.get()) {
29 LOG(ERROR) << "Couldn't get private key slot from NSS!";
30 return std::string(); 26 return std::string();
31 } 27 }
32 28
33 // Authenticate to the token. 29 // Authenticate to the token.
34 if (SECSuccess != 30 if (SECSuccess != PK11_Authenticate(slot.get(),
35 PK11_Authenticate( 31 PR_TRUE,
36 slot.get(), 32 crypto_module_delegate_->wincx())) {
37 PR_TRUE, 33 LOG(ERROR) << "Could not authenticate to the key slot.";
38 crypto_module_delegate_ ? crypto_module_delegate_->wincx() : NULL)) {
39 LOG(ERROR) << "Couldn't authenticate to private key slot!";
40 return std::string(); 34 return std::string();
41 } 35 }
42 36
43 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_, 37 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_,
44 slot.get(), stores_key_); 38 slot.get(), stores_key_);
45 } 39 }
46 40
47 void KeygenHandler::set_crypto_module_delegate( 41 void KeygenHandler::set_crypto_module_delegate(
48 scoped_ptr<crypto::NSSCryptoModuleDelegate> delegate) { 42 scoped_ptr<crypto::NSSCryptoModuleDelegate> delegate) {
49 crypto_module_delegate_ = delegate.Pass(); 43 crypto_module_delegate_ = delegate.Pass();
50 } 44 }
51 45
52 } // namespace net 46 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698