goto end;
}
} else {
- params = load_keyparams(infile, 1, "DSA parameters");
- if (!EVP_PKEY_is_a(params, "DSA")) {
- EVP_PKEY_free(params);
- params = NULL;
- }
+ params = load_keyparams(infile, 1, "DSA", "DSA parameters");
}
if (params == NULL) {
- BIO_printf(bio_err, "Error, unable to load DSA parameters\n");
+ /* Error message should already have been displayed */
goto end;
}
const char *pass, ENGINE *e, const char *desc);
EVP_PKEY *load_pubkey(const char *uri, int format, int maybe_stdin,
const char *pass, ENGINE *e, const char *desc);
-EVP_PKEY *load_keyparams(const char *uri, int maybe_stdin, const char *desc);
+EVP_PKEY *load_keyparams(const char *uri, int maybe_stdin, const char *keytype,
+ const char *desc);
int load_certs(const char *uri, STACK_OF(X509) **certs,
const char *pass, const char *desc);
int load_crls(const char *uri, STACK_OF(X509_CRL) **crls,
return pkey;
}
-EVP_PKEY *load_keyparams(const char *uri, int maybe_stdin, const char *desc)
+EVP_PKEY *load_keyparams(const char *uri, int maybe_stdin, const char *keytype,
+ const char *desc)
{
EVP_PKEY *params = NULL;
(void)load_key_certs_crls(uri, maybe_stdin, NULL, desc,
NULL, NULL, ¶ms, NULL, NULL, NULL, NULL);
- if (params == NULL) {
- BIO_printf(bio_err, "Unable to load %s\n", desc);
+ if (params != NULL && keytype != NULL && !EVP_PKEY_is_a(params, keytype)) {
+ BIO_printf(bio_err,
+ "Unable to load %s from %s (unexpected parameters type)\n",
+ desc, uri);
ERR_print_errors(bio_err);
+ EVP_PKEY_free(params);
+ params = NULL;
}
return params;
}
int ncrls = 0;
const char *failed =
ppkey != NULL ? "key" : ppubkey != NULL ? "public key" :
- pcert != NULL ? "cert" : pcrl != NULL ? "CRL" :
- pcerts != NULL ? "certs" : pcrls != NULL ? "CRLs" : NULL;
+ pparams != NULL ? "params" : pcert != NULL ? "cert" :
+ pcrl != NULL ? "CRL" : pcerts != NULL ? "certs" :
+ pcrls != NULL ? "CRLs" : NULL;
/* TODO make use of the engine reference 'eng' when loading pkeys */
if (ppkey != NULL)