diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-05-16 18:11:32 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-05-16 18:21:27 +0300 |
commit | b25cc0f30166152a56b0035241807e8f4d6f74e1 (patch) | |
tree | 117b6d4bb3ca9cabd00d98c6b33a44daa8995eeb | |
parent | ab7c8f4efc0c6f0c259e6b9303637969d2435f4b (diff) | |
download | libmicrohttpd-b25cc0f30166152a56b0035241807e8f4d6f74e1.tar.gz libmicrohttpd-b25cc0f30166152a56b0035241807e8f4d6f74e1.zip |
sha256: formatting, cosmetics, typos in comments
-rw-r--r-- | src/microhttpd/mhd_bithelpers.h | 26 | ||||
-rw-r--r-- | src/microhttpd/sha256.c | 90 | ||||
-rw-r--r-- | src/microhttpd/sha256.h | 2 | ||||
-rw-r--r-- | src/microhttpd/test_sha256.c | 2 |
4 files changed, 59 insertions, 61 deletions
diff --git a/src/microhttpd/mhd_bithelpers.h b/src/microhttpd/mhd_bithelpers.h index 5d1aadef..ea7682aa 100644 --- a/src/microhttpd/mhd_bithelpers.h +++ b/src/microhttpd/mhd_bithelpers.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | Copyright (C) 2019 Karlson2k (Evgeny Grin) | 3 | Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
@@ -56,8 +56,8 @@ | |||
56 | #define _MHD_BYTES_SWAP32(value32) \ | 56 | #define _MHD_BYTES_SWAP32(value32) \ |
57 | ((uint32_t) __builtin_bswap32 ((uint32_t) value32)) | 57 | ((uint32_t) __builtin_bswap32 ((uint32_t) value32)) |
58 | #else /* ! __has_builtin(__builtin_bswap32) */ | 58 | #else /* ! __has_builtin(__builtin_bswap32) */ |
59 | #define _MHD_BYTES_SWAP32(value32) \ | 59 | #define _MHD_BYTES_SWAP32(value32) \ |
60 | ( (((uint32_t) (value32)) << 24) \ | 60 | ( (((uint32_t) (value32)) << 24) \ |
61 | | ((((uint32_t) (value32)) & ((uint32_t) 0x0000FF00)) << 8) \ | 61 | | ((((uint32_t) (value32)) & ((uint32_t) 0x0000FF00)) << 8) \ |
62 | | ((((uint32_t) (value32)) & ((uint32_t) 0x00FF0000)) >> 8) \ | 62 | | ((((uint32_t) (value32)) & ((uint32_t) 0x00FF0000)) >> 8) \ |
63 | | (((uint32_t) (value32)) >> 24) ) | 63 | | (((uint32_t) (value32)) >> 24) ) |
@@ -78,8 +78,8 @@ | |||
78 | #define _MHD_BYTES_SWAP64(value64) \ | 78 | #define _MHD_BYTES_SWAP64(value64) \ |
79 | ((uint64_t) __builtin_bswap64 ((uint64_t) value64)) | 79 | ((uint64_t) __builtin_bswap64 ((uint64_t) value64)) |
80 | #else /* ! __has_builtin(__builtin_bswap64) */ | 80 | #else /* ! __has_builtin(__builtin_bswap64) */ |
81 | #define _MHD_BYTES_SWAP64(value64) \ | 81 | #define _MHD_BYTES_SWAP64(value64) \ |
82 | ( (((uint64_t) (value64)) << 56) \ | 82 | ( (((uint64_t) (value64)) << 56) \ |
83 | | ((((uint64_t) (value64)) & ((uint64_t) 0x000000000000FF00)) << 40) \ | 83 | | ((((uint64_t) (value64)) & ((uint64_t) 0x000000000000FF00)) << 40) \ |
84 | | ((((uint64_t) (value64)) & ((uint64_t) 0x0000000000FF0000)) << 24) \ | 84 | | ((((uint64_t) (value64)) & ((uint64_t) 0x0000000000FF0000)) << 24) \ |
85 | | ((((uint64_t) (value64)) & ((uint64_t) 0x00000000FF000000)) << 8) \ | 85 | | ((((uint64_t) (value64)) & ((uint64_t) 0x00000000FF000000)) << 8) \ |
@@ -102,7 +102,7 @@ | |||
102 | ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) | 102 | ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) |
103 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 103 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
104 | /* Endianness was not detected or non-standard like PDP-endian */ | 104 | /* Endianness was not detected or non-standard like PDP-endian */ |
105 | #define _MHD_PUT_64BIT_LE(addr, value64) do { \ | 105 | #define _MHD_PUT_64BIT_LE(addr, value64) do { \ |
106 | ((uint8_t*) (addr))[0] = (uint8_t) ((uint64_t) (value64)); \ | 106 | ((uint8_t*) (addr))[0] = (uint8_t) ((uint64_t) (value64)); \ |
107 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 8); \ | 107 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 8); \ |
108 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 16); \ | 108 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 16); \ |
@@ -126,7 +126,7 @@ | |||
126 | ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) | 126 | ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) |
127 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 127 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
128 | /* Endianness was not detected or non-standard like PDP-endian */ | 128 | /* Endianness was not detected or non-standard like PDP-endian */ |
129 | #define _MHD_PUT_32BIT_LE(addr, value32) do { \ | 129 | #define _MHD_PUT_32BIT_LE(addr, value32) do { \ |
130 | ((uint8_t*) (addr))[0] = (uint8_t) ((uint32_t) (value32)); \ | 130 | ((uint8_t*) (addr))[0] = (uint8_t) ((uint32_t) (value32)); \ |
131 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 8); \ | 131 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 8); \ |
132 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 16); \ | 132 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 16); \ |
@@ -146,8 +146,8 @@ | |||
146 | _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) | 146 | _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) |
147 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 147 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
148 | /* Endianness was not detected or non-standard like PDP-endian */ | 148 | /* Endianness was not detected or non-standard like PDP-endian */ |
149 | #define _MHD_GET_32BIT_LE(addr) \ | 149 | #define _MHD_GET_32BIT_LE(addr) \ |
150 | ( ( (uint32_t) (((const uint8_t*) addr)[0])) \ | 150 | ( ( (uint32_t) (((const uint8_t*) addr)[0])) \ |
151 | | (((uint32_t) (((const uint8_t*) addr)[1])) << 8) \ | 151 | | (((uint32_t) (((const uint8_t*) addr)[1])) << 8) \ |
152 | | (((uint32_t) (((const uint8_t*) addr)[2])) << 16) \ | 152 | | (((uint32_t) (((const uint8_t*) addr)[2])) << 16) \ |
153 | | (((uint32_t) (((const uint8_t*) addr)[3])) << 24) ) | 153 | | (((uint32_t) (((const uint8_t*) addr)[3])) << 24) ) |
@@ -166,7 +166,7 @@ | |||
166 | ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) | 166 | ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) |
167 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 167 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
168 | /* Endianness was not detected or non-standard like PDP-endian */ | 168 | /* Endianness was not detected or non-standard like PDP-endian */ |
169 | #define _MHD_PUT_64BIT_BE(addr, value64) do { \ | 169 | #define _MHD_PUT_64BIT_BE(addr, value64) do { \ |
170 | ((uint8_t*) (addr))[7] = (uint8_t) ((uint64_t) (value64)); \ | 170 | ((uint8_t*) (addr))[7] = (uint8_t) ((uint64_t) (value64)); \ |
171 | ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 8); \ | 171 | ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 8); \ |
172 | ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 16); \ | 172 | ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 16); \ |
@@ -190,7 +190,7 @@ | |||
190 | ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) | 190 | ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) |
191 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 191 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
192 | /* Endianness was not detected or non-standard like PDP-endian */ | 192 | /* Endianness was not detected or non-standard like PDP-endian */ |
193 | #define _MHD_PUT_32BIT_BE(addr, value32) do { \ | 193 | #define _MHD_PUT_32BIT_BE(addr, value32) do { \ |
194 | ((uint8_t*) (addr))[3] = (uint8_t) ((uint32_t) (value32)); \ | 194 | ((uint8_t*) (addr))[3] = (uint8_t) ((uint32_t) (value32)); \ |
195 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 8); \ | 195 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 8); \ |
196 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 16); \ | 196 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 16); \ |
@@ -210,8 +210,8 @@ | |||
210 | _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) | 210 | _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) |
211 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 211 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
212 | /* Endianness was not detected or non-standard like PDP-endian */ | 212 | /* Endianness was not detected or non-standard like PDP-endian */ |
213 | #define _MHD_GET_32BIT_BE(addr) \ | 213 | #define _MHD_GET_32BIT_BE(addr) \ |
214 | ( (((uint32_t) (((const uint8_t*) addr)[0])) << 24) \ | 214 | ( (((uint32_t) (((const uint8_t*) addr)[0])) << 24) \ |
215 | | (((uint32_t) (((const uint8_t*) addr)[1])) << 16) \ | 215 | | (((uint32_t) (((const uint8_t*) addr)[1])) << 16) \ |
216 | | (((uint32_t) (((const uint8_t*) addr)[2])) << 8) \ | 216 | | (((uint32_t) (((const uint8_t*) addr)[2])) << 8) \ |
217 | | ((uint32_t) (((const uint8_t*) addr)[3])) ) | 217 | | ((uint32_t) (((const uint8_t*) addr)[3])) ) |
diff --git a/src/microhttpd/sha256.c b/src/microhttpd/sha256.c index 6c79c941..80c41eb5 100644 --- a/src/microhttpd/sha256.c +++ b/src/microhttpd/sha256.c | |||
@@ -1,8 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | Copyright (C) 2019 Karlson2k (Evgeny Grin) | 3 | Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) |
4 | Some ideas are based on Libgcrypt implementation. | ||
5 | Copyright (C) 2003, 2006, 2008, 2009 Free Software Foundation, Inc. | ||
6 | 4 | ||
7 | libmicrohttpd is free software; you can redistribute it and/or | 5 | libmicrohttpd is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
@@ -25,8 +23,6 @@ | |||
25 | * @author Karlson2k (Evgeny Grin) | 23 | * @author Karlson2k (Evgeny Grin) |
26 | */ | 24 | */ |
27 | 25 | ||
28 | /* Some tricks are based on Libgcrypt implementation. */ | ||
29 | |||
30 | #include "sha256.h" | 26 | #include "sha256.h" |
31 | 27 | ||
32 | #include <string.h> | 28 | #include <string.h> |
@@ -100,17 +96,19 @@ sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], | |||
100 | #define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) | 96 | #define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) |
101 | #define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) | 97 | #define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) |
102 | /* Unoptimized (original) versions: */ | 98 | /* Unoptimized (original) versions: */ |
103 | /* #define Ch(x,y,z) ( ( (x) & (y) ) | ( ~(x) & (z) ) ) */ | 99 | /* #define Ch(x,y,z) ( ( (x) & (y) ) ^ ( ~(x) & (z) ) ) */ |
104 | /* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */ | 100 | /* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */ |
105 | 101 | ||
106 | /* Four 'Sigma' macro functions. | 102 | /* Four 'Sigma' macro functions. |
107 | See FIPS PUB 180-4 formulae 4.4, 4.5, 4.6, 4.7. */ | 103 | See FIPS PUB 180-4 formulae 4.4, 4.5, 4.6, 4.7. */ |
108 | #define SIG0(x) (_MHD_ROTR32 ((x),2) ^ _MHD_ROTR32 ((x),13) ^ _MHD_ROTR32 ((x), \ | 104 | #define SIG0(x) (_MHD_ROTR32 ((x), 2) ^ _MHD_ROTR32 ((x), 13) ^ \ |
109 | 22) ) | 105 | _MHD_ROTR32 ((x), 22) ) |
110 | #define SIG1(x) (_MHD_ROTR32 ((x),6) ^ _MHD_ROTR32 ((x),11) ^ _MHD_ROTR32 ((x), \ | 106 | #define SIG1(x) (_MHD_ROTR32 ((x), 6) ^ _MHD_ROTR32 ((x), 11) ^ \ |
111 | 25) ) | 107 | _MHD_ROTR32 ((x), 25) ) |
112 | #define sig0(x) (_MHD_ROTR32 ((x),7) ^ _MHD_ROTR32 ((x),18) ^ ((x) >> 3) ) | 108 | #define sig0(x) (_MHD_ROTR32 ((x), 7) ^ _MHD_ROTR32 ((x), 18) ^ \ |
113 | #define sig1(x) (_MHD_ROTR32 ((x),17) ^ _MHD_ROTR32 ((x),19) ^ ((x) >> 10) ) | 109 | ((x) >> 3) ) |
110 | #define sig1(x) (_MHD_ROTR32 ((x), 17) ^ _MHD_ROTR32 ((x),19) ^ \ | ||
111 | ((x) >> 10) ) | ||
114 | 112 | ||
115 | /* Single step of SHA-256 computation, | 113 | /* Single step of SHA-256 computation, |
116 | see FIPS PUB 180-4 paragraph 6.2.2 step 3. | 114 | see FIPS PUB 180-4 paragraph 6.2.2 step 3. |
@@ -124,7 +122,7 @@ sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], | |||
124 | second (vH += SIG0(vA) + Maj(vE,vF,vC) equals T1 + T2 in FIPS PUB 180-4 paragraph 6.2.2 step 3. | 122 | second (vH += SIG0(vA) + Maj(vE,vF,vC) equals T1 + T2 in FIPS PUB 180-4 paragraph 6.2.2 step 3. |
125 | * Note: 'wt' must be used exactly one time in this macro as it change other data as well | 123 | * Note: 'wt' must be used exactly one time in this macro as it change other data as well |
126 | every time when used. */ | 124 | every time when used. */ |
127 | #define SHA2STEP32(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ | 125 | #define SHA2STEP32(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ |
128 | (vD) += ((vH) += SIG1 ((vE)) + Ch ((vE),(vF),(vG)) + (kt) + (wt)); \ | 126 | (vD) += ((vH) += SIG1 ((vE)) + Ch ((vE),(vF),(vG)) + (kt) + (wt)); \ |
129 | (vH) += SIG0 ((vA)) + Maj ((vA),(vB),(vC)); } while (0) | 127 | (vH) += SIG0 ((vA)) + Maj ((vA),(vB),(vC)); } while (0) |
130 | 128 | ||
@@ -140,38 +138,38 @@ sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], | |||
140 | stored in array of W elements. */ | 138 | stored in array of W elements. */ |
141 | /* Note: instead of using K constants as array, all K values are specified | 139 | /* Note: instead of using K constants as array, all K values are specified |
142 | individually for each step, see FIPS PUB 180-4 paragraph 4.2.2 for K values. */ | 140 | individually for each step, see FIPS PUB 180-4 paragraph 4.2.2 for K values. */ |
143 | SHA2STEP32 (a, b, c, d, e, f, g, h, 0x428a2f98UL, W[0] = GET_W_FROM_DATA ( | 141 | SHA2STEP32 (a, b, c, d, e, f, g, h, 0x428a2f98UL, W[0] = \ |
144 | data,0)); | 142 | GET_W_FROM_DATA (data, 0)); |
145 | SHA2STEP32 (h, a, b, c, d, e, f, g, 0x71374491UL, W[1] = GET_W_FROM_DATA ( | 143 | SHA2STEP32 (h, a, b, c, d, e, f, g, 0x71374491UL, W[1] = \ |
146 | data,1)); | 144 | GET_W_FROM_DATA (data, 1)); |
147 | SHA2STEP32 (g, h, a, b, c, d, e, f, 0xb5c0fbcfUL, W[2] = GET_W_FROM_DATA ( | 145 | SHA2STEP32 (g, h, a, b, c, d, e, f, 0xb5c0fbcfUL, W[2] = \ |
148 | data,2)); | 146 | GET_W_FROM_DATA (data, 2)); |
149 | SHA2STEP32 (f, g, h, a, b, c, d, e, 0xe9b5dba5UL, W[3] = GET_W_FROM_DATA ( | 147 | SHA2STEP32 (f, g, h, a, b, c, d, e, 0xe9b5dba5UL, W[3] = \ |
150 | data,3)); | 148 | GET_W_FROM_DATA (data, 3)); |
151 | SHA2STEP32 (e, f, g, h, a, b, c, d, 0x3956c25bUL, W[4] = GET_W_FROM_DATA ( | 149 | SHA2STEP32 (e, f, g, h, a, b, c, d, 0x3956c25bUL, W[4] = \ |
152 | data,4)); | 150 | GET_W_FROM_DATA (data, 4)); |
153 | SHA2STEP32 (d, e, f, g, h, a, b, c, 0x59f111f1UL, W[5] = GET_W_FROM_DATA ( | 151 | SHA2STEP32 (d, e, f, g, h, a, b, c, 0x59f111f1UL, W[5] = \ |
154 | data,5)); | 152 | GET_W_FROM_DATA (data, 5)); |
155 | SHA2STEP32 (c, d, e, f, g, h, a, b, 0x923f82a4UL, W[6] = GET_W_FROM_DATA ( | 153 | SHA2STEP32 (c, d, e, f, g, h, a, b, 0x923f82a4UL, W[6] = \ |
156 | data,6)); | 154 | GET_W_FROM_DATA (data, 6)); |
157 | SHA2STEP32 (b, c, d, e, f, g, h, a, 0xab1c5ed5UL, W[7] = GET_W_FROM_DATA ( | 155 | SHA2STEP32 (b, c, d, e, f, g, h, a, 0xab1c5ed5UL, W[7] = \ |
158 | data,7)); | 156 | GET_W_FROM_DATA (data, 7)); |
159 | SHA2STEP32 (a, b, c, d, e, f, g, h, 0xd807aa98UL, W[8] = GET_W_FROM_DATA ( | 157 | SHA2STEP32 (a, b, c, d, e, f, g, h, 0xd807aa98UL, W[8] = \ |
160 | data,8)); | 158 | GET_W_FROM_DATA (data, 8)); |
161 | SHA2STEP32 (h, a, b, c, d, e, f, g, 0x12835b01UL, W[9] = GET_W_FROM_DATA ( | 159 | SHA2STEP32 (h, a, b, c, d, e, f, g, 0x12835b01UL, W[9] = \ |
162 | data,9)); | 160 | GET_W_FROM_DATA (data, 9)); |
163 | SHA2STEP32 (g, h, a, b, c, d, e, f, 0x243185beUL, W[10] = GET_W_FROM_DATA ( | 161 | SHA2STEP32 (g, h, a, b, c, d, e, f, 0x243185beUL, W[10] = \ |
164 | data,10)); | 162 | GET_W_FROM_DATA (data, 10)); |
165 | SHA2STEP32 (f, g, h, a, b, c, d, e, 0x550c7dc3UL, W[11] = GET_W_FROM_DATA ( | 163 | SHA2STEP32 (f, g, h, a, b, c, d, e, 0x550c7dc3UL, W[11] = \ |
166 | data,11)); | 164 | GET_W_FROM_DATA (data, 11)); |
167 | SHA2STEP32 (e, f, g, h, a, b, c, d, 0x72be5d74UL, W[12] = GET_W_FROM_DATA ( | 165 | SHA2STEP32 (e, f, g, h, a, b, c, d, 0x72be5d74UL, W[12] = \ |
168 | data,12)); | 166 | GET_W_FROM_DATA (data, 12)); |
169 | SHA2STEP32 (d, e, f, g, h, a, b, c, 0x80deb1feUL, W[13] = GET_W_FROM_DATA ( | 167 | SHA2STEP32 (d, e, f, g, h, a, b, c, 0x80deb1feUL, W[13] = \ |
170 | data,13)); | 168 | GET_W_FROM_DATA (data, 13)); |
171 | SHA2STEP32 (c, d, e, f, g, h, a, b, 0x9bdc06a7UL, W[14] = GET_W_FROM_DATA ( | 169 | SHA2STEP32 (c, d, e, f, g, h, a, b, 0x9bdc06a7UL, W[14] = \ |
172 | data,14)); | 170 | GET_W_FROM_DATA (data, 14)); |
173 | SHA2STEP32 (b, c, d, e, f, g, h, a, 0xc19bf174UL, W[15] = GET_W_FROM_DATA ( | 171 | SHA2STEP32 (b, c, d, e, f, g, h, a, 0xc19bf174UL, W[15] = \ |
174 | data,15)); | 172 | GET_W_FROM_DATA (data, 15)); |
175 | 173 | ||
176 | /* 'W' generation and assignment for 16 <= t <= 63. | 174 | /* 'W' generation and assignment for 16 <= t <= 63. |
177 | See FIPS PUB 180-4 paragraph 6.2.2. | 175 | See FIPS PUB 180-4 paragraph 6.2.2. |
@@ -236,7 +234,7 @@ sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], | |||
236 | SHA2STEP32 (b, c, d, e, f, g, h, a, 0xc67178f2UL, W[63 & 0xf] = Wgen (W,63)); | 234 | SHA2STEP32 (b, c, d, e, f, g, h, a, 0xc67178f2UL, W[63 & 0xf] = Wgen (W,63)); |
237 | 235 | ||
238 | /* Compute intermediate hash. | 236 | /* Compute intermediate hash. |
239 | See FIPS PUB 180-4 paragraph 4.2.2 step 4. */ | 237 | See FIPS PUB 180-4 paragraph 6.2.2 step 4. */ |
240 | H[0] += a; | 238 | H[0] += a; |
241 | H[1] += b; | 239 | H[1] += b; |
242 | H[2] += c; | 240 | H[2] += c; |
diff --git a/src/microhttpd/sha256.h b/src/microhttpd/sha256.h index 8a158567..88a558fc 100644 --- a/src/microhttpd/sha256.h +++ b/src/microhttpd/sha256.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | Copyright (C) 2019 Karlson2k (Evgeny Grin) | 3 | Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
diff --git a/src/microhttpd/test_sha256.c b/src/microhttpd/test_sha256.c index b6904e49..863859fa 100644 --- a/src/microhttpd/test_sha256.c +++ b/src/microhttpd/test_sha256.c | |||
@@ -310,7 +310,7 @@ check_result (const char *test_name, | |||
310 | char calc_str[SHA256_DIGEST_STRING_SIZE]; | 310 | char calc_str[SHA256_DIGEST_STRING_SIZE]; |
311 | bin2hex (calculated, SHA256_DIGEST_SIZE, calc_str); | 311 | bin2hex (calculated, SHA256_DIGEST_SIZE, calc_str); |
312 | printf ( | 312 | printf ( |
313 | "PASSED: %s check %u: calculated digest %s match expected digest.\n", | 313 | "PASSED: %s check %u: calculated digest %s matches expected digest.\n", |
314 | test_name, check_num, calc_str); | 314 | test_name, check_num, calc_str); |
315 | fflush (stdout); | 315 | fflush (stdout); |
316 | } | 316 | } |