Remove more mbedTLS 2.x junk

This commit is contained in:
Wyatt O'Day 2025-08-05 10:03:15 -04:00
parent 0cf5e24999
commit b5ea4f711f
3 changed files with 1 additions and 51 deletions

View file

@ -53,15 +53,7 @@
#ifdef USE_MBEDTLS
#include <mbedtls/version.h>
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
#include <mbedtls/mbedtls_config.h>
#else
#include <mbedtls/config.h>
#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;

View file

@ -36,11 +36,6 @@
#ifdef USE_MBEDTLS
#include <mbedtls/version.h>
#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)

View file

@ -38,10 +38,6 @@
#include <nettle/sha.h>
#elif defined(USE_MBEDTLS)
#include <mbedtls/version.h>
#if(MBEDTLS_VERSION_NUMBER >= 0x02070000) && \
(MBEDTLS_VERSION_NUMBER < 0x03000000)
#define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS
#endif
#include <mbedtls/sha256.h>
#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)