diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 21:02:15 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 21:02:15 +0000 |
commit | cca8f4ae3d30e5fac962ee26538a6b2a06a2698c (patch) | |
tree | 0fe277334c557d81b50bf1008ddf12bbb1432465 /net | |
parent | bb64b5128f1641cba1e802ae7d0768be955ffdc5 (diff) | |
download | chromium_src-cca8f4ae3d30e5fac962ee26538a6b2a06a2698c.zip chromium_src-cca8f4ae3d30e5fac962ee26538a6b2a06a2698c.tar.gz chromium_src-cca8f4ae3d30e5fac962ee26538a6b2a06a2698c.tar.bz2 |
We should delete the underlying persistent public key only
when we cannot sign the challenge. This matches what Mozilla
does.
Fix nits.
R=snej
BUG=148
TEST=No compilation errors.
Review URL: http://codereview.chromium.org/1535016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/keygen_handler_nss.cc | 8 | ||||
-rw-r--r-- | net/base/keygen_handler_unittest.cc | 8 | ||||
-rw-r--r-- | net/base/keygen_handler_win.cc | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/net/base/keygen_handler_nss.cc b/net/base/keygen_handler_nss.cc index 9819289..6b79e14 100644 --- a/net/base/keygen_handler_nss.cc +++ b/net/base/keygen_handler_nss.cc @@ -229,14 +229,14 @@ std::string KeygenHandler::GenKeyAndSignChallenge() { } if (publicKey) { - PK11_DestroyTokenObject(publicKey->pkcs11Slot, publicKey->pkcs11ID); + if (!isSuccess || !stores_key_) { + PK11_DestroyTokenObject(publicKey->pkcs11Slot, publicKey->pkcs11ID); + } + SECKEY_DestroyPublicKey(publicKey); } if (spkInfo) { SECKEY_DestroySubjectPublicKeyInfo(spkInfo); } - if (publicKey) { - SECKEY_DestroyPublicKey(publicKey); - } if (arena) { PORT_FreeArena(arena, PR_TRUE); } diff --git a/net/base/keygen_handler_unittest.cc b/net/base/keygen_handler_unittest.cc index d73d8e1..508508f 100644 --- a/net/base/keygen_handler_unittest.cc +++ b/net/base/keygen_handler_unittest.cc @@ -73,11 +73,11 @@ TEST(KeygenHandlerTest, Cache) { std::string key1("abcd"); cache->Insert(key1, location1); - // The cache should have stored location1 at key1 + // The cache should have stored location1 at key1. EXPECT_TRUE(cache->Find(key1, &location2)); // The cache should have retrieved it into location2, and their equality - // should be reflexive + // should be reflexive. EXPECT_TRUE(location1.Equals(location2)); EXPECT_TRUE(location2.Equals(location1)); @@ -85,11 +85,11 @@ TEST(KeygenHandlerTest, Cache) { KeygenHandler::KeyLocation location3 = ValidKeyLocation(); EXPECT_FALSE(location1.Equals(location2)); - // The cache should miss for an unregistered key + // The cache should miss for an unregistered key. std::string key2("def"); EXPECT_FALSE(cache->Find(key2, &location2)); - // A cache miss should leave the original location unmolested + // A cache miss should leave the original location unmolested. EXPECT_TRUE(location2.Equals(location3)); } diff --git a/net/base/keygen_handler_win.cc b/net/base/keygen_handler_win.cc index 7a664b9..d6e5402 100644 --- a/net/base/keygen_handler_win.cc +++ b/net/base/keygen_handler_win.cc @@ -85,7 +85,7 @@ bool EncodeChallenge(const std::string& challenge, std::vector<BYTE>* output) { CERT_NAME_VALUE challenge_nv; challenge_nv.dwValueType = CERT_RDN_IA5_STRING; challenge_nv.Value.pbData = const_cast<BYTE*>( - reinterpret_cast<const BYTE*>(challenge.c_str())); + reinterpret_cast<const BYTE*>(challenge.data())); challenge_nv.Value.cbData = challenge.size(); return EncodeAndAppendType(X509_ANY_STRING, &challenge_nv, output); |