tron@2186: /* $Id$ */ tron@2186: truelight@602: /* truelight@602: Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. truelight@602: truelight@602: This software is provided 'as-is', without any express or implied truelight@602: warranty. In no event will the authors be held liable for any damages truelight@602: arising from the use of this software. truelight@602: truelight@602: Permission is granted to anyone to use this software for any purpose, truelight@602: including commercial applications, and to alter it and redistribute it truelight@602: freely, subject to the following restrictions: truelight@602: truelight@602: 1. The origin of this software must not be misrepresented; you must not truelight@602: claim that you wrote the original software. If you use this software truelight@602: in a product, an acknowledgment in the product documentation would be truelight@602: appreciated but is not required. truelight@602: 2. Altered source versions must be plainly marked as such, and must not be truelight@602: misrepresented as being the original software. truelight@602: 3. This notice may not be removed or altered from any source distribution. truelight@602: truelight@602: L. Peter Deutsch truelight@602: ghost@aladdin.com truelight@602: truelight@602: */ tron@2186: /* $Id$ */ truelight@602: /* truelight@602: Independent implementation of MD5 (RFC 1321). truelight@602: truelight@602: This code implements the MD5 Algorithm defined in RFC 1321, whose truelight@602: text is available at truelight@602: http://www.ietf.org/rfc/rfc1321.txt truelight@602: The code is derived from the text of the RFC, including the test suite truelight@602: (section A.5) but excluding the rest of Appendix A. It does not include truelight@602: any code or documentation that is identified in the RFC as being truelight@602: copyrighted. truelight@602: truelight@602: The original and principal author of md5.h is L. Peter Deutsch truelight@602: . Other authors are noted in the change history truelight@602: that follows (in reverse chronological order): truelight@602: truelight@602: 2002-04-13 lpd Removed support for non-ANSI compilers; removed truelight@602: references to Ghostscript; clarified derivation from RFC 1321; truelight@602: now handles byte order either statically or dynamically. truelight@602: 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. truelight@602: 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); truelight@602: added conditionalization for C++ compilation from Martin truelight@602: Purschke . truelight@602: 1999-05-03 lpd Original version. truelight@602: */ truelight@602: Darkvater@2436: #ifndef MD5_INCLUDED Darkvater@2436: #define MD5_INCLUDED truelight@602: truelight@602: /* truelight@602: * This package supports both compile-time and run-time determination of CPU truelight@602: * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be truelight@602: * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is truelight@602: * defined as non-zero, the code will be compiled to run only on big-endian truelight@602: * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to truelight@602: * run on either big- or little-endian CPUs, but will run slightly less truelight@602: * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. truelight@602: */ truelight@602: truelight@602: typedef unsigned char md5_byte_t; /* 8-bit byte */ truelight@602: typedef unsigned int md5_word_t; /* 32-bit word */ truelight@602: truelight@602: /* Define the state of the MD5 Algorithm. */ truelight@602: typedef struct md5_state_s { truelight@602: md5_word_t count[2]; /* message length in bits, lsw first */ truelight@602: md5_word_t abcd[4]; /* digest buffer */ truelight@602: md5_byte_t buf[64]; /* accumulate block */ truelight@602: } md5_state_t; truelight@602: truelight@602: #ifdef __cplusplus tron@915: extern "C" truelight@602: { truelight@602: #endif truelight@602: truelight@602: /* Initialize the algorithm. */ truelight@602: void md5_init(md5_state_t *pms); truelight@602: truelight@602: /* Append a string to the message. */ hackykid@1884: void md5_append(md5_state_t *pms, const void *data, int nbytes); truelight@602: truelight@602: /* Finish the message and return the digest. */ truelight@602: void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); truelight@602: truelight@602: #ifdef __cplusplus truelight@602: } /* end extern "C" */ truelight@602: #endif truelight@602: Darkvater@2436: #endif /* MD5_INCLUDED */