Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/crypto/pk11_blocking_password_delegate.h" | |
| 8 #include "base/crypto/scoped_nss_types.h" | |
| 9 #include "base/logging.h" | |
| 10 #include "base/nss_util.h" | |
| 11 #include "base/nss_util_internal.h" | |
| 7 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h" | 12 #include "net/third_party/mozilla_security_manager/nsKeygenHandler.h" |
| 8 | 13 |
| 9 // PSM = Mozilla's Personal Security Manager. | 14 // PSM = Mozilla's Personal Security Manager. |
| 10 namespace psm = mozilla_security_manager; | 15 namespace psm = mozilla_security_manager; |
| 11 | 16 |
| 12 namespace net { | 17 namespace net { |
| 13 | 18 |
| 14 std::string KeygenHandler::GenKeyAndSignChallenge() { | 19 std::string KeygenHandler::GenKeyAndSignChallenge() { |
| 20 // Ensure NSS is initialized. | |
| 21 base::EnsureNSSInit(); | |
| 22 | |
| 23 // TODO(mattm): allow choosing which slot to store the generated key? | |
|
wtc
2010/12/15 20:54:36
Nit: store the generated key => generate and store
mattm
2011/01/12 01:22:07
Done.
| |
| 24 base::ScopedPK11Slot slot(base::GetDefaultNSSKeySlot()); | |
| 25 if (!slot.get()) { | |
| 26 LOG(ERROR) << "Couldn't get Internal key slot!"; | |
|
wtc
2010/12/15 20:54:36
Nit: lowercase "internal".
mattm
2011/01/12 01:22:07
Done.
| |
| 27 return std::string(); | |
| 28 } | |
| 29 | |
| 30 // Authenticate to the token. | |
| 31 if (SECSuccess != PK11_Authenticate(slot.get(), PR_TRUE, | |
| 32 pk11_password_delegate_.get())) { | |
| 33 LOG(ERROR) << "Couldn't authenticate to PK11 token!"; | |
|
wtc
2010/12/15 20:54:36
Nit: this probably should also say "internal key s
mattm
2011/01/12 01:22:07
Done.
| |
| 34 return std::string(); | |
| 35 } | |
| 36 | |
| 15 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_, | 37 return psm::GenKeyAndSignChallenge(key_size_in_bits_, challenge_, url_, |
| 16 stores_key_); | 38 slot.get(), stores_key_); |
| 39 } | |
| 40 | |
| 41 void KeygenHandler::set_pk11_password_delegate( | |
| 42 base::PK11BlockingPasswordDelegate* delegate) { | |
| 43 pk11_password_delegate_.reset(delegate); | |
| 17 } | 44 } |
| 18 | 45 |
| 19 } // namespace net | 46 } // namespace net |
| OLD | NEW |