masqmail-0.2

changeset 162:52c82d755215

replaced the MD5 implementation with the one of Solar Designer Until now, the sample code of RFC 1321 was used. It had an ugly license. Now we use the implementation of Solar Designer, which is in the Public Domain. http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
author meillo@marmaro.de
date Sun, 18 Jul 2010 22:01:04 +0200
parents 6655f7708ee1
children 06525982a56c
files configure configure.ac src/md5/Makefile.am src/md5/Makefile.in src/md5/global.h src/md5/hmac_md5.c src/md5/hmactest.c src/md5/md5.c src/md5/md5.h src/md5/md5c.c src/pop3_in.c src/smtp_out.c
diffstat 12 files changed, 335 insertions(+), 439 deletions(-) [+]
line diff
     1.1 --- a/configure	Sun Jul 18 10:48:14 2010 +0200
     1.2 +++ b/configure	Sun Jul 18 22:01:04 2010 +0200
     1.3 @@ -5197,7 +5197,6 @@
     1.4  
     1.5  $as_echo "#define ENABLE_POP3 1" >>confdefs.h
     1.6  
     1.7 -#	MD5_LIBS='md5/libmd5c.a'
     1.8  	need_md5='yes'
     1.9  fi
    1.10  
    1.11 @@ -5213,7 +5212,6 @@
    1.12  $as_echo "#define ENABLE_AUTH 1" >>confdefs.h
    1.13  
    1.14  	BASE64_LIBS='base64/libbase64.a'
    1.15 -#	MD5_LIBS='md5/libmd5c.a'
    1.16  	need_md5='yes'
    1.17  fi
    1.18  
    1.19 @@ -5292,7 +5290,7 @@
    1.20  			MD5_LIBS='-lcrypto'
    1.21  		fi
    1.22  	else
    1.23 -		MD5_LIBS='md5/libmd5c.a'
    1.24 +		MD5_LIBS='md5/libmd5.a'
    1.25  	fi
    1.26  fi
    1.27  
     2.1 --- a/configure.ac	Sun Jul 18 10:48:14 2010 +0200
     2.2 +++ b/configure.ac	Sun Jul 18 22:01:04 2010 +0200
     2.3 @@ -150,7 +150,6 @@
     2.4  	)
     2.5  if test "x$pop3_enabled" = xyes; then
     2.6  	AC_DEFINE(ENABLE_POP3, 1, [If the POP3 support is enabled])
     2.7 -#	MD5_LIBS='md5/libmd5c.a'
     2.8  	need_md5='yes'
     2.9  fi
    2.10  
    2.11 @@ -164,7 +163,6 @@
    2.12  if test "x$auth_enabled" = xyes; then
    2.13  	AC_DEFINE(ENABLE_AUTH, 1, [If AUTH is enabled])
    2.14  	BASE64_LIBS='base64/libbase64.a'
    2.15 -#	MD5_LIBS='md5/libmd5c.a'
    2.16  	need_md5='yes'
    2.17  fi
    2.18  AC_SUBST(BASE64_LIBS)
    2.19 @@ -197,7 +195,7 @@
    2.20  			MD5_LIBS='-lcrypto'
    2.21  		fi
    2.22  	else
    2.23 -		MD5_LIBS='md5/libmd5c.a'
    2.24 +		MD5_LIBS='md5/libmd5.a'
    2.25  	fi
    2.26  fi
    2.27  AC_SUBST(MD5_LIBS)
     3.1 --- a/src/md5/Makefile.am	Sun Jul 18 10:48:14 2010 +0200
     3.2 +++ b/src/md5/Makefile.am	Sun Jul 18 22:01:04 2010 +0200
     3.3 @@ -1,19 +1,17 @@
     3.4  AM_CFLAGS=@CFLAGS@ @GLIB_CFLAGS@ -D_GNU_SOURCE
     3.5  
     3.6 -noinst_LIBRARIES=libmd5c.a
     3.7 +noinst_LIBRARIES=libmd5.a
     3.8  noinst_PROGRAMS=hmactest
     3.9  
    3.10  hmactest_SOURCES=\
    3.11  	md5.h\
    3.12 -	global.h\
    3.13 -	md5c.c\
    3.14 +	md5.c\
    3.15  	hmac_md5.h\
    3.16  	hmac_md5.c\
    3.17  	hmactest.c
    3.18  
    3.19 -libmd5c_a_SOURCES=\
    3.20 +libmd5_a_SOURCES=\
    3.21  	md5.h\
    3.22 -	global.h\
    3.23 -	md5c.c\
    3.24 +	md5.c\
    3.25  	hmac_md5.h\
    3.26 -	hmac_md5.c
    3.27 \ No newline at end of file
    3.28 +	hmac_md5.c
     4.1 --- a/src/md5/Makefile.in	Sun Jul 18 10:48:14 2010 +0200
     4.2 +++ b/src/md5/Makefile.in	Sun Jul 18 22:01:04 2010 +0200
     4.3 @@ -47,12 +47,12 @@
     4.4  LIBRARIES = $(noinst_LIBRARIES)
     4.5  AR = ar
     4.6  ARFLAGS = cru
     4.7 -libmd5c_a_AR = $(AR) $(ARFLAGS)
     4.8 -libmd5c_a_LIBADD =
     4.9 -am_libmd5c_a_OBJECTS = md5c.$(OBJEXT) hmac_md5.$(OBJEXT)
    4.10 -libmd5c_a_OBJECTS = $(am_libmd5c_a_OBJECTS)
    4.11 +libmd5_a_AR = $(AR) $(ARFLAGS)
    4.12 +libmd5_a_LIBADD =
    4.13 +am_libmd5_a_OBJECTS = md5.$(OBJEXT) hmac_md5.$(OBJEXT)
    4.14 +libmd5_a_OBJECTS = $(am_libmd5_a_OBJECTS)
    4.15  PROGRAMS = $(noinst_PROGRAMS)
    4.16 -am_hmactest_OBJECTS = md5c.$(OBJEXT) hmac_md5.$(OBJEXT) \
    4.17 +am_hmactest_OBJECTS = md5.$(OBJEXT) hmac_md5.$(OBJEXT) \
    4.18  	hmactest.$(OBJEXT)
    4.19  hmactest_OBJECTS = $(am_hmactest_OBJECTS)
    4.20  hmactest_LDADD = $(LDADD)
    4.21 @@ -64,8 +64,8 @@
    4.22  	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
    4.23  CCLD = $(CC)
    4.24  LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
    4.25 -SOURCES = $(libmd5c_a_SOURCES) $(hmactest_SOURCES)
    4.26 -DIST_SOURCES = $(libmd5c_a_SOURCES) $(hmactest_SOURCES)
    4.27 +SOURCES = $(libmd5_a_SOURCES) $(hmactest_SOURCES)
    4.28 +DIST_SOURCES = $(libmd5_a_SOURCES) $(hmactest_SOURCES)
    4.29  ETAGS = etags
    4.30  CTAGS = ctags
    4.31  DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    4.32 @@ -174,19 +174,17 @@
    4.33  with_spooldir = @with_spooldir@
    4.34  with_user = @with_user@
    4.35  AM_CFLAGS = @CFLAGS@ @GLIB_CFLAGS@ -D_GNU_SOURCE
    4.36 -noinst_LIBRARIES = libmd5c.a
    4.37 +noinst_LIBRARIES = libmd5.a
    4.38  hmactest_SOURCES = \
    4.39  	md5.h\
    4.40 -	global.h\
    4.41 -	md5c.c\
    4.42 +	md5.c\
    4.43  	hmac_md5.h\
    4.44  	hmac_md5.c\
    4.45  	hmactest.c
    4.46  
    4.47 -libmd5c_a_SOURCES = \
    4.48 +libmd5_a_SOURCES = \
    4.49  	md5.h\
    4.50 -	global.h\
    4.51 -	md5c.c\
    4.52 +	md5.c\
    4.53  	hmac_md5.h\
    4.54  	hmac_md5.c
    4.55  
    4.56 @@ -227,10 +225,10 @@
    4.57  
    4.58  clean-noinstLIBRARIES:
    4.59  	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
    4.60 -libmd5c.a: $(libmd5c_a_OBJECTS) $(libmd5c_a_DEPENDENCIES) 
    4.61 -	-rm -f libmd5c.a
    4.62 -	$(libmd5c_a_AR) libmd5c.a $(libmd5c_a_OBJECTS) $(libmd5c_a_LIBADD)
    4.63 -	$(RANLIB) libmd5c.a
    4.64 +libmd5.a: $(libmd5_a_OBJECTS) $(libmd5_a_DEPENDENCIES) 
    4.65 +	-rm -f libmd5.a
    4.66 +	$(libmd5_a_AR) libmd5.a $(libmd5_a_OBJECTS) $(libmd5_a_LIBADD)
    4.67 +	$(RANLIB) libmd5.a
    4.68  
    4.69  clean-noinstPROGRAMS:
    4.70  	-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
    4.71 @@ -246,7 +244,7 @@
    4.72  
    4.73  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hmac_md5.Po@am__quote@
    4.74  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hmactest.Po@am__quote@
    4.75 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5c.Po@am__quote@
    4.76 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@
    4.77  
    4.78  .c.o:
    4.79  @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
     5.1 --- a/src/md5/global.h	Sun Jul 18 10:48:14 2010 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,30 +0,0 @@
     5.4 -/* GLOBAL.H - RSAREF types and constants
     5.5 - */
     5.6 -
     5.7 -/* PROTOTYPES should be set to one if and only if the compiler supports
     5.8 -   function argument prototyping.
     5.9 -   The following makes PROTOTYPES default to 0 if it has not already
    5.10 -   been defined with C compiler flags.
    5.11 - */
    5.12 -#ifndef PROTOTYPES
    5.13 -#define PROTOTYPES 0
    5.14 -#endif
    5.15 -
    5.16 -/* POINTER defines a generic pointer type */
    5.17 -typedef unsigned char *POINTER;
    5.18 -
    5.19 -/* UINT2 defines a two byte word */
    5.20 -typedef unsigned short int UINT2;
    5.21 -
    5.22 -/* UINT4 defines a four byte word */
    5.23 -typedef unsigned long int UINT4;
    5.24 -
    5.25 -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
    5.26 -If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
    5.27 -  returns an empty list.
    5.28 - */
    5.29 -#if PROTOTYPES
    5.30 -#define PROTO_LIST(list) list
    5.31 -#else
    5.32 -#define PROTO_LIST(list) ()
    5.33 -#endif
     6.1 --- a/src/md5/hmac_md5.c	Sun Jul 18 10:48:14 2010 +0200
     6.2 +++ b/src/md5/hmac_md5.c	Sun Jul 18 22:01:04 2010 +0200
     6.3 @@ -3,7 +3,6 @@
     6.4  */
     6.5  
     6.6  #include <string.h>
     6.7 -#include "global.h"
     6.8  #include "md5.h"
     6.9  #include "hmac_md5.h"
    6.10  
    6.11 @@ -25,9 +24,9 @@
    6.12  
    6.13  		MD5_CTX tctx;
    6.14  
    6.15 -		MD5Init(&tctx);
    6.16 -		MD5Update(&tctx, key, key_len);
    6.17 -		MD5Final(tk, &tctx);
    6.18 +		MD5_Init(&tctx);
    6.19 +		MD5_Update(&tctx, key, key_len);
    6.20 +		MD5_Final(tk, &tctx);
    6.21  
    6.22  		key = tk;
    6.23  		key_len = 16;
    6.24 @@ -58,15 +57,15 @@
    6.25  	/*
    6.26  	 * perform inner MD5
    6.27  	 */
    6.28 -	MD5Init(&context);  /* init context for 1st pass */
    6.29 -	MD5Update(&context, k_ipad, 64);  /* start with inner pad */
    6.30 -	MD5Update(&context, text, text_len);  /* then text of datagram */
    6.31 -	MD5Final(digest, &context);  /* finish up 1st pass */
    6.32 +	MD5_Init(&context);  /* init context for 1st pass */
    6.33 +	MD5_Update(&context, k_ipad, 64);  /* start with inner pad */
    6.34 +	MD5_Update(&context, text, text_len);  /* then text of datagram */
    6.35 +	MD5_Final(digest, &context);  /* finish up 1st pass */
    6.36  	/*
    6.37  	 * perform outer MD5
    6.38  	 */
    6.39 -	MD5Init(&context);  /* init context for 2nd pass */
    6.40 -	MD5Update(&context, k_opad, 64);  /* start with outer pad */
    6.41 -	MD5Update(&context, digest, 16);  /* then results of 1st hash */
    6.42 -	MD5Final(digest, &context); /* finish up 2nd pass */
    6.43 +	MD5_Init(&context);  /* init context for 2nd pass */
    6.44 +	MD5_Update(&context, k_opad, 64);  /* start with outer pad */
    6.45 +	MD5_Update(&context, digest, 16);  /* then results of 1st hash */
    6.46 +	MD5_Final(digest, &context); /* finish up 2nd pass */
    6.47  }
     7.1 --- a/src/md5/hmactest.c	Sun Jul 18 10:48:14 2010 +0200
     7.2 +++ b/src/md5/hmactest.c	Sun Jul 18 22:01:04 2010 +0200
     7.3 @@ -2,7 +2,6 @@
     7.4  #include <stdlib.h>
     7.5  #include <sys/time.h>
     7.6  #include <string.h>
     7.7 -#include "global.h"
     7.8  #include "md5.h"
     7.9  #include "hmac_md5.h"
    7.10  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/md5/md5.c	Sun Jul 18 22:01:04 2010 +0200
     8.3 @@ -0,0 +1,275 @@
     8.4 +/*
     8.5 + * This is an OpenSSL-compatible implementation of the RSA Data Security,
     8.6 + * Inc. MD5 Message-Digest Algorithm (RFC 1321).
     8.7 + *
     8.8 + * Written by Solar Designer <solar at openwall.com> in 2001, and placed
     8.9 + * in the public domain.  There's absolutely no warranty.
    8.10 + *
    8.11 + * This differs from Colin Plumb's older public domain implementation in
    8.12 + * that no 32-bit integer data type is required, there's no compile-time
    8.13 + * endianness configuration, and the function prototypes match OpenSSL's.
    8.14 + * The primary goals are portability and ease of use.
    8.15 + *
    8.16 + * This implementation is meant to be fast, but not as fast as possible.
    8.17 + * Some known optimizations are not included to reduce source code size
    8.18 + * and avoid compile-time configuration.
    8.19 + */
    8.20 +
    8.21 +#ifndef HAVE_OPENSSL
    8.22 +
    8.23 +#include <string.h>
    8.24 +
    8.25 +#include "md5.h"
    8.26 +
    8.27 +/*
    8.28 + * The basic MD5 functions.
    8.29 + *
    8.30 + * F and G are optimized compared to their RFC 1321 definitions for
    8.31 + * architectures that lack an AND-NOT instruction, just like in Colin Plumb's
    8.32 + * implementation.
    8.33 + */
    8.34 +#define F(x, y, z)			((z) ^ ((x) & ((y) ^ (z))))
    8.35 +#define G(x, y, z)			((y) ^ ((z) & ((x) ^ (y))))
    8.36 +#define H(x, y, z)			((x) ^ (y) ^ (z))
    8.37 +#define I(x, y, z)			((y) ^ ((x) | ~(z)))
    8.38 +
    8.39 +/*
    8.40 + * The MD5 transformation for all four rounds.
    8.41 + */
    8.42 +#define STEP(f, a, b, c, d, x, t, s) \
    8.43 +	(a) += f((b), (c), (d)) + (x) + (t); \
    8.44 +	(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
    8.45 +	(a) += (b);
    8.46 +
    8.47 +/*
    8.48 + * SET reads 4 input bytes in little-endian byte order and stores them
    8.49 + * in a properly aligned word in host byte order.
    8.50 + *
    8.51 + * The check for little-endian architectures that tolerate unaligned
    8.52 + * memory accesses is just an optimization.  Nothing will break if it
    8.53 + * doesn't work.
    8.54 + */
    8.55 +#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
    8.56 +#define SET(n) \
    8.57 +	(*(MD5_u32plus *)&ptr[(n) * 4])
    8.58 +#define GET(n) \
    8.59 +	SET(n)
    8.60 +#else
    8.61 +#define SET(n) \
    8.62 +	(ctx->block[(n)] = \
    8.63 +	(MD5_u32plus)ptr[(n) * 4] | \
    8.64 +	((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
    8.65 +	((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
    8.66 +	((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
    8.67 +#define GET(n) \
    8.68 +	(ctx->block[(n)])
    8.69 +#endif
    8.70 +
    8.71 +/*
    8.72 + * This processes one or more 64-byte data blocks, but does NOT update
    8.73 + * the bit counters.  There are no alignment requirements.
    8.74 + */
    8.75 +static void *body(MD5_CTX *ctx, void *data, unsigned long size)
    8.76 +{
    8.77 +	unsigned char *ptr;
    8.78 +	MD5_u32plus a, b, c, d;
    8.79 +	MD5_u32plus saved_a, saved_b, saved_c, saved_d;
    8.80 +
    8.81 +	ptr = data;
    8.82 +
    8.83 +	a = ctx->a;
    8.84 +	b = ctx->b;
    8.85 +	c = ctx->c;
    8.86 +	d = ctx->d;
    8.87 +
    8.88 +	do {
    8.89 +		saved_a = a;
    8.90 +		saved_b = b;
    8.91 +		saved_c = c;
    8.92 +		saved_d = d;
    8.93 +
    8.94 +/* Round 1 */
    8.95 +		STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
    8.96 +		STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
    8.97 +		STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
    8.98 +		STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
    8.99 +		STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
   8.100 +		STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
   8.101 +		STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
   8.102 +		STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
   8.103 +		STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
   8.104 +		STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
   8.105 +		STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
   8.106 +		STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
   8.107 +		STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
   8.108 +		STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
   8.109 +		STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
   8.110 +		STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
   8.111 +
   8.112 +/* Round 2 */
   8.113 +		STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
   8.114 +		STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
   8.115 +		STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
   8.116 +		STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
   8.117 +		STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
   8.118 +		STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
   8.119 +		STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
   8.120 +		STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
   8.121 +		STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
   8.122 +		STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
   8.123 +		STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
   8.124 +		STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
   8.125 +		STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
   8.126 +		STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
   8.127 +		STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
   8.128 +		STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
   8.129 +
   8.130 +/* Round 3 */
   8.131 +		STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
   8.132 +		STEP(H, d, a, b, c, GET(8), 0x8771f681, 11)
   8.133 +		STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
   8.134 +		STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23)
   8.135 +		STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
   8.136 +		STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11)
   8.137 +		STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
   8.138 +		STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23)
   8.139 +		STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
   8.140 +		STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11)
   8.141 +		STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
   8.142 +		STEP(H, b, c, d, a, GET(6), 0x04881d05, 23)
   8.143 +		STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
   8.144 +		STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11)
   8.145 +		STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
   8.146 +		STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23)
   8.147 +
   8.148 +/* Round 4 */
   8.149 +		STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
   8.150 +		STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
   8.151 +		STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
   8.152 +		STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
   8.153 +		STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
   8.154 +		STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
   8.155 +		STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
   8.156 +		STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
   8.157 +		STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
   8.158 +		STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
   8.159 +		STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
   8.160 +		STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
   8.161 +		STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
   8.162 +		STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
   8.163 +		STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
   8.164 +		STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
   8.165 +
   8.166 +		a += saved_a;
   8.167 +		b += saved_b;
   8.168 +		c += saved_c;
   8.169 +		d += saved_d;
   8.170 +
   8.171 +		ptr += 64;
   8.172 +	} while (size -= 64);
   8.173 +
   8.174 +	ctx->a = a;
   8.175 +	ctx->b = b;
   8.176 +	ctx->c = c;
   8.177 +	ctx->d = d;
   8.178 +
   8.179 +	return ptr;
   8.180 +}
   8.181 +
   8.182 +void MD5_Init(MD5_CTX *ctx)
   8.183 +{
   8.184 +	ctx->a = 0x67452301;
   8.185 +	ctx->b = 0xefcdab89;
   8.186 +	ctx->c = 0x98badcfe;
   8.187 +	ctx->d = 0x10325476;
   8.188 +
   8.189 +	ctx->lo = 0;
   8.190 +	ctx->hi = 0;
   8.191 +}
   8.192 +
   8.193 +void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size)
   8.194 +{
   8.195 +	MD5_u32plus saved_lo;
   8.196 +	unsigned long used, free;
   8.197 +
   8.198 +	saved_lo = ctx->lo;
   8.199 +	if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
   8.200 +		ctx->hi++;
   8.201 +	ctx->hi += size >> 29;
   8.202 +
   8.203 +	used = saved_lo & 0x3f;
   8.204 +
   8.205 +	if (used) {
   8.206 +		free = 64 - used;
   8.207 +
   8.208 +		if (size < free) {
   8.209 +			memcpy(&ctx->buffer[used], data, size);
   8.210 +			return;
   8.211 +		}
   8.212 +
   8.213 +		memcpy(&ctx->buffer[used], data, free);
   8.214 +		data = (unsigned char *)data + free;
   8.215 +		size -= free;
   8.216 +		body(ctx, ctx->buffer, 64);
   8.217 +	}
   8.218 +
   8.219 +	if (size >= 64) {
   8.220 +		data = body(ctx, data, size & ~(unsigned long)0x3f);
   8.221 +		size &= 0x3f;
   8.222 +	}
   8.223 +
   8.224 +	memcpy(ctx->buffer, data, size);
   8.225 +}
   8.226 +
   8.227 +void MD5_Final(unsigned char *result, MD5_CTX *ctx)
   8.228 +{
   8.229 +	unsigned long used, free;
   8.230 +
   8.231 +	used = ctx->lo & 0x3f;
   8.232 +
   8.233 +	ctx->buffer[used++] = 0x80;
   8.234 +
   8.235 +	free = 64 - used;
   8.236 +
   8.237 +	if (free < 8) {
   8.238 +		memset(&ctx->buffer[used], 0, free);
   8.239 +		body(ctx, ctx->buffer, 64);
   8.240 +		used = 0;
   8.241 +		free = 64;
   8.242 +	}
   8.243 +
   8.244 +	memset(&ctx->buffer[used], 0, free - 8);
   8.245 +
   8.246 +	ctx->lo <<= 3;
   8.247 +	ctx->buffer[56] = ctx->lo;
   8.248 +	ctx->buffer[57] = ctx->lo >> 8;
   8.249 +	ctx->buffer[58] = ctx->lo >> 16;
   8.250 +	ctx->buffer[59] = ctx->lo >> 24;
   8.251 +	ctx->buffer[60] = ctx->hi;
   8.252 +	ctx->buffer[61] = ctx->hi >> 8;
   8.253 +	ctx->buffer[62] = ctx->hi >> 16;
   8.254 +	ctx->buffer[63] = ctx->hi >> 24;
   8.255 +
   8.256 +	body(ctx, ctx->buffer, 64);
   8.257 +
   8.258 +	result[0] = ctx->a;
   8.259 +	result[1] = ctx->a >> 8;
   8.260 +	result[2] = ctx->a >> 16;
   8.261 +	result[3] = ctx->a >> 24;
   8.262 +	result[4] = ctx->b;
   8.263 +	result[5] = ctx->b >> 8;
   8.264 +	result[6] = ctx->b >> 16;
   8.265 +	result[7] = ctx->b >> 24;
   8.266 +	result[8] = ctx->c;
   8.267 +	result[9] = ctx->c >> 8;
   8.268 +	result[10] = ctx->c >> 16;
   8.269 +	result[11] = ctx->c >> 24;
   8.270 +	result[12] = ctx->d;
   8.271 +	result[13] = ctx->d >> 8;
   8.272 +	result[14] = ctx->d >> 16;
   8.273 +	result[15] = ctx->d >> 24;
   8.274 +
   8.275 +	memset(ctx, 0, sizeof(*ctx));
   8.276 +}
   8.277 +
   8.278 +#endif
     9.1 --- a/src/md5/md5.h	Sun Jul 18 10:48:14 2010 +0200
     9.2 +++ b/src/md5/md5.h	Sun Jul 18 22:01:04 2010 +0200
     9.3 @@ -1,35 +1,30 @@
     9.4 -/* MD5.H - header file for MD5C.C
     9.5 +/*
     9.6 + * This is an OpenSSL-compatible implementation of the RSA Data Security,
     9.7 + * Inc. MD5 Message-Digest Algorithm (RFC 1321).
     9.8 + *
     9.9 + * Written by Solar Designer <solar at openwall.com> in 2001, and placed
    9.10 + * in the public domain.  There's absolutely no warranty.
    9.11 + *
    9.12 + * See md5.c for more information.
    9.13   */
    9.14  
    9.15 -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
    9.16 -rights reserved.
    9.17 +#ifdef HAVE_OPENSSL
    9.18 +#include <openssl/md5.h>
    9.19 +#elif !defined(_MD5_H)
    9.20 +#define _MD5_H
    9.21  
    9.22 -License to copy and use this software is granted provided that it
    9.23 -is identified as the "RSA Data Security, Inc. MD5 Message-Digest
    9.24 -Algorithm" in all material mentioning or referencing this software
    9.25 -or this function.
    9.26 +/* Any 32-bit or wider unsigned integer data type will do */
    9.27 +typedef unsigned int MD5_u32plus;
    9.28  
    9.29 -License is also granted to make and use derivative works provided
    9.30 -that such works are identified as "derived from the RSA Data
    9.31 -Security, Inc. MD5 Message-Digest Algorithm" in all material
    9.32 -mentioning or referencing the derived work.
    9.33 -
    9.34 -RSA Data Security, Inc. makes no representations concerning either
    9.35 -the merchantability of this software or the suitability of this
    9.36 -software for any particular purpose. It is provided "as is"
    9.37 -without express or implied warranty of any kind.
    9.38 -
    9.39 -These notices must be retained in any copies of any part of this
    9.40 -documentation and/or software.
    9.41 - */
    9.42 -
    9.43 -/* MD5 context. */
    9.44  typedef struct {
    9.45 -	UINT4 state[4];  /* state (ABCD) */
    9.46 -	UINT4 count[2];  /* number of bits, modulo 2^64 (lsb first) */
    9.47 -	unsigned char buffer[64];  /* input buffer */
    9.48 +	MD5_u32plus lo, hi;
    9.49 +	MD5_u32plus a, b, c, d;
    9.50 +	unsigned char buffer[64];
    9.51 +	MD5_u32plus block[16];
    9.52  } MD5_CTX;
    9.53  
    9.54 -void MD5Init PROTO_LIST((MD5_CTX *));
    9.55 -void MD5Update PROTO_LIST((MD5_CTX *, unsigned char *, unsigned int));
    9.56 -void MD5Final PROTO_LIST((unsigned char[16], MD5_CTX *));
    9.57 +extern void MD5_Init(MD5_CTX *ctx);
    9.58 +extern void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size);
    9.59 +extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
    9.60 +
    9.61 +#endif
    10.1 --- a/src/md5/md5c.c	Sun Jul 18 10:48:14 2010 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,332 +0,0 @@
    10.4 -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
    10.5 - */
    10.6 -
    10.7 -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
    10.8 -rights reserved.
    10.9 -
   10.10 -License to copy and use this software is granted provided that it
   10.11 -is identified as the "RSA Data Security, Inc. MD5 Message-Digest
   10.12 -Algorithm" in all material mentioning or referencing this software
   10.13 -or this function.
   10.14 -
   10.15 -License is also granted to make and use derivative works provided
   10.16 -that such works are identified as "derived from the RSA Data
   10.17 -Security, Inc. MD5 Message-Digest Algorithm" in all material
   10.18 -mentioning or referencing the derived work.
   10.19 -
   10.20 -RSA Data Security, Inc. makes no representations concerning either
   10.21 -the merchantability of this software or the suitability of this
   10.22 -software for any particular purpose. It is provided "as is"
   10.23 -without express or implied warranty of any kind.
   10.24 -
   10.25 -These notices must be retained in any copies of any part of this
   10.26 -documentation and/or software.
   10.27 - */
   10.28 -
   10.29 -#include "global.h"
   10.30 -#include "md5.h"
   10.31 -
   10.32 -/* Constants for MD5Transform routine.
   10.33 - */
   10.34 -#define S11 7
   10.35 -#define S12 12
   10.36 -#define S13 17
   10.37 -#define S14 22
   10.38 -#define S21 5
   10.39 -#define S22 9
   10.40 -#define S23 14
   10.41 -#define S24 20
   10.42 -#define S31 4
   10.43 -#define S32 11
   10.44 -#define S33 16
   10.45 -#define S34 23
   10.46 -#define S41 6
   10.47 -#define S42 10
   10.48 -#define S43 15
   10.49 -#define S44 21
   10.50 -
   10.51 -static void MD5Transform PROTO_LIST((UINT4[4], unsigned char[64]));
   10.52 -static void Encode PROTO_LIST((unsigned char *, UINT4 *, unsigned int));
   10.53 -static void Decode PROTO_LIST((UINT4 *, unsigned char *, unsigned int));
   10.54 -static void MD5_memcpy PROTO_LIST((POINTER, POINTER, unsigned int));
   10.55 -static void MD5_memset PROTO_LIST((POINTER, int, unsigned int));
   10.56 -
   10.57 -static unsigned char PADDING[64] = {
   10.58 -	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   10.59 -	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   10.60 -	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   10.61 -};
   10.62 -
   10.63 -/* F, G, H and I are basic MD5 functions.
   10.64 - */
   10.65 -#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
   10.66 -#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
   10.67 -#define H(x, y, z) ((x) ^ (y) ^ (z))
   10.68 -#define I(x, y, z) ((y) ^ ((x) | (~z)))
   10.69 -
   10.70 -/* ROTATE_LEFT rotates x left n bits.
   10.71 - */
   10.72 -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
   10.73 -
   10.74 -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
   10.75 -Rotation is separate from addition to prevent recomputation.
   10.76 - */
   10.77 -#define FF(a, b, c, d, x, s, ac) { \
   10.78 - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
   10.79 - (a) = ROTATE_LEFT ((a), (s)); \
   10.80 - (a) += (b); \
   10.81 -  }
   10.82 -#define GG(a, b, c, d, x, s, ac) { \
   10.83 - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
   10.84 - (a) = ROTATE_LEFT ((a), (s)); \
   10.85 - (a) += (b); \
   10.86 -  }
   10.87 -#define HH(a, b, c, d, x, s, ac) { \
   10.88 - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
   10.89 - (a) = ROTATE_LEFT ((a), (s)); \
   10.90 - (a) += (b); \
   10.91 -  }
   10.92 -#define II(a, b, c, d, x, s, ac) { \
   10.93 - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
   10.94 - (a) = ROTATE_LEFT ((a), (s)); \
   10.95 - (a) += (b); \
   10.96 -  }
   10.97 -
   10.98 -/* MD5 initialization. Begins an MD5 operation, writing a new context.
   10.99 - */
  10.100 -void
  10.101 -MD5Init(context)
  10.102 -MD5_CTX *context;  /* context */
  10.103 -{
  10.104 -	context->count[0] = context->count[1] = 0;
  10.105 -	/* Load magic initialization constants. */
  10.106 -	context->state[0] = 0x67452301;
  10.107 -	context->state[1] = 0xefcdab89;
  10.108 -	context->state[2] = 0x98badcfe;
  10.109 -	context->state[3] = 0x10325476;
  10.110 -}
  10.111 -
  10.112 -/* MD5 block update operation. Continues an MD5 message-digest
  10.113 -  operation, processing another message block, and updating the
  10.114 -  context.
  10.115 - */
  10.116 -void
  10.117 -MD5Update(context, input, inputLen)
  10.118 -MD5_CTX *context;  /* context */
  10.119 -unsigned char *input;  /* input block */
  10.120 -unsigned int inputLen;  /* length of input block */
  10.121 -{
  10.122 -	unsigned int i, index, partLen;
  10.123 -
  10.124 -	/* Compute number of bytes mod 64 */
  10.125 -	index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
  10.126 -
  10.127 -	/* Update number of bits */
  10.128 -	if ((context->count[0] += ((UINT4) inputLen << 3)) < ((UINT4) inputLen << 3))
  10.129 -		context->count[1]++;
  10.130 -	context->count[1] += ((UINT4) inputLen >> 29);
  10.131 -
  10.132 -	partLen = 64 - index;
  10.133 -
  10.134 -	/* Transform as many times as possible.
  10.135 -	 */
  10.136 -	if (inputLen >= partLen) {
  10.137 -		MD5_memcpy((POINTER) & context->buffer[index], (POINTER) input, partLen);
  10.138 -		MD5Transform(context->state, context->buffer);
  10.139 -
  10.140 -		for (i = partLen; i + 63 < inputLen; i += 64)
  10.141 -			MD5Transform(context->state, &input[i]);
  10.142 -
  10.143 -		index = 0;
  10.144 -	} else
  10.145 -		i = 0;
  10.146 -
  10.147 -	/* Buffer remaining input */
  10.148 -	MD5_memcpy((POINTER) & context->buffer[index], (POINTER) & input[i], inputLen - i);
  10.149 -}
  10.150 -
  10.151 -/* MD5 finalization. Ends an MD5 message-digest operation, writing the
  10.152 -  the message digest and zeroizing the context.
  10.153 - */
  10.154 -void
  10.155 -MD5Final(digest, context)
  10.156 -unsigned char digest[16];  /* message digest */
  10.157 -MD5_CTX *context;  /* context */
  10.158 -{
  10.159 -	unsigned char bits[8];
  10.160 -	unsigned int index, padLen;
  10.161 -
  10.162 -	/* Save number of bits */
  10.163 -	Encode(bits, context->count, 8);
  10.164 -
  10.165 -	/* Pad out to 56 mod 64.
  10.166 -	 */
  10.167 -	index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
  10.168 -	padLen = (index < 56) ? (56 - index) : (120 - index);
  10.169 -	MD5Update(context, PADDING, padLen);
  10.170 -
  10.171 -	/* Append length (before padding) */
  10.172 -	MD5Update(context, bits, 8);
  10.173 -
  10.174 -	/* Store state in digest */
  10.175 -	Encode(digest, context->state, 16);
  10.176 -
  10.177 -	/* Zeroize sensitive information.
  10.178 -	 */
  10.179 -	MD5_memset((POINTER) context, 0, sizeof(*context));
  10.180 -}
  10.181 -
  10.182 -/* MD5 basic transformation. Transforms state based on block.
  10.183 - */
  10.184 -static void
  10.185 -MD5Transform(state, block)
  10.186 -UINT4 state[4];
  10.187 -unsigned char block[64];
  10.188 -{
  10.189 -	UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
  10.190 -
  10.191 -	Decode(x, block, 64);
  10.192 -
  10.193 -	/* Round 1 */
  10.194 -	FF(a, b, c, d, x[0], S11, 0xd76aa478);  /* 1 */
  10.195 -	FF(d, a, b, c, x[1], S12, 0xe8c7b756);  /* 2 */
  10.196 -	FF(c, d, a, b, x[2], S13, 0x242070db);  /* 3 */
  10.197 -	FF(b, c, d, a, x[3], S14, 0xc1bdceee);  /* 4 */
  10.198 -	FF(a, b, c, d, x[4], S11, 0xf57c0faf);  /* 5 */
  10.199 -	FF(d, a, b, c, x[5], S12, 0x4787c62a);  /* 6 */
  10.200 -	FF(c, d, a, b, x[6], S13, 0xa8304613);  /* 7 */
  10.201 -	FF(b, c, d, a, x[7], S14, 0xfd469501);  /* 8 */
  10.202 -	FF(a, b, c, d, x[8], S11, 0x698098d8);  /* 9 */
  10.203 -	FF(d, a, b, c, x[9], S12, 0x8b44f7af);  /* 10 */
  10.204 -	FF(c, d, a, b, x[10], S13, 0xffff5bb1);  /* 11 */
  10.205 -	FF(b, c, d, a, x[11], S14, 0x895cd7be);  /* 12 */
  10.206 -	FF(a, b, c, d, x[12], S11, 0x6b901122);  /* 13 */
  10.207 -	FF(d, a, b, c, x[13], S12, 0xfd987193);  /* 14 */
  10.208 -	FF(c, d, a, b, x[14], S13, 0xa679438e);  /* 15 */
  10.209 -	FF(b, c, d, a, x[15], S14, 0x49b40821);  /* 16 */
  10.210 -
  10.211 -	/* Round 2 */
  10.212 -	GG(a, b, c, d, x[1], S21, 0xf61e2562);  /* 17 */
  10.213 -	GG(d, a, b, c, x[6], S22, 0xc040b340);  /* 18 */
  10.214 -	GG(c, d, a, b, x[11], S23, 0x265e5a51);  /* 19 */
  10.215 -	GG(b, c, d, a, x[0], S24, 0xe9b6c7aa);  /* 20 */
  10.216 -	GG(a, b, c, d, x[5], S21, 0xd62f105d);  /* 21 */
  10.217 -	GG(d, a, b, c, x[10], S22, 0x2441453);  /* 22 */
  10.218 -	GG(c, d, a, b, x[15], S23, 0xd8a1e681);  /* 23 */
  10.219 -	GG(b, c, d, a, x[4], S24, 0xe7d3fbc8);  /* 24 */
  10.220 -	GG(a, b, c, d, x[9], S21, 0x21e1cde6);  /* 25 */
  10.221 -	GG(d, a, b, c, x[14], S22, 0xc33707d6);  /* 26 */
  10.222 -	GG(c, d, a, b, x[3], S23, 0xf4d50d87);  /* 27 */
  10.223 -	GG(b, c, d, a, x[8], S24, 0x455a14ed);  /* 28 */
  10.224 -	GG(a, b, c, d, x[13], S21, 0xa9e3e905);  /* 29 */
  10.225 -	GG(d, a, b, c, x[2], S22, 0xfcefa3f8);  /* 30 */
  10.226 -	GG(c, d, a, b, x[7], S23, 0x676f02d9);  /* 31 */
  10.227 -	GG(b, c, d, a, x[12], S24, 0x8d2a4c8a);  /* 32 */
  10.228 -
  10.229 -	/* Round 3 */
  10.230 -	HH(a, b, c, d, x[5], S31, 0xfffa3942);  /* 33 */
  10.231 -	HH(d, a, b, c, x[8], S32, 0x8771f681);  /* 34 */
  10.232 -	HH(c, d, a, b, x[11], S33, 0x6d9d6122);  /* 35 */
  10.233 -	HH(b, c, d, a, x[14], S34, 0xfde5380c);  /* 36 */
  10.234 -	HH(a, b, c, d, x[1], S31, 0xa4beea44);  /* 37 */
  10.235 -	HH(d, a, b, c, x[4], S32, 0x4bdecfa9);  /* 38 */
  10.236 -	HH(c, d, a, b, x[7], S33, 0xf6bb4b60);  /* 39 */
  10.237 -	HH(b, c, d, a, x[10], S34, 0xbebfbc70);  /* 40 */
  10.238 -	HH(a, b, c, d, x[13], S31, 0x289b7ec6);  /* 41 */
  10.239 -	HH(d, a, b, c, x[0], S32, 0xeaa127fa);  /* 42 */
  10.240 -	HH(c, d, a, b, x[3], S33, 0xd4ef3085);  /* 43 */
  10.241 -	HH(b, c, d, a, x[6], S34, 0x4881d05);  /* 44 */
  10.242 -	HH(a, b, c, d, x[9], S31, 0xd9d4d039);  /* 45 */
  10.243 -	HH(d, a, b, c, x[12], S32, 0xe6db99e5);  /* 46 */
  10.244 -	HH(c, d, a, b, x[15], S33, 0x1fa27cf8);  /* 47 */
  10.245 -	HH(b, c, d, a, x[2], S34, 0xc4ac5665);  /* 48 */
  10.246 -
  10.247 -	/* Round 4 */
  10.248 -	II(a, b, c, d, x[0], S41, 0xf4292244);  /* 49 */
  10.249 -	II(d, a, b, c, x[7], S42, 0x432aff97);  /* 50 */
  10.250 -	II(c, d, a, b, x[14], S43, 0xab9423a7);  /* 51 */
  10.251 -	II(b, c, d, a, x[5], S44, 0xfc93a039);  /* 52 */
  10.252 -	II(a, b, c, d, x[12], S41, 0x655b59c3);  /* 53 */
  10.253 -	II(d, a, b, c, x[3], S42, 0x8f0ccc92);  /* 54 */
  10.254 -	II(c, d, a, b, x[10], S43, 0xffeff47d);  /* 55 */
  10.255 -	II(b, c, d, a, x[1], S44, 0x85845dd1);  /* 56 */
  10.256 -	II(a, b, c, d, x[8], S41, 0x6fa87e4f);  /* 57 */
  10.257 -	II(d, a, b, c, x[15], S42, 0xfe2ce6e0);  /* 58 */
  10.258 -	II(c, d, a, b, x[6], S43, 0xa3014314);  /* 59 */
  10.259 -	II(b, c, d, a, x[13], S44, 0x4e0811a1);  /* 60 */
  10.260 -	II(a, b, c, d, x[4], S41, 0xf7537e82);  /* 61 */
  10.261 -	II(d, a, b, c, x[11], S42, 0xbd3af235);  /* 62 */
  10.262 -	II(c, d, a, b, x[2], S43, 0x2ad7d2bb);  /* 63 */
  10.263 -	II(b, c, d, a, x[9], S44, 0xeb86d391);  /* 64 */
  10.264 -
  10.265 -	state[0] += a;
  10.266 -	state[1] += b;
  10.267 -	state[2] += c;
  10.268 -	state[3] += d;
  10.269 -
  10.270 -	/* Zeroize sensitive information. */
  10.271 -	MD5_memset((POINTER) x, 0, sizeof(x));
  10.272 -}
  10.273 -
  10.274 -/* Encodes input (UINT4) into output (unsigned char). Assumes len is
  10.275 -  a multiple of 4.
  10.276 - */
  10.277 -static void
  10.278 -Encode(output, input, len)
  10.279 -unsigned char *output;
  10.280 -UINT4 *input;
  10.281 -unsigned int len;
  10.282 -{
  10.283 -	unsigned int i, j;
  10.284 -
  10.285 -	for (i = 0, j = 0; j < len; i++, j += 4) {
  10.286 -		output[j] = (unsigned char) (input[i] & 0xff);
  10.287 -		output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
  10.288 -		output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
  10.289 -		output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
  10.290 -	}
  10.291 -}
  10.292 -
  10.293 -/* Decodes input (unsigned char) into output (UINT4). Assumes len is
  10.294 -  a multiple of 4.
  10.295 - */
  10.296 -static void
  10.297 -Decode(output, input, len)
  10.298 -UINT4 *output;
  10.299 -unsigned char *input;
  10.300 -unsigned int len;
  10.301 -{
  10.302 -	unsigned int i, j;
  10.303 -
  10.304 -	for (i = 0, j = 0; j < len; i++, j += 4)
  10.305 -		output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24);
  10.306 -}
  10.307 -
  10.308 -/* Note: Replace "for loop" with standard memcpy if possible.
  10.309 - */
  10.310 -
  10.311 -static void
  10.312 -MD5_memcpy(output, input, len)
  10.313 -POINTER output;
  10.314 -POINTER input;
  10.315 -unsigned int len;
  10.316 -{
  10.317 -	unsigned int i;
  10.318 -
  10.319 -	for (i = 0; i < len; i++)
  10.320 -		output[i] = input[i];
  10.321 -}
  10.322 -
  10.323 -/* Note: Replace "for loop" with standard memset if possible.
  10.324 - */
  10.325 -static void
  10.326 -MD5_memset(output, value, len)
  10.327 -POINTER output;
  10.328 -int value;
  10.329 -unsigned int len;
  10.330 -{
  10.331 -	unsigned int i;
  10.332 -
  10.333 -	for (i = 0; i < len; i++)
  10.334 -		((char *) output)[i] = (char) value;
  10.335 -}
    11.1 --- a/src/pop3_in.c	Sun Jul 18 10:48:14 2010 +0200
    11.2 +++ b/src/pop3_in.c	Sun Jul 18 22:01:04 2010 +0200
    11.3 @@ -27,7 +27,6 @@
    11.4  #ifdef USE_LIB_CRYPTO
    11.5  #include <openssl/md5.h>
    11.6  #else
    11.7 -#include "md5/global.h"
    11.8  #include "md5/md5.h"
    11.9  #endif
   11.10  
   11.11 @@ -47,9 +46,9 @@
   11.12  #ifdef USE_LIB_CRYPTO
   11.13  	MD5(string, strlen(string), digest);
   11.14  #else
   11.15 -	MD5Init(&context);
   11.16 -	MD5Update(&context, string, strlen(string));
   11.17 -	MD5Final(digest, &context);
   11.18 +	MD5_Init(&context);
   11.19 +	MD5_Update(&context, string, strlen(string));
   11.20 +	MD5_Final(digest, &context);
   11.21  #endif
   11.22  	for (i = 0; i < 16; i++)
   11.23  		sprintf(str_digest + 2 * i, "%02x", digest[i]);
    12.1 --- a/src/smtp_out.c	Sun Jul 18 10:48:14 2010 +0200
    12.2 +++ b/src/smtp_out.c	Sun Jul 18 22:01:04 2010 +0200
    12.3 @@ -39,7 +39,6 @@
    12.4  #include <openssl/md5.h>
    12.5  #include <openssl/evp.h>
    12.6  #else
    12.7 -#include "md5/global.h"
    12.8  #include "md5/md5.h"
    12.9  #include "md5/hmac_md5.h"
   12.10  #endif