drop md4 i?86 specific asm implementations
[mldonkey.git] / src / utils / lib / md5.h
blob2249d62778f19f9b85f86c3f8301982299d80223
1 /*
2 Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
20 L. Peter Deutsch
21 ghost@aladdin.com
25 Independent implementation of MD5 (RFC 1321).
27 This code implements the MD5 Algorithm defined in RFC 1321.
28 It is derived directly from the text of the RFC and not from the
29 reference implementation.
31 The original and principal author of md5.h is L. Peter Deutsch
32 <ghost@aladdin.com>. Other authors are noted in the change history
33 that follows (in reverse chronological order):
35 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
36 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
37 added conditionalization for C++ compilation from Martin
38 Purschke <purschke@bnl.gov>.
39 1999-05-03 lpd Original version.
42 #ifndef md5_INCLUDED
43 # define md5_INCLUDED
46 * This code has some adaptations for the Ghostscript environment, but it
47 * will compile and run correctly in any environment with 8-bit chars and
48 * 32-bit ints. Specifically, it assumes that if the following are
49 * defined, they have the same meaning as in Ghostscript: P1, P2, P3,
50 * ARCH_IS_BIG_ENDIAN.
53 typedef unsigned char md5_byte_t; /* 8-bit byte */
54 typedef unsigned int md5_word_t; /* 32-bit word */
56 /* Define the state of the MD5 Algorithm. */
57 typedef struct md5_state_s {
58 md5_word_t count[2]; /* message length in bits, lsw first */
59 md5_word_t abcd[4]; /* digest buffer */
60 md5_byte_t buf[64]; /* accumulate block */
61 } md5_state_t;
63 #define MD5_CTX md5_state_t
65 #ifdef __cplusplus
66 extern "C"
68 #endif
70 /* Initialize the algorithm. */
71 #ifdef P1
72 void md5_init(P1(md5_state_t *pms));
73 #else
74 void md5_init(md5_state_t *pms);
75 #endif
77 /* Append a string to the message. */
78 #ifdef P3
79 void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
80 #else
81 void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
82 #endif
84 /* Finish the message and return the digest. */
85 #ifdef P2
86 void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
87 #else
88 void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
89 #endif
91 #ifdef __cplusplus
92 } /* end extern "C" */
93 #endif
95 #define ml_MD5Context md5_state_t
96 #define ml_MD5_HASH_LEN 16
97 #define ml_MD5Init md5_init
98 #define ml_MD5Update md5_append
99 #define ml_MD5Final(md5,ctx) md5_finish(ctx,md5)
101 #endif /* md5_INCLUDED */