diff -c1 -r sxid-4.0.5.orig/source/md5.c sxid-4.0.5/source/md5.c
*** sxid-4.0.5.orig/source/md5.c	1998-12-30 13:35:04.000000000 -0500
--- sxid-4.0.5/source/md5.c	2007-03-23 11:58:40.000000000 -0400
***************
*** 17,18 ****
--- 17,27 ----
  
+ /*
+  * This code contains adaptations of changes made in 1997 by
+  * Jim Kingdon of Cyclic Software so as not to require an integer
+  * type that is exactly 32 bits wide.  Jim Kingdon's changes
+  * were explicitly released to the public domain.  The adaptations
+  * were made by Ari Johnson in 2007 and are also hereby released
+  * into the public domain.
+  */
+ 
  #include <string.h>		/* for memcpy() */
***************
*** 20,44 ****
  
! #ifndef HIGHFIRST
! #define byteReverse(buf, len)	/* Nothing */
! #else
! void byteReverse (unsigned char *buf, unsigned longs);
! 
! #ifndef ASM_MD5
! /*
!  * Note: this code is harmless on little-endian machines.
!  */
! void byteReverse (unsigned char *buf, unsigned longs)
! {
!     uint32 t;
  
!     do {
! 	t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
! 	    ((unsigned) buf[1] << 8 | buf[0]);
! 	*(uint32 *) buf = t;
! 	buf += 4;
!     }
!     while (--longs);
  }
- #endif
- #endif
  
--- 29,47 ----
  
! /* Little-endian byte-swapping routines.  Note that these do not
!    depend on the size of datatypes such as uint32, nor do they require
!    us to detect the endianness of the machine we are running on. */
! 
! static uint32
! getu32 (const unsigned char *addr) {
!     return (((((unsigned long)addr[3] << 8) | addr[2]) << 8)
! 		| addr[1]) << 8 | addr[0];
! }
  
! static void
! putu32 (uint32 data, unsigned char *addr) {
!     addr[0] = (unsigned char) data;
!     addr[1] = (unsigned char) (data >> 8);
!     addr[2] = (unsigned char) (data >> 16);
!     addr[3] = (unsigned char) (data >> 24);
  }
  
***************
*** 70,72 ****
      t = ctx->bits[0];
!     if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
  	ctx->bits[1]++;		/* Carry from low to high */
--- 73,75 ----
      t = ctx->bits[0];
!     if ((ctx->bits[0] = (t + ((uint32) len << 3)) & 0xffffffff) < t)
  	ctx->bits[1]++;		/* Carry from low to high */
***************
*** 79,81 ****
      if (t) {
! 	unsigned char *p = (unsigned char *) ctx->in + t;
  
--- 82,84 ----
      if (t) {
! 	unsigned char *p = ctx->in + t;
  
***************
*** 87,90 ****
  	memcpy (p, buf, t);
! 	byteReverse (ctx->in, 16);
! 	MD5Transform (ctx->buf, (uint32 *) ctx->in);
  	buf += t;
--- 90,92 ----
  	memcpy (p, buf, t);
! 	MD5Transform (ctx->buf, ctx->in);
  	buf += t;
***************
*** 96,99 ****
  	memcpy (ctx->in, buf, 64);
! 	byteReverse (ctx->in, 16);
! 	MD5Transform (ctx->buf, (uint32 *) ctx->in);
  	buf += 64;
--- 98,100 ----
  	memcpy (ctx->in, buf, 64);
! 	MD5Transform (ctx->buf, ctx->in);
  	buf += 64;
***************
*** 131,134 ****
  	memset (p, 0, count);
! 	byteReverse (ctx->in, 16);
! 	MD5Transform (ctx->buf, (uint32 *) ctx->in);
  
--- 132,134 ----
  	memset (p, 0, count);
! 	MD5Transform (ctx->buf, ctx->in);
  
***************
*** 140,150 ****
      }
-     byteReverse (ctx->in, 14);
  
      /* Append length in bits and transform */
!     ((uint32 *) ctx->in)[14] = ctx->bits[0];
!     ((uint32 *) ctx->in)[15] = ctx->bits[1];
  
!     MD5Transform (ctx->buf, (uint32 *) ctx->in);
!     byteReverse ((unsigned char *) ctx->buf, 4);
!     memcpy (digest, ctx->buf, 16);
      memset ((char *) ctx, 0, sizeof (ctx));	/* In case it's sensitive */
--- 140,151 ----
      }
  
      /* Append length in bits and transform */
!     putu32(ctx->bits[0], ctx->in + 56);
!     putu32(ctx->bits[1], ctx->in + 60);
  
!     MD5Transform (ctx->buf, ctx->in);
!     putu32(ctx->buf[0], digest);
!     putu32(ctx->buf[1], digest + 4);
!     putu32(ctx->buf[2], digest + 8);
!     putu32(ctx->buf[3], digest + 12);
      memset ((char *) ctx, 0, sizeof (ctx));	/* In case it's sensitive */
***************
*** 164,166 ****
  #define MD5STEP(f, w, x, y, z, data, s) \
! 	( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
  
--- 165,167 ----
  #define MD5STEP(f, w, x, y, z, data, s) \
! 	( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
  
***************
*** 171,175 ****
   */
! void MD5Transform (uint32 buf[4], uint32 const in[16])
  {
      register uint32 a, b, c, d;
  
--- 172,181 ----
   */
! void MD5Transform (uint32 buf[4], const unsigned char inraw[64])
  {
      register uint32 a, b, c, d;
+     uint32 in[16];
+     int i;
+ 
+     for (i = 0; i < 16; ++i)
+ 	in[i] = getu32 (inraw + 4 * i);
  
diff -c1 -r sxid-4.0.5.orig/source/md5.h sxid-4.0.5/source/md5.h
*** sxid-4.0.5.orig/source/md5.h	1998-12-30 13:35:04.000000000 -0500
--- sxid-4.0.5/source/md5.h	2007-03-23 11:47:25.000000000 -0400
***************
*** 4,13 ****
  
- #ifdef __alpha
- typedef unsigned int uint32;
- 
- #else
  typedef unsigned long uint32;
  
- #endif
- 
  struct MD5Context {
--- 4,7 ----
***************
*** 22,29 ****
  void MD5Final (unsigned char digest[16], struct MD5Context *context);
! void MD5Transform (uint32 buf[4], uint32 const in[16]);
! 
! /*
!  * This is needed to make RSAREF happy on some MS-DOS compilers.
!  */
! typedef struct MD5Context MD5_CTX;
  
--- 16,18 ----
  void MD5Final (unsigned char digest[16], struct MD5Context *context);
! void MD5Transform (uint32 buf[4], const unsigned char in[64]);
  
