GNU libmicrohttpd
0.9.59
md5.h
Go to the documentation of this file.
1
/*
2
* This code implements the MD5 message-digest algorithm.
3
* The algorithm is due to Ron Rivest. This code was
4
* written by Colin Plumb in 1993, no copyright is claimed.
5
* This code is in the public domain; do with it what you wish.
6
*
7
* Equivalent code is available from RSA Data Security, Inc.
8
* This code has been tested against that, and is equivalent,
9
* except that you don't need to include two pages of legalese
10
* with every copy.
11
*
12
* To compute the message digest of a chunk of bytes, declare an
13
* MD5Context structure, pass it to MD5Init, call MD5Update as
14
* needed on buffers full of bytes, and then call MD5Final, which
15
* will fill a supplied 16-byte array with the digest.
16
*/
17
18
#ifndef MHD_MD5_H
19
#define MHD_MD5_H
20
21
#include "
platform.h
"
22
23
#define MD5_BLOCK_SIZE 64
24
#define MD5_DIGEST_SIZE 16
25
#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_SIZE * 2 + 1)
26
27
struct
MD5Context
28
{
29
uint32_t
state
[4];
/* state */
30
uint64_t
count
;
/* number of bits, mod 2^64 */
31
uint8_t
buffer
[
MD5_BLOCK_SIZE
];
/* input buffer */
32
};
33
34
/*
35
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
36
* initialization constants.
37
*/
38
void
MD5Init
(
struct
MD5Context
*ctx);
39
40
/*
41
* Update context to reflect the concatenation of another buffer full
42
* of bytes.
43
*/
44
void
MD5Update
(
struct
MD5Context
*ctx,
const
unsigned
char
*input,
size_t
len);
45
46
/*
47
* Pad pad to 64-byte boundary with the bit pattern
48
* 1 0* (64-bit count of bits processed, MSB-first)
49
*/
50
void
MD5Pad
(
struct
MD5Context
*ctx);
51
52
/*
53
* Final wrapup--call MD5Pad, fill in digest and zero out ctx.
54
*/
55
void
MD5Final
(
unsigned
char
digest[
MD5_DIGEST_SIZE
],
struct
MD5Context
*ctx);
56
57
/*
58
* The core of the MD5 algorithm, this alters an existing MD5 hash to
59
* reflect the addition of 16 longwords of new data. MD5Update blocks
60
* the data and converts bytes into longwords for this routine.
61
*/
62
void
MD5Transform
(uint32_t state[4],
const
uint8_t block[
MD5_BLOCK_SIZE
]);
63
64
#endif
/* !MHD_MD5_H */
MD5Context::buffer
uint8_t buffer[MD5_BLOCK_SIZE]
Definition:
md5.h:31
MD5Context::count
uint64_t count
Definition:
md5.h:30
MD5Init
void MD5Init(struct MD5Context *ctx)
Definition:
md5.c:50
platform.h
platform-specific includes for libmicrohttpd
MD5Transform
void MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE])
Definition:
md5.c:168
MD5_BLOCK_SIZE
#define MD5_BLOCK_SIZE
Definition:
md5.h:23
MD5Final
void MD5Final(unsigned char digest[MD5_DIGEST_SIZE], struct MD5Context *ctx)
Definition:
md5.c:135
MD5Context
Definition:
md5.h:27
MD5_DIGEST_SIZE
#define MD5_DIGEST_SIZE
Definition:
md5.h:24
MD5Update
void MD5Update(struct MD5Context *ctx, const unsigned char *input, size_t len)
Definition:
md5.c:67
MD5Pad
void MD5Pad(struct MD5Context *ctx)
Definition:
md5.c:111
MD5Context::state
uint32_t state[4]
Definition:
md5.h:29
src
microhttpd
md5.h
Generated by
1.8.14