Document openssl dgst -hmac option
[openssl.git] / apps / dgst.c
index 191bc25ee82bbdc96c0cd17a1d1112c4e0d8dfa0..9f6954f26542cb409ce75fceac145374e3f0022b 100644 (file)
@@ -128,6 +128,7 @@ int MAIN(int argc, char **argv)
 #endif
        char *hmac_key=NULL;
        char *mac_name=NULL;
+       int non_fips_allow = 0;
        STACK_OF(OPENSSL_STRING) *sigopts = NULL, *macopts = NULL;
 
        apps_startup();
@@ -218,6 +219,10 @@ int MAIN(int argc, char **argv)
                        out_bin = 1;
                else if (strcmp(*argv,"-d") == 0)
                        debug=1;
+               else if (!strcmp(*argv,"-fips-fingerprint"))
+                       hmac_key = "etaonrishdlcupfm";
+               else if (strcmp(*argv,"-non-fips-allow") == 0)
+                       non_fips_allow=1;
                else if (!strcmp(*argv,"-hmac"))
                        {
                        if (--argc < 1)
@@ -271,6 +276,8 @@ int MAIN(int argc, char **argv)
                BIO_printf(bio_err,"-d              to output debug info\n");
                BIO_printf(bio_err,"-hex            output as hex dump\n");
                BIO_printf(bio_err,"-binary         output in binary form\n");
+               BIO_printf(bio_err,"-hmac arg       set the HMAC key to arg\n");
+               BIO_printf(bio_err,"-non-fips-allow allow use of non FIPS digest\n");
                BIO_printf(bio_err,"-sign   file    sign digest using private key in file\n");
                BIO_printf(bio_err,"-verify file    verify a signature using public key in file\n");
                BIO_printf(bio_err,"-prverify file  verify a signature using private key in file\n");
@@ -403,6 +410,13 @@ int MAIN(int argc, char **argv)
                        goto end;
                }
 
+       if (non_fips_allow)
+               {
+               EVP_MD_CTX *md_ctx;
+               BIO_get_md_ctx(bmd,&md_ctx);
+               EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
+               }
+
        if (hmac_key)
                {
                sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, impl,
@@ -517,7 +531,8 @@ int MAIN(int argc, char **argv)
                                        EVP_PKEY_asn1_get0_info(NULL, NULL,
                                                NULL, NULL, &sig_name, ameth);
                                }
-                       md_name = EVP_MD_name(md);
+                       if (md)
+                               md_name = EVP_MD_name(md);
                        }
                err = 0;
                for (i=0; i<argc; i++)
@@ -629,7 +644,12 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
        else 
                {
                if (sig_name)
-                       BIO_printf(out, "%s-%s(%s)= ", sig_name, md_name, file);
+                       {
+                       BIO_puts(out, sig_name);
+                       if (md_name)
+                               BIO_printf(out, "-%s", md_name);
+                       BIO_printf(out, "(%s)= ", file);
+                       }
                else if (md_name)
                        BIO_printf(out, "%s(%s)= ", md_name, file);
                else