diff --git a/OpenCL/inc_hash_functions.cl b/OpenCL/inc_hash_functions.cl index cf7daf3a5..802cab90d 100644 --- a/OpenCL/inc_hash_functions.cl +++ b/OpenCL/inc_hash_functions.cl @@ -31,27 +31,24 @@ #define MD4_Go(x,y,z) (MD4_G((x), (y), (z))) #endif -#define MD4_STEP_S(f,a,b,c,d,x,K,s) \ -{ \ - a += K; \ - const u32 t = f (b, c, d); \ - a = __add3_S (a, x, t); \ - a = rotl32_S (a, s); \ +#define MD4_STEP_S(f,a,b,c,d,x,K,s) \ +{ \ + a += K; \ + a = __add3_S (a, x, f (b, c, d)); \ + a = rotl32_S (a, s); \ } -#define MD4_STEP(f,a,b,c,d,x,K,s) \ -{ \ - a += K; \ - const u32x t = f (b, c, d); \ - a = __add3 (a, x, t); \ - a = rotl32 (a, s); \ +#define MD4_STEP(f,a,b,c,d,x,K,s) \ +{ \ + a += K; \ + a = __add3 (a, x, f (b, c, d)); \ + a = rotl32 (a, s); \ } -#define MD4_STEP0(f,a,b,c,d,K,s) \ -{ \ - const u32x t = f (b, c, d); \ - a = __add3 (a, K, t); \ - a = rotl32 (a, s); \ +#define MD4_STEP0(f,a,b,c,d,K,s) \ +{ \ + a = __add3 (a, K, f (b, c, d)); \ + a = rotl32 (a, s); \ } #define MD5_F_S(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) @@ -86,28 +83,25 @@ #define MD5_Go(x,y,z) (MD5_G((x), (y), (z))) #endif -#define MD5_STEP_S(f,a,b,c,d,x,K,s) \ -{ \ - a += K; \ - const u32 t = f (b, c, d); \ - a = __add3_S (a, x, t); \ - a = rotl32_S (a, s); \ - a += b; \ +#define MD5_STEP_S(f,a,b,c,d,x,K,s) \ +{ \ + a += K; \ + a = __add3_S (a, x, f (b, c, d)); \ + a = rotl32_S (a, s); \ + a += b; \ } #define MD5_STEP(f,a,b,c,d,x,K,s) \ { \ a += K; \ - const u32x t = f (b, c, d); \ - a = __add3 (a, x, t); \ + a = __add3 (a, x, f (b, c, d)); \ a = rotl32 (a, s); \ a += b; \ } #define MD5_STEP0(f,a,b,c,d,K,s) \ { \ - const u32x t = f (b, c, d); \ - a = __add3 (a, K, t); \ + a = __add3 (a, K, f (b, c, d)); \ a = rotl32 (a, s); \ a += b; \ } @@ -136,36 +130,32 @@ #define SHA1_F2o(x,y,z) (SHA1_F2 ((x), (y), (z))) #endif -#define SHA1_STEP_S(f,a,b,c,d,e,x) \ -{ \ - e += K; \ - const u32 t = f (b, c, d); \ - e = __add3_S (e, x, t); \ - e += rotl32_S (a, 5u); \ - b = rotl32_S (b, 30u); \ +#define SHA1_STEP_S(f,a,b,c,d,e,x) \ +{ \ + e += K; \ + e = __add3_S (e, x, f (b, c, d)); \ + e += rotl32_S (a, 5u); \ + b = rotl32_S (b, 30u); \ } #define SHA1_STEP(f,a,b,c,d,e,x) \ { \ e += K; \ - const u32x t = f (b, c, d); \ - e = __add3 (e, x, t); \ + e = __add3 (e, x, f (b, c, d)); \ e += rotl32 (a, 5u); \ b = rotl32 (b, 30u); \ } #define SHA1_STEP0(f,a,b,c,d,e,x) \ { \ - const u32x t = f (b, c, d); \ - e = __add3 (e, K, t); \ + e = __add3 (e, K, f (b, c, d)); \ e += rotl32 (a, 5u); \ b = rotl32 (b, 30u); \ } #define SHA1_STEPX(f,a,b,c,d,e,x) \ { \ - const u32x t = f (b, c, d); \ - e = __add3 (e, x, t); \ + e = __add3 (e, x, f (b, c, d)); \ e += rotl32 (a, 5u); \ b = rotl32 (b, 30u); \ } @@ -218,28 +208,20 @@ #define SHA256_STEP_S(F0,F1,a,b,c,d,e,f,g,h,x,K) \ { \ - const u32 t1 = SHA256_S3_S (e); \ - const u32 t2 = F1 (e,f,g); \ h = __add3_S (h, K, x); \ - h = __add3_S (h, t1, t2); \ + h = __add3_S (h, SHA256_S3_S (e), F1 (e,f,g)); \ d += h; \ - const u32 t3 = SHA256_S2_S (a); \ - const u32 t4 = F0 (a,b,c); \ - h = __add3_S (h, t3, t4); \ + h = __add3_S (h, SHA256_S2_S (a), F0 (a,b,c)); \ } #define SHA256_EXPAND_S(x,y,z,w) (SHA256_S1_S (x) + y + SHA256_S0_S (z) + w) #define SHA256_STEP(F0,F1,a,b,c,d,e,f,g,h,x,K) \ { \ - const u32 t1 = SHA256_S3 (e); \ - const u32 t2 = F1 (e,f,g); \ h = __add3 (h, K, x); \ - h = __add3 (h, t1, t2); \ + h = __add3 (h, SHA256_S3 (e), F1 (e,f,g)); \ d += h; \ - const u32 t3 = SHA256_S2 (a); \ - const u32 t4 = F0 (a,b,c); \ - h = __add3 (h, t3, t4); \ + h = __add3 (h, SHA256_S2 (a), F0 (a,b,c)); \ } #define SHA256_EXPAND(x,y,z,w) (SHA256_S1 (x) + y + SHA256_S0 (z) + w) diff --git a/include/bitops.h b/include/bitops.h index 30b53c30b..a40ca6090 100644 --- a/include/bitops.h +++ b/include/bitops.h @@ -6,6 +6,9 @@ #ifndef _BITOPS_H #define _BITOPS_H +u32 __add3 (const u32 a, const u32 b, const u32 c); +u32 __add3_S (const u32 a, const u32 b, const u32 c); + u32 rotl32 (const u32 a, const u32 n); u32 rotr32 (const u32 a, const u32 n); u64 rotl64 (const u64 a, const u64 n); diff --git a/src/bitops.c b/src/bitops.c index b0d655fe7..7da972f6b 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -7,6 +7,16 @@ #include "types.h" #include "bitops.h" +u32 __add3_S (const u32 a, const u32 b, const u32 c) +{ + return a + b + c; +} + +u32 __add3 (const u32 a, const u32 b, const u32 c) +{ + return a + b + c; +} + u32 rotl32 (const u32 a, const u32 n) { #if defined (_MSC_VER)