diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-05-18 20:05:06 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-05-18 20:05:06 +0300 |
commit | 7b3e010b6159017b65a1621478fc7b22e34df119 (patch) | |
tree | 2fd3d892a01cc484e19c422844fa9d47982582b5 | |
parent | f59775676f908fecdd71fe9a3190b47f77c36621 (diff) | |
download | libmicrohttpd-7b3e010b6159017b65a1621478fc7b22e34df119.tar.gz libmicrohttpd-7b3e010b6159017b65a1621478fc7b22e34df119.zip |
sha-1 minor improvements
-rw-r--r-- | src/microhttpd/sha1.c | 7 | ||||
-rw-r--r-- | 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 | |||
@@ -55,11 +55,6 @@ MHD_SHA1_init (void *ctx_) | |||
55 | 55 | ||
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Number of bytes in single SHA-1 word | ||
59 | */ | ||
60 | #define SHA1_BYTES_IN_WORD (32 / 8) | ||
61 | |||
62 | /** | ||
63 | * Base of SHA-1 transformation. | 58 | * Base of SHA-1 transformation. |
64 | * Gets full 512 bits / 64 bytes block of data and updates hash values; | 59 | * Gets full 512 bits / 64 bytes block of data and updates hash values; |
65 | * @param H hash values | 60 | * @param H hash values |
@@ -322,7 +317,7 @@ MHD_SHA1_finish (void *ctx_, | |||
322 | 317 | ||
323 | num_bits = ctx->count << 3; | 318 | num_bits = ctx->count << 3; |
324 | /* Note: (count & (SHA1_BLOCK_SIZE-1)) | 319 | /* Note: (count & (SHA1_BLOCK_SIZE-1)) |
325 | equal (count % SHA1_BLOCK_SIZE) for this block size. */ | 320 | equals (count % SHA1_BLOCK_SIZE) for this block size. */ |
326 | bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1)); | 321 | bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1)); |
327 | 322 | ||
328 | /* Input data must be padded with bit "1" and with length of data in bits. | 323 | /* 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,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include "mhd_options.h" | 29 | #include "mhd_options.h" |
30 | #include <stdint.h> | 30 | #include <stdint.h> |
31 | #include <stddef.h> | 31 | #include <stddef.h> /* for size_t */ |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * SHA-1 digest is kept internally as 5 32-bit words. | 34 | * SHA-1 digest is kept internally as 5 32-bit words. |
@@ -36,9 +36,19 @@ | |||
36 | #define _SHA1_DIGEST_LENGTH 5 | 36 | #define _SHA1_DIGEST_LENGTH 5 |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Number of bytes in single SHA-1 word | ||
40 | */ | ||
41 | #define SHA1_WORD_SIZE_BITS 32 | ||
42 | |||
43 | /** | ||
44 | * Number of bytes in single SHA-1 word | ||
45 | */ | ||
46 | #define SHA1_BYTES_IN_WORD (SHA1_WORD_SIZE_BITS / 8) | ||
47 | |||
48 | /** | ||
39 | * Size of SHA-1 digest in bytes | 49 | * Size of SHA-1 digest in bytes |
40 | */ | 50 | */ |
41 | #define SHA1_DIGEST_SIZE (_SHA1_DIGEST_LENGTH * 4) | 51 | #define SHA1_DIGEST_SIZE (_SHA1_DIGEST_LENGTH * SHA1_BYTES_IN_WORD) |
42 | 52 | ||
43 | /** | 53 | /** |
44 | * Size of SHA-1 digest string in chars including termination NUL | 54 | * Size of SHA-1 digest string in chars including termination NUL |