Blender V2.27

md5.h

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