]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/md4lib.h
Undoing revision 377 (reverting just those files modified by that
[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 #ifdef _WIN32
13         #include "stdint.msvc.h"
14 #else
15         #include <stdint.h>
16 #endif
17
18 struct hash_method {
19         const char *name;
20         /* Number of bytes that must be allocated for context */
21         unsigned int context_size;
22         /* Number of bytes that must be allocated for result()'s digest */
23         unsigned int digest_size;
24
25         void (*init)(void *context);
26         void (*loop)(void *context, const void *data, size_t size);
27         void (*result)(void *context, unsigned char *digest_r);
28 };
29
30 const struct hash_method *hash_method_lookup(const char *name);
31
32 /* NULL-terminated list of all hash methods */
33 extern const struct hash_method *hash_methods[];
34
35 #define MD4_RESULTLEN (128/8)
36
37 struct md4_context {
38         uint_fast32_t lo, hi;
39         uint_fast32_t a, b, c, d;
40         unsigned char buffer[64];
41         uint_fast32_t block[MD4_RESULTLEN];
42 };
43
44 void md4_init(struct md4_context *ctx);
45 void md4_update(struct md4_context *ctx, const void *data, size_t size);
46 void md4_final(struct md4_context *ctx, unsigned char result[MD4_RESULTLEN]);
47
48 void md4_get_digest(const void *data, size_t size,
49                     unsigned char result[MD4_RESULTLEN]);
50
51 extern const struct hash_method hash_method_md4;
52
53 #endif