summaryrefslogtreecommitdiffstats
path: root/apps/dsaparam.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-10-20 11:56:22 +0200
committerPauli <paul.dale@oracle.com>2020-10-22 12:14:32 +1000
commitb78c777ee3038920064f5c2e3eb2a4f66a35119d (patch)
tree9eb5786fb794a2e4be77327a11d89cfe8211bca2 /apps/dsaparam.c
parentf31ac320012c9aa1540034288ea94f6c80924aa3 (diff)
APPS: Implement load_keyparams() to load key parameters
'openssl dsaparam' is affected as an obvious usage example. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13191)
Diffstat (limited to 'apps/dsaparam.c')
-rw-r--r--apps/dsaparam.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index 5fd906a069..7e374eb6ad 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -66,7 +66,7 @@ const OPTIONS dsaparam_options[] = {
int dsaparam_main(int argc, char **argv)
{
ENGINE *e = NULL;
- BIO *in = NULL, *out = NULL;
+ BIO *out = NULL;
EVP_PKEY *params = NULL, *pkey = NULL;
EVP_PKEY_CTX *ctx = NULL;
int numbits = -1, num = 0, genkey = 0;
@@ -140,9 +140,6 @@ int dsaparam_main(int argc, char **argv)
}
private = genkey ? 1 : 0;
- in = bio_open_default(infile, 'r', informat);
- if (in == NULL)
- goto end;
out = bio_open_owner(outfile, outformat, private);
if (out == NULL)
goto end;
@@ -181,10 +178,12 @@ int dsaparam_main(int argc, char **argv)
BIO_printf(bio_err, "Error, DSA key generation failed\n");
goto end;
}
- } else if (informat == FORMAT_ASN1) {
- params = d2i_KeyParams_bio(EVP_PKEY_DSA, NULL, in);
} else {
- params = PEM_read_bio_Parameters(in, NULL);
+ params = load_keyparams(infile, 1, "DSA parameters");
+ if (!EVP_PKEY_is_a(params, "DSA")) {
+ EVP_PKEY_free(params);
+ params = NULL;
+ }
}
if (params == NULL) {
BIO_printf(bio_err, "Error, unable to load DSA parameters\n");
@@ -276,7 +275,6 @@ int dsaparam_main(int argc, char **argv)
end:
if (ret != 0)
ERR_print_errors(bio_err);
- BIO_free(in);
BIO_free_all(out);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey);