diff options
Diffstat (limited to 'src/microhttpd/md5.c')
-rw-r--r-- | src/microhttpd/md5.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c index a88dd711..7838ac10 100644 --- a/src/microhttpd/md5.c +++ b/src/microhttpd/md5.c | |||
@@ -20,29 +20,9 @@ | |||
20 | 20 | ||
21 | #include "md5.h" | 21 | #include "md5.h" |
22 | #include "mhd_byteorder.h" | 22 | #include "mhd_byteorder.h" |
23 | #include "mhd_bithelpers.h" | ||
23 | #include "mhd_assert.h" | 24 | #include "mhd_assert.h" |
24 | 25 | ||
25 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | ||
26 | #define PUT_64BIT_LE(addr, value64) ((*(uint64_t*)(addr)) = (uint64_t)(value64)) | ||
27 | #define PUT_32BIT_LE(addr, value32) ((*(uint32_t*)(addr)) = (uint32_t)(value32)) | ||
28 | #else | ||
29 | #define PUT_64BIT_LE(addr, value) do { \ | ||
30 | (addr)[7] = (uint8_t)((value64) >> 56); \ | ||
31 | (addr)[6] = (uint8_t)((value64) >> 48); \ | ||
32 | (addr)[5] = (uint8_t)((value64) >> 40); \ | ||
33 | (addr)[4] = (uint8_t)((value64) >> 32); \ | ||
34 | (addr)[3] = (uint8_t)((value64) >> 24); \ | ||
35 | (addr)[2] = (uint8_t)((value64) >> 16); \ | ||
36 | (addr)[1] = (uint8_t)((value64) >> 8); \ | ||
37 | (addr)[0] = (uint8_t)((value64)); } while (0) | ||
38 | |||
39 | #define PUT_32BIT_LE(addr, value32) do { \ | ||
40 | (addr)[3] = (uint8_t)((value32) >> 24); \ | ||
41 | (addr)[2] = (uint8_t)((value32) >> 16); \ | ||
42 | (addr)[1] = (uint8_t)((value32) >> 8); \ | ||
43 | (addr)[0] = (uint8_t)((value32)); } while (0) | ||
44 | #endif | ||
45 | |||
46 | 26 | ||
47 | /** | 27 | /** |
48 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious | 28 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious |
@@ -102,14 +82,14 @@ MD5Final (void *ctx_, | |||
102 | 82 | ||
103 | /* Put number of bits */ | 83 | /* Put number of bits */ |
104 | count_bits = ctx->count << 3; | 84 | count_bits = ctx->count << 3; |
105 | PUT_64BIT_LE(ctx->buffer + 56, count_bits); | 85 | _MHD_PUT_64BIT_LE(ctx->buffer + 56, count_bits); |
106 | MD5Transform(ctx->state, ctx->buffer); | 86 | MD5Transform(ctx->state, ctx->buffer); |
107 | 87 | ||
108 | /* Put digest in LE mode */ | 88 | /* Put digest in LE mode */ |
109 | PUT_32BIT_LE(digest, ctx->state[0]); | 89 | _MHD_PUT_32BIT_LE(digest, ctx->state[0]); |
110 | PUT_32BIT_LE(digest + 4, ctx->state[1]); | 90 | _MHD_PUT_32BIT_LE(digest + 4, ctx->state[1]); |
111 | PUT_32BIT_LE(digest + 8, ctx->state[2]); | 91 | _MHD_PUT_32BIT_LE(digest + 8, ctx->state[2]); |
112 | PUT_32BIT_LE(digest + 12, ctx->state[3]); | 92 | _MHD_PUT_32BIT_LE(digest + 12, ctx->state[3]); |
113 | 93 | ||
114 | /* Erase buffer */ | 94 | /* Erase buffer */ |
115 | memset(ctx, 0, sizeof(*ctx)); | 95 | memset(ctx, 0, sizeof(*ctx)); |