X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fdgst.c;h=32e40c1f5368406796b6578bb38b1f4087b3d1e0;hb=153aecf91a9d11ccbdf7dedc1051cb6c746f7d6e;hp=1fbef6bed21ef28716cd6eb8e64d8aebdb85c594;hpb=531d630b5cfe0c50de122f0387a65473b4746bf8;p=oweals%2Fopenssl.git diff --git a/apps/dgst.c b/apps/dgst.c index 1fbef6bed2..32e40c1f53 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -66,7 +66,6 @@ #include #include #include -#include #undef BUFSIZE #define BUFSIZE 1024*8 @@ -74,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 **); @@ -89,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; @@ -113,6 +113,9 @@ 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); @@ -274,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) { @@ -317,22 +320,36 @@ 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