src/network/md5.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 
00007 This file was taken from GNU-Ghostscript from Aladdin Enterprises; original
00008 header and copyright notice follow. As I interpret the copyright and licensing
00009 statement, it would be OK to keep this code even for non-GPL distribution.
00010 ( may be needed sometime if third party, non-Free code gets integrated )
00011 
00012 **************************************************************************
00013 
00014 This program is free software; you can redistribute it and/or
00015 modify it under the terms of the GNU General Public License
00016 as published by the Free Software Foundation; either version 2
00017 of the License, or (at your option) any later version.
00018 
00019 This program is distributed in the hope that it will be useful,
00020 but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License
00025 along with this program; if not, write to the Free Software
00026 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00027   
00028 ***************************************************************************
00029 
00030 */
00031 
00032 
00033 /*
00034   Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
00035 
00036   This software is provided 'as-is', without any express or implied
00037   warranty.  In no event will the authors be held liable for any damages
00038   arising from the use of this software.
00039 
00040   Permission is granted to anyone to use this software for any purpose,
00041   including commercial applications, and to alter it and redistribute it
00042   freely, subject to the following restrictions:
00043 
00044   1. The origin of this software must not be misrepresented; you must not
00045      claim that you wrote the original software. If you use this software
00046      in a product, an acknowledgment in the product documentation would be
00047      appreciated but is not required.
00048   2. Altered source versions must be plainly marked as such, and must not be
00049      misrepresented as being the original software.
00050   3. This notice may not be removed or altered from any source distribution.
00051 
00052   L. Peter Deutsch
00053   ghost@aladdin.com
00054 
00055  */
00056 /*$RCSfile$ $Revision: 5868 $ */
00057 /*
00058   Independent implementation of MD5 (RFC 1321).
00059 
00060   This code implements the MD5 Algorithm defined in RFC 1321.
00061   It is derived directly from the text of the RFC and not from the
00062   reference implementation.
00063 
00064   The original and principal author of md5.h is L. Peter Deutsch
00065   <ghost@aladdin.com>.  Other authors are noted in the change history
00066   that follows (in reverse chronological order):
00067 
00068   1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
00069   1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
00070         added conditionalization for C++ compilation from Martin
00071         Purschke <purschke@bnl.gov>.
00072   1999-05-03 lpd Original version.
00073  */
00074 
00075 #ifndef md5_INCLUDED
00076 #  define md5_INCLUDED
00077 
00078 /*
00079  * This code has some adaptations for the Ghostscript environment, but it
00080  * will compile and run correctly in any environment with 8-bit chars and
00081  * 32-bit ints.  Specifically, it assumes that if the following are
00082  * defined, they have the same meaning as in Ghostscript: P1, P2, P3,
00083  * ARCH_IS_BIG_ENDIAN.
00084  */
00085 
00086 typedef unsigned char md5_byte_t; /* 8-bit byte */
00087 typedef unsigned int md5_word_t; /* 32-bit word */
00088 
00089 /* Define the state of the MD5 Algorithm. */
00090 typedef struct md5_state_s {
00091     md5_word_t count[2];        /* message length in bits, lsw first */
00092     md5_word_t abcd[4];         /* digest buffer */
00093     md5_byte_t buf[64];         /* accumulate block */
00094 } md5_state_t;
00095 
00096 #ifdef __cplusplus
00097 extern "C"
00098 {
00099 #endif
00100 
00101     /* Initialize the algorithm. */
00102 #ifdef P1
00103     void md5_init(P1(md5_state_t *pms));
00104 #else
00105     void md5_init(md5_state_t *pms);
00106 #endif
00107 
00108     /* Append a string to the message. */
00109 #ifdef P3
00110     void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
00111 #else
00112     void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
00113 #endif
00114 
00115     /* Finish the message and return the digest. */
00116 #ifdef P2
00117     void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
00118 #else
00119     void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
00120 #endif
00121 
00122 #ifdef __cplusplus
00123 }  /* end extern "C" */
00124 #endif
00125 
00126 #endif /* md5_INCLUDED */

Generated on Sat Mar 15 22:55:49 2008 for Armagetron Advanced by  doxygen 1.5.4