diff options
Diffstat (limited to 'src/microhttpd/md5.c')
-rw-r--r-- | src/microhttpd/md5.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c index 5daa0334..309f492c 100644 --- a/src/microhttpd/md5.c +++ b/src/microhttpd/md5.c | |||
@@ -28,7 +28,7 @@ | |||
28 | /* | 28 | /* |
29 | * Note: this code is harmless on little-endian machines. | 29 | * Note: this code is harmless on little-endian machines. |
30 | */ | 30 | */ |
31 | static void | 31 | static void |
32 | byteReverse(unsigned char *buf, | 32 | byteReverse(unsigned char *buf, |
33 | unsigned longs) | 33 | unsigned longs) |
34 | { | 34 | { |
@@ -60,7 +60,7 @@ byteReverse(unsigned char *buf, | |||
60 | * reflect the addition of 16 longwords of new data. MD5Update blocks | 60 | * reflect the addition of 16 longwords of new data. MD5Update blocks |
61 | * the data and converts bytes into longwords for this routine. | 61 | * the data and converts bytes into longwords for this routine. |
62 | */ | 62 | */ |
63 | static void | 63 | static void |
64 | MD5Transform(uint32_t buf[4], | 64 | MD5Transform(uint32_t buf[4], |
65 | uint32_t in[16]) | 65 | uint32_t in[16]) |
66 | { | 66 | { |
@@ -150,7 +150,7 @@ MD5Transform(uint32_t buf[4], | |||
150 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious | 150 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious |
151 | * initialization constants. | 151 | * initialization constants. |
152 | */ | 152 | */ |
153 | void | 153 | void HIDDEN_SYMBOL |
154 | MD5Init(struct MD5Context *ctx) | 154 | MD5Init(struct MD5Context *ctx) |
155 | { | 155 | { |
156 | ctx->buf[0] = 0x67452301; | 156 | ctx->buf[0] = 0x67452301; |
@@ -166,7 +166,7 @@ MD5Init(struct MD5Context *ctx) | |||
166 | * Update context to reflect the concatenation of another buffer full | 166 | * Update context to reflect the concatenation of another buffer full |
167 | * of bytes. | 167 | * of bytes. |
168 | */ | 168 | */ |
169 | void | 169 | void HIDDEN_SYMBOL |
170 | MD5Update(struct MD5Context *ctx, | 170 | MD5Update(struct MD5Context *ctx, |
171 | const void *data, | 171 | const void *data, |
172 | unsigned len) | 172 | unsigned len) |
@@ -215,49 +215,49 @@ MD5Update(struct MD5Context *ctx, | |||
215 | } | 215 | } |
216 | 216 | ||
217 | /* | 217 | /* |
218 | * Final wrapup - pad to 64-byte boundary with the bit pattern | 218 | * Final wrapup - pad to 64-byte boundary with the bit pattern |
219 | * 1 0* (64-bit count of bits processed, MSB-first) | 219 | * 1 0* (64-bit count of bits processed, MSB-first) |
220 | */ | 220 | */ |
221 | void | 221 | void HIDDEN_SYMBOL |
222 | MD5Final(unsigned char digest[16], | 222 | MD5Final (unsigned char digest[16], |
223 | struct MD5Context *ctx) | 223 | struct MD5Context *ctx) |
224 | { | 224 | { |
225 | unsigned count; | 225 | unsigned count; |
226 | unsigned char *p; | 226 | unsigned char *p; |
227 | 227 | ||
228 | /* Compute number of bytes mod 64 */ | 228 | /* Compute number of bytes mod 64 */ |
229 | count = (ctx->bits[0] >> 3) & 0x3F; | 229 | count = (ctx->bits[0] >> 3) & 0x3F; |
230 | 230 | ||
231 | /* Set the first char of padding to 0x80. This is safe since there is | 231 | /* Set the first char of padding to 0x80. This is safe since there is |
232 | always at least one byte free */ | 232 | always at least one byte free */ |
233 | p = ctx->in + count; | 233 | p = ctx->in + count; |
234 | *p++ = 0x80; | 234 | *p++ = 0x80; |
235 | 235 | ||
236 | /* Bytes of padding needed to make 64 bytes */ | 236 | /* Bytes of padding needed to make 64 bytes */ |
237 | count = 64 - 1 - count; | 237 | count = 64 - 1 - count; |
238 | 238 | ||
239 | /* Pad out to 56 mod 64 */ | 239 | /* Pad out to 56 mod 64 */ |
240 | if (count < 8) | 240 | if (count < 8) |
241 | { | 241 | { |
242 | /* Two lots of padding: Pad the first block to 64 bytes */ | 242 | /* Two lots of padding: Pad the first block to 64 bytes */ |
243 | memset(p, 0, count); | 243 | memset(p, 0, count); |
244 | byteReverse(ctx->in, 16); | 244 | byteReverse(ctx->in, 16); |
245 | MD5Transform(ctx->buf, (uint32_t *) ctx->in); | 245 | MD5Transform(ctx->buf, (uint32_t *) ctx->in); |
246 | 246 | ||
247 | /* Now fill the next block with 56 bytes */ | 247 | /* Now fill the next block with 56 bytes */ |
248 | memset(ctx->in, 0, 56); | 248 | memset(ctx->in, 0, 56); |
249 | } | 249 | } |
250 | else | 250 | else |
251 | { | 251 | { |
252 | /* Pad block to 56 bytes */ | 252 | /* Pad block to 56 bytes */ |
253 | memset(p, 0, count - 8); | 253 | memset(p, 0, count - 8); |
254 | } | 254 | } |
255 | byteReverse(ctx->in, 14); | 255 | byteReverse(ctx->in, 14); |
256 | 256 | ||
257 | /* Append length in bits and transform */ | 257 | /* Append length in bits and transform */ |
258 | ((uint32_t *) ctx->in)[14] = ctx->bits[0]; | 258 | ((uint32_t *) ctx->in)[14] = ctx->bits[0]; |
259 | ((uint32_t *) ctx->in)[15] = ctx->bits[1]; | 259 | ((uint32_t *) ctx->in)[15] = ctx->bits[1]; |
260 | 260 | ||
261 | MD5Transform(ctx->buf, (uint32_t *) ctx->in); | 261 | MD5Transform(ctx->buf, (uint32_t *) ctx->in); |
262 | byteReverse((unsigned char *) ctx->buf, 4); | 262 | byteReverse((unsigned char *) ctx->buf, 4); |
263 | memcpy(digest, ctx->buf, 16); | 263 | memcpy(digest, ctx->buf, 16); |