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

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

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: certdb: handle GetCertTrust and IsUntrusted, failed attempt to handle SetCertTrust Created 7 years, 1 month 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 | « net/base/keygen_handler.h ('k') | 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/crypto_module_blocking_password_delegate.h" 8 #include "crypto/crypto_module_blocking_password_delegate.h"
9 #include "crypto/nss_util.h" 9 #include "crypto/nss_util.h"
10 #include "crypto/nss_util_internal.h" 10 #include "crypto/nss_util_internal.h"
11 #include "crypto/scoped_nss_types.h" 11 #include "crypto/scoped_nss_types.h"
12 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h" 12 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h"
13 13
14 // PSM = Mozilla's Personal Security Manager. 14 // PSM = Mozilla's Personal Security Manager.
15 namespace psm = mozilla_security_manager; 15 namespace psm = mozilla_security_manager;
16 16
17 namespace net { 17 namespace net {
18 18
19 std::string KeygenHandler::GenKeyAndSignChallenge() { 19 std::string KeygenHandler::GenKeyAndSignChallenge() {
20 // Ensure NSS is initialized. 20 if (!slot_.get()) {
21 crypto::EnsureNSSInit();
22
23 // TODO(mattm): allow choosing which slot to generate and store the key.
24 crypto::ScopedPK11Slot slot(crypto::GetPrivateNSSKeySlot());
25 if (!slot.get()) {
26 LOG(ERROR) << "Couldn't get private key slot from NSS!"; 21 LOG(ERROR) << "Couldn't get private key slot from NSS!";
27 return std::string(); 22 return std::string();
28 } 23 }
29 24
30 // Authenticate to the token. 25 // Authenticate to the token.
31 if (SECSuccess != PK11_Authenticate(slot.get(), PR_TRUE, 26 if (SECSuccess != PK11_Authenticate(slot_.get(), PR_TRUE,
32 crypto_module_password_delegate_.get())) { 27 crypto_module_password_delegate_.get())) {
33 LOG(ERROR) << "Couldn't authenticate to private key slot!"; 28 LOG(ERROR) << "Couldn't authenticate to private key slot!";
34 return std::string(); 29 return std::string();
35 } 30 }
36 31
37 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_, 32 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_,
38 slot.get(), stores_key_); 33 slot_.get(), stores_key_);
39 } 34 }
40 35
41 void KeygenHandler::set_crypto_module_password_delegate( 36 void KeygenHandler::set_key_slot(
37 crypto::ScopedPK11Slot slot,
42 crypto::CryptoModuleBlockingPasswordDelegate* delegate) { 38 crypto::CryptoModuleBlockingPasswordDelegate* delegate) {
39 slot_ = slot.Pass();
43 crypto_module_password_delegate_.reset(delegate); 40 crypto_module_password_delegate_.reset(delegate);
44 } 41 }
45 42
46 } // namespace net 43 } // namespace net
OLDNEW
« no previous file with comments | « net/base/keygen_handler.h ('k') | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698