openssl: use non-deprecated API for MD5/MD4
No binary (build failed)
—
(log yok)
| @@ -1518,8 +1518,8 @@ typedef struct sockaddr_un { | |
| /* OpenSSL 3 marks these functions deprecated but we have no replacements (yet) | |
| so tell the compiler to not warn for them: | |
| - DES_* (for NTLM) | |
| - | - EVP_PKEY_get1_RSA, MD5_*, RSA_flags, RSA_free (auto-skipped for OpenSSL |
| - | built with no-deprecated) */ |
| + | - EVP_PKEY_get1_RSA, RSA_flags, RSA_free (auto-skipped for OpenSSL built |
| + | with no-deprecated) */ |
| # define OPENSSL_SUPPRESS_DEPRECATED | |
| # ifdef _WIN32 | |
| /* Silence LibreSSL warnings about wincrypt.h collision. Works in 3.8.2+ */ | |
| @@ -42,16 +42,35 @@ | |
| #include <wolfssl/options.h> | |
| #endif | |
| - | /* When OpenSSL or wolfSSL is available, we use their MD4 functions. */ |
| - | |
| #if defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4) | |
| - | #include <openssl/md4.h> |
| + | #include <openssl/evp.h> |
| + | |
| + | typedef EVP_MD_CTX *my_md4_ctx; |
| + | |
| + | static int my_md4_init(my_md4_ctx *ctx) |
| + | { |
| + | *ctx = EVP_MD_CTX_new(); |
| + | if(!*ctx) |
| + | return 0; |
| + | |
| + | if(!EVP_DigestInit_ex(*ctx, EVP_md4(), NULL)) { |
| + | EVP_MD_CTX_free(*ctx); |
| + | return 0; |
| + | } |
| + | return 1; |
| + | } |
| - | /* Map directly to OpenSSL implementation */ |
| - | #define my_md4_ctx MD4_CTX |
| - | #define my_md4_init MD4_Init |
| - | #define my_md4_update MD4_Update |
| - | #define my_md4_final MD4_Final |
| + | static void my_md4_update(my_md4_ctx *ctx, |
| + | const unsigned char *input, unsigned int len) |
| + | { |
| + | (void)EVP_DigestUpdate(*ctx, input, len); |
| + | } |
| + | |
| + | static void my_md4_final(unsigned char *digest, my_md4_ctx *ctx) |
| + | { |
| + | (void)EVP_DigestFinal_ex(*ctx, digest, NULL); |
| + | EVP_MD_CTX_free(*ctx); |
| + | } |
| #elif defined(USE_WOLFSSL) && !defined(NO_MD4) | |
| #include <wolfssl/wolfcrypt/md4.h> | |
| @@ -72,29 +72,39 @@ static void my_md5_final(unsigned char *digest, void *ctx) | |
| #endif | |
| } | |
| - | #elif defined(USE_OPENSSL) && \ |
| - | !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_DEPRECATED_3_0) |
| - | #include <openssl/md5.h> |
| + | #elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD5) |
| + | #include <openssl/evp.h> |
| - | typedef MD5_CTX my_md5_ctx; |
| + | typedef EVP_MD_CTX *my_md5_ctx; |
| - | static CURLcode my_md5_init(void *ctx) |
| + | static CURLcode my_md5_init(void *in) |
| { | |
| - | if(!MD5_Init(ctx)) |
| + | EVP_MD_CTX **ctx = (EVP_MD_CTX **)in; |
| + | *ctx = EVP_MD_CTX_new(); |
| + | if(!*ctx) |
| return CURLE_OUT_OF_MEMORY; | |
| + | if(!EVP_DigestInit_ex(*ctx, EVP_md5(), NULL)) { |
| + | EVP_MD_CTX_free(*ctx); |
| + | *ctx = NULL; |
| + | return CURLE_FAILED_INIT; |
| + | } |
| return CURLE_OK; | |
| } | |
| - | static void my_md5_update(void *ctx, |
| + | static void my_md5_update(void *in, |
| const unsigned char *input, unsigned int len) | |
| { | |
| - | (void)MD5_Update(ctx, input, len); |
| + | EVP_MD_CTX **ctx = (EVP_MD_CTX **)in; |
| + | (void)EVP_DigestUpdate(*ctx, input, len); |
| } | |
| - | static void my_md5_final(unsigned char *digest, void *ctx) |
| + | static void my_md5_final(unsigned char *digest, void *in) |
| { | |
| - | (void)MD5_Final(digest, ctx); |
| + | EVP_MD_CTX **ctx = (EVP_MD_CTX **)in; |
| + | (void)EVP_DigestFinal_ex(*ctx, digest, NULL); |
| + | EVP_MD_CTX_free(*ctx); |
| + | *ctx = NULL; |
| } | |
| #elif defined(USE_WOLFSSL) && !defined(NO_MD5) | |