From 378ad62adf2c89284c0bd472552de17138fc21c0 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 16 Feb 2024 15:43:48 +0000 Subject: [PATCH] digest: only if we have tls lib to do hashing --- include/libwebsockets/lws-genhash.h | 4 ++++ lib/roles/http/client/client-http.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/libwebsockets/lws-genhash.h b/include/libwebsockets/lws-genhash.h index f27c3b9146..a78a94aa7c 100644 --- a/include/libwebsockets/lws-genhash.h +++ b/include/libwebsockets/lws-genhash.h @@ -51,6 +51,8 @@ enum lws_genhmac_types { #define LWS_GENHASH_LARGEST 64 +#if defined(LWS_WITH_TLS) && defined(LWS_WITH_GENCRYPTO) + struct lws_genhash_ctx { uint8_t type; #if defined(LWS_WITH_MBEDTLS) @@ -186,4 +188,6 @@ lws_genhmac_update(struct lws_genhmac_ctx *ctx, const void *in, size_t len); */ LWS_VISIBLE LWS_EXTERN int lws_genhmac_destroy(struct lws_genhmac_ctx *ctx, void *result); + +#endif ///@} diff --git a/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index b5a03b1291..30974dd3df 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -580,7 +580,7 @@ lws_http_client_http_response(struct lws *wsi) #endif -#if defined(LWS_WITH_HTTP_DIGEST_AUTH) +#if defined(LWS_WITH_HTTP_DIGEST_AUTH) && defined(LWS_WITH_TLS) static const char *digest_toks[] = { "Digest", // 1 << 0 @@ -1047,7 +1047,7 @@ lws_client_interpret_server_handshake(struct lws *wsi) #endif n = atoi(p); -#if defined(LWS_WITH_HTTP_DIGEST_AUTH) +#if defined(LWS_WITH_HTTP_DIGEST_AUTH) && defined(LWS_WITH_TLS) if (n == 401 && lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_WWW_AUTHENTICATE)) { if (!(wsi->stash && wsi->stash->cis[CIS_USERNAME] && wsi->stash->cis[CIS_PASSWORD])) {