VHISTlib
1.84.0.3018
|
00001 /* 00002 $Id: md5.h 2792 2013-05-06 11:25:27Z michael $ 00003 // 00004 // 2 29.09.03 0:39 Stefan 00005 // new MD5 implementation based on free implementation by L. Peter Deutsch 00006 */ 00007 00008 /* MD5.H - header file for MD5C.C 00009 */ 00010 00011 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 00012 rights reserved. 00013 00014 License to copy and use this software is granted provided that it 00015 is identified as the "RSA Data Security, Inc. MD5 Message-Digest 00016 Algorithm" in all material mentioning or referencing this software 00017 or this function. 00018 00019 License is also granted to make and use derivative works provided 00020 that such works are identified as "derived from the RSA Data 00021 Security, Inc. MD5 Message-Digest Algorithm" in all material 00022 mentioning or referencing the derived work. 00023 00024 RSA Data Security, Inc. makes no representations concerning either 00025 the merchantability of this software or the suitability of this 00026 software for any particular purpose. It is provided "as is" 00027 without express or implied warranty of any kind. 00028 00029 These notices must be retained in any copies of any part of this 00030 documentation and/or software. 00031 */ 00032 00033 #ifndef _MD5_H_ 00034 #define _MD5_H_ 1 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 /* PROTOTYPES should be set to one if and only if the compiler supports 00041 function argument prototyping. 00042 The following makes PROTOTYPES default to 1 if it has not already been 00043 defined as 0 with C compiler flags. 00044 */ 00045 #ifndef PROTOTYPES 00046 #define PROTOTYPES 1 00047 #endif 00048 00049 /* POINTER defines a generic pointer type */ 00050 typedef unsigned char *POINTER; 00051 00052 /* UINT2 defines a two byte word */ 00053 typedef unsigned short int UINT2; 00054 00055 /* UINT4 defines a four byte word */ 00056 typedef unsigned long int UINT4; 00057 00058 #ifndef NULL_PTR 00059 #define NULL_PTR ((POINTER)0) 00060 #endif 00061 00062 #ifndef UNUSED_ARG 00063 #define UNUSED_ARG(x) x = *(&x); 00064 #endif 00065 00066 /* PROTO_LIST is defined depending on how PROTOTYPES is defined above. 00067 If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it 00068 returns an empty list. 00069 */ 00070 #if PROTOTYPES 00071 #define PROTO_LIST(list) list 00072 #else 00073 #define PROTO_LIST(list) () 00074 #endif 00075 00076 /* MD5 context. */ 00077 typedef struct { 00078 UINT4 state[4]; /* state (ABCD) */ 00079 UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ 00080 unsigned char buffer[64]; /* input buffer */ 00081 } MD5_CTX; 00082 /* 00083 Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. 00084 00085 This software is provided 'as-is', without any express or implied 00086 warranty. In no event will the authors be held liable for any damages 00087 arising from the use of this software. 00088 00089 Permission is granted to anyone to use this software for any purpose, 00090 including commercial applications, and to alter it and redistribute it 00091 freely, subject to the following restrictions: 00092 00093 1. The origin of this software must not be misrepresented; you must not 00094 claim that you wrote the original software. If you use this software 00095 in a product, an acknowledgment in the product documentation would be 00096 appreciated but is not required. 00097 2. Altered source versions must be plainly marked as such, and must not be 00098 misrepresented as being the original software. 00099 3. This notice may not be removed or altered from any source distribution. 00100 00101 L. Peter Deutsch 00102 ghost@aladdin.com 00103 00104 */ 00105 /* $Id: md5.h 2792 2013-05-06 11:25:27Z michael $ */ 00106 /* 00107 Independent implementation of MD5 (RFC 1321). 00108 00109 This code implements the MD5 Algorithm defined in RFC 1321, whose 00110 text is available at 00111 http://www.ietf.org/rfc/rfc1321.txt 00112 The code is derived from the text of the RFC, including the test suite 00113 (section A.5) but excluding the rest of Appendix A. It does not include 00114 any code or documentation that is identified in the RFC as being 00115 copyrighted. 00116 00117 The original and principal author of md5.h is L. Peter Deutsch 00118 <ghost@aladdin.com>. Other authors are noted in the change history 00119 that follows (in reverse chronological order): 00120 00121 2002-04-13 lpd Removed support for non-ANSI compilers; removed 00122 references to Ghostscript; clarified derivation from RFC 1321; 00123 now handles byte order either statically or dynamically. 00124 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 00125 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); 00126 added conditionalization for C++ compilation from Martin 00127 Purschke <purschke@bnl.gov>. 00128 1999-05-03 lpd Original version. 00129 */ 00130 00131 #ifndef md5_INCLUDED 00132 # define md5_INCLUDED 00133 00134 /* 00135 * This package supports both compile-time and run-time determination of CPU 00136 * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be 00137 * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is 00138 * defined as non-zero, the code will be compiled to run only on big-endian 00139 * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to 00140 * run on either big- or little-endian CPUs, but will run slightly less 00141 * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. 00142 */ 00143 00144 typedef unsigned char md5_byte_t; /* 8-bit byte */ 00145 typedef unsigned int md5_word_t; /* 32-bit word */ 00146 00147 /* Define the state of the MD5 Algorithm. */ 00148 typedef struct md5_state_s { 00149 md5_word_t count[2]; /* message length in bits, lsw first */ 00150 md5_word_t abcd[4]; /* digest buffer */ 00151 md5_byte_t buf[64]; /* accumulate block */ 00152 } md5_state_t; 00153 00154 #ifdef __cplusplus 00155 extern "C" 00156 { 00157 #endif 00158 00159 /* Initialize the algorithm. */ 00160 void md5_init(md5_state_t *pms); 00161 00162 /* Append a string to the message. */ 00163 void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); 00164 00165 /* Finish the message and return the digest. */ 00166 void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); 00167 00168 #ifdef __cplusplus 00169 } /* end extern "C" */ 00170 #endif 00171 00172 #endif /* md5_INCLUDED */ 00173 void MD5Init PROTO_LIST ((MD5_CTX *)); 00174 void MD5Update PROTO_LIST 00175 ((MD5_CTX *, unsigned char *, unsigned int)); 00176 void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); 00177 00178 #ifdef __cplusplus 00179 } 00180 #endif 00181 00182 #endif