aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/md5.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/md5.c')
-rw-r--r--src/microhttpd/md5.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c
index a9e52935..867e0d3f 100644
--- a/src/microhttpd/md5.c
+++ b/src/microhttpd/md5.c
@@ -71,21 +71,23 @@ MD5Init (void *ctx_)
71static void 71static void
72MD5Pad (struct MD5Context *ctx) 72MD5Pad (struct MD5Context *ctx)
73{ 73{
74 uint8_t count[8]; 74 uint8_t count_le[8];
75 size_t padlen; 75 size_t padlen;
76 uint64_t count_bits;
76 77
77 mhd_assert (ctx != NULL); 78 mhd_assert (ctx != NULL);
78 79
79 /* Convert count to 8 bytes in little endian order. */ 80 /* Convert count to 8 bytes in little endian order. */
80 PUT_64BIT_LE(count, ctx->count); 81 count_bits = ctx->count << 3;
82 PUT_64BIT_LE(count_le, count_bits);
81 83
82 /* Pad out to 56 mod 64. */ 84 /* Pad out to 56 mod 64. */
83 padlen = MD5_BLOCK_SIZE - 85 padlen = MD5_BLOCK_SIZE -
84 ((ctx->count >> 3) & (MD5_BLOCK_SIZE - 1)); 86 ((ctx->count) & (MD5_BLOCK_SIZE - 1));
85 if (padlen < 1 + 8) 87 if (padlen < 1 + 8)
86 padlen += MD5_BLOCK_SIZE; 88 padlen += MD5_BLOCK_SIZE;
87 MD5Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */ 89 MD5Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */
88 MD5Update(ctx, count, 8); 90 MD5Update(ctx, count_le, 8);
89} 91}
90 92
91 93
@@ -244,11 +246,11 @@ MD5Update (void *ctx_,
244 mhd_assert ((ctx != NULL) || (len == 0)); 246 mhd_assert ((ctx != NULL) || (len == 0));
245 247
246 /* Check how many bytes we already have and how many more we need. */ 248 /* Check how many bytes we already have and how many more we need. */
247 have = (size_t)((ctx->count >> 3) & (MD5_BLOCK_SIZE - 1)); 249 have = (size_t)((ctx->count) & (MD5_BLOCK_SIZE - 1));
248 need = MD5_BLOCK_SIZE - have; 250 need = MD5_BLOCK_SIZE - have;
249 251
250 /* Update bitcount */ 252 /* Update bytecount */
251 ctx->count += (uint64_t)len << 3; 253 ctx->count += (uint64_t)len;
252 254
253 if (len >= need) 255 if (len >= need)
254 { 256 {