improve key import

- support importing encrypted and unencrypted PKCS#8 DER
   formatted keys
This commit is contained in:
Christian Hohnstaedt 2010-05-01 10:28:55 +02:00
parent 28c63fbaa4
commit 2b91c11d5a
2 changed files with 17 additions and 1 deletions

View File

@ -1,4 +1,5 @@
* support loading DER formatted PKCS#8 keys
* ease commandline use
* add DH param generation menu entry
* improve token handling and PIN changing dialogs

View File

@ -278,6 +278,21 @@ void pki_evp::fload(const QString fname)
rewind(fp);
pkey = d2i_PrivateKey_fp(fp, NULL);
}
if (!pkey) {
ign_openssl_error();
rewind(fp);
pkey = d2i_PKCS8PrivateKey_fp(fp, NULL, cb, &p);
}
if (!pkey) {
PKCS8_PRIV_KEY_INFO *p8inf;
ign_openssl_error();
rewind(fp);
p8inf = d2i_PKCS8_PRIV_KEY_INFO_fp(fp, NULL);
if (p8inf) {
pkey = EVP_PKCS82PKEY(p8inf);
PKCS8_PRIV_KEY_INFO_free(p8inf);
}
}
if (!pkey) {
ign_openssl_error();
rewind(fp);
@ -292,7 +307,7 @@ void pki_evp::fload(const QString fname)
if (ign_openssl_error()) {
if (pkey)
EVP_PKEY_free(pkey);
throw errorEx(tr("Unable to load the private key in file %1. Tried PEM and DER private and public key types.").arg(fname));
throw errorEx(tr("Unable to load the private key in file %1. Tried PEM and DER private, public and PKCS#8 key types.").arg(fname));
}
if (pkey){
if (pkey->type == EVP_PKEY_EC)