[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 03/03: sha-1 minor improvements
From: |
gnunet |
Subject: |
[libmicrohttpd] 03/03: sha-1 minor improvements |
Date: |
Tue, 18 May 2021 19:27:31 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 7b3e010b6159017b65a1621478fc7b22e34df119
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue May 18 20:05:06 2021 +0300
sha-1 minor improvements
---
src/microhttpd/sha1.c | 7 +------
src/microhttpd/sha1.h | 14 ++++++++++++--
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/microhttpd/sha1.c b/src/microhttpd/sha1.c
index 0d5fef72..2ed84208 100644
--- a/src/microhttpd/sha1.c
+++ b/src/microhttpd/sha1.c
@@ -54,11 +54,6 @@ MHD_SHA1_init (void *ctx_)
}
-/**
- * Number of bytes in single SHA-1 word
- */
-#define SHA1_BYTES_IN_WORD (32 / 8)
-
/**
* Base of SHA-1 transformation.
* Gets full 512 bits / 64 bytes block of data and updates hash values;
@@ -322,7 +317,7 @@ MHD_SHA1_finish (void *ctx_,
num_bits = ctx->count << 3;
/* Note: (count & (SHA1_BLOCK_SIZE-1))
- equal (count % SHA1_BLOCK_SIZE) for this block size. */
+ equals (count % SHA1_BLOCK_SIZE) for this block size. */
bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1));
/* Input data must be padded with bit "1" and with length of data in bits.
diff --git a/src/microhttpd/sha1.h b/src/microhttpd/sha1.h
index 800a4909..59f00217 100644
--- a/src/microhttpd/sha1.h
+++ b/src/microhttpd/sha1.h
@@ -28,17 +28,27 @@
#include "mhd_options.h"
#include <stdint.h>
-#include <stddef.h>
+#include <stddef.h> /* for size_t */
/**
* SHA-1 digest is kept internally as 5 32-bit words.
*/
#define _SHA1_DIGEST_LENGTH 5
+/**
+ * Number of bytes in single SHA-1 word
+ */
+#define SHA1_WORD_SIZE_BITS 32
+
+/**
+ * Number of bytes in single SHA-1 word
+ */
+#define SHA1_BYTES_IN_WORD (SHA1_WORD_SIZE_BITS / 8)
+
/**
* Size of SHA-1 digest in bytes
*/
-#define SHA1_DIGEST_SIZE (_SHA1_DIGEST_LENGTH * 4)
+#define SHA1_DIGEST_SIZE (_SHA1_DIGEST_LENGTH * SHA1_BYTES_IN_WORD)
/**
* Size of SHA-1 digest string in chars including termination NUL
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.