]> git.xonotic.org Git - xonotic/netradiant.git/blob - libs/md4lib.h
compiles again on win32, trashed mhash
[xonotic/netradiant.git] / libs / md4lib.h
1 /*
2  * This is an OpenSSL-compatible implementation of the RSA Data Security,
3  * Inc. MD4 Message-Digest Algorithm.
4  *
5  * Written by Solar Designer <solar@openwall.com> in 2001, and placed in
6  * the public domain.  See md4.c for more information.
7  */
8
9 #ifndef MD4_H
10 #define MD4_H
11
12 struct hash_method {\r
13         const char *name;\r
14         /* Number of bytes that must be allocated for context */\r
15         unsigned int context_size;\r
16         /* Number of bytes that must be allocated for result()'s digest */\r
17         unsigned int digest_size;\r
18 \r
19         void (*init)(void *context);\r
20         void (*loop)(void *context, const void *data, size_t size);\r
21         void (*result)(void *context, unsigned char *digest_r);\r
22 };\r
23 \r
24 const struct hash_method *hash_method_lookup(const char *name);\r
25 \r
26 /* NULL-terminated list of all hash methods */\r
27 extern const struct hash_method *hash_methods[];
28
29 typedef unsigned int uint_fast32_t;
30
31 #define MD4_RESULTLEN (128/8)
32
33 struct md4_context {
34         uint_fast32_t lo, hi;
35         uint_fast32_t a, b, c, d;
36         unsigned char buffer[64];
37         uint_fast32_t block[MD4_RESULTLEN];
38 };
39
40 void md4_init(struct md4_context *ctx);
41 void md4_update(struct md4_context *ctx, const void *data, size_t size);
42 void md4_final(struct md4_context *ctx, unsigned char result[MD4_RESULTLEN]);
43
44 void md4_get_digest(const void *data, size_t size,
45                     unsigned char result[MD4_RESULTLEN]);
46
47 extern const struct hash_method hash_method_md4;
48
49 #endif