72 #define BUFSIZE 1024*8
75 #define PROG dgst_main
77 int do_fp(
BIO *out,
unsigned char *buf,
BIO *
bp,
int sep,
int binout,
79 const char *sig_name,
const char *md_name,
82 static void list_md_fn(
const EVP_MD *m,
83 const char *from,
const char *to,
void *
arg)
91 if (strcmp(from, mname))
96 if (strchr(mname,
' '))
98 BIO_printf(arg,
"-%-14s to use the %s message digest algorithm\n",
102 int MAIN(
int,
char **);
104 int MAIN(
int argc,
char **argv)
107 unsigned char *buf=NULL;
113 #define PROG_NAME_SIZE 39
118 const char *outfile = NULL, *keyfile = NULL;
119 const char *sigfile = NULL, *randfile = NULL;
120 int out_bin = -1, want_pub = 0, do_verify = 0;
122 unsigned char *sigbuf = NULL;
124 char *passargin = NULL, *passin = NULL;
125 #ifndef OPENSSL_NO_ENGINE
130 int non_fips_allow = 0;
156 if ((*argv)[0] !=
'-')
break;
157 if (strcmp(*argv,
"-c") == 0)
159 else if (strcmp(*argv,
"-r") == 0)
161 else if (strcmp(*argv,
"-rand") == 0)
163 if (--argc < 1)
break;
166 else if (strcmp(*argv,
"-out") == 0)
168 if (--argc < 1)
break;
171 else if (strcmp(*argv,
"-sign") == 0)
173 if (--argc < 1)
break;
176 else if (!strcmp(*argv,
"-passin"))
182 else if (strcmp(*argv,
"-verify") == 0)
184 if (--argc < 1)
break;
189 else if (strcmp(*argv,
"-prverify") == 0)
191 if (--argc < 1)
break;
195 else if (strcmp(*argv,
"-signature") == 0)
197 if (--argc < 1)
break;
200 else if (strcmp(*argv,
"-keyform") == 0)
202 if (--argc < 1)
break;
205 #ifndef OPENSSL_NO_ENGINE
206 else if (strcmp(*argv,
"-engine") == 0)
208 if (--argc < 1)
break;
213 else if (strcmp(*argv,
"-hex") == 0)
215 else if (strcmp(*argv,
"-binary") == 0)
217 else if (strcmp(*argv,
"-d") == 0)
219 else if (strcmp(*argv,
"-non-fips-allow") == 0)
221 else if (!strcmp(*argv,
"-fips-fingerprint"))
222 hmac_key =
"etaonrishdlcupfm";
223 else if (!strcmp(*argv,
"-hmac"))
229 else if (!strcmp(*argv,
"-mac"))
235 else if (strcmp(*argv,
"-sigopt") == 0)
244 else if (strcmp(*argv,
"-macopt") == 0)
262 if(do_verify && !sigfile) {
267 if ((argc > 0) && (argv[0][0] ==
'-'))
277 BIO_printf(
bio_err,
"-verify file verify a signature using public key in file\n");
278 BIO_printf(
bio_err,
"-prverify file verify a signature using private key in file\n");
286 #ifndef OPENSSL_NO_ENGINE
309 if ((in == NULL) || (bmd == NULL))
331 #ifdef OPENSSL_SYS_VMS
341 outfile ? outfile :
"(stdout)");
345 if ((!!mac_name + !!keyfile + !!hmac_key) > 1)
382 "MAC parameter error \"%s\"\n",
413 (
unsigned char *)hmac_key, -1);
448 "parameter error \"%s\"\n",
469 if(sigfile && sigkey) {
480 siglen =
BIO_read(sigbio, sigbuf, siglen);
501 err=
do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf,
502 siglen,NULL,NULL,
"stdin",bmd);
506 const char *md_name = NULL, *sig_name = NULL;
515 NULL, NULL, &sig_name, ameth);
520 for (i=0; i<argc; i++)
530 r=
do_fp(out,buf,inp,separator,out_bin,sigkey,sigbuf,
531 siglen,sig_name,md_name, argv[i],bmd);
560 const char *sig_name,
const char *md_name,
622 for (i=0; i<(int)len; i++)
629 BIO_printf(out,
"%s-%s(%s)= ", sig_name, md_name, file);
634 for (i=0; i<(int)len; i++)