Hi to all.
I updated to the latest version 0.9.63.
This version caused some trouble with duplicated symbols in the newly
introduced hash methods sha256_init and sha256_update.
I want to ask if it is possible to use unique (MHD specific) names for them?
I attached a patch that introduce MHD_* as a preamble for the functions.
To have a consistent name convention, I also renamed the MD5 hash functions.
It would be great for the compatibilty with other hashing libraries if
this suggestion could be applied.
Kind regards,
Dirk Brinkmeier.
--- src/microhttpd/digestauth.c 2019-02-10 17:11:29.000000000 +0100
+++ /home/dirk/Cpp_Base_Project/src/inc/microhttpd/digestauth.c 2019-06-02 20:56:07.572592259 +0200
@@ -1179,9 +1179,9 @@
da.ctx = &ctx.md5; \
da.alg = "md5"; \
da.sessionkey = skey.md5; \
- da.init = &MD5Init; \
- da.update = &MD5Update; \
- da.digest = &MD5Final; \
+ da.init = &MHD_MD5Init; \
+ da.update = &MHD_MD5Update; \
+ da.digest = &MHD_MD5Final; \
break; \
case MHD_DIGEST_ALG_AUTO: \
/* auto == SHA256, fall-though thus intentional! */ \
@@ -1190,9 +1190,9 @@
da.ctx = &ctx.sha256; \
da.alg = "sha-256"; \
da.sessionkey = skey.sha256; \
- da.init = &sha256_init; \
- da.update = &sha256_update; \
- da.digest = &sha256_digest; \
+ da.init = &MHD_SHA256_init; \
+ da.update = &MHD_SHA256_update; \
+ da.digest = &MHD_SHA256_digest; \
break; \
}
--- src/microhttpd/md5.h 2018-12-08 00:23:29.000000000 +0100
+++ /home/dirk/Cpp_Base_Project/src/inc/microhttpd/md5.h 2019-06-02 20:50:12.787601482 +0200
@@ -39,7 +39,7 @@
* @param ctx_ must be a `struct MD5Context *`
*/
void
-MD5Init (void *ctx_);
+MHD_MD5Init (void *ctx_);
/**
@@ -49,7 +49,7 @@
* @param ctx_ must be a `struct MD5Context *`
*/
void
-MD5Update (void *ctx_,
+MHD_MD5Update (void *ctx_,
const uint8_t *input,
size_t len);
@@ -60,7 +60,7 @@
* @param ctx_ must be a `struct MD5Context *`
*/
void
-MD5Final (void *ctx_,
+MHD_MD5Final (void *ctx_,
unsigned char digest[MD5_DIGEST_SIZE]);
--- src/microhttpd/md5.c 2018-12-08 00:23:33.000000000 +0100
+++ /home/dirk/Cpp_Base_Project/src/inc/microhttpd/md5.c 2019-06-02 20:57:34.571352534 +0200
@@ -50,7 +50,7 @@
* @param ctx must be a `struct MD5Context *`
*/
void
-MD5Init (void *ctx_)
+MHD_MD5Init (void *ctx_)
{
struct MD5Context *ctx = ctx_;
@@ -69,7 +69,7 @@
* 1 0* (64-bit count of bits processed, MSB-first)
*/
static void
-MD5Pad (struct MD5Context *ctx)
+MHD_MD5Pad (struct MD5Context *ctx)
{
uint8_t count[8];
size_t padlen;
@@ -85,8 +85,8 @@
((ctx->count >> 3) & (MD5_BLOCK_SIZE - 1));
if (padlen < 1 + 8)
padlen += MD5_BLOCK_SIZE;
- MD5Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */
- MD5Update(ctx, count, 8);
+ MHD_MD5Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */
+ MHD_MD5Update(ctx, count, 8);
}
@@ -96,7 +96,7 @@
* @param ctx must be a `struct MD5Context *`
*/
void
-MD5Final (void *ctx_,
+MHD_MD5Final (void *ctx_,
unsigned char digest[MD5_DIGEST_SIZE])
{
struct MD5Context *ctx = ctx_;
@@ -105,7 +105,7 @@
if (!ctx || !digest)
return;
- MD5Pad(ctx);
+ MHD_MD5Pad(ctx);
for (i = 0; i < 4; i++)
PUT_32BIT_LE(digest + i * 4, ctx->state[i]);
@@ -131,7 +131,7 @@
* the data and converts bytes into longwords for this routine.
*/
static void
-MD5Transform (uint32_t state[4],
+MHD_MD5Transform (uint32_t state[4],
const uint8_t block[MD5_BLOCK_SIZE])
{
uint32_t a, b, c, d, in[MD5_BLOCK_SIZE / 4];
@@ -234,7 +234,7 @@
* of bytes.
*/
void
-MD5Update (void *ctx_,
+MHD_MD5Update (void *ctx_,
const uint8_t *input,
size_t len)
{
@@ -258,7 +258,7 @@
memcpy (ctx->buffer + have,
input,
need);
- MD5Transform(ctx->state, ctx->buffer);
+ MHD_MD5Transform(ctx->state, ctx->buffer);
input += need;
len -= need;
have = 0;
@@ -267,7 +267,7 @@
/* Process data in MD5_BLOCK_SIZE-byte chunks. */
while (len >= MD5_BLOCK_SIZE)
{
- MD5Transform (ctx->state,
+ MHD_MD5Transform (ctx->state,
(const unsigned char *) input);
input += MD5_BLOCK_SIZE;
len -= MD5_BLOCK_SIZE;
--- src/microhttpd/sha256.h 2018-12-08 00:24:35.000000000 +0100
+++ /home/dirk/Cpp_Base_Project/src/inc/microhttpd/sha256.h 2019-06-02 20:55:38.396028414 +0200
@@ -57,7 +57,7 @@
* @param ctx_ must be a `struct sha256_ctx *`
*/
void
-sha256_init (void *ctx_);
+MHD_SHA256_init (void *ctx_);
/**
@@ -68,7 +68,7 @@
* @param data bytes to add to hash
*/
void
-sha256_update (void *ctx_,
+MHD_SHA256_update (void *ctx_,
const uint8_t *data,
size_t length);
@@ -79,7 +79,7 @@
* @param digest[out] set to the hash, must be #SHA256_DIGEST_SIZE bytes
*/
void
-sha256_digest (void *ctx_,
+MHD_SHA256_digest (void *ctx_,
uint8_t digest[SHA256_DIGEST_SIZE]);
#endif /* NETTLE_SHA2_H_INCLUDED */
--- src/microhttpd/sha256.c 2018-12-08 00:26:16.000000000 +0100
+++ /home/dirk/Cpp_Base_Project/src/inc/microhttpd/sha256.c 2019-06-02 20:52:34.669539309 +0200
@@ -235,7 +235,7 @@
/* Initialize the SHA values */
void
-sha256_init (void *ctx_)
+MHD_SHA256_init (void *ctx_)
{
/* Initial values, also generated by the shadata program. */
static const uint32_t H0[_SHA256_DIGEST_LENGTH] =
@@ -323,7 +323,7 @@
void
-sha256_update (void *ctx_,
+MHD_SHA256_update (void *ctx_,
const uint8_t *data,
size_t length)
{
@@ -372,7 +372,7 @@
static void
-sha256_write_digest (struct sha256_ctx *ctx,
+MHD_SHA256_write_digest (struct sha256_ctx *ctx,
size_t length,
uint8_t *digest)
{
@@ -395,13 +395,13 @@
}
void
-sha256_digest (void *ctx_,
+MHD_SHA256_digest (void *ctx_,
uint8_t *digest)
{
struct sha256_ctx *ctx = ctx_;
- sha256_write_digest (ctx,
+ MHD_SHA256_write_digest (ctx,
SHA256_DIGEST_SIZE,
digest);
- sha256_init (ctx);
+ MHD_SHA256_init (ctx);
}