libmicrohttpd2

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

commit 9af1d7309fa45b0fd7f5746759852eb0becca37a
parent ed09a257495bc667f5ca043ffbe96800f418ff9c
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Sun, 26 Jan 2025 20:05:00 +0100

test_authentication: do not use SHA-256 if libcurl does not support it

Diffstat:
Msrc/tests/client_server/libtest_convenience_server_reply.c | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/tests/client_server/libtest_convenience_server_reply.c b/src/tests/client_server/libtest_convenience_server_reply.c @@ -35,6 +35,14 @@ #include <curl/curl.h> #include <assert.h> +#ifndef CURL_VERSION_BITS +# define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) +#endif +#ifndef CURL_AT_LEAST_VERSION +# define CURL_AT_LEAST_VERSION(x,y,z) \ + (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) +#endif + const struct MHD_Action * MHDT_server_reply_text ( void *cls, @@ -799,7 +807,11 @@ MHDT_server_reply_check_digest_auth ( const char *password; enum MHD_DigestAuthResult dar; const char *realm = "test-realm"; +#if CURL_AT_LEAST_VERSION (7,57,0) enum MHD_DigestAuthAlgo algo = MHD_DIGEST_AUTH_ALGO_SHA256; +#else + enum MHD_DigestAuthAlgo algo = MHD_DIGEST_AUTH_ALGO_MD5; +#endif size_t digest_len = MHD_digest_get_hash_size (algo); if (0 == digest_len) @@ -860,7 +872,7 @@ MHDT_server_reply_check_digest_auth ( NULL, /* domain */ (MHD_DAUTH_NONCE_STALE == dar) ? MHD_YES : MHD_NO, /* indicate stale */ MHD_DIGEST_AUTH_MULT_QOP_AUTH, - MHD_DIGEST_AUTH_MULT_ALGO_SHA256, + (enum MHD_DigestAuthMultiAlgo) algo, MHD_NO /* userhash_support */, MHD_YES /* prefer UTF8 */); if (MHD_SC_OK != sc)