From b352e03ec815d35630f34b8b140f0cf4c0b07e1a Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Sun, 26 Sep 2021 09:19:51 +0200 Subject: md5: fix compilation with OpenSSL 3.0 API Only use OpenSSL's MD5 code if it's available. Also fix wolfSSL build with `NO_MD5`, in which case neither the wolfSSL/OpenSSL implementation nor the fallback implementation was used. Closes https://github.com/curl/curl/pull/7808 --- lib/md5.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/md5.c b/lib/md5.c index 00b40af4d..810c5fba8 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -39,6 +39,20 @@ #endif #endif /* USE_MBEDTLS */ +#if defined(USE_OPENSSL) && !defined(USE_AMISSL) + #include + #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_DEPRECATED_3_0) + #define USE_OPENSSL_MD5 + #endif +#endif + +#ifdef USE_WOLFSSL + #include + #ifndef NO_MD5 + #define USE_WOLFSSL_MD5 + #endif +#endif + #if defined(USE_GNUTLS) #include @@ -65,19 +79,13 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx) md5_digest(ctx, 16, digest); } -#elif (defined(USE_OPENSSL) && !defined(USE_AMISSL)) || defined(USE_WOLFSSL) +#elif defined(USE_OPENSSL_MD5) || defined(USE_WOLFSSL_MD5) -#ifdef USE_WOLFSSL -#include -#endif - -#if defined(USE_OPENSSL) || (defined(USE_WOLFSSL) && !defined(NO_MD5)) /* When OpenSSL or wolfSSL is available, we use their MD5 functions. */ #include #include "curl_memory.h" /* The last #include file should be: */ #include "memdebug.h" -#endif #elif defined(USE_MBEDTLS) -- cgit v1.2.1