aboutsummaryrefslogtreecommitdiff
path: root/apps/dsa.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2020-03-02 14:30:26 +1000
committerPauli <paul.dale@oracle.com>2020-04-19 10:36:35 +1000
commitb940349de1184d050bed069622e2f929533efa45 (patch)
tree723a18b92e16221932959c38cc260725aa0bd2f8 /apps/dsa.c
parente0331eb8b818ed0daac45e0786571958f744d398 (diff)
downloadopenssl-b940349de1184d050bed069622e2f929533efa45.zip
openssl-b940349de1184d050bed069622e2f929533efa45.tar.gz
openssl-b940349de1184d050bed069622e2f929533efa45.tar.bz2
dsa: update command line app to use EVP calls
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11225)
Diffstat (limited to 'apps/dsa.c')
-rw-r--r--apps/dsa.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/apps/dsa.c b/apps/dsa.c
index 200e959..f4677dd 100644
--- a/apps/dsa.c
+++ b/apps/dsa.c
@@ -7,9 +7,6 @@
* https://www.openssl.org/source/license.html
*/
-/* We need to use the deprecated DSA_print */
-#define OPENSSL_SUPPRESS_DEPRECATED
-
#include <openssl/opensslconf.h>
#include <stdio.h>
@@ -73,6 +70,7 @@ int dsa_main(int argc, char **argv)
BIO *out = NULL;
DSA *dsa = NULL;
ENGINE *e = NULL;
+ EVP_PKEY *pkey = NULL;
const EVP_CIPHER *enc = NULL;
char *infile = NULL, *outfile = NULL, *prog;
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
@@ -166,19 +164,13 @@ int dsa_main(int argc, char **argv)
}
BIO_printf(bio_err, "read DSA key\n");
- {
- EVP_PKEY *pkey;
-
- if (pubin)
- pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key");
- else
- pkey = load_key(infile, informat, 1, passin, e, "Private Key");
+ if (pubin)
+ pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key");
+ else
+ pkey = load_key(infile, informat, 1, passin, e, "Private Key");
- if (pkey != NULL) {
- dsa = EVP_PKEY_get1_DSA(pkey);
- EVP_PKEY_free(pkey);
- }
- }
+ if (pkey != NULL)
+ dsa = EVP_PKEY_get1_DSA(pkey);
if (dsa == NULL) {
BIO_printf(bio_err, "unable to load Key\n");
@@ -192,7 +184,8 @@ int dsa_main(int argc, char **argv)
if (text) {
assert(pubin || private);
- if (!DSA_print(out, dsa, 0)) {
+ if ((pubin && EVP_PKEY_print_public(out, pkey, 0, NULL) <= 0)
+ || (!pubin && EVP_PKEY_print_private(out, pkey, 0, NULL) <= 0)) {
perror(outfile);
ERR_print_errors(bio_err);
goto end;
@@ -269,6 +262,7 @@ int dsa_main(int argc, char **argv)
ret = 0;
end:
BIO_free_all(out);
+ EVP_PKEY_free(pkey);
DSA_free(dsa);
release_engine(e);
OPENSSL_free(passin);