From b5ea4f711f6058eba8c494b80e233e959ab0182a Mon Sep 17 00:00:00 2001 From: Wyatt O'Day Date: Tue, 5 Aug 2025 10:03:15 -0400 Subject: [PATCH] Remove more mbedTLS 2.x junk --- lib/md4.c | 12 ------------ lib/md5.c | 24 +----------------------- lib/sha256.c | 16 ---------------- 3 files changed, 1 insertion(+), 51 deletions(-) diff --git a/lib/md4.c b/lib/md4.c index 57545dde93..44f4964fe5 100644 --- a/lib/md4.c +++ b/lib/md4.c @@ -53,15 +53,7 @@ #ifdef USE_MBEDTLS #include -#if MBEDTLS_VERSION_NUMBER >= 0x03000000 #include -#else -#include -#endif -#if(MBEDTLS_VERSION_NUMBER >= 0x02070000) && \ - (MBEDTLS_VERSION_NUMBER < 0x03000000) - #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS -#endif #endif /* USE_MBEDTLS */ /* When OpenSSL or wolfSSL is available, we use their MD4 functions. */ @@ -220,11 +212,7 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) static void MD4_Final(unsigned char *result, MD4_CTX *ctx) { if(ctx->data) { -#ifndef HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS mbedtls_md4(ctx->data, ctx->size, result); -#else - (void)mbedtls_md4_ret(ctx->data, ctx->size, result); -#endif Curl_safefree(ctx->data); ctx->size = 0; diff --git a/lib/md5.c b/lib/md5.c index fea20377fe..912909b84c 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -36,11 +36,6 @@ #ifdef USE_MBEDTLS #include - -#if(MBEDTLS_VERSION_NUMBER >= 0x02070000) && \ - (MBEDTLS_VERSION_NUMBER < 0x03000000) - #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS -#endif #endif /* USE_MBEDTLS */ #ifdef USE_OPENSSL @@ -161,36 +156,19 @@ typedef mbedtls_md5_context my_md5_ctx; static CURLcode my_md5_init(void *ctx) { -#if (MBEDTLS_VERSION_NUMBER >= 0x03000000) - if(mbedtls_md5_starts(ctx)) - return CURLE_OUT_OF_MEMORY; -#elif defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS) - if(mbedtls_md5_starts_ret(ctx)) - return CURLE_OUT_OF_MEMORY; -#else - (void)mbedtls_md5_starts(ctx); -#endif - return CURLE_OK; + return mbedtls_md5_starts(ctx) ? CURLE_OUT_OF_MEMORY : CURLE_OK; } static void my_md5_update(void *ctx, const unsigned char *data, unsigned int length) { -#ifndef HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS (void)mbedtls_md5_update(ctx, data, length); -#else - (void)mbedtls_md5_update_ret(ctx, data, length); -#endif } static void my_md5_final(unsigned char *digest, void *ctx) { -#ifndef HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS (void)mbedtls_md5_finish(ctx, digest); -#else - (void)mbedtls_md5_finish_ret(ctx, digest); -#endif } #elif defined(AN_APPLE_OS) diff --git a/lib/sha256.c b/lib/sha256.c index ca026782a3..17bf6cf75f 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -38,10 +38,6 @@ #include #elif defined(USE_MBEDTLS) #include -#if(MBEDTLS_VERSION_NUMBER >= 0x02070000) && \ - (MBEDTLS_VERSION_NUMBER < 0x03000000) - #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS -#endif #include #elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \ @@ -134,11 +130,7 @@ typedef mbedtls_sha256_context my_sha256_ctx; static CURLcode my_sha256_init(void *ctx) { -#ifndef HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS (void)mbedtls_sha256_starts(ctx, 0); -#else - (void)mbedtls_sha256_starts_ret(ctx, 0); -#endif return CURLE_OK; } @@ -146,20 +138,12 @@ static void my_sha256_update(void *ctx, const unsigned char *data, unsigned int length) { -#ifndef HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS (void)mbedtls_sha256_update(ctx, data, length); -#else - (void)mbedtls_sha256_update_ret(ctx, data, length); -#endif } static void my_sha256_final(unsigned char *digest, void *ctx) { -#ifndef HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS (void)mbedtls_sha256_finish(ctx, digest); -#else - (void)mbedtls_sha256_finish_ret(ctx, digest); -#endif } #elif defined(AN_APPLE_OS)