25 /* |
25 /* |
26 Independent implementation of MD5 (RFC 1321). |
26 Independent implementation of MD5 (RFC 1321). |
27 |
27 |
28 This code implements the MD5 Algorithm defined in RFC 1321, whose |
28 This code implements the MD5 Algorithm defined in RFC 1321, whose |
29 text is available at |
29 text is available at |
30 http://www.ietf.org/rfc/rfc1321.txt |
30 http://www.ietf.org/rfc/rfc1321.txt |
31 The code is derived from the text of the RFC, including the test suite |
31 The code is derived from the text of the RFC, including the test suite |
32 (section A.5) but excluding the rest of Appendix A. It does not include |
32 (section A.5) but excluding the rest of Appendix A. It does not include |
33 any code or documentation that is identified in the RFC as being |
33 any code or documentation that is identified in the RFC as being |
34 copyrighted. |
34 copyrighted. |
35 |
35 |
36 The original and principal author of md5.h is L. Peter Deutsch |
36 The original and principal author of md5.h is L. Peter Deutsch |
37 <ghost@aladdin.com>. Other authors are noted in the change history |
37 <ghost@aladdin.com>. Other authors are noted in the change history |
38 that follows (in reverse chronological order): |
38 that follows (in reverse chronological order): |
39 |
39 |
40 2002-04-13 lpd Removed support for non-ANSI compilers; removed |
40 2002-04-13 lpd Removed support for non-ANSI compilers; removed |
41 references to Ghostscript; clarified derivation from RFC 1321; |
41 references to Ghostscript; clarified derivation from RFC 1321; |
42 now handles byte order either statically or dynamically. |
42 now handles byte order either statically or dynamically. |
43 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. |
43 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. |
44 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); |
44 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); |
45 added conditionalization for C++ compilation from Martin |
45 added conditionalization for C++ compilation from Martin |
46 Purschke <purschke@bnl.gov>. |
46 Purschke <purschke@bnl.gov>. |
47 1999-05-03 lpd Original version. |
47 1999-05-03 lpd Original version. |
48 */ |
48 */ |
49 |
49 |
50 #ifndef md5_INCLUDED |
50 #ifndef md5_INCLUDED |
51 # define md5_INCLUDED |
51 # define md5_INCLUDED |
61 */ |
61 */ |
62 |
62 |
63 typedef unsigned char md5_byte_t; /* 8-bit byte */ |
63 typedef unsigned char md5_byte_t; /* 8-bit byte */ |
64 typedef unsigned int md5_word_t; /* 32-bit word */ |
64 typedef unsigned int md5_word_t; /* 32-bit word */ |
65 |
65 |
66 /* Define the state of the MD5 Algorithm. */ |
66 /*! Define the state of the MD5 Algorithm. */ |
67 typedef struct md5_state_s { |
67 typedef struct md5_state_s { |
68 md5_word_t count[2]; /* message length in bits, lsw first */ |
68 md5_word_t count[2]; /*! message length in bits, lsw first */ |
69 md5_word_t abcd[4]; /* digest buffer */ |
69 md5_word_t abcd[4]; /*! digest buffer */ |
70 md5_byte_t buf[64]; /* accumulate block */ |
70 md5_byte_t buf[64]; /*! accumulate block */ |
71 } md5_state_t; |
71 } md5_state_t; |
72 |
72 |
73 #ifdef __cplusplus |
73 #ifdef __cplusplus |
74 extern "C" |
74 extern "C" |
75 { |
75 { |
76 #endif |
76 #endif |
77 |
77 |
78 /* Initialize the algorithm. */ |
78 /*! Initialize the algorithm. */ |
79 void md5_init(md5_state_t *pms); |
79 void md5_init(md5_state_t *pms); |
80 |
80 |
81 /* Append a string to the message. */ |
81 /*! Append a string to the message. */ |
82 void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); |
82 void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); |
83 |
83 |
84 /* Finish the message and return the digest. */ |
84 /*! Finish the message and return the digest. */ |
85 void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); |
85 void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); |
86 |
86 |
87 #ifdef __cplusplus |
87 #ifdef __cplusplus |
88 } /* end extern "C" */ |
88 } /* end extern "C" */ |
89 #endif |
89 #endif |