Skip to content

Commit 93c563d

Browse files
committed
MDEV-7788 my_md5 crashes with openssl in fips mode
Tell OpenSSL to use MD5 even if FIPS prohibits it. This is fine as long as we do not use MD5 for cryptographical purposes (md5 is used internally for P_S message digests and for view checksums)
1 parent cc12a35 commit 93c563d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

mysys_ssl/my_md5.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ static void my_md5_hash(char *digest, const char *buf, int len)
3737
}
3838

3939
#elif defined(HAVE_OPENSSL)
40-
#include <openssl/md5.h>
40+
#include <openssl/evp.h>
4141

42-
static void my_md5_hash(unsigned char* digest, unsigned const char *buf, int len)
42+
static void my_md5_hash(uchar* digest, const uchar *buf, uint len)
4343
{
44-
MD5_CTX ctx;
45-
MD5_Init (&ctx);
46-
MD5_Update (&ctx, buf, len);
47-
MD5_Final (digest, &ctx);
44+
EVP_MD_CTX ctx;
45+
EVP_MD_CTX_init(&ctx);
46+
#ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
47+
/* Ok to ignore FIPS: MD5 is not used for crypto here */
48+
EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
49+
#endif
50+
EVP_DigestInit_ex(&ctx, EVP_md5(), NULL);
51+
EVP_DigestUpdate(&ctx, buf, len);
52+
EVP_DigestFinal(&ctx, digest, &len);
53+
EVP_MD_CTX_cleanup(&ctx);
4854
}
4955

5056
#endif /* HAVE_YASSL */

0 commit comments

Comments
 (0)