summaryrefslogtreecommitdiffstats
path: root/net/base/keygen_handler_nss.cc
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 18:49:47 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 18:49:47 +0000
commit9aed77b6dace047bff676a7cdcfef345a858d1a7 (patch)
treefddd5e0fac4ee39b6c79af56871f022472f276d9 /net/base/keygen_handler_nss.cc
parent2779491e15b4a157b6351e20bb0f2dd26f6d84de (diff)
downloadchromium_src-9aed77b6dace047bff676a7cdcfef345a858d1a7.zip
chromium_src-9aed77b6dace047bff676a7cdcfef345a858d1a7.tar.gz
chromium_src-9aed77b6dace047bff676a7cdcfef345a858d1a7.tar.bz2
Adds support for the <keygen> element to Windows, matching
support present on Linux and Mac OS X. Contributed by Ryan Sleevi <ryan.sleevi@gmail.com>. Original review URL: http://codereview.chromium.org/843005 R=wtc BUG=148 TEST=KeygenHandler.SmokeTest Review URL: http://codereview.chromium.org/1591006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/keygen_handler_nss.cc')
-rw-r--r--net/base/keygen_handler_nss.cc29
1 files changed, 23 insertions, 6 deletions
diff --git a/net/base/keygen_handler_nss.cc b/net/base/keygen_handler_nss.cc
index d8d9acb..9819289 100644
--- a/net/base/keygen_handler_nss.cc
+++ b/net/base/keygen_handler_nss.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -51,6 +51,21 @@ DERTemplate CERTPublicKeyAndChallengeTemplate[] = {
{ 0, }
};
+void StoreKeyLocationInCache(const SECItem& public_key_info,
+ PK11SlotInfo *slot) {
+ KeygenHandler::Cache* cache = KeygenHandler::Cache::GetInstance();
+ KeygenHandler::KeyLocation key_location;
+ const char* slot_name = PK11_GetSlotName(slot);
+ key_location.slot_name.assign(slot_name);
+ cache->Insert(std::string(reinterpret_cast<char*>(public_key_info.data),
+ public_key_info.len), key_location);
+}
+
+bool KeygenHandler::KeyLocation::Equals(
+ const net::KeygenHandler::KeyLocation& location) const {
+ return slot_name == location.slot_name;
+}
+
// This function is largely copied from the Firefox's
// <keygen> implementation in security/manager/ssl/src/nsKeygenHandler.cpp
// FIXME(gauravsh): Do we need a copy of the Mozilla license here?
@@ -194,21 +209,23 @@ std::string KeygenHandler::GenKeyAndSignChallenge() {
goto failure;
}
+ StoreKeyLocationInCache(spkiItem, slot);
+
failure:
if (!isSuccess) {
LOG(ERROR) << "SSL Keygen failed!";
} else {
- LOG(INFO) << "SSl Keygen succeeded!";
+ LOG(INFO) << "SSL Keygen succeeded!";
}
// Do cleanups
if (privateKey) {
- if (!isSuccess || !stores_key_) {
- PK11_DestroyTokenObject(privateKey->pkcs11Slot,privateKey->pkcs11ID);
- SECKEY_DestroyPrivateKey(privateKey);
- }
// On successful keygen we need to keep the private key, of course,
// or we won't be able to use the client certificate.
+ if (!isSuccess || !stores_key_) {
+ PK11_DestroyTokenObject(privateKey->pkcs11Slot, privateKey->pkcs11ID);
+ }
+ SECKEY_DestroyPrivateKey(privateKey);
}
if (publicKey) {