Rev 44128 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
/* md5.h - Declaration of functions and data types used for MD5 sumcomputing library functions.Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.NOTE: The canonical source of this file is maintained with the GNU CLibrary. Bugs can be reported to bug-glibc@prep.ai.mit.edu.This program is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation; either version 2, or (at your option) anylater version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free Software Foundation,Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/#ifndef R_MD5_H#define R_MD5_H 1#include <stdio.h>#if defined HAVE_LIMITS_H || _LIBC# include <limits.h>#endif/* The following contortions are an attempt to use the C preprocessorto determine an unsigned integral type that is 32 bits wide. Analternative approach is to use autoconf's AC_CHECK_SIZEOF macro, butdoing that would require that the configure script compile and *run*the resulting executable. Locally running cross-compiled executablesis usually not possible. */#ifdef _LIBC# include <sys/types.h>typedef u_int32_t md5_uint32;#else# if defined __STDC__ && __STDC__# define UINT_MAX_32_BITS 4294967295U# else# define UINT_MAX_32_BITS 0xFFFFFFFF# endif/* If UINT_MAX isn't defined, assume it's a 32-bit type.This should be valid for all systems GNU cares about becausethat doesn't include 16-bit systems, and only modern systems(that certainly have <limits.h>) have 64+-bit integral types. */# ifndef UINT_MAX# define UINT_MAX UINT_MAX_32_BITS# endif# if UINT_MAX == UINT_MAX_32_BITStypedef unsigned int md5_uint32;# else# if USHRT_MAX == UINT_MAX_32_BITStypedef unsigned short md5_uint32;# else# if ULONG_MAX == UINT_MAX_32_BITStypedef unsigned long md5_uint32;# else/* The following line is intended to evoke an error.Using #error is not portable enough. */"Cannot determine unsigned 32-bit data type."# endif# endif# endif#endif#undef __P#if defined (__STDC__) && __STDC__#define __P(x) x#else#define __P(x) ()#endif/* Structure to save state of computation between the single steps. */struct md5_ctx{md5_uint32 A;md5_uint32 B;md5_uint32 C;md5_uint32 D;md5_uint32 total[2];md5_uint32 buflen;char buffer[128];};/** The following three functions are build up the low level used in* the functions `md5_stream' and `md5_buffer'.*//* Compute MD5 message digest for bytes read from STREAM. Theresulting message digest number will be written into the 16 bytesbeginning at RESBLOCK. */extern int md5_stream __P ((FILE *stream, void *resblock));/* same as above for a buffer instead of file; returns resblock on success */extern void* md5_buffer __P ((const char *buffer, size_t len, void *resblock));#ifndef ROL_UNUSED/* The following is from gnupg-1.0.2's cipher/bithelp.h. *//* Rotate a 32 bit integer by n bytes */#if defined __GNUC__ && defined __i386__static md5_uint32rol(md5_uint32 x, int n){__asm__("roll %%cl,%0":"=r" (x):"0" (x),"c" (n));return x;}#else# define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )#endif#endif#endif /* R_MD5_H */