Blender  V2.59
md5.h
Go to the documentation of this file.
00001 
00004 /* md5.h - Declaration of functions and data types used for MD5 sum
00005    computing library functions.
00006    Copyright (C) 1995 Free Software Foundation, Inc.
00007 
00008 This program is free software; you can redistribute it and/or modify
00009 it under the terms of the GNU General Public License as published by
00010 the Free Software Foundation; either version 2, or (at your option)
00011 any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00021 
00022 #ifndef _MD5_H
00023 #define _MD5_H
00024 
00025 #include <stdio.h>
00026 
00027 #if defined HAVE_LIMITS_H || defined _LIBC
00028 # include <limits.h>
00029 #endif
00030 
00031 /* The following contortions are an attempt to use the C preprocessor
00032    to determine an unsigned integral type that is 32 bits wide.  An
00033    alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
00034    doing that would require that the configure script compile and *run*
00035    the resulting executable.  Locally running cross-compiled executables
00036    is usually not possible.  */
00037 
00038 #if defined __STDC__ && __STDC__
00039 # define UINT_MAX_32_BITS 4294967295U
00040 #else
00041 # define UINT_MAX_32_BITS 0xFFFFFFFF
00042 #endif
00043 
00044 /* If UINT_MAX isn't defined, assume it's a 32-bit type.
00045    This should be valid for all systems GNU cares about because
00046    that doesn't include 16-bit systems, and only modern systems
00047    (that certainly have <limits.h>) have 64+-bit integral types.  */
00048 
00049 #ifndef UINT_MAX
00050 # define UINT_MAX UINT_MAX_32_BITS
00051 #endif
00052 
00053 #if UINT_MAX == UINT_MAX_32_BITS
00054   typedef unsigned int md5_uint32;
00055 #else
00056 # if USHRT_MAX == UINT_MAX_32_BITS
00057    typedef unsigned short md5_uint32;
00058 # else
00059 #  if ULONG_MAX == UINT_MAX_32_BITS
00060         typedef unsigned long md5_uint32;
00061 #  else
00062         /* The following line is intended to evoke an error.
00063            Using #error is not portable enough.  */
00064         "Cannot determine unsigned 32-bit data type."
00065 #  endif
00066 # endif
00067 #endif
00068 
00069 #undef __P
00070 #if defined (__STDC__) && __STDC__
00071 #define __P(x) x
00072 #else
00073 #define __P(x) ()
00074 #endif
00075 
00076 /* Structure to save state of computation between the single steps.  */
00077 struct md5_ctx
00078 {
00079   md5_uint32 A;
00080   md5_uint32 B;
00081   md5_uint32 C;
00082   md5_uint32 D;
00083 };
00084 
00085 /*
00086  * The following three functions are build up the low level used in
00087  * the functions `md5_stream' and `md5_buffer'.
00088  */
00089 
00090 /* Initialize structure containing state of computation.
00091    (RFC 1321, 3.3: Step 3)  */
00092 void md5_init_ctx __P ((struct md5_ctx *ctx));
00093 
00094 /* Starting with the result of former calls of this function (or the
00095    initialzation function update the context for the next LEN bytes
00096    starting at BUFFER.
00097    It is necessary that LEN is a multiple of 64!!! */
00098 void md5_process_block __P ((const void *buffer, size_t len,
00099                                  struct md5_ctx *ctx));
00100 
00101 /* Put result from CTX in first 16 bytes following RESBUF.  The result is
00102    always in little endian byte order, so that a byte-wise output yields
00103    to the wanted ASCII representation of the message digest.  */
00104 void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
00105 
00106 
00107 /* Compute MD5 message digest for bytes read from STREAM.  The
00108    resulting message digest number will be written into the 16 bytes
00109    beginning at RESBLOCK.  */
00110 int md5_stream __P ((FILE *stream, void *resblock));
00111 
00112 /* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
00113    result is always in little endian byte order, so that a byte-wise
00114    output yields to the wanted ASCII representation of the message
00115    digest.  */
00116 void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
00117 
00118 #endif
00119