diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-17 10:51:03 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-01-17 10:51:08 +0100 |
commit | 899e26205a2dfca9885eb87c460c02124922f493 (patch) | |
tree | 0d0a4137c0f61bc61a1ee0726fed565724668370 | |
parent | 0ea5d514477a8b109a922afe5cdd1343d94c63bd (diff) | |
download | libmicrohttpd-899e26205a2dfca9885eb87c460c02124922f493.tar.gz libmicrohttpd-899e26205a2dfca9885eb87c460c02124922f493.zip |
fix capitalization of SHA-256 / MD5 as per RFC 7616 as reported on the mailinglist by Ahmet Kermen
-rw-r--r-- | src/microhttpd/digestauth.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c index def2fb6d..7c22af6b 100644 --- a/src/microhttpd/digestauth.c +++ b/src/microhttpd/digestauth.c | |||
@@ -128,7 +128,7 @@ struct DigestAlgorithm | |||
128 | void *ctx; | 128 | void *ctx; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * Name of the algorithm, "md5" or "sha-256" | 131 | * Name of the algorithm, "MD5" or "SHA-256" |
132 | */ | 132 | */ |
133 | const char *alg; | 133 | const char *alg; |
134 | 134 | ||
@@ -198,8 +198,8 @@ cvthex (const unsigned char *bin, | |||
198 | * calculate H(A1) from given hash as per RFC2617 spec | 198 | * calculate H(A1) from given hash as per RFC2617 spec |
199 | * and store the * result in 'sessionkey'. | 199 | * and store the * result in 'sessionkey'. |
200 | * | 200 | * |
201 | * @param alg The hash algorithm used, can be "md5" or "md5-sess" | 201 | * @param alg The hash algorithm used, can be "MD5" or "MD5-sess" |
202 | * or "sha-256" or "sha-256-sess" | 202 | * or "SHA-256" or "SHA-256-sess" |
203 | * Note that the rest of the code does not support the the "-sess" variants! | 203 | * Note that the rest of the code does not support the the "-sess" variants! |
204 | * @param[in,out] da digest implementation, must match @a alg; the | 204 | * @param[in,out] da digest implementation, must match @a alg; the |
205 | * da->sessionkey will be initialized to the digest in HEX | 205 | * da->sessionkey will be initialized to the digest in HEX |
@@ -218,9 +218,9 @@ digest_calc_ha1_from_digest (const char *alg, | |||
218 | { | 218 | { |
219 | const unsigned int digest_size = da->digest_size; | 219 | const unsigned int digest_size = da->digest_size; |
220 | if ( (MHD_str_equal_caseless_ (alg, | 220 | if ( (MHD_str_equal_caseless_ (alg, |
221 | "md5-sess")) || | 221 | "MD5-sess")) || |
222 | (MHD_str_equal_caseless_ (alg, | 222 | (MHD_str_equal_caseless_ (alg, |
223 | "sha-256-sess")) ) | 223 | "SHA-256-sess")) ) |
224 | { | 224 | { |
225 | uint8_t dig[VLA_ARRAY_LEN_DIGEST (digest_size)]; | 225 | uint8_t dig[VLA_ARRAY_LEN_DIGEST (digest_size)]; |
226 | 226 | ||
@@ -260,8 +260,8 @@ digest_calc_ha1_from_digest (const char *alg, | |||
260 | * calculate H(A1) from username, realm and password as per RFC2617 spec | 260 | * calculate H(A1) from username, realm and password as per RFC2617 spec |
261 | * and store the result in 'sessionkey'. | 261 | * and store the result in 'sessionkey'. |
262 | * | 262 | * |
263 | * @param alg The hash algorithm used, can be "md5" or "md5-sess" | 263 | * @param alg The hash algorithm used, can be "MD5" or "MD5-sess" |
264 | * or "sha-256" or "sha-256-sess" | 264 | * or "SHA-256" or "SHA-256-sess" |
265 | * @param username A `char *' pointer to the username value | 265 | * @param username A `char *' pointer to the username value |
266 | * @param realm A `char *' pointer to the realm value | 266 | * @param realm A `char *' pointer to the realm value |
267 | * @param password A `char *' pointer to the password value | 267 | * @param password A `char *' pointer to the password value |
@@ -1197,7 +1197,7 @@ MHD_digest_auth_check (struct MHD_Connection *connection, | |||
1197 | case MHD_DIGEST_ALG_MD5: \ | 1197 | case MHD_DIGEST_ALG_MD5: \ |
1198 | da.digest_size = MD5_DIGEST_SIZE; \ | 1198 | da.digest_size = MD5_DIGEST_SIZE; \ |
1199 | da.ctx = &ctx.md5; \ | 1199 | da.ctx = &ctx.md5; \ |
1200 | da.alg = "md5"; \ | 1200 | da.alg = "MD5"; \ |
1201 | da.sessionkey = skey.md5; \ | 1201 | da.sessionkey = skey.md5; \ |
1202 | da.init = &MHD_MD5Init; \ | 1202 | da.init = &MHD_MD5Init; \ |
1203 | da.update = &MHD_MD5Update; \ | 1203 | da.update = &MHD_MD5Update; \ |
@@ -1208,7 +1208,7 @@ MHD_digest_auth_check (struct MHD_Connection *connection, | |||
1208 | case MHD_DIGEST_ALG_SHA256: \ | 1208 | case MHD_DIGEST_ALG_SHA256: \ |
1209 | da.digest_size = SHA256_DIGEST_SIZE; \ | 1209 | da.digest_size = SHA256_DIGEST_SIZE; \ |
1210 | da.ctx = &ctx.sha256; \ | 1210 | da.ctx = &ctx.sha256; \ |
1211 | da.alg = "sha-256"; \ | 1211 | da.alg = "SHA-256"; \ |
1212 | da.sessionkey = skey.sha256; \ | 1212 | da.sessionkey = skey.sha256; \ |
1213 | da.init = &MHD_SHA256_init; \ | 1213 | da.init = &MHD_SHA256_init; \ |
1214 | da.update = &MHD_SHA256_update; \ | 1214 | da.update = &MHD_SHA256_update; \ |