When in FIPS mode, use SHA1 to digest the key, rather than MD5, as MD5
authorRichard Levitte <levitte@openssl.org>
Mon, 17 May 2004 04:31:14 +0000 (04:31 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 17 May 2004 04:31:14 +0000 (04:31 +0000)
isn't a FIPS-approved algorithm.

Note: this means the user needs to keep track of this, and we need to
add support for that...

apps/enc.c

index 30378a9542e8a74659023bd73e4daa354400e685..bd1ecfc6ffc51ed66f6d33410ef6af6f43c2e61c 100644 (file)
@@ -124,6 +124,7 @@ int MAIN(int argc, char **argv)
 #ifndef OPENSSL_NO_ENGINE
        char *engine = NULL;
 #endif
+       const EVP_MD *dgst=NULL;
 
        apps_startup();
 
@@ -296,6 +297,14 @@ bad:
         e = setup_engine(bio_err, engine, 0);
 #endif
 
+       if (dgst == NULL)
+               {
+               if (in_FIPS_mode)
+                       dgst = EVP_sha1();
+               else
+                       dgst = EVP_md5();
+               }
+
        if (bufsize != NULL)
                {
                unsigned long n;
@@ -483,7 +492,7 @@ bad:
                                sptr = salt;
                        }
 
-                       EVP_BytesToKey(cipher,EVP_md5(),sptr,
+                       EVP_BytesToKey(cipher,dgst,sptr,
                                (unsigned char *)str,
                                strlen(str),1,key,iv);
                        /* zero the complete buffer or the string