gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 04/06: MD5: count bytes, not bits MHD do no


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 04/06: MD5: count bytes, not bits MHD do not add bites, no need to count more precise than bytes
Date: Tue, 16 Apr 2019 09:59:49 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 7887edc2b44c840bf2cbe60cb1bf02eceab80dd3
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Mon Apr 15 22:53:29 2019 +0300

    MD5: count bytes, not bits
    MHD do not add bites, no need to count more precise than bytes
---
 src/microhttpd/md5.c | 16 +++++++++-------
 src/microhttpd/md5.h |  2 +-
 2 files changed, 10 insertions(+), 8 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_)
 static void
 MD5Pad (struct MD5Context *ctx)
 {
-  uint8_t count[8];
+  uint8_t count_le[8];
   size_t padlen;
+  uint64_t count_bits;
 
   mhd_assert (ctx != NULL);
 
   /* Convert count to 8 bytes in little endian order. */
-  PUT_64BIT_LE(count, ctx->count);
+  count_bits = ctx->count << 3;
+  PUT_64BIT_LE(count_le, count_bits);
 
   /* Pad out to 56 mod 64. */
   padlen = MD5_BLOCK_SIZE -
-    ((ctx->count >> 3) & (MD5_BLOCK_SIZE - 1));
+    ((ctx->count) & (MD5_BLOCK_SIZE - 1));
   if (padlen < 1 + 8)
     padlen += MD5_BLOCK_SIZE;
   MD5Update(ctx, PADDING, padlen - 8);         /* padlen - 8 <= 64 */
-  MD5Update(ctx, count, 8);
+  MD5Update(ctx, count_le, 8);
 }
 
 
@@ -244,11 +246,11 @@ MD5Update (void *ctx_,
   mhd_assert ((ctx != NULL) || (len == 0));
 
   /* Check how many bytes we already have and how many more we need. */
-  have = (size_t)((ctx->count >> 3) & (MD5_BLOCK_SIZE - 1));
+  have = (size_t)((ctx->count) & (MD5_BLOCK_SIZE - 1));
   need = MD5_BLOCK_SIZE - have;
 
-  /* Update bitcount */
-  ctx->count += (uint64_t)len << 3;
+  /* Update bytecount */
+  ctx->count += (uint64_t)len;
 
   if (len >= need)
   {
diff --git a/src/microhttpd/md5.h b/src/microhttpd/md5.h
index 655b9f72..819d515d 100644
--- a/src/microhttpd/md5.h
+++ b/src/microhttpd/md5.h
@@ -27,7 +27,7 @@
 struct MD5Context
 {
   uint32_t state[4];                   /* state */
-  uint64_t count;                      /* number of bits, mod 2^64 */
+  uint64_t count;                      /* number of bytes, mod 2^64 */
   uint8_t buffer[MD5_BLOCK_SIZE];      /* input buffer */
 };
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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