Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: net/third_party/mozilla_security_manager/nsPKCS12Blob.cpp

Issue 5686002: NSS: PKCS 11 password prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing review comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/third_party/mozilla_security_manager/nsPKCS12Blob.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* ***** BEGIN LICENSE BLOCK ***** 1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 * 3 *
4 * The contents of this file are subject to the Mozilla Public License Version 4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with 5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at 6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/ 7 * http://www.mozilla.org/MPL/
8 * 8 *
9 * Software distributed under the License is distributed on an "AS IS" basis, 9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 static base::LazyInstance<PKCS12InitSingleton> g_pkcs12_init_singleton( 255 static base::LazyInstance<PKCS12InitSingleton> g_pkcs12_init_singleton(
256 base::LINKER_INITIALIZED); 256 base::LINKER_INITIALIZED);
257 257
258 } // namespace 258 } // namespace
259 259
260 void EnsurePKCS12Init() { 260 void EnsurePKCS12Init() {
261 g_pkcs12_init_singleton.Get(); 261 g_pkcs12_init_singleton.Get();
262 } 262 }
263 263
264 // Based on nsPKCS12Blob::ImportFromFile. 264 // Based on nsPKCS12Blob::ImportFromFile.
265 int nsPKCS12Blob_Import(const char* pkcs12_data, 265 int nsPKCS12Blob_Import(PK11SlotInfo* slot,
266 const char* pkcs12_data,
266 size_t pkcs12_len, 267 size_t pkcs12_len,
267 const string16& password) { 268 const string16& password) {
268 base::ScopedPK11Slot slot(base::GetDefaultNSSKeySlot());
269 if (!slot.get()) {
270 LOG(ERROR) << "Couldn't get Internal key slot!";
271 return net::ERR_PKCS12_IMPORT_FAILED;
272 }
273 269
274 int rv = nsPKCS12Blob_ImportHelper(pkcs12_data, pkcs12_len, password, false, 270 int rv = nsPKCS12Blob_ImportHelper(pkcs12_data, pkcs12_len, password, false,
275 slot.get()); 271 slot);
276 272
277 // When the user entered a zero length password: 273 // When the user entered a zero length password:
278 // An empty password should be represented as an empty 274 // An empty password should be represented as an empty
279 // string (a SECItem that contains a single terminating 275 // string (a SECItem that contains a single terminating
280 // NULL UTF16 character), but some applications use a 276 // NULL UTF16 character), but some applications use a
281 // zero length SECItem. 277 // zero length SECItem.
282 // We try both variations, zero length item and empty string, 278 // We try both variations, zero length item and empty string,
283 // without giving a user prompt when trying the different empty password fla vors. 279 // without giving a user prompt when trying the different empty password fla vors.
284 if (rv == net::ERR_PKCS12_IMPORT_BAD_PASSWORD && password.size() == 0) { 280 if (rv == net::ERR_PKCS12_IMPORT_BAD_PASSWORD && password.size() == 0) {
285 rv = nsPKCS12Blob_ImportHelper(pkcs12_data, pkcs12_len, password, true, 281 rv = nsPKCS12Blob_ImportHelper(pkcs12_data, pkcs12_len, password, true,
286 slot.get()); 282 slot);
287 } 283 }
288 return rv; 284 return rv;
289 } 285 }
290 286
291 // Based on nsPKCS12Blob::ExportToFile 287 // Based on nsPKCS12Blob::ExportToFile
292 // 288 //
293 // Having already loaded the certs, form them into a blob (loading the keys 289 // Having already loaded the certs, form them into a blob (loading the keys
294 // also), encode the blob, and stuff it into the file. 290 // also), encode the blob, and stuff it into the file.
295 // 291 //
296 // TODO: handle slots correctly 292 // TODO: handle slots correctly
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 finish: 387 finish:
392 if (srv) 388 if (srv)
393 LOG(ERROR) << "PKCS#12 export failed with error " << PORT_GetError(); 389 LOG(ERROR) << "PKCS#12 export failed with error " << PORT_GetError();
394 if (ecx) 390 if (ecx)
395 SEC_PKCS12DestroyExportContext(ecx); 391 SEC_PKCS12DestroyExportContext(ecx);
396 SECITEM_ZfreeItem(&unicodePw, PR_FALSE); 392 SECITEM_ZfreeItem(&unicodePw, PR_FALSE);
397 return return_count; 393 return return_count;
398 } 394 }
399 395
400 } // namespace mozilla_security_manager 396 } // namespace mozilla_security_manager
OLDNEW
« no previous file with comments | « net/third_party/mozilla_security_manager/nsPKCS12Blob.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698