libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit c4bb79d9253db265fe3bfdf9f59b834b9eff843b
parent 148e953db8bd32788396d43946c3808d6263caf8
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 20 Dec 2025 10:34:39 +0100

make code compile with mbedtls3

Diffstat:
Msrc/mhd2/sha512_256_ext_mbedtls.c | 31+++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/mhd2/sha512_256_ext_mbedtls.c b/src/mhd2/sha512_256_ext_mbedtls.c @@ -41,7 +41,9 @@ * @brief Wrapper for SHA-512/256 calculation performed by mbedTLS library * @author Christian Grothoff */ - +#include <stdlib.h> +#include <string.h> +#define MBEDTLS_ALLOW_PRIVATE_ACCESS 1 #include <mbedtls/sha512.h> #define MHD_SHA512_256_Context mbedtls_sha512_context #include "sha512_256_ext.h" @@ -68,6 +70,7 @@ init512_256 (struct mhd_Sha512_256CtxExt *ctx) mbedtls_sha512_init (ctx->handle); /* is384=0 for SHA-512 */ +#if MBEDTLS_CONFIG_VERSION >= 0x04000000 ctx->ext_error = mbedtls_sha512_starts_ret (ctx->handle, 0); if (0 != ctx->ext_error) @@ -82,6 +85,15 @@ init512_256 (struct mhd_Sha512_256CtxExt *ctx) memcpy (ctx->handle.state, iv_sha512_256, sizeof (iv_sha512_256)); +#else + mbedtls_sha512_starts (ctx->handle, + 0); + mhd_assert (sizeof (ctx->handle->state) == + sizeof (iv_sha512_256)); + memcpy (ctx->handle->state, + iv_sha512_256, + sizeof (iv_sha512_256)); +#endif } @@ -126,9 +138,16 @@ mhd_SHA512_256_update (struct mhd_Sha512_256CtxExt *ctx, const uint8_t *data) { mhd_assert (0 != size); - +#if MBEDTLS_CONFIG_VERSION >= 0x04000000 if (0 == ctx->ext_error) - ctx->ext_error = mbedtls_sha512_update_ret (ctx->handle, data, size); + ctx->ext_error = mbedtls_sha512_update_ret (ctx->handle, + data, + size); +#else + mbedtls_sha512_update (ctx->handle, + data, + size); +#endif } @@ -146,9 +165,13 @@ mhd_SHA512_256_finish_reset (struct mhd_Sha512_256CtxExt *ctx, if (0 == ctx->ext_error) { +#if MBEDTLS_CONFIG_VERSION >= 0x04000000 ctx->ext_error = mbedtls_sha512_finish_ret (ctx->handle, full_digest); - +#else + mbedtls_sha512_finish (ctx->handle, + full_digest); +#endif if (0 == ctx->ext_error) { /* SHA-512/256 uses first 32 bytes of SHA-512 with different IV */