00001 // this is part of tacppd project 00002 // (c) Copyright in 2000-2004 by tacppd team and contributors 00003 // see http://tacppd.org for more information 00004 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 /* 00020 Copyright (c) 1995-1998 by Cisco systems, Inc. 00021 00022 Permission to use, copy, modify, and distribute this software for 00023 any purpose and without fee is hereby granted, provided that this 00024 copyright and permission notice appear on all copies of the 00025 software and supporting documentation, the name of Cisco Systems, 00026 Inc. not be used in advertising or publicity pertaining to 00027 distribution of the program without specific prior permission, and 00028 notice be given in supporting documentation that modification, 00029 copying and distribution is by permission of Cisco Systems, Inc. 00030 00031 Cisco Systems, Inc. makes no representations about the suitability 00032 of this software for any purpose. THIS SOFTWARE IS PROVIDED ``AS 00033 IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 00034 WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00035 FITNESS FOR A PARTICULAR PURPOSE. 00036 */ 00037 00038 /* 00039 * MD5.H - header file for MD5C.C 00040 */ 00041 00042 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 00043 * rights reserved. 00044 * 00045 * License to copy and use this software is granted provided that it 00046 * is identified as the "RSA Data Security, Inc. MD5 Message-Digest 00047 * Algorithm" in all material mentioning or referencing this software 00048 * or this function. 00049 * 00050 * License is also granted to make and use derivative works provided 00051 * that such works are identified as "derived from the RSA Data 00052 * Security, Inc. MD5 Message-Digest Algorithm" in all material 00053 * mentioning or referencing the derived work. 00054 * 00055 * RSA Data Security, Inc. makes no representations concerning either 00056 * the merchantability of this software or the suitability of this 00057 * software for any particular purpose. It is provided "as is" 00058 * without express or implied warranty of any kind. 00059 * 00060 * These notices must be retained in any copies of any part of this 00061 * documentation and/or software. 00062 */ 00063 00064 // Some changes to use with C++ compiler in tacacs++ project 00065 // added by Roman Volkov 00066 00067 #ifndef __MD5_H__ 00068 #define __MD5_H__ 00069 00070 #define MD5_LEN 16 00071 //#include <string.h> 00072 00073 namespace tacpp { 00074 00075 // typedef a 32-bit type 00076 typedef unsigned long int UINT4; 00077 00078 // typedef a generic pointer type 00079 typedef unsigned char *POINTER; 00080 00081 // MD5 context. 00082 typedef struct { 00083 UINT4 state[4]; // state (ABCD) 00084 UINT4 count[2]; // number of bits, modulo 2^64 (lsb first) 00085 unsigned char buffer[64]; // input buffer 00086 } MD5_CTX; 00087 00088 // md5 functions 00089 class md5 { 00090 pthread_mutex_t mutex_; 00091 void lock(); 00092 void unlock(); 00093 public: 00094 md5(); 00095 ~md5(); 00096 void MD5Init(MD5_CTX*); 00097 void MD5Update 00098 (MD5_CTX *, unsigned char *, unsigned int); 00099 void MD5Final 00100 (unsigned char [16], MD5_CTX *); 00101 void MD5_memset(POINTER,int,unsigned int); 00102 void MD5_memcpy(POINTER,POINTER,unsigned int); 00103 void Decode(UINT4*,unsigned char*,unsigned int); 00104 void Encode(unsigned char*,UINT4*,unsigned int); 00105 void MD5Transform (UINT4 state[4],unsigned char block[64]); 00106 00107 //void create_md5_hash(unsigned char*,unsigned char*,unsigned char*); 00108 //void md5_xor(unsigned char*,unsigned char*); 00109 }; 00110 00111 }; 00112 00113 #endif //__MD5_H__