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 <pk11pub.h> | 7 #include <pk11pub.h> |
8 #include <secmod.h> | 8 #include <secmod.h> |
9 #include <ssl.h> | 9 #include <ssl.h> |
10 #include <secder.h> // DER_Encode() | 10 #include <secder.h> // DER_Encode() |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 if (privateKey) { | 222 if (privateKey) { |
223 // On successful keygen we need to keep the private key, of course, | 223 // On successful keygen we need to keep the private key, of course, |
224 // or we won't be able to use the client certificate. | 224 // or we won't be able to use the client certificate. |
225 if (!isSuccess || !stores_key_) { | 225 if (!isSuccess || !stores_key_) { |
226 PK11_DestroyTokenObject(privateKey->pkcs11Slot, privateKey->pkcs11ID); | 226 PK11_DestroyTokenObject(privateKey->pkcs11Slot, privateKey->pkcs11ID); |
227 } | 227 } |
228 SECKEY_DestroyPrivateKey(privateKey); | 228 SECKEY_DestroyPrivateKey(privateKey); |
229 } | 229 } |
230 | 230 |
231 if (publicKey) { | 231 if (publicKey) { |
232 PK11_DestroyTokenObject(publicKey->pkcs11Slot, publicKey->pkcs11ID); | 232 if (!isSuccess || !stores_key_) { |
| 233 PK11_DestroyTokenObject(publicKey->pkcs11Slot, publicKey->pkcs11ID); |
| 234 } |
| 235 SECKEY_DestroyPublicKey(publicKey); |
233 } | 236 } |
234 if (spkInfo) { | 237 if (spkInfo) { |
235 SECKEY_DestroySubjectPublicKeyInfo(spkInfo); | 238 SECKEY_DestroySubjectPublicKeyInfo(spkInfo); |
236 } | 239 } |
237 if (publicKey) { | |
238 SECKEY_DestroyPublicKey(publicKey); | |
239 } | |
240 if (arena) { | 240 if (arena) { |
241 PORT_FreeArena(arena, PR_TRUE); | 241 PORT_FreeArena(arena, PR_TRUE); |
242 } | 242 } |
243 if (slot != NULL) { | 243 if (slot != NULL) { |
244 PK11_FreeSlot(slot); | 244 PK11_FreeSlot(slot); |
245 } | 245 } |
246 if (pkac.challenge.data) { | 246 if (pkac.challenge.data) { |
247 free(pkac.challenge.data); | 247 free(pkac.challenge.data); |
248 } | 248 } |
249 | 249 |
250 return (isSuccess ? result_blob : std::string()); | 250 return (isSuccess ? result_blob : std::string()); |
251 } | 251 } |
252 | 252 |
253 } // namespace net | 253 } // namespace net |
OLD | NEW |