From 64707e82165bb32db5763b38bf550b538bcd4eec Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Sat, 27 Apr 2013 18:07:22 +0200 Subject: make Brokencrypt_md5 also broken on little-endian otherwise broken hashes from big-endian systems won't work also remove ASM_MD5 #ifndef's, we don't have assembler code here --- md5.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/md5.c b/md5.c index 0fb1a78..94f1e2a 100644 --- a/md5.c +++ b/md5.c @@ -19,29 +19,17 @@ */ #include +#include #include "md5.h" #ifndef HIGHFIRST #define byteReverse(buf, len) /* Nothing */ #else -static void byteReverse(unsigned char *buf, unsigned longs); - -#ifndef ASM_MD5 -/* - * Note: this code is harmless on little-endian machines. - */ -static 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); +static void byteReverse(unsigned char *buf, unsigned longs) { + for (; longs; --longs, buf +=4) + *((uint32 *) buf) = bswap_32(*((uint32 *) buf)); } #endif -#endif /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious @@ -151,8 +139,6 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } -#ifndef ASM_MD5 - /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ @@ -252,5 +238,3 @@ void MD5Name(MD5Transform)(uint32 buf[4], uint32 const in[16]) buf[2] += c; buf[3] += d; } - -#endif -- cgit v1.2.3