digest: simplify a switch() to a simple if

This commit is contained in:
Daniel Stenberg 2022-07-04 08:27:21 +02:00
parent a44c9ba799
commit 193215db3c
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 8 additions and 18 deletions

View File

@ -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

View File

@ -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);
}
/*