Constification.
[oweals/openssl.git] / crypto / hmac / hmac.c
index ba27cbf56f2e9f843627795da68240240b67f5d9..45335a1f7af3344d7de54f4a65221334d78ba92a 100644 (file)
@@ -72,6 +72,18 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
        unsigned char pad[HMAC_MAX_MD_CBLOCK];
 
 #ifdef OPENSSL_FIPS
+       /* If FIPS mode switch to approved implementation if possible */
+       if (FIPS_mode())
+               {
+               const EVP_MD *fipsmd;
+               if (md)
+                       {
+                       fipsmd = FIPS_get_digestbynid(EVP_MD_type(md));
+                       if (fipsmd)
+                               md = fipsmd;
+                       }
+               }
+
        if (FIPS_mode())
                {
                /* If we have an ENGINE need to allow non FIPS */