diff options
author | Curl Upstream <curl-library@lists.haxx.se> | 2022-12-21 07:00:59 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-01-27 20:58:30 (GMT) |
commit | dac458ddbf2b48168779821654a7e69cbd828c14 (patch) | |
tree | 8191fa2b92ceb3469c8ac5878b4ded3112f5f16c /lib/md5.c | |
parent | ec122fff08ab9a8e56fb90126ecedb99c759011b (diff) | |
download | CMake-dac458ddbf2b48168779821654a7e69cbd828c14.zip CMake-dac458ddbf2b48168779821654a7e69cbd828c14.tar.gz CMake-dac458ddbf2b48168779821654a7e69cbd828c14.tar.bz2 |
curl 2022-12-21 (c12fb3dd)
Code extracted from:
https://github.com/curl/curl.git
at commit c12fb3ddaf48e709a7a4deaa55ec485e4df163ee (curl-7_87_0).
Diffstat (limited to 'lib/md5.c')
-rw-r--r-- | lib/md5.c | 65 |
1 files changed, 24 insertions, 41 deletions
@@ -26,6 +26,7 @@ #ifndef CURL_DISABLE_CRYPTO_AUTH +#include <string.h> #include <curl/curl.h> #include "curl_md5.h" @@ -56,12 +57,32 @@ #endif #if defined(USE_GNUTLS) - #include <nettle/md5.h> +#elif defined(USE_OPENSSL_MD5) +#include <openssl/md5.h> +#elif defined(USE_WOLFSSL_MD5) +#include <wolfssl/openssl/md5.h> +#elif defined(USE_MBEDTLS) +#include <mbedtls/md5.h> +#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ + (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \ + defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \ + (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ + (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000)) +#define AN_APPLE_OS +#include <CommonCrypto/CommonDigest.h> +#elif defined(USE_WIN32_CRYPTO) +#include <wincrypt.h> +#endif + +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" #include "curl_memory.h" -/* The last #include file should be: */ #include "memdebug.h" +#if defined(USE_GNUTLS) + typedef struct md5_ctx my_md5_ctx; static CURLcode my_md5_init(my_md5_ctx *ctx) @@ -84,17 +105,6 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) #elif defined(USE_OPENSSL_MD5) || defined(USE_WOLFSSL_MD5) -/* When OpenSSL or wolfSSL is available, we use their MD5 functions. */ -#if defined(USE_OPENSSL_MD5) -#include <openssl/md5.h> -#elif defined(USE_WOLFSSL_MD5) -#include <wolfssl/openssl/md5.h> -#endif - -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" - typedef MD5_CTX my_md5_ctx; static CURLcode my_md5_init(my_md5_ctx *ctx) @@ -119,13 +129,6 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) #elif defined(USE_MBEDTLS) -#include <mbedtls/md5.h> - -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" - typedef mbedtls_md5_context my_md5_ctx; static CURLcode my_md5_init(my_md5_ctx *ctx) @@ -162,12 +165,7 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) #endif } -#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ - (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \ - defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \ - (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \ - (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ - (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000)) +#elif defined(AN_APPLE_OS) /* For Apple operating systems: CommonCrypto has the functions we need. These functions are available on Tiger and later, as well as iOS 2.0 @@ -175,11 +173,7 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) Declaring the functions as static like this seems to be a bit more reliable than defining COMMON_DIGEST_FOR_OPENSSL on older cats. */ -# include <CommonCrypto/CommonDigest.h> # define my_md5_ctx CC_MD5_CTX -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" static CURLcode my_md5_init(my_md5_ctx *ctx) { @@ -203,11 +197,6 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) #elif defined(USE_WIN32_CRYPTO) -#include <wincrypt.h> -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" - struct md5_ctx { HCRYPTPROV hCryptProv; HCRYPTHASH hHash; @@ -288,12 +277,6 @@ static void my_md5_final(unsigned char *digest, my_md5_ctx *ctx) * compile-time configuration. */ -#include <string.h> - -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* Any 32-bit or wider unsigned integer data type will do */ typedef unsigned int MD5_u32plus; |