Skip to content

Commit

Permalink
Fix broken MD5x2 asm
Browse files Browse the repository at this point in the history
Fixes #63
  • Loading branch information
animetosho committed Sep 17, 2024
1 parent 92f1eb8 commit dac1bc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions hasher/md5x2-arm-asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ static HEDLEY_ALWAYS_INLINE void md5_process_block_x2_scalar(uint32_t* state, co
RH4( 0, 12, 24, 36, 0x7ec6, 0x289b, 0x27fa, 0xeaa1, 0x3085, 0xd4ef, 0x1d05, 0x0488)
RH4(48, 60, 8, 0, 0xd039, 0xd9d4, 0x99e5, 0xe6db, 0x7cf8, 0x1fa2, 0x5665, 0xc4ac)

RI4(28, 56, 20, 48, 0x2244, 0xf429, 0xff97, 0x432a, 0x23a7, 0xab94, 0xa039, 0xfc93)
RI4(12, 40, 4, 32, 0x59c3, 0x655b, 0xcc92, 0x8f0c, 0xf47d, 0xffef, 0x5dd1, 0x8584)
RI4(60, 24, 52, 16, 0x7e4f, 0x6fa8, 0xe6e0, 0xfe2c, 0x4314, 0xa301, 0x11a1, 0x4e08)
RI4(28, 56, 20, 48, 0x2243, 0xf429, 0xff96, 0x432a, 0x23a6, 0xab94, 0xa038, 0xfc93)
RI4(12, 40, 4, 32, 0x59c2, 0x655b, 0xcc91, 0x8f0c, 0xf47c, 0xffef, 0x5dd0, 0x8584)
RI4(60, 24, 52, 16, 0x7e4e, 0x6fa8, 0xe6df, 0xfe2c, 0x4313, 0xa301, 0x11a0, 0x4e08)

ROUND_I(A1, B1, C1, D1, A2, B2, C2, D2, "[%[i0], #44]", "[%[i1], #44]", 0x7e82, 0xf753, 26)
ROUND_I(D1, A1, B1, C1, D2, A2, B2, C2, "[%[i0], #8]", "[%[i1], #8]", 0xf235, 0xbd3a, 22)
ROUND_I(C1, D1, A1, B1, C2, D2, A2, B2, "[%[i0], #36]", "[%[i1], #36]", 0xd2bb, 0x2ad7, 17)
ROUND_I_LAST(B1, C1, D1, A1, B2, C2, D2, A2, 0xd391, 0xeb86, 11)
ROUND_I(A1, B1, C1, D1, A2, B2, C2, D2, "[%[i0], #44]", "[%[i1], #44]", 0x7e81, 0xf753, 26)
ROUND_I(D1, A1, B1, C1, D2, A2, B2, C2, "[%[i0], #8]", "[%[i1], #8]", 0xf234, 0xbd3a, 22)
ROUND_I(C1, D1, A1, B1, C2, D2, A2, B2, "[%[i0], #36]", "[%[i1], #36]", 0xd2ba, 0x2ad7, 17)
ROUND_I_LAST(B1, C1, D1, A1, B2, C2, D2, A2, 0xd390, 0xeb86, 11)
: [A1]"+&r"(A1), [B1]"+&r"(B1), [C1]"+&r"(C1), [D1]"+&r"(D1),
[A2]"+&r"(A2), [B2]"+&r"(B2), [C2]"+&r"(C2), [D2]"+&r"(D2),
[TMP1]"=&r"(tmp1), [TMP2]"=&r"(tmp2)
Expand Down
8 changes: 4 additions & 4 deletions hasher/md5x2-x86-asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ static HEDLEY_ALWAYS_INLINE void md5_process_block_x2_scalar(uint32_t* state, co
"addl %k[" STR(B2) "], %k[" STR(A2) "]\n"

#ifdef _MD5_USE_BMI1_
#define ROUND_I_INIT(A1, D1, A2, D2, K) \
#define ROUND_I_INIT(A1, B1, D1, A2, B2, D2, K) \
"addl $" STR(K) "-1, %k[" STR(A1) "]\n" \
"addl $" STR(K) "-1, %k[" STR(A2) "]\n" \
"andnl %k[" STR(D1) "], %k[" STR(B1) "], %k[TMP1]\n" \
"andnl %k[" STR(D2) "], %k[" STR(B2) "], %k[TMP2]\n"
#define ROUND_I_ADD "subl"
#else
#define ROUND_I_INIT(A1, D1, A2, D2, K) \
#define ROUND_I_INIT(A1, B1, D1, A2, B2, D2, K) \
"movl %k[" STR(D1) "], %k[TMP1]\n" \
"movl %k[" STR(D2) "], %k[TMP2]\n" \
"addl $" STR(K) ", %k[" STR(A1) "]\n" \
Expand All @@ -82,7 +82,7 @@ static HEDLEY_ALWAYS_INLINE void md5_process_block_x2_scalar(uint32_t* state, co
#define ROUND_I_ADD "addl"
#endif
#define ROUND_I(A1, B1, C1, D1, A2, B2, C2, D2, NEXT_IN1, NEXT_IN2, K, R) \
ROUND_I_INIT(A1, D1, A2, D2, K) \
ROUND_I_INIT(A1, B1, D1, A2, B2, D2, K) \
"xorl %k[" STR(C1) "], %k[TMP1]\n" \
"xorl %k[" STR(C2) "], %k[TMP2]\n" \
"addl " NEXT_IN1 ", %k[" STR(D1) "]\n" \
Expand All @@ -94,7 +94,7 @@ static HEDLEY_ALWAYS_INLINE void md5_process_block_x2_scalar(uint32_t* state, co
"addl %k[" STR(B1) "], %k[" STR(A1) "]\n" \
"addl %k[" STR(B2) "], %k[" STR(A2) "]\n"
#define ROUND_I_LAST(A1, B1, C1, D1, A2, B2, C2, D2, K, R) \
ROUND_I_INIT(A1, D1, A2, D2, K) \
ROUND_I_INIT(A1, B1, D1, A2, B2, D2, K) \
"xorl %k[" STR(C1) "], %k[TMP1]\n" \
"xorl %k[" STR(C2) "], %k[TMP2]\n" \
ROUND_I_ADD " %k[TMP1], %k[" STR(A1) "]\n" \
Expand Down

0 comments on commit dac1bc3

Please sign in to comment.