From: Daniel Stenberg Date: Mon, 4 Jul 2022 06:27:21 +0000 (+0200) Subject: digest: simplify a switch() to a simple if X-Git-Tag: curl-7_85_0~206 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=193215db3ca956b1e5c99539bc20cf892870d11f;p=thirdparty%2Fcurl.git digest: simplify a switch() to a simple if --- diff --git a/lib/urldata.h b/lib/urldata.h index bcb4d460c2..71ac2f1619 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -318,11 +318,11 @@ struct digestdata { char *nonce; char *cnonce; char *realm; - int algo; char *opaque; char *qop; char *algorithm; int nc; /* nonce count */ + unsigned char algo; BIT(stale); /* set true for re-negotiation */ BIT(userhash); #endif diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c index b3e4776f16..16171b0210 100644 --- a/lib/vauth/digest.c +++ b/lib/vauth/digest.c @@ -945,28 +945,18 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, struct digestdata *digest, char **outptr, size_t *outlen) { - switch(digest->algo) { - case ALGO_MD5: - case ALGO_MD5SESS: + if(digest->algo <= ALGO_MD5SESS) return auth_create_digest_http_message(data, userp, passwdp, request, uripath, digest, outptr, outlen, auth_digest_md5_to_ascii, Curl_md5it); - - case ALGO_SHA256: - case ALGO_SHA256SESS: - case ALGO_SHA512_256: - case ALGO_SHA512_256SESS: - return auth_create_digest_http_message(data, userp, passwdp, - request, uripath, digest, - outptr, outlen, - auth_digest_sha256_to_ascii, - Curl_sha256it); - - default: - return CURLE_UNSUPPORTED_PROTOCOL; - } + DEBUGASSERT(digest->algo <= ALGO_SHA512_256SESS); + return auth_create_digest_http_message(data, userp, passwdp, + request, uripath, digest, + outptr, outlen, + auth_digest_sha256_to_ascii, + Curl_sha256it); } /*