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