GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
sha256.c
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2019-2021 Karlson2k (Evgeny Grin)
4
5 libmicrohttpd is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library.
17 If not, see <http://www.gnu.org/licenses/>.
18*/
19
26#include "sha256.h"
27
28#include <string.h>
29#ifdef HAVE_MEMORY_H
30#include <memory.h>
31#endif /* HAVE_MEMORY_H */
32#include "mhd_bithelpers.h"
33#include "mhd_assert.h"
34
40void
41MHD_SHA256_init (void *ctx_)
42{
43 struct sha256_ctx *const ctx = ctx_;
44 /* Initial hash values, see FIPS PUB 180-4 paragraph 5.3.3 */
45 /* First thirty-two bits of the fractional parts of the square
46 * roots of the first eight prime numbers: 2, 3, 5, 7, 11, 13,
47 * 17, 19." */
48 ctx->H[0] = UINT32_C (0x6a09e667);
49 ctx->H[1] = UINT32_C (0xbb67ae85);
50 ctx->H[2] = UINT32_C (0x3c6ef372);
51 ctx->H[3] = UINT32_C (0xa54ff53a);
52 ctx->H[4] = UINT32_C (0x510e527f);
53 ctx->H[5] = UINT32_C (0x9b05688c);
54 ctx->H[6] = UINT32_C (0x1f83d9ab);
55 ctx->H[7] = UINT32_C (0x5be0cd19);
56
57 /* Initialise number of bytes. */
58 ctx->count = 0;
59}
60
61
68static void
70 const uint8_t data[SHA256_BLOCK_SIZE])
71{
72 /* Working variables,
73 see FIPS PUB 180-4 paragraph 6.2. */
74 uint32_t a = H[0];
75 uint32_t b = H[1];
76 uint32_t c = H[2];
77 uint32_t d = H[3];
78 uint32_t e = H[4];
79 uint32_t f = H[5];
80 uint32_t g = H[6];
81 uint32_t h = H[7];
82
83 /* Data buffer, used as cyclic buffer.
84 See FIPS PUB 180-4 paragraphs 5.2.1, 6.2. */
85 uint32_t W[16];
86
87 /* 'Ch' and 'Maj' macro functions are defined with
88 widely-used optimization.
89 See FIPS PUB 180-4 formulae 4.2, 4.3. */
90#define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) )
91#define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) )
92 /* Unoptimized (original) versions: */
93/* #define Ch(x,y,z) ( ( (x) & (y) ) ^ ( ~(x) & (z) ) ) */
94/* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */
95
96 /* Four 'Sigma' macro functions.
97 See FIPS PUB 180-4 formulae 4.4, 4.5, 4.6, 4.7. */
98#define SIG0(x) (_MHD_ROTR32 ((x), 2) ^ _MHD_ROTR32 ((x), 13) ^ \
99 _MHD_ROTR32 ((x), 22) )
100#define SIG1(x) (_MHD_ROTR32 ((x), 6) ^ _MHD_ROTR32 ((x), 11) ^ \
101 _MHD_ROTR32 ((x), 25) )
102#define sig0(x) (_MHD_ROTR32 ((x), 7) ^ _MHD_ROTR32 ((x), 18) ^ \
103 ((x) >> 3) )
104#define sig1(x) (_MHD_ROTR32 ((x), 17) ^ _MHD_ROTR32 ((x),19) ^ \
105 ((x) >> 10) )
106
107 /* Single step of SHA-256 computation,
108 see FIPS PUB 180-4 paragraph 6.2.2 step 3.
109 * Note: instead of reassigning all working variables on each step,
110 variables are rotated for each step:
111 SHA2STEP32(a, b, c, d, e, f, g, h, K[0], data[0]);
112 SHA2STEP32(h, a, b, c, d, e, f, g, K[1], data[1]);
113 so current 'vD' will be used as 'vE' on next step,
114 current 'vH' will be used as 'vA' on next step.
115 * Note: first (vH += SIG1(vE) + Ch(vE,vF,vG) + kt + wt) equals T1 in FIPS PUB 180-4 paragraph 6.2.2 step 3.
116 second (vH += SIG0(vA) + Maj(vE,vF,vC) equals T1 + T2 in FIPS PUB 180-4 paragraph 6.2.2 step 3.
117 * Note: 'wt' must be used exactly one time in this macro as it change other data as well
118 every time when used. */
119#define SHA2STEP32(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \
120 (vD) += ((vH) += SIG1 ((vE)) + Ch ((vE),(vF),(vG)) + (kt) + (wt)); \
121 (vH) += SIG0 ((vA)) + Maj ((vA),(vB),(vC)); } while (0)
122
123#ifndef _MHD_GET_32BIT_BE_UNALIGNED
124 if (0 != (((uintptr_t) data) % _MHD_UINT32_ALIGN))
125 {
126 /* Copy the unaligned input data to the aligned buffer */
127 memcpy (W, data, SHA256_BLOCK_SIZE);
128 /* The W[] buffer itself will be used as the source of the data,
129 * but data will be reloaded in correct bytes order during
130 * the next steps */
131 data = (uint8_t*) W;
132 }
133#endif /* _MHD_GET_32BIT_BE_UNALIGNED */
134
135 /* Get value of W(t) from input data buffer,
136 See FIPS PUB 180-4 paragraph 6.2.
137 Input data must be read in big-endian bytes order,
138 see FIPS PUB 180-4 paragraph 3.1.2. */
139#define GET_W_FROM_DATA(buf,t) \
140 _MHD_GET_32BIT_BE (((const uint8_t*) (buf)) + (t) * SHA256_BYTES_IN_WORD)
141
142 /* During first 16 steps, before making any calculations on each step,
143 the W element is read from input data buffer as big-endian value and
144 stored in array of W elements. */
145 /* Note: instead of using K constants as array, all K values are specified
146 individually for each step, see FIPS PUB 180-4 paragraph 4.2.2 for K values. */
147 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x428a2f98), W[0] = \
148 GET_W_FROM_DATA (data, 0));
149 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x71374491), W[1] = \
150 GET_W_FROM_DATA (data, 1));
151 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xb5c0fbcf), W[2] = \
152 GET_W_FROM_DATA (data, 2));
153 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xe9b5dba5), W[3] = \
154 GET_W_FROM_DATA (data, 3));
155 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x3956c25b), W[4] = \
156 GET_W_FROM_DATA (data, 4));
157 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x59f111f1), W[5] = \
158 GET_W_FROM_DATA (data, 5));
159 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x923f82a4), W[6] = \
160 GET_W_FROM_DATA (data, 6));
161 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xab1c5ed5), W[7] = \
162 GET_W_FROM_DATA (data, 7));
163 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xd807aa98), W[8] = \
164 GET_W_FROM_DATA (data, 8));
165 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x12835b01), W[9] = \
166 GET_W_FROM_DATA (data, 9));
167 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x243185be), W[10] = \
168 GET_W_FROM_DATA (data, 10));
169 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x550c7dc3), W[11] = \
170 GET_W_FROM_DATA (data, 11));
171 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x72be5d74), W[12] = \
172 GET_W_FROM_DATA (data, 12));
173 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x80deb1fe), W[13] = \
174 GET_W_FROM_DATA (data, 13));
175 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x9bdc06a7), W[14] = \
176 GET_W_FROM_DATA (data, 14));
177 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xc19bf174), W[15] = \
178 GET_W_FROM_DATA (data, 15));
179
180 /* 'W' generation and assignment for 16 <= t <= 63.
181 See FIPS PUB 180-4 paragraph 6.2.2.
182 As only last 16 'W' are used in calculations, it is possible to
183 use 16 elements array of W as cyclic buffer.
184 * Note: ((t-16)&0xf) have same value as (t&0xf) */
185#define Wgen(w,t) ( (w)[(t - 16) & 0xf] + sig1 ((w)[((t) - 2) & 0xf]) \
186 + (w)[((t) - 7) & 0xf] + sig0 ((w)[((t) - 15) & 0xf]) )
187
188 /* During last 48 steps, before making any calculations on each step,
189 W element is generated from W elements of cyclic buffer and generated value
190 stored back in cyclic buffer. */
191 /* Note: instead of using K constants as array, all K values are specified
192 individually for each step, see FIPS PUB 180-4 paragraph 4.2.2 for K values. */
193 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xe49b69c1), W[16 & 0xf] = \
194 Wgen (W,16));
195 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0xefbe4786), W[17 & 0xf] = \
196 Wgen (W,17));
197 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x0fc19dc6), W[18 & 0xf] = \
198 Wgen (W,18));
199 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x240ca1cc), W[19 & 0xf] = \
200 Wgen (W,19));
201 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x2de92c6f), W[20 & 0xf] = \
202 Wgen (W,20));
203 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x4a7484aa), W[21 & 0xf] = \
204 Wgen (W,21));
205 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x5cb0a9dc), W[22 & 0xf] = \
206 Wgen (W,22));
207 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x76f988da), W[23 & 0xf] = \
208 Wgen (W,23));
209 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x983e5152), W[24 & 0xf] = \
210 Wgen (W,24));
211 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0xa831c66d), W[25 & 0xf] = \
212 Wgen (W,25));
213 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xb00327c8), W[26 & 0xf] = \
214 Wgen (W,26));
215 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xbf597fc7), W[27 & 0xf] = \
216 Wgen (W,27));
217 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0xc6e00bf3), W[28 & 0xf] = \
218 Wgen (W,28));
219 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0xd5a79147), W[29 & 0xf] = \
220 Wgen (W,29));
221 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x06ca6351), W[30 & 0xf] = \
222 Wgen (W,30));
223 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x14292967), W[31 & 0xf] = \
224 Wgen (W,31));
225 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x27b70a85), W[32 & 0xf] = \
226 Wgen (W,32));
227 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x2e1b2138), W[33 & 0xf] = \
228 Wgen (W,33));
229 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x4d2c6dfc), W[34 & 0xf] = \
230 Wgen (W,34));
231 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x53380d13), W[35 & 0xf] = \
232 Wgen (W,35));
233 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x650a7354), W[36 & 0xf] = \
234 Wgen (W,36));
235 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x766a0abb), W[37 & 0xf] = \
236 Wgen (W,37));
237 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x81c2c92e), W[38 & 0xf] = \
238 Wgen (W,38));
239 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x92722c85), W[39 & 0xf] = \
240 Wgen (W,39));
241 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xa2bfe8a1), W[40 & 0xf] = \
242 Wgen (W,40));
243 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0xa81a664b), W[41 & 0xf] = \
244 Wgen (W,41));
245 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xc24b8b70), W[42 & 0xf] = \
246 Wgen (W,42));
247 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xc76c51a3), W[43 & 0xf] = \
248 Wgen (W,43));
249 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0xd192e819), W[44 & 0xf] = \
250 Wgen (W,44));
251 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0xd6990624), W[45 & 0xf] = \
252 Wgen (W,45));
253 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0xf40e3585), W[46 & 0xf] = \
254 Wgen (W,46));
255 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x106aa070), W[47 & 0xf] = \
256 Wgen (W,47));
257 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x19a4c116), W[48 & 0xf] = \
258 Wgen (W,48));
259 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x1e376c08), W[49 & 0xf] = \
260 Wgen (W,49));
261 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x2748774c), W[50 & 0xf] = \
262 Wgen (W,50));
263 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x34b0bcb5), W[51 & 0xf] = \
264 Wgen (W,51));
265 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x391c0cb3), W[52 & 0xf] = \
266 Wgen (W,52));
267 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x4ed8aa4a), W[53 & 0xf] = \
268 Wgen (W,53));
269 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x5b9cca4f), W[54 & 0xf] = \
270 Wgen (W,54));
271 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x682e6ff3), W[55 & 0xf] = \
272 Wgen (W,55));
273 SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x748f82ee), W[56 & 0xf] = \
274 Wgen (W,56));
275 SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x78a5636f), W[57 & 0xf] = \
276 Wgen (W,57));
277 SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x84c87814), W[58 & 0xf] = \
278 Wgen (W,58));
279 SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x8cc70208), W[59 & 0xf] = \
280 Wgen (W,59));
281 SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x90befffa), W[60 & 0xf] = \
282 Wgen (W,60));
283 SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0xa4506ceb), W[61 & 0xf] = \
284 Wgen (W,61));
285 SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0xbef9a3f7), W[62 & 0xf] = \
286 Wgen (W,62));
287 SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xc67178f2), W[63 & 0xf] = \
288 Wgen (W,63));
289
290 /* Compute intermediate hash.
291 See FIPS PUB 180-4 paragraph 6.2.2 step 4. */
292 H[0] += a;
293 H[1] += b;
294 H[2] += c;
295 H[3] += d;
296 H[4] += e;
297 H[5] += f;
298 H[6] += g;
299 H[7] += h;
300}
301
302
310void
312 const uint8_t *data,
313 size_t length)
314{
315 struct sha256_ctx *const ctx = ctx_;
316 unsigned bytes_have;
318 mhd_assert ((data != NULL) || (length == 0));
319
320 if (0 == length)
321 return; /* Do nothing */
322
323 /* Note: (count & (SHA256_BLOCK_SIZE-1))
324 equals (count % SHA256_BLOCK_SIZE) for this block size. */
325 bytes_have = (unsigned) (ctx->count & (SHA256_BLOCK_SIZE - 1));
326 ctx->count += length;
327
328 if (0 != bytes_have)
329 {
330 unsigned bytes_left = SHA256_BLOCK_SIZE - bytes_have;
331 if (length >= bytes_left)
332 { /* Combine new data with data in the buffer and
333 process full block. */
334 memcpy (ctx->buffer + bytes_have,
335 data,
336 bytes_left);
337 data += bytes_left;
338 length -= bytes_left;
339 sha256_transform (ctx->H, ctx->buffer);
340 bytes_have = 0;
341 }
342 }
343
344 while (SHA256_BLOCK_SIZE <= length)
345 { /* Process any full blocks of new data directly,
346 without copying to the buffer. */
347 sha256_transform (ctx->H, data);
349 length -= SHA256_BLOCK_SIZE;
350 }
351
352 if (0 != length)
353 { /* Copy incomplete block of new data (if any)
354 to the buffer. */
355 memcpy (ctx->buffer + bytes_have, data, length);
356 }
357}
358
359
364#define SHA256_SIZE_OF_LEN_ADD (64 / 8)
365
372void
374 uint8_t digest[SHA256_DIGEST_SIZE])
375{
376 struct sha256_ctx *const ctx = ctx_;
377 uint64_t num_bits;
378 unsigned bytes_have;
380 num_bits = ctx->count << 3;
381 /* Note: (count & (SHA256_BLOCK_SIZE-1))
382 equal (count % SHA256_BLOCK_SIZE) for this block size. */
383 bytes_have = (unsigned) (ctx->count & (SHA256_BLOCK_SIZE - 1));
384
385 /* Input data must be padded with bit "1" and with length of data in bits.
386 See FIPS PUB 180-4 paragraph 5.1.1. */
387 /* Data is always processed in form of bytes (not by individual bits),
388 therefore position of first padding bit in byte is always predefined (0x80). */
389 /* Buffer always have space at least for one byte (as full buffers are
390 processed immediately). */
391 ctx->buffer[bytes_have++] = 0x80;
392
393 if (SHA256_BLOCK_SIZE - bytes_have < SHA256_SIZE_OF_LEN_ADD)
394 { /* No space in current block to put total length of message.
395 Pad current block with zeros and process it. */
396 if (bytes_have < SHA256_BLOCK_SIZE)
397 memset (ctx->buffer + bytes_have, 0, SHA256_BLOCK_SIZE - bytes_have);
398 /* Process full block. */
399 sha256_transform (ctx->H, ctx->buffer);
400 /* Start new block. */
401 bytes_have = 0;
402 }
403
404 /* Pad the rest of the buffer with zeros. */
405 memset (ctx->buffer + bytes_have, 0,
407 /* Put number of bits in processed message as big-endian value. */
410 num_bits);
411 /* Process full final block. */
412 sha256_transform (ctx->H, ctx->buffer);
413
414 /* Put final hash/digest in BE mode */
415#ifndef _MHD_PUT_32BIT_BE_UNALIGNED
416 if (0 != ((uintptr_t) digest) % _MHD_UINT32_ALIGN)
417 {
418 uint32_t alig_dgst[_SHA256_DIGEST_LENGTH];
419 _MHD_PUT_32BIT_BE (alig_dgst + 0, ctx->H[0]);
420 _MHD_PUT_32BIT_BE (alig_dgst + 1, ctx->H[1]);
421 _MHD_PUT_32BIT_BE (alig_dgst + 2, ctx->H[2]);
422 _MHD_PUT_32BIT_BE (alig_dgst + 3, ctx->H[3]);
423 _MHD_PUT_32BIT_BE (alig_dgst + 4, ctx->H[4]);
424 _MHD_PUT_32BIT_BE (alig_dgst + 5, ctx->H[5]);
425 _MHD_PUT_32BIT_BE (alig_dgst + 6, ctx->H[6]);
426 _MHD_PUT_32BIT_BE (alig_dgst + 7, ctx->H[7]);
427 /* Copy result to unaligned destination address */
428 memcpy (digest, alig_dgst, SHA256_DIGEST_SIZE);
429 }
430 else
431#else /* _MHD_PUT_32BIT_BE_UNALIGNED */
432 if (1)
433#endif /* _MHD_PUT_32BIT_BE_UNALIGNED */
434 {
435 _MHD_PUT_32BIT_BE (digest + 0 * SHA256_BYTES_IN_WORD, ctx->H[0]);
436 _MHD_PUT_32BIT_BE (digest + 1 * SHA256_BYTES_IN_WORD, ctx->H[1]);
437 _MHD_PUT_32BIT_BE (digest + 2 * SHA256_BYTES_IN_WORD, ctx->H[2]);
438 _MHD_PUT_32BIT_BE (digest + 3 * SHA256_BYTES_IN_WORD, ctx->H[3]);
439 _MHD_PUT_32BIT_BE (digest + 4 * SHA256_BYTES_IN_WORD, ctx->H[4]);
440 _MHD_PUT_32BIT_BE (digest + 5 * SHA256_BYTES_IN_WORD, ctx->H[5]);
441 _MHD_PUT_32BIT_BE (digest + 6 * SHA256_BYTES_IN_WORD, ctx->H[6]);
442 _MHD_PUT_32BIT_BE (digest + 7 * SHA256_BYTES_IN_WORD, ctx->H[7]);
443 }
444
445 /* Erase potentially sensitive data. */
446 memset (ctx, 0, sizeof(struct sha256_ctx));
447}
#define mhd_assert(CHK)
Definition mhd_assert.h:39
#define NULL
#define _MHD_UINT32_ALIGN
Definition mhd_align.h:85
macros for bits manipulations
_MHD_static_inline void _MHD_PUT_64BIT_BE_SAFE(void *dst, uint64_t value)
#define _MHD_PUT_32BIT_BE(addr, value32)
macros for mhd_assert()
void * data
#define Wgen(w, t)
void MHD_SHA256_finish(void *ctx_, uint8_t digest[SHA256_DIGEST_SIZE])
Definition sha256.c:373
#define SHA256_SIZE_OF_LEN_ADD
Definition sha256.c:364
static void sha256_transform(uint32_t H[_SHA256_DIGEST_LENGTH], const uint8_t data[SHA256_BLOCK_SIZE])
Definition sha256.c:69
#define SHA2STEP32(vA, vB, vC, vD, vE, vF, vG, vH, kt, wt)
#define GET_W_FROM_DATA(buf, t)
void MHD_SHA256_init(void *ctx_)
Definition sha256.c:41
void MHD_SHA256_update(void *ctx_, const uint8_t *data, size_t length)
Definition sha256.c:311
Calculation of SHA-256 digest.
#define SHA256_BYTES_IN_WORD
Definition sha256.h:50
#define _SHA256_DIGEST_LENGTH
Definition sha256.h:39
#define SHA256_DIGEST_SIZE
Definition sha256.h:55
#define SHA256_BLOCK_SIZE
Definition sha256.h:70
uint8_t buffer[SHA256_BLOCK_SIZE]
Definition sha256.h:76
uint32_t H[_SHA256_DIGEST_LENGTH]
Definition sha256.h:75
uint64_t count
Definition sha256.h:77