OLD | NEW |
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 <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "crypto/nss_crypto_module_delegate.h" | 10 #include "crypto/nss_crypto_module_delegate.h" |
9 #include "crypto/nss_util.h" | 11 #include "crypto/nss_util.h" |
10 #include "crypto/scoped_nss_types.h" | 12 #include "crypto/scoped_nss_types.h" |
11 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h" | 13 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h" |
12 | 14 |
13 // PSM = Mozilla's Personal Security Manager. | 15 // PSM = Mozilla's Personal Security Manager. |
14 namespace psm = mozilla_security_manager; | 16 namespace psm = mozilla_security_manager; |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 | 19 |
18 std::string KeygenHandler::GenKeyAndSignChallenge() { | 20 std::string KeygenHandler::GenKeyAndSignChallenge() { |
19 crypto::EnsureNSSInit(); | 21 crypto::EnsureNSSInit(); |
20 | 22 |
21 crypto::ScopedPK11Slot slot; | 23 crypto::ScopedPK11Slot slot; |
22 if (crypto_module_delegate_) { | 24 if (crypto_module_delegate_) { |
23 slot = crypto_module_delegate_->RequestSlot().Pass(); | 25 slot = crypto_module_delegate_->RequestSlot(); |
24 } else { | 26 } else { |
25 LOG(ERROR) << "Could not get an NSS key slot."; | 27 LOG(ERROR) << "Could not get an NSS key slot."; |
26 return std::string(); | 28 return std::string(); |
27 } | 29 } |
28 | 30 |
29 // Authenticate to the token. | 31 // Authenticate to the token. |
30 if (SECSuccess != PK11_Authenticate(slot.get(), | 32 if (SECSuccess != PK11_Authenticate(slot.get(), |
31 PR_TRUE, | 33 PR_TRUE, |
32 crypto_module_delegate_->wincx())) { | 34 crypto_module_delegate_->wincx())) { |
33 LOG(ERROR) << "Could not authenticate to the key slot."; | 35 LOG(ERROR) << "Could not authenticate to the key slot."; |
34 return std::string(); | 36 return std::string(); |
35 } | 37 } |
36 | 38 |
37 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_, | 39 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_, |
38 slot.get(), stores_key_); | 40 slot.get(), stores_key_); |
39 } | 41 } |
40 | 42 |
41 void KeygenHandler::set_crypto_module_delegate( | 43 void KeygenHandler::set_crypto_module_delegate( |
42 scoped_ptr<crypto::NSSCryptoModuleDelegate> delegate) { | 44 scoped_ptr<crypto::NSSCryptoModuleDelegate> delegate) { |
43 crypto_module_delegate_ = delegate.Pass(); | 45 crypto_module_delegate_ = std::move(delegate); |
44 } | 46 } |
45 | 47 |
46 } // namespace net | 48 } // namespace net |
OLD | NEW |