00001 // MD5.CC - source code for the C++/object oriented translation and 00002 // modification of MD5. 00003 00004 // Translation and modification (c) 1995 by Mordechai T. Abzug 00005 00006 // This translation/ modification is provided "as is," without express or 00007 // implied warranty of any kind. 00008 00009 // The translator/ modifier does not claim (1) that MD5 will do what you think 00010 // it does; (2) that this translation/ modification is accurate; or (3) that 00011 // this software is "merchantible." (Language for this disclaimer partially 00012 // copied from the disclaimer below). 00013 00014 /* based on: 00015 00016 MD5.H - header file for MD5C.C 00017 MDDRIVER.C - test driver for MD2, MD4 and MD5 00018 00019 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 00020 rights reserved. 00021 00022 License to copy and use this software is granted provided that it 00023 is identified as the "RSA Data Security, Inc. MD5 Message-Digest 00024 Algorithm" in all material mentioning or referencing this software 00025 or this function. 00026 00027 License is also granted to make and use derivative works provided 00028 that such works are identified as "derived from the RSA Data 00029 Security, Inc. MD5 Message-Digest Algorithm" in all material 00030 mentioning or referencing the derived work. 00031 00032 RSA Data Security, Inc. makes no representations concerning either 00033 the merchantability of this software or the suitability of this 00034 software for any particular purpose. It is provided "as is" 00035 without express or implied warranty of any kind. 00036 00037 These notices must be retained in any copies of any part of this 00038 documentation and/or software. 00039 00040 */ 00041 00042 #ifndef MD5_HPP_INCLUDED 00043 #define MD5_HPP_INCLUDED 00044 00045 #include <boost/cstdint.hpp> 00046 00047 class MD5 { 00048 00049 public: 00050 // methods for controlled operation: 00051 MD5 (); // simple initializer 00052 void update (boost::uint8_t *input, boost::uint32_t input_length); 00053 void finalize (); 00054 00055 // methods to acquire finalized result 00056 boost::uint8_t *raw_digest (); // digest as a 16-byte binary array 00057 00058 00059 private: 00060 00061 // first, some types: 00062 typedef boost::uint32_t uint4; 00063 typedef boost::uint16_t uint2; 00064 typedef boost::uint8_t uint1; 00065 00066 // next, the private data: 00067 uint4 state[4]; 00068 uint4 count[2]; // number of *bits*, mod 2^64 00069 uint1 buffer[64]; // input buffer 00070 uint1 digest[16]; 00071 uint1 finalized; 00072 00073 // last, the private methods, mostly static: 00074 void init (); // called by all constructors 00075 void transform (uint1 buffer[64]); // does the real update work. Note 00076 // that length is implied to be 64. 00077 00078 static void encode (uint1 *dest, uint4 *src, uint4 length); 00079 static void decode (uint4 *dest, uint1 *src, uint4 length); 00080 00081 static inline uint4 rotate_left (uint4 x, uint4 n); 00082 static inline uint4 F (uint4 x, uint4 y, uint4 z); 00083 static inline uint4 G (uint4 x, uint4 y, uint4 z); 00084 static inline uint4 H (uint4 x, uint4 y, uint4 z); 00085 static inline uint4 I (uint4 x, uint4 y, uint4 z); 00086 static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 00087 uint4 s, uint4 ac); 00088 static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 00089 uint4 s, uint4 ac); 00090 static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 00091 uint4 s, uint4 ac); 00092 static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 00093 uint4 s, uint4 ac); 00094 00095 }; 00096 00097 #endif
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:05 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |