29 #define _PICOHASH_BIG_ENDIAN
30 #elif defined __LITTLE_ENDIAN__
32 #elif defined __BYTE_ORDER
33 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
34 #define _PICOHASH_BIG_ENDIAN
38 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
39 #define _PICOHASH_BIG_ENDIAN
43 #define PICOHASH_MD5_BLOCK_LENGTH 64
44 #define PICOHASH_MD5_DIGEST_LENGTH 16
48 uint_fast32_t
a, b, c, d;
65 #define _PICOHASH_MD5_F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
66 #define _PICOHASH_MD5_G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
67 #define _PICOHASH_MD5_H(x, y, z) ((x) ^ (y) ^ (z))
68 #define _PICOHASH_MD5_I(x, y, z) ((y) ^ ((x) | ~(z)))
73 #define _PICOHASH_MD5_STEP(f, a, b, c, d, x, t, s) \
74 (a) += f((b), (c), (d)) + (x) + (t); \
75 (a) = (((a) << (s)) | (((a)&0xffffffff) >> (32 - (s)))); \
86 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
87 #define _PICOHASH_MD5_SET(n) (*(const uint32_t *)&ptr[(n)*4])
88 #define _PICOHASH_MD5_GET(n) _PICOHASH_MD5_SET(n)
90 #define _PICOHASH_MD5_SET(n) \
91 (ctx->block[(n)] = (uint_fast32_t)ptr[(n)*4] | ((uint_fast32_t)ptr[(n)*4 + 1] << 8) | ((uint_fast32_t)ptr[(n)*4 + 2] << 16) | \
92 ((uint_fast32_t)ptr[(n)*4 + 3] << 24))
93 #define _PICOHASH_MD5_GET(n) (ctx->block[(n)])
100 static const void *_picohash_md5_body(
_picohash_md5_ctx_t *ctx,
const void *data,
size_t size)
102 const unsigned char *ptr;
103 uint_fast32_t a, b, c, d;
104 uint_fast32_t saved_a, saved_b, saved_c, saved_d;
106 ptr = (
const unsigned char*) data;
197 }
while (size -= 64);
220 uint_fast32_t saved_lo;
221 unsigned long used, free;
224 if ((ctx->
lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
226 ctx->
hi += size >> 29;
228 used = saved_lo & 0x3f;
234 memcpy(&ctx->
buffer[used], data, size);
238 memcpy(&ctx->
buffer[used], data, free);
239 data = (
const unsigned char *)data + free;
241 _picohash_md5_body(ctx, ctx->
buffer, 64);
245 data = _picohash_md5_body(ctx, data, size & ~(
unsigned long)0x3f);
249 memcpy(ctx->
buffer, data, size);
254 unsigned char *digest = (
unsigned char *) _digest;
255 unsigned long used, free;
257 used = ctx->
lo & 0x3f;
259 ctx->
buffer[used++] = 0x80;
264 memset(&ctx->
buffer[used], 0, free);
265 _picohash_md5_body(ctx, ctx->
buffer, 64);
270 memset(&ctx->
buffer[used], 0, free - 8);
282 _picohash_md5_body(ctx, ctx->
buffer, 64);
285 digest[1] = ctx->
a >> 8;
286 digest[2] = ctx->
a >> 16;
287 digest[3] = ctx->
a >> 24;
289 digest[5] = ctx->
b >> 8;
290 digest[6] = ctx->
b >> 16;
291 digest[7] = ctx->
b >> 24;
293 digest[9] = ctx->
c >> 8;
294 digest[10] = ctx->
c >> 16;
295 digest[11] = ctx->
c >> 24;
297 digest[13] = ctx->
d >> 8;
298 digest[14] = ctx->
d >> 16;
299 digest[15] = ctx->
d >> 24;
301 memset(ctx, 0,
sizeof(*ctx));
char buffer[MAX_BUFFER][MAX_CHARS]
Definition: fourmer.c:46
#define _PICOHASH_MD5_F(x, y, z)
Definition: picohash.h:65
uint_fast32_t hi
Definition: picohash.h:47
uint_fast32_t b
Definition: picohash.h:48
#define _PICOHASH_MD5_H(x, y, z)
Definition: picohash.h:67
uint_fast32_t a
Definition: picohash.h:48
uint_fast32_t d
Definition: picohash.h:48
#define _PICOHASH_MD5_SET(n)
Definition: picohash.h:90
#define _PICOHASH_MD5_GET(n)
Definition: picohash.h:93
#define _PICOHASH_MD5_I(x, y, z)
Definition: picohash.h:68
uint_fast32_t c
Definition: picohash.h:48
#define PICOHASH_MD5_DIGEST_LENGTH
Definition: picohash.h:44
uint_fast32_t lo
Definition: picohash.h:47
unsigned char buffer[64]
Definition: picohash.h:49
#define _PICOHASH_MD5_G(x, y, z)
Definition: picohash.h:66
#define _PICOHASH_MD5_STEP(f, a, b, c, d, x, t, s)
Definition: picohash.h:73
Definition: picohash.h:46