summaryrefslogtreecommitdiff
path: root/runner.c
diff options
context:
space:
mode:
authorEric Anderson <ejona86@gmail.com>2010-12-27 01:14:42 -0600
committerEric Anderson <ejona86@gmail.com>2010-12-27 01:14:42 -0600
commit34f3a25cf608320e8b95ada8cbe412ac7ec46be5 (patch)
tree790b68fa305a5d1072f0b2006f61f40dab221896 /runner.c
parente4c49643c47f4d69282a8d1ad2f05619bd4d86b9 (diff)
downloadmd5game-34f3a25cf608320e8b95ada8cbe412ac7ec46be5.tar.gz
md5game-34f3a25cf608320e8b95ada8cbe412ac7ec46be5.zip
lcs_upper_bound's second sum is required all the time and try to handle endians
Diffstat (limited to 'runner.c')
-rw-r--r--runner.c18
1 files changed, 11 insertions, 7 deletions
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;
}
}