]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
md5: fix compilation with OpenSSL 3.0 API
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Sun, 26 Sep 2021 07:19:51 +0000 (09:19 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Thu, 7 Oct 2021 16:40:03 +0000 (18:40 +0200)
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

index 00b40af4da7023e4b685c22cc5e7f31c94c5730d..810c5fba8e9cba81867c5bbdcf621ec4170ead19 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
 #endif
 #endif /* USE_MBEDTLS */
 
+#if defined(USE_OPENSSL) && !defined(USE_AMISSL)
+  #include <openssl/opensslconf.h>
+  #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
+    #define USE_OPENSSL_MD5
+  #endif
+#endif
+
+#ifdef USE_WOLFSSL
+  #include <wolfssl/options.h>
+  #ifndef NO_MD5
+    #define USE_WOLFSSL_MD5
+  #endif
+#endif
+
 #if defined(USE_GNUTLS)
 
 #include <nettle/md5.h>
@@ -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 <wolfssl/options.h>
-#endif
-
-#if defined(USE_OPENSSL) || (defined(USE_WOLFSSL) && !defined(NO_MD5))
 /* When OpenSSL or wolfSSL is available, we use their MD5 functions. */
 #include <openssl/md5.h>
 #include "curl_memory.h"
 /* The last #include file should be: */
 #include "memdebug.h"
-#endif
 
 #elif defined(USE_MBEDTLS)