]> git.ozlabs.org Git - ccan/blob - ccan/md4/md4.h
memmem, bytestring: Fix includes in _info
[ccan] / ccan / md4 / md4.h
1 /* Licensed under GPLv2+ - see LICENSE file for details */
2 #ifndef CCAN_MD4_H
3 #define CCAN_MD4_H
4 #include <stdint.h>
5 #include <stdlib.h>
6
7 /**
8  * md4_ctx - context structure for md4 hashing
9  * @hash: the 128-bit hash value (only valid after md4_finish)
10  * @block: internal working state.
11  * @byte_count: the total number of bytes processed.
12  */
13 struct md4_ctx {
14         union {
15                 unsigned char bytes[16];
16                 uint32_t words[4];
17         } hash;
18         uint32_t block[16];
19         uint64_t byte_count;
20 };
21
22 /**
23  * md4_init - (re-)initialize the struct md4_ctx before md4_hash.
24  * @mctx: the struct md4_ctx which will be handed to md4_hash.
25  *
26  * Contexts can be safely re-used by calling md4_init() on them again.
27  *
28  * Example:
29  *      struct md4_ctx ctx;
30  *
31  *      md4_init(&ctx);
32  *      ...
33  */
34 void md4_init(struct md4_ctx *mctx);
35
36 /**
37  * md4_hash - add these bytes into the hash
38  * @mctx: the struct md4_ctx.
39  * @p: pointer to the bytes to hash.
40  * @len: the number of bytes pointed to by @p.
41  *
42  * Example:
43  *      struct md4_ctx ctx;
44  *
45  *      md4_init(&ctx);
46  *      md4_hash(&ctx, "hello", 5);
47  *      md4_hash(&ctx, " ", 1);
48  *      md4_hash(&ctx, "world", 5);
49  */
50 void md4_hash(struct md4_ctx *mctx, const void *p, size_t len);
51
52 /**
53  * md4_finish - complete the MD4 hash
54  * @mctx: the struct md4_ctx.
55  *
56  * Example:
57  *      struct md4_ctx ctx;
58  *
59  *      md4_init(&ctx);
60  *      md4_hash(&ctx, "hello world", strlen("hello world"));
61  *      md4_finish(&ctx);
62  */
63 void md4_finish(struct md4_ctx *mctx);
64
65 #endif /* CCAN_MD4_H */