diff options
Diffstat (limited to 'src/lib/md5.h')
-rw-r--r-- | src/lib/md5.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/lib/md5.h b/src/lib/md5.h index 7a6f84e6..8e95b29b 100644 --- a/src/lib/md5.h +++ b/src/lib/md5.h | |||
@@ -20,45 +20,47 @@ | |||
20 | 20 | ||
21 | #include "platform.h" | 21 | #include "platform.h" |
22 | 22 | ||
23 | #define MD5_BLOCK_SIZE 64 | 23 | #define MD5_BLOCK_SIZE 64 |
24 | #define MD5_DIGEST_SIZE 16 | 24 | #define MD5_DIGEST_SIZE 16 |
25 | #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_SIZE * 2 + 1) | 25 | #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_SIZE * 2 + 1) |
26 | 26 | ||
27 | struct MD5Context | 27 | struct MD5Context |
28 | { | 28 | { |
29 | uint32_t state[4]; /* state */ | 29 | uint32_t state[4]; /* state */ |
30 | uint64_t count; /* number of bits, mod 2^64 */ | 30 | uint64_t count; /* number of bits, mod 2^64 */ |
31 | uint8_t buffer[MD5_BLOCK_SIZE]; /* input buffer */ | 31 | uint8_t buffer[MD5_BLOCK_SIZE]; /* input buffer */ |
32 | }; | 32 | }; |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious | 35 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious |
36 | * initialization constants. | 36 | * initialization constants. |
37 | */ | 37 | */ |
38 | void MHD_MD5Init(struct MD5Context *ctx); | 38 | void MHD_MD5Init (struct MD5Context *ctx); |
39 | 39 | ||
40 | /* | 40 | /* |
41 | * Update context to reflect the concatenation of another buffer full | 41 | * Update context to reflect the concatenation of another buffer full |
42 | * of bytes. | 42 | * of bytes. |
43 | */ | 43 | */ |
44 | void MHD_MD5Update(struct MD5Context *ctx, const unsigned char *input, size_t len); | 44 | void MHD_MD5Update (struct MD5Context *ctx, const unsigned char *input, size_t |
45 | len); | ||
45 | 46 | ||
46 | /* | 47 | /* |
47 | * Pad pad to 64-byte boundary with the bit pattern | 48 | * Pad pad to 64-byte boundary with the bit pattern |
48 | * 1 0* (64-bit count of bits processed, MSB-first) | 49 | * 1 0* (64-bit count of bits processed, MSB-first) |
49 | */ | 50 | */ |
50 | void MD5Pad(struct MD5Context *ctx); | 51 | void MD5Pad (struct MD5Context *ctx); |
51 | 52 | ||
52 | /* | 53 | /* |
53 | * Final wrapup--call MD5Pad, fill in digest and zero out ctx. | 54 | * Final wrapup--call MD5Pad, fill in digest and zero out ctx. |
54 | */ | 55 | */ |
55 | void MHD_MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx); | 56 | void MHD_MD5Final (unsigned char digest[MD5_DIGEST_SIZE], struct |
57 | MD5Context *ctx); | ||
56 | 58 | ||
57 | /* | 59 | /* |
58 | * The core of the MD5 algorithm, this alters an existing MD5 hash to | 60 | * The core of the MD5 algorithm, this alters an existing MD5 hash to |
59 | * reflect the addition of 16 longwords of new data. MHD_MD5Update blocks | 61 | * reflect the addition of 16 longwords of new data. MHD_MD5Update blocks |
60 | * the data and converts bytes into longwords for this routine. | 62 | * the data and converts bytes into longwords for this routine. |
61 | */ | 63 | */ |
62 | void MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE]); | 64 | void MD5Transform (uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE]); |
63 | 65 | ||
64 | #endif /* !MHD_MD5_H */ | 66 | #endif /* !MHD_MD5_H */ |