| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 * ***** END LICENSE BLOCK ***** */ | 36 * ***** END LICENSE BLOCK ***** */ |
| 37 | 37 |
| 38 #include "net/third_party/mozilla_security_manager/nsPKCS12Blob.h" | 38 #include "net/third_party/mozilla_security_manager/nsPKCS12Blob.h" |
| 39 | 39 |
| 40 #include <pk11pub.h> | 40 #include <pk11pub.h> |
| 41 #include <pkcs12.h> | 41 #include <pkcs12.h> |
| 42 #include <p12plcy.h> | 42 #include <p12plcy.h> |
| 43 #include <secerr.h> | 43 #include <secerr.h> |
| 44 | 44 |
| 45 #include "base/crypto/scoped_nss_types.h" | 45 #include "base/crypto/scoped_nss_types.h" |
| 46 #include "base/lazy_instance.h" |
| 46 #include "base/logging.h" | 47 #include "base/logging.h" |
| 47 #include "base/nss_util_internal.h" | 48 #include "base/nss_util_internal.h" |
| 48 #include "base/singleton.h" | |
| 49 #include "base/string_util.h" | 49 #include "base/string_util.h" |
| 50 #include "net/base/net_errors.h" | 50 #include "net/base/net_errors.h" |
| 51 #include "net/base/x509_certificate.h" | 51 #include "net/base/x509_certificate.h" |
| 52 | 52 |
| 53 namespace mozilla_security_manager { | 53 namespace mozilla_security_manager { |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 // unicodeToItem | 57 // unicodeToItem |
| 58 // | 58 // |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 SEC_PKCS12EnableCipher(PKCS12_DES_EDE3_168, 1); | 245 SEC_PKCS12EnableCipher(PKCS12_DES_EDE3_168, 1); |
| 246 SEC_PKCS12SetPreferredCipher(PKCS12_DES_EDE3_168, 1); | 246 SEC_PKCS12SetPreferredCipher(PKCS12_DES_EDE3_168, 1); |
| 247 | 247 |
| 248 // Set no-op ascii-ucs2 conversion function to work around weird NSS | 248 // Set no-op ascii-ucs2 conversion function to work around weird NSS |
| 249 // interface. Thankfully, PKCS12 appears to be the only thing in NSS that | 249 // interface. Thankfully, PKCS12 appears to be the only thing in NSS that |
| 250 // uses PORT_UCS2_ASCIIConversion, so this doesn't break anything else. | 250 // uses PORT_UCS2_ASCIIConversion, so this doesn't break anything else. |
| 251 PORT_SetUCS2_ASCIIConversionFunction(pip_ucs2_ascii_conversion_fn); | 251 PORT_SetUCS2_ASCIIConversionFunction(pip_ucs2_ascii_conversion_fn); |
| 252 } | 252 } |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 static base::LazyInstance<PKCS12InitSingleton> g_pkcs12_init_singleton( |
| 256 base::LINKER_INITIALIZED); |
| 257 |
| 255 } // namespace | 258 } // namespace |
| 256 | 259 |
| 257 void EnsurePKCS12Init() { | 260 void EnsurePKCS12Init() { |
| 258 Singleton<PKCS12InitSingleton>::get(); | 261 g_pkcs12_init_singleton.Get(); |
| 259 } | 262 } |
| 260 | 263 |
| 261 // Based on nsPKCS12Blob::ImportFromFile. | 264 // Based on nsPKCS12Blob::ImportFromFile. |
| 262 int nsPKCS12Blob_Import(const char* pkcs12_data, | 265 int nsPKCS12Blob_Import(const char* pkcs12_data, |
| 263 size_t pkcs12_len, | 266 size_t pkcs12_len, |
| 264 const string16& password) { | 267 const string16& password) { |
| 265 base::ScopedPK11Slot slot(base::GetDefaultNSSKeySlot()); | 268 base::ScopedPK11Slot slot(base::GetDefaultNSSKeySlot()); |
| 266 if (!slot.get()) { | 269 if (!slot.get()) { |
| 267 LOG(ERROR) << "Couldn't get Internal key slot!"; | 270 LOG(ERROR) << "Couldn't get Internal key slot!"; |
| 268 return net::ERR_PKCS12_IMPORT_FAILED; | 271 return net::ERR_PKCS12_IMPORT_FAILED; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 finish: | 391 finish: |
| 389 if (srv) | 392 if (srv) |
| 390 LOG(ERROR) << "PKCS#12 export failed with error " << PORT_GetError(); | 393 LOG(ERROR) << "PKCS#12 export failed with error " << PORT_GetError(); |
| 391 if (ecx) | 394 if (ecx) |
| 392 SEC_PKCS12DestroyExportContext(ecx); | 395 SEC_PKCS12DestroyExportContext(ecx); |
| 393 SECITEM_ZfreeItem(&unicodePw, PR_FALSE); | 396 SECITEM_ZfreeItem(&unicodePw, PR_FALSE); |
| 394 return return_count; | 397 return return_count; |
| 395 } | 398 } |
| 396 | 399 |
| 397 } // namespace mozilla_security_manager | 400 } // namespace mozilla_security_manager |
| OLD | NEW |