From 34f3a25cf608320e8b95ada8cbe412ac7ec46be5 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 27 Dec 2010 01:14:42 -0600 Subject: lcs_upper_bound's second sum is required all the time and try to handle endians --- runner.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'runner.c') diff --git a/runner.c b/runner.c index 889fe5b..2960cee 100644 --- a/runner.c +++ b/runner.c @@ -22,6 +22,16 @@ #define MSF 8 +#if BYTE_ORDER == LITTLE_ENDIAN +#define BE_BYTE_INDEX(i) (i^3) +#define LE_BYTE_INDEX(i) (i) +#elif BYTE_ORDER == BIG_ENDIAN +#define BE_BYTE_INDEX(i) (i) +#define LE_BYTE_INDEX(i) (i^3) +#else +#error Unknown endianness +#endif + unsigned char tbl[512]; md5_state_t global_md5; @@ -49,13 +59,7 @@ void raw_MD5_64(unsigned char* input, unsigned char* digest) { */ unsigned int i; for (i = 0; i < 16; ++i) { -#if BYTE_ORDER == LITTLE_ENDIAN - memcpy(digest, tbl + ((unsigned char*)(global_md5.abcd))[i] * 2, 2); -#elif BYTE_ORDER == BIG_ENDIAN - memcpy(digest, tbl + ((unsigned char*)(global_md5.abcd))[i^0x3] * 2, 2); -#else -#error Unknown endianness -#endif + memcpy(digest, tbl + ((unsigned char*)(global_md5.abcd))[LE_BYTE_INDEX(i)] * 2, 2); digest += 2; } } -- cgit v1.2.3-70-g09d2