Whoops.  I think that last patch had the endian conditions backwards...
Try this one.

--Mike


On Thu, 2004-05-27 at 21:36, Michael Griego wrote:
> Try the attached patch to the sha1.c file and see if that takes care of
> the problem.
> 
> --Mike

--- sha1.c.save 2004-05-27 21:26:12.000000000 -0500
+++ sha1.c      2004-05-27 21:41:50.000000000 -0500
@@ -9,6 +9,7 @@
 #include "autoconf.h"
 
 #include <string.h>
+#include <endian.h>
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -24,14 +25,19 @@
 
 #include "sha1.h"
 
-#define blk0(i) (block->l[i] = htonl(block->l[i]))
 
 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
 
 /* blk0() and blk() perform the initial expand. */
 /* I got the idea of expanding during the round function from SSLeay */
 
-#define blk0(i) (block->l[i] = htonl(block->l[i]))
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define blk0(i) block->l[i]
+# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#  define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+     |(rol(block->l[i],8)&0x00FF00FF))
+# endif
+
 
 #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
     ^block->l[(i+2)&15]^block->l[i&15],1))

Reply via email to