gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 01/04: digestauth: added macros for algorithms identific


From: gnunet
Subject: [libmicrohttpd] 01/04: digestauth: added macros for algorithms identifications
Date: Tue, 18 Jan 2022 13:22:54 +0100

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 17c22c2c3b8e2b56874ff701be58e7c10d1d41f4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue Jan 18 12:41:32 2022 +0300

    digestauth: added macros for algorithms identifications
---
 src/microhttpd/digestauth.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 7c22af6b..81ca2ac9 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -108,6 +108,20 @@
  */
 #define MAX_AUTH_RESPONSE_LENGTH 256
 
+/**
+ * The token for MD5 algorithm.
+ */
+#define _MHD_MD5_TOKEN "MD5"
+
+/**
+ * The token for SHA-256 algorithm.
+ */
+#define _MHD_SHA256_TOKEN "SHA-256"
+
+/**
+ * The postfix token for "session" algorithms.
+ */
+#define _MHD_SESS_TOKEN "-sess"
 
 /**
  * Context passed to functions that need to calculate
@@ -128,7 +142,8 @@ struct DigestAlgorithm
   void *ctx;
 
   /**
-   * Name of the algorithm, "MD5" or "SHA-256"
+   * Name of the algorithm, "MD5" or "SHA-256".
+   * @sa #_MHD_MD5_TOKEN, #_MHD_SHA256_TOKEN
    */
   const char *alg;
 
@@ -218,9 +233,9 @@ digest_calc_ha1_from_digest (const char *alg,
 {
   const unsigned int digest_size = da->digest_size;
   if ( (MHD_str_equal_caseless_ (alg,
-                                 "MD5-sess")) ||
+                                 _MHD_MD5_TOKEN _MHD_SESS_TOKEN)) ||
        (MHD_str_equal_caseless_ (alg,
-                                 "SHA-256-sess")) )
+                                 _MHD_SHA256_TOKEN _MHD_SESS_TOKEN)) )
   {
     uint8_t dig[VLA_ARRAY_LEN_DIGEST (digest_size)];
 
@@ -1197,7 +1212,7 @@ MHD_digest_auth_check (struct MHD_Connection *connection,
     case MHD_DIGEST_ALG_MD5:                        \
       da.digest_size = MD5_DIGEST_SIZE;             \
       da.ctx = &ctx.md5;                            \
-      da.alg = "MD5";                               \
+      da.alg = _MHD_MD5_TOKEN;                               \
       da.sessionkey = skey.md5;                     \
       da.init = &MHD_MD5Init;                           \
       da.update = &MHD_MD5Update;                       \
@@ -1208,7 +1223,7 @@ MHD_digest_auth_check (struct MHD_Connection *connection,
     case MHD_DIGEST_ALG_SHA256:                           \
       da.digest_size = SHA256_DIGEST_SIZE;                \
       da.ctx = &ctx.sha256;                               \
-      da.alg = "SHA-256";                                 \
+      da.alg = _MHD_SHA256_TOKEN;                                 \
       da.sessionkey = skey.sha256;                        \
       da.init = &MHD_SHA256_init;                             \
       da.update = &MHD_SHA256_update;                         \

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]