1 /*
2   Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
3 
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.
7 
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:
11 
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.
19 
20   L. Peter Deutsch
21   ghost@aladdin.com
22 
23  */
24 /*$Id: md5.h,v 1.3 2002/08/05 03:56:55 lukeh Exp $ */
25 /*
26   Independent implementation of MD5 (RFC 1321).
27 
28   This code implements the MD5 Algorithm defined in RFC 1321.
29   It is derived directly from the text of the RFC and not from the
30   reference implementation.
31 
32   The original and principal author of md5.h is L. Peter Deutsch
33   <ghost@aladdin.com>.  Other authors are noted in the change history
34   that follows (in reverse chronological order):
35 
36   1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
37   1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
38 	added conditionalization for C++ compilation from Martin
39 	Purschke <purschke@bnl.gov>.
40   1999-05-03 lpd Original version.
41  */
42 
43 #ifndef md5_INCLUDED
44 #  define md5_INCLUDED
45 
46 /*
47  * This code has some adaptations for the Ghostscript environment, but it
48  * will compile and run correctly in any environment with 8-bit chars and
49  * 32-bit ints.  Specifically, it assumes that if the following are
50  * defined, they have the same meaning as in Ghostscript: P1, P2, P3,
51  * ARCH_IS_BIG_ENDIAN.
52  */
53 
54 typedef unsigned char md5_byte_t; /* 8-bit byte */
55 typedef unsigned int md5_word_t; /* 32-bit word */
56 
57 /* Define the state of the MD5 Algorithm. */
58 typedef struct md5_state_s {
59     md5_word_t count[2];	/* message length in bits, lsw first */
60     md5_word_t abcd[4];		/* digest buffer */
61     md5_byte_t buf[64];		/* accumulate block */
62 } md5_state_t;
63 
64 #ifdef __cplusplus
65 extern "C"
66 {
67 #endif
68 
69 /* Initialize the algorithm. */
70 #ifdef P1
71 void _pam_ldap_md5_init(P1(md5_state_t *pms));
72 #else
73 void _pam_ldap_md5_init(md5_state_t *pms);
74 #endif
75 
76 /* Append a string to the message. */
77 #ifdef P3
78 void _pam_ldap_md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
79 #else
80 void _pam_ldap_md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
81 #endif
82 
83 /* Finish the message and return the digest. */
84 #ifdef P2
85 void _pam_ldap_md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
86 #else
87 void _pam_ldap_md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
88 #endif
89 
90 #ifdef __cplusplus
91 }  /* end extern "C" */
92 #endif
93 
94 #endif /* md5_INCLUDED */
95