summaryrefslogtreecommitdiff
path: root/apps/dgst.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2007-05-17 12:55:03 +0000
committerDr. Stephen Henson <steve@openssl.org>2007-05-17 12:55:03 +0000
commitf03620ea15c4553de375258bc40bbf7a4092da90 (patch)
tree9e5d9b5c6f7ec84b7d2e8cf68fcb650a1fae19d6 /apps/dgst.c
parent47b2e238e5684eb0a31d363e2c8b949527b59306 (diff)
downloadopenssl-new-f03620ea15c4553de375258bc40bbf7a4092da90.tar.gz
Use default md if none specified in dgst utility.
Diffstat (limited to 'apps/dgst.c')
-rw-r--r--apps/dgst.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/apps/dgst.c b/apps/dgst.c
index 147c4f9e61..deb829ae19 100644
--- a/apps/dgst.c
+++ b/apps/dgst.c
@@ -231,8 +231,6 @@ int MAIN(int argc, char **argv)
argv++;
}
- if (md == NULL)
- md=EVP_md5();
if(do_verify && !sigfile) {
BIO_printf(bio_err, "No signature to verify: use the -signature option\n");
@@ -447,11 +445,16 @@ int MAIN(int argc, char **argv)
}
}
/* we use md as a filter, reading from 'in' */
- else if (!BIO_set_md(bmd,md))
+ else
{
- BIO_printf(bio_err, "Error setting digest %s\n", pname);
- ERR_print_errors(bio_err);
- goto end;
+ if (md == NULL)
+ md = EVP_md5();
+ if (!BIO_set_md(bmd,md))
+ {
+ BIO_printf(bio_err, "Error setting digest %s\n", pname);
+ ERR_print_errors(bio_err);
+ goto end;
+ }
}
if(sigfile && sigkey) {
@@ -476,6 +479,13 @@ int MAIN(int argc, char **argv)
}
inp=BIO_push(bmd,in);
+ if (md == NULL)
+ {
+ EVP_MD_CTX *tctx;
+ BIO_get_md_ctx(bmd, &tctx);
+ md = EVP_MD_CTX_md(tctx);
+ }
+
if (argc == 0)
{
BIO_set_fp(in,stdin,BIO_NOCLOSE);