libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 603ecd85bceb1ffa257e7ecdca8380c7996616ad
parent bf7c90c30f7c6c0227fb873bfb1f361f03e6b1f7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon,  3 Jun 2019 23:46:28 +0200

prefix even potentially exported hash symbols with MHD_ (as proposed by Dirk Brinkmeier)

Diffstat:
MChangeLog | 4++++
Msrc/examples/msgs_i18n.c | 0
Msrc/lib/md5.c | 16++++++++--------
Msrc/lib/md5.h | 12++++++------
Msrc/microhttpd/digestauth.c | 10+++++-----
Msrc/microhttpd/md5.c | 12++++++------
Msrc/microhttpd/md5.h | 10+++++-----
Msrc/microhttpd/sha256.c | 4++--
Msrc/microhttpd/sha256.h | 4++--
Msrc/microhttpd/test_md5.c | 28++++++++++++++--------------
Msrc/microhttpd/test_sha256.c | 20++++++++++----------
11 files changed, 62 insertions(+), 58 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Mon 03 Jun 2019 11:45:52 PM CEST + Apply MHD_-prefix to hash functions, even if they are not in the + officially exported API. -CG/DB + Sun May 26 23:05:42 MSK 2019 Better detection of sockaddr member in configure, fixed build on *BSD, Fixed compiler warnings, diff --git a/src/examples/msgs_i18n.c b/src/examples/msgs_i18n.c diff --git a/src/lib/md5.c b/src/lib/md5.c @@ -10,8 +10,8 @@ * with every copy. * * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which + * MD5Context structure, pass it to MHD_MD5Init, call MHD_MD5Update as + * needed on buffers full of bytes, and then call MHD_MD5Final, which * will fill a supplied 16-byte array with the digest. */ @@ -47,7 +47,7 @@ static uint8_t PADDING[MD5_BLOCK_SIZE] = { * initialization constants. */ void -MD5Init(struct MD5Context *ctx) +MHD_MD5Init(struct MD5Context *ctx) { if (!ctx) return; @@ -64,7 +64,7 @@ MD5Init(struct MD5Context *ctx) * of bytes. */ void -MD5Update(struct MD5Context *ctx, const unsigned char *input, size_t len) +MHD_MD5Update(struct MD5Context *ctx, const unsigned char *input, size_t len) { size_t have, need; @@ -124,15 +124,15 @@ MD5Pad(struct MD5Context *ctx) ((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); } /* * Final wrapup--call MD5Pad, fill in digest and zero out ctx. */ void -MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx) +MHD_MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx) { int i; @@ -161,7 +161,7 @@ MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks + * reflect the addition of 16 longwords of new data. MHD_MD5Update blocks * the data and converts bytes into longwords for this routine. */ void diff --git a/src/lib/md5.h b/src/lib/md5.h @@ -10,8 +10,8 @@ * with every copy. * * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which + * MD5Context structure, pass it to MHD_MD5Init, call MHD_MD5Update as + * needed on buffers full of bytes, and then call MHD_MD5Final, which * will fill a supplied 16-byte array with the digest. */ @@ -35,13 +35,13 @@ struct MD5Context * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ -void MD5Init(struct MD5Context *ctx); +void MHD_MD5Init(struct MD5Context *ctx); /* * Update context to reflect the concatenation of another buffer full * of bytes. */ -void MD5Update(struct MD5Context *ctx, const unsigned char *input, size_t len); +void MHD_MD5Update(struct MD5Context *ctx, const unsigned char *input, size_t len); /* * Pad pad to 64-byte boundary with the bit pattern @@ -52,11 +52,11 @@ void MD5Pad(struct MD5Context *ctx); /* * Final wrapup--call MD5Pad, fill in digest and zero out ctx. */ -void MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx); +void MHD_MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx); /* * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks + * reflect the addition of 16 longwords of new data. MHD_MD5Update blocks * the data and converts bytes into longwords for this routine. */ void MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE]); diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c @@ -1195,9 +1195,9 @@ MHD_digest_auth_check (struct MHD_Connection *connection, 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! */ \ @@ -1206,8 +1206,8 @@ MHD_digest_auth_check (struct MHD_Connection *connection, da.ctx = &ctx.sha256; \ da.alg = "sha-256"; \ da.sessionkey = skey.sha256; \ - da.init = &sha256_init; \ - da.update = &sha256_update; \ + da.init = &MHD_SHA256_init; \ + da.update = &MHD_SHA256_update; \ da.digest = &sha256_finish; \ break; \ } \ diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c @@ -10,8 +10,8 @@ * with every copy. * * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which + * MD5Context structure, pass it to MHD_MD5Init, call MHD_MD5Update as + * needed on buffers full of bytes, and then call MHD_MD5Final, which * will fill a supplied 16-byte array with the digest. */ @@ -34,7 +34,7 @@ * @param ctx must be a `struct MD5Context *` */ void -MD5Init (void *ctx_) +MHD_MD5Init (void *ctx_) { struct MD5Context *ctx = ctx_; @@ -57,7 +57,7 @@ MD5Transform (uint32_t state[4], * @param ctx must be a `struct MD5Context *` */ void -MD5Final (void *ctx_, +MHD_MD5Final (void *ctx_, uint8_t digest[MD5_DIGEST_SIZE]) { struct MD5Context *ctx = ctx_; @@ -119,7 +119,7 @@ MD5Final (void *ctx_, /** * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks + * reflect the addition of 16 longwords of new data. MHD_MD5Update blocks * the data and converts bytes into longwords for this routine. */ static void @@ -225,7 +225,7 @@ MD5Transform (uint32_t state[4], * of bytes. */ void -MD5Update (void *ctx_, +MHD_MD5Update (void *ctx_, const uint8_t *input, size_t len) { diff --git a/src/microhttpd/md5.h b/src/microhttpd/md5.h @@ -10,8 +10,8 @@ * with every copy. * * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which + * MD5Context structure, pass it to MHD_MD5Init, call MHD_MD5Update as + * needed on buffers full of bytes, and then call MHD_MD5Final, which * will fill a supplied 16-byte array with the digest. */ @@ -41,7 +41,7 @@ struct MD5Context * @param ctx_ must be a `struct MD5Context *` */ void -MD5Init (void *ctx_); +MHD_MD5Init (void *ctx_); /** @@ -51,7 +51,7 @@ MD5Init (void *ctx_); * @param ctx_ must be a `struct MD5Context *` */ void -MD5Update (void *ctx_, +MHD_MD5Update (void *ctx_, const uint8_t *input, size_t len); @@ -62,7 +62,7 @@ MD5Update (void *ctx_, * @param ctx_ must be a `struct MD5Context *` */ void -MD5Final (void *ctx_, +MHD_MD5Final (void *ctx_, uint8_t digest[MD5_DIGEST_SIZE]); diff --git a/src/microhttpd/sha256.c b/src/microhttpd/sha256.c @@ -42,7 +42,7 @@ * @param ctx_ must be a `struct sha256_ctx *` */ void -sha256_init (void *ctx_) +MHD_SHA256_init (void *ctx_) { struct sha256_ctx *const ctx = ctx_; /* Initial hash values, see FIPS PUB 180-4 paragraph 5.3.3 */ @@ -236,7 +236,7 @@ sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], * @param length number of bytes in @a data */ void -sha256_update (void *ctx_, +MHD_SHA256_update (void *ctx_, const uint8_t *data, size_t length) { diff --git a/src/microhttpd/sha256.h b/src/microhttpd/sha256.h @@ -64,7 +64,7 @@ struct sha256_ctx * @param ctx_ must be a `struct sha256_ctx *` */ void -sha256_init (void *ctx_); +MHD_SHA256_init (void *ctx_); /** @@ -75,7 +75,7 @@ sha256_init (void *ctx_); * @param length number of bytes in @a data */ void -sha256_update (void *ctx_, +MHD_SHA256_update (void *ctx_, const uint8_t *data, size_t length); diff --git a/src/microhttpd/test_md5.c b/src/microhttpd/test_md5.c @@ -228,9 +228,9 @@ int test1_str(void) struct MD5Context ctx; uint8_t digest[MD5_DIGEST_SIZE]; - MD5Init (&ctx); - MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str, data_units1[i].str_l.len); - MD5Final (&ctx, digest); + MHD_MD5Init (&ctx); + MHD_MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str, data_units1[i].str_l.len); + MHD_MD5Final (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units1[i].digest); } @@ -245,9 +245,9 @@ int test1_bin(void) struct MD5Context ctx; uint8_t digest[MD5_DIGEST_SIZE]; - MD5Init (&ctx); - MD5Update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); - MD5Final (&ctx, digest); + MHD_MD5Init (&ctx); + MHD_MD5Update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); + MHD_MD5Final (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units2[i].digest); } @@ -264,10 +264,10 @@ int test2_str(void) uint8_t digest[MD5_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; - MD5Init (&ctx); - MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str, part_s); - MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); - MD5Final (&ctx, digest); + MHD_MD5Init (&ctx); + MHD_MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str, part_s); + MHD_MD5Update (&ctx, (const uint8_t*)data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); + MHD_MD5Final (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units1[i].digest); } @@ -283,10 +283,10 @@ int test2_bin(void) uint8_t digest[MD5_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; - MD5Init (&ctx); - MD5Update (&ctx, data_units2[i].bin_l.bin, part_s); - MD5Update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); - MD5Final (&ctx, digest); + MHD_MD5Init (&ctx); + MHD_MD5Update (&ctx, data_units2[i].bin_l.bin, part_s); + MHD_MD5Update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); + MHD_MD5Final (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units2[i].digest); } diff --git a/src/microhttpd/test_sha256.c b/src/microhttpd/test_sha256.c @@ -253,8 +253,8 @@ int test1_str(void) struct sha256_ctx ctx; uint8_t digest[SHA256_DIGEST_SIZE]; - sha256_init (&ctx); - sha256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str, data_units1[i].str_l.len); + MHD_SHA256_init (&ctx); + MHD_SHA256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str, data_units1[i].str_l.len); sha256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units1[i].digest); @@ -270,8 +270,8 @@ int test1_bin(void) struct sha256_ctx ctx; uint8_t digest[SHA256_DIGEST_SIZE]; - sha256_init (&ctx); - sha256_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); + MHD_SHA256_init (&ctx); + MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); sha256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units2[i].digest); @@ -289,9 +289,9 @@ int test2_str(void) uint8_t digest[SHA256_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; - sha256_init (&ctx); - sha256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str, part_s); - sha256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); + MHD_SHA256_init (&ctx); + MHD_SHA256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str, part_s); + MHD_SHA256_update (&ctx, (const uint8_t*)data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); sha256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units1[i].digest); @@ -308,9 +308,9 @@ int test2_bin(void) uint8_t digest[SHA256_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; - sha256_init (&ctx); - sha256_update (&ctx, data_units2[i].bin_l.bin, part_s); - sha256_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); + MHD_SHA256_init (&ctx); + MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, part_s); + MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); sha256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units2[i].digest);