diff --git a/lib/db_x509.cpp b/lib/db_x509.cpp index 7c71768c..193788b4 100644 --- a/lib/db_x509.cpp +++ b/lib/db_x509.cpp @@ -662,7 +662,8 @@ void db_x509::writePKCS12(pki_x509 *cert, XFile &file, bool chain) const cert = signer; signer = signer->getSigner(); } - p12->writePKCS12(file); + encAlgo encAlgo((QString) Settings["pkcs12_enc_algo"]); + p12->writePKCS12(file, encAlgo); } catch (errorEx &err) { XCA_ERROR(err); diff --git a/lib/pki_pkcs12.cpp b/lib/pki_pkcs12.cpp index 04ba7ecb..2b714e0f 100644 --- a/lib/pki_pkcs12.cpp +++ b/lib/pki_pkcs12.cpp @@ -118,7 +118,7 @@ pki_pkcs12::pki_pkcs12(const QString &fname) pki_openssl_error(); } -void pki_pkcs12::writePKCS12(XFile &file) const +void pki_pkcs12::writePKCS12(XFile &file, encAlgo &encAlgo) const { Passwd pass; PKCS12 *pkcs12; @@ -137,9 +137,10 @@ void pki_pkcs12::writePKCS12(XFile &file) const if (x && x != cert) sk_X509_push(certstack, x->getCert()); } + int encAlgoNid = encAlgo.getEncAlgoNid(); pkcs12 = PKCS12_create(pass.data(), getIntName().toUtf8().data(), key->decryptKey(), cert->getCert(), certstack, - NID_pbe_WithSHA1And3_Key_TripleDES_CBC, NID_pbe_WithSHA1And3_Key_TripleDES_CBC, + encAlgoNid, encAlgoNid, 0, 0, 0); BioByteArray b; i2d_PKCS12_bio(b, pkcs12); diff --git a/lib/pki_pkcs12.h b/lib/pki_pkcs12.h index 64605d54..ad3b848d 100644 --- a/lib/pki_pkcs12.h +++ b/lib/pki_pkcs12.h @@ -57,6 +57,6 @@ class pki_pkcs12: public pki_multi { return cert; } - void writePKCS12(XFile &file) const; + void writePKCS12(XFile &file, encAlgo &encAlgo) const; }; #endif diff --git a/lib/settings.cpp b/lib/settings.cpp index 5c455d20..a543e6f6 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -3,6 +3,7 @@ #include "sql.h" #include "pki_key.h" #include "digest.h" +#include "pki_pkcs12.h" #include "pki_export.h" #include @@ -34,6 +35,7 @@ settings::settings() defaul["string_opt"] = "MASK:0x2002"; defaul["workingdir"] = ""; defaul["default_hash"] = digest::getDefault().name(); + defaul["pkcs12_enc_algo"] = encAlgo::getDefault().name(); defaul["ical_expiry"] = "1W"; defaul["cert_expiry"] = "80%"; defaul["serial_len"] = "64"; @@ -59,6 +61,8 @@ void settings::setAction(const QString &key, const QString &value) ASN1_STRING_set_default_mask_asc((char*)CCHAR(value)); else if (key == "default_hash") digest::setDefault(value); + else if (key == "pkcs12_enc_algo") + encAlgo::setDefault(value); else if (key == "defaultkey") keyjob::defaultjob = keyjob(value); else if (key == "optionflags") { diff --git a/ui/Options.ui b/ui/Options.ui index 71044b73..abd0fa70 100644 --- a/ui/Options.ui +++ b/ui/Options.ui @@ -56,6 +56,20 @@ + + + + + + PKCS12 encryption algorithm + + + + + + + + @@ -423,15 +437,20 @@ Especially EC and DSA are only defined with SHA1 in the PKCS#11 specification. + + focusCombo + QComboBox +
widgets/FocusCombo.h
+
hashBox QComboBox
widgets/hashBox.h
- focusCombo + pkcs12EncBox QComboBox -
widgets/FocusCombo.h
+
widgets/pkcs12EncBox.h
diff --git a/widgets/Options.cpp b/widgets/Options.cpp index 2fdbe7fd..c0173779 100644 --- a/widgets/Options.cpp +++ b/widgets/Options.cpp @@ -147,6 +147,7 @@ int Options::exec() Settings["disable_netscape"] = disableNetscape->checkState(); Settings["default_hash"] = hashAlgo->current().name(); + Settings["pkcs12_enc_algo"] = pkcs12EncAlgo->current().name(); Settings["mandatory_dn"] = getDnString(extDNlist); Settings["explicit_dn"] = getDnString(expDNlist); Settings["string_opt"] = string_opts[mbstring->currentIndex()];