X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fdgst.c;h=280f79b4a23abaf5f1c3029642763bdc5dd7536f;hb=db186beee4ae2af2ea87f75781d62ea34846e440;hp=7989a1dcd38604c16864f5c1d420a5c1b733c6ea;hpb=fbfcdc4cef0d9cf7dcda17d8744a03ea6b97857b;p=oweals%2Fopenssl.git diff --git a/apps/dgst.c b/apps/dgst.c index 7989a1dcd3..280f79b4a2 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -73,8 +73,9 @@ #undef PROG #define PROG dgst_main -void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, - EVP_PKEY *key, unsigned char *sigin, int siglen); +int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, + EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title, + const char *file); int MAIN(int, char **); @@ -88,8 +89,8 @@ int MAIN(int argc, char **argv) BIO *bmd=NULL; BIO *out = NULL; const char *name; -#define PROG_NAME_SIZE 16 - char pname[PROG_NAME_SIZE]; +#define PROG_NAME_SIZE 39 + char pname[PROG_NAME_SIZE+1]; int separator=0; int debug=0; int keyform=FORMAT_PEM; @@ -112,8 +113,11 @@ int MAIN(int argc, char **argv) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); + if (!load_config(bio_err, NULL)) + goto end; + /* first check the program name */ - program_name(argv[0],pname,PROG_NAME_SIZE); + program_name(argv[0],pname,sizeof pname); md=EVP_get_digestbyname(pname); @@ -273,10 +277,10 @@ int MAIN(int argc, char **argv) if(keyfile) { if (want_pub) - sigkey = load_pubkey(bio_err, keyfile, keyform, NULL, + sigkey = load_pubkey(bio_err, keyfile, keyform, 0, NULL, e, "key file"); else - sigkey = load_key(bio_err, keyfile, keyform, NULL, + sigkey = load_key(bio_err, keyfile, keyform, 0, NULL, e, "key file"); if (!sigkey) { @@ -316,29 +320,43 @@ int MAIN(int argc, char **argv) if (argc == 0) { BIO_set_fp(in,stdin,BIO_NOCLOSE); - do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf, siglen); + err=do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf, + siglen,"","(stdin)"); } else { name=OBJ_nid2sn(md->type); for (i=0; i 0) BIO_printf(out, "Verified OK\n"); - else if(i == 0) BIO_printf(out, "Verification Failure\n"); + if(i > 0) + BIO_printf(out, "Verified OK\n"); + else if(i == 0) + { + BIO_printf(out, "Verification Failure\n"); + return 1; + } else { BIO_printf(bio_err, "Error Verifying Data\n"); ERR_print_errors(bio_err); + return 1; } - return; + return 0; } if(key) { @@ -383,7 +414,7 @@ void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, { BIO_printf(bio_err, "Error Signing Data\n"); ERR_print_errors(bio_err); - return; + return 1; } } else @@ -392,6 +423,7 @@ void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, if(binout) BIO_write(out, buf, len); else { + BIO_write(out,title,strlen(title)); for (i=0; i