SIMD for slow hashes prototype

This commit is contained in:
jsteube
2016-05-01 18:34:59 +02:00
parent 74fa4c1886
commit 9b3d18f87d
8 changed files with 301 additions and 417 deletions
+2
View File
@@ -123,4 +123,6 @@ void log_error (const char *fmt, ...);
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
#endif // COMMON_H
+9 -32
View File
@@ -10,15 +10,9 @@
#define MD4_H_S(x,y,z) ((x) ^ (y) ^ (z))
#ifdef IS_NV
#if CUDA_ARCH >= 500
#define MD4_F(x,y,z) lut3_ca ((x), (y), (z))
#define MD4_G(x,y,z) lut3_e8 ((x), (y), (z))
#define MD4_H(x,y,z) lut3_96 ((x), (y), (z))
#else
#define MD4_F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
#define MD4_G(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define MD4_H(x,y,z) ((x) ^ (y) ^ (z))
#endif
#define MD4_Fo(x,y,z) (MD4_F((x), (y), (z)))
#define MD4_Go(x,y,z) (MD4_G((x), (y), (z)))
#endif
@@ -64,17 +58,10 @@
#define MD5_I_S(x,y,z) ((y) ^ ((x) | ~(z)))
#ifdef IS_NV
#if CUDA_ARCH >= 500
#define MD5_F(x,y,z) lut3_ca ((x), (y), (z))
#define MD5_G(x,y,z) lut3_e4 ((x), (y), (z))
#define MD5_H(x,y,z) lut3_96 ((x), (y), (z))
#define MD5_I(x,y,z) lut3_39 ((x), (y), (z))
#else
#define MD5_F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define MD5_G(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
#define MD5_H(x,y,z) ((x) ^ (y) ^ (z))
#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z)))
#endif
#define MD5_Fo(x,y,z) (MD5_F((x), (y), (z)))
#define MD5_Go(x,y,z) (MD5_G((x), (y), (z)))
#endif
@@ -97,6 +84,15 @@
#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; \
a += x; \
a += f (b, c, d); \
a = rotl32_S (a, s); \
a += b; \
}
#define MD5_STEP(f,a,b,c,d,x,K,s) \
{ \
a += K; \
@@ -118,15 +114,9 @@
#if defined _SHA1_ || defined _SAPG_ || defined _OFFICE2007_ || defined _OFFICE2010_ || defined _OLDOFFICE34_ || defined _ANDROIDFDE_ || defined _DCC2_ || defined _WPA_ || defined _MD5_SHA1_ || defined _SHA1_MD5_ || defined _PSAFE2_ || defined _LOTUS8_ || defined _PBKDF2_SHA1_ || defined _RAR3_ || defined _SHA256_SHA1_
#ifdef IS_NV
#if CUDA_ARCH >= 500
#define SHA1_F0(x,y,z) lut3_ca ((x), (y), (z))
#define SHA1_F1(x,y,z) lut3_96 ((x), (y), (z))
#define SHA1_F2(x,y,z) lut3_e8 ((x), (y), (z))
#else
#define SHA1_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#define SHA1_F1(x,y,z) ((x) ^ (y) ^ (z))
#define SHA1_F2(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#endif
#define SHA1_F0o(x,y,z) (SHA1_F0 ((x), (y), (z)))
#define SHA1_F2o(x,y,z) (SHA1_F2 ((x), (y), (z)))
#endif
@@ -196,13 +186,8 @@
#define SHA256_S3(x) (rotl32 ((x), 26u) ^ rotl32 ((x), 21u) ^ rotl32 ((x), 7u))
#ifdef IS_NV
#if CUDA_ARCH >= 500
#define SHA256_F0(x,y,z) lut3_e8 ((x), (y), (z))
#define SHA256_F1(x,y,z) lut3_ca ((x), (y), (z))
#else
#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
#endif
#define SHA256_F0o(x,y,z) (SHA256_F0 ((x), (y), (z)))
#define SHA256_F1o(x,y,z) (SHA256_F1 ((x), (y), (z)))
#endif
@@ -321,19 +306,11 @@
#ifdef _RIPEMD160_
#ifdef IS_NV
#if CUDA_ARCH >= 500
#define RIPEMD160_F(x,y,z) lut3_96 ((x), (y), (z))
#define RIPEMD160_G(x,y,z) lut3_ca ((x), (y), (z))
#define RIPEMD160_H(x,y,z) lut3_59 ((x), (y), (z))
#define RIPEMD160_I(x,y,z) lut3_e4 ((x), (y), (z))
#define RIPEMD160_J(x,y,z) lut3_2d ((x), (y), (z))
#else
#define RIPEMD160_F(x,y,z) ((x) ^ (y) ^ (z))
#define RIPEMD160_G(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) /* x ? y : z */
#define RIPEMD160_H(x,y,z) (((x) | ~(y)) ^ (z))
#define RIPEMD160_I(x,y,z) ((y) ^ ((z) & ((x) ^ (y)))) /* z ? x : y */
#define RIPEMD160_J(x,y,z) ((x) ^ ((y) | ~(z)))
#endif
#define RIPEMD160_Go(x,y,z) (RIPEMD160_G ((x), (y), (z)))
#define RIPEMD160_Io(x,y,z) (RIPEMD160_I ((x), (y), (z)))
#endif
+6 -4
View File
@@ -1121,10 +1121,11 @@ extern hc_thread_mutex_t mux_display;
#define OPTI_TYPE_SINGLE_SALT (1 << 12)
#define OPTI_TYPE_BRUTE_FORCE (1 << 13)
#define OPTI_TYPE_RAW_HASH (1 << 14)
#define OPTI_TYPE_USES_BITS_8 (1 << 15)
#define OPTI_TYPE_USES_BITS_16 (1 << 16)
#define OPTI_TYPE_USES_BITS_32 (1 << 17)
#define OPTI_TYPE_USES_BITS_64 (1 << 18)
#define OPTI_TYPE_SLOW_HASH_SIMD (1 << 15)
#define OPTI_TYPE_USES_BITS_8 (1 << 16)
#define OPTI_TYPE_USES_BITS_16 (1 << 17)
#define OPTI_TYPE_USES_BITS_32 (1 << 18)
#define OPTI_TYPE_USES_BITS_64 (1 << 19)
#define OPTI_STR_ZERO_BYTE "Zero-Byte"
#define OPTI_STR_PRECOMPUTE_INIT "Precompute-Init"
@@ -1140,6 +1141,7 @@ extern hc_thread_mutex_t mux_display;
#define OPTI_STR_SINGLE_SALT "Single-Salt"
#define OPTI_STR_BRUTE_FORCE "Brute-Force"
#define OPTI_STR_RAW_HASH "Raw-Hash"
#define OPTI_STR_SLOW_HASH_SIMD "Slow-Hash-SIMD"
#define OPTI_STR_USES_BITS_8 "Uses-8-Bit"
#define OPTI_STR_USES_BITS_16 "Uses-16-Bit"
#define OPTI_STR_USES_BITS_32 "Uses-32-Bit"