diff --git a/hasher/md5-base.h b/hasher/md5-base.h index 9494519..3db4d5c 100644 --- a/hasher/md5-base.h +++ b/hasher/md5-base.h @@ -28,10 +28,6 @@ # define _ADDF(f,a,b,c,d) ADD(a, f(b,c,d)) #endif -#ifndef IOFFSET -# define IOFFSET -#endif - /* code was originally based off OpenSSL's implementation */ #ifndef _RX @@ -243,38 +239,44 @@ static HEDLEY_ALWAYS_INLINE void FNB(md5_process_block)(state_word_t* state, con RX(H, C, D, A, B, X, 15, 16, 0x1fa27cf8L); RX(H, B, C, D, A, X, 2, 23, 0xc4ac5665L); /* Round 3 */ +#ifdef IOFFSET +# define _IOF(n) (int32_t)(n IOFFSET) +#else +# define _IOF(n) n +#endif #ifdef ADD16 ADD16(XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15, - 0xf4292244L IOFFSET, 0x85845dd1L IOFFSET, 0x2ad7d2bbL IOFFSET, 0x8f0ccc92L IOFFSET, - 0xf7537e82L IOFFSET, 0xfc93a039L IOFFSET, 0xa3014314L IOFFSET, 0x432aff97L IOFFSET, - 0x6fa87e4fL IOFFSET, 0xeb86d391L IOFFSET, 0xffeff47dL IOFFSET, 0xbd3af235L IOFFSET, - 0x655b59c3L IOFFSET, 0x4e0811a1L IOFFSET, 0xab9423a7L IOFFSET, 0xfe2ce6e0L IOFFSET); + _IOF(0xf4292244L), _IOF(0x85845dd1L), _IOF(0x2ad7d2bbL), _IOF(0x8f0ccc92L), + _IOF(0xf7537e82L), _IOF(0xfc93a039L), _IOF(0xa3014314L), _IOF(0x432aff97L), + _IOF(0x6fa87e4fL), _IOF(0xeb86d391L), _IOF(0xffeff47dL), _IOF(0xbd3af235L), + _IOF(0x655b59c3L), _IOF(0x4e0811a1L), _IOF(0xab9423a7L), _IOF(0xfe2ce6e0L)); # ifdef MD5X2 ADD16(XX0b, XX1b, XX2b, XX3b, XX4b, XX5b, XX6b, XX7b, XX8b, XX9b, XX10b, XX11b, XX12b, XX13b, XX14b, XX15b, - 0xf4292244L IOFFSET, 0x85845dd1L IOFFSET, 0x2ad7d2bbL IOFFSET, 0x8f0ccc92L IOFFSET, - 0xf7537e82L IOFFSET, 0xfc93a039L IOFFSET, 0xa3014314L IOFFSET, 0x432aff97L IOFFSET, - 0x6fa87e4fL IOFFSET, 0xeb86d391L IOFFSET, 0xffeff47dL IOFFSET, 0xbd3af235L IOFFSET, - 0x655b59c3L IOFFSET, 0x4e0811a1L IOFFSET, 0xab9423a7L IOFFSET, 0xfe2ce6e0L IOFFSET); + _IOF(0xf4292244L), _IOF(0x85845dd1L), _IOF(0x2ad7d2bbL), _IOF(0x8f0ccc92L), + _IOF(0xf7537e82L), _IOF(0xfc93a039L), _IOF(0xa3014314L), _IOF(0x432aff97L), + _IOF(0x6fa87e4fL), _IOF(0xeb86d391L), _IOF(0xffeff47dL), _IOF(0xbd3af235L), + _IOF(0x655b59c3L), _IOF(0x4e0811a1L), _IOF(0xab9423a7L), _IOF(0xfe2ce6e0L)); # endif #endif - RX(I, A, B, C, D, X, 0, 6, 0xf4292244L IOFFSET); - RX(I, D, A, B, C, X, 7, 10, 0x432aff97L IOFFSET); - RX(I, C, D, A, B, X, 14, 15, 0xab9423a7L IOFFSET); - RX(I, B, C, D, A, X, 5, 21, 0xfc93a039L IOFFSET); - RX(I, A, B, C, D, X, 12, 6, 0x655b59c3L IOFFSET); - RX(I, D, A, B, C, X, 3, 10, 0x8f0ccc92L IOFFSET); - RX(I, C, D, A, B, X, 10, 15, 0xffeff47dL IOFFSET); - RX(I, B, C, D, A, X, 1, 21, 0x85845dd1L IOFFSET); - RX(I, A, B, C, D, X, 8, 6, 0x6fa87e4fL IOFFSET); - RX(I, D, A, B, C, X, 15, 10, 0xfe2ce6e0L IOFFSET); - RX(I, C, D, A, B, X, 6, 15, 0xa3014314L IOFFSET); - RX(I, B, C, D, A, X, 13, 21, 0x4e0811a1L IOFFSET); - RX(I, A, B, C, D, X, 4, 6, 0xf7537e82L IOFFSET); - RX(I, D, A, B, C, X, 11, 10, 0xbd3af235L IOFFSET); - RX(I, C, D, A, B, X, 2, 15, 0x2ad7d2bbL IOFFSET); - RX(I, B, C, D, A, X, 9, 21, 0xeb86d391L IOFFSET); + RX(I, A, B, C, D, X, 0, 6, _IOF(0xf4292244L)); + RX(I, D, A, B, C, X, 7, 10, _IOF(0x432aff97L)); + RX(I, C, D, A, B, X, 14, 15, _IOF(0xab9423a7L)); + RX(I, B, C, D, A, X, 5, 21, _IOF(0xfc93a039L)); + RX(I, A, B, C, D, X, 12, 6, _IOF(0x655b59c3L)); + RX(I, D, A, B, C, X, 3, 10, _IOF(0x8f0ccc92L)); + RX(I, C, D, A, B, X, 10, 15, _IOF(0xffeff47dL)); + RX(I, B, C, D, A, X, 1, 21, _IOF(0x85845dd1L)); + RX(I, A, B, C, D, X, 8, 6, _IOF(0x6fa87e4fL)); + RX(I, D, A, B, C, X, 15, 10, _IOF(0xfe2ce6e0L)); + RX(I, C, D, A, B, X, 6, 15, _IOF(0xa3014314L)); + RX(I, B, C, D, A, X, 13, 21, _IOF(0x4e0811a1L)); + RX(I, A, B, C, D, X, 4, 6, _IOF(0xf7537e82L)); + RX(I, D, A, B, C, X, 11, 10, _IOF(0xbd3af235L)); + RX(I, C, D, A, B, X, 2, 15, _IOF(0x2ad7d2bbL)); + RX(I, B, C, D, A, X, 9, 21, _IOF(0xeb86d391L)); +#undef _IOF _SET_STATE(state, 0, ADD(oA, A)); _SET_STATE(state, 1, ADD(oB, B));