46 ctx->
H[0] = UINT32_C (0x67452301);
47 ctx->
H[1] = UINT32_C (0xefcdab89);
48 ctx->
H[2] = UINT32_C (0x98badcfe);
49 ctx->
H[3] = UINT32_C (0x10325476);
50 ctx->
H[4] = UINT32_C (0xc3d2e1f0);
82#define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) )
83#define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) )
87#define Par(x,y,z) ( (x) ^ (y) ^ (z) )
100#define SHA1STEP32(vA,vB,vC,vD,vE,ft,kt,wt) do { \
101 (vE) += _MHD_ROTL32 ((vA), 5) + ft ((vB), (vC), (vD)) + (kt) + (wt); \
102 (vB) = _MHD_ROTL32 ((vB), 30); } while (0)
110#define GET_W_FROM_DATA(buf,t) \
111 _MHD_GET_32BIT_BE ((const void *)(((const uint8_t*) (buf)) + \
112 (t) * SHA1_BYTES_IN_WORD))
114#ifndef _MHD_GET_32BIT_BE_UNALIGNED
122 data = (uint8_t *) W;
127#define K00 UINT32_C(0x5a827999)
129#define K20 UINT32_C(0x6ed9eba1)
131#define K40 UINT32_C(0x8f1bbcdc)
133#define K60 UINT32_C(0xca62c1d6)
161#define Wgen(w,t) _MHD_ROTL32((w)[(t + 13) & 0xf] ^ (w)[(t + 8) & 0xf] \
162 ^ (w)[(t + 2) & 0xf] ^ (w)[t & 0xf], 1)
267 ctx->
count += length;
272 if (length >= bytes_left)
275 memcpy (ctx->
buffer + bytes_have,
279 length -= bytes_left;
296 memcpy (ctx->
buffer + bytes_have,
data, length);
305#define SHA1_SIZE_OF_LEN_ADD (64 / 8)
321 num_bits = ctx->
count << 3;
332 ctx->
buffer[bytes_have++] = 0x80;
346 memset (ctx->
buffer + bytes_have, 0,
355#ifndef _MHD_PUT_32BIT_BE_UNALIGNED
382 memset (ctx, 0,
sizeof(
struct sha1_ctx));
#define _MHD_UINT32_ALIGN
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)
void MHD_SHA1_update(void *ctx_, const uint8_t *data, size_t length)
void MHD_SHA1_finish(void *ctx_, uint8_t digest[SHA1_DIGEST_SIZE])
#define SHA1STEP32(vA, vB, vC, vD, vE, ft, kt, wt)
void MHD_SHA1_init(void *ctx_)
#define SHA1_SIZE_OF_LEN_ADD
#define GET_W_FROM_DATA(buf, t)
static void sha1_transform(uint32_t H[_SHA1_DIGEST_LENGTH], const uint8_t data[SHA1_BLOCK_SIZE])
Calculation of SHA-1 digest.
#define _SHA1_DIGEST_LENGTH
#define SHA1_BYTES_IN_WORD
uint32_t H[_SHA1_DIGEST_LENGTH]
uint8_t buffer[SHA1_BLOCK_SIZE]