aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2013-04-27 18:07:22 +0200
committerTimo Weingärtner <timo@tiwe.de>2013-05-12 18:43:00 +0200
commit64707e82165bb32db5763b38bf550b538bcd4eec (patch)
tree03e8c16dea4b0ad40d129073dd7c1611b48c48b6
parent629c03d7775e1f4b5c0fdee358c6773f70e91961 (diff)
downloadlibpam-pwdfile-64707e82165bb32db5763b38bf550b538bcd4eec.tar.gz
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
-rw-r--r--md5.c24
1 files 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 <string.h>
+#include <byteswap.h>
#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