From 7eff6aa0d627c2bdbce0493bdb029e477a8caf1e Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Sun, 13 Dec 2015 02:51:44 -0500 Subject: Avoid erroneous "assert(private)" failures. When processing a public key input via "-pubin", "private" was sometimes erroneously set, or else not set and incorrectly asserted. Reviewed-by: Rich salz --- apps/dsa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/dsa.c') diff --git a/apps/dsa.c b/apps/dsa.c index 9dcc75e88a..992d4e4ff9 100644 --- a/apps/dsa.c +++ b/apps/dsa.c @@ -194,7 +194,7 @@ int dsa_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); private = pubin || pubout ? 0 : 1; - if (text) + if (text && !pubin) private = 1; if (!app_passwd(passinarg, passoutarg, &passin, &passout)) { @@ -227,7 +227,7 @@ int dsa_main(int argc, char **argv) goto end; if (text) { - assert(private); + assert(pubin || private); if (!DSA_print(out, dsa, 0)) { perror(outfile); ERR_print_errors(bio_err); @@ -267,6 +267,11 @@ int dsa_main(int argc, char **argv) pk = EVP_PKEY_new(); EVP_PKEY_set1_DSA(pk, dsa); if (outformat == FORMAT_PVK) { + if (pubin) { + BIO_printf(bio_err, "PVK form impossible with public key input\n"); + EVP_PKEY_free(pk); + goto end; + } assert(private); i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); } -- cgit v1.2.3