]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
digest: simplify a switch() to a simple if
authorDaniel Stenberg <daniel@haxx.se>
Mon, 4 Jul 2022 06:27:21 +0000 (08:27 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 4 Jul 2022 06:27:21 +0000 (08:27 +0200)
lib/urldata.h
lib/vauth/digest.c

index bcb4d460c2fe6d2108683d83506a54c2bcd4bbb2..71ac2f1619591535d8ce556df24370f75c76a257 100644 (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
index b3e4776f1672191a6da8a256a1227db3fbfd11d0..16171b0210175e25e9073b86e2abb4fbea130cc0 100644 (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);
 }
 
 /*