jigdo API
Last update by Admin on 2010-05-23
util/glibc-md5.hh
Go to the documentation of this file.00001 /* Declaration of functions and data types used for MD5 sum computing 00002 library functions. 00003 Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. 00004 This file is part of the GNU C Library. 00005 00006 The GNU C Library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public License as 00008 published by the Free Software Foundation; either version 2 of the 00009 License, or (at your option) any later version. 00010 00011 The GNU C Library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public 00017 License along with the GNU C Library; see the file COPYING.LIB. If not, 00018 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. */ 00020 00021 #ifndef _MD5_H 00022 #define _MD5_H 1 00023 00024 #include <stdio.h> 00025 00026 #if defined HAVE_LIMITS_H || _LIBC 00027 # include <limits.h> 00028 #endif 00029 00030 /* The following contortions are an attempt to use the C preprocessor 00031 to determine an unsigned integral type that is 32 bits wide. An 00032 alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but 00033 doing that would require that the configure script compile and *run* 00034 the resulting executable. Locally running cross-compiled executables 00035 is usually not possible. */ 00036 00037 #ifdef _LIBC 00038 # include <stdint.h> 00039 typedef uint32_t md5_uint32; 00040 typedef uintptr_t md5_uintptr; 00041 #else 00042 # if defined __STDC__ && __STDC__ 00043 # define UINT_MAX_32_BITS 4294967295U 00044 # else 00045 # define UINT_MAX_32_BITS 0xFFFFFFFF 00046 # endif 00047 00048 /* If UINT_MAX isn't defined, assume it's a 32-bit type. 00049 This should be valid for all systems GNU cares about because 00050 that doesn't include 16-bit systems, and only modern systems 00051 (that certainly have <limits.h>) have 64+-bit integral types. */ 00052 00053 # ifndef UINT_MAX 00054 # define UINT_MAX UINT_MAX_32_BITS 00055 # endif 00056 00057 # if UINT_MAX == UINT_MAX_32_BITS 00058 typedef unsigned int md5_uint32; 00059 # else 00060 # if USHRT_MAX == UINT_MAX_32_BITS 00061 typedef unsigned short md5_uint32; 00062 # else 00063 # if ULONG_MAX == UINT_MAX_32_BITS 00064 typedef unsigned long md5_uint32; 00065 # else 00066 /* The following line is intended to evoke an error. 00067 Using #error is not portable enough. */ 00068 "Cannot determine unsigned 32-bit data type." 00069 # endif 00070 # endif 00071 # endif 00072 /* We have to make a guess about the integer type equivalent in size 00073 to pointers which should always be correct. */ 00074 typedef unsigned long int md5_uintptr; 00075 #endif 00076 00077 #undef __P 00078 #if defined (__STDC__) && __STDC__ 00079 # define __P(x) x 00080 #else 00081 # define __P(x) () 00082 #endif 00083 00084 /* Structure to save state of computation between the single steps. */ 00085 /* [RA] moved this to md5sum.hh */ 00086 /* [RA] struct md5_ctx */ 00087 /* [RA] { */ 00088 /* [RA] uint32 A; */ 00089 /* [RA] uint32 B; */ 00090 /* [RA] uint32 C; */ 00091 /* [RA] uint32 D; */ 00092 /* [RA] */ 00093 /* [RA] uint32 total[2]; */ 00094 /* [RA] uint32 buflen; */ 00095 /* [RA] char buffer[128]; */ 00096 /* [RA] }; */ 00097 00098 /* 00099 * The following three functions are build up the low level used in 00100 * the functions `md5_stream' and `md5_buffer'. 00101 */ 00102 00103 /* Initialize structure containing state of computation. 00104 (RFC 1321, 3.3: Step 3) */ 00105 extern void md5_init_ctx __P ((struct md5_ctx *ctx)); 00106 /* [RA] extern void __md5_init_ctx __P ((struct md5_ctx *ctx)); */ 00107 00108 /* Starting with the result of former calls of this function (or the 00109 initialization function update the context for the next LEN bytes 00110 starting at BUFFER. 00111 It is necessary that LEN is a multiple of 64!!! */ 00112 extern void md5_process_block __P ((const void *buffer, size_t len, 00113 struct md5_ctx *ctx)); 00114 /* [RA] extern void __md5_process_block __P ((const void *buffer, size_t len, */ 00115 /* [RA] struct md5_ctx *ctx)); */ 00116 00117 /* Starting with the result of former calls of this function (or the 00118 initialization function update the context for the next LEN bytes 00119 starting at BUFFER. 00120 It is NOT required that LEN is a multiple of 64. */ 00121 extern void md5_process_bytes __P ((const void *buffer, size_t len, 00122 struct md5_ctx *ctx)); 00123 /* [RA] extern void __md5_process_bytes __P ((const void *buffer, size_t len, */ 00124 /* [RA] struct md5_ctx *ctx)); */ 00125 00126 /* Process the remaining bytes in the buffer and put result from CTX 00127 in first 16 bytes following RESBUF. The result is always in little 00128 endian byte order, so that a byte-wise output yields to the wanted 00129 ASCII representation of the message digest. 00130 00131 IMPORTANT: On some systems it is required that RESBUF is correctly 00132 aligned for a 32 bits value. */ 00133 extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); 00134 /* [RA] extern void *__md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); */ 00135 00136 00137 /* Put result from CTX in first 16 bytes following RESBUF. The result is 00138 always in little endian byte order, so that a byte-wise output yields 00139 to the wanted ASCII representation of the message digest. 00140 00141 IMPORTANT: On some systems it is required that RESBUF is correctly 00142 aligned for a 32 bits value. */ 00143 extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); 00144 /* [RA] extern void *__md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); */ 00145 00146 00147 /* Compute MD5 message digest for bytes read from STREAM. The 00148 resulting message digest number will be written into the 16 bytes 00149 beginning at RESBLOCK. */ 00150 /* [RA] extern int __md5_stream __P ((FILE *stream, void *resblock)); */ 00151 00152 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The 00153 result is always in little endian byte order, so that a byte-wise 00154 output yields to the wanted ASCII representation of the message 00155 digest. */ 00156 /* [RA] extern void *__md5_buffer __P ((const char *buffer, size_t len, */ 00157 /* [RA] void *resblock)); */ 00158 00159 #endif /* md5.h */
Generated on Tue Sep 23 14:27:41 2008 for jigdo by
