diff --git a/OpenCL/amp_a1.cl b/OpenCL/amp_a1.cl index 5ab241211..1b0ef4c33 100644 --- a/OpenCL/amp_a1.cl +++ b/OpenCL/amp_a1.cl @@ -34,11 +34,70 @@ KERNEL_FQ void amp (GLOBAL_AS pw_t *pws, GLOBAL_AS pw_t *pws_amp, GLOBAL_AS cons switch_buffer_by_offset_1x64_le_S (pw.i, comb_len); } - #pragma unroll - for (int i = 0; i < 64; i++) - { - pw.i[i] |= comb.i[i]; - } + pw.i[ 0] |= comb.i[ 0]; + pw.i[ 1] |= comb.i[ 1]; + pw.i[ 2] |= comb.i[ 2]; + pw.i[ 3] |= comb.i[ 3]; + pw.i[ 4] |= comb.i[ 4]; + pw.i[ 5] |= comb.i[ 5]; + pw.i[ 6] |= comb.i[ 6]; + pw.i[ 7] |= comb.i[ 7]; + pw.i[ 8] |= comb.i[ 8]; + pw.i[ 9] |= comb.i[ 9]; + pw.i[10] |= comb.i[10]; + pw.i[11] |= comb.i[11]; + pw.i[12] |= comb.i[12]; + pw.i[13] |= comb.i[13]; + pw.i[14] |= comb.i[14]; + pw.i[15] |= comb.i[15]; + pw.i[16] |= comb.i[16]; + pw.i[17] |= comb.i[17]; + pw.i[18] |= comb.i[18]; + pw.i[19] |= comb.i[19]; + pw.i[20] |= comb.i[20]; + pw.i[21] |= comb.i[21]; + pw.i[22] |= comb.i[22]; + pw.i[23] |= comb.i[23]; + pw.i[24] |= comb.i[24]; + pw.i[25] |= comb.i[25]; + pw.i[26] |= comb.i[26]; + pw.i[27] |= comb.i[27]; + pw.i[28] |= comb.i[28]; + pw.i[29] |= comb.i[29]; + pw.i[30] |= comb.i[30]; + pw.i[31] |= comb.i[31]; + pw.i[32] |= comb.i[32]; + pw.i[33] |= comb.i[33]; + pw.i[34] |= comb.i[34]; + pw.i[35] |= comb.i[35]; + pw.i[36] |= comb.i[36]; + pw.i[37] |= comb.i[37]; + pw.i[38] |= comb.i[38]; + pw.i[39] |= comb.i[39]; + pw.i[40] |= comb.i[40]; + pw.i[41] |= comb.i[41]; + pw.i[42] |= comb.i[42]; + pw.i[43] |= comb.i[43]; + pw.i[44] |= comb.i[44]; + pw.i[45] |= comb.i[45]; + pw.i[46] |= comb.i[46]; + pw.i[47] |= comb.i[47]; + pw.i[48] |= comb.i[48]; + pw.i[49] |= comb.i[49]; + pw.i[50] |= comb.i[50]; + pw.i[51] |= comb.i[51]; + pw.i[52] |= comb.i[52]; + pw.i[53] |= comb.i[53]; + pw.i[54] |= comb.i[54]; + pw.i[55] |= comb.i[55]; + pw.i[56] |= comb.i[56]; + pw.i[57] |= comb.i[57]; + pw.i[58] |= comb.i[58]; + pw.i[59] |= comb.i[59]; + pw.i[60] |= comb.i[60]; + pw.i[61] |= comb.i[61]; + pw.i[62] |= comb.i[62]; + pw.i[63] |= comb.i[63]; pw.pw_len = pw_len + comb_len; diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index 09946e52f..407a24ef6 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -48,6 +48,390 @@ DECLSPEC u8 v8d_from_v32_S (const u32 v32) return v.v8.d; } +DECLSPEC u8 v8a_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.a; +} + +DECLSPEC u8 v8b_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.b; +} + +DECLSPEC u8 v8c_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.c; +} + +DECLSPEC u8 v8d_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.d; +} + +DECLSPEC u8 v8e_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.e; +} + +DECLSPEC u8 v8f_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.f; +} + +DECLSPEC u8 v8g_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.g; +} + +DECLSPEC u8 v8h_from_v64_S (const u64 v64) +{ + vconv64_t v; + + v.v64 = v64; + + return v.v8.h; +} + +DECLSPEC u8x v8a_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8a_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8a_from_v64_S (a.s0); + r.s1 = v8a_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8a_from_v64_S (a.s2); + r.s3 = v8a_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8a_from_v64_S (a.s4); + r.s5 = v8a_from_v64_S (a.s5); + r.s6 = v8a_from_v64_S (a.s6); + r.s7 = v8a_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8a_from_v64_S (a.s8); + r.s9 = v8a_from_v64_S (a.s9); + r.sa = v8a_from_v64_S (a.sa); + r.sb = v8a_from_v64_S (a.sb); + r.sc = v8a_from_v64_S (a.sc); + r.sd = v8a_from_v64_S (a.sd); + r.se = v8a_from_v64_S (a.se); + r.sf = v8a_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8b_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8b_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8b_from_v64_S (a.s0); + r.s1 = v8b_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8b_from_v64_S (a.s2); + r.s3 = v8b_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8b_from_v64_S (a.s4); + r.s5 = v8b_from_v64_S (a.s5); + r.s6 = v8b_from_v64_S (a.s6); + r.s7 = v8b_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8b_from_v64_S (a.s8); + r.s9 = v8b_from_v64_S (a.s9); + r.sa = v8b_from_v64_S (a.sa); + r.sb = v8b_from_v64_S (a.sb); + r.sc = v8b_from_v64_S (a.sc); + r.sd = v8b_from_v64_S (a.sd); + r.se = v8b_from_v64_S (a.se); + r.sf = v8b_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8c_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8c_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8c_from_v64_S (a.s0); + r.s1 = v8c_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8c_from_v64_S (a.s2); + r.s3 = v8c_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8c_from_v64_S (a.s4); + r.s5 = v8c_from_v64_S (a.s5); + r.s6 = v8c_from_v64_S (a.s6); + r.s7 = v8c_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8c_from_v64_S (a.s8); + r.s9 = v8c_from_v64_S (a.s9); + r.sa = v8c_from_v64_S (a.sa); + r.sb = v8c_from_v64_S (a.sb); + r.sc = v8c_from_v64_S (a.sc); + r.sd = v8c_from_v64_S (a.sd); + r.se = v8c_from_v64_S (a.se); + r.sf = v8c_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8d_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8d_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8d_from_v64_S (a.s0); + r.s1 = v8d_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8d_from_v64_S (a.s2); + r.s3 = v8d_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8d_from_v64_S (a.s4); + r.s5 = v8d_from_v64_S (a.s5); + r.s6 = v8d_from_v64_S (a.s6); + r.s7 = v8d_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8d_from_v64_S (a.s8); + r.s9 = v8d_from_v64_S (a.s9); + r.sa = v8d_from_v64_S (a.sa); + r.sb = v8d_from_v64_S (a.sb); + r.sc = v8d_from_v64_S (a.sc); + r.sd = v8d_from_v64_S (a.sd); + r.se = v8d_from_v64_S (a.se); + r.sf = v8d_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8e_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8e_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8e_from_v64_S (a.s0); + r.s1 = v8e_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8e_from_v64_S (a.s2); + r.s3 = v8e_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8e_from_v64_S (a.s4); + r.s5 = v8e_from_v64_S (a.s5); + r.s6 = v8e_from_v64_S (a.s6); + r.s7 = v8e_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8e_from_v64_S (a.s8); + r.s9 = v8e_from_v64_S (a.s9); + r.sa = v8e_from_v64_S (a.sa); + r.sb = v8e_from_v64_S (a.sb); + r.sc = v8e_from_v64_S (a.sc); + r.sd = v8e_from_v64_S (a.sd); + r.se = v8e_from_v64_S (a.se); + r.sf = v8e_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8f_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8f_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8f_from_v64_S (a.s0); + r.s1 = v8f_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8f_from_v64_S (a.s2); + r.s3 = v8f_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8f_from_v64_S (a.s4); + r.s5 = v8f_from_v64_S (a.s5); + r.s6 = v8f_from_v64_S (a.s6); + r.s7 = v8f_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8f_from_v64_S (a.s8); + r.s9 = v8f_from_v64_S (a.s9); + r.sa = v8f_from_v64_S (a.sa); + r.sb = v8f_from_v64_S (a.sb); + r.sc = v8f_from_v64_S (a.sc); + r.sd = v8f_from_v64_S (a.sd); + r.se = v8f_from_v64_S (a.se); + r.sf = v8f_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8g_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8g_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8g_from_v64_S (a.s0); + r.s1 = v8g_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8g_from_v64_S (a.s2); + r.s3 = v8g_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8g_from_v64_S (a.s4); + r.s5 = v8g_from_v64_S (a.s5); + r.s6 = v8g_from_v64_S (a.s6); + r.s7 = v8g_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8g_from_v64_S (a.s8); + r.s9 = v8g_from_v64_S (a.s9); + r.sa = v8g_from_v64_S (a.sa); + r.sb = v8g_from_v64_S (a.sb); + r.sc = v8g_from_v64_S (a.sc); + r.sd = v8g_from_v64_S (a.sd); + r.se = v8g_from_v64_S (a.se); + r.sf = v8g_from_v64_S (a.sf); + #endif + + return r; +} + +DECLSPEC u8x v8h_from_v64 (u64x a) +{ + u8x r = 0; + + #if VECT_SIZE == 1 + r = v8h_from_v64_S (a); + #endif + + #if VECT_SIZE >= 2 + r.s0 = v8h_from_v64_S (a.s0); + r.s1 = v8h_from_v64_S (a.s1); + #endif + + #if VECT_SIZE >= 4 + r.s2 = v8h_from_v64_S (a.s2); + r.s3 = v8h_from_v64_S (a.s3); + #endif + + #if VECT_SIZE >= 8 + r.s4 = v8h_from_v64_S (a.s4); + r.s5 = v8h_from_v64_S (a.s5); + r.s6 = v8h_from_v64_S (a.s6); + r.s7 = v8h_from_v64_S (a.s7); + #endif + + #if VECT_SIZE >= 16 + r.s8 = v8h_from_v64_S (a.s8); + r.s9 = v8h_from_v64_S (a.s9); + r.sa = v8h_from_v64_S (a.sa); + r.sb = v8h_from_v64_S (a.sb); + r.sc = v8h_from_v64_S (a.sc); + r.sd = v8h_from_v64_S (a.sd); + r.se = v8h_from_v64_S (a.se); + r.sf = v8h_from_v64_S (a.sf); + #endif + + return r; +} + DECLSPEC u16 v16a_from_v32_S (const u32 v32) { vconv32_t v; @@ -106,14 +490,202 @@ DECLSPEC u64 v64_from_v32ab_S (const u32 v32a, const u32 v32b) // unpack function are similar, but always return u32 +DECLSPEC u32x unpack_v8a_from_v32 (const u32x v32) +{ + u32x r = 0; + + #if defined IS_NV && HAS_BFE == 1 + + #if VECT_SIZE == 1 + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r) : "r"(v32)); + #endif + + #if VECT_SIZE >= 2 + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s0) : "r"(v32.s0)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s1) : "r"(v32.s1)); + #endif + + #if VECT_SIZE >= 4 + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s2) : "r"(v32.s2)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s3) : "r"(v32.s3)); + #endif + + #if VECT_SIZE >= 8 + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s4) : "r"(v32.s4)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s5) : "r"(v32.s5)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s6) : "r"(v32.s6)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s7) : "r"(v32.s7)); + #endif + + #if VECT_SIZE >= 16 + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s8) : "r"(v32.s8)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.s9) : "r"(v32.s9)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.sa) : "r"(v32.sa)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.sb) : "r"(v32.sb)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.sc) : "r"(v32.sc)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.sd) : "r"(v32.sd)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.se) : "r"(v32.se)); + asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r.sf) : "r"(v32.sf)); + #endif + + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 0, 8;" : "=v"(r) : "v"(v32)); + #else + r = (v32 >> 0) & 0xff; + #endif + + return r; +} + +DECLSPEC u32x unpack_v8b_from_v32 (const u32x v32) +{ + u32x r = 0; + + #if defined IS_NV && HAS_BFE == 1 + + #if VECT_SIZE == 1 + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r) : "r"(v32)); + #endif + + #if VECT_SIZE >= 2 + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s0) : "r"(v32.s0)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s1) : "r"(v32.s1)); + #endif + + #if VECT_SIZE >= 4 + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s2) : "r"(v32.s2)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s3) : "r"(v32.s3)); + #endif + + #if VECT_SIZE >= 8 + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s4) : "r"(v32.s4)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s5) : "r"(v32.s5)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s6) : "r"(v32.s6)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s7) : "r"(v32.s7)); + #endif + + #if VECT_SIZE >= 16 + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s8) : "r"(v32.s8)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.s9) : "r"(v32.s9)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.sa) : "r"(v32.sa)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.sb) : "r"(v32.sb)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.sc) : "r"(v32.sc)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.sd) : "r"(v32.sd)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.se) : "r"(v32.se)); + asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r.sf) : "r"(v32.sf)); + #endif + + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 8, 8;" : "=v"(r) : "v"(v32)); + #else + r = (v32 >> 8) & 0xff; + #endif + + return r; +} + +DECLSPEC u32x unpack_v8c_from_v32 (const u32x v32) +{ + u32x r = 0; + + #if defined IS_NV && HAS_BFE == 1 + + #if VECT_SIZE == 1 + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r) : "r"(v32)); + #endif + + #if VECT_SIZE >= 2 + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s0) : "r"(v32.s0)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s1) : "r"(v32.s1)); + #endif + + #if VECT_SIZE >= 4 + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s2) : "r"(v32.s2)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s3) : "r"(v32.s3)); + #endif + + #if VECT_SIZE >= 8 + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s4) : "r"(v32.s4)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s5) : "r"(v32.s5)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s6) : "r"(v32.s6)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s7) : "r"(v32.s7)); + #endif + + #if VECT_SIZE >= 16 + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s8) : "r"(v32.s8)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.s9) : "r"(v32.s9)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.sa) : "r"(v32.sa)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.sb) : "r"(v32.sb)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.sc) : "r"(v32.sc)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.sd) : "r"(v32.sd)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.se) : "r"(v32.se)); + asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r.sf) : "r"(v32.sf)); + #endif + + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 16, 8;" : "=v"(r) : "v"(v32)); + #else + r = (v32 >> 16) & 0xff; + #endif + + return r; +} + +DECLSPEC u32x unpack_v8d_from_v32 (const u32x v32) +{ + u32x r = 0; + + #if defined IS_NV && HAS_BFE == 1 + + #if VECT_SIZE == 1 + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r) : "r"(v32)); + #endif + + #if VECT_SIZE >= 2 + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s0) : "r"(v32.s0)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s1) : "r"(v32.s1)); + #endif + + #if VECT_SIZE >= 4 + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s2) : "r"(v32.s2)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s3) : "r"(v32.s3)); + #endif + + #if VECT_SIZE >= 8 + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s4) : "r"(v32.s4)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s5) : "r"(v32.s5)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s6) : "r"(v32.s6)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s7) : "r"(v32.s7)); + #endif + + #if VECT_SIZE >= 16 + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s8) : "r"(v32.s8)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.s9) : "r"(v32.s9)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.sa) : "r"(v32.sa)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.sb) : "r"(v32.sb)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.sc) : "r"(v32.sc)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.sd) : "r"(v32.sd)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.se) : "r"(v32.se)); + asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r.sf) : "r"(v32.sf)); + #endif + + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 24, 8;" : "=v"(r) : "v"(v32)); + #else + r = (v32 >> 24) & 0xff; + #endif + + return r; +} + DECLSPEC u32 unpack_v8a_from_v32_S (const u32 v32) { u32 r = 0; #if defined IS_NV && HAS_BFE == 1 asm volatile ("bfe.u32 %0, %1, 0, 8;" : "=r"(r) : "r"(v32)); - #elif defined IS_AMD && HAS_VBFE == 1 - __asm__ __volatile__ ("V_BFE_U32 %0, %1, 0, 8;" : "=v"(r) : "v"(v32)); + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 0, 8;" : "=v"(r) : "v"(v32)); #else r = (v32 >> 0) & 0xff; #endif @@ -127,8 +699,8 @@ DECLSPEC u32 unpack_v8b_from_v32_S (const u32 v32) #if defined IS_NV && HAS_BFE == 1 asm volatile ("bfe.u32 %0, %1, 8, 8;" : "=r"(r) : "r"(v32)); - #elif defined IS_AMD && HAS_VBFE == 1 - __asm__ __volatile__ ("V_BFE_U32 %0, %1, 8, 8;" : "=v"(r) : "v"(v32)); + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 8, 8;" : "=v"(r) : "v"(v32)); #else r = (v32 >> 8) & 0xff; #endif @@ -142,8 +714,8 @@ DECLSPEC u32 unpack_v8c_from_v32_S (const u32 v32) #if defined IS_NV && HAS_BFE == 1 asm volatile ("bfe.u32 %0, %1, 16, 8;" : "=r"(r) : "r"(v32)); - #elif defined IS_AMD && HAS_VBFE == 1 - __asm__ __volatile__ ("V_BFE_U32 %0, %1, 16, 8;" : "=v"(r) : "v"(v32)); + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 16, 8;" : "=v"(r) : "v"(v32)); #else r = (v32 >> 16) & 0xff; #endif @@ -157,8 +729,8 @@ DECLSPEC u32 unpack_v8d_from_v32_S (const u32 v32) #if defined IS_NV && HAS_BFE == 1 asm volatile ("bfe.u32 %0, %1, 24, 8;" : "=r"(r) : "r"(v32)); - #elif defined IS_AMD && HAS_VBFE == 1 - __asm__ __volatile__ ("V_BFE_U32 %0, %1, 24, 8;" : "=v"(r) : "v"(v32)); + //#elif defined IS_AMD && HAS_VBFE == 1 + //__asm__ __volatile__ ("V_BFE_U32 %0, %1, 24, 8;" : "=v"(r) : "v"(v32)); #else r = (v32 >> 24) & 0xff; #endif @@ -310,7 +882,11 @@ DECLSPEC u32x hc_rotl32 (const u32x a, const int n) #elif defined IS_CUDA return rotl32 (a, n); #else + #ifdef USE_ROTATE return rotate (a, make_u32x (n)); + #else + return ((a << n) | (a >> (32 - n))); + #endif #endif } @@ -321,7 +897,11 @@ DECLSPEC u32x hc_rotr32 (const u32x a, const int n) #elif defined IS_CUDA return rotr32 (a, n); #else + #ifdef USE_ROTATE return rotate (a, make_u32x (32 - n)); + #else + return ((a >> n) | (a << (32 - n))); + #endif #endif } @@ -332,7 +912,11 @@ DECLSPEC u32 hc_rotl32_S (const u32 a, const int n) #elif defined IS_CUDA return rotl32_S (a, n); #else + #ifdef USE_ROTATE return rotate (a, (u32) (n)); + #else + return ((a << n) | (a >> (32 - n))); + #endif #endif } @@ -343,7 +927,11 @@ DECLSPEC u32 hc_rotr32_S (const u32 a, const int n) #elif defined IS_CUDA return rotr32_S (a, n); #else + #ifdef USE_ROTATE return rotate (a, (u32) (32 - n)); + #else + return ((a >> n) | (a << (32 - n))); + #endif #endif } @@ -356,7 +944,11 @@ DECLSPEC u64x hc_rotl64 (const u64x a, const int n) #elif defined IS_AMD return rotl64 (a, n); #else + #ifdef USE_ROTATE return rotate (a, make_u64x (n)); + #else + return ((a << n) | (a >> (64 - n))); + #endif #endif } @@ -369,7 +961,11 @@ DECLSPEC u64x hc_rotr64 (const u64x a, const int n) #elif defined IS_AMD return rotr64 (a, n); #else + #ifdef USE_ROTATE return rotate (a, make_u64x (64 - n)); + #else + return ((a >> n) | (a << (64 - n))); + #endif #endif } @@ -382,7 +978,11 @@ DECLSPEC u64 hc_rotl64_S (const u64 a, const int n) #elif defined IS_AMD return rotl64_S (a, n); #else + #ifdef USE_ROTATE return rotate (a, (u64) (n)); + #else + return ((a << n) | (a >> (64 - n))); + #endif #endif } @@ -395,7 +995,11 @@ DECLSPEC u64 hc_rotr64_S (const u64 a, const int n) #elif defined IS_AMD return rotr64_S (a, n); #else + #ifdef USE_ROTATE return rotate (a, (u64) (64 - n)); + #else + return ((a >> n) | (a << (64 - n))); + #endif #endif } @@ -479,10 +1083,20 @@ DECLSPEC u32x hc_swap32 (const u32x v) #endif #else + + #if defined USE_BITSELECT && defined USE_ROTATE r = bitselect (rotate (v, make_u32x (24)), rotate (v, make_u32x ( 8)), make_u32x (0x00ff00ff)); + #else + r = ((v & make_u32x (0xff000000)) >> 24) + | ((v & make_u32x (0x00ff0000)) >> 8) + | ((v & make_u32x (0x0000ff00)) << 8) + | ((v & make_u32x (0x000000ff)) << 24); #endif + + #endif + #endif return r; @@ -500,7 +1114,14 @@ DECLSPEC u32 hc_swap32_S (const u32 v) #elif defined IS_NV && HAS_PRMT == 1 asm volatile ("prmt.b32 %0, %1, 0, 0x0123;" : "=r"(r) : "r"(v)); #else + #ifdef USE_SWIZZLE r = as_uint (as_uchar4 (v).s3210); + #else + r = ((v & 0xff000000) >> 24) + | ((v & 0x00ff0000) >> 8) + | ((v & 0x0000ff00) << 8) + | ((v & 0x000000ff) << 24); + #endif #endif #endif @@ -697,6 +1318,9 @@ DECLSPEC u64x hc_swap64 (const u64x v) #endif #else + + #if defined USE_BITSELECT && defined USE_ROTATE + r = bitselect (bitselect (rotate (v, make_u64x (24)), rotate (v, make_u64x ( 8)), make_u64x (0x000000ff000000ff)), @@ -704,6 +1328,19 @@ DECLSPEC u64x hc_swap64 (const u64x v) rotate (v, make_u64x (40)), make_u64x (0x00ff000000ff0000)), make_u64x (0xffff0000ffff0000)); + #else + + r = ((v & make_u64x (0xff00000000000000ULL)) >> 56) + | ((v & make_u64x (0x00ff000000000000ULL)) >> 40) + | ((v & make_u64x (0x0000ff0000000000ULL)) >> 24) + | ((v & make_u64x (0x000000ff00000000ULL)) >> 8) + | ((v & make_u64x (0x00000000ff000000ULL)) << 8) + | ((v & make_u64x (0x0000000000ff0000ULL)) << 24) + | ((v & make_u64x (0x000000000000ff00ULL)) << 40) + | ((v & make_u64x (0x00000000000000ffULL)) << 56); + + #endif + #endif #endif @@ -744,7 +1381,18 @@ DECLSPEC u64 hc_swap64_S (const u64 v) asm volatile ("mov.b64 %0, {%1, %2};" : "=l"(r) : "r"(tr), "r"(tl)); #else + #ifdef USE_SWIZZLE r = as_ulong (as_uchar8 (v).s76543210); + #else + r = ((v & (u64) 0xff00000000000000ULL) >> 56) + | ((v & (u64) 0x00ff000000000000ULL) >> 40) + | ((v & (u64) 0x0000ff0000000000ULL) >> 24) + | ((v & (u64) 0x000000ff00000000ULL) >> 8) + | ((v & (u64) 0x00000000ff000000ULL) << 8) + | ((v & (u64) 0x0000000000ff0000ULL) << 24) + | ((v & (u64) 0x000000000000ff00ULL) << 40) + | ((v & (u64) 0x00000000000000ffULL) << 56); + #endif #endif #endif @@ -854,17 +1502,11 @@ DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const int c) #endif #if VECT_SIZE >= 4 - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s0) : "v"(b.s0), "v"(a.s0), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s1) : "v"(b.s1), "v"(a.s1), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s2) : "v"(b.s2), "v"(a.s2), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s3) : "v"(b.s3), "v"(a.s3), "v"(c)); #endif #if VECT_SIZE >= 8 - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s0) : "v"(b.s0), "v"(a.s0), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s1) : "v"(b.s1), "v"(a.s1), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s2) : "v"(b.s2), "v"(a.s2), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s3) : "v"(b.s3), "v"(a.s3), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s4) : "v"(b.s4), "v"(a.s4), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s5) : "v"(b.s5), "v"(a.s5), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s6) : "v"(b.s6), "v"(a.s6), "v"(c)); @@ -872,14 +1514,6 @@ DECLSPEC u32x hc_byte_perm (const u32x a, const u32x b, const int c) #endif #if VECT_SIZE >= 16 - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s0) : "v"(b.s0), "v"(a.s0), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s1) : "v"(b.s1), "v"(a.s1), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s2) : "v"(b.s2), "v"(a.s2), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s3) : "v"(b.s3), "v"(a.s3), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s4) : "v"(b.s4), "v"(a.s4), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s5) : "v"(b.s5), "v"(a.s5), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s6) : "v"(b.s6), "v"(a.s6), "v"(c)); - __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s7) : "v"(b.s7), "v"(a.s7), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s8) : "v"(b.s8), "v"(a.s8), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.s9) : "v"(b.s9), "v"(a.s9), "v"(c)); __asm__ __volatile__ ("V_PERM_B32 %0, %1, %2, %3;" : "=v"(r.sa) : "v"(b.sa), "v"(a.sa), "v"(c)); @@ -919,17 +1553,11 @@ DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) #endif #if VECT_SIZE >= 4 - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s0) : "v"(b.s0), "v"(a.s0), "v"(c.s0)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s1) : "v"(b.s1), "v"(a.s1), "v"(c.s1)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s2) : "v"(b.s2), "v"(a.s2), "v"(c.s2)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s3) : "v"(b.s3), "v"(a.s3), "v"(c.s3)); #endif #if VECT_SIZE >= 8 - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s0) : "v"(b.s0), "v"(a.s0), "v"(c.s0)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s1) : "v"(b.s1), "v"(a.s1), "v"(c.s1)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s2) : "v"(b.s2), "v"(a.s2), "v"(c.s2)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s3) : "v"(b.s3), "v"(a.s3), "v"(c.s3)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s4) : "v"(b.s4), "v"(a.s4), "v"(c.s4)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s5) : "v"(b.s5), "v"(a.s5), "v"(c.s5)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s6) : "v"(b.s6), "v"(a.s6), "v"(c.s6)); @@ -937,14 +1565,6 @@ DECLSPEC u32x hc_add3 (const u32x a, const u32x b, const u32x c) #endif #if VECT_SIZE >= 16 - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s0) : "v"(b.s0), "v"(a.s0), "v"(c.s0)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s1) : "v"(b.s1), "v"(a.s1), "v"(c.s1)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s2) : "v"(b.s2), "v"(a.s2), "v"(c.s2)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s3) : "v"(b.s3), "v"(a.s3), "v"(c.s3)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s4) : "v"(b.s4), "v"(a.s4), "v"(c.s4)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s5) : "v"(b.s5), "v"(a.s5), "v"(c.s5)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s6) : "v"(b.s6), "v"(a.s6), "v"(c.s6)); - __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s7) : "v"(b.s7), "v"(a.s7), "v"(c.s7)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s8) : "v"(b.s8), "v"(a.s8), "v"(c.s8)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.s9) : "v"(b.s9), "v"(a.s9), "v"(c.s9)); __asm__ __volatile__ ("V_ADD3_U32 %0, %1, %2, %3;" : "=v"(r.sa) : "v"(b.sa), "v"(a.sa), "v"(c.sa)); @@ -1502,7 +2122,7 @@ DECLSPEC int hc_find_keyboard_layout_map (const u32 search, const int search_len return -1; } -DECLSPEC int hc_execute_keyboard_layout_mapping (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt) +DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt) { u32 out_buf[16] = { 0 }; @@ -60851,145 +61471,3 @@ DECLSPEC void append_0x80_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const #endif } - -DECLSPEC void gpu_decompress_entry (GLOBAL_AS pw_idx_t *pws_idx, GLOBAL_AS u32 *pws_comp, pw_t *pw, const u64 gid) -{ - const u32 off = pws_idx[gid].off; - const u32 cnt = pws_idx[gid].cnt; - const u32 len = pws_idx[gid].len; - - #ifdef _unroll - #pragma unroll - #endif - for (u32 i = 0; i < 64; i++) - { - pw->i[i] = 0; - } - - for (u32 i = 0, j = off; i < cnt; i++, j++) - { - pw->i[i] = pws_comp[j]; - } - - pw->pw_len = len; -} - -KERNEL_FQ void gpu_decompress (GLOBAL_AS pw_idx_t *pws_idx, GLOBAL_AS u32 *pws_comp, GLOBAL_AS pw_t *pws_buf, const u64 gid_max) -{ - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - - pw_t pw; - - gpu_decompress_entry (pws_idx, pws_comp, &pw, gid); - - pws_buf[gid] = pw; -} - -KERNEL_FQ void gpu_memset (GLOBAL_AS uint4 *buf, const u32 value, const u64 gid_max) -{ - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - - uint4 r; - - #if defined IS_NATIVE - r = value; - #elif defined IS_OPENCL - r.s0 = value; - r.s1 = value; - r.s2 = value; - r.s3 = value; - #elif defined IS_CUDA - r.x = value; - r.y = value; - r.z = value; - r.w = value; - #endif - - buf[gid] = r; -} - -KERNEL_FQ void gpu_atinit (GLOBAL_AS pw_t *buf, const u64 gid_max) -{ - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - - const u32 l32 = l32_from_64_S (gid); - const u32 h32 = h32_from_64_S (gid); - - pw_t pw; - - pw.i[ 0] = 0x5c5c5c5c ^ l32; - pw.i[ 1] = 0x36363636 ^ h32; - pw.i[ 2] = 0; - pw.i[ 3] = 0; - pw.i[ 4] = 0; - pw.i[ 5] = 0; - pw.i[ 6] = 0; - pw.i[ 7] = 0; - pw.i[ 8] = 0; - pw.i[ 9] = 0; - pw.i[10] = 0; - pw.i[11] = 0; - pw.i[12] = 0; - pw.i[13] = 0; - pw.i[14] = 0; - pw.i[15] = 0; - pw.i[16] = 0; - pw.i[17] = 0; - pw.i[18] = 0; - pw.i[19] = 0; - pw.i[20] = 0; - pw.i[21] = 0; - pw.i[22] = 0; - pw.i[23] = 0; - pw.i[24] = 0; - pw.i[25] = 0; - pw.i[26] = 0; - pw.i[27] = 0; - pw.i[28] = 0; - pw.i[29] = 0; - pw.i[30] = 0; - pw.i[31] = 0; - pw.i[32] = 0; - pw.i[33] = 0; - pw.i[34] = 0; - pw.i[35] = 0; - pw.i[36] = 0; - pw.i[37] = 0; - pw.i[38] = 0; - pw.i[39] = 0; - pw.i[40] = 0; - pw.i[41] = 0; - pw.i[42] = 0; - pw.i[43] = 0; - pw.i[44] = 0; - pw.i[45] = 0; - pw.i[46] = 0; - pw.i[47] = 0; - pw.i[48] = 0; - pw.i[49] = 0; - pw.i[50] = 0; - pw.i[51] = 0; - pw.i[52] = 0; - pw.i[53] = 0; - pw.i[54] = 0; - pw.i[55] = 0; - pw.i[56] = 0; - pw.i[57] = 0; - pw.i[58] = 0; - pw.i[59] = 0; - pw.i[60] = 0; - pw.i[61] = 0; - pw.i[62] = 0; - pw.i[63] = 0; // yep that's faster - - //pw.pw_len = 1 + (l32 & 15); - pw.pw_len = 7; // some algorithms are very sensible on this (example: 12500) - - buf[gid] = pw; -} diff --git a/OpenCL/inc_common.h b/OpenCL/inc_common.h index 58a6bbeb5..07137297b 100644 --- a/OpenCL/inc_common.h +++ b/OpenCL/inc_common.h @@ -110,27 +110,29 @@ */ #ifdef IS_CUDA -#define KERN_ATTR_BASIC() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, void) -#define KERN_ATTR_BITSLICE() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bs_word_t *g_words_buf_s, void, void, void) -#define KERN_ATTR_ESALT(e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, e) -#define KERN_ATTR_RULES() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, void) -#define KERN_ATTR_RULES_ESALT(e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, e) -#define KERN_ATTR_TMPS(t) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, void, void) -#define KERN_ATTR_TMPS_ESALT(t,e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, void, e) -#define KERN_ATTR_TMPS_HOOKS(t,h) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, h, void) -#define KERN_ATTR_VECTOR() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const u32x *g_words_buf_r, void, void, void) -#define KERN_ATTR_VECTOR_ESALT(e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const u32x *g_words_buf_r, void, void, e) +#define KERN_ATTR_BASIC() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, void) +#define KERN_ATTR_BITSLICE() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bs_word_t *g_words_buf_s, void, void, void) +#define KERN_ATTR_ESALT(e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, e) +#define KERN_ATTR_RULES() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, void) +#define KERN_ATTR_RULES_ESALT(e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, void, void, e) +#define KERN_ATTR_TMPS(t) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, void, void) +#define KERN_ATTR_TMPS_ESALT(t,e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, void, e) +#define KERN_ATTR_TMPS_HOOKS(t,h) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, h, void) +#define KERN_ATTR_TMPS_HOOKS_ESALT(t,h,e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const bf_t *g_bfs_buf, t, h, e) +#define KERN_ATTR_VECTOR() KERN_ATTR (GLOBAL_AS, GLOBAL_AS const u32x *g_words_buf_r, void, void, void) +#define KERN_ATTR_VECTOR_ESALT(e) KERN_ATTR (GLOBAL_AS, GLOBAL_AS const u32x *g_words_buf_r, void, void, e) #else -#define KERN_ATTR_BASIC() KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, void, void, void) -#define KERN_ATTR_BITSLICE() KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bs_word_t *words_buf_s, void, void, void) -#define KERN_ATTR_ESALT(e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, void, void, e) -#define KERN_ATTR_RULES() KERN_ATTR (CONSTANT_AS, GLOBAL_AS const bf_t *bfs_buf, void, void, void) -#define KERN_ATTR_RULES_ESALT(e) KERN_ATTR (CONSTANT_AS, GLOBAL_AS const bf_t *bfs_buf, void, void, e) -#define KERN_ATTR_TMPS(t) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, void, void) -#define KERN_ATTR_TMPS_ESALT(t,e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, void, e) -#define KERN_ATTR_TMPS_HOOKS(t,h) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, h, void) -#define KERN_ATTR_VECTOR() KERN_ATTR (GLOBAL_AS, CONSTANT_AS const u32x *words_buf_r, void, void, void) -#define KERN_ATTR_VECTOR_ESALT(e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const u32x *words_buf_r, void, void, e) +#define KERN_ATTR_BASIC() KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, void, void, void) +#define KERN_ATTR_BITSLICE() KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bs_word_t *words_buf_s, void, void, void) +#define KERN_ATTR_ESALT(e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, void, void, e) +#define KERN_ATTR_RULES() KERN_ATTR (CONSTANT_AS, GLOBAL_AS const bf_t *bfs_buf, void, void, void) +#define KERN_ATTR_RULES_ESALT(e) KERN_ATTR (CONSTANT_AS, GLOBAL_AS const bf_t *bfs_buf, void, void, e) +#define KERN_ATTR_TMPS(t) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, void, void) +#define KERN_ATTR_TMPS_ESALT(t,e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, void, e) +#define KERN_ATTR_TMPS_HOOKS(t,h) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, h, void) +#define KERN_ATTR_TMPS_HOOKS_ESALT(t,h,e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const bf_t *bfs_buf, t, h, e) +#define KERN_ATTR_VECTOR() KERN_ATTR (GLOBAL_AS, CONSTANT_AS const u32x *words_buf_r, void, void, void) +#define KERN_ATTR_VECTOR_ESALT(e) KERN_ATTR (GLOBAL_AS, CONSTANT_AS const u32x *words_buf_r, void, void, e) #endif // union based packing @@ -140,6 +142,24 @@ DECLSPEC u8 v8b_from_v32_S (const u32 v32); DECLSPEC u8 v8c_from_v32_S (const u32 v32); DECLSPEC u8 v8d_from_v32_S (const u32 v32); +DECLSPEC u8 v8a_from_v64_S (const u64 v64); +DECLSPEC u8 v8b_from_v64_S (const u64 v64); +DECLSPEC u8 v8c_from_v64_S (const u64 v64); +DECLSPEC u8 v8d_from_v64_S (const u64 v64); +DECLSPEC u8 v8e_from_v64_S (const u64 v64); +DECLSPEC u8 v8f_from_v64_S (const u64 v64); +DECLSPEC u8 v8g_from_v64_S (const u64 v64); +DECLSPEC u8 v8h_from_v64_S (const u64 v64); + +DECLSPEC u8x v8a_from_v64 (const u64x v64); +DECLSPEC u8x v8b_from_v64 (const u64x v64); +DECLSPEC u8x v8c_from_v64 (const u64x v64); +DECLSPEC u8x v8d_from_v64 (const u64x v64); +DECLSPEC u8x v8e_from_v64 (const u64x v64); +DECLSPEC u8x v8f_from_v64 (const u64x v64); +DECLSPEC u8x v8g_from_v64 (const u64x v64); +DECLSPEC u8x v8h_from_v64 (const u64x v64); + DECLSPEC u16 v16a_from_v32_S (const u32 v32); DECLSPEC u16 v16b_from_v32_S (const u32 v32); @@ -151,6 +171,11 @@ DECLSPEC u64 v64_from_v32ab_S (const u32 v32a, const u32 v32b); // inline asm packing +DECLSPEC u32x unpack_v8a_from_v32 (const u32x v32); +DECLSPEC u32x unpack_v8b_from_v32 (const u32x v32); +DECLSPEC u32x unpack_v8c_from_v32 (const u32x v32); +DECLSPEC u32x unpack_v8d_from_v32 (const u32x v32); + DECLSPEC u32 unpack_v8a_from_v32_S (const u32 v32); DECLSPEC u32 unpack_v8b_from_v32_S (const u32 v32); DECLSPEC u32 unpack_v8c_from_v32_S (const u32 v32); @@ -217,7 +242,7 @@ DECLSPEC int is_valid_hex_32 (const u32 v); DECLSPEC int is_valid_base58_8 (const u8 v); DECLSPEC int is_valid_base58_32 (const u32 v); DECLSPEC int hc_find_keyboard_layout_map (const u32 search, const int search_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); -DECLSPEC int hc_execute_keyboard_layout_mapping (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); +DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); DECLSPEC void make_utf16be (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16beN (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16le (const u32x *in, u32x *out1, u32x *out2); @@ -275,6 +300,5 @@ DECLSPEC void append_0x01_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const DECLSPEC void append_0x06_2x4_VV (u32x *w0, u32x *w1, const u32x offset); DECLSPEC void append_0x80_2x4_VV (u32x *w0, u32x *w1, const u32x offset); DECLSPEC void append_0x80_4x4_VV (u32x *w0, u32x *w1, u32x *w2, u32x *w3, const u32x offset); -DECLSPEC void gpu_decompress_entry (GLOBAL_AS pw_idx_t *pws_idx, GLOBAL_AS u32 *pws_comp, pw_t *pw, const u64 gid); #endif diff --git a/OpenCL/inc_ecc_secp256k1.cl b/OpenCL/inc_ecc_secp256k1.cl new file mode 100644 index 000000000..ff877ca11 --- /dev/null +++ b/OpenCL/inc_ecc_secp256k1.cl @@ -0,0 +1,2064 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + * + * Furthermore, since elliptic curve operations are highly researched and optimized, + * we've consulted a lot of online resources to implement this, including several papers and + * example code. + * + * Credits where credits are due: there are a lot of nice projects that explain and/or optimize + * elliptic curve operations (especially elliptic curve multiplications by a scalar). + * + * We want to shout out following projects, which were quite helpful when implementing this: + * - secp256k1 by Pieter Wuille (https://github.com/bitcoin-core/secp256k1/, MIT) + * - secp256k1-cl by hhanh00 (https://github.com/hhanh00/secp256k1-cl/, MIT) + * - ec_pure_c by masterzorag (https://github.com/masterzorag/ec_pure_c/) + * - ecc-gmp by leivaburto (https://github.com/leivaburto/ecc-gmp) + * - micro-ecc by Ken MacKay (https://github.com/kmackay/micro-ecc/, BSD) + * - curve_example by willem (https://gist.github.com/nlitsme/c9031c7b9bf6bb009e5a) + * - py_ecc by Vitalik Buterin (https://github.com/ethereum/py_ecc/, MIT) + * + * + * Some BigNum operations are implemented similar to micro-ecc which is licensed under these terms: + * Copyright 2014 Ken MacKay, 2-Clause BSD License + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * ATTENTION: this code is NOT meant to be used in security critical environments that are at risk + * of side-channel or timing attacks etc, it's only purpose is to make it work fast for GPGPU + * (OpenCL/CUDA). Some attack vectors like side-channel and timing-attacks might be possible, + * because of some optimizations used within this code (non-constant time etc). + */ + +/* + * Implementation considerations: + * point double and point add are implemented similar to algorithms mentioned in this 2011 paper: + * http://eprint.iacr.org/2011/338.pdf + * (Fast and Regular Algorithms for Scalar Multiplication over Elliptic Curves by Matthieu Rivain) + * + * In theory we could use the Jacobian Co-Z enhancement to get rid of the larger buffer caused by + * the z coordinates (and in this way reduce register pressure etc). + * For the Co-Z improvement there are a lot of fast algorithms, but we might still be faster + * with this implementation (b/c we allow non-constant time) without the Brier/Joye Montgomery-like + * ladder. Of course, this claim would need to be verified and tested to see which one is faster + * for our specific scenario at the end. + * + * We accomplish a "little" speedup by using scalars converted to w-NAF (non-adjacent form): + * The general idea of w-NAF is to pre-compute some zi coefficients like below to reduce the + * costly point additions by using a non-binary ("signed") number system (values other than just + * 0 and 1, but ranging from -2^(w-1)-1 to 2^(w-1)-1). This works best with the left-to-right + * binary algorithm such that we just add zi * P when adding point P (we pre-compute all the + * possible zi * P values because the x/y coordinates are known before the kernel starts): + * + * // Example with window size w = 2 (i.e. mod 4 => & 3): + * // 173 => 1 0 -1 0 -1 0 -1 0 1 = 2^8 - 2^6 - 2^4 - 2^2 + 1 + * int e = 0b10101101; // 173 + * int z[8 + 1] = { 0 }; // our zi/di, we need one extra slot to make the subtraction work + * + * int i = 0; + * + * while (e) + * { + * if (e & 1) + * { + * // for window size w = 3 it would be: + * // => 2^(w-0) = 2^3 = 8 + * // => 2^(w-1) = 2^2 = 4 + * + * int bit; // = 2 - (e & 3) for w = 2 + * + * if ((e & 3) >= 2) // e % 4 == e & 3, use (e & 7) >= 4 for w = 3 + * bit = (e & 3) - 4; // (e & 7) - 8 for w = 3 + * else + * bit = e & 3; // e & 7 for w = 3 + * + * z[i] = bit; + * e -= bit; + * } + * + * e >>= 1; // e / 2 + * i++; + * } +*/ + +#include "inc_ecc_secp256k1.h" + +DECLSPEC u32 sub (u32 *r, const u32 *a, const u32 *b) +{ + u32 c = 0; // carry/borrow + + #if defined IS_NV && HAS_SUB == 1 && HAS_SUBC == 1 + asm volatile + ( + "sub.cc.u32 %0, %9, %17;" + "subc.cc.u32 %1, %10, %18;" + "subc.cc.u32 %2, %11, %19;" + "subc.cc.u32 %3, %12, %20;" + "subc.cc.u32 %4, %13, %21;" + "subc.cc.u32 %5, %14, %22;" + "subc.cc.u32 %6, %15, %23;" + "subc.cc.u32 %7, %16, %24;" + "subc.u32 %8, 0, 0;" + : "=r"(r[0]), "=r"(r[1]), "=r"(r[2]), "=r"(r[3]), "=r"(r[4]), "=r"(r[5]), "=r"(r[6]), "=r"(r[7]), + "=r"(c) + : "r"(a[0]), "r"(a[1]), "r"(a[2]), "r"(a[3]), "r"(a[4]), "r"(a[5]), "r"(a[6]), "r"(a[7]), + "r"(b[0]), "r"(b[1]), "r"(b[2]), "r"(b[3]), "r"(b[4]), "r"(b[5]), "r"(b[6]), "r"(b[7]) + ); + #elif defined IS_AMD && HAS_VSUB == 1 && HAS_VSUBB == 1 + __asm__ __volatile__ + ( + "V_SUB_U32 %0, %9, %17;" + "V_SUBB_U32 %1, %10, %18;" + "V_SUBB_U32 %2, %11, %19;" + "V_SUBB_U32 %3, %12, %20;" + "V_SUBB_U32 %4, %13, %21;" + "V_SUBB_U32 %5, %14, %22;" + "V_SUBB_U32 %6, %15, %23;" + "V_SUBB_U32 %7, %16, %24;" + "V_SUBB_U32 %8, 0, 0;" + : "=v"(r[0]), "=v"(r[1]), "=v"(r[2]), "=v"(r[3]), "=v"(r[4]), "=v"(r[5]), "=v"(r[6]), "=v"(r[7]), + "=v"(c) + : "v"(a[0]), "v"(a[1]), "v"(a[2]), "v"(a[3]), "v"(a[4]), "v"(a[5]), "v"(a[6]), "v"(a[7]), + "v"(b[0]), "v"(b[1]), "v"(b[2]), "v"(b[3]), "v"(b[4]), "v"(b[5]), "v"(b[6]), "v"(b[7]) + ); + #else + for (u32 i = 0; i < 8; i++) + { + const u32 diff = a[i] - b[i] - c; + + if (diff != a[i]) c = (diff > a[i]); + + r[i] = diff; + } + #endif + + return c; +} + +DECLSPEC u32 add (u32 *r, const u32 *a, const u32 *b) +{ + u32 c = 0; // carry/borrow + + #if defined IS_NV && HAS_ADD == 1 && HAS_ADDC == 1 + asm volatile + ( + "add.cc.u32 %0, %9, %17;" + "addc.cc.u32 %1, %10, %18;" + "addc.cc.u32 %2, %11, %19;" + "addc.cc.u32 %3, %12, %20;" + "addc.cc.u32 %4, %13, %21;" + "addc.cc.u32 %5, %14, %22;" + "addc.cc.u32 %6, %15, %23;" + "addc.cc.u32 %7, %16, %24;" + "addc.u32 %8, 0, 0;" + : "=r"(r[0]), "=r"(r[1]), "=r"(r[2]), "=r"(r[3]), "=r"(r[4]), "=r"(r[5]), "=r"(r[6]), "=r"(r[7]), + "=r"(c) + : "r"(a[0]), "r"(a[1]), "r"(a[2]), "r"(a[3]), "r"(a[4]), "r"(a[5]), "r"(a[6]), "r"(a[7]), + "r"(b[0]), "r"(b[1]), "r"(b[2]), "r"(b[3]), "r"(b[4]), "r"(b[5]), "r"(b[6]), "r"(b[7]) + ); + #elif defined IS_AMD && HAS_VADD == 1 && HAS_VADDC == 1 + __asm__ __volatile__ + ( + "V_ADD_U32 %0, %9, %17;" + "V_ADDC_U32 %1, %10, %18;" + "V_ADDC_U32 %2, %11, %19;" + "V_ADDC_U32 %3, %12, %20;" + "V_ADDC_U32 %4, %13, %21;" + "V_ADDC_U32 %5, %14, %22;" + "V_ADDC_U32 %6, %15, %23;" + "V_ADDC_U32 %7, %16, %24;" + "V_ADDC_U32 %8, 0, 0;" + : "=v"(r[0]), "=v"(r[1]), "=v"(r[2]), "=v"(r[3]), "=v"(r[4]), "=v"(r[5]), "=v"(r[6]), "=v"(r[7]), + "=v"(c) + : "v"(a[0]), "v"(a[1]), "v"(a[2]), "v"(a[3]), "v"(a[4]), "v"(a[5]), "v"(a[6]), "v"(a[7]), + "v"(b[0]), "v"(b[1]), "v"(b[2]), "v"(b[3]), "v"(b[4]), "v"(b[5]), "v"(b[6]), "v"(b[7]) + ); + #else + for (u32 i = 0; i < 8; i++) + { + const u32 t = a[i] + b[i] + c; + + if (t != a[i]) c = (t < a[i]); + + r[i] = t; + } + #endif + + return c; +} + +DECLSPEC void sub_mod (u32 *r, const u32 *a, const u32 *b) +{ + const u32 c = sub (r, a, b); // carry + + if (c) + { + u32 t[8]; + + t[0] = SECP256K1_P0; + t[1] = SECP256K1_P1; + t[2] = SECP256K1_P2; + t[3] = SECP256K1_P3; + t[4] = SECP256K1_P4; + t[5] = SECP256K1_P5; + t[6] = SECP256K1_P6; + t[7] = SECP256K1_P7; + + add (r, r, t); + } +} + +DECLSPEC void add_mod (u32 *r, const u32 *a, const u32 *b) +{ + const u32 c = add (r, a, b); // carry + + /* + * Modulo operation: + */ + + // note: we could have an early exit in case of c == 1 => sub () + + u32 t[8]; + + t[0] = SECP256K1_P0; + t[1] = SECP256K1_P1; + t[2] = SECP256K1_P2; + t[3] = SECP256K1_P3; + t[4] = SECP256K1_P4; + t[5] = SECP256K1_P5; + t[6] = SECP256K1_P6; + t[7] = SECP256K1_P7; + + // check if modulo operation is needed + + u32 mod = 1; + + if (c == 0) + { + for (int i = 7; i >= 0; i--) + { + if (r[i] < t[i]) + { + mod = 0; + + break; // or return ! (check if faster) + } + + if (r[i] > t[i]) break; + } + } + + if (mod == 1) + { + sub (r, r, t); + } +} + +DECLSPEC void mod_512 (u32 *n) +{ + // we need to perform a modulo operation with 512-bit % 256-bit (bignum modulo): + // the modulus is the secp256k1 group order + + // ATTENTION: for this function the byte-order is reversed (most significant bytes + // at the left) + + /* + the general modulo by shift and substract code (a = a % b): + + x = b; + + t = a >> 1; + + while (x <= t) x <<= 1; + + while (a >= b) + { + if (a >= x) a -= x; + + x >>= 1; + } + + return a; // remainder + */ + + u32 a[16]; + + a[ 0] = n[ 0]; + a[ 1] = n[ 1]; + a[ 2] = n[ 2]; + a[ 3] = n[ 3]; + a[ 4] = n[ 4]; + a[ 5] = n[ 5]; + a[ 6] = n[ 6]; + a[ 7] = n[ 7]; + a[ 8] = n[ 8]; + a[ 9] = n[ 9]; + a[10] = n[10]; + a[11] = n[11]; + a[12] = n[12]; + a[13] = n[13]; + a[14] = n[14]; + a[15] = n[15]; + + u32 b[16]; + + b[ 0] = 0x00000000; + b[ 1] = 0x00000000; + b[ 2] = 0x00000000; + b[ 3] = 0x00000000; + b[ 4] = 0x00000000; + b[ 5] = 0x00000000; + b[ 6] = 0x00000000; + b[ 7] = 0x00000000; + b[ 8] = SECP256K1_N7; + b[ 9] = SECP256K1_N6; + b[10] = SECP256K1_N5; + b[11] = SECP256K1_N4; + b[12] = SECP256K1_N3; + b[13] = SECP256K1_N2; + b[14] = SECP256K1_N1; + b[15] = SECP256K1_N0; + + /* + * Start: + */ + + // x = b (but with a fast "shift" trick to avoid the while loop) + + u32 x[16]; + + x[ 0] = b[ 8]; // this is a trick: we just put the group order's most significant bit all the + x[ 1] = b[ 9]; // way to the top to avoid doing the initial: while (x <= t) x <<= 1 + x[ 2] = b[10]; + x[ 3] = b[11]; + x[ 4] = b[12]; + x[ 5] = b[13]; + x[ 6] = b[14]; + x[ 7] = b[15]; + x[ 8] = 0x00000000; + x[ 9] = 0x00000000; + x[10] = 0x00000000; + x[11] = 0x00000000; + x[12] = 0x00000000; + x[13] = 0x00000000; + x[14] = 0x00000000; + x[15] = 0x00000000; + + // a >= b + + while (a[0] >= b[0]) + { + u32 l00 = a[ 0] < b[ 0]; + u32 l01 = a[ 1] < b[ 1]; + u32 l02 = a[ 2] < b[ 2]; + u32 l03 = a[ 3] < b[ 3]; + u32 l04 = a[ 4] < b[ 4]; + u32 l05 = a[ 5] < b[ 5]; + u32 l06 = a[ 6] < b[ 6]; + u32 l07 = a[ 7] < b[ 7]; + u32 l08 = a[ 8] < b[ 8]; + u32 l09 = a[ 9] < b[ 9]; + u32 l10 = a[10] < b[10]; + u32 l11 = a[11] < b[11]; + u32 l12 = a[12] < b[12]; + u32 l13 = a[13] < b[13]; + u32 l14 = a[14] < b[14]; + u32 l15 = a[15] < b[15]; + + u32 e00 = a[ 0] == b[ 0]; + u32 e01 = a[ 1] == b[ 1]; + u32 e02 = a[ 2] == b[ 2]; + u32 e03 = a[ 3] == b[ 3]; + u32 e04 = a[ 4] == b[ 4]; + u32 e05 = a[ 5] == b[ 5]; + u32 e06 = a[ 6] == b[ 6]; + u32 e07 = a[ 7] == b[ 7]; + u32 e08 = a[ 8] == b[ 8]; + u32 e09 = a[ 9] == b[ 9]; + u32 e10 = a[10] == b[10]; + u32 e11 = a[11] == b[11]; + u32 e12 = a[12] == b[12]; + u32 e13 = a[13] == b[13]; + u32 e14 = a[14] == b[14]; + + if (l00) break; + if (l01 && e00) break; + if (l02 && e00 && e01) break; + if (l03 && e00 && e01 && e02) break; + if (l04 && e00 && e01 && e02 && e03) break; + if (l05 && e00 && e01 && e02 && e03 && e04) break; + if (l06 && e00 && e01 && e02 && e03 && e04 && e05) break; + if (l07 && e00 && e01 && e02 && e03 && e04 && e05 && e06) break; + if (l08 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07) break; + if (l09 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08) break; + if (l10 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09) break; + if (l11 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10) break; + if (l12 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11) break; + if (l13 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11 && e12) break; + if (l14 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11 && e12 && e13) break; + if (l15 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11 && e12 && e13 && e14) break; + + // r = x (copy it to have the original values for the subtraction) + + u32 r[16]; + + r[ 0] = x[ 0]; + r[ 1] = x[ 1]; + r[ 2] = x[ 2]; + r[ 3] = x[ 3]; + r[ 4] = x[ 4]; + r[ 5] = x[ 5]; + r[ 6] = x[ 6]; + r[ 7] = x[ 7]; + r[ 8] = x[ 8]; + r[ 9] = x[ 9]; + r[10] = x[10]; + r[11] = x[11]; + r[12] = x[12]; + r[13] = x[13]; + r[14] = x[14]; + r[15] = x[15]; + + // x <<= 1 + + x[15] = x[15] >> 1 | x[14] << 31; + x[14] = x[14] >> 1 | x[13] << 31; + x[13] = x[13] >> 1 | x[12] << 31; + x[12] = x[12] >> 1 | x[11] << 31; + x[11] = x[11] >> 1 | x[10] << 31; + x[10] = x[10] >> 1 | x[ 9] << 31; + x[ 9] = x[ 9] >> 1 | x[ 8] << 31; + x[ 8] = x[ 8] >> 1 | x[ 7] << 31; + x[ 7] = x[ 7] >> 1 | x[ 6] << 31; + x[ 6] = x[ 6] >> 1 | x[ 5] << 31; + x[ 5] = x[ 5] >> 1 | x[ 4] << 31; + x[ 4] = x[ 4] >> 1 | x[ 3] << 31; + x[ 3] = x[ 3] >> 1 | x[ 2] << 31; + x[ 2] = x[ 2] >> 1 | x[ 1] << 31; + x[ 1] = x[ 1] >> 1 | x[ 0] << 31; + x[ 0] = x[ 0] >> 1; + + // if (a >= r) a -= r; + + l00 = a[ 0] < r[ 0]; + l01 = a[ 1] < r[ 1]; + l02 = a[ 2] < r[ 2]; + l03 = a[ 3] < r[ 3]; + l04 = a[ 4] < r[ 4]; + l05 = a[ 5] < r[ 5]; + l06 = a[ 6] < r[ 6]; + l07 = a[ 7] < r[ 7]; + l08 = a[ 8] < r[ 8]; + l09 = a[ 9] < r[ 9]; + l10 = a[10] < r[10]; + l11 = a[11] < r[11]; + l12 = a[12] < r[12]; + l13 = a[13] < r[13]; + l14 = a[14] < r[14]; + l15 = a[15] < r[15]; + + e00 = a[ 0] == r[ 0]; + e01 = a[ 1] == r[ 1]; + e02 = a[ 2] == r[ 2]; + e03 = a[ 3] == r[ 3]; + e04 = a[ 4] == r[ 4]; + e05 = a[ 5] == r[ 5]; + e06 = a[ 6] == r[ 6]; + e07 = a[ 7] == r[ 7]; + e08 = a[ 8] == r[ 8]; + e09 = a[ 9] == r[ 9]; + e10 = a[10] == r[10]; + e11 = a[11] == r[11]; + e12 = a[12] == r[12]; + e13 = a[13] == r[13]; + e14 = a[14] == r[14]; + + if (l00) continue; + if (l01 && e00) continue; + if (l02 && e00 && e01) continue; + if (l03 && e00 && e01 && e02) continue; + if (l04 && e00 && e01 && e02 && e03) continue; + if (l05 && e00 && e01 && e02 && e03 && e04) continue; + if (l06 && e00 && e01 && e02 && e03 && e04 && e05) continue; + if (l07 && e00 && e01 && e02 && e03 && e04 && e05 && e06) continue; + if (l08 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07) continue; + if (l09 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08) continue; + if (l10 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09) continue; + if (l11 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10) continue; + if (l12 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11) continue; + if (l13 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11 && e12) continue; + if (l14 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11 && e12 && e13) continue; + if (l15 && e00 && e01 && e02 && e03 && e04 && e05 && e06 && e07 && e08 && e09 && e10 && e11 && e12 && e13 && e14) continue; + + // substract (a -= r): + + if ((r[ 0] | r[ 1] | r[ 2] | r[ 3] | r[ 4] | r[ 5] | r[ 6] | r[ 7] | + r[ 8] | r[ 9] | r[10] | r[11] | r[12] | r[13] | r[14] | r[15]) == 0) break; + + r[ 0] = a[ 0] - r[ 0]; + r[ 1] = a[ 1] - r[ 1]; + r[ 2] = a[ 2] - r[ 2]; + r[ 3] = a[ 3] - r[ 3]; + r[ 4] = a[ 4] - r[ 4]; + r[ 5] = a[ 5] - r[ 5]; + r[ 6] = a[ 6] - r[ 6]; + r[ 7] = a[ 7] - r[ 7]; + r[ 8] = a[ 8] - r[ 8]; + r[ 9] = a[ 9] - r[ 9]; + r[10] = a[10] - r[10]; + r[11] = a[11] - r[11]; + r[12] = a[12] - r[12]; + r[13] = a[13] - r[13]; + r[14] = a[14] - r[14]; + r[15] = a[15] - r[15]; + + // take care of the "borrow" (we can't do it the other way around 15...1 because r[x] is changed!) + + if (r[ 1] > a[ 1]) r[ 0]--; + if (r[ 2] > a[ 2]) r[ 1]--; + if (r[ 3] > a[ 3]) r[ 2]--; + if (r[ 4] > a[ 4]) r[ 3]--; + if (r[ 5] > a[ 5]) r[ 4]--; + if (r[ 6] > a[ 6]) r[ 5]--; + if (r[ 7] > a[ 7]) r[ 6]--; + if (r[ 8] > a[ 8]) r[ 7]--; + if (r[ 9] > a[ 9]) r[ 8]--; + if (r[10] > a[10]) r[ 9]--; + if (r[11] > a[11]) r[10]--; + if (r[12] > a[12]) r[11]--; + if (r[13] > a[13]) r[12]--; + if (r[14] > a[14]) r[13]--; + if (r[15] > a[15]) r[14]--; + + a[ 0] = r[ 0]; + a[ 1] = r[ 1]; + a[ 2] = r[ 2]; + a[ 3] = r[ 3]; + a[ 4] = r[ 4]; + a[ 5] = r[ 5]; + a[ 6] = r[ 6]; + a[ 7] = r[ 7]; + a[ 8] = r[ 8]; + a[ 9] = r[ 9]; + a[10] = r[10]; + a[11] = r[11]; + a[12] = r[12]; + a[13] = r[13]; + a[14] = r[14]; + a[15] = r[15]; + } + + n[ 0] = a[ 0]; + n[ 1] = a[ 1]; + n[ 2] = a[ 2]; + n[ 3] = a[ 3]; + n[ 4] = a[ 4]; + n[ 5] = a[ 5]; + n[ 6] = a[ 6]; + n[ 7] = a[ 7]; + n[ 8] = a[ 8]; + n[ 9] = a[ 9]; + n[10] = a[10]; + n[11] = a[11]; + n[12] = a[12]; + n[13] = a[13]; + n[14] = a[14]; + n[15] = a[15]; +} + +DECLSPEC void mul_mod (u32 *r, const u32 *a, const u32 *b) // TODO get rid of u64 ? +{ + u32 t[16] = { 0 }; // we need up to double the space (2 * 8) + + /* + * First start with the basic a * b multiplication: + */ + + u32 t0 = 0; + u32 t1 = 0; + u32 c = 0; + + for (u32 i = 0; i < 8; i++) + { + for (u32 j = 0; j <= i; j++) + { + u64 p = ((u64) a[j]) * b[i - j]; + + u64 d = ((u64) t1) << 32 | t0; + + d += p; + + t0 = (u32) d; + t1 = d >> 32; + + c += d < p; // carry + } + + t[i] = t0; + + t0 = t1; + t1 = c; + + c = 0; + } + + for (u32 i = 8; i < 15; i++) + { + for (u32 j = i - 7; j < 8; j++) + { + u64 p = ((u64) a[j]) * b[i - j]; + + u64 d = ((u64) t1) << 32 | t0; + + d += p; + + t0 = (u32) d; + t1 = d >> 32; + + c += d < p; + } + + t[i] = t0; + + t0 = t1; + t1 = c; + + c = 0; + } + + t[15] = t0; + + + + /* + * Now do the modulo operation: + * (r = t % p) + * + * http://www.isys.uni-klu.ac.at/PDF/2001-0126-MT.pdf (p.354 or p.9 in that document) + */ + + u32 tmp[16] = { 0 }; + + // c = 0; + + // Note: SECP256K1_P = 2^256 - 2^32 - 977 (0x03d1 = 977) + // multiply t[8]...t[15] by omega: + + for (u32 i = 0, j = 8; i < 8; i++, j++) + { + u64 p = ((u64) 0x03d1) * t[j] + c; + + tmp[i] = (u32) p; + + c = p >> 32; + } + + tmp[8] = c; + + c = add (tmp + 1, tmp + 1, t + 8); // modifies tmp[1]...tmp[8] + + tmp[9] = c; + + + // r = t + tmp + + c = add (r, t, tmp); + + // multiply t[0]...t[7] by omega: + + u32 c2 = 0; + + // memset (t, 0, sizeof (t)); + + for (u32 i = 0, j = 8; i < 8; i++, j++) + { + u64 p = ((u64) 0x3d1) * tmp[j] + c2; + + t[i] = (u32) p; + + c2 = p >> 32; + } + + t[8] = c2; + + c2 = add (t + 1, t + 1, tmp + 8); // modifies t[1]...t[8] + + t[9] = c2; + + + // r = r + t + + c2 = add (r, r, t); + + c += c2; + + t[0] = SECP256K1_P0; + t[1] = SECP256K1_P1; + t[2] = SECP256K1_P2; + t[3] = SECP256K1_P3; + t[4] = SECP256K1_P4; + t[5] = SECP256K1_P5; + t[6] = SECP256K1_P6; + t[7] = SECP256K1_P7; + + for (u32 i = c; i > 0; i--) + { + sub (r, r, t); + } + + for (int i = 7; i >= 0; i--) + { + if (r[i] < t[i]) break; + + if (r[i] > t[i]) + { + sub (r, r, t); + + break; + } + } +} + +DECLSPEC void sqrt_mod (u32 *r) +{ + // Fermat's Little Theorem + // secp256k1: y^2 = x^3 + 7 % p + // y ^ (p - 1) = 1 + // y ^ (p - 1) = (y^2) ^ ((p - 1) / 2) = 1 => y^2 = (y^2) ^ (((p - 1) / 2) + 1) + // => y = (y^2) ^ ((((p - 1) / 2) + 1) / 2) + // y = (y^2) ^ (((p - 1 + 2) / 2) / 2) = (y^2) ^ ((p + 1) / 4) + + // y1 = (x^3 + 7) ^ ((p + 1) / 4) + // y2 = p - y1 (or y2 = y1 * -1 % p) + + u32 s[8]; + + s[0] = SECP256K1_P0 + 1; // because of (p + 1) / 4 or use add (s, s, 1) + s[1] = SECP256K1_P1; + s[2] = SECP256K1_P2; + s[3] = SECP256K1_P3; + s[4] = SECP256K1_P4; + s[5] = SECP256K1_P5; + s[6] = SECP256K1_P6; + s[7] = SECP256K1_P7; + + u32 t[8] = { 0 }; + + t[0] = 1; + + for (u32 i = 255; i > 1; i--) // we just skip the last 2 multiplications (=> exp / 4) + { + mul_mod (t, t, t); // r * r + + u32 idx = i >> 5; + u32 mask = 1 << (i & 0x1f); + + if (s[idx] & mask) + { + mul_mod (t, t, r); // t * r + } + } + + r[0] = t[0]; + r[1] = t[1]; + r[2] = t[2]; + r[3] = t[3]; + r[4] = t[4]; + r[5] = t[5]; + r[6] = t[6]; + r[7] = t[7]; +} + +// (inverse (a, p) * a) % p == 1 (or think of a * a^-1 = a / a = 1) + +DECLSPEC void inv_mod (u32 *a) +{ + // How often does this really happen? it should "almost" never happen (but would be safer) + // if ((a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]) == 0) return; + + u32 t0[8]; + + t0[0] = a[0]; + t0[1] = a[1]; + t0[2] = a[2]; + t0[3] = a[3]; + t0[4] = a[4]; + t0[5] = a[5]; + t0[6] = a[6]; + t0[7] = a[7]; + + u32 p[8]; + + p[0] = SECP256K1_P0; + p[1] = SECP256K1_P1; + p[2] = SECP256K1_P2; + p[3] = SECP256K1_P3; + p[4] = SECP256K1_P4; + p[5] = SECP256K1_P5; + p[6] = SECP256K1_P6; + p[7] = SECP256K1_P7; + + u32 t1[8]; + + t1[0] = SECP256K1_P0; + t1[1] = SECP256K1_P1; + t1[2] = SECP256K1_P2; + t1[3] = SECP256K1_P3; + t1[4] = SECP256K1_P4; + t1[5] = SECP256K1_P5; + t1[6] = SECP256K1_P6; + t1[7] = SECP256K1_P7; + + u32 t2[8] = { 0 }; + + t2[0] = 0x00000001; + + u32 t3[8] = { 0 }; + + u32 b = (t0[0] != t1[0]) + | (t0[1] != t1[1]) + | (t0[2] != t1[2]) + | (t0[3] != t1[3]) + | (t0[4] != t1[4]) + | (t0[5] != t1[5]) + | (t0[6] != t1[6]) + | (t0[7] != t1[7]); + + while (b) + { + if ((t0[0] & 1) == 0) // even + { + t0[0] = t0[0] >> 1 | t0[1] << 31; + t0[1] = t0[1] >> 1 | t0[2] << 31; + t0[2] = t0[2] >> 1 | t0[3] << 31; + t0[3] = t0[3] >> 1 | t0[4] << 31; + t0[4] = t0[4] >> 1 | t0[5] << 31; + t0[5] = t0[5] >> 1 | t0[6] << 31; + t0[6] = t0[6] >> 1 | t0[7] << 31; + t0[7] = t0[7] >> 1; + + u32 c = 0; + + if (t2[0] & 1) c = add (t2, t2, p); + + t2[0] = t2[0] >> 1 | t2[1] << 31; + t2[1] = t2[1] >> 1 | t2[2] << 31; + t2[2] = t2[2] >> 1 | t2[3] << 31; + t2[3] = t2[3] >> 1 | t2[4] << 31; + t2[4] = t2[4] >> 1 | t2[5] << 31; + t2[5] = t2[5] >> 1 | t2[6] << 31; + t2[6] = t2[6] >> 1 | t2[7] << 31; + t2[7] = t2[7] >> 1 | c << 31; + } + else if ((t1[0] & 1) == 0) + { + t1[0] = t1[0] >> 1 | t1[1] << 31; + t1[1] = t1[1] >> 1 | t1[2] << 31; + t1[2] = t1[2] >> 1 | t1[3] << 31; + t1[3] = t1[3] >> 1 | t1[4] << 31; + t1[4] = t1[4] >> 1 | t1[5] << 31; + t1[5] = t1[5] >> 1 | t1[6] << 31; + t1[6] = t1[6] >> 1 | t1[7] << 31; + t1[7] = t1[7] >> 1; + + u32 c = 0; + + if (t3[0] & 1) c = add (t3, t3, p); + + t3[0] = t3[0] >> 1 | t3[1] << 31; + t3[1] = t3[1] >> 1 | t3[2] << 31; + t3[2] = t3[2] >> 1 | t3[3] << 31; + t3[3] = t3[3] >> 1 | t3[4] << 31; + t3[4] = t3[4] >> 1 | t3[5] << 31; + t3[5] = t3[5] >> 1 | t3[6] << 31; + t3[6] = t3[6] >> 1 | t3[7] << 31; + t3[7] = t3[7] >> 1 | c << 31; + } + else + { + u32 gt = 0; + + for (int i = 7; i >= 0; i--) + { + if (t0[i] > t1[i]) + { + gt = 1; + + break; + } + + if (t0[i] < t1[i]) break; + } + + if (gt) + { + sub (t0, t0, t1); + + t0[0] = t0[0] >> 1 | t0[1] << 31; + t0[1] = t0[1] >> 1 | t0[2] << 31; + t0[2] = t0[2] >> 1 | t0[3] << 31; + t0[3] = t0[3] >> 1 | t0[4] << 31; + t0[4] = t0[4] >> 1 | t0[5] << 31; + t0[5] = t0[5] >> 1 | t0[6] << 31; + t0[6] = t0[6] >> 1 | t0[7] << 31; + t0[7] = t0[7] >> 1; + + u32 lt = 0; + + for (int i = 7; i >= 0; i--) + { + if (t2[i] < t3[i]) + { + lt = 1; + + break; + } + + if (t2[i] > t3[i]) break; + } + + if (lt) add (t2, t2, p); + + sub (t2, t2, t3); + + u32 c = 0; + + if (t2[0] & 1) c = add (t2, t2, p); + + t2[0] = t2[0] >> 1 | t2[1] << 31; + t2[1] = t2[1] >> 1 | t2[2] << 31; + t2[2] = t2[2] >> 1 | t2[3] << 31; + t2[3] = t2[3] >> 1 | t2[4] << 31; + t2[4] = t2[4] >> 1 | t2[5] << 31; + t2[5] = t2[5] >> 1 | t2[6] << 31; + t2[6] = t2[6] >> 1 | t2[7] << 31; + t2[7] = t2[7] >> 1 | c << 31; + } + else + { + sub (t1, t1, t0); + + t1[0] = t1[0] >> 1 | t1[1] << 31; + t1[1] = t1[1] >> 1 | t1[2] << 31; + t1[2] = t1[2] >> 1 | t1[3] << 31; + t1[3] = t1[3] >> 1 | t1[4] << 31; + t1[4] = t1[4] >> 1 | t1[5] << 31; + t1[5] = t1[5] >> 1 | t1[6] << 31; + t1[6] = t1[6] >> 1 | t1[7] << 31; + t1[7] = t1[7] >> 1; + + u32 lt = 0; + + for (int i = 7; i >= 0; i--) + { + if (t3[i] < t2[i]) + { + lt = 1; + + break; + } + + if (t3[i] > t2[i]) break; + } + + if (lt) add (t3, t3, p); + + sub (t3, t3, t2); + + u32 c = 0; + + if (t3[0] & 1) c = add (t3, t3, p); + + t3[0] = t3[0] >> 1 | t3[1] << 31; + t3[1] = t3[1] >> 1 | t3[2] << 31; + t3[2] = t3[2] >> 1 | t3[3] << 31; + t3[3] = t3[3] >> 1 | t3[4] << 31; + t3[4] = t3[4] >> 1 | t3[5] << 31; + t3[5] = t3[5] >> 1 | t3[6] << 31; + t3[6] = t3[6] >> 1 | t3[7] << 31; + t3[7] = t3[7] >> 1 | c << 31; + } + } + + // update b: + + b = (t0[0] != t1[0]) + | (t0[1] != t1[1]) + | (t0[2] != t1[2]) + | (t0[3] != t1[3]) + | (t0[4] != t1[4]) + | (t0[5] != t1[5]) + | (t0[6] != t1[6]) + | (t0[7] != t1[7]); + } + + // set result: + + a[0] = t2[0]; + a[1] = t2[1]; + a[2] = t2[2]; + a[3] = t2[3]; + a[4] = t2[4]; + a[5] = t2[5]; + a[6] = t2[6]; + a[7] = t2[7]; +} + +/* + // everything from the formulas below of course MOD the prime: + + // we use this formula: + + X = (3/2 * x^2)^2 - 2 * x * y^2 + Y = (3/2 * x^2) * (x * y^2 - X) - y^4 + Z = y * z + + this is identical to the more frequently used form: + + X = (3 * x^2)^2 - 8 * x * y^2 + Y = 3 * x^2 * (4 * x * y^2 - X) - 8 * y^4 + Z = 2 * y * z +*/ + +DECLSPEC void point_double (u32 *x, u32 *y, u32 *z) +{ + // How often does this really happen? it should "almost" never happen (but would be safer) + + /* + if ((y[0] | y[1] | y[2] | y[3] | y[4] | y[5] | y[6] | y[7]) == 0) + { + x[0] = 0; + x[1] = 0; + x[2] = 0; + x[3] = 0; + x[4] = 0; + x[5] = 0; + x[6] = 0; + x[7] = 0; + + y[0] = 0; + y[1] = 0; + y[2] = 0; + y[3] = 0; + y[4] = 0; + y[5] = 0; + y[6] = 0; + y[7] = 0; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + z[4] = 0; + z[5] = 0; + z[6] = 0; + z[7] = 0; + + return; + } + */ + + u32 t1[8]; + + t1[0] = x[0]; + t1[1] = x[1]; + t1[2] = x[2]; + t1[3] = x[3]; + t1[4] = x[4]; + t1[5] = x[5]; + t1[6] = x[6]; + t1[7] = x[7]; + + u32 t2[8]; + + t2[0] = y[0]; + t2[1] = y[1]; + t2[2] = y[2]; + t2[3] = y[3]; + t2[4] = y[4]; + t2[5] = y[5]; + t2[6] = y[6]; + t2[7] = y[7]; + + u32 t3[8]; + + t3[0] = z[0]; + t3[1] = z[1]; + t3[2] = z[2]; + t3[3] = z[3]; + t3[4] = z[4]; + t3[5] = z[5]; + t3[6] = z[6]; + t3[7] = z[7]; + + u32 t4[8]; + u32 t5[8]; + u32 t6[8]; + + mul_mod (t4, t1, t1); // t4 = x^2 + + mul_mod (t5, t2, t2); // t5 = y^2 + + mul_mod (t1, t1, t5); // t1 = x*y^2 + + mul_mod (t5, t5, t5); // t5 = t5^2 = y^4 + + // here the z^2 and z^4 is not needed for a = 0 + + mul_mod (t3, t2, t3); // t3 = x * z + + add_mod (t2, t4, t4); // t2 = 2 * t4 = 2 * x^2 + add_mod (t4, t4, t2); // t4 = 3 * t4 = 3 * x^2 + + // a * z^4 = 0 * 1^4 = 0 + + // don't discard the least significant bit it's important too! + + u32 c = 0; + + if (t4[0] & 1) + { + u32 t[8]; + + t[0] = SECP256K1_P0; + t[1] = SECP256K1_P1; + t[2] = SECP256K1_P2; + t[3] = SECP256K1_P3; + t[4] = SECP256K1_P4; + t[5] = SECP256K1_P5; + t[6] = SECP256K1_P6; + t[7] = SECP256K1_P7; + + c = add (t4, t4, t); // t4 + SECP256K1_P + } + + // right shift (t4 / 2): + + t4[0] = t4[0] >> 1 | t4[1] << 31; + t4[1] = t4[1] >> 1 | t4[2] << 31; + t4[2] = t4[2] >> 1 | t4[3] << 31; + t4[3] = t4[3] >> 1 | t4[4] << 31; + t4[4] = t4[4] >> 1 | t4[5] << 31; + t4[5] = t4[5] >> 1 | t4[6] << 31; + t4[6] = t4[6] >> 1 | t4[7] << 31; + t4[7] = t4[7] >> 1 | c << 31; + + mul_mod (t6, t4, t4); // t6 = t4^2 = (3/2 * x^2)^2 + + add_mod (t2, t1, t1); // t2 = 2 * t1 + + sub_mod (t6, t6, t2); // t6 = t6 - t2 + sub_mod (t1, t1, t6); // t1 = t1 - t6 + + mul_mod (t4, t4, t1); // t4 = t4 * t1 + + sub_mod (t1, t4, t5); // t1 = t4 - t5 + + // => x = t6, y = t1, z = t3: + + x[0] = t6[0]; + x[1] = t6[1]; + x[2] = t6[2]; + x[3] = t6[3]; + x[4] = t6[4]; + x[5] = t6[5]; + x[6] = t6[6]; + x[7] = t6[7]; + + y[0] = t1[0]; + y[1] = t1[1]; + y[2] = t1[2]; + y[3] = t1[3]; + y[4] = t1[4]; + y[5] = t1[5]; + y[6] = t1[6]; + y[7] = t1[7]; + + z[0] = t3[0]; + z[1] = t3[1]; + z[2] = t3[2]; + z[3] = t3[3]; + z[4] = t3[4]; + z[5] = t3[5]; + z[6] = t3[6]; + z[7] = t3[7]; +} + +/* + * madd-2004-hmv: + * (from https://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html) + * t1 = z1^2 + * t2 = t1*z1 + * t1 = t1*x2 + * t2 = t2*y2 + * t1 = t1-x1 + * t2 = t2-y1 + * z3 = z1*t1 + * t3 = t1^2 + * t4 = t3*t1 + * t3 = t3*x1 + * t1 = 2*t3 + * x3 = t2^2 + * x3 = x3-t1 + * x3 = x3-t4 + * t3 = t3-x3 + * t3 = t3*t2 + * t4 = t4*y1 + * y3 = t3-t4 + */ + +DECLSPEC void point_add (u32 *x1, u32 *y1, u32 *z1, u32 *x2, u32 *y2) // z2 = 1 +{ + // How often does this really happen? it should "almost" never happen (but would be safer) + + /* + if ((y2[0] | y2[1] | y2[2] | y2[3] | y2[4] | y2[5] | y2[6] | y2[7]) == 0) return; + + if ((y1[0] | y1[1] | y1[2] | y1[3] | y1[4] | y1[5] | y1[6] | y1[7]) == 0) + { + x1[0] = x2[0]; + x1[1] = x2[1]; + x1[2] = x2[2]; + x1[3] = x2[3]; + x1[4] = x2[4]; + x1[5] = x2[5]; + x1[6] = x2[6]; + x1[7] = x2[7]; + + y1[0] = y2[0]; + y1[1] = y2[1]; + y1[2] = y2[2]; + y1[3] = y2[3]; + y1[4] = y2[4]; + y1[5] = y2[5]; + y1[6] = y2[6]; + y1[7] = y2[7]; + + z1[0] = z2[0]; + z1[1] = z2[1]; + z1[2] = z2[2]; + z1[3] = z2[3]; + z1[4] = z2[4]; + z1[5] = z2[5]; + z1[6] = z2[6]; + z1[7] = z2[7]; + + return; + } + */ + + // if x1 == x2 and y2 == y2 and z2 == z2 we need to double instead? + + // x1/y1/z1: + + u32 t1[8]; + + t1[0] = x1[0]; + t1[1] = x1[1]; + t1[2] = x1[2]; + t1[3] = x1[3]; + t1[4] = x1[4]; + t1[5] = x1[5]; + t1[6] = x1[6]; + t1[7] = x1[7]; + + u32 t2[8]; + + t2[0] = y1[0]; + t2[1] = y1[1]; + t2[2] = y1[2]; + t2[3] = y1[3]; + t2[4] = y1[4]; + t2[5] = y1[5]; + t2[6] = y1[6]; + t2[7] = y1[7]; + + u32 t3[8]; + + t3[0] = z1[0]; + t3[1] = z1[1]; + t3[2] = z1[2]; + t3[3] = z1[3]; + t3[4] = z1[4]; + t3[5] = z1[5]; + t3[6] = z1[6]; + t3[7] = z1[7]; + + // x2/y2: + + u32 t4[8]; + + t4[0] = x2[0]; + t4[1] = x2[1]; + t4[2] = x2[2]; + t4[3] = x2[3]; + t4[4] = x2[4]; + t4[5] = x2[5]; + t4[6] = x2[6]; + t4[7] = x2[7]; + + u32 t5[8]; + + t5[0] = y2[0]; + t5[1] = y2[1]; + t5[2] = y2[2]; + t5[3] = y2[3]; + t5[4] = y2[4]; + t5[5] = y2[5]; + t5[6] = y2[6]; + t5[7] = y2[7]; + + u32 t6[8]; + u32 t7[8]; + u32 t8[8]; + u32 t9[8]; + + mul_mod (t6, t3, t3); // t6 = t3^2 + + mul_mod (t7, t6, t3); // t7 = t6*t3 + mul_mod (t6, t6, t4); // t6 = t6*t4 + mul_mod (t7, t7, t5); // t7 = t7*t5 + + sub_mod (t6, t6, t1); // t6 = t6-t1 + sub_mod (t7, t7, t2); // t7 = t7-t2 + + mul_mod (t8, t3, t6); // t8 = t3*t6 + mul_mod (t4, t6, t6); // t4 = t6^2 + mul_mod (t9, t4, t6); // t9 = t4*t6 + mul_mod (t4, t4, t1); // t4 = t4*t1 + + // left shift (t4 * 2): + + t6[7] = t4[7] << 1 | t4[6] >> 31; + t6[6] = t4[6] << 1 | t4[5] >> 31; + t6[5] = t4[5] << 1 | t4[4] >> 31; + t6[4] = t4[4] << 1 | t4[3] >> 31; + t6[3] = t4[3] << 1 | t4[2] >> 31; + t6[2] = t4[2] << 1 | t4[1] >> 31; + t6[1] = t4[1] << 1 | t4[0] >> 31; + t6[0] = t4[0] << 1; + + // don't discard the most significant bit, it's important too! + + if (t4[7] & 0x80000000) + { + // use most significant bit and perform mod P, since we have: t4 * 2 % P + + u32 a[8] = { 0 }; + + a[1] = 1; + a[0] = 0x000003d1; // omega (see: mul_mod ()) + + add (t6, t6, a); + } + + mul_mod (t5, t7, t7); // t5 = t7*t7 + + sub_mod (t5, t5, t6); // t5 = t5-t6 + sub_mod (t5, t5, t9); // t5 = t5-t9 + sub_mod (t4, t4, t5); // t4 = t4-t5 + + mul_mod (t4, t4, t7); // t4 = t4*t7 + mul_mod (t9, t9, t2); // t9 = t9*t2 + + sub_mod (t9, t4, t9); // t9 = t4-t9 + + x1[0] = t5[0]; + x1[1] = t5[1]; + x1[2] = t5[2]; + x1[3] = t5[3]; + x1[4] = t5[4]; + x1[5] = t5[5]; + x1[6] = t5[6]; + x1[7] = t5[7]; + + y1[0] = t9[0]; + y1[1] = t9[1]; + y1[2] = t9[2]; + y1[3] = t9[3]; + y1[4] = t9[4]; + y1[5] = t9[5]; + y1[6] = t9[6]; + y1[7] = t9[7]; + + z1[0] = t8[0]; + z1[1] = t8[1]; + z1[2] = t8[2]; + z1[3] = t8[3]; + z1[4] = t8[4]; + z1[5] = t8[5]; + z1[6] = t8[6]; + z1[7] = t8[7]; +} + +DECLSPEC void point_get_coords (secp256k1_t *r, const u32 *x, const u32 *y) +{ + /* + pre-compute 1/-1, 3/-3, 5/-5, 7/-7 times P (x, y) + for wNAF with window size 4 (max/min: +/- 2^3-1): -7, -5, -3, -1, 1, 3, 5, 7 + + +x1 ( 0) + +y1 ( 8) + -y1 (16) + + +x3 (24) + +y3 (32) + -y3 (40) + + +x5 (48) + +y5 (56) + -y5 (64) + + +x7 (72) + +y7 (80) + -y7 (88) + */ + + // note: we use jacobian forms with (x, y, z) for computation, but affine + // (or just converted to z = 1) for storage + + // 1: + + r->xy[ 0] = x[0]; + r->xy[ 1] = x[1]; + r->xy[ 2] = x[2]; + r->xy[ 3] = x[3]; + r->xy[ 4] = x[4]; + r->xy[ 5] = x[5]; + r->xy[ 6] = x[6]; + r->xy[ 7] = x[7]; + + r->xy[ 8] = y[0]; + r->xy[ 9] = y[1]; + r->xy[10] = y[2]; + r->xy[11] = y[3]; + r->xy[12] = y[4]; + r->xy[13] = y[5]; + r->xy[14] = y[6]; + r->xy[15] = y[7]; + + // -1: + + u32 p[8]; + + p[0] = SECP256K1_P0; + p[1] = SECP256K1_P1; + p[2] = SECP256K1_P2; + p[3] = SECP256K1_P3; + p[4] = SECP256K1_P4; + p[5] = SECP256K1_P5; + p[6] = SECP256K1_P6; + p[7] = SECP256K1_P7; + + u32 neg[8]; + + neg[0] = y[0]; + neg[1] = y[1]; + neg[2] = y[2]; + neg[3] = y[3]; + neg[4] = y[4]; + neg[5] = y[5]; + neg[6] = y[6]; + neg[7] = y[7]; + + sub_mod (neg, p, neg); // -y = p - y + + r->xy[16] = neg[0]; + r->xy[17] = neg[1]; + r->xy[18] = neg[2]; + r->xy[19] = neg[3]; + r->xy[20] = neg[4]; + r->xy[21] = neg[5]; + r->xy[22] = neg[6]; + r->xy[23] = neg[7]; + + + // copy of 1: + + u32 tx[8]; + + tx[0] = x[0]; + tx[1] = x[1]; + tx[2] = x[2]; + tx[3] = x[3]; + tx[4] = x[4]; + tx[5] = x[5]; + tx[6] = x[6]; + tx[7] = x[7]; + + u32 ty[8]; + + ty[0] = y[0]; + ty[1] = y[1]; + ty[2] = y[2]; + ty[3] = y[3]; + ty[4] = y[4]; + ty[5] = y[5]; + ty[6] = y[6]; + ty[7] = y[7]; + + u32 rx[8]; + + rx[0] = x[0]; + rx[1] = x[1]; + rx[2] = x[2]; + rx[3] = x[3]; + rx[4] = x[4]; + rx[5] = x[5]; + rx[6] = x[6]; + rx[7] = x[7]; + + u32 ry[8]; + + ry[0] = y[0]; + ry[1] = y[1]; + ry[2] = y[2]; + ry[3] = y[3]; + ry[4] = y[4]; + ry[5] = y[5]; + ry[6] = y[6]; + ry[7] = y[7]; + + u32 rz[8] = { 0 }; + + rz[0] = 1; + + + // 3: + + point_double (rx, ry, rz); // 2 + point_add (rx, ry, rz, tx, ty); // 3 + + // to affine: + + inv_mod (rz); + + mul_mod (neg, rz, rz); // neg is temporary variable (z^2) + mul_mod (rx, rx, neg); + + mul_mod (rz, neg, rz); + mul_mod (ry, ry, rz); + + r->xy[24] = rx[0]; + r->xy[25] = rx[1]; + r->xy[26] = rx[2]; + r->xy[27] = rx[3]; + r->xy[28] = rx[4]; + r->xy[29] = rx[5]; + r->xy[30] = rx[6]; + r->xy[31] = rx[7]; + + r->xy[32] = ry[0]; + r->xy[33] = ry[1]; + r->xy[34] = ry[2]; + r->xy[35] = ry[3]; + r->xy[36] = ry[4]; + r->xy[37] = ry[5]; + r->xy[38] = ry[6]; + r->xy[39] = ry[7]; + + // -3: + + neg[0] = ry[0]; + neg[1] = ry[1]; + neg[2] = ry[2]; + neg[3] = ry[3]; + neg[4] = ry[4]; + neg[5] = ry[5]; + neg[6] = ry[6]; + neg[7] = ry[7]; + + sub_mod (neg, p, neg); + + r->xy[40] = neg[0]; + r->xy[41] = neg[1]; + r->xy[42] = neg[2]; + r->xy[43] = neg[3]; + r->xy[44] = neg[4]; + r->xy[45] = neg[5]; + r->xy[46] = neg[6]; + r->xy[47] = neg[7]; + + + // 5: + + rz[0] = 1; // actually we could take advantage of rz being 1 too (alternative point_add ()), + rz[1] = 0; // but it is not important because this is performed only once per "hash" + rz[2] = 0; + rz[3] = 0; + rz[4] = 0; + rz[5] = 0; + rz[6] = 0; + rz[7] = 0; + + point_add (rx, ry, rz, tx, ty); // 4 + point_add (rx, ry, rz, tx, ty); // 5 + + // to affine: + + inv_mod (rz); + + mul_mod (neg, rz, rz); + mul_mod (rx, rx, neg); + + mul_mod (rz, neg, rz); + mul_mod (ry, ry, rz); + + r->xy[48] = rx[0]; + r->xy[49] = rx[1]; + r->xy[50] = rx[2]; + r->xy[51] = rx[3]; + r->xy[52] = rx[4]; + r->xy[53] = rx[5]; + r->xy[54] = rx[6]; + r->xy[55] = rx[7]; + + r->xy[56] = ry[0]; + r->xy[57] = ry[1]; + r->xy[58] = ry[2]; + r->xy[59] = ry[3]; + r->xy[60] = ry[4]; + r->xy[61] = ry[5]; + r->xy[62] = ry[6]; + r->xy[63] = ry[7]; + + // -5: + + neg[0] = ry[0]; + neg[1] = ry[1]; + neg[2] = ry[2]; + neg[3] = ry[3]; + neg[4] = ry[4]; + neg[5] = ry[5]; + neg[6] = ry[6]; + neg[7] = ry[7]; + + sub_mod (neg, p, neg); + + r->xy[64] = neg[0]; + r->xy[65] = neg[1]; + r->xy[66] = neg[2]; + r->xy[67] = neg[3]; + r->xy[68] = neg[4]; + r->xy[69] = neg[5]; + r->xy[70] = neg[6]; + r->xy[71] = neg[7]; + + + // 7: + + rz[0] = 1; + rz[1] = 0; + rz[2] = 0; + rz[3] = 0; + rz[4] = 0; + rz[5] = 0; + rz[6] = 0; + rz[7] = 0; + + point_add (rx, ry, rz, tx, ty); // 6 + point_add (rx, ry, rz, tx, ty); // 7 + + // to affine: + + inv_mod (rz); + + mul_mod (neg, rz, rz); + mul_mod (rx, rx, neg); + + mul_mod (rz, neg, rz); + mul_mod (ry, ry, rz); + + r->xy[72] = rx[0]; + r->xy[73] = rx[1]; + r->xy[74] = rx[2]; + r->xy[75] = rx[3]; + r->xy[76] = rx[4]; + r->xy[77] = rx[5]; + r->xy[78] = rx[6]; + r->xy[79] = rx[7]; + + r->xy[80] = ry[0]; + r->xy[81] = ry[1]; + r->xy[82] = ry[2]; + r->xy[83] = ry[3]; + r->xy[84] = ry[4]; + r->xy[85] = ry[5]; + r->xy[86] = ry[6]; + r->xy[87] = ry[7]; + + // -7: + + neg[0] = ry[0]; + neg[1] = ry[1]; + neg[2] = ry[2]; + neg[3] = ry[3]; + neg[4] = ry[4]; + neg[5] = ry[5]; + neg[6] = ry[6]; + neg[7] = ry[7]; + + sub_mod (neg, p, neg); + + r->xy[88] = neg[0]; + r->xy[89] = neg[1]; + r->xy[90] = neg[2]; + r->xy[91] = neg[3]; + r->xy[92] = neg[4]; + r->xy[93] = neg[5]; + r->xy[94] = neg[6]; + r->xy[95] = neg[7]; +} + +DECLSPEC void point_mul (u32 *r, const u32 *k, GLOBAL_AS const secp256k1_t *tmps) +{ + /* + * Convert the tweak/scalar k to w-NAF (window size is 4) + */ + + u32 n[9]; + + n[0] = 0; // we need this extra slot sometimes for the subtraction to work + n[1] = k[7]; + n[2] = k[6]; + n[3] = k[5]; + n[4] = k[4]; + n[5] = k[3]; + n[6] = k[2]; + n[7] = k[1]; + n[8] = k[0]; + + u32 naf[32 + 1] = { 0 }; // we need one extra slot + + int loop_start = 0; + + for (int i = 0; i <= 256; i++) + { + if (n[8] & 1) + { + // for window size w = 4: + // => 2^(w-0) = 2^4 = 16 (0x10) + // => 2^(w-1) = 2^3 = 8 (0x08) + + int diff = n[8] & 0x0f; // n % 2^w == n & (2^w - 1) + + // convert diff to val according to this table: + // 1 -> +1 -> 1 + // 3 -> +3 -> 3 + // 5 -> +5 -> 5 + // 7 -> +7 -> 7 + // 9 -> -7 -> 8 + // 11 -> -5 -> 6 + // 13 -> -3 -> 4 + // 15 -> -1 -> 2 + + int val = diff; + + if (diff >= 0x08) + { + diff -= 0x10; + + val = 0x11 - val; + } + + naf[i >> 3] |= val << ((i & 7) << 2); + + u32 t = n[8]; // t is the (temporary) old/unmodified value + + n[8] -= diff; + + // we need to take care of the carry/borrow: + + u32 k = 8; + + if (diff > 0) + { + while (n[k] > t) // overflow propagation + { + if (k == 0) break; // needed ? + + k--; + + t = n[k]; + + n[k]--; + } + } + else // if (diff < 0) + { + while (t > n[k]) // overflow propagation + { + if (k == 0) break; + + k--; + + t = n[k]; + + n[k]++; + } + } + + // update start: + + loop_start = i; + } + + // n = n / 2: + + n[8] = n[8] >> 1 | n[7] << 31; + n[7] = n[7] >> 1 | n[6] << 31; + n[6] = n[6] >> 1 | n[5] << 31; + n[5] = n[5] >> 1 | n[4] << 31; + n[4] = n[4] >> 1 | n[3] << 31; + n[3] = n[3] >> 1 | n[2] << 31; + n[2] = n[2] >> 1 | n[1] << 31; + n[1] = n[1] >> 1 | n[0] << 31; + n[0] = n[0] >> 1; + } + + + // first set: + + const u32 multiplier = (naf[loop_start >> 3] >> ((loop_start & 7) << 2)) & 0x0f; // or use u8 ? + + const u32 odd = multiplier & 1; + + const u32 x_pos = ((multiplier - 1 + odd) >> 1) * 24; + const u32 y_pos = odd ? (x_pos + 8) : (x_pos + 16); + + u32 x1[8]; + + x1[0] = tmps->xy[x_pos + 0]; + x1[1] = tmps->xy[x_pos + 1]; + x1[2] = tmps->xy[x_pos + 2]; + x1[3] = tmps->xy[x_pos + 3]; + x1[4] = tmps->xy[x_pos + 4]; + x1[5] = tmps->xy[x_pos + 5]; + x1[6] = tmps->xy[x_pos + 6]; + x1[7] = tmps->xy[x_pos + 7]; + + u32 y1[8]; + + y1[0] = tmps->xy[y_pos + 0]; + y1[1] = tmps->xy[y_pos + 1]; + y1[2] = tmps->xy[y_pos + 2]; + y1[3] = tmps->xy[y_pos + 3]; + y1[4] = tmps->xy[y_pos + 4]; + y1[5] = tmps->xy[y_pos + 5]; + y1[6] = tmps->xy[y_pos + 6]; + y1[7] = tmps->xy[y_pos + 7]; + + u32 z1[8] = { 0 }; + + z1[0] = 1; + + /* + * Start: + */ + + // main loop (left-to-right binary algorithm): + + for (int pos = loop_start - 1; pos >= 0; pos--) // -1 because we've set/add the point already + { + // always double: + + point_double (x1, y1, z1); + + // add only if needed: + + const u32 multiplier = (naf[pos >> 3] >> ((pos & 7) << 2)) & 0x0f; + + if (multiplier) + { + /* + m -> y | y = ((m - (m & 1)) / 2) * 24 + ---------------------------------- + 1 -> 0 | 1/2 * 24 = 0 + 2 -> 16 + 3 -> 24 | 3/2 * 24 = 24 + 4 -> 40 + 5 -> 48 | 5/2 * 24 = 2*24 + 6 -> 64 + 7 -> 72 | 7/2 * 24 = 3*24 + 8 -> 88 + */ + + const u32 odd = multiplier & 1; + + const u32 x_pos = ((multiplier - 1 + odd) >> 1) * 24; + const u32 y_pos = odd ? (x_pos + 8) : (x_pos + 16); + + u32 x2[8]; + + x2[0] = tmps->xy[x_pos + 0]; + x2[1] = tmps->xy[x_pos + 1]; + x2[2] = tmps->xy[x_pos + 2]; + x2[3] = tmps->xy[x_pos + 3]; + x2[4] = tmps->xy[x_pos + 4]; + x2[5] = tmps->xy[x_pos + 5]; + x2[6] = tmps->xy[x_pos + 6]; + x2[7] = tmps->xy[x_pos + 7]; + + u32 y2[8]; + + y2[0] = tmps->xy[y_pos + 0]; + y2[1] = tmps->xy[y_pos + 1]; + y2[2] = tmps->xy[y_pos + 2]; + y2[3] = tmps->xy[y_pos + 3]; + y2[4] = tmps->xy[y_pos + 4]; + y2[5] = tmps->xy[y_pos + 5]; + y2[6] = tmps->xy[y_pos + 6]; + y2[7] = tmps->xy[y_pos + 7]; + + // (x1, y1, z1) + multiplier * (x, y, z) = (x1, y1, z1) + (x2, y2, z2) + + point_add (x1, y1, z1, x2, y2); + + // optimization (there can't be any adds after an add for w-1 times): + // (but it seems to be faster without this manipulation of "pos") + + //for (u32 i = 0; i < 3; i++) + //{ + // if (pos == 0) break; + // point_double (x1, y1, z1); + // pos--; + //} + } + } + + + /* + * Get the corresponding affine coordinates x/y: + * + * Note: + * x1_affine = x1_jacobian / z1^2 = x1_jacobian * z1_inv^2 + * y1_affine = y1_jacobian / z1^2 = y1_jacobian * z1_inv^2 + * + */ + + inv_mod (z1); + + u32 z2[8]; + + mul_mod (z2, z1, z1); // z1^2 + mul_mod (x1, x1, z2); // x1_affine + + mul_mod (z1, z2, z1); // z1^3 + mul_mod (y1, y1, z1); // y1_affine + + /* + * output: + */ + + // shift by 1 byte (8 bits) to make room and add the parity/sign (for odd/even y): + + r[8] = (x1[0] << 24); + r[7] = (x1[0] >> 8) | (x1[1] << 24); + r[6] = (x1[1] >> 8) | (x1[2] << 24); + r[5] = (x1[2] >> 8) | (x1[3] << 24); + r[4] = (x1[3] >> 8) | (x1[4] << 24); + r[3] = (x1[4] >> 8) | (x1[5] << 24); + r[2] = (x1[5] >> 8) | (x1[6] << 24); + r[1] = (x1[6] >> 8) | (x1[7] << 24); + r[0] = (x1[7] >> 8); + + const u32 type = 0x02 | (y1[0] & 1); // (note: 0b10 | 0b01 = 0x03) + + r[0] = r[0] | type << 24; // 0x02 or 0x03 +} + +DECLSPEC u32 parse_public (secp256k1_t *r, const u32 *k) +{ + // verify: + + const u32 first_byte = k[0] & 0xff; + + if ((first_byte != '\x02') && (first_byte != '\x03')) + { + return 1; + } + + // load k into x without the first byte: + + u32 x[8]; + + x[0] = (k[7] & 0xff00) << 16 | (k[7] & 0xff0000) | (k[7] & 0xff000000) >> 16 | (k[8] & 0xff); + x[1] = (k[6] & 0xff00) << 16 | (k[6] & 0xff0000) | (k[6] & 0xff000000) >> 16 | (k[7] & 0xff); + x[2] = (k[5] & 0xff00) << 16 | (k[5] & 0xff0000) | (k[5] & 0xff000000) >> 16 | (k[6] & 0xff); + x[3] = (k[4] & 0xff00) << 16 | (k[4] & 0xff0000) | (k[4] & 0xff000000) >> 16 | (k[5] & 0xff); + x[4] = (k[3] & 0xff00) << 16 | (k[3] & 0xff0000) | (k[3] & 0xff000000) >> 16 | (k[4] & 0xff); + x[5] = (k[2] & 0xff00) << 16 | (k[2] & 0xff0000) | (k[2] & 0xff000000) >> 16 | (k[3] & 0xff); + x[6] = (k[1] & 0xff00) << 16 | (k[1] & 0xff0000) | (k[1] & 0xff000000) >> 16 | (k[2] & 0xff); + x[7] = (k[0] & 0xff00) << 16 | (k[0] & 0xff0000) | (k[0] & 0xff000000) >> 16 | (k[1] & 0xff); + + u32 p[8]; + + p[0] = SECP256K1_P0; + p[1] = SECP256K1_P1; + p[2] = SECP256K1_P2; + p[3] = SECP256K1_P3; + p[4] = SECP256K1_P4; + p[5] = SECP256K1_P5; + p[6] = SECP256K1_P6; + p[7] = SECP256K1_P7; + + // x must be smaller than p (because of y ^ 2 = x ^ 3 % p) + + for (int i = 7; i >= 0; i--) + { + if (x[i] < p[i]) break; + if (x[i] > p[i]) return 1; + } + + + // get y^2 = x^3 + 7: + + u32 b[8] = { 0 }; + + b[0] = SECP256K1_B; + + u32 y[8]; + + mul_mod (y, x, x); + mul_mod (y, y, x); + add_mod (y, y, b); + + // get y = sqrt (y^2): + + sqrt_mod (y); + + // check if it's of the correct parity that we want (odd/even): + + if ((first_byte & 1) != (y[0] & 1)) + { + // y2 = p - y1 (or y2 = y1 * -1) + + sub_mod (y, p, y); + } + + // get xy: + + point_get_coords (r, x, y); + + return 0; +} diff --git a/OpenCL/inc_ecc_secp256k1.h b/OpenCL/inc_ecc_secp256k1.h new file mode 100644 index 000000000..9a8e069d2 --- /dev/null +++ b/OpenCL/inc_ecc_secp256k1.h @@ -0,0 +1,41 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _INC_ECC_SECP256K1_H +#define _INC_ECC_SECP256K1_H + +// y^2 = x^3 + ax + b with a = 0 and b = 7 => y^2 = x^3 + 7: + +#define SECP256K1_B 7 + +#define SECP256K1_P0 0xfffffc2f +#define SECP256K1_P1 0xfffffffe +#define SECP256K1_P2 0xffffffff +#define SECP256K1_P3 0xffffffff +#define SECP256K1_P4 0xffffffff +#define SECP256K1_P5 0xffffffff +#define SECP256K1_P6 0xffffffff +#define SECP256K1_P7 0xffffffff + +#define SECP256K1_N0 0xd0364141 +#define SECP256K1_N1 0xbfd25e8c +#define SECP256K1_N2 0xaf48a03b +#define SECP256K1_N3 0xbaaedce6 +#define SECP256K1_N4 0xfffffffe +#define SECP256K1_N5 0xffffffff +#define SECP256K1_N6 0xffffffff +#define SECP256K1_N7 0xffffffff + +typedef struct secp256k1 +{ + u32 xy[96]; // pre-computed points: (x1,y1,-y1),(x3,y3,-y3),(x5,y5,-y5),(x7,y7,-y7) + +} secp256k1_t; + +DECLSPEC u32 parse_public (secp256k1_t *r, const u32 *k); + +DECLSPEC void point_mul (u32 *r, const u32 *k, GLOBAL_AS const secp256k1_t *tmps); + +#endif // _INC_ECC_SECP256K1_H diff --git a/OpenCL/inc_hash_md4.cl b/OpenCL/inc_hash_md4.cl index 28720b25c..eeb28cd17 100644 --- a/OpenCL/inc_hash_md4.cl +++ b/OpenCL/inc_hash_md4.cl @@ -799,9 +799,7 @@ DECLSPEC void md4_hmac_init_64 (md4_hmac_ctx_t *ctx, const u32 *w0, const u32 *w md4_init (&ctx->ipad); - md4_transform (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + md4_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -824,9 +822,7 @@ DECLSPEC void md4_hmac_init_64 (md4_hmac_ctx_t *ctx, const u32 *w0, const u32 *w md4_init (&ctx->opad); - md4_transform (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + md4_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void md4_hmac_init (md4_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -1686,9 +1682,7 @@ DECLSPEC void md4_hmac_init_vector_64 (md4_hmac_ctx_vector_t *ctx, const u32x *w md4_init_vector (&ctx->ipad); - md4_transform_vector (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + md4_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1711,9 +1705,7 @@ DECLSPEC void md4_hmac_init_vector_64 (md4_hmac_ctx_vector_t *ctx, const u32x *w md4_init_vector (&ctx->opad); - md4_transform_vector (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + md4_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void md4_hmac_init_vector (md4_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_md4.h b/OpenCL/inc_hash_md4.h index 8dcebba55..7c3b31894 100644 --- a/OpenCL/inc_hash_md4.h +++ b/OpenCL/inc_hash_md4.h @@ -10,26 +10,14 @@ #define MD4_G_S(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) #define MD4_H_S(x,y,z) ((x) ^ (y) ^ (z)) -#ifdef IS_NV #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)) + +#ifdef USE_BITSELECT #define MD4_Fo(x,y,z) (bitselect ((z), (y), (x))) #define MD4_Go(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_AMD -#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)) -#define MD4_Fo(x,y,z) (bitselect ((z), (y), (x))) -#define MD4_Go(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_GENERIC -#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)) +#else #define MD4_Fo(x,y,z) (MD4_F((x), (y), (z))) #define MD4_Go(x,y,z) (MD4_G((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_md5.cl b/OpenCL/inc_hash_md5.cl index 2fee96f96..3c52c1f40 100644 --- a/OpenCL/inc_hash_md5.cl +++ b/OpenCL/inc_hash_md5.cl @@ -835,9 +835,7 @@ DECLSPEC void md5_hmac_init_64 (md5_hmac_ctx_t *ctx, const u32 *w0, const u32 *w md5_init (&ctx->ipad); - md5_transform (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + md5_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -860,9 +858,7 @@ DECLSPEC void md5_hmac_init_64 (md5_hmac_ctx_t *ctx, const u32 *w0, const u32 *w md5_init (&ctx->opad); - md5_transform (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + md5_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void md5_hmac_init (md5_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -1758,9 +1754,7 @@ DECLSPEC void md5_hmac_init_vector_64 (md5_hmac_ctx_vector_t *ctx, const u32x *w md5_init_vector (&ctx->ipad); - md5_transform_vector (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + md5_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1783,9 +1777,7 @@ DECLSPEC void md5_hmac_init_vector_64 (md5_hmac_ctx_vector_t *ctx, const u32x *w md5_init_vector (&ctx->opad); - md5_transform_vector (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + md5_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void md5_hmac_init_vector (md5_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_md5.h b/OpenCL/inc_hash_md5.h index f6b4a00b3..1e6eaaf93 100644 --- a/OpenCL/inc_hash_md5.h +++ b/OpenCL/inc_hash_md5.h @@ -11,35 +11,17 @@ #define MD5_H_S(x,y,z) ((x) ^ (y) ^ (z)) #define MD5_I_S(x,y,z) ((y) ^ ((x) | ~(z))) -#ifdef IS_NV #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_H1(x,y,z) ((t = (x) ^ (y)) ^ (z)) #define MD5_H2(x,y,z) ((x) ^ t) #define MD5_I(x,y,z) ((y) ^ ((x) | ~(z))) -#define MD5_Fo(x,y,z) (MD5_F((x), (y), (z))) -#define MD5_Go(x,y,z) (MD5_G((x), (y), (z))) -#endif -#ifdef IS_AMD -#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_H1(x,y,z) ((t = (x) ^ (y)) ^ (z)) -#define MD5_H2(x,y,z) ((x) ^ t) -#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z))) +#ifdef USE_BITSELECT #define MD5_Fo(x,y,z) (bitselect ((z), (y), (x))) #define MD5_Go(x,y,z) (bitselect ((y), (x), (z))) -#endif - -#ifdef IS_GENERIC -#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_H1(x,y,z) ((t = (x) ^ (y)) ^ (z)) -#define MD5_H2(x,y,z) ((x) ^ t) -#define MD5_I(x,y,z) ((y) ^ ((x) | ~(z))) +#else #define MD5_Fo(x,y,z) (MD5_F((x), (y), (z))) #define MD5_Go(x,y,z) (MD5_G((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_ripemd160.cl b/OpenCL/inc_hash_ripemd160.cl index 703f0dcc8..bcf1074ac 100644 --- a/OpenCL/inc_hash_ripemd160.cl +++ b/OpenCL/inc_hash_ripemd160.cl @@ -933,9 +933,7 @@ DECLSPEC void ripemd160_hmac_init_64 (ripemd160_hmac_ctx_t *ctx, const u32 *w0, ripemd160_init (&ctx->ipad); - ripemd160_transform (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + ripemd160_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -958,9 +956,7 @@ DECLSPEC void ripemd160_hmac_init_64 (ripemd160_hmac_ctx_t *ctx, const u32 *w0, ripemd160_init (&ctx->opad); - ripemd160_transform (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + ripemd160_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void ripemd160_hmac_init (ripemd160_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -1955,9 +1951,7 @@ DECLSPEC void ripemd160_hmac_init_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, c ripemd160_init_vector (&ctx->ipad); - ripemd160_transform_vector (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + ripemd160_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1980,9 +1974,7 @@ DECLSPEC void ripemd160_hmac_init_vector_64 (ripemd160_hmac_ctx_vector_t *ctx, c ripemd160_init_vector (&ctx->opad); - ripemd160_transform_vector (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + ripemd160_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void ripemd160_hmac_init_vector (ripemd160_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_ripemd160.h b/OpenCL/inc_hash_ripemd160.h index 982f4fdb2..25a69ed56 100644 --- a/OpenCL/inc_hash_ripemd160.h +++ b/OpenCL/inc_hash_ripemd160.h @@ -6,32 +6,16 @@ #ifndef _INC_HASH_RIPEMD160_H #define _INC_HASH_RIPEMD160_H -#ifdef IS_NV #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))) + +#ifdef USE_BITSELECT #define RIPEMD160_Go(x,y,z) (bitselect ((z), (y), (x))) #define RIPEMD160_Io(x,y,z) (bitselect ((y), (x), (z))) -#endif - -#ifdef IS_AMD -#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))) -#define RIPEMD160_Go(x,y,z) (bitselect ((z), (y), (x))) -#define RIPEMD160_Io(x,y,z) (bitselect ((y), (x), (z))) -#endif - -#ifdef IS_GENERIC -#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))) +#else #define RIPEMD160_Go(x,y,z) (RIPEMD160_G ((x), (y), (z))) #define RIPEMD160_Io(x,y,z) (RIPEMD160_I ((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_sha1.cl b/OpenCL/inc_hash_sha1.cl index 6ec45c6ba..a8f754c1a 100644 --- a/OpenCL/inc_hash_sha1.cl +++ b/OpenCL/inc_hash_sha1.cl @@ -22,6 +22,8 @@ DECLSPEC void sha1_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 d = digest[3]; u32 e = digest[4]; + #ifdef IS_CPU + u32 w0_t = w0[0]; u32 w1_t = w0[1]; u32 w2_t = w0[2]; @@ -136,6 +138,187 @@ DECLSPEC void sha1_transform (const u32 *w0, const u32 *w1, const u32 *w2, const #undef K + #else + + u32 w00_t = w0[0]; + u32 w01_t = w0[1]; + u32 w02_t = w0[2]; + u32 w03_t = w0[3]; + u32 w04_t = w1[0]; + u32 w05_t = w1[1]; + u32 w06_t = w1[2]; + u32 w07_t = w1[3]; + u32 w08_t = w2[0]; + u32 w09_t = w2[1]; + u32 w0a_t = w2[2]; + u32 w0b_t = w2[3]; + u32 w0c_t = w3[0]; + u32 w0d_t = w3[1]; + u32 w0e_t = w3[2]; + u32 w0f_t = w3[3]; + u32 w10_t; + u32 w11_t; + u32 w12_t; + u32 w13_t; + u32 w14_t; + u32 w15_t; + u32 w16_t; + u32 w17_t; + u32 w18_t; + u32 w19_t; + u32 w1a_t; + u32 w1b_t; + u32 w1c_t; + u32 w1d_t; + u32 w1e_t; + u32 w1f_t; + u32 w20_t; + u32 w21_t; + u32 w22_t; + u32 w23_t; + u32 w24_t; + u32 w25_t; + u32 w26_t; + u32 w27_t; + u32 w28_t; + u32 w29_t; + u32 w2a_t; + u32 w2b_t; + u32 w2c_t; + u32 w2d_t; + u32 w2e_t; + u32 w2f_t; + u32 w30_t; + u32 w31_t; + u32 w32_t; + u32 w33_t; + u32 w34_t; + u32 w35_t; + u32 w36_t; + u32 w37_t; + u32 w38_t; + u32 w39_t; + u32 w3a_t; + u32 w3b_t; + u32 w3c_t; + u32 w3d_t; + u32 w3e_t; + u32 w3f_t; + u32 w40_t; + u32 w41_t; + u32 w42_t; + u32 w43_t; + u32 w44_t; + u32 w45_t; + u32 w46_t; + u32 w47_t; + u32 w48_t; + u32 w49_t; + u32 w4a_t; + u32 w4b_t; + u32 w4c_t; + u32 w4d_t; + u32 w4e_t; + u32 w4f_t; + + #define K SHA1C00 + + SHA1_STEP_S (SHA1_F0o, a, b, c, d, e, w00_t); + SHA1_STEP_S (SHA1_F0o, e, a, b, c, d, w01_t); + SHA1_STEP_S (SHA1_F0o, d, e, a, b, c, w02_t); + SHA1_STEP_S (SHA1_F0o, c, d, e, a, b, w03_t); + SHA1_STEP_S (SHA1_F0o, b, c, d, e, a, w04_t); + SHA1_STEP_S (SHA1_F0o, a, b, c, d, e, w05_t); + SHA1_STEP_S (SHA1_F0o, e, a, b, c, d, w06_t); + SHA1_STEP_S (SHA1_F0o, d, e, a, b, c, w07_t); + SHA1_STEP_S (SHA1_F0o, c, d, e, a, b, w08_t); + SHA1_STEP_S (SHA1_F0o, b, c, d, e, a, w09_t); + SHA1_STEP_S (SHA1_F0o, a, b, c, d, e, w0a_t); + SHA1_STEP_S (SHA1_F0o, e, a, b, c, d, w0b_t); + SHA1_STEP_S (SHA1_F0o, d, e, a, b, c, w0c_t); + SHA1_STEP_S (SHA1_F0o, c, d, e, a, b, w0d_t); + SHA1_STEP_S (SHA1_F0o, b, c, d, e, a, w0e_t); + SHA1_STEP_S (SHA1_F0o, a, b, c, d, e, w0f_t); + w10_t = hc_rotl32_S ((w0d_t ^ w08_t ^ w02_t ^ w00_t), 1u); SHA1_STEP_S (SHA1_F0o, e, a, b, c, d, w10_t); + w11_t = hc_rotl32_S ((w0e_t ^ w09_t ^ w03_t ^ w01_t), 1u); SHA1_STEP_S (SHA1_F0o, d, e, a, b, c, w11_t); + w12_t = hc_rotl32_S ((w0f_t ^ w0a_t ^ w04_t ^ w02_t), 1u); SHA1_STEP_S (SHA1_F0o, c, d, e, a, b, w12_t); + w13_t = hc_rotl32_S ((w10_t ^ w0b_t ^ w05_t ^ w03_t), 1u); SHA1_STEP_S (SHA1_F0o, b, c, d, e, a, w13_t); + + #undef K + #define K SHA1C01 + + w14_t = hc_rotl32_S ((w11_t ^ w0c_t ^ w06_t ^ w04_t), 1u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w14_t); + w15_t = hc_rotl32_S ((w12_t ^ w0d_t ^ w07_t ^ w05_t), 1u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w15_t); + w16_t = hc_rotl32_S ((w13_t ^ w0e_t ^ w08_t ^ w06_t), 1u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w16_t); + w17_t = hc_rotl32_S ((w14_t ^ w0f_t ^ w09_t ^ w07_t), 1u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w17_t); + w18_t = hc_rotl32_S ((w15_t ^ w10_t ^ w0a_t ^ w08_t), 1u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w18_t); + w19_t = hc_rotl32_S ((w16_t ^ w11_t ^ w0b_t ^ w09_t), 1u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w19_t); + w1a_t = hc_rotl32_S ((w17_t ^ w12_t ^ w0c_t ^ w0a_t), 1u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w1a_t); + w1b_t = hc_rotl32_S ((w18_t ^ w13_t ^ w0d_t ^ w0b_t), 1u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w1b_t); + w1c_t = hc_rotl32_S ((w19_t ^ w14_t ^ w0e_t ^ w0c_t), 1u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w1c_t); + w1d_t = hc_rotl32_S ((w1a_t ^ w15_t ^ w0f_t ^ w0d_t), 1u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w1d_t); + w1e_t = hc_rotl32_S ((w1b_t ^ w16_t ^ w10_t ^ w0e_t), 1u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w1e_t); + w1f_t = hc_rotl32_S ((w1c_t ^ w17_t ^ w11_t ^ w0f_t), 1u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w1f_t); + w20_t = hc_rotl32_S ((w1a_t ^ w10_t ^ w04_t ^ w00_t), 2u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w20_t); + w21_t = hc_rotl32_S ((w1b_t ^ w11_t ^ w05_t ^ w01_t), 2u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w21_t); + w22_t = hc_rotl32_S ((w1c_t ^ w12_t ^ w06_t ^ w02_t), 2u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w22_t); + w23_t = hc_rotl32_S ((w1d_t ^ w13_t ^ w07_t ^ w03_t), 2u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w23_t); + w24_t = hc_rotl32_S ((w1e_t ^ w14_t ^ w08_t ^ w04_t), 2u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w24_t); + w25_t = hc_rotl32_S ((w1f_t ^ w15_t ^ w09_t ^ w05_t), 2u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w25_t); + w26_t = hc_rotl32_S ((w20_t ^ w16_t ^ w0a_t ^ w06_t), 2u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w26_t); + w27_t = hc_rotl32_S ((w21_t ^ w17_t ^ w0b_t ^ w07_t), 2u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w27_t); + + #undef K + #define K SHA1C02 + + w28_t = hc_rotl32_S ((w22_t ^ w18_t ^ w0c_t ^ w08_t), 2u); SHA1_STEP_S (SHA1_F2o, a, b, c, d, e, w28_t); + w29_t = hc_rotl32_S ((w23_t ^ w19_t ^ w0d_t ^ w09_t), 2u); SHA1_STEP_S (SHA1_F2o, e, a, b, c, d, w29_t); + w2a_t = hc_rotl32_S ((w24_t ^ w1a_t ^ w0e_t ^ w0a_t), 2u); SHA1_STEP_S (SHA1_F2o, d, e, a, b, c, w2a_t); + w2b_t = hc_rotl32_S ((w25_t ^ w1b_t ^ w0f_t ^ w0b_t), 2u); SHA1_STEP_S (SHA1_F2o, c, d, e, a, b, w2b_t); + w2c_t = hc_rotl32_S ((w26_t ^ w1c_t ^ w10_t ^ w0c_t), 2u); SHA1_STEP_S (SHA1_F2o, b, c, d, e, a, w2c_t); + w2d_t = hc_rotl32_S ((w27_t ^ w1d_t ^ w11_t ^ w0d_t), 2u); SHA1_STEP_S (SHA1_F2o, a, b, c, d, e, w2d_t); + w2e_t = hc_rotl32_S ((w28_t ^ w1e_t ^ w12_t ^ w0e_t), 2u); SHA1_STEP_S (SHA1_F2o, e, a, b, c, d, w2e_t); + w2f_t = hc_rotl32_S ((w29_t ^ w1f_t ^ w13_t ^ w0f_t), 2u); SHA1_STEP_S (SHA1_F2o, d, e, a, b, c, w2f_t); + w30_t = hc_rotl32_S ((w2a_t ^ w20_t ^ w14_t ^ w10_t), 2u); SHA1_STEP_S (SHA1_F2o, c, d, e, a, b, w30_t); + w31_t = hc_rotl32_S ((w2b_t ^ w21_t ^ w15_t ^ w11_t), 2u); SHA1_STEP_S (SHA1_F2o, b, c, d, e, a, w31_t); + w32_t = hc_rotl32_S ((w2c_t ^ w22_t ^ w16_t ^ w12_t), 2u); SHA1_STEP_S (SHA1_F2o, a, b, c, d, e, w32_t); + w33_t = hc_rotl32_S ((w2d_t ^ w23_t ^ w17_t ^ w13_t), 2u); SHA1_STEP_S (SHA1_F2o, e, a, b, c, d, w33_t); + w34_t = hc_rotl32_S ((w2e_t ^ w24_t ^ w18_t ^ w14_t), 2u); SHA1_STEP_S (SHA1_F2o, d, e, a, b, c, w34_t); + w35_t = hc_rotl32_S ((w2f_t ^ w25_t ^ w19_t ^ w15_t), 2u); SHA1_STEP_S (SHA1_F2o, c, d, e, a, b, w35_t); + w36_t = hc_rotl32_S ((w30_t ^ w26_t ^ w1a_t ^ w16_t), 2u); SHA1_STEP_S (SHA1_F2o, b, c, d, e, a, w36_t); + w37_t = hc_rotl32_S ((w31_t ^ w27_t ^ w1b_t ^ w17_t), 2u); SHA1_STEP_S (SHA1_F2o, a, b, c, d, e, w37_t); + w38_t = hc_rotl32_S ((w32_t ^ w28_t ^ w1c_t ^ w18_t), 2u); SHA1_STEP_S (SHA1_F2o, e, a, b, c, d, w38_t); + w39_t = hc_rotl32_S ((w33_t ^ w29_t ^ w1d_t ^ w19_t), 2u); SHA1_STEP_S (SHA1_F2o, d, e, a, b, c, w39_t); + w3a_t = hc_rotl32_S ((w34_t ^ w2a_t ^ w1e_t ^ w1a_t), 2u); SHA1_STEP_S (SHA1_F2o, c, d, e, a, b, w3a_t); + w3b_t = hc_rotl32_S ((w35_t ^ w2b_t ^ w1f_t ^ w1b_t), 2u); SHA1_STEP_S (SHA1_F2o, b, c, d, e, a, w3b_t); + + #undef K + #define K SHA1C03 + + w3c_t = hc_rotl32_S ((w36_t ^ w2c_t ^ w20_t ^ w1c_t), 2u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w3c_t); + w3d_t = hc_rotl32_S ((w37_t ^ w2d_t ^ w21_t ^ w1d_t), 2u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w3d_t); + w3e_t = hc_rotl32_S ((w38_t ^ w2e_t ^ w22_t ^ w1e_t), 2u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w3e_t); + w3f_t = hc_rotl32_S ((w39_t ^ w2f_t ^ w23_t ^ w1f_t), 2u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w3f_t); + w40_t = hc_rotl32_S ((w34_t ^ w20_t ^ w08_t ^ w00_t), 4u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w40_t); + w41_t = hc_rotl32_S ((w35_t ^ w21_t ^ w09_t ^ w01_t), 4u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w41_t); + w42_t = hc_rotl32_S ((w36_t ^ w22_t ^ w0a_t ^ w02_t), 4u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w42_t); + w43_t = hc_rotl32_S ((w37_t ^ w23_t ^ w0b_t ^ w03_t), 4u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w43_t); + w44_t = hc_rotl32_S ((w38_t ^ w24_t ^ w0c_t ^ w04_t), 4u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w44_t); + w45_t = hc_rotl32_S ((w39_t ^ w25_t ^ w0d_t ^ w05_t), 4u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w45_t); + w46_t = hc_rotl32_S ((w3a_t ^ w26_t ^ w0e_t ^ w06_t), 4u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w46_t); + w47_t = hc_rotl32_S ((w3b_t ^ w27_t ^ w0f_t ^ w07_t), 4u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w47_t); + w48_t = hc_rotl32_S ((w3c_t ^ w28_t ^ w10_t ^ w08_t), 4u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w48_t); + w49_t = hc_rotl32_S ((w3d_t ^ w29_t ^ w11_t ^ w09_t), 4u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w49_t); + w4a_t = hc_rotl32_S ((w3e_t ^ w2a_t ^ w12_t ^ w0a_t), 4u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w4a_t); + w4b_t = hc_rotl32_S ((w3f_t ^ w2b_t ^ w13_t ^ w0b_t), 4u); SHA1_STEP_S (SHA1_F1, a, b, c, d, e, w4b_t); + w4c_t = hc_rotl32_S ((w40_t ^ w2c_t ^ w14_t ^ w0c_t), 4u); SHA1_STEP_S (SHA1_F1, e, a, b, c, d, w4c_t); + w4d_t = hc_rotl32_S ((w41_t ^ w2d_t ^ w15_t ^ w0d_t), 4u); SHA1_STEP_S (SHA1_F1, d, e, a, b, c, w4d_t); + w4e_t = hc_rotl32_S ((w42_t ^ w2e_t ^ w16_t ^ w0e_t), 4u); SHA1_STEP_S (SHA1_F1, c, d, e, a, b, w4e_t); + w4f_t = hc_rotl32_S ((w43_t ^ w2f_t ^ w17_t ^ w0f_t), 4u); SHA1_STEP_S (SHA1_F1, b, c, d, e, a, w4f_t); + + #undef K + #endif + digest[0] += a; digest[1] += b; digest[2] += c; @@ -1101,9 +1284,7 @@ DECLSPEC void sha1_hmac_init_64 (sha1_hmac_ctx_t *ctx, const u32 *w0, const u32 sha1_init (&ctx->ipad); - sha1_transform (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + sha1_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1126,9 +1307,7 @@ DECLSPEC void sha1_hmac_init_64 (sha1_hmac_ctx_t *ctx, const u32 *w0, const u32 sha1_init (&ctx->opad); - sha1_transform (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + sha1_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void sha1_hmac_init (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -1440,6 +1619,9 @@ DECLSPEC void sha1_transform_vector (const u32x *w0, const u32x *w1, const u32x u32x d = digest[3]; u32x e = digest[4]; + #ifdef IS_CPU + + u32x w0_t = w0[0]; u32x w1_t = w0[1]; u32x w2_t = w0[2]; @@ -1554,6 +1736,188 @@ DECLSPEC void sha1_transform_vector (const u32x *w0, const u32x *w1, const u32x #undef K + #else + + u32x w00_t = w0[0]; + u32x w01_t = w0[1]; + u32x w02_t = w0[2]; + u32x w03_t = w0[3]; + u32x w04_t = w1[0]; + u32x w05_t = w1[1]; + u32x w06_t = w1[2]; + u32x w07_t = w1[3]; + u32x w08_t = w2[0]; + u32x w09_t = w2[1]; + u32x w0a_t = w2[2]; + u32x w0b_t = w2[3]; + u32x w0c_t = w3[0]; + u32x w0d_t = w3[1]; + u32x w0e_t = w3[2]; + u32x w0f_t = w3[3]; + u32x w10_t; + u32x w11_t; + u32x w12_t; + u32x w13_t; + u32x w14_t; + u32x w15_t; + u32x w16_t; + u32x w17_t; + u32x w18_t; + u32x w19_t; + u32x w1a_t; + u32x w1b_t; + u32x w1c_t; + u32x w1d_t; + u32x w1e_t; + u32x w1f_t; + u32x w20_t; + u32x w21_t; + u32x w22_t; + u32x w23_t; + u32x w24_t; + u32x w25_t; + u32x w26_t; + u32x w27_t; + u32x w28_t; + u32x w29_t; + u32x w2a_t; + u32x w2b_t; + u32x w2c_t; + u32x w2d_t; + u32x w2e_t; + u32x w2f_t; + u32x w30_t; + u32x w31_t; + u32x w32_t; + u32x w33_t; + u32x w34_t; + u32x w35_t; + u32x w36_t; + u32x w37_t; + u32x w38_t; + u32x w39_t; + u32x w3a_t; + u32x w3b_t; + u32x w3c_t; + u32x w3d_t; + u32x w3e_t; + u32x w3f_t; + u32x w40_t; + u32x w41_t; + u32x w42_t; + u32x w43_t; + u32x w44_t; + u32x w45_t; + u32x w46_t; + u32x w47_t; + u32x w48_t; + u32x w49_t; + u32x w4a_t; + u32x w4b_t; + u32x w4c_t; + u32x w4d_t; + u32x w4e_t; + u32x w4f_t; + + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w00_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w01_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w02_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w03_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w04_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w05_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w06_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w07_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w08_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w09_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0a_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0b_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w0c_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w0d_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w0e_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0f_t); + w10_t = hc_rotl32 ((w0d_t ^ w08_t ^ w02_t ^ w00_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w10_t); + w11_t = hc_rotl32 ((w0e_t ^ w09_t ^ w03_t ^ w01_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w11_t); + w12_t = hc_rotl32 ((w0f_t ^ w0a_t ^ w04_t ^ w02_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w12_t); + w13_t = hc_rotl32 ((w10_t ^ w0b_t ^ w05_t ^ w03_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w13_t); + + #undef K + #define K SHA1C01 + + w14_t = hc_rotl32 ((w11_t ^ w0c_t ^ w06_t ^ w04_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w14_t); + w15_t = hc_rotl32 ((w12_t ^ w0d_t ^ w07_t ^ w05_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w15_t); + w16_t = hc_rotl32 ((w13_t ^ w0e_t ^ w08_t ^ w06_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w16_t); + w17_t = hc_rotl32 ((w14_t ^ w0f_t ^ w09_t ^ w07_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w17_t); + w18_t = hc_rotl32 ((w15_t ^ w10_t ^ w0a_t ^ w08_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w18_t); + w19_t = hc_rotl32 ((w16_t ^ w11_t ^ w0b_t ^ w09_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w19_t); + w1a_t = hc_rotl32 ((w17_t ^ w12_t ^ w0c_t ^ w0a_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w1a_t); + w1b_t = hc_rotl32 ((w18_t ^ w13_t ^ w0d_t ^ w0b_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w1b_t); + w1c_t = hc_rotl32 ((w19_t ^ w14_t ^ w0e_t ^ w0c_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1c_t); + w1d_t = hc_rotl32 ((w1a_t ^ w15_t ^ w0f_t ^ w0d_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w1d_t); + w1e_t = hc_rotl32 ((w1b_t ^ w16_t ^ w10_t ^ w0e_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1e_t); + w1f_t = hc_rotl32 ((w1c_t ^ w17_t ^ w11_t ^ w0f_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w1f_t); + w20_t = hc_rotl32 ((w1a_t ^ w10_t ^ w04_t ^ w00_t), 2u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w20_t); + w21_t = hc_rotl32 ((w1b_t ^ w11_t ^ w05_t ^ w01_t), 2u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w21_t); + w22_t = hc_rotl32 ((w1c_t ^ w12_t ^ w06_t ^ w02_t), 2u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w22_t); + w23_t = hc_rotl32 ((w1d_t ^ w13_t ^ w07_t ^ w03_t), 2u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w23_t); + w24_t = hc_rotl32 ((w1e_t ^ w14_t ^ w08_t ^ w04_t), 2u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w24_t); + w25_t = hc_rotl32 ((w1f_t ^ w15_t ^ w09_t ^ w05_t), 2u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w25_t); + w26_t = hc_rotl32 ((w20_t ^ w16_t ^ w0a_t ^ w06_t), 2u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w26_t); + w27_t = hc_rotl32 ((w21_t ^ w17_t ^ w0b_t ^ w07_t), 2u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w27_t); + + #undef K + #define K SHA1C02 + + w28_t = hc_rotl32 ((w22_t ^ w18_t ^ w0c_t ^ w08_t), 2u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w28_t); + w29_t = hc_rotl32 ((w23_t ^ w19_t ^ w0d_t ^ w09_t), 2u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w29_t); + w2a_t = hc_rotl32 ((w24_t ^ w1a_t ^ w0e_t ^ w0a_t), 2u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w2a_t); + w2b_t = hc_rotl32 ((w25_t ^ w1b_t ^ w0f_t ^ w0b_t), 2u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w2b_t); + w2c_t = hc_rotl32 ((w26_t ^ w1c_t ^ w10_t ^ w0c_t), 2u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w2c_t); + w2d_t = hc_rotl32 ((w27_t ^ w1d_t ^ w11_t ^ w0d_t), 2u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2d_t); + w2e_t = hc_rotl32 ((w28_t ^ w1e_t ^ w12_t ^ w0e_t), 2u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w2e_t); + w2f_t = hc_rotl32 ((w29_t ^ w1f_t ^ w13_t ^ w0f_t), 2u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w2f_t); + w30_t = hc_rotl32 ((w2a_t ^ w20_t ^ w14_t ^ w10_t), 2u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w30_t); + w31_t = hc_rotl32 ((w2b_t ^ w21_t ^ w15_t ^ w11_t), 2u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w31_t); + w32_t = hc_rotl32 ((w2c_t ^ w22_t ^ w16_t ^ w12_t), 2u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w32_t); + w33_t = hc_rotl32 ((w2d_t ^ w23_t ^ w17_t ^ w13_t), 2u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w33_t); + w34_t = hc_rotl32 ((w2e_t ^ w24_t ^ w18_t ^ w14_t), 2u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w34_t); + w35_t = hc_rotl32 ((w2f_t ^ w25_t ^ w19_t ^ w15_t), 2u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w35_t); + w36_t = hc_rotl32 ((w30_t ^ w26_t ^ w1a_t ^ w16_t), 2u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w36_t); + w37_t = hc_rotl32 ((w31_t ^ w27_t ^ w1b_t ^ w17_t), 2u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w37_t); + w38_t = hc_rotl32 ((w32_t ^ w28_t ^ w1c_t ^ w18_t), 2u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w38_t); + w39_t = hc_rotl32 ((w33_t ^ w29_t ^ w1d_t ^ w19_t), 2u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w39_t); + w3a_t = hc_rotl32 ((w34_t ^ w2a_t ^ w1e_t ^ w1a_t), 2u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w3a_t); + w3b_t = hc_rotl32 ((w35_t ^ w2b_t ^ w1f_t ^ w1b_t), 2u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w3b_t); + + #undef K + #define K SHA1C03 + + w3c_t = hc_rotl32 ((w36_t ^ w2c_t ^ w20_t ^ w1c_t), 2u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3c_t); + w3d_t = hc_rotl32 ((w37_t ^ w2d_t ^ w21_t ^ w1d_t), 2u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w3d_t); + w3e_t = hc_rotl32 ((w38_t ^ w2e_t ^ w22_t ^ w1e_t), 2u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3e_t); + w3f_t = hc_rotl32 ((w39_t ^ w2f_t ^ w23_t ^ w1f_t), 2u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w3f_t); + w40_t = hc_rotl32 ((w34_t ^ w20_t ^ w08_t ^ w00_t), 4u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w40_t); + w41_t = hc_rotl32 ((w35_t ^ w21_t ^ w09_t ^ w01_t), 4u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w41_t); + w42_t = hc_rotl32 ((w36_t ^ w22_t ^ w0a_t ^ w02_t), 4u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w42_t); + w43_t = hc_rotl32 ((w37_t ^ w23_t ^ w0b_t ^ w03_t), 4u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w43_t); + w44_t = hc_rotl32 ((w38_t ^ w24_t ^ w0c_t ^ w04_t), 4u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w44_t); + w45_t = hc_rotl32 ((w39_t ^ w25_t ^ w0d_t ^ w05_t), 4u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w45_t); + w46_t = hc_rotl32 ((w3a_t ^ w26_t ^ w0e_t ^ w06_t), 4u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w46_t); + w47_t = hc_rotl32 ((w3b_t ^ w27_t ^ w0f_t ^ w07_t), 4u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w47_t); + w48_t = hc_rotl32 ((w3c_t ^ w28_t ^ w10_t ^ w08_t), 4u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w48_t); + w49_t = hc_rotl32 ((w3d_t ^ w29_t ^ w11_t ^ w09_t), 4u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w49_t); + w4a_t = hc_rotl32 ((w3e_t ^ w2a_t ^ w12_t ^ w0a_t), 4u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w4a_t); + w4b_t = hc_rotl32 ((w3f_t ^ w2b_t ^ w13_t ^ w0b_t), 4u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4b_t); + w4c_t = hc_rotl32 ((w40_t ^ w2c_t ^ w14_t ^ w0c_t), 4u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4c_t); + w4d_t = hc_rotl32 ((w41_t ^ w2d_t ^ w15_t ^ w0d_t), 4u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w4d_t); + w4e_t = hc_rotl32 ((w42_t ^ w2e_t ^ w16_t ^ w0e_t), 4u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4e_t); + w4f_t = hc_rotl32 ((w43_t ^ w2f_t ^ w17_t ^ w0f_t), 4u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w4f_t); + + #undef K + + #endif + digest[0] += a; digest[1] += b; digest[2] += c; @@ -2139,9 +2503,7 @@ DECLSPEC void sha1_hmac_init_vector_64 (sha1_hmac_ctx_vector_t *ctx, const u32x sha1_init_vector (&ctx->ipad); - sha1_transform_vector (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + sha1_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -2164,9 +2526,7 @@ DECLSPEC void sha1_hmac_init_vector_64 (sha1_hmac_ctx_vector_t *ctx, const u32x sha1_init_vector (&ctx->opad); - sha1_transform_vector (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + sha1_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void sha1_hmac_init_vector (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_sha1.h b/OpenCL/inc_hash_sha1.h index 055516cb8..2ff36fdad 100644 --- a/OpenCL/inc_hash_sha1.h +++ b/OpenCL/inc_hash_sha1.h @@ -6,26 +6,14 @@ #ifndef _INC_HASH_SHA1_H #define _INC_HASH_SHA1_H -#ifdef IS_NV #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)))) + +#ifdef USE_BITSELECT #define SHA1_F0o(x,y,z) (bitselect ((z), (y), (x))) #define SHA1_F2o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_AMD -#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)))) -#define SHA1_F0o(x,y,z) (bitselect ((z), (y), (x))) -#define SHA1_F2o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_GENERIC -#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)))) +#else #define SHA1_F0o(x,y,z) (SHA1_F0 ((x), (y), (z))) #define SHA1_F2o(x,y,z) (SHA1_F2 ((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_sha224.cl b/OpenCL/inc_hash_sha224.cl index e93206e44..72f3dac99 100644 --- a/OpenCL/inc_hash_sha224.cl +++ b/OpenCL/inc_hash_sha224.cl @@ -850,9 +850,7 @@ DECLSPEC void sha224_hmac_init_64 (sha224_hmac_ctx_t *ctx, const u32 *w0, const sha224_init (&ctx->ipad); - sha224_transform (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + sha224_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -875,9 +873,7 @@ DECLSPEC void sha224_hmac_init_64 (sha224_hmac_ctx_t *ctx, const u32 *w0, const sha224_init (&ctx->opad); - sha224_transform (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + sha224_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void sha224_hmac_init (sha224_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -1814,9 +1810,7 @@ DECLSPEC void sha224_hmac_init_vector_64 (sha224_hmac_ctx_vector_t *ctx, const u sha224_init_vector (&ctx->ipad); - sha224_transform_vector (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + sha224_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1839,9 +1833,7 @@ DECLSPEC void sha224_hmac_init_vector_64 (sha224_hmac_ctx_vector_t *ctx, const u sha224_init_vector (&ctx->opad); - sha224_transform_vector (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + sha224_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void sha224_hmac_init_vector (sha224_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_sha224.h b/OpenCL/inc_hash_sha224.h index 6f243f7b4..d68c79d65 100644 --- a/OpenCL/inc_hash_sha224.h +++ b/OpenCL/inc_hash_sha224.h @@ -18,23 +18,13 @@ #define SHA224_S2(x) (hc_rotl32 ((x), 30u) ^ hc_rotl32 ((x), 19u) ^ hc_rotl32 ((x), 10u)) #define SHA224_S3(x) (hc_rotl32 ((x), 26u) ^ hc_rotl32 ((x), 21u) ^ hc_rotl32 ((x), 7u)) -#ifdef IS_NV #define SHA224_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) #define SHA224_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) + +#ifdef USE_BITSELECT #define SHA224_F0o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) #define SHA224_F1o(x,y,z) (bitselect ((z), (y), (x))) -#endif - -#ifdef IS_AMD -#define SHA224_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) -#define SHA224_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) -#define SHA224_F0o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#define SHA224_F1o(x,y,z) (bitselect ((z), (y), (x))) -#endif - -#ifdef IS_GENERIC -#define SHA224_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) -#define SHA224_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) +#else #define SHA224_F0o(x,y,z) (SHA224_F0 ((x), (y), (z))) #define SHA224_F1o(x,y,z) (SHA224_F1 ((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_sha256.cl b/OpenCL/inc_hash_sha256.cl index de2bd5897..430b0e8b9 100644 --- a/OpenCL/inc_hash_sha256.cl +++ b/OpenCL/inc_hash_sha256.cl @@ -850,9 +850,7 @@ DECLSPEC void sha256_hmac_init_64 (sha256_hmac_ctx_t *ctx, const u32 *w0, const sha256_init (&ctx->ipad); - sha256_transform (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + sha256_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -875,9 +873,7 @@ DECLSPEC void sha256_hmac_init_64 (sha256_hmac_ctx_t *ctx, const u32 *w0, const sha256_init (&ctx->opad); - sha256_transform (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + sha256_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void sha256_hmac_init (sha256_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -1814,9 +1810,7 @@ DECLSPEC void sha256_hmac_init_vector_64 (sha256_hmac_ctx_vector_t *ctx, const u sha256_init_vector (&ctx->ipad); - sha256_transform_vector (t0, t1, t2, t3, ctx->ipad.h); - - ctx->ipad.len = 64; + sha256_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1839,9 +1833,7 @@ DECLSPEC void sha256_hmac_init_vector_64 (sha256_hmac_ctx_vector_t *ctx, const u sha256_init_vector (&ctx->opad); - sha256_transform_vector (t0, t1, t2, t3, ctx->opad.h); - - ctx->opad.len = 64; + sha256_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void sha256_hmac_init_vector (sha256_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_sha256.h b/OpenCL/inc_hash_sha256.h index 89421be23..ccf5a79f8 100644 --- a/OpenCL/inc_hash_sha256.h +++ b/OpenCL/inc_hash_sha256.h @@ -18,23 +18,13 @@ #define SHA256_S2(x) (hc_rotl32 ((x), 30u) ^ hc_rotl32 ((x), 19u) ^ hc_rotl32 ((x), 10u)) #define SHA256_S3(x) (hc_rotl32 ((x), 26u) ^ hc_rotl32 ((x), 21u) ^ hc_rotl32 ((x), 7u)) -#ifdef IS_NV #define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) #define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) + +#ifdef USE_BITSELECT #define SHA256_F0o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) #define SHA256_F1o(x,y,z) (bitselect ((z), (y), (x))) -#endif - -#ifdef IS_AMD -#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) -#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) -#define SHA256_F0o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#define SHA256_F1o(x,y,z) (bitselect ((z), (y), (x))) -#endif - -#ifdef IS_GENERIC -#define SHA256_F0(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) -#define SHA256_F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) +#else #define SHA256_F0o(x,y,z) (SHA256_F0 ((x), (y), (z))) #define SHA256_F1o(x,y,z) (SHA256_F1 ((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_sha384.cl b/OpenCL/inc_hash_sha384.cl index ea26ec734..d63a5ab2b 100644 --- a/OpenCL/inc_hash_sha384.cl +++ b/OpenCL/inc_hash_sha384.cl @@ -219,7 +219,7 @@ DECLSPEC void sha384_update_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u if (len == 128) { - sha384_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); + sha384_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); ctx->w0[0] = 0; ctx->w0[1] = 0; @@ -1358,9 +1358,7 @@ DECLSPEC void sha384_hmac_init_128 (sha384_hmac_ctx_t *ctx, const u32 *w0, const sha384_init (&ctx->ipad); - sha384_transform (t0, t1, t2, t3, t4, t5, t6, t7, ctx->ipad.h); - - ctx->ipad.len = 128; + sha384_update_128 (&ctx->ipad, t0, t1, t2, t3, t4, t5, t6, t7, 128); // opad @@ -1399,9 +1397,7 @@ DECLSPEC void sha384_hmac_init_128 (sha384_hmac_ctx_t *ctx, const u32 *w0, const sha384_init (&ctx->opad); - sha384_transform (t0, t1, t2, t3, t4, t5, t6, t7, ctx->opad.h); - - ctx->opad.len = 128; + sha384_update_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } DECLSPEC void sha384_hmac_init (sha384_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -2093,7 +2089,7 @@ DECLSPEC void sha384_update_vector_128 (sha384_ctx_vector_t *ctx, u32x *w0, u32x if (len == 128) { - sha384_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); + sha384_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); ctx->w0[0] = 0; ctx->w0[1] = 0; @@ -2858,9 +2854,7 @@ DECLSPEC void sha384_hmac_init_vector_128 (sha384_hmac_ctx_vector_t *ctx, const sha384_init_vector (&ctx->ipad); - sha384_transform_vector (t0, t1, t2, t3, t4, t5, t6, t7, ctx->ipad.h); - - ctx->ipad.len = 128; + sha384_update_vector_128 (&ctx->ipad, t0, t1, t2, t3, t4, t5, t6, t7, 128); // opad @@ -2899,9 +2893,7 @@ DECLSPEC void sha384_hmac_init_vector_128 (sha384_hmac_ctx_vector_t *ctx, const sha384_init_vector (&ctx->opad); - sha384_transform_vector (t0, t1, t2, t3, t4, t5, t6, t7, ctx->opad.h); - - ctx->opad.len = 128; + sha384_update_vector_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } DECLSPEC void sha384_hmac_init_vector (sha384_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_sha384.h b/OpenCL/inc_hash_sha384.h index e19c9ec9a..92266b24a 100644 --- a/OpenCL/inc_hash_sha384.h +++ b/OpenCL/inc_hash_sha384.h @@ -21,17 +21,10 @@ #define SHA384_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) #define SHA384_F1(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) -#ifdef IS_NV +#ifdef USE_BITSELECT #define SHA384_F0o(x,y,z) (bitselect ((z), (y), (x))) #define SHA384_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_AMD -#define SHA384_F0o(x,y,z) (bitselect ((z), (y), (x))) -#define SHA384_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_GENERIC +#else #define SHA384_F0o(x,y,z) (SHA384_F0 ((x), (y), (z))) #define SHA384_F1o(x,y,z) (SHA384_F1 ((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_sha512.cl b/OpenCL/inc_hash_sha512.cl index 783a66fbe..0f5ca288a 100644 --- a/OpenCL/inc_hash_sha512.cl +++ b/OpenCL/inc_hash_sha512.cl @@ -1358,9 +1358,7 @@ DECLSPEC void sha512_hmac_init_128 (sha512_hmac_ctx_t *ctx, const u32 *w0, const sha512_init (&ctx->ipad); - sha512_transform (t0, t1, t2, t3, t4, t5, t6, t7, ctx->ipad.h); - - ctx->ipad.len = 128; + sha512_update_128 (&ctx->ipad, t0, t1, t2, t3, t4, t5, t6, t7, 128); // opad @@ -1399,9 +1397,7 @@ DECLSPEC void sha512_hmac_init_128 (sha512_hmac_ctx_t *ctx, const u32 *w0, const sha512_init (&ctx->opad); - sha512_transform (t0, t1, t2, t3, t4, t5, t6, t7, ctx->opad.h); - - ctx->opad.len = 128; + sha512_update_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } DECLSPEC void sha512_hmac_init (sha512_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -2975,9 +2971,7 @@ DECLSPEC void sha512_hmac_init_vector_128 (sha512_hmac_ctx_vector_t *ctx, const sha512_init_vector (&ctx->ipad); - sha512_transform_vector (t0, t1, t2, t3, t4, t5, t6, t7, ctx->ipad.h); - - ctx->ipad.len = 128; + sha512_update_vector_128 (&ctx->ipad, t0, t1, t2, t3, t4, t5, t6, t7, 128); // opad @@ -3016,9 +3010,7 @@ DECLSPEC void sha512_hmac_init_vector_128 (sha512_hmac_ctx_vector_t *ctx, const sha512_init_vector (&ctx->opad); - sha512_transform_vector (t0, t1, t2, t3, t4, t5, t6, t7, ctx->opad.h); - - ctx->opad.len = 128; + sha512_update_vector_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 128); } DECLSPEC void sha512_hmac_init_vector (sha512_hmac_ctx_vector_t *ctx, const u32x *w, const int len) diff --git a/OpenCL/inc_hash_sha512.h b/OpenCL/inc_hash_sha512.h index f30dc2b86..c66aa1fb9 100644 --- a/OpenCL/inc_hash_sha512.h +++ b/OpenCL/inc_hash_sha512.h @@ -21,17 +21,10 @@ #define SHA512_F0(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) #define SHA512_F1(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y)))) -#ifdef IS_NV +#ifdef USE_BITSELECT #define SHA512_F0o(x,y,z) (bitselect ((z), (y), (x))) #define SHA512_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_AMD -#define SHA512_F0o(x,y,z) (bitselect ((z), (y), (x))) -#define SHA512_F1o(x,y,z) (bitselect ((x), (y), ((x) ^ (z)))) -#endif - -#ifdef IS_GENERIC +#else #define SHA512_F0o(x,y,z) (SHA512_F0 ((x), (y), (z))) #define SHA512_F1o(x,y,z) (SHA512_F1 ((x), (y), (z))) #endif diff --git a/OpenCL/inc_hash_streebog256.cl b/OpenCL/inc_hash_streebog256.cl index 92534db1d..3983ef70a 100644 --- a/OpenCL/inc_hash_streebog256.cl +++ b/OpenCL/inc_hash_streebog256.cl @@ -1106,9 +1106,7 @@ DECLSPEC void streebog256_hmac_init_64 (streebog256_hmac_ctx_t *ctx, const u32 * streebog256_init (&ctx->ipad, s_sbob_sl64); - streebog256_transform (&ctx->ipad, t0, t1, t2, t3); - - ctx->ipad.len = 64; + streebog256_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1131,9 +1129,7 @@ DECLSPEC void streebog256_hmac_init_64 (streebog256_hmac_ctx_t *ctx, const u32 * streebog256_init (&ctx->opad, s_sbob_sl64); - streebog256_transform (&ctx->opad, t0, t1, t2, t3); - - ctx->opad.len = 64; + streebog256_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void streebog256_hmac_init (streebog256_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) @@ -1752,9 +1748,7 @@ DECLSPEC void streebog256_hmac_init_vector_64 (streebog256_hmac_ctx_vector_t *ct streebog256_init_vector (&ctx->ipad, s_sbob_sl64); - streebog256_transform_vector (&ctx->ipad, t0, t1, t2, t3); - - ctx->ipad.len = 64; + streebog256_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1777,9 +1771,7 @@ DECLSPEC void streebog256_hmac_init_vector_64 (streebog256_hmac_ctx_vector_t *ct streebog256_init_vector (&ctx->opad, s_sbob_sl64); - streebog256_transform_vector (&ctx->opad, t0, t1, t2, t3); - - ctx->opad.len = 64; + streebog256_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void streebog256_hmac_init_vector (streebog256_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) diff --git a/OpenCL/inc_hash_streebog512.cl b/OpenCL/inc_hash_streebog512.cl index 08580981d..e30119d3d 100644 --- a/OpenCL/inc_hash_streebog512.cl +++ b/OpenCL/inc_hash_streebog512.cl @@ -682,7 +682,7 @@ DECLSPEC void streebog512_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a ( for (int i = 0; i < 8; i++) { - k[i] = SBOG_LPSti64; + k[i] = SBOG_LPSti64_S; } #ifdef _unroll @@ -708,7 +708,7 @@ DECLSPEC void streebog512_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a ( #endif for (int i = 0; i < 8; i++) { - s[i] = SBOG_LPSti64; + s[i] = SBOG_LPSti64_S; } for (int i = 0; i < 8; i++) @@ -721,7 +721,7 @@ DECLSPEC void streebog512_g (u64 *h, const u64 *n, const u64 *m, SHM_TYPE u64a ( #endif for (int i = 0; i < 8; i++) { - k[i] = SBOG_LPSti64; + k[i] = SBOG_LPSti64_S; } } @@ -1106,9 +1106,7 @@ DECLSPEC void streebog512_hmac_init_64 (streebog512_hmac_ctx_t *ctx, const u32 * streebog512_init (&ctx->ipad, s_sbob_sl64); - streebog512_transform (&ctx->ipad, t0, t1, t2, t3); - - ctx->ipad.len = 64; + streebog512_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1131,9 +1129,7 @@ DECLSPEC void streebog512_hmac_init_64 (streebog512_hmac_ctx_t *ctx, const u32 * streebog512_init (&ctx->opad, s_sbob_sl64); - streebog512_transform (&ctx->opad, t0, t1, t2, t3); - - ctx->opad.len = 64; + streebog512_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void streebog512_hmac_init (streebog512_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) @@ -1771,9 +1767,7 @@ DECLSPEC void streebog512_hmac_init_vector_64 (streebog512_hmac_ctx_vector_t *ct streebog512_init_vector (&ctx->ipad, s_sbob_sl64); - streebog512_transform_vector (&ctx->ipad, t0, t1, t2, t3); - - ctx->ipad.len = 64; + streebog512_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -1796,9 +1790,7 @@ DECLSPEC void streebog512_hmac_init_vector_64 (streebog512_hmac_ctx_vector_t *ct streebog512_init_vector (&ctx->opad, s_sbob_sl64); - streebog512_transform_vector (&ctx->opad, t0, t1, t2, t3); - - ctx->opad.len = 64; + streebog512_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } DECLSPEC void streebog512_hmac_init_vector (streebog512_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64a (*s_sbob_sl64)[256]) diff --git a/OpenCL/inc_hash_streebog512.h b/OpenCL/inc_hash_streebog512.h index 4181674e8..e038181c7 100644 --- a/OpenCL/inc_hash_streebog512.h +++ b/OpenCL/inc_hash_streebog512.h @@ -6,6 +6,8 @@ #ifndef _INC_HASH_STREEBOG512_H #define _INC_HASH_STREEBOG512_H +#define BOX_S(S,n,i) ((S)[(n)][(i)]) + #if VECT_SIZE == 1 #define BOX(S,n,i) ((S)[(n)][(i)]) @@ -17,15 +19,25 @@ #elif VECT_SIZE == 8 #define BOX(S,n,i) make_u64x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], \ - (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) + (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) #elif VECT_SIZE == 16 #define BOX(S,n,i) make_u64x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], \ - (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], \ - (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], \ - (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) + (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], \ + (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], \ + (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif +#define SBOG_LPSti64_S \ + BOX_S (s_sbob_sl64, 0, ((t[0] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 1, ((t[1] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 2, ((t[2] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 3, ((t[3] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 4, ((t[4] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 5, ((t[5] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 6, ((t[6] >> (i * 8)) & 0xff)) ^ \ + BOX_S (s_sbob_sl64, 7, ((t[7] >> (i * 8)) & 0xff)) + #define SBOG_LPSti64 \ BOX (s_sbob_sl64, 0, ((t[0] >> (i * 8)) & 0xff)) ^ \ BOX (s_sbob_sl64, 1, ((t[1] >> (i * 8)) & 0xff)) ^ \ diff --git a/OpenCL/inc_hash_whirlpool.cl b/OpenCL/inc_hash_whirlpool.cl index b4933e6f7..f1d3c2323 100644 --- a/OpenCL/inc_hash_whirlpool.cl +++ b/OpenCL/inc_hash_whirlpool.cl @@ -9,1098 +9,548 @@ #include "inc_common.h" #include "inc_hash_whirlpool.h" -CONSTANT_VK u32a Ch[8][256] = +CONSTANT_VK u64a MT0[256] = { - { - 0x18186018, 0x23238c23, 0xc6c63fc6, 0xe8e887e8, - 0x87872687, 0xb8b8dab8, 0x01010401, 0x4f4f214f, - 0x3636d836, 0xa6a6a2a6, 0xd2d26fd2, 0xf5f5f3f5, - 0x7979f979, 0x6f6fa16f, 0x91917e91, 0x52525552, - 0x60609d60, 0xbcbccabc, 0x9b9b569b, 0x8e8e028e, - 0xa3a3b6a3, 0x0c0c300c, 0x7b7bf17b, 0x3535d435, - 0x1d1d741d, 0xe0e0a7e0, 0xd7d77bd7, 0xc2c22fc2, - 0x2e2eb82e, 0x4b4b314b, 0xfefedffe, 0x57574157, - 0x15155415, 0x7777c177, 0x3737dc37, 0xe5e5b3e5, - 0x9f9f469f, 0xf0f0e7f0, 0x4a4a354a, 0xdada4fda, - 0x58587d58, 0xc9c903c9, 0x2929a429, 0x0a0a280a, - 0xb1b1feb1, 0xa0a0baa0, 0x6b6bb16b, 0x85852e85, - 0xbdbdcebd, 0x5d5d695d, 0x10104010, 0xf4f4f7f4, - 0xcbcb0bcb, 0x3e3ef83e, 0x05051405, 0x67678167, - 0xe4e4b7e4, 0x27279c27, 0x41411941, 0x8b8b168b, - 0xa7a7a6a7, 0x7d7de97d, 0x95956e95, 0xd8d847d8, - 0xfbfbcbfb, 0xeeee9fee, 0x7c7ced7c, 0x66668566, - 0xdddd53dd, 0x17175c17, 0x47470147, 0x9e9e429e, - 0xcaca0fca, 0x2d2db42d, 0xbfbfc6bf, 0x07071c07, - 0xadad8ead, 0x5a5a755a, 0x83833683, 0x3333cc33, - 0x63639163, 0x02020802, 0xaaaa92aa, 0x7171d971, - 0xc8c807c8, 0x19196419, 0x49493949, 0xd9d943d9, - 0xf2f2eff2, 0xe3e3abe3, 0x5b5b715b, 0x88881a88, - 0x9a9a529a, 0x26269826, 0x3232c832, 0xb0b0fab0, - 0xe9e983e9, 0x0f0f3c0f, 0xd5d573d5, 0x80803a80, - 0xbebec2be, 0xcdcd13cd, 0x3434d034, 0x48483d48, - 0xffffdbff, 0x7a7af57a, 0x90907a90, 0x5f5f615f, - 0x20208020, 0x6868bd68, 0x1a1a681a, 0xaeae82ae, - 0xb4b4eab4, 0x54544d54, 0x93937693, 0x22228822, - 0x64648d64, 0xf1f1e3f1, 0x7373d173, 0x12124812, - 0x40401d40, 0x08082008, 0xc3c32bc3, 0xecec97ec, - 0xdbdb4bdb, 0xa1a1bea1, 0x8d8d0e8d, 0x3d3df43d, - 0x97976697, 0x00000000, 0xcfcf1bcf, 0x2b2bac2b, - 0x7676c576, 0x82823282, 0xd6d67fd6, 0x1b1b6c1b, - 0xb5b5eeb5, 0xafaf86af, 0x6a6ab56a, 0x50505d50, - 0x45450945, 0xf3f3ebf3, 0x3030c030, 0xefef9bef, - 0x3f3ffc3f, 0x55554955, 0xa2a2b2a2, 0xeaea8fea, - 0x65658965, 0xbabad2ba, 0x2f2fbc2f, 0xc0c027c0, - 0xdede5fde, 0x1c1c701c, 0xfdfdd3fd, 0x4d4d294d, - 0x92927292, 0x7575c975, 0x06061806, 0x8a8a128a, - 0xb2b2f2b2, 0xe6e6bfe6, 0x0e0e380e, 0x1f1f7c1f, - 0x62629562, 0xd4d477d4, 0xa8a89aa8, 0x96966296, - 0xf9f9c3f9, 0xc5c533c5, 0x25259425, 0x59597959, - 0x84842a84, 0x7272d572, 0x3939e439, 0x4c4c2d4c, - 0x5e5e655e, 0x7878fd78, 0x3838e038, 0x8c8c0a8c, - 0xd1d163d1, 0xa5a5aea5, 0xe2e2afe2, 0x61619961, - 0xb3b3f6b3, 0x21218421, 0x9c9c4a9c, 0x1e1e781e, - 0x43431143, 0xc7c73bc7, 0xfcfcd7fc, 0x04041004, - 0x51515951, 0x99995e99, 0x6d6da96d, 0x0d0d340d, - 0xfafacffa, 0xdfdf5bdf, 0x7e7ee57e, 0x24249024, - 0x3b3bec3b, 0xabab96ab, 0xcece1fce, 0x11114411, - 0x8f8f068f, 0x4e4e254e, 0xb7b7e6b7, 0xebeb8beb, - 0x3c3cf03c, 0x81813e81, 0x94946a94, 0xf7f7fbf7, - 0xb9b9deb9, 0x13134c13, 0x2c2cb02c, 0xd3d36bd3, - 0xe7e7bbe7, 0x6e6ea56e, 0xc4c437c4, 0x03030c03, - 0x56564556, 0x44440d44, 0x7f7fe17f, 0xa9a99ea9, - 0x2a2aa82a, 0xbbbbd6bb, 0xc1c123c1, 0x53535153, - 0xdcdc57dc, 0x0b0b2c0b, 0x9d9d4e9d, 0x6c6cad6c, - 0x3131c431, 0x7474cd74, 0xf6f6fff6, 0x46460546, - 0xacac8aac, 0x89891e89, 0x14145014, 0xe1e1a3e1, - 0x16165816, 0x3a3ae83a, 0x6969b969, 0x09092409, - 0x7070dd70, 0xb6b6e2b6, 0xd0d067d0, 0xeded93ed, - 0xcccc17cc, 0x42421542, 0x98985a98, 0xa4a4aaa4, - 0x2828a028, 0x5c5c6d5c, 0xf8f8c7f8, 0x86862286, - }, - { - 0xd8181860, 0x2623238c, 0xb8c6c63f, 0xfbe8e887, - 0xcb878726, 0x11b8b8da, 0x09010104, 0x0d4f4f21, - 0x9b3636d8, 0xffa6a6a2, 0x0cd2d26f, 0x0ef5f5f3, - 0x967979f9, 0x306f6fa1, 0x6d91917e, 0xf8525255, - 0x4760609d, 0x35bcbcca, 0x379b9b56, 0x8a8e8e02, - 0xd2a3a3b6, 0x6c0c0c30, 0x847b7bf1, 0x803535d4, - 0xf51d1d74, 0xb3e0e0a7, 0x21d7d77b, 0x9cc2c22f, - 0x432e2eb8, 0x294b4b31, 0x5dfefedf, 0xd5575741, - 0xbd151554, 0xe87777c1, 0x923737dc, 0x9ee5e5b3, - 0x139f9f46, 0x23f0f0e7, 0x204a4a35, 0x44dada4f, - 0xa258587d, 0xcfc9c903, 0x7c2929a4, 0x5a0a0a28, - 0x50b1b1fe, 0xc9a0a0ba, 0x146b6bb1, 0xd985852e, - 0x3cbdbdce, 0x8f5d5d69, 0x90101040, 0x07f4f4f7, - 0xddcbcb0b, 0xd33e3ef8, 0x2d050514, 0x78676781, - 0x97e4e4b7, 0x0227279c, 0x73414119, 0xa78b8b16, - 0xf6a7a7a6, 0xb27d7de9, 0x4995956e, 0x56d8d847, - 0x70fbfbcb, 0xcdeeee9f, 0xbb7c7ced, 0x71666685, - 0x7bdddd53, 0xaf17175c, 0x45474701, 0x1a9e9e42, - 0xd4caca0f, 0x582d2db4, 0x2ebfbfc6, 0x3f07071c, - 0xacadad8e, 0xb05a5a75, 0xef838336, 0xb63333cc, - 0x5c636391, 0x12020208, 0x93aaaa92, 0xde7171d9, - 0xc6c8c807, 0xd1191964, 0x3b494939, 0x5fd9d943, - 0x31f2f2ef, 0xa8e3e3ab, 0xb95b5b71, 0xbc88881a, - 0x3e9a9a52, 0x0b262698, 0xbf3232c8, 0x59b0b0fa, - 0xf2e9e983, 0x770f0f3c, 0x33d5d573, 0xf480803a, - 0x27bebec2, 0xebcdcd13, 0x893434d0, 0x3248483d, - 0x54ffffdb, 0x8d7a7af5, 0x6490907a, 0x9d5f5f61, - 0x3d202080, 0x0f6868bd, 0xca1a1a68, 0xb7aeae82, - 0x7db4b4ea, 0xce54544d, 0x7f939376, 0x2f222288, - 0x6364648d, 0x2af1f1e3, 0xcc7373d1, 0x82121248, - 0x7a40401d, 0x48080820, 0x95c3c32b, 0xdfecec97, - 0x4ddbdb4b, 0xc0a1a1be, 0x918d8d0e, 0xc83d3df4, - 0x5b979766, 0x00000000, 0xf9cfcf1b, 0x6e2b2bac, - 0xe17676c5, 0xe6828232, 0x28d6d67f, 0xc31b1b6c, - 0x74b5b5ee, 0xbeafaf86, 0x1d6a6ab5, 0xea50505d, - 0x57454509, 0x38f3f3eb, 0xad3030c0, 0xc4efef9b, - 0xda3f3ffc, 0xc7555549, 0xdba2a2b2, 0xe9eaea8f, - 0x6a656589, 0x03babad2, 0x4a2f2fbc, 0x8ec0c027, - 0x60dede5f, 0xfc1c1c70, 0x46fdfdd3, 0x1f4d4d29, - 0x76929272, 0xfa7575c9, 0x36060618, 0xae8a8a12, - 0x4bb2b2f2, 0x85e6e6bf, 0x7e0e0e38, 0xe71f1f7c, - 0x55626295, 0x3ad4d477, 0x81a8a89a, 0x52969662, - 0x62f9f9c3, 0xa3c5c533, 0x10252594, 0xab595979, - 0xd084842a, 0xc57272d5, 0xec3939e4, 0x164c4c2d, - 0x945e5e65, 0x9f7878fd, 0xe53838e0, 0x988c8c0a, - 0x17d1d163, 0xe4a5a5ae, 0xa1e2e2af, 0x4e616199, - 0x42b3b3f6, 0x34212184, 0x089c9c4a, 0xee1e1e78, - 0x61434311, 0xb1c7c73b, 0x4ffcfcd7, 0x24040410, - 0xe3515159, 0x2599995e, 0x226d6da9, 0x650d0d34, - 0x79fafacf, 0x69dfdf5b, 0xa97e7ee5, 0x19242490, - 0xfe3b3bec, 0x9aabab96, 0xf0cece1f, 0x99111144, - 0x838f8f06, 0x044e4e25, 0x66b7b7e6, 0xe0ebeb8b, - 0xc13c3cf0, 0xfd81813e, 0x4094946a, 0x1cf7f7fb, - 0x18b9b9de, 0x8b13134c, 0x512c2cb0, 0x05d3d36b, - 0x8ce7e7bb, 0x396e6ea5, 0xaac4c437, 0x1b03030c, - 0xdc565645, 0x5e44440d, 0xa07f7fe1, 0x88a9a99e, - 0x672a2aa8, 0x0abbbbd6, 0x87c1c123, 0xf1535351, - 0x72dcdc57, 0x530b0b2c, 0x019d9d4e, 0x2b6c6cad, - 0xa43131c4, 0xf37474cd, 0x15f6f6ff, 0x4c464605, - 0xa5acac8a, 0xb589891e, 0xb4141450, 0xbae1e1a3, - 0xa6161658, 0xf73a3ae8, 0x066969b9, 0x41090924, - 0xd77070dd, 0x6fb6b6e2, 0x1ed0d067, 0xd6eded93, - 0xe2cccc17, 0x68424215, 0x2c98985a, 0xeda4a4aa, - 0x752828a0, 0x865c5c6d, 0x6bf8f8c7, 0xc2868622, - }, - { - 0x30d81818, 0x46262323, 0x91b8c6c6, 0xcdfbe8e8, - 0x13cb8787, 0x6d11b8b8, 0x02090101, 0x9e0d4f4f, - 0x6c9b3636, 0x51ffa6a6, 0xb90cd2d2, 0xf70ef5f5, - 0xf2967979, 0xde306f6f, 0x3f6d9191, 0xa4f85252, - 0xc0476060, 0x6535bcbc, 0x2b379b9b, 0x018a8e8e, - 0x5bd2a3a3, 0x186c0c0c, 0xf6847b7b, 0x6a803535, - 0x3af51d1d, 0xddb3e0e0, 0xb321d7d7, 0x999cc2c2, - 0x5c432e2e, 0x96294b4b, 0xe15dfefe, 0xaed55757, - 0x2abd1515, 0xeee87777, 0x6e923737, 0xd79ee5e5, - 0x23139f9f, 0xfd23f0f0, 0x94204a4a, 0xa944dada, - 0xb0a25858, 0x8fcfc9c9, 0x527c2929, 0x145a0a0a, - 0x7f50b1b1, 0x5dc9a0a0, 0xd6146b6b, 0x17d98585, - 0x673cbdbd, 0xba8f5d5d, 0x20901010, 0xf507f4f4, - 0x8bddcbcb, 0x7cd33e3e, 0x0a2d0505, 0xce786767, - 0xd597e4e4, 0x4e022727, 0x82734141, 0x0ba78b8b, - 0x53f6a7a7, 0xfab27d7d, 0x37499595, 0xad56d8d8, - 0xeb70fbfb, 0xc1cdeeee, 0xf8bb7c7c, 0xcc716666, - 0xa77bdddd, 0x2eaf1717, 0x8e454747, 0x211a9e9e, - 0x89d4caca, 0x5a582d2d, 0x632ebfbf, 0x0e3f0707, - 0x47acadad, 0xb4b05a5a, 0x1bef8383, 0x66b63333, - 0xc65c6363, 0x04120202, 0x4993aaaa, 0xe2de7171, - 0x8dc6c8c8, 0x32d11919, 0x923b4949, 0xaf5fd9d9, - 0xf931f2f2, 0xdba8e3e3, 0xb6b95b5b, 0x0dbc8888, - 0x293e9a9a, 0x4c0b2626, 0x64bf3232, 0x7d59b0b0, - 0xcff2e9e9, 0x1e770f0f, 0xb733d5d5, 0x1df48080, - 0x6127bebe, 0x87ebcdcd, 0x68893434, 0x90324848, - 0xe354ffff, 0xf48d7a7a, 0x3d649090, 0xbe9d5f5f, - 0x403d2020, 0xd00f6868, 0x34ca1a1a, 0x41b7aeae, - 0x757db4b4, 0xa8ce5454, 0x3b7f9393, 0x442f2222, - 0xc8636464, 0xff2af1f1, 0xe6cc7373, 0x24821212, - 0x807a4040, 0x10480808, 0x9b95c3c3, 0xc5dfecec, - 0xab4ddbdb, 0x5fc0a1a1, 0x07918d8d, 0x7ac83d3d, - 0x335b9797, 0x00000000, 0x83f9cfcf, 0x566e2b2b, - 0xece17676, 0x19e68282, 0xb128d6d6, 0x36c31b1b, - 0x7774b5b5, 0x43beafaf, 0xd41d6a6a, 0xa0ea5050, - 0x8a574545, 0xfb38f3f3, 0x60ad3030, 0xc3c4efef, - 0x7eda3f3f, 0xaac75555, 0x59dba2a2, 0xc9e9eaea, - 0xca6a6565, 0x6903baba, 0x5e4a2f2f, 0x9d8ec0c0, - 0xa160dede, 0x38fc1c1c, 0xe746fdfd, 0x9a1f4d4d, - 0x39769292, 0xeafa7575, 0x0c360606, 0x09ae8a8a, - 0x794bb2b2, 0xd185e6e6, 0x1c7e0e0e, 0x3ee71f1f, - 0xc4556262, 0xb53ad4d4, 0x4d81a8a8, 0x31529696, - 0xef62f9f9, 0x97a3c5c5, 0x4a102525, 0xb2ab5959, - 0x15d08484, 0xe4c57272, 0x72ec3939, 0x98164c4c, - 0xbc945e5e, 0xf09f7878, 0x70e53838, 0x05988c8c, - 0xbf17d1d1, 0x57e4a5a5, 0xd9a1e2e2, 0xc24e6161, - 0x7b42b3b3, 0x42342121, 0x25089c9c, 0x3cee1e1e, - 0x86614343, 0x93b1c7c7, 0xe54ffcfc, 0x08240404, - 0xa2e35151, 0x2f259999, 0xda226d6d, 0x1a650d0d, - 0xe979fafa, 0xa369dfdf, 0xfca97e7e, 0x48192424, - 0x76fe3b3b, 0x4b9aabab, 0x81f0cece, 0x22991111, - 0x03838f8f, 0x9c044e4e, 0x7366b7b7, 0xcbe0ebeb, - 0x78c13c3c, 0x1ffd8181, 0x35409494, 0xf31cf7f7, - 0x6f18b9b9, 0x268b1313, 0x58512c2c, 0xbb05d3d3, - 0xd38ce7e7, 0xdc396e6e, 0x95aac4c4, 0x061b0303, - 0xacdc5656, 0x885e4444, 0xfea07f7f, 0x4f88a9a9, - 0x54672a2a, 0x6b0abbbb, 0x9f87c1c1, 0xa6f15353, - 0xa572dcdc, 0x16530b0b, 0x27019d9d, 0xd82b6c6c, - 0x62a43131, 0xe8f37474, 0xf115f6f6, 0x8c4c4646, - 0x45a5acac, 0x0fb58989, 0x28b41414, 0xdfbae1e1, - 0x2ca61616, 0x74f73a3a, 0xd2066969, 0x12410909, - 0xe0d77070, 0x716fb6b6, 0xbd1ed0d0, 0xc7d6eded, - 0x85e2cccc, 0x84684242, 0x2d2c9898, 0x55eda4a4, - 0x50752828, 0xb8865c5c, 0xed6bf8f8, 0x11c28686, - }, - { - 0x7830d818, 0xaf462623, 0xf991b8c6, 0x6fcdfbe8, - 0xa113cb87, 0x626d11b8, 0x05020901, 0x6e9e0d4f, - 0xee6c9b36, 0x0451ffa6, 0xbdb90cd2, 0x06f70ef5, - 0x80f29679, 0xcede306f, 0xef3f6d91, 0x07a4f852, - 0xfdc04760, 0x766535bc, 0xcd2b379b, 0x8c018a8e, - 0x155bd2a3, 0x3c186c0c, 0x8af6847b, 0xe16a8035, - 0x693af51d, 0x47ddb3e0, 0xacb321d7, 0xed999cc2, - 0x965c432e, 0x7a96294b, 0x21e15dfe, 0x16aed557, - 0x412abd15, 0xb6eee877, 0xeb6e9237, 0x56d79ee5, - 0xd923139f, 0x17fd23f0, 0x7f94204a, 0x95a944da, - 0x25b0a258, 0xca8fcfc9, 0x8d527c29, 0x22145a0a, - 0x4f7f50b1, 0x1a5dc9a0, 0xdad6146b, 0xab17d985, - 0x73673cbd, 0x34ba8f5d, 0x50209010, 0x03f507f4, - 0xc08bddcb, 0xc67cd33e, 0x110a2d05, 0xe6ce7867, - 0x53d597e4, 0xbb4e0227, 0x58827341, 0x9d0ba78b, - 0x0153f6a7, 0x94fab27d, 0xfb374995, 0x9fad56d8, - 0x30eb70fb, 0x71c1cdee, 0x91f8bb7c, 0xe3cc7166, - 0x8ea77bdd, 0x4b2eaf17, 0x468e4547, 0xdc211a9e, - 0xc589d4ca, 0x995a582d, 0x79632ebf, 0x1b0e3f07, - 0x2347acad, 0x2fb4b05a, 0xb51bef83, 0xff66b633, - 0xf2c65c63, 0x0a041202, 0x384993aa, 0xa8e2de71, - 0xcf8dc6c8, 0x7d32d119, 0x70923b49, 0x9aaf5fd9, - 0x1df931f2, 0x48dba8e3, 0x2ab6b95b, 0x920dbc88, - 0xc8293e9a, 0xbe4c0b26, 0xfa64bf32, 0x4a7d59b0, - 0x6acff2e9, 0x331e770f, 0xa6b733d5, 0xba1df480, - 0x7c6127be, 0xde87ebcd, 0xe4688934, 0x75903248, - 0x24e354ff, 0x8ff48d7a, 0xea3d6490, 0x3ebe9d5f, - 0xa0403d20, 0xd5d00f68, 0x7234ca1a, 0x2c41b7ae, - 0x5e757db4, 0x19a8ce54, 0xe53b7f93, 0xaa442f22, - 0xe9c86364, 0x12ff2af1, 0xa2e6cc73, 0x5a248212, - 0x5d807a40, 0x28104808, 0xe89b95c3, 0x7bc5dfec, - 0x90ab4ddb, 0x1f5fc0a1, 0x8307918d, 0xc97ac83d, - 0xf1335b97, 0x00000000, 0xd483f9cf, 0x87566e2b, - 0xb3ece176, 0xb019e682, 0xa9b128d6, 0x7736c31b, - 0x5b7774b5, 0x2943beaf, 0xdfd41d6a, 0x0da0ea50, - 0x4c8a5745, 0x18fb38f3, 0xf060ad30, 0x74c3c4ef, - 0xc37eda3f, 0x1caac755, 0x1059dba2, 0x65c9e9ea, - 0xecca6a65, 0x686903ba, 0x935e4a2f, 0xe79d8ec0, - 0x81a160de, 0x6c38fc1c, 0x2ee746fd, 0x649a1f4d, - 0xe0397692, 0xbceafa75, 0x1e0c3606, 0x9809ae8a, - 0x40794bb2, 0x59d185e6, 0x361c7e0e, 0x633ee71f, - 0xf7c45562, 0xa3b53ad4, 0x324d81a8, 0xf4315296, - 0x3aef62f9, 0xf697a3c5, 0xb14a1025, 0x20b2ab59, - 0xae15d084, 0xa7e4c572, 0xdd72ec39, 0x6198164c, - 0x3bbc945e, 0x85f09f78, 0xd870e538, 0x8605988c, - 0xb2bf17d1, 0x0b57e4a5, 0x4dd9a1e2, 0xf8c24e61, - 0x457b42b3, 0xa5423421, 0xd625089c, 0x663cee1e, - 0x52866143, 0xfc93b1c7, 0x2be54ffc, 0x14082404, - 0x08a2e351, 0xc72f2599, 0xc4da226d, 0x391a650d, - 0x35e979fa, 0x84a369df, 0x9bfca97e, 0xb4481924, - 0xd776fe3b, 0x3d4b9aab, 0xd181f0ce, 0x55229911, - 0x8903838f, 0x6b9c044e, 0x517366b7, 0x60cbe0eb, - 0xcc78c13c, 0xbf1ffd81, 0xfe354094, 0x0cf31cf7, - 0x676f18b9, 0x5f268b13, 0x9c58512c, 0xb8bb05d3, - 0x5cd38ce7, 0xcbdc396e, 0xf395aac4, 0x0f061b03, - 0x13acdc56, 0x49885e44, 0x9efea07f, 0x374f88a9, - 0x8254672a, 0x6d6b0abb, 0xe29f87c1, 0x02a6f153, - 0x8ba572dc, 0x2716530b, 0xd327019d, 0xc1d82b6c, - 0xf562a431, 0xb9e8f374, 0x09f115f6, 0x438c4c46, - 0x2645a5ac, 0x970fb589, 0x4428b414, 0x42dfbae1, - 0x4e2ca616, 0xd274f73a, 0xd0d20669, 0x2d124109, - 0xade0d770, 0x54716fb6, 0xb7bd1ed0, 0x7ec7d6ed, - 0xdb85e2cc, 0x57846842, 0xc22d2c98, 0x0e55eda4, - 0x88507528, 0x31b8865c, 0x3fed6bf8, 0xa411c286, - }, - { - 0xc07830d8, 0x05af4626, 0x7ef991b8, 0x136fcdfb, - 0x4ca113cb, 0xa9626d11, 0x08050209, 0x426e9e0d, - 0xadee6c9b, 0x590451ff, 0xdebdb90c, 0xfb06f70e, - 0xef80f296, 0x5fcede30, 0xfcef3f6d, 0xaa07a4f8, - 0x27fdc047, 0x89766535, 0xaccd2b37, 0x048c018a, - 0x71155bd2, 0x603c186c, 0xff8af684, 0xb5e16a80, - 0xe8693af5, 0x5347ddb3, 0xf6acb321, 0x5eed999c, - 0x6d965c43, 0x627a9629, 0xa321e15d, 0x8216aed5, - 0xa8412abd, 0x9fb6eee8, 0xa5eb6e92, 0x7b56d79e, - 0x8cd92313, 0xd317fd23, 0x6a7f9420, 0x9e95a944, - 0xfa25b0a2, 0x06ca8fcf, 0x558d527c, 0x5022145a, - 0xe14f7f50, 0x691a5dc9, 0x7fdad614, 0x5cab17d9, - 0x8173673c, 0xd234ba8f, 0x80502090, 0xf303f507, - 0x16c08bdd, 0xedc67cd3, 0x28110a2d, 0x1fe6ce78, - 0x7353d597, 0x25bb4e02, 0x32588273, 0x2c9d0ba7, - 0x510153f6, 0xcf94fab2, 0xdcfb3749, 0x8e9fad56, - 0x8b30eb70, 0x2371c1cd, 0xc791f8bb, 0x17e3cc71, - 0xa68ea77b, 0xb84b2eaf, 0x02468e45, 0x84dc211a, - 0x1ec589d4, 0x75995a58, 0x9179632e, 0x381b0e3f, - 0x012347ac, 0xea2fb4b0, 0x6cb51bef, 0x85ff66b6, - 0x3ff2c65c, 0x100a0412, 0x39384993, 0xafa8e2de, - 0x0ecf8dc6, 0xc87d32d1, 0x7270923b, 0x869aaf5f, - 0xc31df931, 0x4b48dba8, 0xe22ab6b9, 0x34920dbc, - 0xa4c8293e, 0x2dbe4c0b, 0x8dfa64bf, 0xe94a7d59, - 0x1b6acff2, 0x78331e77, 0xe6a6b733, 0x74ba1df4, - 0x997c6127, 0x26de87eb, 0xbde46889, 0x7a759032, - 0xab24e354, 0xf78ff48d, 0xf4ea3d64, 0xc23ebe9d, - 0x1da0403d, 0x67d5d00f, 0xd07234ca, 0x192c41b7, - 0xc95e757d, 0x9a19a8ce, 0xece53b7f, 0x0daa442f, - 0x07e9c863, 0xdb12ff2a, 0xbfa2e6cc, 0x905a2482, - 0x3a5d807a, 0x40281048, 0x56e89b95, 0x337bc5df, - 0x9690ab4d, 0x611f5fc0, 0x1c830791, 0xf5c97ac8, - 0xccf1335b, 0x00000000, 0x36d483f9, 0x4587566e, - 0x97b3ece1, 0x64b019e6, 0xfea9b128, 0xd87736c3, - 0xc15b7774, 0x112943be, 0x77dfd41d, 0xba0da0ea, - 0x124c8a57, 0xcb18fb38, 0x9df060ad, 0x2b74c3c4, - 0xe5c37eda, 0x921caac7, 0x791059db, 0x0365c9e9, - 0x0fecca6a, 0xb9686903, 0x65935e4a, 0x4ee79d8e, - 0xbe81a160, 0xe06c38fc, 0xbb2ee746, 0x52649a1f, - 0xe4e03976, 0x8fbceafa, 0x301e0c36, 0x249809ae, - 0xf940794b, 0x6359d185, 0x70361c7e, 0xf8633ee7, - 0x37f7c455, 0xeea3b53a, 0x29324d81, 0xc4f43152, - 0x9b3aef62, 0x66f697a3, 0x35b14a10, 0xf220b2ab, - 0x54ae15d0, 0xb7a7e4c5, 0xd5dd72ec, 0x5a619816, - 0xca3bbc94, 0xe785f09f, 0xddd870e5, 0x14860598, - 0xc6b2bf17, 0x410b57e4, 0x434dd9a1, 0x2ff8c24e, - 0xf1457b42, 0x15a54234, 0x94d62508, 0xf0663cee, - 0x22528661, 0x76fc93b1, 0xb32be54f, 0x20140824, - 0xb208a2e3, 0xbcc72f25, 0x4fc4da22, 0x68391a65, - 0x8335e979, 0xb684a369, 0xd79bfca9, 0x3db44819, - 0xc5d776fe, 0x313d4b9a, 0x3ed181f0, 0x88552299, - 0x0c890383, 0x4a6b9c04, 0xd1517366, 0x0b60cbe0, - 0xfdcc78c1, 0x7cbf1ffd, 0xd4fe3540, 0xeb0cf31c, - 0xa1676f18, 0x985f268b, 0x7d9c5851, 0xd6b8bb05, - 0x6b5cd38c, 0x57cbdc39, 0x6ef395aa, 0x180f061b, - 0x8a13acdc, 0x1a49885e, 0xdf9efea0, 0x21374f88, - 0x4d825467, 0xb16d6b0a, 0x46e29f87, 0xa202a6f1, - 0xae8ba572, 0x58271653, 0x9cd32701, 0x47c1d82b, - 0x95f562a4, 0x87b9e8f3, 0xe309f115, 0x0a438c4c, - 0x092645a5, 0x3c970fb5, 0xa04428b4, 0x5b42dfba, - 0xb04e2ca6, 0xcdd274f7, 0x6fd0d206, 0x482d1241, - 0xa7ade0d7, 0xd954716f, 0xceb7bd1e, 0x3b7ec7d6, - 0x2edb85e2, 0x2a578468, 0xb4c22d2c, 0x490e55ed, - 0x5d885075, 0xda31b886, 0x933fed6b, 0x44a411c2, - }, - { - 0x18c07830, 0x2305af46, 0xc67ef991, 0xe8136fcd, - 0x874ca113, 0xb8a9626d, 0x01080502, 0x4f426e9e, - 0x36adee6c, 0xa6590451, 0xd2debdb9, 0xf5fb06f7, - 0x79ef80f2, 0x6f5fcede, 0x91fcef3f, 0x52aa07a4, - 0x6027fdc0, 0xbc897665, 0x9baccd2b, 0x8e048c01, - 0xa371155b, 0x0c603c18, 0x7bff8af6, 0x35b5e16a, - 0x1de8693a, 0xe05347dd, 0xd7f6acb3, 0xc25eed99, - 0x2e6d965c, 0x4b627a96, 0xfea321e1, 0x578216ae, - 0x15a8412a, 0x779fb6ee, 0x37a5eb6e, 0xe57b56d7, - 0x9f8cd923, 0xf0d317fd, 0x4a6a7f94, 0xda9e95a9, - 0x58fa25b0, 0xc906ca8f, 0x29558d52, 0x0a502214, - 0xb1e14f7f, 0xa0691a5d, 0x6b7fdad6, 0x855cab17, - 0xbd817367, 0x5dd234ba, 0x10805020, 0xf4f303f5, - 0xcb16c08b, 0x3eedc67c, 0x0528110a, 0x671fe6ce, - 0xe47353d5, 0x2725bb4e, 0x41325882, 0x8b2c9d0b, - 0xa7510153, 0x7dcf94fa, 0x95dcfb37, 0xd88e9fad, - 0xfb8b30eb, 0xee2371c1, 0x7cc791f8, 0x6617e3cc, - 0xdda68ea7, 0x17b84b2e, 0x4702468e, 0x9e84dc21, - 0xca1ec589, 0x2d75995a, 0xbf917963, 0x07381b0e, - 0xad012347, 0x5aea2fb4, 0x836cb51b, 0x3385ff66, - 0x633ff2c6, 0x02100a04, 0xaa393849, 0x71afa8e2, - 0xc80ecf8d, 0x19c87d32, 0x49727092, 0xd9869aaf, - 0xf2c31df9, 0xe34b48db, 0x5be22ab6, 0x8834920d, - 0x9aa4c829, 0x262dbe4c, 0x328dfa64, 0xb0e94a7d, - 0xe91b6acf, 0x0f78331e, 0xd5e6a6b7, 0x8074ba1d, - 0xbe997c61, 0xcd26de87, 0x34bde468, 0x487a7590, - 0xffab24e3, 0x7af78ff4, 0x90f4ea3d, 0x5fc23ebe, - 0x201da040, 0x6867d5d0, 0x1ad07234, 0xae192c41, - 0xb4c95e75, 0x549a19a8, 0x93ece53b, 0x220daa44, - 0x6407e9c8, 0xf1db12ff, 0x73bfa2e6, 0x12905a24, - 0x403a5d80, 0x08402810, 0xc356e89b, 0xec337bc5, - 0xdb9690ab, 0xa1611f5f, 0x8d1c8307, 0x3df5c97a, - 0x97ccf133, 0x00000000, 0xcf36d483, 0x2b458756, - 0x7697b3ec, 0x8264b019, 0xd6fea9b1, 0x1bd87736, - 0xb5c15b77, 0xaf112943, 0x6a77dfd4, 0x50ba0da0, - 0x45124c8a, 0xf3cb18fb, 0x309df060, 0xef2b74c3, - 0x3fe5c37e, 0x55921caa, 0xa2791059, 0xea0365c9, - 0x650fecca, 0xbab96869, 0x2f65935e, 0xc04ee79d, - 0xdebe81a1, 0x1ce06c38, 0xfdbb2ee7, 0x4d52649a, - 0x92e4e039, 0x758fbcea, 0x06301e0c, 0x8a249809, - 0xb2f94079, 0xe66359d1, 0x0e70361c, 0x1ff8633e, - 0x6237f7c4, 0xd4eea3b5, 0xa829324d, 0x96c4f431, - 0xf99b3aef, 0xc566f697, 0x2535b14a, 0x59f220b2, - 0x8454ae15, 0x72b7a7e4, 0x39d5dd72, 0x4c5a6198, - 0x5eca3bbc, 0x78e785f0, 0x38ddd870, 0x8c148605, - 0xd1c6b2bf, 0xa5410b57, 0xe2434dd9, 0x612ff8c2, - 0xb3f1457b, 0x2115a542, 0x9c94d625, 0x1ef0663c, - 0x43225286, 0xc776fc93, 0xfcb32be5, 0x04201408, - 0x51b208a2, 0x99bcc72f, 0x6d4fc4da, 0x0d68391a, - 0xfa8335e9, 0xdfb684a3, 0x7ed79bfc, 0x243db448, - 0x3bc5d776, 0xab313d4b, 0xce3ed181, 0x11885522, - 0x8f0c8903, 0x4e4a6b9c, 0xb7d15173, 0xeb0b60cb, - 0x3cfdcc78, 0x817cbf1f, 0x94d4fe35, 0xf7eb0cf3, - 0xb9a1676f, 0x13985f26, 0x2c7d9c58, 0xd3d6b8bb, - 0xe76b5cd3, 0x6e57cbdc, 0xc46ef395, 0x03180f06, - 0x568a13ac, 0x441a4988, 0x7fdf9efe, 0xa921374f, - 0x2a4d8254, 0xbbb16d6b, 0xc146e29f, 0x53a202a6, - 0xdcae8ba5, 0x0b582716, 0x9d9cd327, 0x6c47c1d8, - 0x3195f562, 0x7487b9e8, 0xf6e309f1, 0x460a438c, - 0xac092645, 0x893c970f, 0x14a04428, 0xe15b42df, - 0x16b04e2c, 0x3acdd274, 0x696fd0d2, 0x09482d12, - 0x70a7ade0, 0xb6d95471, 0xd0ceb7bd, 0xed3b7ec7, - 0xcc2edb85, 0x422a5784, 0x98b4c22d, 0xa4490e55, - 0x285d8850, 0x5cda31b8, 0xf8933fed, 0x8644a411, - }, - { - 0x6018c078, 0x8c2305af, 0x3fc67ef9, 0x87e8136f, - 0x26874ca1, 0xdab8a962, 0x04010805, 0x214f426e, - 0xd836adee, 0xa2a65904, 0x6fd2debd, 0xf3f5fb06, - 0xf979ef80, 0xa16f5fce, 0x7e91fcef, 0x5552aa07, - 0x9d6027fd, 0xcabc8976, 0x569baccd, 0x028e048c, - 0xb6a37115, 0x300c603c, 0xf17bff8a, 0xd435b5e1, - 0x741de869, 0xa7e05347, 0x7bd7f6ac, 0x2fc25eed, - 0xb82e6d96, 0x314b627a, 0xdffea321, 0x41578216, - 0x5415a841, 0xc1779fb6, 0xdc37a5eb, 0xb3e57b56, - 0x469f8cd9, 0xe7f0d317, 0x354a6a7f, 0x4fda9e95, - 0x7d58fa25, 0x03c906ca, 0xa429558d, 0x280a5022, - 0xfeb1e14f, 0xbaa0691a, 0xb16b7fda, 0x2e855cab, - 0xcebd8173, 0x695dd234, 0x40108050, 0xf7f4f303, - 0x0bcb16c0, 0xf83eedc6, 0x14052811, 0x81671fe6, - 0xb7e47353, 0x9c2725bb, 0x19413258, 0x168b2c9d, - 0xa6a75101, 0xe97dcf94, 0x6e95dcfb, 0x47d88e9f, - 0xcbfb8b30, 0x9fee2371, 0xed7cc791, 0x856617e3, - 0x53dda68e, 0x5c17b84b, 0x01470246, 0x429e84dc, - 0x0fca1ec5, 0xb42d7599, 0xc6bf9179, 0x1c07381b, - 0x8ead0123, 0x755aea2f, 0x36836cb5, 0xcc3385ff, - 0x91633ff2, 0x0802100a, 0x92aa3938, 0xd971afa8, - 0x07c80ecf, 0x6419c87d, 0x39497270, 0x43d9869a, - 0xeff2c31d, 0xabe34b48, 0x715be22a, 0x1a883492, - 0x529aa4c8, 0x98262dbe, 0xc8328dfa, 0xfab0e94a, - 0x83e91b6a, 0x3c0f7833, 0x73d5e6a6, 0x3a8074ba, - 0xc2be997c, 0x13cd26de, 0xd034bde4, 0x3d487a75, - 0xdbffab24, 0xf57af78f, 0x7a90f4ea, 0x615fc23e, - 0x80201da0, 0xbd6867d5, 0x681ad072, 0x82ae192c, - 0xeab4c95e, 0x4d549a19, 0x7693ece5, 0x88220daa, - 0x8d6407e9, 0xe3f1db12, 0xd173bfa2, 0x4812905a, - 0x1d403a5d, 0x20084028, 0x2bc356e8, 0x97ec337b, - 0x4bdb9690, 0xbea1611f, 0x0e8d1c83, 0xf43df5c9, - 0x6697ccf1, 0x00000000, 0x1bcf36d4, 0xac2b4587, - 0xc57697b3, 0x328264b0, 0x7fd6fea9, 0x6c1bd877, - 0xeeb5c15b, 0x86af1129, 0xb56a77df, 0x5d50ba0d, - 0x0945124c, 0xebf3cb18, 0xc0309df0, 0x9bef2b74, - 0xfc3fe5c3, 0x4955921c, 0xb2a27910, 0x8fea0365, - 0x89650fec, 0xd2bab968, 0xbc2f6593, 0x27c04ee7, - 0x5fdebe81, 0x701ce06c, 0xd3fdbb2e, 0x294d5264, - 0x7292e4e0, 0xc9758fbc, 0x1806301e, 0x128a2498, - 0xf2b2f940, 0xbfe66359, 0x380e7036, 0x7c1ff863, - 0x956237f7, 0x77d4eea3, 0x9aa82932, 0x6296c4f4, - 0xc3f99b3a, 0x33c566f6, 0x942535b1, 0x7959f220, - 0x2a8454ae, 0xd572b7a7, 0xe439d5dd, 0x2d4c5a61, - 0x655eca3b, 0xfd78e785, 0xe038ddd8, 0x0a8c1486, - 0x63d1c6b2, 0xaea5410b, 0xafe2434d, 0x99612ff8, - 0xf6b3f145, 0x842115a5, 0x4a9c94d6, 0x781ef066, - 0x11432252, 0x3bc776fc, 0xd7fcb32b, 0x10042014, - 0x5951b208, 0x5e99bcc7, 0xa96d4fc4, 0x340d6839, - 0xcffa8335, 0x5bdfb684, 0xe57ed79b, 0x90243db4, - 0xec3bc5d7, 0x96ab313d, 0x1fce3ed1, 0x44118855, - 0x068f0c89, 0x254e4a6b, 0xe6b7d151, 0x8beb0b60, - 0xf03cfdcc, 0x3e817cbf, 0x6a94d4fe, 0xfbf7eb0c, - 0xdeb9a167, 0x4c13985f, 0xb02c7d9c, 0x6bd3d6b8, - 0xbbe76b5c, 0xa56e57cb, 0x37c46ef3, 0x0c03180f, - 0x45568a13, 0x0d441a49, 0xe17fdf9e, 0x9ea92137, - 0xa82a4d82, 0xd6bbb16d, 0x23c146e2, 0x5153a202, - 0x57dcae8b, 0x2c0b5827, 0x4e9d9cd3, 0xad6c47c1, - 0xc43195f5, 0xcd7487b9, 0xfff6e309, 0x05460a43, - 0x8aac0926, 0x1e893c97, 0x5014a044, 0xa3e15b42, - 0x5816b04e, 0xe83acdd2, 0xb9696fd0, 0x2409482d, - 0xdd70a7ad, 0xe2b6d954, 0x67d0ceb7, 0x93ed3b7e, - 0x17cc2edb, 0x15422a57, 0x5a98b4c2, 0xaaa4490e, - 0xa0285d88, 0x6d5cda31, 0xc7f8933f, 0x228644a4, - }, - { - 0x186018c0, 0x238c2305, 0xc63fc67e, 0xe887e813, - 0x8726874c, 0xb8dab8a9, 0x01040108, 0x4f214f42, - 0x36d836ad, 0xa6a2a659, 0xd26fd2de, 0xf5f3f5fb, - 0x79f979ef, 0x6fa16f5f, 0x917e91fc, 0x525552aa, - 0x609d6027, 0xbccabc89, 0x9b569bac, 0x8e028e04, - 0xa3b6a371, 0x0c300c60, 0x7bf17bff, 0x35d435b5, - 0x1d741de8, 0xe0a7e053, 0xd77bd7f6, 0xc22fc25e, - 0x2eb82e6d, 0x4b314b62, 0xfedffea3, 0x57415782, - 0x155415a8, 0x77c1779f, 0x37dc37a5, 0xe5b3e57b, - 0x9f469f8c, 0xf0e7f0d3, 0x4a354a6a, 0xda4fda9e, - 0x587d58fa, 0xc903c906, 0x29a42955, 0x0a280a50, - 0xb1feb1e1, 0xa0baa069, 0x6bb16b7f, 0x852e855c, - 0xbdcebd81, 0x5d695dd2, 0x10401080, 0xf4f7f4f3, - 0xcb0bcb16, 0x3ef83eed, 0x05140528, 0x6781671f, - 0xe4b7e473, 0x279c2725, 0x41194132, 0x8b168b2c, - 0xa7a6a751, 0x7de97dcf, 0x956e95dc, 0xd847d88e, - 0xfbcbfb8b, 0xee9fee23, 0x7ced7cc7, 0x66856617, - 0xdd53dda6, 0x175c17b8, 0x47014702, 0x9e429e84, - 0xca0fca1e, 0x2db42d75, 0xbfc6bf91, 0x071c0738, - 0xad8ead01, 0x5a755aea, 0x8336836c, 0x33cc3385, - 0x6391633f, 0x02080210, 0xaa92aa39, 0x71d971af, - 0xc807c80e, 0x196419c8, 0x49394972, 0xd943d986, - 0xf2eff2c3, 0xe3abe34b, 0x5b715be2, 0x881a8834, - 0x9a529aa4, 0x2698262d, 0x32c8328d, 0xb0fab0e9, - 0xe983e91b, 0x0f3c0f78, 0xd573d5e6, 0x803a8074, - 0xbec2be99, 0xcd13cd26, 0x34d034bd, 0x483d487a, - 0xffdbffab, 0x7af57af7, 0x907a90f4, 0x5f615fc2, - 0x2080201d, 0x68bd6867, 0x1a681ad0, 0xae82ae19, - 0xb4eab4c9, 0x544d549a, 0x937693ec, 0x2288220d, - 0x648d6407, 0xf1e3f1db, 0x73d173bf, 0x12481290, - 0x401d403a, 0x08200840, 0xc32bc356, 0xec97ec33, - 0xdb4bdb96, 0xa1bea161, 0x8d0e8d1c, 0x3df43df5, - 0x976697cc, 0x00000000, 0xcf1bcf36, 0x2bac2b45, - 0x76c57697, 0x82328264, 0xd67fd6fe, 0x1b6c1bd8, - 0xb5eeb5c1, 0xaf86af11, 0x6ab56a77, 0x505d50ba, - 0x45094512, 0xf3ebf3cb, 0x30c0309d, 0xef9bef2b, - 0x3ffc3fe5, 0x55495592, 0xa2b2a279, 0xea8fea03, - 0x6589650f, 0xbad2bab9, 0x2fbc2f65, 0xc027c04e, - 0xde5fdebe, 0x1c701ce0, 0xfdd3fdbb, 0x4d294d52, - 0x927292e4, 0x75c9758f, 0x06180630, 0x8a128a24, - 0xb2f2b2f9, 0xe6bfe663, 0x0e380e70, 0x1f7c1ff8, - 0x62956237, 0xd477d4ee, 0xa89aa829, 0x966296c4, - 0xf9c3f99b, 0xc533c566, 0x25942535, 0x597959f2, - 0x842a8454, 0x72d572b7, 0x39e439d5, 0x4c2d4c5a, - 0x5e655eca, 0x78fd78e7, 0x38e038dd, 0x8c0a8c14, - 0xd163d1c6, 0xa5aea541, 0xe2afe243, 0x6199612f, - 0xb3f6b3f1, 0x21842115, 0x9c4a9c94, 0x1e781ef0, - 0x43114322, 0xc73bc776, 0xfcd7fcb3, 0x04100420, - 0x515951b2, 0x995e99bc, 0x6da96d4f, 0x0d340d68, - 0xfacffa83, 0xdf5bdfb6, 0x7ee57ed7, 0x2490243d, - 0x3bec3bc5, 0xab96ab31, 0xce1fce3e, 0x11441188, - 0x8f068f0c, 0x4e254e4a, 0xb7e6b7d1, 0xeb8beb0b, - 0x3cf03cfd, 0x813e817c, 0x946a94d4, 0xf7fbf7eb, - 0xb9deb9a1, 0x134c1398, 0x2cb02c7d, 0xd36bd3d6, - 0xe7bbe76b, 0x6ea56e57, 0xc437c46e, 0x030c0318, - 0x5645568a, 0x440d441a, 0x7fe17fdf, 0xa99ea921, - 0x2aa82a4d, 0xbbd6bbb1, 0xc123c146, 0x535153a2, - 0xdc57dcae, 0x0b2c0b58, 0x9d4e9d9c, 0x6cad6c47, - 0x31c43195, 0x74cd7487, 0xf6fff6e3, 0x4605460a, - 0xac8aac09, 0x891e893c, 0x145014a0, 0xe1a3e15b, - 0x165816b0, 0x3ae83acd, 0x69b9696f, 0x09240948, - 0x70dd70a7, 0xb6e2b6d9, 0xd067d0ce, 0xed93ed3b, - 0xcc17cc2e, 0x4215422a, 0x985a98b4, 0xa4aaa449, - 0x28a0285d, 0x5c6d5cda, 0xf8c7f893, 0x86228644, - } + 0x18186018c07830d8, 0x23238c2305af4626, 0xc6c63fc67ef991b8, 0xe8e887e8136fcdfb, + 0x878726874ca113cb, 0xb8b8dab8a9626d11, 0x0101040108050209, 0x4f4f214f426e9e0d, + 0x3636d836adee6c9b, 0xa6a6a2a6590451ff, 0xd2d26fd2debdb90c, 0xf5f5f3f5fb06f70e, + 0x7979f979ef80f296, 0x6f6fa16f5fcede30, 0x91917e91fcef3f6d, 0x52525552aa07a4f8, + 0x60609d6027fdc047, 0xbcbccabc89766535, 0x9b9b569baccd2b37, 0x8e8e028e048c018a, + 0xa3a3b6a371155bd2, 0x0c0c300c603c186c, 0x7b7bf17bff8af684, 0x3535d435b5e16a80, + 0x1d1d741de8693af5, 0xe0e0a7e05347ddb3, 0xd7d77bd7f6acb321, 0xc2c22fc25eed999c, + 0x2e2eb82e6d965c43, 0x4b4b314b627a9629, 0xfefedffea321e15d, 0x575741578216aed5, + 0x15155415a8412abd, 0x7777c1779fb6eee8, 0x3737dc37a5eb6e92, 0xe5e5b3e57b56d79e, + 0x9f9f469f8cd92313, 0xf0f0e7f0d317fd23, 0x4a4a354a6a7f9420, 0xdada4fda9e95a944, + 0x58587d58fa25b0a2, 0xc9c903c906ca8fcf, 0x2929a429558d527c, 0x0a0a280a5022145a, + 0xb1b1feb1e14f7f50, 0xa0a0baa0691a5dc9, 0x6b6bb16b7fdad614, 0x85852e855cab17d9, + 0xbdbdcebd8173673c, 0x5d5d695dd234ba8f, 0x1010401080502090, 0xf4f4f7f4f303f507, + 0xcbcb0bcb16c08bdd, 0x3e3ef83eedc67cd3, 0x0505140528110a2d, 0x676781671fe6ce78, + 0xe4e4b7e47353d597, 0x27279c2725bb4e02, 0x4141194132588273, 0x8b8b168b2c9d0ba7, + 0xa7a7a6a7510153f6, 0x7d7de97dcf94fab2, 0x95956e95dcfb3749, 0xd8d847d88e9fad56, + 0xfbfbcbfb8b30eb70, 0xeeee9fee2371c1cd, 0x7c7ced7cc791f8bb, 0x6666856617e3cc71, + 0xdddd53dda68ea77b, 0x17175c17b84b2eaf, 0x4747014702468e45, 0x9e9e429e84dc211a, + 0xcaca0fca1ec589d4, 0x2d2db42d75995a58, 0xbfbfc6bf9179632e, 0x07071c07381b0e3f, + 0xadad8ead012347ac, 0x5a5a755aea2fb4b0, 0x838336836cb51bef, 0x3333cc3385ff66b6, + 0x636391633ff2c65c, 0x02020802100a0412, 0xaaaa92aa39384993, 0x7171d971afa8e2de, + 0xc8c807c80ecf8dc6, 0x19196419c87d32d1, 0x494939497270923b, 0xd9d943d9869aaf5f, + 0xf2f2eff2c31df931, 0xe3e3abe34b48dba8, 0x5b5b715be22ab6b9, 0x88881a8834920dbc, + 0x9a9a529aa4c8293e, 0x262698262dbe4c0b, 0x3232c8328dfa64bf, 0xb0b0fab0e94a7d59, + 0xe9e983e91b6acff2, 0x0f0f3c0f78331e77, 0xd5d573d5e6a6b733, 0x80803a8074ba1df4, + 0xbebec2be997c6127, 0xcdcd13cd26de87eb, 0x3434d034bde46889, 0x48483d487a759032, + 0xffffdbffab24e354, 0x7a7af57af78ff48d, 0x90907a90f4ea3d64, 0x5f5f615fc23ebe9d, + 0x202080201da0403d, 0x6868bd6867d5d00f, 0x1a1a681ad07234ca, 0xaeae82ae192c41b7, + 0xb4b4eab4c95e757d, 0x54544d549a19a8ce, 0x93937693ece53b7f, 0x222288220daa442f, + 0x64648d6407e9c863, 0xf1f1e3f1db12ff2a, 0x7373d173bfa2e6cc, 0x12124812905a2482, + 0x40401d403a5d807a, 0x0808200840281048, 0xc3c32bc356e89b95, 0xecec97ec337bc5df, + 0xdbdb4bdb9690ab4d, 0xa1a1bea1611f5fc0, 0x8d8d0e8d1c830791, 0x3d3df43df5c97ac8, + 0x97976697ccf1335b, 0x0000000000000000, 0xcfcf1bcf36d483f9, 0x2b2bac2b4587566e, + 0x7676c57697b3ece1, 0x8282328264b019e6, 0xd6d67fd6fea9b128, 0x1b1b6c1bd87736c3, + 0xb5b5eeb5c15b7774, 0xafaf86af112943be, 0x6a6ab56a77dfd41d, 0x50505d50ba0da0ea, + 0x45450945124c8a57, 0xf3f3ebf3cb18fb38, 0x3030c0309df060ad, 0xefef9bef2b74c3c4, + 0x3f3ffc3fe5c37eda, 0x55554955921caac7, 0xa2a2b2a2791059db, 0xeaea8fea0365c9e9, + 0x656589650fecca6a, 0xbabad2bab9686903, 0x2f2fbc2f65935e4a, 0xc0c027c04ee79d8e, + 0xdede5fdebe81a160, 0x1c1c701ce06c38fc, 0xfdfdd3fdbb2ee746, 0x4d4d294d52649a1f, + 0x92927292e4e03976, 0x7575c9758fbceafa, 0x06061806301e0c36, 0x8a8a128a249809ae, + 0xb2b2f2b2f940794b, 0xe6e6bfe66359d185, 0x0e0e380e70361c7e, 0x1f1f7c1ff8633ee7, + 0x6262956237f7c455, 0xd4d477d4eea3b53a, 0xa8a89aa829324d81, 0x96966296c4f43152, + 0xf9f9c3f99b3aef62, 0xc5c533c566f697a3, 0x2525942535b14a10, 0x59597959f220b2ab, + 0x84842a8454ae15d0, 0x7272d572b7a7e4c5, 0x3939e439d5dd72ec, 0x4c4c2d4c5a619816, + 0x5e5e655eca3bbc94, 0x7878fd78e785f09f, 0x3838e038ddd870e5, 0x8c8c0a8c14860598, + 0xd1d163d1c6b2bf17, 0xa5a5aea5410b57e4, 0xe2e2afe2434dd9a1, 0x616199612ff8c24e, + 0xb3b3f6b3f1457b42, 0x2121842115a54234, 0x9c9c4a9c94d62508, 0x1e1e781ef0663cee, + 0x4343114322528661, 0xc7c73bc776fc93b1, 0xfcfcd7fcb32be54f, 0x0404100420140824, + 0x51515951b208a2e3, 0x99995e99bcc72f25, 0x6d6da96d4fc4da22, 0x0d0d340d68391a65, + 0xfafacffa8335e979, 0xdfdf5bdfb684a369, 0x7e7ee57ed79bfca9, 0x242490243db44819, + 0x3b3bec3bc5d776fe, 0xabab96ab313d4b9a, 0xcece1fce3ed181f0, 0x1111441188552299, + 0x8f8f068f0c890383, 0x4e4e254e4a6b9c04, 0xb7b7e6b7d1517366, 0xebeb8beb0b60cbe0, + 0x3c3cf03cfdcc78c1, 0x81813e817cbf1ffd, 0x94946a94d4fe3540, 0xf7f7fbf7eb0cf31c, + 0xb9b9deb9a1676f18, 0x13134c13985f268b, 0x2c2cb02c7d9c5851, 0xd3d36bd3d6b8bb05, + 0xe7e7bbe76b5cd38c, 0x6e6ea56e57cbdc39, 0xc4c437c46ef395aa, 0x03030c03180f061b, + 0x565645568a13acdc, 0x44440d441a49885e, 0x7f7fe17fdf9efea0, 0xa9a99ea921374f88, + 0x2a2aa82a4d825467, 0xbbbbd6bbb16d6b0a, 0xc1c123c146e29f87, 0x53535153a202a6f1, + 0xdcdc57dcae8ba572, 0x0b0b2c0b58271653, 0x9d9d4e9d9cd32701, 0x6c6cad6c47c1d82b, + 0x3131c43195f562a4, 0x7474cd7487b9e8f3, 0xf6f6fff6e309f115, 0x464605460a438c4c, + 0xacac8aac092645a5, 0x89891e893c970fb5, 0x14145014a04428b4, 0xe1e1a3e15b42dfba, + 0x16165816b04e2ca6, 0x3a3ae83acdd274f7, 0x6969b9696fd0d206, 0x09092409482d1241, + 0x7070dd70a7ade0d7, 0xb6b6e2b6d954716f, 0xd0d067d0ceb7bd1e, 0xeded93ed3b7ec7d6, + 0xcccc17cc2edb85e2, 0x424215422a578468, 0x98985a98b4c22d2c, 0xa4a4aaa4490e55ed, + 0x2828a0285d885075, 0x5c5c6d5cda31b886, 0xf8f8c7f8933fed6b, 0x8686228644a411c2, }; -CONSTANT_VK u32a Cl[8][256] = +CONSTANT_VK u64a MT1[256] = { - { - 0xc07830d8, 0x05af4626, 0x7ef991b8, 0x136fcdfb, - 0x4ca113cb, 0xa9626d11, 0x08050209, 0x426e9e0d, - 0xadee6c9b, 0x590451ff, 0xdebdb90c, 0xfb06f70e, - 0xef80f296, 0x5fcede30, 0xfcef3f6d, 0xaa07a4f8, - 0x27fdc047, 0x89766535, 0xaccd2b37, 0x048c018a, - 0x71155bd2, 0x603c186c, 0xff8af684, 0xb5e16a80, - 0xe8693af5, 0x5347ddb3, 0xf6acb321, 0x5eed999c, - 0x6d965c43, 0x627a9629, 0xa321e15d, 0x8216aed5, - 0xa8412abd, 0x9fb6eee8, 0xa5eb6e92, 0x7b56d79e, - 0x8cd92313, 0xd317fd23, 0x6a7f9420, 0x9e95a944, - 0xfa25b0a2, 0x06ca8fcf, 0x558d527c, 0x5022145a, - 0xe14f7f50, 0x691a5dc9, 0x7fdad614, 0x5cab17d9, - 0x8173673c, 0xd234ba8f, 0x80502090, 0xf303f507, - 0x16c08bdd, 0xedc67cd3, 0x28110a2d, 0x1fe6ce78, - 0x7353d597, 0x25bb4e02, 0x32588273, 0x2c9d0ba7, - 0x510153f6, 0xcf94fab2, 0xdcfb3749, 0x8e9fad56, - 0x8b30eb70, 0x2371c1cd, 0xc791f8bb, 0x17e3cc71, - 0xa68ea77b, 0xb84b2eaf, 0x02468e45, 0x84dc211a, - 0x1ec589d4, 0x75995a58, 0x9179632e, 0x381b0e3f, - 0x012347ac, 0xea2fb4b0, 0x6cb51bef, 0x85ff66b6, - 0x3ff2c65c, 0x100a0412, 0x39384993, 0xafa8e2de, - 0x0ecf8dc6, 0xc87d32d1, 0x7270923b, 0x869aaf5f, - 0xc31df931, 0x4b48dba8, 0xe22ab6b9, 0x34920dbc, - 0xa4c8293e, 0x2dbe4c0b, 0x8dfa64bf, 0xe94a7d59, - 0x1b6acff2, 0x78331e77, 0xe6a6b733, 0x74ba1df4, - 0x997c6127, 0x26de87eb, 0xbde46889, 0x7a759032, - 0xab24e354, 0xf78ff48d, 0xf4ea3d64, 0xc23ebe9d, - 0x1da0403d, 0x67d5d00f, 0xd07234ca, 0x192c41b7, - 0xc95e757d, 0x9a19a8ce, 0xece53b7f, 0x0daa442f, - 0x07e9c863, 0xdb12ff2a, 0xbfa2e6cc, 0x905a2482, - 0x3a5d807a, 0x40281048, 0x56e89b95, 0x337bc5df, - 0x9690ab4d, 0x611f5fc0, 0x1c830791, 0xf5c97ac8, - 0xccf1335b, 0x00000000, 0x36d483f9, 0x4587566e, - 0x97b3ece1, 0x64b019e6, 0xfea9b128, 0xd87736c3, - 0xc15b7774, 0x112943be, 0x77dfd41d, 0xba0da0ea, - 0x124c8a57, 0xcb18fb38, 0x9df060ad, 0x2b74c3c4, - 0xe5c37eda, 0x921caac7, 0x791059db, 0x0365c9e9, - 0x0fecca6a, 0xb9686903, 0x65935e4a, 0x4ee79d8e, - 0xbe81a160, 0xe06c38fc, 0xbb2ee746, 0x52649a1f, - 0xe4e03976, 0x8fbceafa, 0x301e0c36, 0x249809ae, - 0xf940794b, 0x6359d185, 0x70361c7e, 0xf8633ee7, - 0x37f7c455, 0xeea3b53a, 0x29324d81, 0xc4f43152, - 0x9b3aef62, 0x66f697a3, 0x35b14a10, 0xf220b2ab, - 0x54ae15d0, 0xb7a7e4c5, 0xd5dd72ec, 0x5a619816, - 0xca3bbc94, 0xe785f09f, 0xddd870e5, 0x14860598, - 0xc6b2bf17, 0x410b57e4, 0x434dd9a1, 0x2ff8c24e, - 0xf1457b42, 0x15a54234, 0x94d62508, 0xf0663cee, - 0x22528661, 0x76fc93b1, 0xb32be54f, 0x20140824, - 0xb208a2e3, 0xbcc72f25, 0x4fc4da22, 0x68391a65, - 0x8335e979, 0xb684a369, 0xd79bfca9, 0x3db44819, - 0xc5d776fe, 0x313d4b9a, 0x3ed181f0, 0x88552299, - 0x0c890383, 0x4a6b9c04, 0xd1517366, 0x0b60cbe0, - 0xfdcc78c1, 0x7cbf1ffd, 0xd4fe3540, 0xeb0cf31c, - 0xa1676f18, 0x985f268b, 0x7d9c5851, 0xd6b8bb05, - 0x6b5cd38c, 0x57cbdc39, 0x6ef395aa, 0x180f061b, - 0x8a13acdc, 0x1a49885e, 0xdf9efea0, 0x21374f88, - 0x4d825467, 0xb16d6b0a, 0x46e29f87, 0xa202a6f1, - 0xae8ba572, 0x58271653, 0x9cd32701, 0x47c1d82b, - 0x95f562a4, 0x87b9e8f3, 0xe309f115, 0x0a438c4c, - 0x092645a5, 0x3c970fb5, 0xa04428b4, 0x5b42dfba, - 0xb04e2ca6, 0xcdd274f7, 0x6fd0d206, 0x482d1241, - 0xa7ade0d7, 0xd954716f, 0xceb7bd1e, 0x3b7ec7d6, - 0x2edb85e2, 0x2a578468, 0xb4c22d2c, 0x490e55ed, - 0x5d885075, 0xda31b886, 0x933fed6b, 0x44a411c2, - }, - { - 0x18c07830, 0x2305af46, 0xc67ef991, 0xe8136fcd, - 0x874ca113, 0xb8a9626d, 0x01080502, 0x4f426e9e, - 0x36adee6c, 0xa6590451, 0xd2debdb9, 0xf5fb06f7, - 0x79ef80f2, 0x6f5fcede, 0x91fcef3f, 0x52aa07a4, - 0x6027fdc0, 0xbc897665, 0x9baccd2b, 0x8e048c01, - 0xa371155b, 0x0c603c18, 0x7bff8af6, 0x35b5e16a, - 0x1de8693a, 0xe05347dd, 0xd7f6acb3, 0xc25eed99, - 0x2e6d965c, 0x4b627a96, 0xfea321e1, 0x578216ae, - 0x15a8412a, 0x779fb6ee, 0x37a5eb6e, 0xe57b56d7, - 0x9f8cd923, 0xf0d317fd, 0x4a6a7f94, 0xda9e95a9, - 0x58fa25b0, 0xc906ca8f, 0x29558d52, 0x0a502214, - 0xb1e14f7f, 0xa0691a5d, 0x6b7fdad6, 0x855cab17, - 0xbd817367, 0x5dd234ba, 0x10805020, 0xf4f303f5, - 0xcb16c08b, 0x3eedc67c, 0x0528110a, 0x671fe6ce, - 0xe47353d5, 0x2725bb4e, 0x41325882, 0x8b2c9d0b, - 0xa7510153, 0x7dcf94fa, 0x95dcfb37, 0xd88e9fad, - 0xfb8b30eb, 0xee2371c1, 0x7cc791f8, 0x6617e3cc, - 0xdda68ea7, 0x17b84b2e, 0x4702468e, 0x9e84dc21, - 0xca1ec589, 0x2d75995a, 0xbf917963, 0x07381b0e, - 0xad012347, 0x5aea2fb4, 0x836cb51b, 0x3385ff66, - 0x633ff2c6, 0x02100a04, 0xaa393849, 0x71afa8e2, - 0xc80ecf8d, 0x19c87d32, 0x49727092, 0xd9869aaf, - 0xf2c31df9, 0xe34b48db, 0x5be22ab6, 0x8834920d, - 0x9aa4c829, 0x262dbe4c, 0x328dfa64, 0xb0e94a7d, - 0xe91b6acf, 0x0f78331e, 0xd5e6a6b7, 0x8074ba1d, - 0xbe997c61, 0xcd26de87, 0x34bde468, 0x487a7590, - 0xffab24e3, 0x7af78ff4, 0x90f4ea3d, 0x5fc23ebe, - 0x201da040, 0x6867d5d0, 0x1ad07234, 0xae192c41, - 0xb4c95e75, 0x549a19a8, 0x93ece53b, 0x220daa44, - 0x6407e9c8, 0xf1db12ff, 0x73bfa2e6, 0x12905a24, - 0x403a5d80, 0x08402810, 0xc356e89b, 0xec337bc5, - 0xdb9690ab, 0xa1611f5f, 0x8d1c8307, 0x3df5c97a, - 0x97ccf133, 0x00000000, 0xcf36d483, 0x2b458756, - 0x7697b3ec, 0x8264b019, 0xd6fea9b1, 0x1bd87736, - 0xb5c15b77, 0xaf112943, 0x6a77dfd4, 0x50ba0da0, - 0x45124c8a, 0xf3cb18fb, 0x309df060, 0xef2b74c3, - 0x3fe5c37e, 0x55921caa, 0xa2791059, 0xea0365c9, - 0x650fecca, 0xbab96869, 0x2f65935e, 0xc04ee79d, - 0xdebe81a1, 0x1ce06c38, 0xfdbb2ee7, 0x4d52649a, - 0x92e4e039, 0x758fbcea, 0x06301e0c, 0x8a249809, - 0xb2f94079, 0xe66359d1, 0x0e70361c, 0x1ff8633e, - 0x6237f7c4, 0xd4eea3b5, 0xa829324d, 0x96c4f431, - 0xf99b3aef, 0xc566f697, 0x2535b14a, 0x59f220b2, - 0x8454ae15, 0x72b7a7e4, 0x39d5dd72, 0x4c5a6198, - 0x5eca3bbc, 0x78e785f0, 0x38ddd870, 0x8c148605, - 0xd1c6b2bf, 0xa5410b57, 0xe2434dd9, 0x612ff8c2, - 0xb3f1457b, 0x2115a542, 0x9c94d625, 0x1ef0663c, - 0x43225286, 0xc776fc93, 0xfcb32be5, 0x04201408, - 0x51b208a2, 0x99bcc72f, 0x6d4fc4da, 0x0d68391a, - 0xfa8335e9, 0xdfb684a3, 0x7ed79bfc, 0x243db448, - 0x3bc5d776, 0xab313d4b, 0xce3ed181, 0x11885522, - 0x8f0c8903, 0x4e4a6b9c, 0xb7d15173, 0xeb0b60cb, - 0x3cfdcc78, 0x817cbf1f, 0x94d4fe35, 0xf7eb0cf3, - 0xb9a1676f, 0x13985f26, 0x2c7d9c58, 0xd3d6b8bb, - 0xe76b5cd3, 0x6e57cbdc, 0xc46ef395, 0x03180f06, - 0x568a13ac, 0x441a4988, 0x7fdf9efe, 0xa921374f, - 0x2a4d8254, 0xbbb16d6b, 0xc146e29f, 0x53a202a6, - 0xdcae8ba5, 0x0b582716, 0x9d9cd327, 0x6c47c1d8, - 0x3195f562, 0x7487b9e8, 0xf6e309f1, 0x460a438c, - 0xac092645, 0x893c970f, 0x14a04428, 0xe15b42df, - 0x16b04e2c, 0x3acdd274, 0x696fd0d2, 0x09482d12, - 0x70a7ade0, 0xb6d95471, 0xd0ceb7bd, 0xed3b7ec7, - 0xcc2edb85, 0x422a5784, 0x98b4c22d, 0xa4490e55, - 0x285d8850, 0x5cda31b8, 0xf8933fed, 0x8644a411, - }, - { - 0x6018c078, 0x8c2305af, 0x3fc67ef9, 0x87e8136f, - 0x26874ca1, 0xdab8a962, 0x04010805, 0x214f426e, - 0xd836adee, 0xa2a65904, 0x6fd2debd, 0xf3f5fb06, - 0xf979ef80, 0xa16f5fce, 0x7e91fcef, 0x5552aa07, - 0x9d6027fd, 0xcabc8976, 0x569baccd, 0x028e048c, - 0xb6a37115, 0x300c603c, 0xf17bff8a, 0xd435b5e1, - 0x741de869, 0xa7e05347, 0x7bd7f6ac, 0x2fc25eed, - 0xb82e6d96, 0x314b627a, 0xdffea321, 0x41578216, - 0x5415a841, 0xc1779fb6, 0xdc37a5eb, 0xb3e57b56, - 0x469f8cd9, 0xe7f0d317, 0x354a6a7f, 0x4fda9e95, - 0x7d58fa25, 0x03c906ca, 0xa429558d, 0x280a5022, - 0xfeb1e14f, 0xbaa0691a, 0xb16b7fda, 0x2e855cab, - 0xcebd8173, 0x695dd234, 0x40108050, 0xf7f4f303, - 0x0bcb16c0, 0xf83eedc6, 0x14052811, 0x81671fe6, - 0xb7e47353, 0x9c2725bb, 0x19413258, 0x168b2c9d, - 0xa6a75101, 0xe97dcf94, 0x6e95dcfb, 0x47d88e9f, - 0xcbfb8b30, 0x9fee2371, 0xed7cc791, 0x856617e3, - 0x53dda68e, 0x5c17b84b, 0x01470246, 0x429e84dc, - 0x0fca1ec5, 0xb42d7599, 0xc6bf9179, 0x1c07381b, - 0x8ead0123, 0x755aea2f, 0x36836cb5, 0xcc3385ff, - 0x91633ff2, 0x0802100a, 0x92aa3938, 0xd971afa8, - 0x07c80ecf, 0x6419c87d, 0x39497270, 0x43d9869a, - 0xeff2c31d, 0xabe34b48, 0x715be22a, 0x1a883492, - 0x529aa4c8, 0x98262dbe, 0xc8328dfa, 0xfab0e94a, - 0x83e91b6a, 0x3c0f7833, 0x73d5e6a6, 0x3a8074ba, - 0xc2be997c, 0x13cd26de, 0xd034bde4, 0x3d487a75, - 0xdbffab24, 0xf57af78f, 0x7a90f4ea, 0x615fc23e, - 0x80201da0, 0xbd6867d5, 0x681ad072, 0x82ae192c, - 0xeab4c95e, 0x4d549a19, 0x7693ece5, 0x88220daa, - 0x8d6407e9, 0xe3f1db12, 0xd173bfa2, 0x4812905a, - 0x1d403a5d, 0x20084028, 0x2bc356e8, 0x97ec337b, - 0x4bdb9690, 0xbea1611f, 0x0e8d1c83, 0xf43df5c9, - 0x6697ccf1, 0x00000000, 0x1bcf36d4, 0xac2b4587, - 0xc57697b3, 0x328264b0, 0x7fd6fea9, 0x6c1bd877, - 0xeeb5c15b, 0x86af1129, 0xb56a77df, 0x5d50ba0d, - 0x0945124c, 0xebf3cb18, 0xc0309df0, 0x9bef2b74, - 0xfc3fe5c3, 0x4955921c, 0xb2a27910, 0x8fea0365, - 0x89650fec, 0xd2bab968, 0xbc2f6593, 0x27c04ee7, - 0x5fdebe81, 0x701ce06c, 0xd3fdbb2e, 0x294d5264, - 0x7292e4e0, 0xc9758fbc, 0x1806301e, 0x128a2498, - 0xf2b2f940, 0xbfe66359, 0x380e7036, 0x7c1ff863, - 0x956237f7, 0x77d4eea3, 0x9aa82932, 0x6296c4f4, - 0xc3f99b3a, 0x33c566f6, 0x942535b1, 0x7959f220, - 0x2a8454ae, 0xd572b7a7, 0xe439d5dd, 0x2d4c5a61, - 0x655eca3b, 0xfd78e785, 0xe038ddd8, 0x0a8c1486, - 0x63d1c6b2, 0xaea5410b, 0xafe2434d, 0x99612ff8, - 0xf6b3f145, 0x842115a5, 0x4a9c94d6, 0x781ef066, - 0x11432252, 0x3bc776fc, 0xd7fcb32b, 0x10042014, - 0x5951b208, 0x5e99bcc7, 0xa96d4fc4, 0x340d6839, - 0xcffa8335, 0x5bdfb684, 0xe57ed79b, 0x90243db4, - 0xec3bc5d7, 0x96ab313d, 0x1fce3ed1, 0x44118855, - 0x068f0c89, 0x254e4a6b, 0xe6b7d151, 0x8beb0b60, - 0xf03cfdcc, 0x3e817cbf, 0x6a94d4fe, 0xfbf7eb0c, - 0xdeb9a167, 0x4c13985f, 0xb02c7d9c, 0x6bd3d6b8, - 0xbbe76b5c, 0xa56e57cb, 0x37c46ef3, 0x0c03180f, - 0x45568a13, 0x0d441a49, 0xe17fdf9e, 0x9ea92137, - 0xa82a4d82, 0xd6bbb16d, 0x23c146e2, 0x5153a202, - 0x57dcae8b, 0x2c0b5827, 0x4e9d9cd3, 0xad6c47c1, - 0xc43195f5, 0xcd7487b9, 0xfff6e309, 0x05460a43, - 0x8aac0926, 0x1e893c97, 0x5014a044, 0xa3e15b42, - 0x5816b04e, 0xe83acdd2, 0xb9696fd0, 0x2409482d, - 0xdd70a7ad, 0xe2b6d954, 0x67d0ceb7, 0x93ed3b7e, - 0x17cc2edb, 0x15422a57, 0x5a98b4c2, 0xaaa4490e, - 0xa0285d88, 0x6d5cda31, 0xc7f8933f, 0x228644a4, - }, - { - 0x186018c0, 0x238c2305, 0xc63fc67e, 0xe887e813, - 0x8726874c, 0xb8dab8a9, 0x01040108, 0x4f214f42, - 0x36d836ad, 0xa6a2a659, 0xd26fd2de, 0xf5f3f5fb, - 0x79f979ef, 0x6fa16f5f, 0x917e91fc, 0x525552aa, - 0x609d6027, 0xbccabc89, 0x9b569bac, 0x8e028e04, - 0xa3b6a371, 0x0c300c60, 0x7bf17bff, 0x35d435b5, - 0x1d741de8, 0xe0a7e053, 0xd77bd7f6, 0xc22fc25e, - 0x2eb82e6d, 0x4b314b62, 0xfedffea3, 0x57415782, - 0x155415a8, 0x77c1779f, 0x37dc37a5, 0xe5b3e57b, - 0x9f469f8c, 0xf0e7f0d3, 0x4a354a6a, 0xda4fda9e, - 0x587d58fa, 0xc903c906, 0x29a42955, 0x0a280a50, - 0xb1feb1e1, 0xa0baa069, 0x6bb16b7f, 0x852e855c, - 0xbdcebd81, 0x5d695dd2, 0x10401080, 0xf4f7f4f3, - 0xcb0bcb16, 0x3ef83eed, 0x05140528, 0x6781671f, - 0xe4b7e473, 0x279c2725, 0x41194132, 0x8b168b2c, - 0xa7a6a751, 0x7de97dcf, 0x956e95dc, 0xd847d88e, - 0xfbcbfb8b, 0xee9fee23, 0x7ced7cc7, 0x66856617, - 0xdd53dda6, 0x175c17b8, 0x47014702, 0x9e429e84, - 0xca0fca1e, 0x2db42d75, 0xbfc6bf91, 0x071c0738, - 0xad8ead01, 0x5a755aea, 0x8336836c, 0x33cc3385, - 0x6391633f, 0x02080210, 0xaa92aa39, 0x71d971af, - 0xc807c80e, 0x196419c8, 0x49394972, 0xd943d986, - 0xf2eff2c3, 0xe3abe34b, 0x5b715be2, 0x881a8834, - 0x9a529aa4, 0x2698262d, 0x32c8328d, 0xb0fab0e9, - 0xe983e91b, 0x0f3c0f78, 0xd573d5e6, 0x803a8074, - 0xbec2be99, 0xcd13cd26, 0x34d034bd, 0x483d487a, - 0xffdbffab, 0x7af57af7, 0x907a90f4, 0x5f615fc2, - 0x2080201d, 0x68bd6867, 0x1a681ad0, 0xae82ae19, - 0xb4eab4c9, 0x544d549a, 0x937693ec, 0x2288220d, - 0x648d6407, 0xf1e3f1db, 0x73d173bf, 0x12481290, - 0x401d403a, 0x08200840, 0xc32bc356, 0xec97ec33, - 0xdb4bdb96, 0xa1bea161, 0x8d0e8d1c, 0x3df43df5, - 0x976697cc, 0x00000000, 0xcf1bcf36, 0x2bac2b45, - 0x76c57697, 0x82328264, 0xd67fd6fe, 0x1b6c1bd8, - 0xb5eeb5c1, 0xaf86af11, 0x6ab56a77, 0x505d50ba, - 0x45094512, 0xf3ebf3cb, 0x30c0309d, 0xef9bef2b, - 0x3ffc3fe5, 0x55495592, 0xa2b2a279, 0xea8fea03, - 0x6589650f, 0xbad2bab9, 0x2fbc2f65, 0xc027c04e, - 0xde5fdebe, 0x1c701ce0, 0xfdd3fdbb, 0x4d294d52, - 0x927292e4, 0x75c9758f, 0x06180630, 0x8a128a24, - 0xb2f2b2f9, 0xe6bfe663, 0x0e380e70, 0x1f7c1ff8, - 0x62956237, 0xd477d4ee, 0xa89aa829, 0x966296c4, - 0xf9c3f99b, 0xc533c566, 0x25942535, 0x597959f2, - 0x842a8454, 0x72d572b7, 0x39e439d5, 0x4c2d4c5a, - 0x5e655eca, 0x78fd78e7, 0x38e038dd, 0x8c0a8c14, - 0xd163d1c6, 0xa5aea541, 0xe2afe243, 0x6199612f, - 0xb3f6b3f1, 0x21842115, 0x9c4a9c94, 0x1e781ef0, - 0x43114322, 0xc73bc776, 0xfcd7fcb3, 0x04100420, - 0x515951b2, 0x995e99bc, 0x6da96d4f, 0x0d340d68, - 0xfacffa83, 0xdf5bdfb6, 0x7ee57ed7, 0x2490243d, - 0x3bec3bc5, 0xab96ab31, 0xce1fce3e, 0x11441188, - 0x8f068f0c, 0x4e254e4a, 0xb7e6b7d1, 0xeb8beb0b, - 0x3cf03cfd, 0x813e817c, 0x946a94d4, 0xf7fbf7eb, - 0xb9deb9a1, 0x134c1398, 0x2cb02c7d, 0xd36bd3d6, - 0xe7bbe76b, 0x6ea56e57, 0xc437c46e, 0x030c0318, - 0x5645568a, 0x440d441a, 0x7fe17fdf, 0xa99ea921, - 0x2aa82a4d, 0xbbd6bbb1, 0xc123c146, 0x535153a2, - 0xdc57dcae, 0x0b2c0b58, 0x9d4e9d9c, 0x6cad6c47, - 0x31c43195, 0x74cd7487, 0xf6fff6e3, 0x4605460a, - 0xac8aac09, 0x891e893c, 0x145014a0, 0xe1a3e15b, - 0x165816b0, 0x3ae83acd, 0x69b9696f, 0x09240948, - 0x70dd70a7, 0xb6e2b6d9, 0xd067d0ce, 0xed93ed3b, - 0xcc17cc2e, 0x4215422a, 0x985a98b4, 0xa4aaa449, - 0x28a0285d, 0x5c6d5cda, 0xf8c7f893, 0x86228644, - }, - { - 0x18186018, 0x23238c23, 0xc6c63fc6, 0xe8e887e8, - 0x87872687, 0xb8b8dab8, 0x01010401, 0x4f4f214f, - 0x3636d836, 0xa6a6a2a6, 0xd2d26fd2, 0xf5f5f3f5, - 0x7979f979, 0x6f6fa16f, 0x91917e91, 0x52525552, - 0x60609d60, 0xbcbccabc, 0x9b9b569b, 0x8e8e028e, - 0xa3a3b6a3, 0x0c0c300c, 0x7b7bf17b, 0x3535d435, - 0x1d1d741d, 0xe0e0a7e0, 0xd7d77bd7, 0xc2c22fc2, - 0x2e2eb82e, 0x4b4b314b, 0xfefedffe, 0x57574157, - 0x15155415, 0x7777c177, 0x3737dc37, 0xe5e5b3e5, - 0x9f9f469f, 0xf0f0e7f0, 0x4a4a354a, 0xdada4fda, - 0x58587d58, 0xc9c903c9, 0x2929a429, 0x0a0a280a, - 0xb1b1feb1, 0xa0a0baa0, 0x6b6bb16b, 0x85852e85, - 0xbdbdcebd, 0x5d5d695d, 0x10104010, 0xf4f4f7f4, - 0xcbcb0bcb, 0x3e3ef83e, 0x05051405, 0x67678167, - 0xe4e4b7e4, 0x27279c27, 0x41411941, 0x8b8b168b, - 0xa7a7a6a7, 0x7d7de97d, 0x95956e95, 0xd8d847d8, - 0xfbfbcbfb, 0xeeee9fee, 0x7c7ced7c, 0x66668566, - 0xdddd53dd, 0x17175c17, 0x47470147, 0x9e9e429e, - 0xcaca0fca, 0x2d2db42d, 0xbfbfc6bf, 0x07071c07, - 0xadad8ead, 0x5a5a755a, 0x83833683, 0x3333cc33, - 0x63639163, 0x02020802, 0xaaaa92aa, 0x7171d971, - 0xc8c807c8, 0x19196419, 0x49493949, 0xd9d943d9, - 0xf2f2eff2, 0xe3e3abe3, 0x5b5b715b, 0x88881a88, - 0x9a9a529a, 0x26269826, 0x3232c832, 0xb0b0fab0, - 0xe9e983e9, 0x0f0f3c0f, 0xd5d573d5, 0x80803a80, - 0xbebec2be, 0xcdcd13cd, 0x3434d034, 0x48483d48, - 0xffffdbff, 0x7a7af57a, 0x90907a90, 0x5f5f615f, - 0x20208020, 0x6868bd68, 0x1a1a681a, 0xaeae82ae, - 0xb4b4eab4, 0x54544d54, 0x93937693, 0x22228822, - 0x64648d64, 0xf1f1e3f1, 0x7373d173, 0x12124812, - 0x40401d40, 0x08082008, 0xc3c32bc3, 0xecec97ec, - 0xdbdb4bdb, 0xa1a1bea1, 0x8d8d0e8d, 0x3d3df43d, - 0x97976697, 0x00000000, 0xcfcf1bcf, 0x2b2bac2b, - 0x7676c576, 0x82823282, 0xd6d67fd6, 0x1b1b6c1b, - 0xb5b5eeb5, 0xafaf86af, 0x6a6ab56a, 0x50505d50, - 0x45450945, 0xf3f3ebf3, 0x3030c030, 0xefef9bef, - 0x3f3ffc3f, 0x55554955, 0xa2a2b2a2, 0xeaea8fea, - 0x65658965, 0xbabad2ba, 0x2f2fbc2f, 0xc0c027c0, - 0xdede5fde, 0x1c1c701c, 0xfdfdd3fd, 0x4d4d294d, - 0x92927292, 0x7575c975, 0x06061806, 0x8a8a128a, - 0xb2b2f2b2, 0xe6e6bfe6, 0x0e0e380e, 0x1f1f7c1f, - 0x62629562, 0xd4d477d4, 0xa8a89aa8, 0x96966296, - 0xf9f9c3f9, 0xc5c533c5, 0x25259425, 0x59597959, - 0x84842a84, 0x7272d572, 0x3939e439, 0x4c4c2d4c, - 0x5e5e655e, 0x7878fd78, 0x3838e038, 0x8c8c0a8c, - 0xd1d163d1, 0xa5a5aea5, 0xe2e2afe2, 0x61619961, - 0xb3b3f6b3, 0x21218421, 0x9c9c4a9c, 0x1e1e781e, - 0x43431143, 0xc7c73bc7, 0xfcfcd7fc, 0x04041004, - 0x51515951, 0x99995e99, 0x6d6da96d, 0x0d0d340d, - 0xfafacffa, 0xdfdf5bdf, 0x7e7ee57e, 0x24249024, - 0x3b3bec3b, 0xabab96ab, 0xcece1fce, 0x11114411, - 0x8f8f068f, 0x4e4e254e, 0xb7b7e6b7, 0xebeb8beb, - 0x3c3cf03c, 0x81813e81, 0x94946a94, 0xf7f7fbf7, - 0xb9b9deb9, 0x13134c13, 0x2c2cb02c, 0xd3d36bd3, - 0xe7e7bbe7, 0x6e6ea56e, 0xc4c437c4, 0x03030c03, - 0x56564556, 0x44440d44, 0x7f7fe17f, 0xa9a99ea9, - 0x2a2aa82a, 0xbbbbd6bb, 0xc1c123c1, 0x53535153, - 0xdcdc57dc, 0x0b0b2c0b, 0x9d9d4e9d, 0x6c6cad6c, - 0x3131c431, 0x7474cd74, 0xf6f6fff6, 0x46460546, - 0xacac8aac, 0x89891e89, 0x14145014, 0xe1e1a3e1, - 0x16165816, 0x3a3ae83a, 0x6969b969, 0x09092409, - 0x7070dd70, 0xb6b6e2b6, 0xd0d067d0, 0xeded93ed, - 0xcccc17cc, 0x42421542, 0x98985a98, 0xa4a4aaa4, - 0x2828a028, 0x5c5c6d5c, 0xf8f8c7f8, 0x86862286, - }, - { - 0xd8181860, 0x2623238c, 0xb8c6c63f, 0xfbe8e887, - 0xcb878726, 0x11b8b8da, 0x09010104, 0x0d4f4f21, - 0x9b3636d8, 0xffa6a6a2, 0x0cd2d26f, 0x0ef5f5f3, - 0x967979f9, 0x306f6fa1, 0x6d91917e, 0xf8525255, - 0x4760609d, 0x35bcbcca, 0x379b9b56, 0x8a8e8e02, - 0xd2a3a3b6, 0x6c0c0c30, 0x847b7bf1, 0x803535d4, - 0xf51d1d74, 0xb3e0e0a7, 0x21d7d77b, 0x9cc2c22f, - 0x432e2eb8, 0x294b4b31, 0x5dfefedf, 0xd5575741, - 0xbd151554, 0xe87777c1, 0x923737dc, 0x9ee5e5b3, - 0x139f9f46, 0x23f0f0e7, 0x204a4a35, 0x44dada4f, - 0xa258587d, 0xcfc9c903, 0x7c2929a4, 0x5a0a0a28, - 0x50b1b1fe, 0xc9a0a0ba, 0x146b6bb1, 0xd985852e, - 0x3cbdbdce, 0x8f5d5d69, 0x90101040, 0x07f4f4f7, - 0xddcbcb0b, 0xd33e3ef8, 0x2d050514, 0x78676781, - 0x97e4e4b7, 0x0227279c, 0x73414119, 0xa78b8b16, - 0xf6a7a7a6, 0xb27d7de9, 0x4995956e, 0x56d8d847, - 0x70fbfbcb, 0xcdeeee9f, 0xbb7c7ced, 0x71666685, - 0x7bdddd53, 0xaf17175c, 0x45474701, 0x1a9e9e42, - 0xd4caca0f, 0x582d2db4, 0x2ebfbfc6, 0x3f07071c, - 0xacadad8e, 0xb05a5a75, 0xef838336, 0xb63333cc, - 0x5c636391, 0x12020208, 0x93aaaa92, 0xde7171d9, - 0xc6c8c807, 0xd1191964, 0x3b494939, 0x5fd9d943, - 0x31f2f2ef, 0xa8e3e3ab, 0xb95b5b71, 0xbc88881a, - 0x3e9a9a52, 0x0b262698, 0xbf3232c8, 0x59b0b0fa, - 0xf2e9e983, 0x770f0f3c, 0x33d5d573, 0xf480803a, - 0x27bebec2, 0xebcdcd13, 0x893434d0, 0x3248483d, - 0x54ffffdb, 0x8d7a7af5, 0x6490907a, 0x9d5f5f61, - 0x3d202080, 0x0f6868bd, 0xca1a1a68, 0xb7aeae82, - 0x7db4b4ea, 0xce54544d, 0x7f939376, 0x2f222288, - 0x6364648d, 0x2af1f1e3, 0xcc7373d1, 0x82121248, - 0x7a40401d, 0x48080820, 0x95c3c32b, 0xdfecec97, - 0x4ddbdb4b, 0xc0a1a1be, 0x918d8d0e, 0xc83d3df4, - 0x5b979766, 0x00000000, 0xf9cfcf1b, 0x6e2b2bac, - 0xe17676c5, 0xe6828232, 0x28d6d67f, 0xc31b1b6c, - 0x74b5b5ee, 0xbeafaf86, 0x1d6a6ab5, 0xea50505d, - 0x57454509, 0x38f3f3eb, 0xad3030c0, 0xc4efef9b, - 0xda3f3ffc, 0xc7555549, 0xdba2a2b2, 0xe9eaea8f, - 0x6a656589, 0x03babad2, 0x4a2f2fbc, 0x8ec0c027, - 0x60dede5f, 0xfc1c1c70, 0x46fdfdd3, 0x1f4d4d29, - 0x76929272, 0xfa7575c9, 0x36060618, 0xae8a8a12, - 0x4bb2b2f2, 0x85e6e6bf, 0x7e0e0e38, 0xe71f1f7c, - 0x55626295, 0x3ad4d477, 0x81a8a89a, 0x52969662, - 0x62f9f9c3, 0xa3c5c533, 0x10252594, 0xab595979, - 0xd084842a, 0xc57272d5, 0xec3939e4, 0x164c4c2d, - 0x945e5e65, 0x9f7878fd, 0xe53838e0, 0x988c8c0a, - 0x17d1d163, 0xe4a5a5ae, 0xa1e2e2af, 0x4e616199, - 0x42b3b3f6, 0x34212184, 0x089c9c4a, 0xee1e1e78, - 0x61434311, 0xb1c7c73b, 0x4ffcfcd7, 0x24040410, - 0xe3515159, 0x2599995e, 0x226d6da9, 0x650d0d34, - 0x79fafacf, 0x69dfdf5b, 0xa97e7ee5, 0x19242490, - 0xfe3b3bec, 0x9aabab96, 0xf0cece1f, 0x99111144, - 0x838f8f06, 0x044e4e25, 0x66b7b7e6, 0xe0ebeb8b, - 0xc13c3cf0, 0xfd81813e, 0x4094946a, 0x1cf7f7fb, - 0x18b9b9de, 0x8b13134c, 0x512c2cb0, 0x05d3d36b, - 0x8ce7e7bb, 0x396e6ea5, 0xaac4c437, 0x1b03030c, - 0xdc565645, 0x5e44440d, 0xa07f7fe1, 0x88a9a99e, - 0x672a2aa8, 0x0abbbbd6, 0x87c1c123, 0xf1535351, - 0x72dcdc57, 0x530b0b2c, 0x019d9d4e, 0x2b6c6cad, - 0xa43131c4, 0xf37474cd, 0x15f6f6ff, 0x4c464605, - 0xa5acac8a, 0xb589891e, 0xb4141450, 0xbae1e1a3, - 0xa6161658, 0xf73a3ae8, 0x066969b9, 0x41090924, - 0xd77070dd, 0x6fb6b6e2, 0x1ed0d067, 0xd6eded93, - 0xe2cccc17, 0x68424215, 0x2c98985a, 0xeda4a4aa, - 0x752828a0, 0x865c5c6d, 0x6bf8f8c7, 0xc2868622, - }, - { - 0x30d81818, 0x46262323, 0x91b8c6c6, 0xcdfbe8e8, - 0x13cb8787, 0x6d11b8b8, 0x02090101, 0x9e0d4f4f, - 0x6c9b3636, 0x51ffa6a6, 0xb90cd2d2, 0xf70ef5f5, - 0xf2967979, 0xde306f6f, 0x3f6d9191, 0xa4f85252, - 0xc0476060, 0x6535bcbc, 0x2b379b9b, 0x018a8e8e, - 0x5bd2a3a3, 0x186c0c0c, 0xf6847b7b, 0x6a803535, - 0x3af51d1d, 0xddb3e0e0, 0xb321d7d7, 0x999cc2c2, - 0x5c432e2e, 0x96294b4b, 0xe15dfefe, 0xaed55757, - 0x2abd1515, 0xeee87777, 0x6e923737, 0xd79ee5e5, - 0x23139f9f, 0xfd23f0f0, 0x94204a4a, 0xa944dada, - 0xb0a25858, 0x8fcfc9c9, 0x527c2929, 0x145a0a0a, - 0x7f50b1b1, 0x5dc9a0a0, 0xd6146b6b, 0x17d98585, - 0x673cbdbd, 0xba8f5d5d, 0x20901010, 0xf507f4f4, - 0x8bddcbcb, 0x7cd33e3e, 0x0a2d0505, 0xce786767, - 0xd597e4e4, 0x4e022727, 0x82734141, 0x0ba78b8b, - 0x53f6a7a7, 0xfab27d7d, 0x37499595, 0xad56d8d8, - 0xeb70fbfb, 0xc1cdeeee, 0xf8bb7c7c, 0xcc716666, - 0xa77bdddd, 0x2eaf1717, 0x8e454747, 0x211a9e9e, - 0x89d4caca, 0x5a582d2d, 0x632ebfbf, 0x0e3f0707, - 0x47acadad, 0xb4b05a5a, 0x1bef8383, 0x66b63333, - 0xc65c6363, 0x04120202, 0x4993aaaa, 0xe2de7171, - 0x8dc6c8c8, 0x32d11919, 0x923b4949, 0xaf5fd9d9, - 0xf931f2f2, 0xdba8e3e3, 0xb6b95b5b, 0x0dbc8888, - 0x293e9a9a, 0x4c0b2626, 0x64bf3232, 0x7d59b0b0, - 0xcff2e9e9, 0x1e770f0f, 0xb733d5d5, 0x1df48080, - 0x6127bebe, 0x87ebcdcd, 0x68893434, 0x90324848, - 0xe354ffff, 0xf48d7a7a, 0x3d649090, 0xbe9d5f5f, - 0x403d2020, 0xd00f6868, 0x34ca1a1a, 0x41b7aeae, - 0x757db4b4, 0xa8ce5454, 0x3b7f9393, 0x442f2222, - 0xc8636464, 0xff2af1f1, 0xe6cc7373, 0x24821212, - 0x807a4040, 0x10480808, 0x9b95c3c3, 0xc5dfecec, - 0xab4ddbdb, 0x5fc0a1a1, 0x07918d8d, 0x7ac83d3d, - 0x335b9797, 0x00000000, 0x83f9cfcf, 0x566e2b2b, - 0xece17676, 0x19e68282, 0xb128d6d6, 0x36c31b1b, - 0x7774b5b5, 0x43beafaf, 0xd41d6a6a, 0xa0ea5050, - 0x8a574545, 0xfb38f3f3, 0x60ad3030, 0xc3c4efef, - 0x7eda3f3f, 0xaac75555, 0x59dba2a2, 0xc9e9eaea, - 0xca6a6565, 0x6903baba, 0x5e4a2f2f, 0x9d8ec0c0, - 0xa160dede, 0x38fc1c1c, 0xe746fdfd, 0x9a1f4d4d, - 0x39769292, 0xeafa7575, 0x0c360606, 0x09ae8a8a, - 0x794bb2b2, 0xd185e6e6, 0x1c7e0e0e, 0x3ee71f1f, - 0xc4556262, 0xb53ad4d4, 0x4d81a8a8, 0x31529696, - 0xef62f9f9, 0x97a3c5c5, 0x4a102525, 0xb2ab5959, - 0x15d08484, 0xe4c57272, 0x72ec3939, 0x98164c4c, - 0xbc945e5e, 0xf09f7878, 0x70e53838, 0x05988c8c, - 0xbf17d1d1, 0x57e4a5a5, 0xd9a1e2e2, 0xc24e6161, - 0x7b42b3b3, 0x42342121, 0x25089c9c, 0x3cee1e1e, - 0x86614343, 0x93b1c7c7, 0xe54ffcfc, 0x08240404, - 0xa2e35151, 0x2f259999, 0xda226d6d, 0x1a650d0d, - 0xe979fafa, 0xa369dfdf, 0xfca97e7e, 0x48192424, - 0x76fe3b3b, 0x4b9aabab, 0x81f0cece, 0x22991111, - 0x03838f8f, 0x9c044e4e, 0x7366b7b7, 0xcbe0ebeb, - 0x78c13c3c, 0x1ffd8181, 0x35409494, 0xf31cf7f7, - 0x6f18b9b9, 0x268b1313, 0x58512c2c, 0xbb05d3d3, - 0xd38ce7e7, 0xdc396e6e, 0x95aac4c4, 0x061b0303, - 0xacdc5656, 0x885e4444, 0xfea07f7f, 0x4f88a9a9, - 0x54672a2a, 0x6b0abbbb, 0x9f87c1c1, 0xa6f15353, - 0xa572dcdc, 0x16530b0b, 0x27019d9d, 0xd82b6c6c, - 0x62a43131, 0xe8f37474, 0xf115f6f6, 0x8c4c4646, - 0x45a5acac, 0x0fb58989, 0x28b41414, 0xdfbae1e1, - 0x2ca61616, 0x74f73a3a, 0xd2066969, 0x12410909, - 0xe0d77070, 0x716fb6b6, 0xbd1ed0d0, 0xc7d6eded, - 0x85e2cccc, 0x84684242, 0x2d2c9898, 0x55eda4a4, - 0x50752828, 0xb8865c5c, 0xed6bf8f8, 0x11c28686, - }, - { - 0x7830d818, 0xaf462623, 0xf991b8c6, 0x6fcdfbe8, - 0xa113cb87, 0x626d11b8, 0x05020901, 0x6e9e0d4f, - 0xee6c9b36, 0x0451ffa6, 0xbdb90cd2, 0x06f70ef5, - 0x80f29679, 0xcede306f, 0xef3f6d91, 0x07a4f852, - 0xfdc04760, 0x766535bc, 0xcd2b379b, 0x8c018a8e, - 0x155bd2a3, 0x3c186c0c, 0x8af6847b, 0xe16a8035, - 0x693af51d, 0x47ddb3e0, 0xacb321d7, 0xed999cc2, - 0x965c432e, 0x7a96294b, 0x21e15dfe, 0x16aed557, - 0x412abd15, 0xb6eee877, 0xeb6e9237, 0x56d79ee5, - 0xd923139f, 0x17fd23f0, 0x7f94204a, 0x95a944da, - 0x25b0a258, 0xca8fcfc9, 0x8d527c29, 0x22145a0a, - 0x4f7f50b1, 0x1a5dc9a0, 0xdad6146b, 0xab17d985, - 0x73673cbd, 0x34ba8f5d, 0x50209010, 0x03f507f4, - 0xc08bddcb, 0xc67cd33e, 0x110a2d05, 0xe6ce7867, - 0x53d597e4, 0xbb4e0227, 0x58827341, 0x9d0ba78b, - 0x0153f6a7, 0x94fab27d, 0xfb374995, 0x9fad56d8, - 0x30eb70fb, 0x71c1cdee, 0x91f8bb7c, 0xe3cc7166, - 0x8ea77bdd, 0x4b2eaf17, 0x468e4547, 0xdc211a9e, - 0xc589d4ca, 0x995a582d, 0x79632ebf, 0x1b0e3f07, - 0x2347acad, 0x2fb4b05a, 0xb51bef83, 0xff66b633, - 0xf2c65c63, 0x0a041202, 0x384993aa, 0xa8e2de71, - 0xcf8dc6c8, 0x7d32d119, 0x70923b49, 0x9aaf5fd9, - 0x1df931f2, 0x48dba8e3, 0x2ab6b95b, 0x920dbc88, - 0xc8293e9a, 0xbe4c0b26, 0xfa64bf32, 0x4a7d59b0, - 0x6acff2e9, 0x331e770f, 0xa6b733d5, 0xba1df480, - 0x7c6127be, 0xde87ebcd, 0xe4688934, 0x75903248, - 0x24e354ff, 0x8ff48d7a, 0xea3d6490, 0x3ebe9d5f, - 0xa0403d20, 0xd5d00f68, 0x7234ca1a, 0x2c41b7ae, - 0x5e757db4, 0x19a8ce54, 0xe53b7f93, 0xaa442f22, - 0xe9c86364, 0x12ff2af1, 0xa2e6cc73, 0x5a248212, - 0x5d807a40, 0x28104808, 0xe89b95c3, 0x7bc5dfec, - 0x90ab4ddb, 0x1f5fc0a1, 0x8307918d, 0xc97ac83d, - 0xf1335b97, 0x00000000, 0xd483f9cf, 0x87566e2b, - 0xb3ece176, 0xb019e682, 0xa9b128d6, 0x7736c31b, - 0x5b7774b5, 0x2943beaf, 0xdfd41d6a, 0x0da0ea50, - 0x4c8a5745, 0x18fb38f3, 0xf060ad30, 0x74c3c4ef, - 0xc37eda3f, 0x1caac755, 0x1059dba2, 0x65c9e9ea, - 0xecca6a65, 0x686903ba, 0x935e4a2f, 0xe79d8ec0, - 0x81a160de, 0x6c38fc1c, 0x2ee746fd, 0x649a1f4d, - 0xe0397692, 0xbceafa75, 0x1e0c3606, 0x9809ae8a, - 0x40794bb2, 0x59d185e6, 0x361c7e0e, 0x633ee71f, - 0xf7c45562, 0xa3b53ad4, 0x324d81a8, 0xf4315296, - 0x3aef62f9, 0xf697a3c5, 0xb14a1025, 0x20b2ab59, - 0xae15d084, 0xa7e4c572, 0xdd72ec39, 0x6198164c, - 0x3bbc945e, 0x85f09f78, 0xd870e538, 0x8605988c, - 0xb2bf17d1, 0x0b57e4a5, 0x4dd9a1e2, 0xf8c24e61, - 0x457b42b3, 0xa5423421, 0xd625089c, 0x663cee1e, - 0x52866143, 0xfc93b1c7, 0x2be54ffc, 0x14082404, - 0x08a2e351, 0xc72f2599, 0xc4da226d, 0x391a650d, - 0x35e979fa, 0x84a369df, 0x9bfca97e, 0xb4481924, - 0xd776fe3b, 0x3d4b9aab, 0xd181f0ce, 0x55229911, - 0x8903838f, 0x6b9c044e, 0x517366b7, 0x60cbe0eb, - 0xcc78c13c, 0xbf1ffd81, 0xfe354094, 0x0cf31cf7, - 0x676f18b9, 0x5f268b13, 0x9c58512c, 0xb8bb05d3, - 0x5cd38ce7, 0xcbdc396e, 0xf395aac4, 0x0f061b03, - 0x13acdc56, 0x49885e44, 0x9efea07f, 0x374f88a9, - 0x8254672a, 0x6d6b0abb, 0xe29f87c1, 0x02a6f153, - 0x8ba572dc, 0x2716530b, 0xd327019d, 0xc1d82b6c, - 0xf562a431, 0xb9e8f374, 0x09f115f6, 0x438c4c46, - 0x2645a5ac, 0x970fb589, 0x4428b414, 0x42dfbae1, - 0x4e2ca616, 0xd274f73a, 0xd0d20669, 0x2d124109, - 0xade0d770, 0x54716fb6, 0xb7bd1ed0, 0x7ec7d6ed, - 0xdb85e2cc, 0x57846842, 0xc22d2c98, 0x0e55eda4, - 0x88507528, 0x31b8865c, 0x3fed6bf8, 0xa411c286, - }, + 0xd818186018c07830, 0x2623238c2305af46, 0xb8c6c63fc67ef991, 0xfbe8e887e8136fcd, + 0xcb878726874ca113, 0x11b8b8dab8a9626d, 0x0901010401080502, 0x0d4f4f214f426e9e, + 0x9b3636d836adee6c, 0xffa6a6a2a6590451, 0x0cd2d26fd2debdb9, 0x0ef5f5f3f5fb06f7, + 0x967979f979ef80f2, 0x306f6fa16f5fcede, 0x6d91917e91fcef3f, 0xf852525552aa07a4, + 0x4760609d6027fdc0, 0x35bcbccabc897665, 0x379b9b569baccd2b, 0x8a8e8e028e048c01, + 0xd2a3a3b6a371155b, 0x6c0c0c300c603c18, 0x847b7bf17bff8af6, 0x803535d435b5e16a, + 0xf51d1d741de8693a, 0xb3e0e0a7e05347dd, 0x21d7d77bd7f6acb3, 0x9cc2c22fc25eed99, + 0x432e2eb82e6d965c, 0x294b4b314b627a96, 0x5dfefedffea321e1, 0xd5575741578216ae, + 0xbd15155415a8412a, 0xe87777c1779fb6ee, 0x923737dc37a5eb6e, 0x9ee5e5b3e57b56d7, + 0x139f9f469f8cd923, 0x23f0f0e7f0d317fd, 0x204a4a354a6a7f94, 0x44dada4fda9e95a9, + 0xa258587d58fa25b0, 0xcfc9c903c906ca8f, 0x7c2929a429558d52, 0x5a0a0a280a502214, + 0x50b1b1feb1e14f7f, 0xc9a0a0baa0691a5d, 0x146b6bb16b7fdad6, 0xd985852e855cab17, + 0x3cbdbdcebd817367, 0x8f5d5d695dd234ba, 0x9010104010805020, 0x07f4f4f7f4f303f5, + 0xddcbcb0bcb16c08b, 0xd33e3ef83eedc67c, 0x2d0505140528110a, 0x78676781671fe6ce, + 0x97e4e4b7e47353d5, 0x0227279c2725bb4e, 0x7341411941325882, 0xa78b8b168b2c9d0b, + 0xf6a7a7a6a7510153, 0xb27d7de97dcf94fa, 0x4995956e95dcfb37, 0x56d8d847d88e9fad, + 0x70fbfbcbfb8b30eb, 0xcdeeee9fee2371c1, 0xbb7c7ced7cc791f8, 0x716666856617e3cc, + 0x7bdddd53dda68ea7, 0xaf17175c17b84b2e, 0x454747014702468e, 0x1a9e9e429e84dc21, + 0xd4caca0fca1ec589, 0x582d2db42d75995a, 0x2ebfbfc6bf917963, 0x3f07071c07381b0e, + 0xacadad8ead012347, 0xb05a5a755aea2fb4, 0xef838336836cb51b, 0xb63333cc3385ff66, + 0x5c636391633ff2c6, 0x1202020802100a04, 0x93aaaa92aa393849, 0xde7171d971afa8e2, + 0xc6c8c807c80ecf8d, 0xd119196419c87d32, 0x3b49493949727092, 0x5fd9d943d9869aaf, + 0x31f2f2eff2c31df9, 0xa8e3e3abe34b48db, 0xb95b5b715be22ab6, 0xbc88881a8834920d, + 0x3e9a9a529aa4c829, 0x0b262698262dbe4c, 0xbf3232c8328dfa64, 0x59b0b0fab0e94a7d, + 0xf2e9e983e91b6acf, 0x770f0f3c0f78331e, 0x33d5d573d5e6a6b7, 0xf480803a8074ba1d, + 0x27bebec2be997c61, 0xebcdcd13cd26de87, 0x893434d034bde468, 0x3248483d487a7590, + 0x54ffffdbffab24e3, 0x8d7a7af57af78ff4, 0x6490907a90f4ea3d, 0x9d5f5f615fc23ebe, + 0x3d202080201da040, 0x0f6868bd6867d5d0, 0xca1a1a681ad07234, 0xb7aeae82ae192c41, + 0x7db4b4eab4c95e75, 0xce54544d549a19a8, 0x7f93937693ece53b, 0x2f222288220daa44, + 0x6364648d6407e9c8, 0x2af1f1e3f1db12ff, 0xcc7373d173bfa2e6, 0x8212124812905a24, + 0x7a40401d403a5d80, 0x4808082008402810, 0x95c3c32bc356e89b, 0xdfecec97ec337bc5, + 0x4ddbdb4bdb9690ab, 0xc0a1a1bea1611f5f, 0x918d8d0e8d1c8307, 0xc83d3df43df5c97a, + 0x5b97976697ccf133, 0x0000000000000000, 0xf9cfcf1bcf36d483, 0x6e2b2bac2b458756, + 0xe17676c57697b3ec, 0xe68282328264b019, 0x28d6d67fd6fea9b1, 0xc31b1b6c1bd87736, + 0x74b5b5eeb5c15b77, 0xbeafaf86af112943, 0x1d6a6ab56a77dfd4, 0xea50505d50ba0da0, + 0x5745450945124c8a, 0x38f3f3ebf3cb18fb, 0xad3030c0309df060, 0xc4efef9bef2b74c3, + 0xda3f3ffc3fe5c37e, 0xc755554955921caa, 0xdba2a2b2a2791059, 0xe9eaea8fea0365c9, + 0x6a656589650fecca, 0x03babad2bab96869, 0x4a2f2fbc2f65935e, 0x8ec0c027c04ee79d, + 0x60dede5fdebe81a1, 0xfc1c1c701ce06c38, 0x46fdfdd3fdbb2ee7, 0x1f4d4d294d52649a, + 0x7692927292e4e039, 0xfa7575c9758fbcea, 0x3606061806301e0c, 0xae8a8a128a249809, + 0x4bb2b2f2b2f94079, 0x85e6e6bfe66359d1, 0x7e0e0e380e70361c, 0xe71f1f7c1ff8633e, + 0x556262956237f7c4, 0x3ad4d477d4eea3b5, 0x81a8a89aa829324d, 0x5296966296c4f431, + 0x62f9f9c3f99b3aef, 0xa3c5c533c566f697, 0x102525942535b14a, 0xab59597959f220b2, + 0xd084842a8454ae15, 0xc57272d572b7a7e4, 0xec3939e439d5dd72, 0x164c4c2d4c5a6198, + 0x945e5e655eca3bbc, 0x9f7878fd78e785f0, 0xe53838e038ddd870, 0x988c8c0a8c148605, + 0x17d1d163d1c6b2bf, 0xe4a5a5aea5410b57, 0xa1e2e2afe2434dd9, 0x4e616199612ff8c2, + 0x42b3b3f6b3f1457b, 0x342121842115a542, 0x089c9c4a9c94d625, 0xee1e1e781ef0663c, + 0x6143431143225286, 0xb1c7c73bc776fc93, 0x4ffcfcd7fcb32be5, 0x2404041004201408, + 0xe351515951b208a2, 0x2599995e99bcc72f, 0x226d6da96d4fc4da, 0x650d0d340d68391a, + 0x79fafacffa8335e9, 0x69dfdf5bdfb684a3, 0xa97e7ee57ed79bfc, 0x19242490243db448, + 0xfe3b3bec3bc5d776, 0x9aabab96ab313d4b, 0xf0cece1fce3ed181, 0x9911114411885522, + 0x838f8f068f0c8903, 0x044e4e254e4a6b9c, 0x66b7b7e6b7d15173, 0xe0ebeb8beb0b60cb, + 0xc13c3cf03cfdcc78, 0xfd81813e817cbf1f, 0x4094946a94d4fe35, 0x1cf7f7fbf7eb0cf3, + 0x18b9b9deb9a1676f, 0x8b13134c13985f26, 0x512c2cb02c7d9c58, 0x05d3d36bd3d6b8bb, + 0x8ce7e7bbe76b5cd3, 0x396e6ea56e57cbdc, 0xaac4c437c46ef395, 0x1b03030c03180f06, + 0xdc565645568a13ac, 0x5e44440d441a4988, 0xa07f7fe17fdf9efe, 0x88a9a99ea921374f, + 0x672a2aa82a4d8254, 0x0abbbbd6bbb16d6b, 0x87c1c123c146e29f, 0xf153535153a202a6, + 0x72dcdc57dcae8ba5, 0x530b0b2c0b582716, 0x019d9d4e9d9cd327, 0x2b6c6cad6c47c1d8, + 0xa43131c43195f562, 0xf37474cd7487b9e8, 0x15f6f6fff6e309f1, 0x4c464605460a438c, + 0xa5acac8aac092645, 0xb589891e893c970f, 0xb414145014a04428, 0xbae1e1a3e15b42df, + 0xa616165816b04e2c, 0xf73a3ae83acdd274, 0x066969b9696fd0d2, 0x4109092409482d12, + 0xd77070dd70a7ade0, 0x6fb6b6e2b6d95471, 0x1ed0d067d0ceb7bd, 0xd6eded93ed3b7ec7, + 0xe2cccc17cc2edb85, 0x68424215422a5784, 0x2c98985a98b4c22d, 0xeda4a4aaa4490e55, + 0x752828a0285d8850, 0x865c5c6d5cda31b8, 0x6bf8f8c7f8933fed, 0xc28686228644a411, }; -CONSTANT_VK u32a rch[R + 1] = +CONSTANT_VK u64a MT2[256] = { - 0x00000000, - 0x1823c6e8, - 0x36a6d2f5, - 0x60bc9b8e, - 0x1de0d7c2, - 0x157737e5, - 0x58c9290a, - 0xbd5d10f4, - 0xe427418b, - 0xfbee7c66, - 0xca2dbf07, + 0x30d818186018c078, 0x462623238c2305af, 0x91b8c6c63fc67ef9, 0xcdfbe8e887e8136f, + 0x13cb878726874ca1, 0x6d11b8b8dab8a962, 0x0209010104010805, 0x9e0d4f4f214f426e, + 0x6c9b3636d836adee, 0x51ffa6a6a2a65904, 0xb90cd2d26fd2debd, 0xf70ef5f5f3f5fb06, + 0xf2967979f979ef80, 0xde306f6fa16f5fce, 0x3f6d91917e91fcef, 0xa4f852525552aa07, + 0xc04760609d6027fd, 0x6535bcbccabc8976, 0x2b379b9b569baccd, 0x018a8e8e028e048c, + 0x5bd2a3a3b6a37115, 0x186c0c0c300c603c, 0xf6847b7bf17bff8a, 0x6a803535d435b5e1, + 0x3af51d1d741de869, 0xddb3e0e0a7e05347, 0xb321d7d77bd7f6ac, 0x999cc2c22fc25eed, + 0x5c432e2eb82e6d96, 0x96294b4b314b627a, 0xe15dfefedffea321, 0xaed5575741578216, + 0x2abd15155415a841, 0xeee87777c1779fb6, 0x6e923737dc37a5eb, 0xd79ee5e5b3e57b56, + 0x23139f9f469f8cd9, 0xfd23f0f0e7f0d317, 0x94204a4a354a6a7f, 0xa944dada4fda9e95, + 0xb0a258587d58fa25, 0x8fcfc9c903c906ca, 0x527c2929a429558d, 0x145a0a0a280a5022, + 0x7f50b1b1feb1e14f, 0x5dc9a0a0baa0691a, 0xd6146b6bb16b7fda, 0x17d985852e855cab, + 0x673cbdbdcebd8173, 0xba8f5d5d695dd234, 0x2090101040108050, 0xf507f4f4f7f4f303, + 0x8bddcbcb0bcb16c0, 0x7cd33e3ef83eedc6, 0x0a2d050514052811, 0xce78676781671fe6, + 0xd597e4e4b7e47353, 0x4e0227279c2725bb, 0x8273414119413258, 0x0ba78b8b168b2c9d, + 0x53f6a7a7a6a75101, 0xfab27d7de97dcf94, 0x374995956e95dcfb, 0xad56d8d847d88e9f, + 0xeb70fbfbcbfb8b30, 0xc1cdeeee9fee2371, 0xf8bb7c7ced7cc791, 0xcc716666856617e3, + 0xa77bdddd53dda68e, 0x2eaf17175c17b84b, 0x8e45474701470246, 0x211a9e9e429e84dc, + 0x89d4caca0fca1ec5, 0x5a582d2db42d7599, 0x632ebfbfc6bf9179, 0x0e3f07071c07381b, + 0x47acadad8ead0123, 0xb4b05a5a755aea2f, 0x1bef838336836cb5, 0x66b63333cc3385ff, + 0xc65c636391633ff2, 0x041202020802100a, 0x4993aaaa92aa3938, 0xe2de7171d971afa8, + 0x8dc6c8c807c80ecf, 0x32d119196419c87d, 0x923b494939497270, 0xaf5fd9d943d9869a, + 0xf931f2f2eff2c31d, 0xdba8e3e3abe34b48, 0xb6b95b5b715be22a, 0x0dbc88881a883492, + 0x293e9a9a529aa4c8, 0x4c0b262698262dbe, 0x64bf3232c8328dfa, 0x7d59b0b0fab0e94a, + 0xcff2e9e983e91b6a, 0x1e770f0f3c0f7833, 0xb733d5d573d5e6a6, 0x1df480803a8074ba, + 0x6127bebec2be997c, 0x87ebcdcd13cd26de, 0x68893434d034bde4, 0x903248483d487a75, + 0xe354ffffdbffab24, 0xf48d7a7af57af78f, 0x3d6490907a90f4ea, 0xbe9d5f5f615fc23e, + 0x403d202080201da0, 0xd00f6868bd6867d5, 0x34ca1a1a681ad072, 0x41b7aeae82ae192c, + 0x757db4b4eab4c95e, 0xa8ce54544d549a19, 0x3b7f93937693ece5, 0x442f222288220daa, + 0xc86364648d6407e9, 0xff2af1f1e3f1db12, 0xe6cc7373d173bfa2, 0x248212124812905a, + 0x807a40401d403a5d, 0x1048080820084028, 0x9b95c3c32bc356e8, 0xc5dfecec97ec337b, + 0xab4ddbdb4bdb9690, 0x5fc0a1a1bea1611f, 0x07918d8d0e8d1c83, 0x7ac83d3df43df5c9, + 0x335b97976697ccf1, 0x0000000000000000, 0x83f9cfcf1bcf36d4, 0x566e2b2bac2b4587, + 0xece17676c57697b3, 0x19e68282328264b0, 0xb128d6d67fd6fea9, 0x36c31b1b6c1bd877, + 0x7774b5b5eeb5c15b, 0x43beafaf86af1129, 0xd41d6a6ab56a77df, 0xa0ea50505d50ba0d, + 0x8a5745450945124c, 0xfb38f3f3ebf3cb18, 0x60ad3030c0309df0, 0xc3c4efef9bef2b74, + 0x7eda3f3ffc3fe5c3, 0xaac755554955921c, 0x59dba2a2b2a27910, 0xc9e9eaea8fea0365, + 0xca6a656589650fec, 0x6903babad2bab968, 0x5e4a2f2fbc2f6593, 0x9d8ec0c027c04ee7, + 0xa160dede5fdebe81, 0x38fc1c1c701ce06c, 0xe746fdfdd3fdbb2e, 0x9a1f4d4d294d5264, + 0x397692927292e4e0, 0xeafa7575c9758fbc, 0x0c3606061806301e, 0x09ae8a8a128a2498, + 0x794bb2b2f2b2f940, 0xd185e6e6bfe66359, 0x1c7e0e0e380e7036, 0x3ee71f1f7c1ff863, + 0xc4556262956237f7, 0xb53ad4d477d4eea3, 0x4d81a8a89aa82932, 0x315296966296c4f4, + 0xef62f9f9c3f99b3a, 0x97a3c5c533c566f6, 0x4a102525942535b1, 0xb2ab59597959f220, + 0x15d084842a8454ae, 0xe4c57272d572b7a7, 0x72ec3939e439d5dd, 0x98164c4c2d4c5a61, + 0xbc945e5e655eca3b, 0xf09f7878fd78e785, 0x70e53838e038ddd8, 0x05988c8c0a8c1486, + 0xbf17d1d163d1c6b2, 0x57e4a5a5aea5410b, 0xd9a1e2e2afe2434d, 0xc24e616199612ff8, + 0x7b42b3b3f6b3f145, 0x42342121842115a5, 0x25089c9c4a9c94d6, 0x3cee1e1e781ef066, + 0x8661434311432252, 0x93b1c7c73bc776fc, 0xe54ffcfcd7fcb32b, 0x0824040410042014, + 0xa2e351515951b208, 0x2f2599995e99bcc7, 0xda226d6da96d4fc4, 0x1a650d0d340d6839, + 0xe979fafacffa8335, 0xa369dfdf5bdfb684, 0xfca97e7ee57ed79b, 0x4819242490243db4, + 0x76fe3b3bec3bc5d7, 0x4b9aabab96ab313d, 0x81f0cece1fce3ed1, 0x2299111144118855, + 0x03838f8f068f0c89, 0x9c044e4e254e4a6b, 0x7366b7b7e6b7d151, 0xcbe0ebeb8beb0b60, + 0x78c13c3cf03cfdcc, 0x1ffd81813e817cbf, 0x354094946a94d4fe, 0xf31cf7f7fbf7eb0c, + 0x6f18b9b9deb9a167, 0x268b13134c13985f, 0x58512c2cb02c7d9c, 0xbb05d3d36bd3d6b8, + 0xd38ce7e7bbe76b5c, 0xdc396e6ea56e57cb, 0x95aac4c437c46ef3, 0x061b03030c03180f, + 0xacdc565645568a13, 0x885e44440d441a49, 0xfea07f7fe17fdf9e, 0x4f88a9a99ea92137, + 0x54672a2aa82a4d82, 0x6b0abbbbd6bbb16d, 0x9f87c1c123c146e2, 0xa6f153535153a202, + 0xa572dcdc57dcae8b, 0x16530b0b2c0b5827, 0x27019d9d4e9d9cd3, 0xd82b6c6cad6c47c1, + 0x62a43131c43195f5, 0xe8f37474cd7487b9, 0xf115f6f6fff6e309, 0x8c4c464605460a43, + 0x45a5acac8aac0926, 0x0fb589891e893c97, 0x28b414145014a044, 0xdfbae1e1a3e15b42, + 0x2ca616165816b04e, 0x74f73a3ae83acdd2, 0xd2066969b9696fd0, 0x124109092409482d, + 0xe0d77070dd70a7ad, 0x716fb6b6e2b6d954, 0xbd1ed0d067d0ceb7, 0xc7d6eded93ed3b7e, + 0x85e2cccc17cc2edb, 0x8468424215422a57, 0x2d2c98985a98b4c2, 0x55eda4a4aaa4490e, + 0x50752828a0285d88, 0xb8865c5c6d5cda31, 0xed6bf8f8c7f8933f, 0x11c28686228644a4, }; -CONSTANT_VK u32a rcl[R + 1] = +CONSTANT_VK u64a MT3[256] = { - 0x00000000, - 0x87b8014f, - 0x796f9152, - 0xa30c7b35, - 0x2e4bfe57, - 0x9ff04ada, - 0xb1a06b85, - 0xcb3e0567, - 0xa77d95d8, - 0xdd17479e, - 0xad5a8333, + 0x7830d818186018c0, 0xaf462623238c2305, 0xf991b8c6c63fc67e, 0x6fcdfbe8e887e813, + 0xa113cb878726874c, 0x626d11b8b8dab8a9, 0x0502090101040108, 0x6e9e0d4f4f214f42, + 0xee6c9b3636d836ad, 0x0451ffa6a6a2a659, 0xbdb90cd2d26fd2de, 0x06f70ef5f5f3f5fb, + 0x80f2967979f979ef, 0xcede306f6fa16f5f, 0xef3f6d91917e91fc, 0x07a4f852525552aa, + 0xfdc04760609d6027, 0x766535bcbccabc89, 0xcd2b379b9b569bac, 0x8c018a8e8e028e04, + 0x155bd2a3a3b6a371, 0x3c186c0c0c300c60, 0x8af6847b7bf17bff, 0xe16a803535d435b5, + 0x693af51d1d741de8, 0x47ddb3e0e0a7e053, 0xacb321d7d77bd7f6, 0xed999cc2c22fc25e, + 0x965c432e2eb82e6d, 0x7a96294b4b314b62, 0x21e15dfefedffea3, 0x16aed55757415782, + 0x412abd15155415a8, 0xb6eee87777c1779f, 0xeb6e923737dc37a5, 0x56d79ee5e5b3e57b, + 0xd923139f9f469f8c, 0x17fd23f0f0e7f0d3, 0x7f94204a4a354a6a, 0x95a944dada4fda9e, + 0x25b0a258587d58fa, 0xca8fcfc9c903c906, 0x8d527c2929a42955, 0x22145a0a0a280a50, + 0x4f7f50b1b1feb1e1, 0x1a5dc9a0a0baa069, 0xdad6146b6bb16b7f, 0xab17d985852e855c, + 0x73673cbdbdcebd81, 0x34ba8f5d5d695dd2, 0x5020901010401080, 0x03f507f4f4f7f4f3, + 0xc08bddcbcb0bcb16, 0xc67cd33e3ef83eed, 0x110a2d0505140528, 0xe6ce78676781671f, + 0x53d597e4e4b7e473, 0xbb4e0227279c2725, 0x5882734141194132, 0x9d0ba78b8b168b2c, + 0x0153f6a7a7a6a751, 0x94fab27d7de97dcf, 0xfb374995956e95dc, 0x9fad56d8d847d88e, + 0x30eb70fbfbcbfb8b, 0x71c1cdeeee9fee23, 0x91f8bb7c7ced7cc7, 0xe3cc716666856617, + 0x8ea77bdddd53dda6, 0x4b2eaf17175c17b8, 0x468e454747014702, 0xdc211a9e9e429e84, + 0xc589d4caca0fca1e, 0x995a582d2db42d75, 0x79632ebfbfc6bf91, 0x1b0e3f07071c0738, + 0x2347acadad8ead01, 0x2fb4b05a5a755aea, 0xb51bef838336836c, 0xff66b63333cc3385, + 0xf2c65c636391633f, 0x0a04120202080210, 0x384993aaaa92aa39, 0xa8e2de7171d971af, + 0xcf8dc6c8c807c80e, 0x7d32d119196419c8, 0x70923b4949394972, 0x9aaf5fd9d943d986, + 0x1df931f2f2eff2c3, 0x48dba8e3e3abe34b, 0x2ab6b95b5b715be2, 0x920dbc88881a8834, + 0xc8293e9a9a529aa4, 0xbe4c0b262698262d, 0xfa64bf3232c8328d, 0x4a7d59b0b0fab0e9, + 0x6acff2e9e983e91b, 0x331e770f0f3c0f78, 0xa6b733d5d573d5e6, 0xba1df480803a8074, + 0x7c6127bebec2be99, 0xde87ebcdcd13cd26, 0xe468893434d034bd, 0x75903248483d487a, + 0x24e354ffffdbffab, 0x8ff48d7a7af57af7, 0xea3d6490907a90f4, 0x3ebe9d5f5f615fc2, + 0xa0403d202080201d, 0xd5d00f6868bd6867, 0x7234ca1a1a681ad0, 0x2c41b7aeae82ae19, + 0x5e757db4b4eab4c9, 0x19a8ce54544d549a, 0xe53b7f93937693ec, 0xaa442f222288220d, + 0xe9c86364648d6407, 0x12ff2af1f1e3f1db, 0xa2e6cc7373d173bf, 0x5a24821212481290, + 0x5d807a40401d403a, 0x2810480808200840, 0xe89b95c3c32bc356, 0x7bc5dfecec97ec33, + 0x90ab4ddbdb4bdb96, 0x1f5fc0a1a1bea161, 0x8307918d8d0e8d1c, 0xc97ac83d3df43df5, + 0xf1335b97976697cc, 0x0000000000000000, 0xd483f9cfcf1bcf36, 0x87566e2b2bac2b45, + 0xb3ece17676c57697, 0xb019e68282328264, 0xa9b128d6d67fd6fe, 0x7736c31b1b6c1bd8, + 0x5b7774b5b5eeb5c1, 0x2943beafaf86af11, 0xdfd41d6a6ab56a77, 0x0da0ea50505d50ba, + 0x4c8a574545094512, 0x18fb38f3f3ebf3cb, 0xf060ad3030c0309d, 0x74c3c4efef9bef2b, + 0xc37eda3f3ffc3fe5, 0x1caac75555495592, 0x1059dba2a2b2a279, 0x65c9e9eaea8fea03, + 0xecca6a656589650f, 0x686903babad2bab9, 0x935e4a2f2fbc2f65, 0xe79d8ec0c027c04e, + 0x81a160dede5fdebe, 0x6c38fc1c1c701ce0, 0x2ee746fdfdd3fdbb, 0x649a1f4d4d294d52, + 0xe0397692927292e4, 0xbceafa7575c9758f, 0x1e0c360606180630, 0x9809ae8a8a128a24, + 0x40794bb2b2f2b2f9, 0x59d185e6e6bfe663, 0x361c7e0e0e380e70, 0x633ee71f1f7c1ff8, + 0xf7c4556262956237, 0xa3b53ad4d477d4ee, 0x324d81a8a89aa829, 0xf4315296966296c4, + 0x3aef62f9f9c3f99b, 0xf697a3c5c533c566, 0xb14a102525942535, 0x20b2ab59597959f2, + 0xae15d084842a8454, 0xa7e4c57272d572b7, 0xdd72ec3939e439d5, 0x6198164c4c2d4c5a, + 0x3bbc945e5e655eca, 0x85f09f7878fd78e7, 0xd870e53838e038dd, 0x8605988c8c0a8c14, + 0xb2bf17d1d163d1c6, 0x0b57e4a5a5aea541, 0x4dd9a1e2e2afe243, 0xf8c24e616199612f, + 0x457b42b3b3f6b3f1, 0xa542342121842115, 0xd625089c9c4a9c94, 0x663cee1e1e781ef0, + 0x5286614343114322, 0xfc93b1c7c73bc776, 0x2be54ffcfcd7fcb3, 0x1408240404100420, + 0x08a2e351515951b2, 0xc72f2599995e99bc, 0xc4da226d6da96d4f, 0x391a650d0d340d68, + 0x35e979fafacffa83, 0x84a369dfdf5bdfb6, 0x9bfca97e7ee57ed7, 0xb44819242490243d, + 0xd776fe3b3bec3bc5, 0x3d4b9aabab96ab31, 0xd181f0cece1fce3e, 0x5522991111441188, + 0x8903838f8f068f0c, 0x6b9c044e4e254e4a, 0x517366b7b7e6b7d1, 0x60cbe0ebeb8beb0b, + 0xcc78c13c3cf03cfd, 0xbf1ffd81813e817c, 0xfe354094946a94d4, 0x0cf31cf7f7fbf7eb, + 0x676f18b9b9deb9a1, 0x5f268b13134c1398, 0x9c58512c2cb02c7d, 0xb8bb05d3d36bd3d6, + 0x5cd38ce7e7bbe76b, 0xcbdc396e6ea56e57, 0xf395aac4c437c46e, 0x0f061b03030c0318, + 0x13acdc565645568a, 0x49885e44440d441a, 0x9efea07f7fe17fdf, 0x374f88a9a99ea921, + 0x8254672a2aa82a4d, 0x6d6b0abbbbd6bbb1, 0xe29f87c1c123c146, 0x02a6f153535153a2, + 0x8ba572dcdc57dcae, 0x2716530b0b2c0b58, 0xd327019d9d4e9d9c, 0xc1d82b6c6cad6c47, + 0xf562a43131c43195, 0xb9e8f37474cd7487, 0x09f115f6f6fff6e3, 0x438c4c464605460a, + 0x2645a5acac8aac09, 0x970fb589891e893c, 0x4428b414145014a0, 0x42dfbae1e1a3e15b, + 0x4e2ca616165816b0, 0xd274f73a3ae83acd, 0xd0d2066969b9696f, 0x2d12410909240948, + 0xade0d77070dd70a7, 0x54716fb6b6e2b6d9, 0xb7bd1ed0d067d0ce, 0x7ec7d6eded93ed3b, + 0xdb85e2cccc17cc2e, 0x578468424215422a, 0xc22d2c98985a98b4, 0x0e55eda4a4aaa449, + 0x8850752828a0285d, 0x31b8865c5c6d5cda, 0x3fed6bf8f8c7f893, 0xa411c28686228644, +}; + +CONSTANT_VK u64a MT4[256] = +{ + 0xc07830d818186018, 0x05af462623238c23, 0x7ef991b8c6c63fc6, 0x136fcdfbe8e887e8, + 0x4ca113cb87872687, 0xa9626d11b8b8dab8, 0x0805020901010401, 0x426e9e0d4f4f214f, + 0xadee6c9b3636d836, 0x590451ffa6a6a2a6, 0xdebdb90cd2d26fd2, 0xfb06f70ef5f5f3f5, + 0xef80f2967979f979, 0x5fcede306f6fa16f, 0xfcef3f6d91917e91, 0xaa07a4f852525552, + 0x27fdc04760609d60, 0x89766535bcbccabc, 0xaccd2b379b9b569b, 0x048c018a8e8e028e, + 0x71155bd2a3a3b6a3, 0x603c186c0c0c300c, 0xff8af6847b7bf17b, 0xb5e16a803535d435, + 0xe8693af51d1d741d, 0x5347ddb3e0e0a7e0, 0xf6acb321d7d77bd7, 0x5eed999cc2c22fc2, + 0x6d965c432e2eb82e, 0x627a96294b4b314b, 0xa321e15dfefedffe, 0x8216aed557574157, + 0xa8412abd15155415, 0x9fb6eee87777c177, 0xa5eb6e923737dc37, 0x7b56d79ee5e5b3e5, + 0x8cd923139f9f469f, 0xd317fd23f0f0e7f0, 0x6a7f94204a4a354a, 0x9e95a944dada4fda, + 0xfa25b0a258587d58, 0x06ca8fcfc9c903c9, 0x558d527c2929a429, 0x5022145a0a0a280a, + 0xe14f7f50b1b1feb1, 0x691a5dc9a0a0baa0, 0x7fdad6146b6bb16b, 0x5cab17d985852e85, + 0x8173673cbdbdcebd, 0xd234ba8f5d5d695d, 0x8050209010104010, 0xf303f507f4f4f7f4, + 0x16c08bddcbcb0bcb, 0xedc67cd33e3ef83e, 0x28110a2d05051405, 0x1fe6ce7867678167, + 0x7353d597e4e4b7e4, 0x25bb4e0227279c27, 0x3258827341411941, 0x2c9d0ba78b8b168b, + 0x510153f6a7a7a6a7, 0xcf94fab27d7de97d, 0xdcfb374995956e95, 0x8e9fad56d8d847d8, + 0x8b30eb70fbfbcbfb, 0x2371c1cdeeee9fee, 0xc791f8bb7c7ced7c, 0x17e3cc7166668566, + 0xa68ea77bdddd53dd, 0xb84b2eaf17175c17, 0x02468e4547470147, 0x84dc211a9e9e429e, + 0x1ec589d4caca0fca, 0x75995a582d2db42d, 0x9179632ebfbfc6bf, 0x381b0e3f07071c07, + 0x012347acadad8ead, 0xea2fb4b05a5a755a, 0x6cb51bef83833683, 0x85ff66b63333cc33, + 0x3ff2c65c63639163, 0x100a041202020802, 0x39384993aaaa92aa, 0xafa8e2de7171d971, + 0x0ecf8dc6c8c807c8, 0xc87d32d119196419, 0x7270923b49493949, 0x869aaf5fd9d943d9, + 0xc31df931f2f2eff2, 0x4b48dba8e3e3abe3, 0xe22ab6b95b5b715b, 0x34920dbc88881a88, + 0xa4c8293e9a9a529a, 0x2dbe4c0b26269826, 0x8dfa64bf3232c832, 0xe94a7d59b0b0fab0, + 0x1b6acff2e9e983e9, 0x78331e770f0f3c0f, 0xe6a6b733d5d573d5, 0x74ba1df480803a80, + 0x997c6127bebec2be, 0x26de87ebcdcd13cd, 0xbde468893434d034, 0x7a75903248483d48, + 0xab24e354ffffdbff, 0xf78ff48d7a7af57a, 0xf4ea3d6490907a90, 0xc23ebe9d5f5f615f, + 0x1da0403d20208020, 0x67d5d00f6868bd68, 0xd07234ca1a1a681a, 0x192c41b7aeae82ae, + 0xc95e757db4b4eab4, 0x9a19a8ce54544d54, 0xece53b7f93937693, 0x0daa442f22228822, + 0x07e9c86364648d64, 0xdb12ff2af1f1e3f1, 0xbfa2e6cc7373d173, 0x905a248212124812, + 0x3a5d807a40401d40, 0x4028104808082008, 0x56e89b95c3c32bc3, 0x337bc5dfecec97ec, + 0x9690ab4ddbdb4bdb, 0x611f5fc0a1a1bea1, 0x1c8307918d8d0e8d, 0xf5c97ac83d3df43d, + 0xccf1335b97976697, 0x0000000000000000, 0x36d483f9cfcf1bcf, 0x4587566e2b2bac2b, + 0x97b3ece17676c576, 0x64b019e682823282, 0xfea9b128d6d67fd6, 0xd87736c31b1b6c1b, + 0xc15b7774b5b5eeb5, 0x112943beafaf86af, 0x77dfd41d6a6ab56a, 0xba0da0ea50505d50, + 0x124c8a5745450945, 0xcb18fb38f3f3ebf3, 0x9df060ad3030c030, 0x2b74c3c4efef9bef, + 0xe5c37eda3f3ffc3f, 0x921caac755554955, 0x791059dba2a2b2a2, 0x0365c9e9eaea8fea, + 0x0fecca6a65658965, 0xb9686903babad2ba, 0x65935e4a2f2fbc2f, 0x4ee79d8ec0c027c0, + 0xbe81a160dede5fde, 0xe06c38fc1c1c701c, 0xbb2ee746fdfdd3fd, 0x52649a1f4d4d294d, + 0xe4e0397692927292, 0x8fbceafa7575c975, 0x301e0c3606061806, 0x249809ae8a8a128a, + 0xf940794bb2b2f2b2, 0x6359d185e6e6bfe6, 0x70361c7e0e0e380e, 0xf8633ee71f1f7c1f, + 0x37f7c45562629562, 0xeea3b53ad4d477d4, 0x29324d81a8a89aa8, 0xc4f4315296966296, + 0x9b3aef62f9f9c3f9, 0x66f697a3c5c533c5, 0x35b14a1025259425, 0xf220b2ab59597959, + 0x54ae15d084842a84, 0xb7a7e4c57272d572, 0xd5dd72ec3939e439, 0x5a6198164c4c2d4c, + 0xca3bbc945e5e655e, 0xe785f09f7878fd78, 0xddd870e53838e038, 0x148605988c8c0a8c, + 0xc6b2bf17d1d163d1, 0x410b57e4a5a5aea5, 0x434dd9a1e2e2afe2, 0x2ff8c24e61619961, + 0xf1457b42b3b3f6b3, 0x15a5423421218421, 0x94d625089c9c4a9c, 0xf0663cee1e1e781e, + 0x2252866143431143, 0x76fc93b1c7c73bc7, 0xb32be54ffcfcd7fc, 0x2014082404041004, + 0xb208a2e351515951, 0xbcc72f2599995e99, 0x4fc4da226d6da96d, 0x68391a650d0d340d, + 0x8335e979fafacffa, 0xb684a369dfdf5bdf, 0xd79bfca97e7ee57e, 0x3db4481924249024, + 0xc5d776fe3b3bec3b, 0x313d4b9aabab96ab, 0x3ed181f0cece1fce, 0x8855229911114411, + 0x0c8903838f8f068f, 0x4a6b9c044e4e254e, 0xd1517366b7b7e6b7, 0x0b60cbe0ebeb8beb, + 0xfdcc78c13c3cf03c, 0x7cbf1ffd81813e81, 0xd4fe354094946a94, 0xeb0cf31cf7f7fbf7, + 0xa1676f18b9b9deb9, 0x985f268b13134c13, 0x7d9c58512c2cb02c, 0xd6b8bb05d3d36bd3, + 0x6b5cd38ce7e7bbe7, 0x57cbdc396e6ea56e, 0x6ef395aac4c437c4, 0x180f061b03030c03, + 0x8a13acdc56564556, 0x1a49885e44440d44, 0xdf9efea07f7fe17f, 0x21374f88a9a99ea9, + 0x4d8254672a2aa82a, 0xb16d6b0abbbbd6bb, 0x46e29f87c1c123c1, 0xa202a6f153535153, + 0xae8ba572dcdc57dc, 0x582716530b0b2c0b, 0x9cd327019d9d4e9d, 0x47c1d82b6c6cad6c, + 0x95f562a43131c431, 0x87b9e8f37474cd74, 0xe309f115f6f6fff6, 0x0a438c4c46460546, + 0x092645a5acac8aac, 0x3c970fb589891e89, 0xa04428b414145014, 0x5b42dfbae1e1a3e1, + 0xb04e2ca616165816, 0xcdd274f73a3ae83a, 0x6fd0d2066969b969, 0x482d124109092409, + 0xa7ade0d77070dd70, 0xd954716fb6b6e2b6, 0xceb7bd1ed0d067d0, 0x3b7ec7d6eded93ed, + 0x2edb85e2cccc17cc, 0x2a57846842421542, 0xb4c22d2c98985a98, 0x490e55eda4a4aaa4, + 0x5d8850752828a028, 0xda31b8865c5c6d5c, 0x933fed6bf8f8c7f8, 0x44a411c286862286, +}; + +CONSTANT_VK u64a MT5[256] = +{ + 0x18c07830d8181860, 0x2305af462623238c, 0xc67ef991b8c6c63f, 0xe8136fcdfbe8e887, + 0x874ca113cb878726, 0xb8a9626d11b8b8da, 0x0108050209010104, 0x4f426e9e0d4f4f21, + 0x36adee6c9b3636d8, 0xa6590451ffa6a6a2, 0xd2debdb90cd2d26f, 0xf5fb06f70ef5f5f3, + 0x79ef80f2967979f9, 0x6f5fcede306f6fa1, 0x91fcef3f6d91917e, 0x52aa07a4f8525255, + 0x6027fdc04760609d, 0xbc89766535bcbcca, 0x9baccd2b379b9b56, 0x8e048c018a8e8e02, + 0xa371155bd2a3a3b6, 0x0c603c186c0c0c30, 0x7bff8af6847b7bf1, 0x35b5e16a803535d4, + 0x1de8693af51d1d74, 0xe05347ddb3e0e0a7, 0xd7f6acb321d7d77b, 0xc25eed999cc2c22f, + 0x2e6d965c432e2eb8, 0x4b627a96294b4b31, 0xfea321e15dfefedf, 0x578216aed5575741, + 0x15a8412abd151554, 0x779fb6eee87777c1, 0x37a5eb6e923737dc, 0xe57b56d79ee5e5b3, + 0x9f8cd923139f9f46, 0xf0d317fd23f0f0e7, 0x4a6a7f94204a4a35, 0xda9e95a944dada4f, + 0x58fa25b0a258587d, 0xc906ca8fcfc9c903, 0x29558d527c2929a4, 0x0a5022145a0a0a28, + 0xb1e14f7f50b1b1fe, 0xa0691a5dc9a0a0ba, 0x6b7fdad6146b6bb1, 0x855cab17d985852e, + 0xbd8173673cbdbdce, 0x5dd234ba8f5d5d69, 0x1080502090101040, 0xf4f303f507f4f4f7, + 0xcb16c08bddcbcb0b, 0x3eedc67cd33e3ef8, 0x0528110a2d050514, 0x671fe6ce78676781, + 0xe47353d597e4e4b7, 0x2725bb4e0227279c, 0x4132588273414119, 0x8b2c9d0ba78b8b16, + 0xa7510153f6a7a7a6, 0x7dcf94fab27d7de9, 0x95dcfb374995956e, 0xd88e9fad56d8d847, + 0xfb8b30eb70fbfbcb, 0xee2371c1cdeeee9f, 0x7cc791f8bb7c7ced, 0x6617e3cc71666685, + 0xdda68ea77bdddd53, 0x17b84b2eaf17175c, 0x4702468e45474701, 0x9e84dc211a9e9e42, + 0xca1ec589d4caca0f, 0x2d75995a582d2db4, 0xbf9179632ebfbfc6, 0x07381b0e3f07071c, + 0xad012347acadad8e, 0x5aea2fb4b05a5a75, 0x836cb51bef838336, 0x3385ff66b63333cc, + 0x633ff2c65c636391, 0x02100a0412020208, 0xaa39384993aaaa92, 0x71afa8e2de7171d9, + 0xc80ecf8dc6c8c807, 0x19c87d32d1191964, 0x497270923b494939, 0xd9869aaf5fd9d943, + 0xf2c31df931f2f2ef, 0xe34b48dba8e3e3ab, 0x5be22ab6b95b5b71, 0x8834920dbc88881a, + 0x9aa4c8293e9a9a52, 0x262dbe4c0b262698, 0x328dfa64bf3232c8, 0xb0e94a7d59b0b0fa, + 0xe91b6acff2e9e983, 0x0f78331e770f0f3c, 0xd5e6a6b733d5d573, 0x8074ba1df480803a, + 0xbe997c6127bebec2, 0xcd26de87ebcdcd13, 0x34bde468893434d0, 0x487a75903248483d, + 0xffab24e354ffffdb, 0x7af78ff48d7a7af5, 0x90f4ea3d6490907a, 0x5fc23ebe9d5f5f61, + 0x201da0403d202080, 0x6867d5d00f6868bd, 0x1ad07234ca1a1a68, 0xae192c41b7aeae82, + 0xb4c95e757db4b4ea, 0x549a19a8ce54544d, 0x93ece53b7f939376, 0x220daa442f222288, + 0x6407e9c86364648d, 0xf1db12ff2af1f1e3, 0x73bfa2e6cc7373d1, 0x12905a2482121248, + 0x403a5d807a40401d, 0x0840281048080820, 0xc356e89b95c3c32b, 0xec337bc5dfecec97, + 0xdb9690ab4ddbdb4b, 0xa1611f5fc0a1a1be, 0x8d1c8307918d8d0e, 0x3df5c97ac83d3df4, + 0x97ccf1335b979766, 0x0000000000000000, 0xcf36d483f9cfcf1b, 0x2b4587566e2b2bac, + 0x7697b3ece17676c5, 0x8264b019e6828232, 0xd6fea9b128d6d67f, 0x1bd87736c31b1b6c, + 0xb5c15b7774b5b5ee, 0xaf112943beafaf86, 0x6a77dfd41d6a6ab5, 0x50ba0da0ea50505d, + 0x45124c8a57454509, 0xf3cb18fb38f3f3eb, 0x309df060ad3030c0, 0xef2b74c3c4efef9b, + 0x3fe5c37eda3f3ffc, 0x55921caac7555549, 0xa2791059dba2a2b2, 0xea0365c9e9eaea8f, + 0x650fecca6a656589, 0xbab9686903babad2, 0x2f65935e4a2f2fbc, 0xc04ee79d8ec0c027, + 0xdebe81a160dede5f, 0x1ce06c38fc1c1c70, 0xfdbb2ee746fdfdd3, 0x4d52649a1f4d4d29, + 0x92e4e03976929272, 0x758fbceafa7575c9, 0x06301e0c36060618, 0x8a249809ae8a8a12, + 0xb2f940794bb2b2f2, 0xe66359d185e6e6bf, 0x0e70361c7e0e0e38, 0x1ff8633ee71f1f7c, + 0x6237f7c455626295, 0xd4eea3b53ad4d477, 0xa829324d81a8a89a, 0x96c4f43152969662, + 0xf99b3aef62f9f9c3, 0xc566f697a3c5c533, 0x2535b14a10252594, 0x59f220b2ab595979, + 0x8454ae15d084842a, 0x72b7a7e4c57272d5, 0x39d5dd72ec3939e4, 0x4c5a6198164c4c2d, + 0x5eca3bbc945e5e65, 0x78e785f09f7878fd, 0x38ddd870e53838e0, 0x8c148605988c8c0a, + 0xd1c6b2bf17d1d163, 0xa5410b57e4a5a5ae, 0xe2434dd9a1e2e2af, 0x612ff8c24e616199, + 0xb3f1457b42b3b3f6, 0x2115a54234212184, 0x9c94d625089c9c4a, 0x1ef0663cee1e1e78, + 0x4322528661434311, 0xc776fc93b1c7c73b, 0xfcb32be54ffcfcd7, 0x0420140824040410, + 0x51b208a2e3515159, 0x99bcc72f2599995e, 0x6d4fc4da226d6da9, 0x0d68391a650d0d34, + 0xfa8335e979fafacf, 0xdfb684a369dfdf5b, 0x7ed79bfca97e7ee5, 0x243db44819242490, + 0x3bc5d776fe3b3bec, 0xab313d4b9aabab96, 0xce3ed181f0cece1f, 0x1188552299111144, + 0x8f0c8903838f8f06, 0x4e4a6b9c044e4e25, 0xb7d1517366b7b7e6, 0xeb0b60cbe0ebeb8b, + 0x3cfdcc78c13c3cf0, 0x817cbf1ffd81813e, 0x94d4fe354094946a, 0xf7eb0cf31cf7f7fb, + 0xb9a1676f18b9b9de, 0x13985f268b13134c, 0x2c7d9c58512c2cb0, 0xd3d6b8bb05d3d36b, + 0xe76b5cd38ce7e7bb, 0x6e57cbdc396e6ea5, 0xc46ef395aac4c437, 0x03180f061b03030c, + 0x568a13acdc565645, 0x441a49885e44440d, 0x7fdf9efea07f7fe1, 0xa921374f88a9a99e, + 0x2a4d8254672a2aa8, 0xbbb16d6b0abbbbd6, 0xc146e29f87c1c123, 0x53a202a6f1535351, + 0xdcae8ba572dcdc57, 0x0b582716530b0b2c, 0x9d9cd327019d9d4e, 0x6c47c1d82b6c6cad, + 0x3195f562a43131c4, 0x7487b9e8f37474cd, 0xf6e309f115f6f6ff, 0x460a438c4c464605, + 0xac092645a5acac8a, 0x893c970fb589891e, 0x14a04428b4141450, 0xe15b42dfbae1e1a3, + 0x16b04e2ca6161658, 0x3acdd274f73a3ae8, 0x696fd0d2066969b9, 0x09482d1241090924, + 0x70a7ade0d77070dd, 0xb6d954716fb6b6e2, 0xd0ceb7bd1ed0d067, 0xed3b7ec7d6eded93, + 0xcc2edb85e2cccc17, 0x422a578468424215, 0x98b4c22d2c98985a, 0xa4490e55eda4a4aa, + 0x285d8850752828a0, 0x5cda31b8865c5c6d, 0xf8933fed6bf8f8c7, 0x8644a411c2868622, +}; + +CONSTANT_VK u64a MT6[256] = +{ + 0x6018c07830d81818, 0x8c2305af46262323, 0x3fc67ef991b8c6c6, 0x87e8136fcdfbe8e8, + 0x26874ca113cb8787, 0xdab8a9626d11b8b8, 0x0401080502090101, 0x214f426e9e0d4f4f, + 0xd836adee6c9b3636, 0xa2a6590451ffa6a6, 0x6fd2debdb90cd2d2, 0xf3f5fb06f70ef5f5, + 0xf979ef80f2967979, 0xa16f5fcede306f6f, 0x7e91fcef3f6d9191, 0x5552aa07a4f85252, + 0x9d6027fdc0476060, 0xcabc89766535bcbc, 0x569baccd2b379b9b, 0x028e048c018a8e8e, + 0xb6a371155bd2a3a3, 0x300c603c186c0c0c, 0xf17bff8af6847b7b, 0xd435b5e16a803535, + 0x741de8693af51d1d, 0xa7e05347ddb3e0e0, 0x7bd7f6acb321d7d7, 0x2fc25eed999cc2c2, + 0xb82e6d965c432e2e, 0x314b627a96294b4b, 0xdffea321e15dfefe, 0x41578216aed55757, + 0x5415a8412abd1515, 0xc1779fb6eee87777, 0xdc37a5eb6e923737, 0xb3e57b56d79ee5e5, + 0x469f8cd923139f9f, 0xe7f0d317fd23f0f0, 0x354a6a7f94204a4a, 0x4fda9e95a944dada, + 0x7d58fa25b0a25858, 0x03c906ca8fcfc9c9, 0xa429558d527c2929, 0x280a5022145a0a0a, + 0xfeb1e14f7f50b1b1, 0xbaa0691a5dc9a0a0, 0xb16b7fdad6146b6b, 0x2e855cab17d98585, + 0xcebd8173673cbdbd, 0x695dd234ba8f5d5d, 0x4010805020901010, 0xf7f4f303f507f4f4, + 0x0bcb16c08bddcbcb, 0xf83eedc67cd33e3e, 0x140528110a2d0505, 0x81671fe6ce786767, + 0xb7e47353d597e4e4, 0x9c2725bb4e022727, 0x1941325882734141, 0x168b2c9d0ba78b8b, + 0xa6a7510153f6a7a7, 0xe97dcf94fab27d7d, 0x6e95dcfb37499595, 0x47d88e9fad56d8d8, + 0xcbfb8b30eb70fbfb, 0x9fee2371c1cdeeee, 0xed7cc791f8bb7c7c, 0x856617e3cc716666, + 0x53dda68ea77bdddd, 0x5c17b84b2eaf1717, 0x014702468e454747, 0x429e84dc211a9e9e, + 0x0fca1ec589d4caca, 0xb42d75995a582d2d, 0xc6bf9179632ebfbf, 0x1c07381b0e3f0707, + 0x8ead012347acadad, 0x755aea2fb4b05a5a, 0x36836cb51bef8383, 0xcc3385ff66b63333, + 0x91633ff2c65c6363, 0x0802100a04120202, 0x92aa39384993aaaa, 0xd971afa8e2de7171, + 0x07c80ecf8dc6c8c8, 0x6419c87d32d11919, 0x39497270923b4949, 0x43d9869aaf5fd9d9, + 0xeff2c31df931f2f2, 0xabe34b48dba8e3e3, 0x715be22ab6b95b5b, 0x1a8834920dbc8888, + 0x529aa4c8293e9a9a, 0x98262dbe4c0b2626, 0xc8328dfa64bf3232, 0xfab0e94a7d59b0b0, + 0x83e91b6acff2e9e9, 0x3c0f78331e770f0f, 0x73d5e6a6b733d5d5, 0x3a8074ba1df48080, + 0xc2be997c6127bebe, 0x13cd26de87ebcdcd, 0xd034bde468893434, 0x3d487a7590324848, + 0xdbffab24e354ffff, 0xf57af78ff48d7a7a, 0x7a90f4ea3d649090, 0x615fc23ebe9d5f5f, + 0x80201da0403d2020, 0xbd6867d5d00f6868, 0x681ad07234ca1a1a, 0x82ae192c41b7aeae, + 0xeab4c95e757db4b4, 0x4d549a19a8ce5454, 0x7693ece53b7f9393, 0x88220daa442f2222, + 0x8d6407e9c8636464, 0xe3f1db12ff2af1f1, 0xd173bfa2e6cc7373, 0x4812905a24821212, + 0x1d403a5d807a4040, 0x2008402810480808, 0x2bc356e89b95c3c3, 0x97ec337bc5dfecec, + 0x4bdb9690ab4ddbdb, 0xbea1611f5fc0a1a1, 0x0e8d1c8307918d8d, 0xf43df5c97ac83d3d, + 0x6697ccf1335b9797, 0x0000000000000000, 0x1bcf36d483f9cfcf, 0xac2b4587566e2b2b, + 0xc57697b3ece17676, 0x328264b019e68282, 0x7fd6fea9b128d6d6, 0x6c1bd87736c31b1b, + 0xeeb5c15b7774b5b5, 0x86af112943beafaf, 0xb56a77dfd41d6a6a, 0x5d50ba0da0ea5050, + 0x0945124c8a574545, 0xebf3cb18fb38f3f3, 0xc0309df060ad3030, 0x9bef2b74c3c4efef, + 0xfc3fe5c37eda3f3f, 0x4955921caac75555, 0xb2a2791059dba2a2, 0x8fea0365c9e9eaea, + 0x89650fecca6a6565, 0xd2bab9686903baba, 0xbc2f65935e4a2f2f, 0x27c04ee79d8ec0c0, + 0x5fdebe81a160dede, 0x701ce06c38fc1c1c, 0xd3fdbb2ee746fdfd, 0x294d52649a1f4d4d, + 0x7292e4e039769292, 0xc9758fbceafa7575, 0x1806301e0c360606, 0x128a249809ae8a8a, + 0xf2b2f940794bb2b2, 0xbfe66359d185e6e6, 0x380e70361c7e0e0e, 0x7c1ff8633ee71f1f, + 0x956237f7c4556262, 0x77d4eea3b53ad4d4, 0x9aa829324d81a8a8, 0x6296c4f431529696, + 0xc3f99b3aef62f9f9, 0x33c566f697a3c5c5, 0x942535b14a102525, 0x7959f220b2ab5959, + 0x2a8454ae15d08484, 0xd572b7a7e4c57272, 0xe439d5dd72ec3939, 0x2d4c5a6198164c4c, + 0x655eca3bbc945e5e, 0xfd78e785f09f7878, 0xe038ddd870e53838, 0x0a8c148605988c8c, + 0x63d1c6b2bf17d1d1, 0xaea5410b57e4a5a5, 0xafe2434dd9a1e2e2, 0x99612ff8c24e6161, + 0xf6b3f1457b42b3b3, 0x842115a542342121, 0x4a9c94d625089c9c, 0x781ef0663cee1e1e, + 0x1143225286614343, 0x3bc776fc93b1c7c7, 0xd7fcb32be54ffcfc, 0x1004201408240404, + 0x5951b208a2e35151, 0x5e99bcc72f259999, 0xa96d4fc4da226d6d, 0x340d68391a650d0d, + 0xcffa8335e979fafa, 0x5bdfb684a369dfdf, 0xe57ed79bfca97e7e, 0x90243db448192424, + 0xec3bc5d776fe3b3b, 0x96ab313d4b9aabab, 0x1fce3ed181f0cece, 0x4411885522991111, + 0x068f0c8903838f8f, 0x254e4a6b9c044e4e, 0xe6b7d1517366b7b7, 0x8beb0b60cbe0ebeb, + 0xf03cfdcc78c13c3c, 0x3e817cbf1ffd8181, 0x6a94d4fe35409494, 0xfbf7eb0cf31cf7f7, + 0xdeb9a1676f18b9b9, 0x4c13985f268b1313, 0xb02c7d9c58512c2c, 0x6bd3d6b8bb05d3d3, + 0xbbe76b5cd38ce7e7, 0xa56e57cbdc396e6e, 0x37c46ef395aac4c4, 0x0c03180f061b0303, + 0x45568a13acdc5656, 0x0d441a49885e4444, 0xe17fdf9efea07f7f, 0x9ea921374f88a9a9, + 0xa82a4d8254672a2a, 0xd6bbb16d6b0abbbb, 0x23c146e29f87c1c1, 0x5153a202a6f15353, + 0x57dcae8ba572dcdc, 0x2c0b582716530b0b, 0x4e9d9cd327019d9d, 0xad6c47c1d82b6c6c, + 0xc43195f562a43131, 0xcd7487b9e8f37474, 0xfff6e309f115f6f6, 0x05460a438c4c4646, + 0x8aac092645a5acac, 0x1e893c970fb58989, 0x5014a04428b41414, 0xa3e15b42dfbae1e1, + 0x5816b04e2ca61616, 0xe83acdd274f73a3a, 0xb9696fd0d2066969, 0x2409482d12410909, + 0xdd70a7ade0d77070, 0xe2b6d954716fb6b6, 0x67d0ceb7bd1ed0d0, 0x93ed3b7ec7d6eded, + 0x17cc2edb85e2cccc, 0x15422a5784684242, 0x5a98b4c22d2c9898, 0xaaa4490e55eda4a4, + 0xa0285d8850752828, 0x6d5cda31b8865c5c, 0xc7f8933fed6bf8f8, 0x228644a411c28686, +}; + +CONSTANT_VK u64a MT7[256] = +{ + 0x186018c07830d818, 0x238c2305af462623, 0xc63fc67ef991b8c6, 0xe887e8136fcdfbe8, + 0x8726874ca113cb87, 0xb8dab8a9626d11b8, 0x0104010805020901, 0x4f214f426e9e0d4f, + 0x36d836adee6c9b36, 0xa6a2a6590451ffa6, 0xd26fd2debdb90cd2, 0xf5f3f5fb06f70ef5, + 0x79f979ef80f29679, 0x6fa16f5fcede306f, 0x917e91fcef3f6d91, 0x525552aa07a4f852, + 0x609d6027fdc04760, 0xbccabc89766535bc, 0x9b569baccd2b379b, 0x8e028e048c018a8e, + 0xa3b6a371155bd2a3, 0x0c300c603c186c0c, 0x7bf17bff8af6847b, 0x35d435b5e16a8035, + 0x1d741de8693af51d, 0xe0a7e05347ddb3e0, 0xd77bd7f6acb321d7, 0xc22fc25eed999cc2, + 0x2eb82e6d965c432e, 0x4b314b627a96294b, 0xfedffea321e15dfe, 0x5741578216aed557, + 0x155415a8412abd15, 0x77c1779fb6eee877, 0x37dc37a5eb6e9237, 0xe5b3e57b56d79ee5, + 0x9f469f8cd923139f, 0xf0e7f0d317fd23f0, 0x4a354a6a7f94204a, 0xda4fda9e95a944da, + 0x587d58fa25b0a258, 0xc903c906ca8fcfc9, 0x29a429558d527c29, 0x0a280a5022145a0a, + 0xb1feb1e14f7f50b1, 0xa0baa0691a5dc9a0, 0x6bb16b7fdad6146b, 0x852e855cab17d985, + 0xbdcebd8173673cbd, 0x5d695dd234ba8f5d, 0x1040108050209010, 0xf4f7f4f303f507f4, + 0xcb0bcb16c08bddcb, 0x3ef83eedc67cd33e, 0x05140528110a2d05, 0x6781671fe6ce7867, + 0xe4b7e47353d597e4, 0x279c2725bb4e0227, 0x4119413258827341, 0x8b168b2c9d0ba78b, + 0xa7a6a7510153f6a7, 0x7de97dcf94fab27d, 0x956e95dcfb374995, 0xd847d88e9fad56d8, + 0xfbcbfb8b30eb70fb, 0xee9fee2371c1cdee, 0x7ced7cc791f8bb7c, 0x66856617e3cc7166, + 0xdd53dda68ea77bdd, 0x175c17b84b2eaf17, 0x47014702468e4547, 0x9e429e84dc211a9e, + 0xca0fca1ec589d4ca, 0x2db42d75995a582d, 0xbfc6bf9179632ebf, 0x071c07381b0e3f07, + 0xad8ead012347acad, 0x5a755aea2fb4b05a, 0x8336836cb51bef83, 0x33cc3385ff66b633, + 0x6391633ff2c65c63, 0x020802100a041202, 0xaa92aa39384993aa, 0x71d971afa8e2de71, + 0xc807c80ecf8dc6c8, 0x196419c87d32d119, 0x4939497270923b49, 0xd943d9869aaf5fd9, + 0xf2eff2c31df931f2, 0xe3abe34b48dba8e3, 0x5b715be22ab6b95b, 0x881a8834920dbc88, + 0x9a529aa4c8293e9a, 0x2698262dbe4c0b26, 0x32c8328dfa64bf32, 0xb0fab0e94a7d59b0, + 0xe983e91b6acff2e9, 0x0f3c0f78331e770f, 0xd573d5e6a6b733d5, 0x803a8074ba1df480, + 0xbec2be997c6127be, 0xcd13cd26de87ebcd, 0x34d034bde4688934, 0x483d487a75903248, + 0xffdbffab24e354ff, 0x7af57af78ff48d7a, 0x907a90f4ea3d6490, 0x5f615fc23ebe9d5f, + 0x2080201da0403d20, 0x68bd6867d5d00f68, 0x1a681ad07234ca1a, 0xae82ae192c41b7ae, + 0xb4eab4c95e757db4, 0x544d549a19a8ce54, 0x937693ece53b7f93, 0x2288220daa442f22, + 0x648d6407e9c86364, 0xf1e3f1db12ff2af1, 0x73d173bfa2e6cc73, 0x124812905a248212, + 0x401d403a5d807a40, 0x0820084028104808, 0xc32bc356e89b95c3, 0xec97ec337bc5dfec, + 0xdb4bdb9690ab4ddb, 0xa1bea1611f5fc0a1, 0x8d0e8d1c8307918d, 0x3df43df5c97ac83d, + 0x976697ccf1335b97, 0x0000000000000000, 0xcf1bcf36d483f9cf, 0x2bac2b4587566e2b, + 0x76c57697b3ece176, 0x82328264b019e682, 0xd67fd6fea9b128d6, 0x1b6c1bd87736c31b, + 0xb5eeb5c15b7774b5, 0xaf86af112943beaf, 0x6ab56a77dfd41d6a, 0x505d50ba0da0ea50, + 0x450945124c8a5745, 0xf3ebf3cb18fb38f3, 0x30c0309df060ad30, 0xef9bef2b74c3c4ef, + 0x3ffc3fe5c37eda3f, 0x554955921caac755, 0xa2b2a2791059dba2, 0xea8fea0365c9e9ea, + 0x6589650fecca6a65, 0xbad2bab9686903ba, 0x2fbc2f65935e4a2f, 0xc027c04ee79d8ec0, + 0xde5fdebe81a160de, 0x1c701ce06c38fc1c, 0xfdd3fdbb2ee746fd, 0x4d294d52649a1f4d, + 0x927292e4e0397692, 0x75c9758fbceafa75, 0x061806301e0c3606, 0x8a128a249809ae8a, + 0xb2f2b2f940794bb2, 0xe6bfe66359d185e6, 0x0e380e70361c7e0e, 0x1f7c1ff8633ee71f, + 0x62956237f7c45562, 0xd477d4eea3b53ad4, 0xa89aa829324d81a8, 0x966296c4f4315296, + 0xf9c3f99b3aef62f9, 0xc533c566f697a3c5, 0x25942535b14a1025, 0x597959f220b2ab59, + 0x842a8454ae15d084, 0x72d572b7a7e4c572, 0x39e439d5dd72ec39, 0x4c2d4c5a6198164c, + 0x5e655eca3bbc945e, 0x78fd78e785f09f78, 0x38e038ddd870e538, 0x8c0a8c148605988c, + 0xd163d1c6b2bf17d1, 0xa5aea5410b57e4a5, 0xe2afe2434dd9a1e2, 0x6199612ff8c24e61, + 0xb3f6b3f1457b42b3, 0x21842115a5423421, 0x9c4a9c94d625089c, 0x1e781ef0663cee1e, + 0x4311432252866143, 0xc73bc776fc93b1c7, 0xfcd7fcb32be54ffc, 0x0410042014082404, + 0x515951b208a2e351, 0x995e99bcc72f2599, 0x6da96d4fc4da226d, 0x0d340d68391a650d, + 0xfacffa8335e979fa, 0xdf5bdfb684a369df, 0x7ee57ed79bfca97e, 0x2490243db4481924, + 0x3bec3bc5d776fe3b, 0xab96ab313d4b9aab, 0xce1fce3ed181f0ce, 0x1144118855229911, + 0x8f068f0c8903838f, 0x4e254e4a6b9c044e, 0xb7e6b7d1517366b7, 0xeb8beb0b60cbe0eb, + 0x3cf03cfdcc78c13c, 0x813e817cbf1ffd81, 0x946a94d4fe354094, 0xf7fbf7eb0cf31cf7, + 0xb9deb9a1676f18b9, 0x134c13985f268b13, 0x2cb02c7d9c58512c, 0xd36bd3d6b8bb05d3, + 0xe7bbe76b5cd38ce7, 0x6ea56e57cbdc396e, 0xc437c46ef395aac4, 0x030c03180f061b03, + 0x5645568a13acdc56, 0x440d441a49885e44, 0x7fe17fdf9efea07f, 0xa99ea921374f88a9, + 0x2aa82a4d8254672a, 0xbbd6bbb16d6b0abb, 0xc123c146e29f87c1, 0x535153a202a6f153, + 0xdc57dcae8ba572dc, 0x0b2c0b582716530b, 0x9d4e9d9cd327019d, 0x6cad6c47c1d82b6c, + 0x31c43195f562a431, 0x74cd7487b9e8f374, 0xf6fff6e309f115f6, 0x4605460a438c4c46, + 0xac8aac092645a5ac, 0x891e893c970fb589, 0x145014a04428b414, 0xe1a3e15b42dfbae1, + 0x165816b04e2ca616, 0x3ae83acdd274f73a, 0x69b9696fd0d20669, 0x092409482d124109, + 0x70dd70a7ade0d770, 0xb6e2b6d954716fb6, 0xd067d0ceb7bd1ed0, 0xed93ed3b7ec7d6ed, + 0xcc17cc2edb85e2cc, 0x4215422a57846842, 0x985a98b4c22d2c98, 0xa4aaa4490e55eda4, + 0x28a0285d88507528, 0x5c6d5cda31b8865c, 0xf8c7f8933fed6bf8, 0x86228644a411c286, }; // important notes on this: @@ -1108,177 +558,161 @@ CONSTANT_VK u32a rcl[R + 1] = // input buf needs to be in algorithm native byte order (md5 = LE, sha256 = BE, etc) // input buf needs to be 64 byte aligned when using whirlpool_update() -DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) -{ - u32 Kh[8]; - u32 Kl[8]; - - Kh[0] = digest[ 0]; - Kl[0] = digest[ 1]; - Kh[1] = digest[ 2]; - Kl[1] = digest[ 3]; - Kh[2] = digest[ 4]; - Kl[2] = digest[ 5]; - Kh[3] = digest[ 6]; - Kl[3] = digest[ 7]; - Kh[4] = digest[ 8]; - Kl[4] = digest[ 9]; - Kh[5] = digest[10]; - Kl[5] = digest[11]; - Kh[6] = digest[12]; - Kl[6] = digest[13]; - Kh[7] = digest[14]; - Kl[7] = digest[15]; - - u32 stateh[8]; - u32 statel[8]; - - stateh[0] = w0[0] ^ Kh[0]; - statel[0] = w0[1] ^ Kl[0]; - stateh[1] = w0[2] ^ Kh[1]; - statel[1] = w0[3] ^ Kl[1]; - stateh[2] = w1[0] ^ Kh[2]; - statel[2] = w1[1] ^ Kl[2]; - stateh[3] = w1[2] ^ Kh[3]; - statel[3] = w1[3] ^ Kl[3]; - stateh[4] = w2[0] ^ Kh[4]; - statel[4] = w2[1] ^ Kl[4]; - stateh[5] = w2[2] ^ Kh[5]; - statel[5] = w2[3] ^ Kl[5]; - stateh[6] = w3[0] ^ Kh[6]; - statel[6] = w3[1] ^ Kl[6]; - stateh[7] = w3[2] ^ Kh[7]; - statel[7] = w3[3] ^ Kl[7]; - - u32 r; - - for (r = 1; r <= R; r++) - { - u32 Lh[8]; - u32 Ll[8]; - - u32 i; - - #ifdef _unroll - #pragma unroll - #endif - for (i = 0; i < 8; i++) - { - const u32 Lp0 = Kh[(i + 8) & 7] >> 24; - const u32 Lp1 = Kh[(i + 7) & 7] >> 16; - const u32 Lp2 = Kh[(i + 6) & 7] >> 8; - const u32 Lp3 = Kh[(i + 5) & 7] >> 0; - const u32 Lp4 = Kl[(i + 4) & 7] >> 24; - const u32 Lp5 = Kl[(i + 3) & 7] >> 16; - const u32 Lp6 = Kl[(i + 2) & 7] >> 8; - const u32 Lp7 = Kl[(i + 1) & 7] >> 0; - - Lh[i] = BOX_S (s_Ch, 0, Lp0 & 0xff) - ^ BOX_S (s_Ch, 1, Lp1 & 0xff) - ^ BOX_S (s_Ch, 2, Lp2 & 0xff) - ^ BOX_S (s_Ch, 3, Lp3 & 0xff) - ^ BOX_S (s_Ch, 4, Lp4 & 0xff) - ^ BOX_S (s_Ch, 5, Lp5 & 0xff) - ^ BOX_S (s_Ch, 6, Lp6 & 0xff) - ^ BOX_S (s_Ch, 7, Lp7 & 0xff); - - Ll[i] = BOX_S (s_Cl, 0, Lp0 & 0xff) - ^ BOX_S (s_Cl, 1, Lp1 & 0xff) - ^ BOX_S (s_Cl, 2, Lp2 & 0xff) - ^ BOX_S (s_Cl, 3, Lp3 & 0xff) - ^ BOX_S (s_Cl, 4, Lp4 & 0xff) - ^ BOX_S (s_Cl, 5, Lp5 & 0xff) - ^ BOX_S (s_Cl, 6, Lp6 & 0xff) - ^ BOX_S (s_Cl, 7, Lp7 & 0xff); - } - - Kh[0] = Lh[0] ^ rch[r]; - Kl[0] = Ll[0] ^ rcl[r]; - Kh[1] = Lh[1]; - Kl[1] = Ll[1]; - Kh[2] = Lh[2]; - Kl[2] = Ll[2]; - Kh[3] = Lh[3]; - Kl[3] = Ll[3]; - Kh[4] = Lh[4]; - Kl[4] = Ll[4]; - Kh[5] = Lh[5]; - Kl[5] = Ll[5]; - Kh[6] = Lh[6]; - Kl[6] = Ll[6]; - Kh[7] = Lh[7]; - Kl[7] = Ll[7]; - - #ifdef _unroll - #pragma unroll - #endif - for (i = 0; i < 8; i++) - { - const u32 Lp0 = stateh[(i + 8) & 7] >> 24; - const u32 Lp1 = stateh[(i + 7) & 7] >> 16; - const u32 Lp2 = stateh[(i + 6) & 7] >> 8; - const u32 Lp3 = stateh[(i + 5) & 7] >> 0; - const u32 Lp4 = statel[(i + 4) & 7] >> 24; - const u32 Lp5 = statel[(i + 3) & 7] >> 16; - const u32 Lp6 = statel[(i + 2) & 7] >> 8; - const u32 Lp7 = statel[(i + 1) & 7] >> 0; - - Lh[i] = BOX_S (s_Ch, 0, Lp0 & 0xff) - ^ BOX_S (s_Ch, 1, Lp1 & 0xff) - ^ BOX_S (s_Ch, 2, Lp2 & 0xff) - ^ BOX_S (s_Ch, 3, Lp3 & 0xff) - ^ BOX_S (s_Ch, 4, Lp4 & 0xff) - ^ BOX_S (s_Ch, 5, Lp5 & 0xff) - ^ BOX_S (s_Ch, 6, Lp6 & 0xff) - ^ BOX_S (s_Ch, 7, Lp7 & 0xff); - - Ll[i] = BOX_S (s_Cl, 0, Lp0 & 0xff) - ^ BOX_S (s_Cl, 1, Lp1 & 0xff) - ^ BOX_S (s_Cl, 2, Lp2 & 0xff) - ^ BOX_S (s_Cl, 3, Lp3 & 0xff) - ^ BOX_S (s_Cl, 4, Lp4 & 0xff) - ^ BOX_S (s_Cl, 5, Lp5 & 0xff) - ^ BOX_S (s_Cl, 6, Lp6 & 0xff) - ^ BOX_S (s_Cl, 7, Lp7 & 0xff); - } - - stateh[0] = Lh[0] ^ Kh[0]; - statel[0] = Ll[0] ^ Kl[0]; - stateh[1] = Lh[1] ^ Kh[1]; - statel[1] = Ll[1] ^ Kl[1]; - stateh[2] = Lh[2] ^ Kh[2]; - statel[2] = Ll[2] ^ Kl[2]; - stateh[3] = Lh[3] ^ Kh[3]; - statel[3] = Ll[3] ^ Kl[3]; - stateh[4] = Lh[4] ^ Kh[4]; - statel[4] = Ll[4] ^ Kl[4]; - stateh[5] = Lh[5] ^ Kh[5]; - statel[5] = Ll[5] ^ Kl[5]; - stateh[6] = Lh[6] ^ Kh[6]; - statel[6] = Ll[6] ^ Kl[6]; - stateh[7] = Lh[7] ^ Kh[7]; - statel[7] = Ll[7] ^ Kl[7]; - } - - digest[ 0] ^= stateh[0] ^ w0[0]; - digest[ 1] ^= statel[0] ^ w0[1]; - digest[ 2] ^= stateh[1] ^ w0[2]; - digest[ 3] ^= statel[1] ^ w0[3]; - digest[ 4] ^= stateh[2] ^ w1[0]; - digest[ 5] ^= statel[2] ^ w1[1]; - digest[ 6] ^= stateh[3] ^ w1[2]; - digest[ 7] ^= statel[3] ^ w1[3]; - digest[ 8] ^= stateh[4] ^ w2[0]; - digest[ 9] ^= statel[4] ^ w2[1]; - digest[10] ^= stateh[5] ^ w2[2]; - digest[11] ^= statel[5] ^ w2[3]; - digest[12] ^= stateh[6] ^ w3[0]; - digest[13] ^= statel[6] ^ w3[1]; - digest[14] ^= stateh[7] ^ w3[2]; - digest[15] ^= statel[7] ^ w3[3]; +#define F1(l,v0,v1,v2,v3,v4,v5,v6,v7) \ +{ \ + const u8 Lp0 = v8h_from_v64_S ((v0)); \ + const u8 Lp1 = v8g_from_v64_S ((v1)); \ + const u8 Lp2 = v8f_from_v64_S ((v2)); \ + const u8 Lp3 = v8e_from_v64_S ((v3)); \ + const u8 Lp4 = v8d_from_v64_S ((v4)); \ + const u8 Lp5 = v8c_from_v64_S ((v5)); \ + const u8 Lp6 = v8b_from_v64_S ((v6)); \ + const u8 Lp7 = v8a_from_v64_S ((v7)); \ + \ + const u64 X0 = BOX64_S (s_MT0, Lp0); \ + const u64 X1 = BOX64_S (s_MT1, Lp1); \ + const u64 X2 = BOX64_S (s_MT2, Lp2); \ + const u64 X3 = BOX64_S (s_MT3, Lp3); \ + const u64 X4 = BOX64_S (s_MT4, Lp4); \ + const u64 X5 = BOX64_S (s_MT5, Lp5); \ + const u64 X6 = BOX64_S (s_MT6, Lp6); \ + const u64 X7 = BOX64_S (s_MT7, Lp7); \ + \ + (l) = X0 \ + ^ X1 \ + ^ X2 \ + ^ X3 \ + ^ X4 \ + ^ X5 \ + ^ X6 \ + ^ X7; \ } -DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +#define F0(rc) \ +{ \ + u64 L0; \ + u64 L1; \ + u64 L2; \ + u64 L3; \ + u64 L4; \ + u64 L5; \ + u64 L6; \ + u64 L7; \ + \ + F1 (L0, K0, K7, K6, K5, K4, K3, K2, K1); \ + F1 (L1, K1, K0, K7, K6, K5, K4, K3, K2); \ + F1 (L2, K2, K1, K0, K7, K6, K5, K4, K3); \ + F1 (L3, K3, K2, K1, K0, K7, K6, K5, K4); \ + F1 (L4, K4, K3, K2, K1, K0, K7, K6, K5); \ + F1 (L5, K5, K4, K3, K2, K1, K0, K7, K6); \ + F1 (L6, K6, K5, K4, K3, K2, K1, K0, K7); \ + F1 (L7, K7, K6, K5, K4, K3, K2, K1, K0); \ + \ + K0 = L0 ^ (rc); \ + K1 = L1; \ + K2 = L2; \ + K3 = L3; \ + K4 = L4; \ + K5 = L5; \ + K6 = L6; \ + K7 = L7; \ + \ + F1 (L0, S0, S7, S6, S5, S4, S3, S2, S1); \ + F1 (L1, S1, S0, S7, S6, S5, S4, S3, S2); \ + F1 (L2, S2, S1, S0, S7, S6, S5, S4, S3); \ + F1 (L3, S3, S2, S1, S0, S7, S6, S5, S4); \ + F1 (L4, S4, S3, S2, S1, S0, S7, S6, S5); \ + F1 (L5, S5, S4, S3, S2, S1, S0, S7, S6); \ + F1 (L6, S6, S5, S4, S3, S2, S1, S0, S7); \ + F1 (L7, S7, S6, S5, S4, S3, S2, S1, S0); \ + \ + S0 = L0 ^ K0; \ + S1 = L1 ^ K1; \ + S2 = L2 ^ K2; \ + S3 = L3 ^ K3; \ + S4 = L4 ^ K4; \ + S5 = L5 ^ K5; \ + S6 = L6 ^ K6; \ + S7 = L7 ^ K7; \ +} + +DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) +{ + u64 W0 = hl32_to_64_S (w0[0], w0[1]); + u64 W1 = hl32_to_64_S (w0[2], w0[3]); + u64 W2 = hl32_to_64_S (w1[0], w1[1]); + u64 W3 = hl32_to_64_S (w1[2], w1[3]); + u64 W4 = hl32_to_64_S (w2[0], w2[1]); + u64 W5 = hl32_to_64_S (w2[2], w2[3]); + u64 W6 = hl32_to_64_S (w3[0], w3[1]); + u64 W7 = hl32_to_64_S (w3[2], w3[3]); + + u64 D0 = hl32_to_64_S (digest[ 0], digest[ 1]); + u64 D1 = hl32_to_64_S (digest[ 2], digest[ 3]); + u64 D2 = hl32_to_64_S (digest[ 4], digest[ 5]); + u64 D3 = hl32_to_64_S (digest[ 6], digest[ 7]); + u64 D4 = hl32_to_64_S (digest[ 8], digest[ 9]); + u64 D5 = hl32_to_64_S (digest[10], digest[11]); + u64 D6 = hl32_to_64_S (digest[12], digest[13]); + u64 D7 = hl32_to_64_S (digest[14], digest[15]); + + u64 K0 = D0; + u64 K1 = D1; + u64 K2 = D2; + u64 K3 = D3; + u64 K4 = D4; + u64 K5 = D5; + u64 K6 = D6; + u64 K7 = D7; + + u64 S0 = K0 ^ W0; + u64 S1 = K1 ^ W1; + u64 S2 = K2 ^ W2; + u64 S3 = K3 ^ W3; + u64 S4 = K4 ^ W4; + u64 S5 = K5 ^ W5; + u64 S6 = K6 ^ W6; + u64 S7 = K7 ^ W7; + + F0 (0x1823c6e887b8014f); + F0 (0x36a6d2f5796f9152); + F0 (0x60bc9b8ea30c7b35); + F0 (0x1de0d7c22e4bfe57); + F0 (0x157737e59ff04ada); + F0 (0x58c9290ab1a06b85); + F0 (0xbd5d10f4cb3e0567); + F0 (0xe427418ba77d95d8); + F0 (0xfbee7c66dd17479e); + F0 (0xca2dbf07ad5a8333); + + D0 ^= S0 ^ W0; + D1 ^= S1 ^ W1; + D2 ^= S2 ^ W2; + D3 ^= S3 ^ W3; + D4 ^= S4 ^ W4; + D5 ^= S5 ^ W5; + D6 ^= S6 ^ W6; + D7 ^= S7 ^ W7; + + digest[ 0] = h32_from_64_S (D0); + digest[ 1] = l32_from_64_S (D0); + digest[ 2] = h32_from_64_S (D1); + digest[ 3] = l32_from_64_S (D1); + digest[ 4] = h32_from_64_S (D2); + digest[ 5] = l32_from_64_S (D2); + digest[ 6] = h32_from_64_S (D3); + digest[ 7] = l32_from_64_S (D3); + digest[ 8] = h32_from_64_S (D4); + digest[ 9] = l32_from_64_S (D4); + digest[10] = h32_from_64_S (D5); + digest[11] = l32_from_64_S (D5); + digest[12] = h32_from_64_S (D6); + digest[13] = l32_from_64_S (D6); + digest[14] = h32_from_64_S (D7); + digest[15] = l32_from_64_S (D7); +} + +DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { ctx->h[ 0] = 0; ctx->h[ 1] = 0; @@ -1316,8 +750,14 @@ DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u32 (*s_Ch)[256], S ctx->len = 0; - ctx->s_Ch = s_Ch; - ctx->s_Cl = s_Cl; + ctx->s_MT0 = s_MT0; + ctx->s_MT1 = s_MT1; + ctx->s_MT2 = s_MT2; + ctx->s_MT3 = s_MT3; + ctx->s_MT4 = s_MT4; + ctx->s_MT5 = s_MT5; + ctx->s_MT6 = s_MT6; + ctx->s_MT7 = s_MT7; } DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) @@ -1347,7 +787,7 @@ DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 * if (len == 64) { - whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); ctx->w0[0] = 0; ctx->w0[1] = 0; @@ -1416,7 +856,7 @@ DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 * ctx->w3[2] |= w3[2]; ctx->w3[3] |= w3[3]; - whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); ctx->w0[0] = c0[0]; ctx->w0[1] = c0[1]; @@ -1958,7 +1398,7 @@ DECLSPEC void whirlpool_final (whirlpool_ctx_t *ctx) if (pos >= 32) { - whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); ctx->w0[0] = 0; ctx->w0[1] = 0; @@ -1981,12 +1421,12 @@ DECLSPEC void whirlpool_final (whirlpool_ctx_t *ctx) ctx->w3[2] = 0; ctx->w3[3] = ctx->len * 8; - whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); } // whirlpool_hmac -DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32 t0[4]; u32 t1[4]; @@ -2012,11 +1452,9 @@ DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, t3[2] = w3[2] ^ 0x36363636; t3[3] = w3[3] ^ 0x36363636; - whirlpool_init (&ctx->ipad, s_Ch, s_Cl); + whirlpool_init (&ctx->ipad, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); - whirlpool_transform (t0, t1, t2, t3, ctx->ipad.h, ctx->ipad.s_Ch, ctx->ipad.s_Cl); - - ctx->ipad.len = 64; + whirlpool_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -2037,14 +1475,12 @@ DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, t3[2] = w3[2] ^ 0x5c5c5c5c; t3[3] = w3[3] ^ 0x5c5c5c5c; - whirlpool_init (&ctx->opad, s_Ch, s_Cl); + whirlpool_init (&ctx->opad, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); - whirlpool_transform (t0, t1, t2, t3, ctx->opad.h, ctx->opad.s_Ch, ctx->opad.s_Cl); - - ctx->opad.len = 64; + whirlpool_update_64 (&ctx->opad, t0, t1, t2, t3, 64); } -DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32 w0[4]; u32 w1[4]; @@ -2055,7 +1491,7 @@ DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, cons { whirlpool_ctx_t tmp; - whirlpool_init (&tmp, s_Ch, s_Cl); + whirlpool_init (&tmp, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update (&tmp, w, len); @@ -2098,10 +1534,10 @@ DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, cons w3[3] = w[15]; } - whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } -DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32 w0[4]; u32 w1[4]; @@ -2112,7 +1548,7 @@ DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, { whirlpool_ctx_t tmp; - whirlpool_init (&tmp, s_Ch, s_Cl); + whirlpool_init (&tmp, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_swap (&tmp, w, len); @@ -2155,10 +1591,10 @@ DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, w3[3] = hc_swap32_S (w[15]); } - whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } -DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32 w0[4]; u32 w1[4]; @@ -2169,7 +1605,7 @@ DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS c { whirlpool_ctx_t tmp; - whirlpool_init (&tmp, s_Ch, s_Cl); + whirlpool_init (&tmp, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_global (&tmp, w, len); @@ -2212,10 +1648,10 @@ DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS c w3[3] = w[15]; } - whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } -DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32 w0[4]; u32 w1[4]; @@ -2226,7 +1662,7 @@ DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL { whirlpool_ctx_t tmp; - whirlpool_init (&tmp, s_Ch, s_Cl); + whirlpool_init (&tmp, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_global_swap (&tmp, w, len); @@ -2269,7 +1705,7 @@ DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL w3[3] = hc_swap32_S (w[15]); } - whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } DECLSPEC void whirlpool_hmac_update_64 (whirlpool_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len) @@ -2340,7 +1776,7 @@ DECLSPEC void whirlpool_hmac_final (whirlpool_hmac_ctx_t *ctx) ctx->opad.len += 64; - whirlpool_transform (ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3, ctx->opad.h, ctx->opad.s_Ch, ctx->opad.s_Cl); + whirlpool_transform (ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3, ctx->opad.h, ctx->opad.s_MT0, ctx->opad.s_MT1, ctx->opad.s_MT2, ctx->opad.s_MT3, ctx->opad.s_MT4, ctx->opad.s_MT5, ctx->opad.s_MT6, ctx->opad.s_MT7); ctx->opad.w0[0] = 0; ctx->opad.w0[1] = 0; @@ -2364,177 +1800,161 @@ DECLSPEC void whirlpool_hmac_final (whirlpool_hmac_ctx_t *ctx) // while input buf can be a vector datatype, the length of the different elements can not -DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) -{ - u32x Kh[8]; - u32x Kl[8]; - - Kh[0] = digest[ 0]; - Kl[0] = digest[ 1]; - Kh[1] = digest[ 2]; - Kl[1] = digest[ 3]; - Kh[2] = digest[ 4]; - Kl[2] = digest[ 5]; - Kh[3] = digest[ 6]; - Kl[3] = digest[ 7]; - Kh[4] = digest[ 8]; - Kl[4] = digest[ 9]; - Kh[5] = digest[10]; - Kl[5] = digest[11]; - Kh[6] = digest[12]; - Kl[6] = digest[13]; - Kh[7] = digest[14]; - Kl[7] = digest[15]; - - u32x stateh[8]; - u32x statel[8]; - - stateh[0] = w0[0] ^ Kh[0]; - statel[0] = w0[1] ^ Kl[0]; - stateh[1] = w0[2] ^ Kh[1]; - statel[1] = w0[3] ^ Kl[1]; - stateh[2] = w1[0] ^ Kh[2]; - statel[2] = w1[1] ^ Kl[2]; - stateh[3] = w1[2] ^ Kh[3]; - statel[3] = w1[3] ^ Kl[3]; - stateh[4] = w2[0] ^ Kh[4]; - statel[4] = w2[1] ^ Kl[4]; - stateh[5] = w2[2] ^ Kh[5]; - statel[5] = w2[3] ^ Kl[5]; - stateh[6] = w3[0] ^ Kh[6]; - statel[6] = w3[1] ^ Kl[6]; - stateh[7] = w3[2] ^ Kh[7]; - statel[7] = w3[3] ^ Kl[7]; - - u32 r; - - for (r = 1; r <= R; r++) - { - u32x Lh[8]; - u32x Ll[8]; - - u32 i; - - #ifdef _unroll - #pragma unroll - #endif - for (i = 0; i < 8; i++) - { - const u32x Lp0 = Kh[(i + 8) & 7] >> 24; - const u32x Lp1 = Kh[(i + 7) & 7] >> 16; - const u32x Lp2 = Kh[(i + 6) & 7] >> 8; - const u32x Lp3 = Kh[(i + 5) & 7] >> 0; - const u32x Lp4 = Kl[(i + 4) & 7] >> 24; - const u32x Lp5 = Kl[(i + 3) & 7] >> 16; - const u32x Lp6 = Kl[(i + 2) & 7] >> 8; - const u32x Lp7 = Kl[(i + 1) & 7] >> 0; - - Lh[i] = BOX (s_Ch, 0, Lp0 & 0xff) - ^ BOX (s_Ch, 1, Lp1 & 0xff) - ^ BOX (s_Ch, 2, Lp2 & 0xff) - ^ BOX (s_Ch, 3, Lp3 & 0xff) - ^ BOX (s_Ch, 4, Lp4 & 0xff) - ^ BOX (s_Ch, 5, Lp5 & 0xff) - ^ BOX (s_Ch, 6, Lp6 & 0xff) - ^ BOX (s_Ch, 7, Lp7 & 0xff); - - Ll[i] = BOX (s_Cl, 0, Lp0 & 0xff) - ^ BOX (s_Cl, 1, Lp1 & 0xff) - ^ BOX (s_Cl, 2, Lp2 & 0xff) - ^ BOX (s_Cl, 3, Lp3 & 0xff) - ^ BOX (s_Cl, 4, Lp4 & 0xff) - ^ BOX (s_Cl, 5, Lp5 & 0xff) - ^ BOX (s_Cl, 6, Lp6 & 0xff) - ^ BOX (s_Cl, 7, Lp7 & 0xff); - } - - Kh[0] = Lh[0] ^ rch[r]; - Kl[0] = Ll[0] ^ rcl[r]; - Kh[1] = Lh[1]; - Kl[1] = Ll[1]; - Kh[2] = Lh[2]; - Kl[2] = Ll[2]; - Kh[3] = Lh[3]; - Kl[3] = Ll[3]; - Kh[4] = Lh[4]; - Kl[4] = Ll[4]; - Kh[5] = Lh[5]; - Kl[5] = Ll[5]; - Kh[6] = Lh[6]; - Kl[6] = Ll[6]; - Kh[7] = Lh[7]; - Kl[7] = Ll[7]; - - #ifdef _unroll - #pragma unroll - #endif - for (i = 0; i < 8; i++) - { - const u32x Lp0 = stateh[(i + 8) & 7] >> 24; - const u32x Lp1 = stateh[(i + 7) & 7] >> 16; - const u32x Lp2 = stateh[(i + 6) & 7] >> 8; - const u32x Lp3 = stateh[(i + 5) & 7] >> 0; - const u32x Lp4 = statel[(i + 4) & 7] >> 24; - const u32x Lp5 = statel[(i + 3) & 7] >> 16; - const u32x Lp6 = statel[(i + 2) & 7] >> 8; - const u32x Lp7 = statel[(i + 1) & 7] >> 0; - - Lh[i] = BOX (s_Ch, 0, Lp0 & 0xff) - ^ BOX (s_Ch, 1, Lp1 & 0xff) - ^ BOX (s_Ch, 2, Lp2 & 0xff) - ^ BOX (s_Ch, 3, Lp3 & 0xff) - ^ BOX (s_Ch, 4, Lp4 & 0xff) - ^ BOX (s_Ch, 5, Lp5 & 0xff) - ^ BOX (s_Ch, 6, Lp6 & 0xff) - ^ BOX (s_Ch, 7, Lp7 & 0xff); - - Ll[i] = BOX (s_Cl, 0, Lp0 & 0xff) - ^ BOX (s_Cl, 1, Lp1 & 0xff) - ^ BOX (s_Cl, 2, Lp2 & 0xff) - ^ BOX (s_Cl, 3, Lp3 & 0xff) - ^ BOX (s_Cl, 4, Lp4 & 0xff) - ^ BOX (s_Cl, 5, Lp5 & 0xff) - ^ BOX (s_Cl, 6, Lp6 & 0xff) - ^ BOX (s_Cl, 7, Lp7 & 0xff); - } - - stateh[0] = Lh[0] ^ Kh[0]; - statel[0] = Ll[0] ^ Kl[0]; - stateh[1] = Lh[1] ^ Kh[1]; - statel[1] = Ll[1] ^ Kl[1]; - stateh[2] = Lh[2] ^ Kh[2]; - statel[2] = Ll[2] ^ Kl[2]; - stateh[3] = Lh[3] ^ Kh[3]; - statel[3] = Ll[3] ^ Kl[3]; - stateh[4] = Lh[4] ^ Kh[4]; - statel[4] = Ll[4] ^ Kl[4]; - stateh[5] = Lh[5] ^ Kh[5]; - statel[5] = Ll[5] ^ Kl[5]; - stateh[6] = Lh[6] ^ Kh[6]; - statel[6] = Ll[6] ^ Kl[6]; - stateh[7] = Lh[7] ^ Kh[7]; - statel[7] = Ll[7] ^ Kl[7]; - } - - digest[ 0] ^= stateh[0] ^ w0[0]; - digest[ 1] ^= statel[0] ^ w0[1]; - digest[ 2] ^= stateh[1] ^ w0[2]; - digest[ 3] ^= statel[1] ^ w0[3]; - digest[ 4] ^= stateh[2] ^ w1[0]; - digest[ 5] ^= statel[2] ^ w1[1]; - digest[ 6] ^= stateh[3] ^ w1[2]; - digest[ 7] ^= statel[3] ^ w1[3]; - digest[ 8] ^= stateh[4] ^ w2[0]; - digest[ 9] ^= statel[4] ^ w2[1]; - digest[10] ^= stateh[5] ^ w2[2]; - digest[11] ^= statel[5] ^ w2[3]; - digest[12] ^= stateh[6] ^ w3[0]; - digest[13] ^= statel[6] ^ w3[1]; - digest[14] ^= stateh[7] ^ w3[2]; - digest[15] ^= statel[7] ^ w3[3]; +#define F1x(l,v0,v1,v2,v3,v4,v5,v6,v7) \ +{ \ + const u8x Lp0 = v8h_from_v64 ((v0)); \ + const u8x Lp1 = v8g_from_v64 ((v1)); \ + const u8x Lp2 = v8f_from_v64 ((v2)); \ + const u8x Lp3 = v8e_from_v64 ((v3)); \ + const u8x Lp4 = v8d_from_v64 ((v4)); \ + const u8x Lp5 = v8c_from_v64 ((v5)); \ + const u8x Lp6 = v8b_from_v64 ((v6)); \ + const u8x Lp7 = v8a_from_v64 ((v7)); \ + \ + const u64x X0 = BOX64 (s_MT0, Lp0); \ + const u64x X1 = BOX64 (s_MT1, Lp1); \ + const u64x X2 = BOX64 (s_MT2, Lp2); \ + const u64x X3 = BOX64 (s_MT3, Lp3); \ + const u64x X4 = BOX64 (s_MT4, Lp4); \ + const u64x X5 = BOX64 (s_MT5, Lp5); \ + const u64x X6 = BOX64 (s_MT6, Lp6); \ + const u64x X7 = BOX64 (s_MT7, Lp7); \ + \ + (l) = X0 \ + ^ X1 \ + ^ X2 \ + ^ X3 \ + ^ X4 \ + ^ X5 \ + ^ X6 \ + ^ X7; \ } -DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +#define F0x(rc) \ +{ \ + u64x L0; \ + u64x L1; \ + u64x L2; \ + u64x L3; \ + u64x L4; \ + u64x L5; \ + u64x L6; \ + u64x L7; \ + \ + F1x (L0, K0, K7, K6, K5, K4, K3, K2, K1); \ + F1x (L1, K1, K0, K7, K6, K5, K4, K3, K2); \ + F1x (L2, K2, K1, K0, K7, K6, K5, K4, K3); \ + F1x (L3, K3, K2, K1, K0, K7, K6, K5, K4); \ + F1x (L4, K4, K3, K2, K1, K0, K7, K6, K5); \ + F1x (L5, K5, K4, K3, K2, K1, K0, K7, K6); \ + F1x (L6, K6, K5, K4, K3, K2, K1, K0, K7); \ + F1x (L7, K7, K6, K5, K4, K3, K2, K1, K0); \ + \ + K0 = L0 ^ (rc); \ + K1 = L1; \ + K2 = L2; \ + K3 = L3; \ + K4 = L4; \ + K5 = L5; \ + K6 = L6; \ + K7 = L7; \ + \ + F1x (L0, S0, S7, S6, S5, S4, S3, S2, S1); \ + F1x (L1, S1, S0, S7, S6, S5, S4, S3, S2); \ + F1x (L2, S2, S1, S0, S7, S6, S5, S4, S3); \ + F1x (L3, S3, S2, S1, S0, S7, S6, S5, S4); \ + F1x (L4, S4, S3, S2, S1, S0, S7, S6, S5); \ + F1x (L5, S5, S4, S3, S2, S1, S0, S7, S6); \ + F1x (L6, S6, S5, S4, S3, S2, S1, S0, S7); \ + F1x (L7, S7, S6, S5, S4, S3, S2, S1, S0); \ + \ + S0 = L0 ^ K0; \ + S1 = L1 ^ K1; \ + S2 = L2 ^ K2; \ + S3 = L3 ^ K3; \ + S4 = L4 ^ K4; \ + S5 = L5 ^ K5; \ + S6 = L6 ^ K6; \ + S7 = L7 ^ K7; \ +} + +DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) +{ + u64x W0 = hl32_to_64 (w0[0], w0[1]); + u64x W1 = hl32_to_64 (w0[2], w0[3]); + u64x W2 = hl32_to_64 (w1[0], w1[1]); + u64x W3 = hl32_to_64 (w1[2], w1[3]); + u64x W4 = hl32_to_64 (w2[0], w2[1]); + u64x W5 = hl32_to_64 (w2[2], w2[3]); + u64x W6 = hl32_to_64 (w3[0], w3[1]); + u64x W7 = hl32_to_64 (w3[2], w3[3]); + + u64x D0 = hl32_to_64 (digest[ 0], digest[ 1]); + u64x D1 = hl32_to_64 (digest[ 2], digest[ 3]); + u64x D2 = hl32_to_64 (digest[ 4], digest[ 5]); + u64x D3 = hl32_to_64 (digest[ 6], digest[ 7]); + u64x D4 = hl32_to_64 (digest[ 8], digest[ 9]); + u64x D5 = hl32_to_64 (digest[10], digest[11]); + u64x D6 = hl32_to_64 (digest[12], digest[13]); + u64x D7 = hl32_to_64 (digest[14], digest[15]); + + u64x K0 = D0; + u64x K1 = D1; + u64x K2 = D2; + u64x K3 = D3; + u64x K4 = D4; + u64x K5 = D5; + u64x K6 = D6; + u64x K7 = D7; + + u64x S0 = K0 ^ W0; + u64x S1 = K1 ^ W1; + u64x S2 = K2 ^ W2; + u64x S3 = K3 ^ W3; + u64x S4 = K4 ^ W4; + u64x S5 = K5 ^ W5; + u64x S6 = K6 ^ W6; + u64x S7 = K7 ^ W7; + + F0x (0x1823c6e887b8014f); + F0x (0x36a6d2f5796f9152); + F0x (0x60bc9b8ea30c7b35); + F0x (0x1de0d7c22e4bfe57); + F0x (0x157737e59ff04ada); + F0x (0x58c9290ab1a06b85); + F0x (0xbd5d10f4cb3e0567); + F0x (0xe427418ba77d95d8); + F0x (0xfbee7c66dd17479e); + F0x (0xca2dbf07ad5a8333); + + D0 ^= S0 ^ W0; + D1 ^= S1 ^ W1; + D2 ^= S2 ^ W2; + D3 ^= S3 ^ W3; + D4 ^= S4 ^ W4; + D5 ^= S5 ^ W5; + D6 ^= S6 ^ W6; + D7 ^= S7 ^ W7; + + digest[ 0] = h32_from_64 (D0); + digest[ 1] = l32_from_64 (D0); + digest[ 2] = h32_from_64 (D1); + digest[ 3] = l32_from_64 (D1); + digest[ 4] = h32_from_64 (D2); + digest[ 5] = l32_from_64 (D2); + digest[ 6] = h32_from_64 (D3); + digest[ 7] = l32_from_64 (D3); + digest[ 8] = h32_from_64 (D4); + digest[ 9] = l32_from_64 (D4); + digest[10] = h32_from_64 (D5); + digest[11] = l32_from_64 (D5); + digest[12] = h32_from_64 (D6); + digest[13] = l32_from_64 (D6); + digest[14] = h32_from_64 (D7); + digest[15] = l32_from_64 (D7); +} + +DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { ctx->h[ 0] = 0; ctx->h[ 1] = 0; @@ -2572,8 +1992,14 @@ DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u32 ( ctx->len = 0; - ctx->s_Ch = s_Ch; - ctx->s_Cl = s_Cl; + ctx->s_MT0 = s_MT0; + ctx->s_MT1 = s_MT1; + ctx->s_MT2 = s_MT2; + ctx->s_MT3 = s_MT3; + ctx->s_MT4 = s_MT4; + ctx->s_MT5 = s_MT5; + ctx->s_MT6 = s_MT6; + ctx->s_MT7 = s_MT7; } DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, whirlpool_ctx_t *ctx0) @@ -2614,8 +2040,14 @@ DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, wh ctx->len = ctx0->len; - ctx->s_Ch = ctx0->s_Ch; - ctx->s_Cl = ctx0->s_Cl; + ctx->s_MT0 = ctx0->s_MT0; + ctx->s_MT1 = ctx0->s_MT1; + ctx->s_MT2 = ctx0->s_MT2; + ctx->s_MT3 = ctx0->s_MT3; + ctx->s_MT4 = ctx0->s_MT4; + ctx->s_MT5 = ctx0->s_MT5; + ctx->s_MT6 = ctx0->s_MT6; + ctx->s_MT7 = ctx0->s_MT7; } DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) @@ -2645,7 +2077,7 @@ DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, if (len == 64) { - whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); ctx->w0[0] = 0; ctx->w0[1] = 0; @@ -2714,7 +2146,7 @@ DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, ctx->w3[2] |= w3[2]; ctx->w3[3] |= w3[3]; - whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); ctx->w0[0] = c0[0]; ctx->w0[1] = c0[1]; @@ -3000,7 +2432,7 @@ DECLSPEC void whirlpool_final_vector (whirlpool_ctx_vector_t *ctx) if (pos >= 32) { - whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); ctx->w0[0] = 0; ctx->w0[1] = 0; @@ -3023,12 +2455,12 @@ DECLSPEC void whirlpool_final_vector (whirlpool_ctx_vector_t *ctx) ctx->w3[2] = 0; ctx->w3[3] = ctx->len * 8; - whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); + whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_MT0, ctx->s_MT1, ctx->s_MT2, ctx->s_MT3, ctx->s_MT4, ctx->s_MT5, ctx->s_MT6, ctx->s_MT7); } // HMAC + Vector -DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32x t0[4]; u32x t1[4]; @@ -3054,11 +2486,9 @@ DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, c t3[2] = w3[2] ^ 0x36363636; t3[3] = w3[3] ^ 0x36363636; - whirlpool_init_vector (&ctx->ipad, s_Ch, s_Cl); + whirlpool_init_vector (&ctx->ipad, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); - whirlpool_transform_vector (t0, t1, t2, t3, ctx->ipad.h, ctx->ipad.s_Ch, ctx->ipad.s_Cl); - - ctx->ipad.len = 64; + whirlpool_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); // opad @@ -3079,14 +2509,12 @@ DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, c t3[2] = w3[2] ^ 0x5c5c5c5c; t3[3] = w3[3] ^ 0x5c5c5c5c; - whirlpool_init_vector (&ctx->opad, s_Ch, s_Cl); + whirlpool_init_vector (&ctx->opad, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); - whirlpool_transform_vector (t0, t1, t2, t3, ctx->opad.h, ctx->opad.s_Ch, ctx->opad.s_Cl); - - ctx->opad.len = 64; + whirlpool_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); } -DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { u32x w0[4]; u32x w1[4]; @@ -3097,7 +2525,7 @@ DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, cons { whirlpool_ctx_vector_t tmp; - whirlpool_init_vector (&tmp, s_Ch, s_Cl); + whirlpool_init_vector (&tmp, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_vector (&tmp, w, len); @@ -3140,7 +2568,7 @@ DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, cons w3[3] = w[15]; } - whirlpool_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_vector_64 (ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } DECLSPEC void whirlpool_hmac_update_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len) @@ -3176,7 +2604,7 @@ DECLSPEC void whirlpool_hmac_final_vector (whirlpool_hmac_ctx_vector_t *ctx) ctx->opad.len += 64; - whirlpool_transform_vector (ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3, ctx->opad.h, ctx->opad.s_Ch, ctx->opad.s_Cl); + whirlpool_transform_vector (ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3, ctx->opad.h, ctx->opad.s_MT0, ctx->opad.s_MT1, ctx->opad.s_MT2, ctx->opad.s_MT3, ctx->opad.s_MT4, ctx->opad.s_MT5, ctx->opad.s_MT6, ctx->opad.s_MT7); ctx->opad.w0[0] = 0; ctx->opad.w0[1] = 0; @@ -3201,3 +2629,7 @@ DECLSPEC void whirlpool_hmac_final_vector (whirlpool_hmac_ctx_vector_t *ctx) #undef R #undef BOX #undef BOX_S +#undef F0 +#undef F0x +#undef F1 +#undef F1x diff --git a/OpenCL/inc_hash_whirlpool.h b/OpenCL/inc_hash_whirlpool.h index 882bdd75b..e13ec9960 100644 --- a/OpenCL/inc_hash_whirlpool.h +++ b/OpenCL/inc_hash_whirlpool.h @@ -6,21 +6,25 @@ #ifndef _INC_HASH_WHIRLPOOL_H #define _INC_HASH_WHIRLPOOL_H -#define R 10 - #if VECT_SIZE == 1 -#define BOX(S,n,i) (S)[(n)][(i)] +#define BOX(S,i) (S)[(i)] +#define BOX64(S,i) (S)[(i)] #elif VECT_SIZE == 2 -#define BOX(S,n,i) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1]) +#define BOX(S,i) make_u32x ((S)[(i).s0], (S)[(i).s1]) +#define BOX64(S,i) make_u64x ((S)[(i).s0], (S)[(i).s1]) #elif VECT_SIZE == 4 -#define BOX(S,n,i) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3]) +#define BOX(S,i) make_u32x ((S)[(i).s0], (S)[(i).s1], (S)[(i).s2], (S)[(i).s3]) +#define BOX64(S,i) make_u64x ((S)[(i).s0], (S)[(i).s1], (S)[(i).s2], (S)[(i).s3]) #elif VECT_SIZE == 8 -#define BOX(S,n,i) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7]) +#define BOX(S,i) make_u32x ((S)[(i).s0], (S)[(i).s1], (S)[(i).s2], (S)[(i).s3], (S)[(i).s4], (S)[(i).s5], (S)[(i).s6], (S)[(i).s7]) +#define BOX64(S,i) make_u64x ((S)[(i).s0], (S)[(i).s1], (S)[(i).s2], (S)[(i).s3], (S)[(i).s4], (S)[(i).s5], (S)[(i).s6], (S)[(i).s7]) #elif VECT_SIZE == 16 -#define BOX(S,n,i) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) +#define BOX(S,i) make_u32x ((S)[(i).s0], (S)[(i).s1], (S)[(i).s2], (S)[(i).s3], (S)[(i).s4], (S)[(i).s5], (S)[(i).s6], (S)[(i).s7], (S)[(i).s8], (S)[(i).s9], (S)[(i).sa], (S)[(i).sb], (S)[(i).sc], (S)[(i).sd], (S)[(i).se], (S)[(i).sf]) +#define BOX64(S,i) make_u64x ((S)[(i).s0], (S)[(i).s1], (S)[(i).s2], (S)[(i).s3], (S)[(i).s4], (S)[(i).s5], (S)[(i).s6], (S)[(i).s7], (S)[(i).s8], (S)[(i).s9], (S)[(i).sa], (S)[(i).sb], (S)[(i).sc], (S)[(i).sd], (S)[(i).se], (S)[(i).sf]) #endif -#define BOX_S(S,n,i) (S)[(n)][(i)] +#define BOX_S(S,i) (S)[(i)] +#define BOX64_S(S,i) (S)[(i)] typedef struct whirlpool_ctx { @@ -33,8 +37,14 @@ typedef struct whirlpool_ctx int len; - SHM_TYPE u32 (*s_Ch)[256]; - SHM_TYPE u32 (*s_Cl)[256]; + SHM_TYPE u64 *s_MT0; + SHM_TYPE u64 *s_MT1; + SHM_TYPE u64 *s_MT2; + SHM_TYPE u64 *s_MT3; + SHM_TYPE u64 *s_MT4; + SHM_TYPE u64 *s_MT5; + SHM_TYPE u64 *s_MT6; + SHM_TYPE u64 *s_MT7; } whirlpool_ctx_t; @@ -56,8 +66,14 @@ typedef struct whirlpool_ctx_vector int len; - SHM_TYPE u32 (*s_Ch)[256]; - SHM_TYPE u32 (*s_Cl)[256]; + SHM_TYPE u64 *s_MT0; + SHM_TYPE u64 *s_MT1; + SHM_TYPE u64 *s_MT2; + SHM_TYPE u64 *s_MT3; + SHM_TYPE u64 *s_MT4; + SHM_TYPE u64 *s_MT5; + SHM_TYPE u64 *s_MT6; + SHM_TYPE u64 *s_MT7; } whirlpool_ctx_vector_t; @@ -68,8 +84,8 @@ typedef struct whirlpool_hmac_ctx_vector } whirlpool_hmac_ctx_vector_t; -DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void whirlpool_update (whirlpool_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_update_swap (whirlpool_ctx_t *ctx, const u32 *w, const int len); @@ -80,11 +96,11 @@ DECLSPEC void whirlpool_update_global_swap (whirlpool_ctx_t *ctx, GLOBAL_AS cons DECLSPEC void whirlpool_update_global_utf16le (whirlpool_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); DECLSPEC void whirlpool_update_global_utf16le_swap (whirlpool_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); DECLSPEC void whirlpool_final (whirlpool_ctx_t *ctx); -DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_64 (whirlpool_hmac_ctx_t *ctx, const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_hmac_init (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_hmac_init_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_hmac_init_global (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_hmac_init_global_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); DECLSPEC void whirlpool_hmac_update_64 (whirlpool_hmac_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int len); DECLSPEC void whirlpool_hmac_update (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_swap (whirlpool_hmac_ctx_t *ctx, const u32 *w, const int len); @@ -95,8 +111,8 @@ DECLSPEC void whirlpool_hmac_update_global_swap (whirlpool_hmac_ctx_t *ctx, GLOB DECLSPEC void whirlpool_hmac_update_global_utf16le (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); DECLSPEC void whirlpool_hmac_update_global_utf16le_swap (whirlpool_hmac_ctx_t *ctx, GLOBAL_AS const u32 *w, const int len); DECLSPEC void whirlpool_hmac_final (whirlpool_hmac_ctx_t *ctx); -DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_transform_vector (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_init_vector (whirlpool_ctx_vector_t *ctx, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, whirlpool_ctx_t *ctx0); DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void whirlpool_update_vector (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); @@ -104,8 +120,8 @@ DECLSPEC void whirlpool_update_vector_swap (whirlpool_ctx_vector_t *ctx, const u DECLSPEC void whirlpool_update_vector_utf16le (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_update_vector_utf16le_swap (whirlpool_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_final_vector (whirlpool_ctx_vector_t *ctx); -DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); -DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]); +DECLSPEC void whirlpool_hmac_init_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); +DECLSPEC void whirlpool_hmac_init_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7); DECLSPEC void whirlpool_hmac_update_vector_64 (whirlpool_hmac_ctx_vector_t *ctx, u32x *w0, u32x *w1, u32x *w2, u32x *w3, const int len); DECLSPEC void whirlpool_hmac_update_vector (whirlpool_hmac_ctx_vector_t *ctx, const u32x *w, const int len); DECLSPEC void whirlpool_hmac_final_vector (whirlpool_hmac_ctx_vector_t *ctx); diff --git a/OpenCL/inc_rp.cl b/OpenCL/inc_rp.cl index d67127317..1d17b365e 100644 --- a/OpenCL/inc_rp.cl +++ b/OpenCL/inc_rp.cl @@ -298,9 +298,17 @@ DECLSPEC int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const if (out_len >= RP_PASSWORD_SIZE) return (len); - u8 *out = buf + len; + int out_pos = len; - for (int t = 0; t < p0; t++) for (int i = 0; i < len; i++) *out++ = *buf++; + for (int t = 0; t < p0; t++) + { + for (int i = 0; i < len; i++) + { + buf[out_pos] = buf[i]; + + out_pos++; + } + } return (out_len); } @@ -769,6 +777,7 @@ DECLSPEC int apply_rules (CONSTANT_AS const u32 *cmds, u32 *buf, const int in_le const u8 p0 = (cmd >> 8) & 0xff; const u8 p1 = (cmd >> 16) & 0xff; + // we need to guarantee input length < 256 otherwise functions like rule_op_mangle_switch_last() and others will read out of boundary out_len = apply_rule (name, p0, p1, buf, out_len); } diff --git a/OpenCL/inc_rp_optimized.cl b/OpenCL/inc_rp_optimized.cl index 6a21bd688..36ee6263b 100644 --- a/OpenCL/inc_rp_optimized.cl +++ b/OpenCL/inc_rp_optimized.cl @@ -2349,6 +2349,7 @@ DECLSPEC u32 apply_rules_optimized (CONSTANT_AS const u32 *cmds, u32 *buf0, u32 const u32 p0 = (cmd >> 8) & 0xff; const u32 p1 = (cmd >> 16) & 0xff; + // we need to guarantee input length < 32 otherwise functions like rule_op_mangle_switch_last() and others will read out of boundary out_len = apply_rule_optimized (name, p0, p1, buf0, buf1, out_len); } diff --git a/OpenCL/inc_vendor.h b/OpenCL/inc_vendor.h index f2f201e19..6ca2c5707 100644 --- a/OpenCL/inc_vendor.h +++ b/OpenCL/inc_vendor.h @@ -88,6 +88,10 @@ #define IS_GENERIC #endif +#if defined IS_AMD && HAS_VPERM == 1 +#define IS_ROCM +#endif + #define LOCAL_MEM_TYPE_LOCAL 1 #define LOCAL_MEM_TYPE_GLOBAL 2 @@ -95,6 +99,11 @@ #define REAL_SHM #endif +// So far, only used by -m 22100 and only affects NVIDIA on OpenCL. CUDA seems to work fine. +#ifdef FORCE_DISABLE_SHM +#undef REAL_SHM +#endif + #ifdef REAL_SHM #define SHM_TYPE LOCAL_AS #else @@ -106,17 +115,11 @@ * fast but pure kernels on rocm is a good example */ -#if defined IS_CPU -#define DECLSPEC inline -#elif defined IS_GPU -#if defined IS_AMD +#if defined IS_AMD && defined IS_GPU #define DECLSPEC inline static #else #define DECLSPEC #endif -#else -#define DECLSPEC -#endif /** * AMD specific @@ -131,17 +134,30 @@ #endif #endif -/** - * Unrolling is generally enabled, for all device types and hash modes - * There's a few exception when it's better not to unroll - * Some algorithms run into too much register pressure due to loop unrolling - */ +// Whitelist some OpenCL specific functions +// This could create more stable kernels on systems with bad OpenCL drivers -// generic vendors: those algos have shown that they produce better results on both amd and nv when not unrolled -// so we can assume they will produce better results on other vendors as well +#ifdef IS_CUDA +#define USE_BITSELECT +#define USE_ROTATE +#endif -#ifdef NO_UNROLL -#undef _unroll +#ifdef IS_ROCM +#define USE_BITSELECT +#define USE_ROTATE +#endif + +#ifdef IS_INTEL_SDK +#ifdef IS_CPU +//#define USE_BITSELECT +//#define USE_ROTATE +#endif +#endif + +#ifdef IS_OPENCL +//#define USE_BITSELECT +//#define USE_ROTATE +//#define USE_SWIZZLE #endif #endif diff --git a/OpenCL/inc_zip_inflate.cl b/OpenCL/inc_zip_inflate.cl index d43d6bc10..d05f6a792 100644 --- a/OpenCL/inc_zip_inflate.cl +++ b/OpenCL/inc_zip_inflate.cl @@ -209,6 +209,15 @@ DECLSPEC void *memset(u8 *s, int c, u32 len){ #define TINFL_MEMSET(p, c, l) memset(p, c, (u32)l) #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) +// hashcat-patched/hashcat-specific: +#ifdef CRC32_IN_INFLATE +#define M_DICT_SIZE 1 +#define MAYBE_GLOBAL GLOBAL_AS +#else +#define M_DICT_SIZE TINFL_LZ_DICT_SIZE +#define MAYBE_GLOBAL +#endif + #define TINFL_CR_FINISH } #define TINFL_CR_BEGIN \ switch (r->m_state) \ @@ -411,14 +420,16 @@ typedef struct tinfl_decompressor m_decomp; mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits; - mz_uint8 m_dict[1]; // hashcat-patched: we do not need m_dict because we have our own output buffer + // hashcat-patched: we do not need m_dict in case of CRC32 checksums, + // because we have our own output buffer: + mz_uint8 m_dict[M_DICT_SIZE]; tinfl_status m_last_status; } inflate_state; typedef struct mz_stream_s { - GLOBAL_AS const unsigned char *next_in; /* pointer to next byte to read */ + MAYBE_GLOBAL const unsigned char *next_in; /* pointer to next byte to read */ unsigned int avail_in; /* number of bytes available at next_in */ mz_ulong total_in; /* total number of bytes consumed so far */ @@ -457,9 +468,10 @@ DECLSPEC int mz_inflateEnd(mz_streamp pStream); DECLSPEC int mz_inflateInit2(mz_streamp pStream, int window_bits, inflate_state*); - +// hashcat-patched/hashcat-specific: DECLSPEC const mz_uint8 pIn_xor_byte (const mz_uint8 c, mz_streamp pStream) { + #ifdef CRC32_IN_INFLATE mz_uint8 r = c; u32 key3; @@ -469,18 +481,21 @@ DECLSPEC const mz_uint8 pIn_xor_byte (const mz_uint8 c, mz_streamp pStream) update_key012 (pStream->key0, pStream->key1, pStream->key2, plain, pStream->crc32tab); return (mz_uint8) plain; + #else + return c; + #endif } -DECLSPEC void memcpy_g(void *dest, GLOBAL_AS const void *src, size_t n, mz_streamp pStream){ - GLOBAL_AS char *csrc = (GLOBAL_AS char *)src; +DECLSPEC void memcpy_g(void *dest, MAYBE_GLOBAL const void *src, size_t n, mz_streamp pStream){ + MAYBE_GLOBAL char *csrc = (MAYBE_GLOBAL char *)src; char *cdest = (char *)dest; for (int i=0; i 0) { @@ -1008,10 +1023,12 @@ DECLSPEC int mz_inflate(mz_streamp pStream, int flush) out_bytes = pStream->avail_out; status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags, pStream); + #ifdef CRC32_IN_INFLATE for (int i = 0; i < out_bytes; i++) { pStream->crc32 = CRC32 (pStream->crc32, pStream->next_out[i], pStream->crc32tab); } + #endif pState->m_last_status = status; pStream->next_in += (mz_uint)in_bytes; @@ -1040,10 +1057,12 @@ DECLSPEC int mz_inflate(mz_streamp pStream, int flush) n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); + #ifdef CRC32_IN_INFLATE for (int i = 0; i < n; i++) { pStream->crc32 = CRC32 (pStream->crc32, pStream->next_out[i], pStream->crc32tab); } + #endif //pStream->next_out += n; //pStream->avail_out -= n; @@ -1072,10 +1091,12 @@ DECLSPEC int mz_inflate(mz_streamp pStream, int flush) n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); + #ifdef CRC32_IN_INFLATE for (int i = 0; i < n; i++) { pStream->crc32 = CRC32 (pStream->crc32, pStream->next_out[i], pStream->crc32tab); } + #endif //pStream->next_out += n; //pStream->avail_out -= n; @@ -1158,10 +1179,12 @@ DECLSPEC int hc_inflate (mz_streamp pStream) tinfl_status status = tinfl_decompress (&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out + pStream->total_out, &out_bytes, decomp_flags, pStream); + #ifdef CRC32_IN_INFLATE for (int i = 0; i < out_bytes; i++) { pStream->crc32 = CRC32 (pStream->crc32, pStream->next_out[pStream->total_out + i], pStream->crc32tab); } + #endif pStream->next_in += (mz_uint) in_bytes; pStream->avail_in -= (mz_uint) in_bytes; diff --git a/OpenCL/m00200_a0-optimized.cl b/OpenCL/m00200_a0-optimized.cl index c5d334f36..ab9071cb0 100644 --- a/OpenCL/m00200_a0-optimized.cl +++ b/OpenCL/m00200_a0-optimized.cl @@ -99,10 +99,10 @@ KERNEL_FQ void m00200_m04 (KERN_ATTR_RULES ()) { const u32x wj = w_t[j]; - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); - ROUND ((wj >> 24) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); + ROUND (unpack_v8d_from_v32 (wj)); } const u32x wj = w_t[j]; @@ -111,18 +111,18 @@ KERNEL_FQ void m00200_m04 (KERN_ATTR_RULES ()) if (left == 3) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); } else if (left == 2) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); } else if (left == 1) { - ROUND ((wj >> 0) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); } a &= 0x7fffffff; @@ -237,10 +237,10 @@ KERNEL_FQ void m00200_s04 (KERN_ATTR_RULES ()) { const u32x wj = w_t[j]; - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); - ROUND ((wj >> 24) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); + ROUND (unpack_v8d_from_v32 (wj)); } const u32x wj = w_t[j]; @@ -249,18 +249,18 @@ KERNEL_FQ void m00200_s04 (KERN_ATTR_RULES ()) if (left == 3) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); } else if (left == 2) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); } else if (left == 1) { - ROUND ((wj >> 0) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); } a &= 0x7fffffff; diff --git a/OpenCL/m00200_a1-optimized.cl b/OpenCL/m00200_a1-optimized.cl index 5589a386a..16b5054ab 100644 --- a/OpenCL/m00200_a1-optimized.cl +++ b/OpenCL/m00200_a1-optimized.cl @@ -142,6 +142,8 @@ KERNEL_FQ void m00200_m04 (KERN_ATTR_BASIC ()) u32x a = MYSQL323_A; u32x b = MYSQL323_B; + u32x c = 0; + u32x d = 0; u32x add = 7; @@ -159,10 +161,10 @@ KERNEL_FQ void m00200_m04 (KERN_ATTR_BASIC ()) { const u32x wj = w_t[j]; - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); - ROUND ((wj >> 24) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); + ROUND (unpack_v8d_from_v32 (wj)); } const u32x wj = w_t[j]; @@ -171,18 +173,18 @@ KERNEL_FQ void m00200_m04 (KERN_ATTR_BASIC ()) if (left == 3) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); } else if (left == 2) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); } else if (left == 1) { - ROUND ((wj >> 0) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); } a &= 0x7fffffff; @@ -361,10 +363,10 @@ KERNEL_FQ void m00200_s04 (KERN_ATTR_BASIC ()) { const u32x wj = w_t[j]; - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); - ROUND ((wj >> 24) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); + ROUND (unpack_v8d_from_v32 (wj)); } const u32x wj = w_t[j]; @@ -373,18 +375,18 @@ KERNEL_FQ void m00200_s04 (KERN_ATTR_BASIC ()) if (left == 3) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); - ROUND ((wj >> 16) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); + ROUND (unpack_v8c_from_v32 (wj)); } else if (left == 2) { - ROUND ((wj >> 0) & 0xff); - ROUND ((wj >> 8) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); + ROUND (unpack_v8b_from_v32 (wj)); } else if (left == 1) { - ROUND ((wj >> 0) & 0xff); + ROUND (unpack_v8a_from_v32 (wj)); } a &= 0x7fffffff; diff --git a/OpenCL/m00200_a3-optimized.cl b/OpenCL/m00200_a3-optimized.cl index 74a1c3234..1a9b72e39 100644 --- a/OpenCL/m00200_a3-optimized.cl +++ b/OpenCL/m00200_a3-optimized.cl @@ -42,10 +42,10 @@ { \ const u32 wj = w[j]; \ \ - ROUND ((wj >> 0) & 0xff); \ - ROUND ((wj >> 8) & 0xff); \ - ROUND ((wj >> 16) & 0xff); \ - ROUND ((wj >> 24) & 0xff); \ + ROUND (unpack_v8a_from_v32 (wj)); \ + ROUND (unpack_v8b_from_v32 (wj)); \ + ROUND (unpack_v8c_from_v32 (wj)); \ + ROUND (unpack_v8d_from_v32 (wj)); \ } \ \ const u32 wj = w[j]; \ @@ -54,18 +54,18 @@ \ if (left == 3) \ { \ - ROUND ((wj >> 0) & 0xff); \ - ROUND ((wj >> 8) & 0xff); \ - ROUND ((wj >> 16) & 0xff); \ + ROUND (unpack_v8a_from_v32 (wj)); \ + ROUND (unpack_v8b_from_v32 (wj)); \ + ROUND (unpack_v8c_from_v32 (wj)); \ } \ else if (left == 2) \ { \ - ROUND ((wj >> 0) & 0xff); \ - ROUND ((wj >> 8) & 0xff); \ + ROUND (unpack_v8a_from_v32 (wj)); \ + ROUND (unpack_v8b_from_v32 (wj)); \ } \ else if (left == 1) \ { \ - ROUND ((wj >> 0) & 0xff); \ + ROUND (unpack_v8a_from_v32 (wj)); \ } #define CODE_POST_M \ @@ -99,141 +99,123 @@ DECLSPEC void m00200m (u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + 0, + 0 + }; + /** * loop */ u32 w0l = w[0]; + CODE_PRE; + switch (pw_len) { case 1: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); break; case 2: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); break; case 3: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); break; case 4: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); break; case 5: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); break; case 6: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); break; case 7: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); break; case 8: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); break; case 9: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); break; case 10: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); break; case 11: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); break; case 12: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); break; case 13: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); break; case 14: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); ROUND ((w[3] >> 8) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); ROUND (unpack_v8b_from_v32 (w[3])); break; case 15: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); ROUND ((w[3] >> 8) & 0xff); ROUND ((w[3] >> 16) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); ROUND (unpack_v8b_from_v32 (w[3])); ROUND (unpack_v8c_from_v32 (w[3])); break; case 16: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); ROUND ((w[3] >> 8) & 0xff); ROUND ((w[3] >> 16) & 0xff); ROUND ((w[3] >> 24) & 0xff); - CODE_POST_M; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); ROUND (unpack_v8b_from_v32 (w[3])); ROUND (unpack_v8c_from_v32 (w[3])); ROUND (unpack_v8d_from_v32 (w[3])); break; default: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); CODE_LOOP (pw_len - 4); - CODE_POST_M; break; } + + CODE_POST_M; } DECLSPEC void m00200s (u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) @@ -263,135 +245,105 @@ DECLSPEC void m00200s (u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) u32 w0l = w[0]; + CODE_PRE; + switch (pw_len) { case 1: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); break; case 2: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); break; case 3: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); break; case 4: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); break; case 5: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); break; case 6: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); break; case 7: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); break; case 8: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); break; case 9: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); break; case 10: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); break; case 11: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); break; case 12: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); break; case 13: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); break; case 14: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); ROUND ((w[3] >> 8) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); ROUND (unpack_v8b_from_v32 (w[3])); break; case 15: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); ROUND ((w[3] >> 8) & 0xff); ROUND ((w[3] >> 16) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); ROUND (unpack_v8b_from_v32 (w[3])); ROUND (unpack_v8c_from_v32 (w[3])); break; case 16: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); - ROUND ((w[1] >> 0) & 0xff); ROUND ((w[1] >> 8) & 0xff); ROUND ((w[1] >> 16) & 0xff); ROUND ((w[1] >> 24) & 0xff); - ROUND ((w[2] >> 0) & 0xff); ROUND ((w[2] >> 8) & 0xff); ROUND ((w[2] >> 16) & 0xff); ROUND ((w[2] >> 24) & 0xff); - ROUND ((w[3] >> 0) & 0xff); ROUND ((w[3] >> 8) & 0xff); ROUND ((w[3] >> 16) & 0xff); ROUND ((w[3] >> 24) & 0xff); - CODE_POST_S; + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); + ROUND (unpack_v8a_from_v32 (w[1])); ROUND (unpack_v8b_from_v32 (w[1])); ROUND (unpack_v8c_from_v32 (w[1])); ROUND (unpack_v8d_from_v32 (w[1])); + ROUND (unpack_v8a_from_v32 (w[2])); ROUND (unpack_v8b_from_v32 (w[2])); ROUND (unpack_v8c_from_v32 (w[2])); ROUND (unpack_v8d_from_v32 (w[2])); + ROUND (unpack_v8a_from_v32 (w[3])); ROUND (unpack_v8b_from_v32 (w[3])); ROUND (unpack_v8c_from_v32 (w[3])); ROUND (unpack_v8d_from_v32 (w[3])); break; default: - CODE_PRE; - ROUND ((w0 >> 0) & 0xff); ROUND ((w0 >> 8) & 0xff); ROUND ((w0 >> 16) & 0xff); ROUND ((w0 >> 24) & 0xff); + ROUND (unpack_v8a_from_v32 ( w0)); ROUND (unpack_v8b_from_v32 ( w0)); ROUND (unpack_v8c_from_v32 ( w0)); ROUND (unpack_v8d_from_v32 ( w0)); CODE_LOOP (pw_len - 4); - CODE_POST_S; break; } + + CODE_POST_S; } KERNEL_FQ void m00200_m04 (KERN_ATTR_VECTOR ()) diff --git a/OpenCL/m00600_a0-optimized.cl b/OpenCL/m00600_a0-optimized.cl index e72920690..272fc6d97 100644 --- a/OpenCL/m00600_a0-optimized.cl +++ b/OpenCL/m00600_a0-optimized.cl @@ -28,28 +28,28 @@ typedef struct blake2 #define BLAKE2B_FINAL 1 #define BLAKE2B_UPDATE 0 -#define BLAKE2B_G(r,i,a,b,c,d) \ - do { \ - a = a + b + m[blake2b_sigma[r][2*i+0]]; \ - d = hc_rotr64 (d ^ a, 32); \ - c = c + d; \ - b = hc_rotr64 (b ^ c, 24); \ - a = a + b + m[blake2b_sigma[r][2*i+1]]; \ - d = hc_rotr64 (d ^ a, 16); \ - c = c + d; \ - b = hc_rotr64 (b ^ c, 63); \ +#define BLAKE2B_G(k0,k1,a,b,c,d) \ + do { \ + a = a + b + m[(k0)]; \ + d = hc_rotr64 (d ^ a, 32); \ + c = c + d; \ + b = hc_rotr64 (b ^ c, 24); \ + a = a + b + m[(k1)]; \ + d = hc_rotr64 (d ^ a, 16); \ + c = c + d; \ + b = hc_rotr64 (b ^ c, 63); \ } while(0) -#define BLAKE2B_ROUND(r) \ - do { \ - BLAKE2B_G (r,0,v[ 0],v[ 4],v[ 8],v[12]); \ - BLAKE2B_G (r,1,v[ 1],v[ 5],v[ 9],v[13]); \ - BLAKE2B_G (r,2,v[ 2],v[ 6],v[10],v[14]); \ - BLAKE2B_G (r,3,v[ 3],v[ 7],v[11],v[15]); \ - BLAKE2B_G (r,4,v[ 0],v[ 5],v[10],v[15]); \ - BLAKE2B_G (r,5,v[ 1],v[ 6],v[11],v[12]); \ - BLAKE2B_G (r,6,v[ 2],v[ 7],v[ 8],v[13]); \ - BLAKE2B_G (r,7,v[ 3],v[ 4],v[ 9],v[14]); \ +#define BLAKE2B_ROUND(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cc,cd,ce,cf) \ + do { \ + BLAKE2B_G ((c0),(c1),v[ 0],v[ 4],v[ 8],v[12]); \ + BLAKE2B_G ((c2),(c3),v[ 1],v[ 5],v[ 9],v[13]); \ + BLAKE2B_G ((c4),(c5),v[ 2],v[ 6],v[10],v[14]); \ + BLAKE2B_G ((c6),(c7),v[ 3],v[ 7],v[11],v[15]); \ + BLAKE2B_G ((c8),(c9),v[ 0],v[ 5],v[10],v[15]); \ + BLAKE2B_G ((ca),(cb),v[ 1],v[ 6],v[11],v[12]); \ + BLAKE2B_G ((cc),(cd),v[ 2],v[ 7],v[ 8],v[13]); \ + BLAKE2B_G ((ce),(cf),v[ 3],v[ 4],v[ 9],v[14]); \ } while(0) DECLSPEC void blake2b_transform (u64x *h, u64x *t, u64x *f, u64x *m, u64x *v, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x out_len, const u8 isFinal) @@ -93,34 +93,18 @@ DECLSPEC void blake2b_transform (u64x *h, u64x *t, u64x *f, u64x *m, u64x *v, co v[14] = BLAKE2B_IV_06 ^ f[0]; v[15] = BLAKE2B_IV_07 ^ f[1]; - const int blake2b_sigma[12][16] = - { - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } , - { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } , - { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } , - { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } , - { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } , - { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } , - { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } , - { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } , - { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } , - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } - }; - - BLAKE2B_ROUND ( 0); - BLAKE2B_ROUND ( 1); - BLAKE2B_ROUND ( 2); - BLAKE2B_ROUND ( 3); - BLAKE2B_ROUND ( 4); - BLAKE2B_ROUND ( 5); - BLAKE2B_ROUND ( 6); - BLAKE2B_ROUND ( 7); - BLAKE2B_ROUND ( 8); - BLAKE2B_ROUND ( 9); - BLAKE2B_ROUND (10); - BLAKE2B_ROUND (11); + BLAKE2B_ROUND ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + BLAKE2B_ROUND (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); + BLAKE2B_ROUND (11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4); + BLAKE2B_ROUND ( 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8); + BLAKE2B_ROUND ( 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13); + BLAKE2B_ROUND ( 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9); + BLAKE2B_ROUND (12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11); + BLAKE2B_ROUND (13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10); + BLAKE2B_ROUND ( 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5); + BLAKE2B_ROUND (10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0); + BLAKE2B_ROUND ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + BLAKE2B_ROUND (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); h[0] = h[0] ^ v[0] ^ v[ 8]; h[1] = h[1] ^ v[1] ^ v[ 9]; diff --git a/OpenCL/m00600_a1-optimized.cl b/OpenCL/m00600_a1-optimized.cl index 9547523ac..8b51bfcf0 100644 --- a/OpenCL/m00600_a1-optimized.cl +++ b/OpenCL/m00600_a1-optimized.cl @@ -26,28 +26,28 @@ typedef struct blake2 #define BLAKE2B_FINAL 1 #define BLAKE2B_UPDATE 0 -#define BLAKE2B_G(r,i,a,b,c,d) \ - do { \ - a = a + b + m[blake2b_sigma[r][2*i+0]]; \ - d = hc_rotr64 (d ^ a, 32); \ - c = c + d; \ - b = hc_rotr64 (b ^ c, 24); \ - a = a + b + m[blake2b_sigma[r][2*i+1]]; \ - d = hc_rotr64 (d ^ a, 16); \ - c = c + d; \ - b = hc_rotr64 (b ^ c, 63); \ +#define BLAKE2B_G(k0,k1,a,b,c,d) \ + do { \ + a = a + b + m[(k0)]; \ + d = hc_rotr64 (d ^ a, 32); \ + c = c + d; \ + b = hc_rotr64 (b ^ c, 24); \ + a = a + b + m[(k1)]; \ + d = hc_rotr64 (d ^ a, 16); \ + c = c + d; \ + b = hc_rotr64 (b ^ c, 63); \ } while(0) -#define BLAKE2B_ROUND(r) \ - do { \ - BLAKE2B_G (r,0,v[ 0],v[ 4],v[ 8],v[12]); \ - BLAKE2B_G (r,1,v[ 1],v[ 5],v[ 9],v[13]); \ - BLAKE2B_G (r,2,v[ 2],v[ 6],v[10],v[14]); \ - BLAKE2B_G (r,3,v[ 3],v[ 7],v[11],v[15]); \ - BLAKE2B_G (r,4,v[ 0],v[ 5],v[10],v[15]); \ - BLAKE2B_G (r,5,v[ 1],v[ 6],v[11],v[12]); \ - BLAKE2B_G (r,6,v[ 2],v[ 7],v[ 8],v[13]); \ - BLAKE2B_G (r,7,v[ 3],v[ 4],v[ 9],v[14]); \ +#define BLAKE2B_ROUND(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cc,cd,ce,cf) \ + do { \ + BLAKE2B_G ((c0),(c1),v[ 0],v[ 4],v[ 8],v[12]); \ + BLAKE2B_G ((c2),(c3),v[ 1],v[ 5],v[ 9],v[13]); \ + BLAKE2B_G ((c4),(c5),v[ 2],v[ 6],v[10],v[14]); \ + BLAKE2B_G ((c6),(c7),v[ 3],v[ 7],v[11],v[15]); \ + BLAKE2B_G ((c8),(c9),v[ 0],v[ 5],v[10],v[15]); \ + BLAKE2B_G ((ca),(cb),v[ 1],v[ 6],v[11],v[12]); \ + BLAKE2B_G ((cc),(cd),v[ 2],v[ 7],v[ 8],v[13]); \ + BLAKE2B_G ((ce),(cf),v[ 3],v[ 4],v[ 9],v[14]); \ } while(0) DECLSPEC void blake2b_transform (u64x *h, u64x *t, u64x *f, u64x *m, u64x *v, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x out_len, const u8 isFinal) @@ -91,34 +91,18 @@ DECLSPEC void blake2b_transform (u64x *h, u64x *t, u64x *f, u64x *m, u64x *v, co v[14] = BLAKE2B_IV_06 ^ f[0]; v[15] = BLAKE2B_IV_07 ^ f[1]; - const int blake2b_sigma[12][16] = - { - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } , - { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } , - { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } , - { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } , - { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } , - { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } , - { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } , - { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } , - { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } , - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } - }; - - BLAKE2B_ROUND ( 0); - BLAKE2B_ROUND ( 1); - BLAKE2B_ROUND ( 2); - BLAKE2B_ROUND ( 3); - BLAKE2B_ROUND ( 4); - BLAKE2B_ROUND ( 5); - BLAKE2B_ROUND ( 6); - BLAKE2B_ROUND ( 7); - BLAKE2B_ROUND ( 8); - BLAKE2B_ROUND ( 9); - BLAKE2B_ROUND (10); - BLAKE2B_ROUND (11); + BLAKE2B_ROUND ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + BLAKE2B_ROUND (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); + BLAKE2B_ROUND (11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4); + BLAKE2B_ROUND ( 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8); + BLAKE2B_ROUND ( 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13); + BLAKE2B_ROUND ( 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9); + BLAKE2B_ROUND (12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11); + BLAKE2B_ROUND (13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10); + BLAKE2B_ROUND ( 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5); + BLAKE2B_ROUND (10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0); + BLAKE2B_ROUND ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + BLAKE2B_ROUND (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); h[0] = h[0] ^ v[0] ^ v[ 8]; h[1] = h[1] ^ v[1] ^ v[ 9]; diff --git a/OpenCL/m00600_a3-optimized.cl b/OpenCL/m00600_a3-optimized.cl index 2545bdca5..1ae51223f 100644 --- a/OpenCL/m00600_a3-optimized.cl +++ b/OpenCL/m00600_a3-optimized.cl @@ -26,28 +26,28 @@ typedef struct blake2 #define BLAKE2B_FINAL 1 #define BLAKE2B_UPDATE 0 -#define BLAKE2B_G(r,i,a,b,c,d) \ - do { \ - a = a + b + m[blake2b_sigma[r][2*i+0]]; \ - d = hc_rotr64 (d ^ a, 32); \ - c = c + d; \ - b = hc_rotr64 (b ^ c, 24); \ - a = a + b + m[blake2b_sigma[r][2*i+1]]; \ - d = hc_rotr64 (d ^ a, 16); \ - c = c + d; \ - b = hc_rotr64 (b ^ c, 63); \ +#define BLAKE2B_G(k0,k1,a,b,c,d) \ + do { \ + a = a + b + m[(k0)]; \ + d = hc_rotr64 (d ^ a, 32); \ + c = c + d; \ + b = hc_rotr64 (b ^ c, 24); \ + a = a + b + m[(k1)]; \ + d = hc_rotr64 (d ^ a, 16); \ + c = c + d; \ + b = hc_rotr64 (b ^ c, 63); \ } while(0) -#define BLAKE2B_ROUND(r) \ - do { \ - BLAKE2B_G (r,0,v[ 0],v[ 4],v[ 8],v[12]); \ - BLAKE2B_G (r,1,v[ 1],v[ 5],v[ 9],v[13]); \ - BLAKE2B_G (r,2,v[ 2],v[ 6],v[10],v[14]); \ - BLAKE2B_G (r,3,v[ 3],v[ 7],v[11],v[15]); \ - BLAKE2B_G (r,4,v[ 0],v[ 5],v[10],v[15]); \ - BLAKE2B_G (r,5,v[ 1],v[ 6],v[11],v[12]); \ - BLAKE2B_G (r,6,v[ 2],v[ 7],v[ 8],v[13]); \ - BLAKE2B_G (r,7,v[ 3],v[ 4],v[ 9],v[14]); \ +#define BLAKE2B_ROUND(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cc,cd,ce,cf) \ + do { \ + BLAKE2B_G ((c0),(c1),v[ 0],v[ 4],v[ 8],v[12]); \ + BLAKE2B_G ((c2),(c3),v[ 1],v[ 5],v[ 9],v[13]); \ + BLAKE2B_G ((c4),(c5),v[ 2],v[ 6],v[10],v[14]); \ + BLAKE2B_G ((c6),(c7),v[ 3],v[ 7],v[11],v[15]); \ + BLAKE2B_G ((c8),(c9),v[ 0],v[ 5],v[10],v[15]); \ + BLAKE2B_G ((ca),(cb),v[ 1],v[ 6],v[11],v[12]); \ + BLAKE2B_G ((cc),(cd),v[ 2],v[ 7],v[ 8],v[13]); \ + BLAKE2B_G ((ce),(cf),v[ 3],v[ 4],v[ 9],v[14]); \ } while(0) DECLSPEC void blake2b_transform (u64x *h, u64x *t, u64x *f, u64x *m, u64x *v, const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, const u32x out_len, const u8 isFinal) @@ -91,34 +91,18 @@ DECLSPEC void blake2b_transform (u64x *h, u64x *t, u64x *f, u64x *m, u64x *v, co v[14] = BLAKE2B_IV_06 ^ f[0]; v[15] = BLAKE2B_IV_07 ^ f[1]; - const int blake2b_sigma[12][16] = - { - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } , - { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } , - { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } , - { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } , - { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } , - { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } , - { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } , - { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } , - { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } , - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } - }; - - BLAKE2B_ROUND ( 0); - BLAKE2B_ROUND ( 1); - BLAKE2B_ROUND ( 2); - BLAKE2B_ROUND ( 3); - BLAKE2B_ROUND ( 4); - BLAKE2B_ROUND ( 5); - BLAKE2B_ROUND ( 6); - BLAKE2B_ROUND ( 7); - BLAKE2B_ROUND ( 8); - BLAKE2B_ROUND ( 9); - BLAKE2B_ROUND (10); - BLAKE2B_ROUND (11); + BLAKE2B_ROUND ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + BLAKE2B_ROUND (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); + BLAKE2B_ROUND (11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4); + BLAKE2B_ROUND ( 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8); + BLAKE2B_ROUND ( 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13); + BLAKE2B_ROUND ( 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9); + BLAKE2B_ROUND (12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11); + BLAKE2B_ROUND (13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10); + BLAKE2B_ROUND ( 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5); + BLAKE2B_ROUND (10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0); + BLAKE2B_ROUND ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + BLAKE2B_ROUND (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); h[0] = h[0] ^ v[0] ^ v[ 8]; h[1] = h[1] ^ v[1] ^ v[ 9]; diff --git a/OpenCL/m01500_a3-pure.cl b/OpenCL/m01500_a3-pure.cl index ca612828d..a751c55fe 100644 --- a/OpenCL/m01500_a3-pure.cl +++ b/OpenCL/m01500_a3-pure.cl @@ -16,7 +16,6 @@ #define COMPARE_M "inc_comp_multi_bs.cl" #ifdef IS_NV -#undef _unroll #define KXX_DECL #endif @@ -1998,296 +1997,293 @@ KERNEL_FQ void m01500_mxx (KERN_ATTR_BITSLICE ()) * inner loop */ - #ifdef IS_CUDA - const u32 pc_pos = (blockIdx.y * blockDim.y) + threadIdx.y; - #else - const u32 pc_pos = get_global_id (1); - #endif - - const u32 il_pos = pc_pos * 32; - - u32 k00 = K00; - u32 k01 = K01; - u32 k02 = K02; - u32 k03 = K03; - u32 k04 = K04; - u32 k05 = K05; - u32 k06 = K06; - u32 k07 = K07; - u32 k08 = K08; - u32 k09 = K09; - u32 k10 = K10; - u32 k11 = K11; - u32 k12 = K12; - u32 k13 = K13; - u32 k14 = K14; - u32 k15 = K15; - u32 k16 = K16; - u32 k17 = K17; - u32 k18 = K18; - u32 k19 = K19; - u32 k20 = K20; - u32 k21 = K21; - u32 k22 = K22; - u32 k23 = K23; - u32 k24 = K24; - u32 k25 = K25; - u32 k26 = K26; - u32 k27 = K27; - - k00 |= words_buf_s[pc_pos].b[ 0]; - k01 |= words_buf_s[pc_pos].b[ 1]; - k02 |= words_buf_s[pc_pos].b[ 2]; - k03 |= words_buf_s[pc_pos].b[ 3]; - k04 |= words_buf_s[pc_pos].b[ 4]; - k05 |= words_buf_s[pc_pos].b[ 5]; - k06 |= words_buf_s[pc_pos].b[ 6]; - k07 |= words_buf_s[pc_pos].b[ 7]; - k08 |= words_buf_s[pc_pos].b[ 8]; - k09 |= words_buf_s[pc_pos].b[ 9]; - k10 |= words_buf_s[pc_pos].b[10]; - k11 |= words_buf_s[pc_pos].b[11]; - k12 |= words_buf_s[pc_pos].b[12]; - k13 |= words_buf_s[pc_pos].b[13]; - k14 |= words_buf_s[pc_pos].b[14]; - k15 |= words_buf_s[pc_pos].b[15]; - k16 |= words_buf_s[pc_pos].b[16]; - k17 |= words_buf_s[pc_pos].b[17]; - k18 |= words_buf_s[pc_pos].b[18]; - k19 |= words_buf_s[pc_pos].b[19]; - k20 |= words_buf_s[pc_pos].b[20]; - k21 |= words_buf_s[pc_pos].b[21]; - k22 |= words_buf_s[pc_pos].b[22]; - k23 |= words_buf_s[pc_pos].b[23]; - k24 |= words_buf_s[pc_pos].b[24]; - k25 |= words_buf_s[pc_pos].b[25]; - k26 |= words_buf_s[pc_pos].b[26]; - k27 |= words_buf_s[pc_pos].b[27]; - - u32 D00 = 0; - u32 D01 = 0; - u32 D02 = 0; - u32 D03 = 0; - u32 D04 = 0; - u32 D05 = 0; - u32 D06 = 0; - u32 D07 = 0; - u32 D08 = 0; - u32 D09 = 0; - u32 D10 = 0; - u32 D11 = 0; - u32 D12 = 0; - u32 D13 = 0; - u32 D14 = 0; - u32 D15 = 0; - u32 D16 = 0; - u32 D17 = 0; - u32 D18 = 0; - u32 D19 = 0; - u32 D20 = 0; - u32 D21 = 0; - u32 D22 = 0; - u32 D23 = 0; - u32 D24 = 0; - u32 D25 = 0; - u32 D26 = 0; - u32 D27 = 0; - u32 D28 = 0; - u32 D29 = 0; - u32 D30 = 0; - u32 D31 = 0; - u32 D32 = 0; - u32 D33 = 0; - u32 D34 = 0; - u32 D35 = 0; - u32 D36 = 0; - u32 D37 = 0; - u32 D38 = 0; - u32 D39 = 0; - u32 D40 = 0; - u32 D41 = 0; - u32 D42 = 0; - u32 D43 = 0; - u32 D44 = 0; - u32 D45 = 0; - u32 D46 = 0; - u32 D47 = 0; - u32 D48 = 0; - u32 D49 = 0; - u32 D50 = 0; - u32 D51 = 0; - u32 D52 = 0; - u32 D53 = 0; - u32 D54 = 0; - u32 D55 = 0; - u32 D56 = 0; - u32 D57 = 0; - u32 D58 = 0; - u32 D59 = 0; - u32 D60 = 0; - u32 D61 = 0; - u32 D62 = 0; - u32 D63 = 0; - - DESCrypt - ( - salt, - k00, k01, k02, k03, k04, k05, k06, - k07, k08, k09, k10, k11, k12, k13, - k14, k15, k16, k17, k18, k19, k20, - k21, k22, k23, k24, k25, k26, k27, - K28, K29, K30, K31, K32, K33, K34, - K35, K36, K37, K38, K39, K40, K41, - K42, K43, K44, K45, K46, K47, K48, - K49, K50, K51, K52, K53, K54, K55, - &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, - &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, - &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, - &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, - &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, - &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, - &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, - &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 - ); - - u32 out[64]; - - out[ 0] = D00; - out[ 1] = D01; - out[ 2] = D02; - out[ 3] = D03; - out[ 4] = D04; - out[ 5] = D05; - out[ 6] = D06; - out[ 7] = D07; - out[ 8] = D08; - out[ 9] = D09; - out[10] = D10; - out[11] = D11; - out[12] = D12; - out[13] = D13; - out[14] = D14; - out[15] = D15; - out[16] = D16; - out[17] = D17; - out[18] = D18; - out[19] = D19; - out[20] = D20; - out[21] = D21; - out[22] = D22; - out[23] = D23; - out[24] = D24; - out[25] = D25; - out[26] = D26; - out[27] = D27; - out[28] = D28; - out[29] = D29; - out[30] = D30; - out[31] = D31; - out[32] = D32; - out[33] = D33; - out[34] = D34; - out[35] = D35; - out[36] = D36; - out[37] = D37; - out[38] = D38; - out[39] = D39; - out[40] = D40; - out[41] = D41; - out[42] = D42; - out[43] = D43; - out[44] = D44; - out[45] = D45; - out[46] = D46; - out[47] = D47; - out[48] = D48; - out[49] = D49; - out[50] = D50; - out[51] = D51; - out[52] = D52; - out[53] = D53; - out[54] = D54; - out[55] = D55; - out[56] = D56; - out[57] = D57; - out[58] = D58; - out[59] = D59; - out[60] = D60; - out[61] = D61; - out[62] = D62; - out[63] = D63; - - if (digests_cnt < 16) + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += 32) { - for (u32 d = 0; d < digests_cnt; d++) + u32 k00 = K00; + u32 k01 = K01; + u32 k02 = K02; + u32 k03 = K03; + u32 k04 = K04; + u32 k05 = K05; + u32 k06 = K06; + u32 k07 = K07; + u32 k08 = K08; + u32 k09 = K09; + u32 k10 = K10; + u32 k11 = K11; + u32 k12 = K12; + u32 k13 = K13; + u32 k14 = K14; + u32 k15 = K15; + u32 k16 = K16; + u32 k17 = K17; + u32 k18 = K18; + u32 k19 = K19; + u32 k20 = K20; + u32 k21 = K21; + u32 k22 = K22; + u32 k23 = K23; + u32 k24 = K24; + u32 k25 = K25; + u32 k26 = K26; + u32 k27 = K27; + + const u32 pc_pos = il_pos / 32; + + k00 |= words_buf_s[pc_pos].b[ 0]; + k01 |= words_buf_s[pc_pos].b[ 1]; + k02 |= words_buf_s[pc_pos].b[ 2]; + k03 |= words_buf_s[pc_pos].b[ 3]; + k04 |= words_buf_s[pc_pos].b[ 4]; + k05 |= words_buf_s[pc_pos].b[ 5]; + k06 |= words_buf_s[pc_pos].b[ 6]; + k07 |= words_buf_s[pc_pos].b[ 7]; + k08 |= words_buf_s[pc_pos].b[ 8]; + k09 |= words_buf_s[pc_pos].b[ 9]; + k10 |= words_buf_s[pc_pos].b[10]; + k11 |= words_buf_s[pc_pos].b[11]; + k12 |= words_buf_s[pc_pos].b[12]; + k13 |= words_buf_s[pc_pos].b[13]; + k14 |= words_buf_s[pc_pos].b[14]; + k15 |= words_buf_s[pc_pos].b[15]; + k16 |= words_buf_s[pc_pos].b[16]; + k17 |= words_buf_s[pc_pos].b[17]; + k18 |= words_buf_s[pc_pos].b[18]; + k19 |= words_buf_s[pc_pos].b[19]; + k20 |= words_buf_s[pc_pos].b[20]; + k21 |= words_buf_s[pc_pos].b[21]; + k22 |= words_buf_s[pc_pos].b[22]; + k23 |= words_buf_s[pc_pos].b[23]; + k24 |= words_buf_s[pc_pos].b[24]; + k25 |= words_buf_s[pc_pos].b[25]; + k26 |= words_buf_s[pc_pos].b[26]; + k27 |= words_buf_s[pc_pos].b[27]; + + u32 D00 = 0; + u32 D01 = 0; + u32 D02 = 0; + u32 D03 = 0; + u32 D04 = 0; + u32 D05 = 0; + u32 D06 = 0; + u32 D07 = 0; + u32 D08 = 0; + u32 D09 = 0; + u32 D10 = 0; + u32 D11 = 0; + u32 D12 = 0; + u32 D13 = 0; + u32 D14 = 0; + u32 D15 = 0; + u32 D16 = 0; + u32 D17 = 0; + u32 D18 = 0; + u32 D19 = 0; + u32 D20 = 0; + u32 D21 = 0; + u32 D22 = 0; + u32 D23 = 0; + u32 D24 = 0; + u32 D25 = 0; + u32 D26 = 0; + u32 D27 = 0; + u32 D28 = 0; + u32 D29 = 0; + u32 D30 = 0; + u32 D31 = 0; + u32 D32 = 0; + u32 D33 = 0; + u32 D34 = 0; + u32 D35 = 0; + u32 D36 = 0; + u32 D37 = 0; + u32 D38 = 0; + u32 D39 = 0; + u32 D40 = 0; + u32 D41 = 0; + u32 D42 = 0; + u32 D43 = 0; + u32 D44 = 0; + u32 D45 = 0; + u32 D46 = 0; + u32 D47 = 0; + u32 D48 = 0; + u32 D49 = 0; + u32 D50 = 0; + u32 D51 = 0; + u32 D52 = 0; + u32 D53 = 0; + u32 D54 = 0; + u32 D55 = 0; + u32 D56 = 0; + u32 D57 = 0; + u32 D58 = 0; + u32 D59 = 0; + u32 D60 = 0; + u32 D61 = 0; + u32 D62 = 0; + u32 D63 = 0; + + DESCrypt + ( + salt, + k00, k01, k02, k03, k04, k05, k06, + k07, k08, k09, k10, k11, k12, k13, + k14, k15, k16, k17, k18, k19, k20, + k21, k22, k23, k24, k25, k26, k27, + K28, K29, K30, K31, K32, K33, K34, + K35, K36, K37, K38, K39, K40, K41, + K42, K43, K44, K45, K46, K47, K48, + K49, K50, K51, K52, K53, K54, K55, + &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, + &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, + &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, + &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, + &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, + &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, + &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, + &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 + ); + + u32 out[64]; + + out[ 0] = D00; + out[ 1] = D01; + out[ 2] = D02; + out[ 3] = D03; + out[ 4] = D04; + out[ 5] = D05; + out[ 6] = D06; + out[ 7] = D07; + out[ 8] = D08; + out[ 9] = D09; + out[10] = D10; + out[11] = D11; + out[12] = D12; + out[13] = D13; + out[14] = D14; + out[15] = D15; + out[16] = D16; + out[17] = D17; + out[18] = D18; + out[19] = D19; + out[20] = D20; + out[21] = D21; + out[22] = D22; + out[23] = D23; + out[24] = D24; + out[25] = D25; + out[26] = D26; + out[27] = D27; + out[28] = D28; + out[29] = D29; + out[30] = D30; + out[31] = D31; + out[32] = D32; + out[33] = D33; + out[34] = D34; + out[35] = D35; + out[36] = D36; + out[37] = D37; + out[38] = D38; + out[39] = D39; + out[40] = D40; + out[41] = D41; + out[42] = D42; + out[43] = D43; + out[44] = D44; + out[45] = D45; + out[46] = D46; + out[47] = D47; + out[48] = D48; + out[49] = D49; + out[50] = D50; + out[51] = D51; + out[52] = D52; + out[53] = D53; + out[54] = D54; + out[55] = D55; + out[56] = D56; + out[57] = D57; + out[58] = D58; + out[59] = D59; + out[60] = D60; + out[61] = D61; + out[62] = D62; + out[63] = D63; + + if (digests_cnt < 16) { - const u32 final_hash_pos = digests_offset + d; + for (u32 d = 0; d < digests_cnt; d++) + { + const u32 final_hash_pos = digests_offset + d; - if (hashes_shown[final_hash_pos]) continue; + if (hashes_shown[final_hash_pos]) continue; - u32 search[2]; + u32 search[2]; - search[0] = digests_buf[final_hash_pos].digest_buf[DGST_R0]; - search[1] = digests_buf[final_hash_pos].digest_buf[DGST_R1]; + search[0] = digests_buf[final_hash_pos].digest_buf[DGST_R0]; + search[1] = digests_buf[final_hash_pos].digest_buf[DGST_R1]; - u32 tmpResult = 0; + u32 tmpResult = 0; + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 32; i++) + { + const u32 b0 = -((search[0] >> i) & 1); + const u32 b1 = -((search[1] >> i) & 1); + + tmpResult |= out[ 0 + i] ^ b0; + tmpResult |= out[32 + i] ^ b1; + } + + if (tmpResult == 0xffffffff) continue; + + const u32 slice = ffz (tmpResult); + + const u32 r0 = search[0]; + const u32 r1 = search[1]; + const u32 r2 = 0; + const u32 r3 = 0; + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif + } + } + else + { + u32 out0[32]; + u32 out1[32]; #ifdef _unroll #pragma unroll #endif for (int i = 0; i < 32; i++) { - const u32 b0 = -((search[0] >> i) & 1); - const u32 b1 = -((search[1] >> i) & 1); - - tmpResult |= out[ 0 + i] ^ b0; - tmpResult |= out[32 + i] ^ b1; + out0[i] = out[ 0 + 31 - i]; + out1[i] = out[32 + 31 - i]; } - if (tmpResult == 0xffffffff) continue; + transpose32c (out0); + transpose32c (out1); - const u32 slice = ffz (tmpResult); - - const u32 r0 = search[0]; - const u32 r1 = search[1]; - const u32 r2 = 0; - const u32 r3 = 0; - - #ifdef KERNEL_STATIC - #include COMPARE_M + #ifdef _unroll + #pragma unroll #endif - } - } - else - { - u32 out0[32]; - u32 out1[32]; + for (int slice = 0; slice < 32; slice++) + { + const u32 r0 = out0[31 - slice]; + const u32 r1 = out1[31 - slice]; + const u32 r2 = 0; + #ifdef KERNEL_STATIC + const u32 r3 = 0; + #endif - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 32; i++) - { - out0[i] = out[ 0 + 31 - i]; - out1[i] = out[32 + 31 - i]; - } - - transpose32c (out0); - transpose32c (out1); - - #ifdef _unroll - #pragma unroll - #endif - for (int slice = 0; slice < 32; slice++) - { - const u32 r0 = out0[31 - slice]; - const u32 r1 = out1[31 - slice]; - const u32 r2 = 0; - #ifdef KERNEL_STATIC - const u32 r3 = 0; - #endif - - #include COMPARE_M + #include COMPARE_M + } } } } @@ -2314,70 +2310,70 @@ KERNEL_FQ void m01500_sxx (KERN_ATTR_BITSLICE ()) const u32 s0 = digests_buf[0].digest_buf[0]; const u32 s1 = digests_buf[0].digest_buf[1]; - #define S00 (((s0 >> 0) & 1) ? -1 : 0) - #define S01 (((s0 >> 1) & 1) ? -1 : 0) - #define S02 (((s0 >> 2) & 1) ? -1 : 0) - #define S03 (((s0 >> 3) & 1) ? -1 : 0) - #define S04 (((s0 >> 4) & 1) ? -1 : 0) - #define S05 (((s0 >> 5) & 1) ? -1 : 0) - #define S06 (((s0 >> 6) & 1) ? -1 : 0) - #define S07 (((s0 >> 7) & 1) ? -1 : 0) - #define S08 (((s0 >> 8) & 1) ? -1 : 0) - #define S09 (((s0 >> 9) & 1) ? -1 : 0) - #define S10 (((s0 >> 10) & 1) ? -1 : 0) - #define S11 (((s0 >> 11) & 1) ? -1 : 0) - #define S12 (((s0 >> 12) & 1) ? -1 : 0) - #define S13 (((s0 >> 13) & 1) ? -1 : 0) - #define S14 (((s0 >> 14) & 1) ? -1 : 0) - #define S15 (((s0 >> 15) & 1) ? -1 : 0) - #define S16 (((s0 >> 16) & 1) ? -1 : 0) - #define S17 (((s0 >> 17) & 1) ? -1 : 0) - #define S18 (((s0 >> 18) & 1) ? -1 : 0) - #define S19 (((s0 >> 19) & 1) ? -1 : 0) - #define S20 (((s0 >> 20) & 1) ? -1 : 0) - #define S21 (((s0 >> 21) & 1) ? -1 : 0) - #define S22 (((s0 >> 22) & 1) ? -1 : 0) - #define S23 (((s0 >> 23) & 1) ? -1 : 0) - #define S24 (((s0 >> 24) & 1) ? -1 : 0) - #define S25 (((s0 >> 25) & 1) ? -1 : 0) - #define S26 (((s0 >> 26) & 1) ? -1 : 0) - #define S27 (((s0 >> 27) & 1) ? -1 : 0) - #define S28 (((s0 >> 28) & 1) ? -1 : 0) - #define S29 (((s0 >> 29) & 1) ? -1 : 0) - #define S30 (((s0 >> 30) & 1) ? -1 : 0) - #define S31 (((s0 >> 31) & 1) ? -1 : 0) - #define S32 (((s1 >> 0) & 1) ? -1 : 0) - #define S33 (((s1 >> 1) & 1) ? -1 : 0) - #define S34 (((s1 >> 2) & 1) ? -1 : 0) - #define S35 (((s1 >> 3) & 1) ? -1 : 0) - #define S36 (((s1 >> 4) & 1) ? -1 : 0) - #define S37 (((s1 >> 5) & 1) ? -1 : 0) - #define S38 (((s1 >> 6) & 1) ? -1 : 0) - #define S39 (((s1 >> 7) & 1) ? -1 : 0) - #define S40 (((s1 >> 8) & 1) ? -1 : 0) - #define S41 (((s1 >> 9) & 1) ? -1 : 0) - #define S42 (((s1 >> 10) & 1) ? -1 : 0) - #define S43 (((s1 >> 11) & 1) ? -1 : 0) - #define S44 (((s1 >> 12) & 1) ? -1 : 0) - #define S45 (((s1 >> 13) & 1) ? -1 : 0) - #define S46 (((s1 >> 14) & 1) ? -1 : 0) - #define S47 (((s1 >> 15) & 1) ? -1 : 0) - #define S48 (((s1 >> 16) & 1) ? -1 : 0) - #define S49 (((s1 >> 17) & 1) ? -1 : 0) - #define S50 (((s1 >> 18) & 1) ? -1 : 0) - #define S51 (((s1 >> 19) & 1) ? -1 : 0) - #define S52 (((s1 >> 20) & 1) ? -1 : 0) - #define S53 (((s1 >> 21) & 1) ? -1 : 0) - #define S54 (((s1 >> 22) & 1) ? -1 : 0) - #define S55 (((s1 >> 23) & 1) ? -1 : 0) - #define S56 (((s1 >> 24) & 1) ? -1 : 0) - #define S57 (((s1 >> 25) & 1) ? -1 : 0) - #define S58 (((s1 >> 26) & 1) ? -1 : 0) - #define S59 (((s1 >> 27) & 1) ? -1 : 0) - #define S60 (((s1 >> 28) & 1) ? -1 : 0) - #define S61 (((s1 >> 29) & 1) ? -1 : 0) - #define S62 (((s1 >> 30) & 1) ? -1 : 0) - #define S63 (((s1 >> 31) & 1) ? -1 : 0) + const u32 S00 = (((s0 >> 0) & 1) ? -1 : 0); + const u32 S01 = (((s0 >> 1) & 1) ? -1 : 0); + const u32 S02 = (((s0 >> 2) & 1) ? -1 : 0); + const u32 S03 = (((s0 >> 3) & 1) ? -1 : 0); + const u32 S04 = (((s0 >> 4) & 1) ? -1 : 0); + const u32 S05 = (((s0 >> 5) & 1) ? -1 : 0); + const u32 S06 = (((s0 >> 6) & 1) ? -1 : 0); + const u32 S07 = (((s0 >> 7) & 1) ? -1 : 0); + const u32 S08 = (((s0 >> 8) & 1) ? -1 : 0); + const u32 S09 = (((s0 >> 9) & 1) ? -1 : 0); + const u32 S10 = (((s0 >> 10) & 1) ? -1 : 0); + const u32 S11 = (((s0 >> 11) & 1) ? -1 : 0); + const u32 S12 = (((s0 >> 12) & 1) ? -1 : 0); + const u32 S13 = (((s0 >> 13) & 1) ? -1 : 0); + const u32 S14 = (((s0 >> 14) & 1) ? -1 : 0); + const u32 S15 = (((s0 >> 15) & 1) ? -1 : 0); + const u32 S16 = (((s0 >> 16) & 1) ? -1 : 0); + const u32 S17 = (((s0 >> 17) & 1) ? -1 : 0); + const u32 S18 = (((s0 >> 18) & 1) ? -1 : 0); + const u32 S19 = (((s0 >> 19) & 1) ? -1 : 0); + const u32 S20 = (((s0 >> 20) & 1) ? -1 : 0); + const u32 S21 = (((s0 >> 21) & 1) ? -1 : 0); + const u32 S22 = (((s0 >> 22) & 1) ? -1 : 0); + const u32 S23 = (((s0 >> 23) & 1) ? -1 : 0); + const u32 S24 = (((s0 >> 24) & 1) ? -1 : 0); + const u32 S25 = (((s0 >> 25) & 1) ? -1 : 0); + const u32 S26 = (((s0 >> 26) & 1) ? -1 : 0); + const u32 S27 = (((s0 >> 27) & 1) ? -1 : 0); + const u32 S28 = (((s0 >> 28) & 1) ? -1 : 0); + const u32 S29 = (((s0 >> 29) & 1) ? -1 : 0); + const u32 S30 = (((s0 >> 30) & 1) ? -1 : 0); + const u32 S31 = (((s0 >> 31) & 1) ? -1 : 0); + const u32 S32 = (((s1 >> 0) & 1) ? -1 : 0); + const u32 S33 = (((s1 >> 1) & 1) ? -1 : 0); + const u32 S34 = (((s1 >> 2) & 1) ? -1 : 0); + const u32 S35 = (((s1 >> 3) & 1) ? -1 : 0); + const u32 S36 = (((s1 >> 4) & 1) ? -1 : 0); + const u32 S37 = (((s1 >> 5) & 1) ? -1 : 0); + const u32 S38 = (((s1 >> 6) & 1) ? -1 : 0); + const u32 S39 = (((s1 >> 7) & 1) ? -1 : 0); + const u32 S40 = (((s1 >> 8) & 1) ? -1 : 0); + const u32 S41 = (((s1 >> 9) & 1) ? -1 : 0); + const u32 S42 = (((s1 >> 10) & 1) ? -1 : 0); + const u32 S43 = (((s1 >> 11) & 1) ? -1 : 0); + const u32 S44 = (((s1 >> 12) & 1) ? -1 : 0); + const u32 S45 = (((s1 >> 13) & 1) ? -1 : 0); + const u32 S46 = (((s1 >> 14) & 1) ? -1 : 0); + const u32 S47 = (((s1 >> 15) & 1) ? -1 : 0); + const u32 S48 = (((s1 >> 16) & 1) ? -1 : 0); + const u32 S49 = (((s1 >> 17) & 1) ? -1 : 0); + const u32 S50 = (((s1 >> 18) & 1) ? -1 : 0); + const u32 S51 = (((s1 >> 19) & 1) ? -1 : 0); + const u32 S52 = (((s1 >> 20) & 1) ? -1 : 0); + const u32 S53 = (((s1 >> 21) & 1) ? -1 : 0); + const u32 S54 = (((s1 >> 22) & 1) ? -1 : 0); + const u32 S55 = (((s1 >> 23) & 1) ? -1 : 0); + const u32 S56 = (((s1 >> 24) & 1) ? -1 : 0); + const u32 S57 = (((s1 >> 25) & 1) ? -1 : 0); + const u32 S58 = (((s1 >> 26) & 1) ? -1 : 0); + const u32 S59 = (((s1 >> 27) & 1) ? -1 : 0); + const u32 S60 = (((s1 >> 28) & 1) ? -1 : 0); + const u32 S61 = (((s1 >> 29) & 1) ? -1 : 0); + const u32 S62 = (((s1 >> 30) & 1) ? -1 : 0); + const u32 S63 = (((s1 >> 31) & 1) ? -1 : 0); /** * base @@ -2450,239 +2446,236 @@ KERNEL_FQ void m01500_sxx (KERN_ATTR_BITSLICE ()) * inner loop */ - #ifdef IS_CUDA - const u32 pc_pos = (blockIdx.y * blockDim.y) + threadIdx.y; - #else - const u32 pc_pos = get_global_id (1); - #endif + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += 32) + { + u32 k00 = K00; + u32 k01 = K01; + u32 k02 = K02; + u32 k03 = K03; + u32 k04 = K04; + u32 k05 = K05; + u32 k06 = K06; + u32 k07 = K07; + u32 k08 = K08; + u32 k09 = K09; + u32 k10 = K10; + u32 k11 = K11; + u32 k12 = K12; + u32 k13 = K13; + u32 k14 = K14; + u32 k15 = K15; + u32 k16 = K16; + u32 k17 = K17; + u32 k18 = K18; + u32 k19 = K19; + u32 k20 = K20; + u32 k21 = K21; + u32 k22 = K22; + u32 k23 = K23; + u32 k24 = K24; + u32 k25 = K25; + u32 k26 = K26; + u32 k27 = K27; - const u32 il_pos = pc_pos * 32; + const u32 pc_pos = il_pos / 32; - u32 k00 = K00; - u32 k01 = K01; - u32 k02 = K02; - u32 k03 = K03; - u32 k04 = K04; - u32 k05 = K05; - u32 k06 = K06; - u32 k07 = K07; - u32 k08 = K08; - u32 k09 = K09; - u32 k10 = K10; - u32 k11 = K11; - u32 k12 = K12; - u32 k13 = K13; - u32 k14 = K14; - u32 k15 = K15; - u32 k16 = K16; - u32 k17 = K17; - u32 k18 = K18; - u32 k19 = K19; - u32 k20 = K20; - u32 k21 = K21; - u32 k22 = K22; - u32 k23 = K23; - u32 k24 = K24; - u32 k25 = K25; - u32 k26 = K26; - u32 k27 = K27; + k00 |= words_buf_s[pc_pos].b[ 0]; + k01 |= words_buf_s[pc_pos].b[ 1]; + k02 |= words_buf_s[pc_pos].b[ 2]; + k03 |= words_buf_s[pc_pos].b[ 3]; + k04 |= words_buf_s[pc_pos].b[ 4]; + k05 |= words_buf_s[pc_pos].b[ 5]; + k06 |= words_buf_s[pc_pos].b[ 6]; + k07 |= words_buf_s[pc_pos].b[ 7]; + k08 |= words_buf_s[pc_pos].b[ 8]; + k09 |= words_buf_s[pc_pos].b[ 9]; + k10 |= words_buf_s[pc_pos].b[10]; + k11 |= words_buf_s[pc_pos].b[11]; + k12 |= words_buf_s[pc_pos].b[12]; + k13 |= words_buf_s[pc_pos].b[13]; + k14 |= words_buf_s[pc_pos].b[14]; + k15 |= words_buf_s[pc_pos].b[15]; + k16 |= words_buf_s[pc_pos].b[16]; + k17 |= words_buf_s[pc_pos].b[17]; + k18 |= words_buf_s[pc_pos].b[18]; + k19 |= words_buf_s[pc_pos].b[19]; + k20 |= words_buf_s[pc_pos].b[20]; + k21 |= words_buf_s[pc_pos].b[21]; + k22 |= words_buf_s[pc_pos].b[22]; + k23 |= words_buf_s[pc_pos].b[23]; + k24 |= words_buf_s[pc_pos].b[24]; + k25 |= words_buf_s[pc_pos].b[25]; + k26 |= words_buf_s[pc_pos].b[26]; + k27 |= words_buf_s[pc_pos].b[27]; - k00 |= words_buf_s[pc_pos].b[ 0]; - k01 |= words_buf_s[pc_pos].b[ 1]; - k02 |= words_buf_s[pc_pos].b[ 2]; - k03 |= words_buf_s[pc_pos].b[ 3]; - k04 |= words_buf_s[pc_pos].b[ 4]; - k05 |= words_buf_s[pc_pos].b[ 5]; - k06 |= words_buf_s[pc_pos].b[ 6]; - k07 |= words_buf_s[pc_pos].b[ 7]; - k08 |= words_buf_s[pc_pos].b[ 8]; - k09 |= words_buf_s[pc_pos].b[ 9]; - k10 |= words_buf_s[pc_pos].b[10]; - k11 |= words_buf_s[pc_pos].b[11]; - k12 |= words_buf_s[pc_pos].b[12]; - k13 |= words_buf_s[pc_pos].b[13]; - k14 |= words_buf_s[pc_pos].b[14]; - k15 |= words_buf_s[pc_pos].b[15]; - k16 |= words_buf_s[pc_pos].b[16]; - k17 |= words_buf_s[pc_pos].b[17]; - k18 |= words_buf_s[pc_pos].b[18]; - k19 |= words_buf_s[pc_pos].b[19]; - k20 |= words_buf_s[pc_pos].b[20]; - k21 |= words_buf_s[pc_pos].b[21]; - k22 |= words_buf_s[pc_pos].b[22]; - k23 |= words_buf_s[pc_pos].b[23]; - k24 |= words_buf_s[pc_pos].b[24]; - k25 |= words_buf_s[pc_pos].b[25]; - k26 |= words_buf_s[pc_pos].b[26]; - k27 |= words_buf_s[pc_pos].b[27]; + u32 D00 = 0; + u32 D01 = 0; + u32 D02 = 0; + u32 D03 = 0; + u32 D04 = 0; + u32 D05 = 0; + u32 D06 = 0; + u32 D07 = 0; + u32 D08 = 0; + u32 D09 = 0; + u32 D10 = 0; + u32 D11 = 0; + u32 D12 = 0; + u32 D13 = 0; + u32 D14 = 0; + u32 D15 = 0; + u32 D16 = 0; + u32 D17 = 0; + u32 D18 = 0; + u32 D19 = 0; + u32 D20 = 0; + u32 D21 = 0; + u32 D22 = 0; + u32 D23 = 0; + u32 D24 = 0; + u32 D25 = 0; + u32 D26 = 0; + u32 D27 = 0; + u32 D28 = 0; + u32 D29 = 0; + u32 D30 = 0; + u32 D31 = 0; + u32 D32 = 0; + u32 D33 = 0; + u32 D34 = 0; + u32 D35 = 0; + u32 D36 = 0; + u32 D37 = 0; + u32 D38 = 0; + u32 D39 = 0; + u32 D40 = 0; + u32 D41 = 0; + u32 D42 = 0; + u32 D43 = 0; + u32 D44 = 0; + u32 D45 = 0; + u32 D46 = 0; + u32 D47 = 0; + u32 D48 = 0; + u32 D49 = 0; + u32 D50 = 0; + u32 D51 = 0; + u32 D52 = 0; + u32 D53 = 0; + u32 D54 = 0; + u32 D55 = 0; + u32 D56 = 0; + u32 D57 = 0; + u32 D58 = 0; + u32 D59 = 0; + u32 D60 = 0; + u32 D61 = 0; + u32 D62 = 0; + u32 D63 = 0; - u32 D00 = 0; - u32 D01 = 0; - u32 D02 = 0; - u32 D03 = 0; - u32 D04 = 0; - u32 D05 = 0; - u32 D06 = 0; - u32 D07 = 0; - u32 D08 = 0; - u32 D09 = 0; - u32 D10 = 0; - u32 D11 = 0; - u32 D12 = 0; - u32 D13 = 0; - u32 D14 = 0; - u32 D15 = 0; - u32 D16 = 0; - u32 D17 = 0; - u32 D18 = 0; - u32 D19 = 0; - u32 D20 = 0; - u32 D21 = 0; - u32 D22 = 0; - u32 D23 = 0; - u32 D24 = 0; - u32 D25 = 0; - u32 D26 = 0; - u32 D27 = 0; - u32 D28 = 0; - u32 D29 = 0; - u32 D30 = 0; - u32 D31 = 0; - u32 D32 = 0; - u32 D33 = 0; - u32 D34 = 0; - u32 D35 = 0; - u32 D36 = 0; - u32 D37 = 0; - u32 D38 = 0; - u32 D39 = 0; - u32 D40 = 0; - u32 D41 = 0; - u32 D42 = 0; - u32 D43 = 0; - u32 D44 = 0; - u32 D45 = 0; - u32 D46 = 0; - u32 D47 = 0; - u32 D48 = 0; - u32 D49 = 0; - u32 D50 = 0; - u32 D51 = 0; - u32 D52 = 0; - u32 D53 = 0; - u32 D54 = 0; - u32 D55 = 0; - u32 D56 = 0; - u32 D57 = 0; - u32 D58 = 0; - u32 D59 = 0; - u32 D60 = 0; - u32 D61 = 0; - u32 D62 = 0; - u32 D63 = 0; + DESCrypt + ( + salt, + k00, k01, k02, k03, k04, k05, k06, + k07, k08, k09, k10, k11, k12, k13, + k14, k15, k16, k17, k18, k19, k20, + k21, k22, k23, k24, k25, k26, k27, + K28, K29, K30, K31, K32, K33, K34, + K35, K36, K37, K38, K39, K40, K41, + K42, K43, K44, K45, K46, K47, K48, + K49, K50, K51, K52, K53, K54, K55, + &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, + &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, + &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, + &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, + &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, + &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, + &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, + &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 + ); - DESCrypt - ( - salt, - k00, k01, k02, k03, k04, k05, k06, - k07, k08, k09, k10, k11, k12, k13, - k14, k15, k16, k17, k18, k19, k20, - k21, k22, k23, k24, k25, k26, k27, - K28, K29, K30, K31, K32, K33, K34, - K35, K36, K37, K38, K39, K40, K41, - K42, K43, K44, K45, K46, K47, K48, - K49, K50, K51, K52, K53, K54, K55, - &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, - &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, - &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, - &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, - &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, - &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, - &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, - &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 - ); + u32 tmpResult = 0; - u32 tmpResult = 0; + tmpResult |= D00 ^ S00; + tmpResult |= D01 ^ S01; + tmpResult |= D02 ^ S02; + tmpResult |= D03 ^ S03; + tmpResult |= D04 ^ S04; + tmpResult |= D05 ^ S05; + tmpResult |= D06 ^ S06; + tmpResult |= D07 ^ S07; + tmpResult |= D08 ^ S08; + tmpResult |= D09 ^ S09; + tmpResult |= D10 ^ S10; + tmpResult |= D11 ^ S11; + tmpResult |= D12 ^ S12; + tmpResult |= D13 ^ S13; + tmpResult |= D14 ^ S14; + tmpResult |= D15 ^ S15; - tmpResult |= D00 ^ S00; - tmpResult |= D01 ^ S01; - tmpResult |= D02 ^ S02; - tmpResult |= D03 ^ S03; - tmpResult |= D04 ^ S04; - tmpResult |= D05 ^ S05; - tmpResult |= D06 ^ S06; - tmpResult |= D07 ^ S07; - tmpResult |= D08 ^ S08; - tmpResult |= D09 ^ S09; - tmpResult |= D10 ^ S10; - tmpResult |= D11 ^ S11; - tmpResult |= D12 ^ S12; - tmpResult |= D13 ^ S13; - tmpResult |= D14 ^ S14; - tmpResult |= D15 ^ S15; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D16 ^ S16; + tmpResult |= D17 ^ S17; + tmpResult |= D18 ^ S18; + tmpResult |= D19 ^ S19; + tmpResult |= D20 ^ S20; + tmpResult |= D21 ^ S21; + tmpResult |= D22 ^ S22; + tmpResult |= D23 ^ S23; + tmpResult |= D24 ^ S24; + tmpResult |= D25 ^ S25; + tmpResult |= D26 ^ S26; + tmpResult |= D27 ^ S27; + tmpResult |= D28 ^ S28; + tmpResult |= D29 ^ S29; + tmpResult |= D30 ^ S30; + tmpResult |= D31 ^ S31; - tmpResult |= D16 ^ S16; - tmpResult |= D17 ^ S17; - tmpResult |= D18 ^ S18; - tmpResult |= D19 ^ S19; - tmpResult |= D20 ^ S20; - tmpResult |= D21 ^ S21; - tmpResult |= D22 ^ S22; - tmpResult |= D23 ^ S23; - tmpResult |= D24 ^ S24; - tmpResult |= D25 ^ S25; - tmpResult |= D26 ^ S26; - tmpResult |= D27 ^ S27; - tmpResult |= D28 ^ S28; - tmpResult |= D29 ^ S29; - tmpResult |= D30 ^ S30; - tmpResult |= D31 ^ S31; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D32 ^ S32; + tmpResult |= D33 ^ S33; + tmpResult |= D34 ^ S34; + tmpResult |= D35 ^ S35; + tmpResult |= D36 ^ S36; + tmpResult |= D37 ^ S37; + tmpResult |= D38 ^ S38; + tmpResult |= D39 ^ S39; + tmpResult |= D40 ^ S40; + tmpResult |= D41 ^ S41; + tmpResult |= D42 ^ S42; + tmpResult |= D43 ^ S43; + tmpResult |= D44 ^ S44; + tmpResult |= D45 ^ S45; + tmpResult |= D46 ^ S46; + tmpResult |= D47 ^ S47; - tmpResult |= D32 ^ S32; - tmpResult |= D33 ^ S33; - tmpResult |= D34 ^ S34; - tmpResult |= D35 ^ S35; - tmpResult |= D36 ^ S36; - tmpResult |= D37 ^ S37; - tmpResult |= D38 ^ S38; - tmpResult |= D39 ^ S39; - tmpResult |= D40 ^ S40; - tmpResult |= D41 ^ S41; - tmpResult |= D42 ^ S42; - tmpResult |= D43 ^ S43; - tmpResult |= D44 ^ S44; - tmpResult |= D45 ^ S45; - tmpResult |= D46 ^ S46; - tmpResult |= D47 ^ S47; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D48 ^ S48; + tmpResult |= D49 ^ S49; + tmpResult |= D50 ^ S50; + tmpResult |= D51 ^ S51; + tmpResult |= D52 ^ S52; + tmpResult |= D53 ^ S53; + tmpResult |= D54 ^ S54; + tmpResult |= D55 ^ S55; + tmpResult |= D56 ^ S56; + tmpResult |= D57 ^ S57; + tmpResult |= D58 ^ S58; + tmpResult |= D59 ^ S59; + tmpResult |= D60 ^ S60; + tmpResult |= D61 ^ S61; + tmpResult |= D62 ^ S62; + tmpResult |= D63 ^ S63; - tmpResult |= D48 ^ S48; - tmpResult |= D49 ^ S49; - tmpResult |= D50 ^ S50; - tmpResult |= D51 ^ S51; - tmpResult |= D52 ^ S52; - tmpResult |= D53 ^ S53; - tmpResult |= D54 ^ S54; - tmpResult |= D55 ^ S55; - tmpResult |= D56 ^ S56; - tmpResult |= D57 ^ S57; - tmpResult |= D58 ^ S58; - tmpResult |= D59 ^ S59; - tmpResult |= D60 ^ S60; - tmpResult |= D61 ^ S61; - tmpResult |= D62 ^ S62; - tmpResult |= D63 ^ S63; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + const u32 slice = ffz (tmpResult); - const u32 slice = ffz (tmpResult); - - #ifdef KERNEL_STATIC - #include COMPARE_S - #endif + #ifdef KERNEL_STATIC + #include COMPARE_S + #endif + } } diff --git a/OpenCL/m03000_a3-pure.cl b/OpenCL/m03000_a3-pure.cl index 682edabf4..27b5c5630 100644 --- a/OpenCL/m03000_a3-pure.cl +++ b/OpenCL/m03000_a3-pure.cl @@ -16,7 +16,6 @@ #define COMPARE_M "inc_comp_multi_bs.cl" #ifdef IS_NV -#undef _unroll #define KXX_DECL #endif @@ -1830,305 +1829,302 @@ KERNEL_FQ void m03000_mxx (KERN_ATTR_BITSLICE ()) * inner loop */ - #ifdef IS_CUDA - const u32 pc_pos = (blockIdx.y * blockDim.y) + threadIdx.y; - #else - const u32 pc_pos = get_global_id (1); - #endif - - const u32 il_pos = pc_pos * 32; - - u32 k00 = K00; - u32 k01 = K01; - u32 k02 = K02; - u32 k03 = K03; - u32 k04 = K04; - u32 k05 = K05; - u32 k06 = K06; - u32 k07 = K07; - u32 k08 = K08; - u32 k09 = K09; - u32 k10 = K10; - u32 k11 = K11; - u32 k12 = K12; - u32 k13 = K13; - u32 k14 = K14; - u32 k15 = K15; - u32 k16 = K16; - u32 k17 = K17; - u32 k18 = K18; - u32 k19 = K19; - u32 k20 = K20; - u32 k21 = K21; - u32 k22 = K22; - u32 k23 = K23; - u32 k24 = K24; - u32 k25 = K25; - u32 k26 = K26; - u32 k27 = K27; - u32 k28 = K28; - u32 k29 = K29; - u32 k30 = K30; - u32 k31 = K31; - - k00 |= words_buf_s[pc_pos].b[ 0]; - k01 |= words_buf_s[pc_pos].b[ 1]; - k02 |= words_buf_s[pc_pos].b[ 2]; - k03 |= words_buf_s[pc_pos].b[ 3]; - k04 |= words_buf_s[pc_pos].b[ 4]; - k05 |= words_buf_s[pc_pos].b[ 5]; - k06 |= words_buf_s[pc_pos].b[ 6]; - k07 |= words_buf_s[pc_pos].b[ 7]; - k08 |= words_buf_s[pc_pos].b[ 8]; - k09 |= words_buf_s[pc_pos].b[ 9]; - k10 |= words_buf_s[pc_pos].b[10]; - k11 |= words_buf_s[pc_pos].b[11]; - k12 |= words_buf_s[pc_pos].b[12]; - k13 |= words_buf_s[pc_pos].b[13]; - k14 |= words_buf_s[pc_pos].b[14]; - k15 |= words_buf_s[pc_pos].b[15]; - k16 |= words_buf_s[pc_pos].b[16]; - k17 |= words_buf_s[pc_pos].b[17]; - k18 |= words_buf_s[pc_pos].b[18]; - k19 |= words_buf_s[pc_pos].b[19]; - k20 |= words_buf_s[pc_pos].b[20]; - k21 |= words_buf_s[pc_pos].b[21]; - k22 |= words_buf_s[pc_pos].b[22]; - k23 |= words_buf_s[pc_pos].b[23]; - k24 |= words_buf_s[pc_pos].b[24]; - k25 |= words_buf_s[pc_pos].b[25]; - k26 |= words_buf_s[pc_pos].b[26]; - k27 |= words_buf_s[pc_pos].b[27]; - k28 |= words_buf_s[pc_pos].b[28]; - k29 |= words_buf_s[pc_pos].b[29]; - k30 |= words_buf_s[pc_pos].b[30]; - k31 |= words_buf_s[pc_pos].b[31]; - - // KGS!@#$% including IP - - u32 D00 = 0; - u32 D01 = 0; - u32 D02 = 0; - u32 D03 = 0xffffffff; - u32 D04 = 0; - u32 D05 = 0xffffffff; - u32 D06 = 0xffffffff; - u32 D07 = 0xffffffff; - u32 D08 = 0; - u32 D09 = 0; - u32 D10 = 0; - u32 D11 = 0; - u32 D12 = 0; - u32 D13 = 0xffffffff; - u32 D14 = 0; - u32 D15 = 0; - u32 D16 = 0xffffffff; - u32 D17 = 0xffffffff; - u32 D18 = 0; - u32 D19 = 0; - u32 D20 = 0; - u32 D21 = 0; - u32 D22 = 0xffffffff; - u32 D23 = 0; - u32 D24 = 0xffffffff; - u32 D25 = 0; - u32 D26 = 0xffffffff; - u32 D27 = 0; - u32 D28 = 0xffffffff; - u32 D29 = 0xffffffff; - u32 D30 = 0xffffffff; - u32 D31 = 0xffffffff; - u32 D32 = 0; - u32 D33 = 0; - u32 D34 = 0; - u32 D35 = 0; - u32 D36 = 0; - u32 D37 = 0; - u32 D38 = 0; - u32 D39 = 0; - u32 D40 = 0xffffffff; - u32 D41 = 0xffffffff; - u32 D42 = 0xffffffff; - u32 D43 = 0; - u32 D44 = 0xffffffff; - u32 D45 = 0; - u32 D46 = 0; - u32 D47 = 0; - u32 D48 = 0; - u32 D49 = 0; - u32 D50 = 0; - u32 D51 = 0; - u32 D52 = 0; - u32 D53 = 0; - u32 D54 = 0; - u32 D55 = 0xffffffff; - u32 D56 = 0; - u32 D57 = 0; - u32 D58 = 0xffffffff; - u32 D59 = 0; - u32 D60 = 0; - u32 D61 = 0xffffffff; - u32 D62 = 0xffffffff; - u32 D63 = 0xffffffff; - - DES - ( - k00, k01, k02, k03, k04, k05, k06, - k07, k08, k09, k10, k11, k12, k13, - k14, k15, k16, k17, k18, k19, k20, - k21, k22, k23, k24, k25, k26, k27, - k28, k29, k30, k31, K32, K33, K34, - K35, K36, K37, K38, K39, K40, K41, - K42, K43, K44, K45, K46, K47, K48, - K49, K50, K51, K52, K53, K54, K55, - &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, - &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, - &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, - &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, - &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, - &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, - &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, - &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 - ); - - u32 out[64]; - - out[ 0] = D00; - out[ 1] = D01; - out[ 2] = D02; - out[ 3] = D03; - out[ 4] = D04; - out[ 5] = D05; - out[ 6] = D06; - out[ 7] = D07; - out[ 8] = D08; - out[ 9] = D09; - out[10] = D10; - out[11] = D11; - out[12] = D12; - out[13] = D13; - out[14] = D14; - out[15] = D15; - out[16] = D16; - out[17] = D17; - out[18] = D18; - out[19] = D19; - out[20] = D20; - out[21] = D21; - out[22] = D22; - out[23] = D23; - out[24] = D24; - out[25] = D25; - out[26] = D26; - out[27] = D27; - out[28] = D28; - out[29] = D29; - out[30] = D30; - out[31] = D31; - out[32] = D32; - out[33] = D33; - out[34] = D34; - out[35] = D35; - out[36] = D36; - out[37] = D37; - out[38] = D38; - out[39] = D39; - out[40] = D40; - out[41] = D41; - out[42] = D42; - out[43] = D43; - out[44] = D44; - out[45] = D45; - out[46] = D46; - out[47] = D47; - out[48] = D48; - out[49] = D49; - out[50] = D50; - out[51] = D51; - out[52] = D52; - out[53] = D53; - out[54] = D54; - out[55] = D55; - out[56] = D56; - out[57] = D57; - out[58] = D58; - out[59] = D59; - out[60] = D60; - out[61] = D61; - out[62] = D62; - out[63] = D63; - - if (digests_cnt < 16) + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += 32) { - for (u32 d = 0; d < digests_cnt; d++) + u32 k00 = K00; + u32 k01 = K01; + u32 k02 = K02; + u32 k03 = K03; + u32 k04 = K04; + u32 k05 = K05; + u32 k06 = K06; + u32 k07 = K07; + u32 k08 = K08; + u32 k09 = K09; + u32 k10 = K10; + u32 k11 = K11; + u32 k12 = K12; + u32 k13 = K13; + u32 k14 = K14; + u32 k15 = K15; + u32 k16 = K16; + u32 k17 = K17; + u32 k18 = K18; + u32 k19 = K19; + u32 k20 = K20; + u32 k21 = K21; + u32 k22 = K22; + u32 k23 = K23; + u32 k24 = K24; + u32 k25 = K25; + u32 k26 = K26; + u32 k27 = K27; + u32 k28 = K28; + u32 k29 = K29; + u32 k30 = K30; + u32 k31 = K31; + + const u32 pc_pos = il_pos / 32; + + k00 |= words_buf_s[pc_pos].b[ 0]; + k01 |= words_buf_s[pc_pos].b[ 1]; + k02 |= words_buf_s[pc_pos].b[ 2]; + k03 |= words_buf_s[pc_pos].b[ 3]; + k04 |= words_buf_s[pc_pos].b[ 4]; + k05 |= words_buf_s[pc_pos].b[ 5]; + k06 |= words_buf_s[pc_pos].b[ 6]; + k07 |= words_buf_s[pc_pos].b[ 7]; + k08 |= words_buf_s[pc_pos].b[ 8]; + k09 |= words_buf_s[pc_pos].b[ 9]; + k10 |= words_buf_s[pc_pos].b[10]; + k11 |= words_buf_s[pc_pos].b[11]; + k12 |= words_buf_s[pc_pos].b[12]; + k13 |= words_buf_s[pc_pos].b[13]; + k14 |= words_buf_s[pc_pos].b[14]; + k15 |= words_buf_s[pc_pos].b[15]; + k16 |= words_buf_s[pc_pos].b[16]; + k17 |= words_buf_s[pc_pos].b[17]; + k18 |= words_buf_s[pc_pos].b[18]; + k19 |= words_buf_s[pc_pos].b[19]; + k20 |= words_buf_s[pc_pos].b[20]; + k21 |= words_buf_s[pc_pos].b[21]; + k22 |= words_buf_s[pc_pos].b[22]; + k23 |= words_buf_s[pc_pos].b[23]; + k24 |= words_buf_s[pc_pos].b[24]; + k25 |= words_buf_s[pc_pos].b[25]; + k26 |= words_buf_s[pc_pos].b[26]; + k27 |= words_buf_s[pc_pos].b[27]; + k28 |= words_buf_s[pc_pos].b[28]; + k29 |= words_buf_s[pc_pos].b[29]; + k30 |= words_buf_s[pc_pos].b[30]; + k31 |= words_buf_s[pc_pos].b[31]; + + // KGS!@#$% including IP + + u32 D00 = 0; + u32 D01 = 0; + u32 D02 = 0; + u32 D03 = 0xffffffff; + u32 D04 = 0; + u32 D05 = 0xffffffff; + u32 D06 = 0xffffffff; + u32 D07 = 0xffffffff; + u32 D08 = 0; + u32 D09 = 0; + u32 D10 = 0; + u32 D11 = 0; + u32 D12 = 0; + u32 D13 = 0xffffffff; + u32 D14 = 0; + u32 D15 = 0; + u32 D16 = 0xffffffff; + u32 D17 = 0xffffffff; + u32 D18 = 0; + u32 D19 = 0; + u32 D20 = 0; + u32 D21 = 0; + u32 D22 = 0xffffffff; + u32 D23 = 0; + u32 D24 = 0xffffffff; + u32 D25 = 0; + u32 D26 = 0xffffffff; + u32 D27 = 0; + u32 D28 = 0xffffffff; + u32 D29 = 0xffffffff; + u32 D30 = 0xffffffff; + u32 D31 = 0xffffffff; + u32 D32 = 0; + u32 D33 = 0; + u32 D34 = 0; + u32 D35 = 0; + u32 D36 = 0; + u32 D37 = 0; + u32 D38 = 0; + u32 D39 = 0; + u32 D40 = 0xffffffff; + u32 D41 = 0xffffffff; + u32 D42 = 0xffffffff; + u32 D43 = 0; + u32 D44 = 0xffffffff; + u32 D45 = 0; + u32 D46 = 0; + u32 D47 = 0; + u32 D48 = 0; + u32 D49 = 0; + u32 D50 = 0; + u32 D51 = 0; + u32 D52 = 0; + u32 D53 = 0; + u32 D54 = 0; + u32 D55 = 0xffffffff; + u32 D56 = 0; + u32 D57 = 0; + u32 D58 = 0xffffffff; + u32 D59 = 0; + u32 D60 = 0; + u32 D61 = 0xffffffff; + u32 D62 = 0xffffffff; + u32 D63 = 0xffffffff; + + DES + ( + k00, k01, k02, k03, k04, k05, k06, + k07, k08, k09, k10, k11, k12, k13, + k14, k15, k16, k17, k18, k19, k20, + k21, k22, k23, k24, k25, k26, k27, + k28, k29, k30, k31, K32, K33, K34, + K35, K36, K37, K38, K39, K40, K41, + K42, K43, K44, K45, K46, K47, K48, + K49, K50, K51, K52, K53, K54, K55, + &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, + &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, + &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, + &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, + &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, + &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, + &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, + &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 + ); + + u32 out[64]; + + out[ 0] = D00; + out[ 1] = D01; + out[ 2] = D02; + out[ 3] = D03; + out[ 4] = D04; + out[ 5] = D05; + out[ 6] = D06; + out[ 7] = D07; + out[ 8] = D08; + out[ 9] = D09; + out[10] = D10; + out[11] = D11; + out[12] = D12; + out[13] = D13; + out[14] = D14; + out[15] = D15; + out[16] = D16; + out[17] = D17; + out[18] = D18; + out[19] = D19; + out[20] = D20; + out[21] = D21; + out[22] = D22; + out[23] = D23; + out[24] = D24; + out[25] = D25; + out[26] = D26; + out[27] = D27; + out[28] = D28; + out[29] = D29; + out[30] = D30; + out[31] = D31; + out[32] = D32; + out[33] = D33; + out[34] = D34; + out[35] = D35; + out[36] = D36; + out[37] = D37; + out[38] = D38; + out[39] = D39; + out[40] = D40; + out[41] = D41; + out[42] = D42; + out[43] = D43; + out[44] = D44; + out[45] = D45; + out[46] = D46; + out[47] = D47; + out[48] = D48; + out[49] = D49; + out[50] = D50; + out[51] = D51; + out[52] = D52; + out[53] = D53; + out[54] = D54; + out[55] = D55; + out[56] = D56; + out[57] = D57; + out[58] = D58; + out[59] = D59; + out[60] = D60; + out[61] = D61; + out[62] = D62; + out[63] = D63; + + if (digests_cnt < 16) { - const u32 final_hash_pos = digests_offset + d; + for (u32 d = 0; d < digests_cnt; d++) + { + const u32 final_hash_pos = digests_offset + d; - if (hashes_shown[final_hash_pos]) continue; + if (hashes_shown[final_hash_pos]) continue; - u32 search[2]; + u32 search[2]; - search[0] = digests_buf[final_hash_pos].digest_buf[DGST_R0]; - search[1] = digests_buf[final_hash_pos].digest_buf[DGST_R1]; + search[0] = digests_buf[final_hash_pos].digest_buf[DGST_R0]; + search[1] = digests_buf[final_hash_pos].digest_buf[DGST_R1]; - u32 tmpResult = 0; + u32 tmpResult = 0; + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 32; i++) + { + const u32 b0 = -((search[0] >> i) & 1); + const u32 b1 = -((search[1] >> i) & 1); + + tmpResult |= out[ 0 + i] ^ b0; + tmpResult |= out[32 + i] ^ b1; + } + + if (tmpResult == 0xffffffff) continue; + + const u32 slice = ffz (tmpResult); + + const u32 r0 = search[0]; + const u32 r1 = search[1]; + const u32 r2 = 0; + #ifdef KERNEL_STATIC + const u32 r3 = 0; + #endif + + #include COMPARE_M + } + } + else + { + u32 out0[32]; + u32 out1[32]; #ifdef _unroll #pragma unroll #endif for (int i = 0; i < 32; i++) { - const u32 b0 = -((search[0] >> i) & 1); - const u32 b1 = -((search[1] >> i) & 1); - - tmpResult |= out[ 0 + i] ^ b0; - tmpResult |= out[32 + i] ^ b1; + out0[i] = out[ 0 + 31 - i]; + out1[i] = out[32 + 31 - i]; } - if (tmpResult == 0xffffffff) continue; + transpose32c (out0); + transpose32c (out1); - const u32 slice = ffz (tmpResult); - - const u32 r0 = search[0]; - const u32 r1 = search[1]; - const u32 r2 = 0; - #ifdef KERNEL_STATIC - const u32 r3 = 0; + #ifdef _unroll + #pragma unroll #endif + for (int slice = 0; slice < 32; slice++) + { + const u32 r0 = out0[31 - slice]; + const u32 r1 = out1[31 - slice]; + const u32 r2 = 0; + #ifdef KERNEL_STATIC + const u32 r3 = 0; + #endif - #include COMPARE_M - } - } - else - { - u32 out0[32]; - u32 out1[32]; - - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 32; i++) - { - out0[i] = out[ 0 + 31 - i]; - out1[i] = out[32 + 31 - i]; - } - - transpose32c (out0); - transpose32c (out1); - - #ifdef _unroll - #pragma unroll - #endif - for (int slice = 0; slice < 32; slice++) - { - const u32 r0 = out0[31 - slice]; - const u32 r1 = out1[31 - slice]; - const u32 r2 = 0; - #ifdef KERNEL_STATIC - const u32 r3 = 0; - #endif - - #include COMPARE_M + #include COMPARE_M + } } } } @@ -2149,70 +2145,70 @@ KERNEL_FQ void m03000_sxx (KERN_ATTR_BITSLICE ()) const u32 s0 = digests_buf[0].digest_buf[0]; const u32 s1 = digests_buf[0].digest_buf[1]; - #define S00 (((s0 >> 0) & 1) ? -1 : 0) - #define S01 (((s0 >> 1) & 1) ? -1 : 0) - #define S02 (((s0 >> 2) & 1) ? -1 : 0) - #define S03 (((s0 >> 3) & 1) ? -1 : 0) - #define S04 (((s0 >> 4) & 1) ? -1 : 0) - #define S05 (((s0 >> 5) & 1) ? -1 : 0) - #define S06 (((s0 >> 6) & 1) ? -1 : 0) - #define S07 (((s0 >> 7) & 1) ? -1 : 0) - #define S08 (((s0 >> 8) & 1) ? -1 : 0) - #define S09 (((s0 >> 9) & 1) ? -1 : 0) - #define S10 (((s0 >> 10) & 1) ? -1 : 0) - #define S11 (((s0 >> 11) & 1) ? -1 : 0) - #define S12 (((s0 >> 12) & 1) ? -1 : 0) - #define S13 (((s0 >> 13) & 1) ? -1 : 0) - #define S14 (((s0 >> 14) & 1) ? -1 : 0) - #define S15 (((s0 >> 15) & 1) ? -1 : 0) - #define S16 (((s0 >> 16) & 1) ? -1 : 0) - #define S17 (((s0 >> 17) & 1) ? -1 : 0) - #define S18 (((s0 >> 18) & 1) ? -1 : 0) - #define S19 (((s0 >> 19) & 1) ? -1 : 0) - #define S20 (((s0 >> 20) & 1) ? -1 : 0) - #define S21 (((s0 >> 21) & 1) ? -1 : 0) - #define S22 (((s0 >> 22) & 1) ? -1 : 0) - #define S23 (((s0 >> 23) & 1) ? -1 : 0) - #define S24 (((s0 >> 24) & 1) ? -1 : 0) - #define S25 (((s0 >> 25) & 1) ? -1 : 0) - #define S26 (((s0 >> 26) & 1) ? -1 : 0) - #define S27 (((s0 >> 27) & 1) ? -1 : 0) - #define S28 (((s0 >> 28) & 1) ? -1 : 0) - #define S29 (((s0 >> 29) & 1) ? -1 : 0) - #define S30 (((s0 >> 30) & 1) ? -1 : 0) - #define S31 (((s0 >> 31) & 1) ? -1 : 0) - #define S32 (((s1 >> 0) & 1) ? -1 : 0) - #define S33 (((s1 >> 1) & 1) ? -1 : 0) - #define S34 (((s1 >> 2) & 1) ? -1 : 0) - #define S35 (((s1 >> 3) & 1) ? -1 : 0) - #define S36 (((s1 >> 4) & 1) ? -1 : 0) - #define S37 (((s1 >> 5) & 1) ? -1 : 0) - #define S38 (((s1 >> 6) & 1) ? -1 : 0) - #define S39 (((s1 >> 7) & 1) ? -1 : 0) - #define S40 (((s1 >> 8) & 1) ? -1 : 0) - #define S41 (((s1 >> 9) & 1) ? -1 : 0) - #define S42 (((s1 >> 10) & 1) ? -1 : 0) - #define S43 (((s1 >> 11) & 1) ? -1 : 0) - #define S44 (((s1 >> 12) & 1) ? -1 : 0) - #define S45 (((s1 >> 13) & 1) ? -1 : 0) - #define S46 (((s1 >> 14) & 1) ? -1 : 0) - #define S47 (((s1 >> 15) & 1) ? -1 : 0) - #define S48 (((s1 >> 16) & 1) ? -1 : 0) - #define S49 (((s1 >> 17) & 1) ? -1 : 0) - #define S50 (((s1 >> 18) & 1) ? -1 : 0) - #define S51 (((s1 >> 19) & 1) ? -1 : 0) - #define S52 (((s1 >> 20) & 1) ? -1 : 0) - #define S53 (((s1 >> 21) & 1) ? -1 : 0) - #define S54 (((s1 >> 22) & 1) ? -1 : 0) - #define S55 (((s1 >> 23) & 1) ? -1 : 0) - #define S56 (((s1 >> 24) & 1) ? -1 : 0) - #define S57 (((s1 >> 25) & 1) ? -1 : 0) - #define S58 (((s1 >> 26) & 1) ? -1 : 0) - #define S59 (((s1 >> 27) & 1) ? -1 : 0) - #define S60 (((s1 >> 28) & 1) ? -1 : 0) - #define S61 (((s1 >> 29) & 1) ? -1 : 0) - #define S62 (((s1 >> 30) & 1) ? -1 : 0) - #define S63 (((s1 >> 31) & 1) ? -1 : 0) + const u32 S00 = (((s0 >> 0) & 1) ? -1 : 0); + const u32 S01 = (((s0 >> 1) & 1) ? -1 : 0); + const u32 S02 = (((s0 >> 2) & 1) ? -1 : 0); + const u32 S03 = (((s0 >> 3) & 1) ? -1 : 0); + const u32 S04 = (((s0 >> 4) & 1) ? -1 : 0); + const u32 S05 = (((s0 >> 5) & 1) ? -1 : 0); + const u32 S06 = (((s0 >> 6) & 1) ? -1 : 0); + const u32 S07 = (((s0 >> 7) & 1) ? -1 : 0); + const u32 S08 = (((s0 >> 8) & 1) ? -1 : 0); + const u32 S09 = (((s0 >> 9) & 1) ? -1 : 0); + const u32 S10 = (((s0 >> 10) & 1) ? -1 : 0); + const u32 S11 = (((s0 >> 11) & 1) ? -1 : 0); + const u32 S12 = (((s0 >> 12) & 1) ? -1 : 0); + const u32 S13 = (((s0 >> 13) & 1) ? -1 : 0); + const u32 S14 = (((s0 >> 14) & 1) ? -1 : 0); + const u32 S15 = (((s0 >> 15) & 1) ? -1 : 0); + const u32 S16 = (((s0 >> 16) & 1) ? -1 : 0); + const u32 S17 = (((s0 >> 17) & 1) ? -1 : 0); + const u32 S18 = (((s0 >> 18) & 1) ? -1 : 0); + const u32 S19 = (((s0 >> 19) & 1) ? -1 : 0); + const u32 S20 = (((s0 >> 20) & 1) ? -1 : 0); + const u32 S21 = (((s0 >> 21) & 1) ? -1 : 0); + const u32 S22 = (((s0 >> 22) & 1) ? -1 : 0); + const u32 S23 = (((s0 >> 23) & 1) ? -1 : 0); + const u32 S24 = (((s0 >> 24) & 1) ? -1 : 0); + const u32 S25 = (((s0 >> 25) & 1) ? -1 : 0); + const u32 S26 = (((s0 >> 26) & 1) ? -1 : 0); + const u32 S27 = (((s0 >> 27) & 1) ? -1 : 0); + const u32 S28 = (((s0 >> 28) & 1) ? -1 : 0); + const u32 S29 = (((s0 >> 29) & 1) ? -1 : 0); + const u32 S30 = (((s0 >> 30) & 1) ? -1 : 0); + const u32 S31 = (((s0 >> 31) & 1) ? -1 : 0); + const u32 S32 = (((s1 >> 0) & 1) ? -1 : 0); + const u32 S33 = (((s1 >> 1) & 1) ? -1 : 0); + const u32 S34 = (((s1 >> 2) & 1) ? -1 : 0); + const u32 S35 = (((s1 >> 3) & 1) ? -1 : 0); + const u32 S36 = (((s1 >> 4) & 1) ? -1 : 0); + const u32 S37 = (((s1 >> 5) & 1) ? -1 : 0); + const u32 S38 = (((s1 >> 6) & 1) ? -1 : 0); + const u32 S39 = (((s1 >> 7) & 1) ? -1 : 0); + const u32 S40 = (((s1 >> 8) & 1) ? -1 : 0); + const u32 S41 = (((s1 >> 9) & 1) ? -1 : 0); + const u32 S42 = (((s1 >> 10) & 1) ? -1 : 0); + const u32 S43 = (((s1 >> 11) & 1) ? -1 : 0); + const u32 S44 = (((s1 >> 12) & 1) ? -1 : 0); + const u32 S45 = (((s1 >> 13) & 1) ? -1 : 0); + const u32 S46 = (((s1 >> 14) & 1) ? -1 : 0); + const u32 S47 = (((s1 >> 15) & 1) ? -1 : 0); + const u32 S48 = (((s1 >> 16) & 1) ? -1 : 0); + const u32 S49 = (((s1 >> 17) & 1) ? -1 : 0); + const u32 S50 = (((s1 >> 18) & 1) ? -1 : 0); + const u32 S51 = (((s1 >> 19) & 1) ? -1 : 0); + const u32 S52 = (((s1 >> 20) & 1) ? -1 : 0); + const u32 S53 = (((s1 >> 21) & 1) ? -1 : 0); + const u32 S54 = (((s1 >> 22) & 1) ? -1 : 0); + const u32 S55 = (((s1 >> 23) & 1) ? -1 : 0); + const u32 S56 = (((s1 >> 24) & 1) ? -1 : 0); + const u32 S57 = (((s1 >> 25) & 1) ? -1 : 0); + const u32 S58 = (((s1 >> 26) & 1) ? -1 : 0); + const u32 S59 = (((s1 >> 27) & 1) ? -1 : 0); + const u32 S60 = (((s1 >> 28) & 1) ? -1 : 0); + const u32 S61 = (((s1 >> 29) & 1) ? -1 : 0); + const u32 S62 = (((s1 >> 30) & 1) ? -1 : 0); + const u32 S63 = (((s1 >> 31) & 1) ? -1 : 0); /** * base @@ -2282,248 +2278,245 @@ KERNEL_FQ void m03000_sxx (KERN_ATTR_BITSLICE ()) * inner loop */ - #ifdef IS_CUDA - const u32 pc_pos = (blockIdx.y * blockDim.y) + threadIdx.y; - #else - const u32 pc_pos = get_global_id (1); - #endif + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += 32) + { + u32 k00 = K00; + u32 k01 = K01; + u32 k02 = K02; + u32 k03 = K03; + u32 k04 = K04; + u32 k05 = K05; + u32 k06 = K06; + u32 k07 = K07; + u32 k08 = K08; + u32 k09 = K09; + u32 k10 = K10; + u32 k11 = K11; + u32 k12 = K12; + u32 k13 = K13; + u32 k14 = K14; + u32 k15 = K15; + u32 k16 = K16; + u32 k17 = K17; + u32 k18 = K18; + u32 k19 = K19; + u32 k20 = K20; + u32 k21 = K21; + u32 k22 = K22; + u32 k23 = K23; + u32 k24 = K24; + u32 k25 = K25; + u32 k26 = K26; + u32 k27 = K27; + u32 k28 = K28; + u32 k29 = K29; + u32 k30 = K30; + u32 k31 = K31; - const u32 il_pos = pc_pos * 32; + const u32 pc_pos = il_pos / 32; - u32 k00 = K00; - u32 k01 = K01; - u32 k02 = K02; - u32 k03 = K03; - u32 k04 = K04; - u32 k05 = K05; - u32 k06 = K06; - u32 k07 = K07; - u32 k08 = K08; - u32 k09 = K09; - u32 k10 = K10; - u32 k11 = K11; - u32 k12 = K12; - u32 k13 = K13; - u32 k14 = K14; - u32 k15 = K15; - u32 k16 = K16; - u32 k17 = K17; - u32 k18 = K18; - u32 k19 = K19; - u32 k20 = K20; - u32 k21 = K21; - u32 k22 = K22; - u32 k23 = K23; - u32 k24 = K24; - u32 k25 = K25; - u32 k26 = K26; - u32 k27 = K27; - u32 k28 = K28; - u32 k29 = K29; - u32 k30 = K30; - u32 k31 = K31; + k00 |= words_buf_s[pc_pos].b[ 0]; + k01 |= words_buf_s[pc_pos].b[ 1]; + k02 |= words_buf_s[pc_pos].b[ 2]; + k03 |= words_buf_s[pc_pos].b[ 3]; + k04 |= words_buf_s[pc_pos].b[ 4]; + k05 |= words_buf_s[pc_pos].b[ 5]; + k06 |= words_buf_s[pc_pos].b[ 6]; + k07 |= words_buf_s[pc_pos].b[ 7]; + k08 |= words_buf_s[pc_pos].b[ 8]; + k09 |= words_buf_s[pc_pos].b[ 9]; + k10 |= words_buf_s[pc_pos].b[10]; + k11 |= words_buf_s[pc_pos].b[11]; + k12 |= words_buf_s[pc_pos].b[12]; + k13 |= words_buf_s[pc_pos].b[13]; + k14 |= words_buf_s[pc_pos].b[14]; + k15 |= words_buf_s[pc_pos].b[15]; + k16 |= words_buf_s[pc_pos].b[16]; + k17 |= words_buf_s[pc_pos].b[17]; + k18 |= words_buf_s[pc_pos].b[18]; + k19 |= words_buf_s[pc_pos].b[19]; + k20 |= words_buf_s[pc_pos].b[20]; + k21 |= words_buf_s[pc_pos].b[21]; + k22 |= words_buf_s[pc_pos].b[22]; + k23 |= words_buf_s[pc_pos].b[23]; + k24 |= words_buf_s[pc_pos].b[24]; + k25 |= words_buf_s[pc_pos].b[25]; + k26 |= words_buf_s[pc_pos].b[26]; + k27 |= words_buf_s[pc_pos].b[27]; + k28 |= words_buf_s[pc_pos].b[28]; + k29 |= words_buf_s[pc_pos].b[29]; + k30 |= words_buf_s[pc_pos].b[30]; + k31 |= words_buf_s[pc_pos].b[31]; - k00 |= words_buf_s[pc_pos].b[ 0]; - k01 |= words_buf_s[pc_pos].b[ 1]; - k02 |= words_buf_s[pc_pos].b[ 2]; - k03 |= words_buf_s[pc_pos].b[ 3]; - k04 |= words_buf_s[pc_pos].b[ 4]; - k05 |= words_buf_s[pc_pos].b[ 5]; - k06 |= words_buf_s[pc_pos].b[ 6]; - k07 |= words_buf_s[pc_pos].b[ 7]; - k08 |= words_buf_s[pc_pos].b[ 8]; - k09 |= words_buf_s[pc_pos].b[ 9]; - k10 |= words_buf_s[pc_pos].b[10]; - k11 |= words_buf_s[pc_pos].b[11]; - k12 |= words_buf_s[pc_pos].b[12]; - k13 |= words_buf_s[pc_pos].b[13]; - k14 |= words_buf_s[pc_pos].b[14]; - k15 |= words_buf_s[pc_pos].b[15]; - k16 |= words_buf_s[pc_pos].b[16]; - k17 |= words_buf_s[pc_pos].b[17]; - k18 |= words_buf_s[pc_pos].b[18]; - k19 |= words_buf_s[pc_pos].b[19]; - k20 |= words_buf_s[pc_pos].b[20]; - k21 |= words_buf_s[pc_pos].b[21]; - k22 |= words_buf_s[pc_pos].b[22]; - k23 |= words_buf_s[pc_pos].b[23]; - k24 |= words_buf_s[pc_pos].b[24]; - k25 |= words_buf_s[pc_pos].b[25]; - k26 |= words_buf_s[pc_pos].b[26]; - k27 |= words_buf_s[pc_pos].b[27]; - k28 |= words_buf_s[pc_pos].b[28]; - k29 |= words_buf_s[pc_pos].b[29]; - k30 |= words_buf_s[pc_pos].b[30]; - k31 |= words_buf_s[pc_pos].b[31]; + // KGS!@#$% including IP - // KGS!@#$% including IP + u32 D00 = 0; + u32 D01 = 0; + u32 D02 = 0; + u32 D03 = 0xffffffff; + u32 D04 = 0; + u32 D05 = 0xffffffff; + u32 D06 = 0xffffffff; + u32 D07 = 0xffffffff; + u32 D08 = 0; + u32 D09 = 0; + u32 D10 = 0; + u32 D11 = 0; + u32 D12 = 0; + u32 D13 = 0xffffffff; + u32 D14 = 0; + u32 D15 = 0; + u32 D16 = 0xffffffff; + u32 D17 = 0xffffffff; + u32 D18 = 0; + u32 D19 = 0; + u32 D20 = 0; + u32 D21 = 0; + u32 D22 = 0xffffffff; + u32 D23 = 0; + u32 D24 = 0xffffffff; + u32 D25 = 0; + u32 D26 = 0xffffffff; + u32 D27 = 0; + u32 D28 = 0xffffffff; + u32 D29 = 0xffffffff; + u32 D30 = 0xffffffff; + u32 D31 = 0xffffffff; + u32 D32 = 0; + u32 D33 = 0; + u32 D34 = 0; + u32 D35 = 0; + u32 D36 = 0; + u32 D37 = 0; + u32 D38 = 0; + u32 D39 = 0; + u32 D40 = 0xffffffff; + u32 D41 = 0xffffffff; + u32 D42 = 0xffffffff; + u32 D43 = 0; + u32 D44 = 0xffffffff; + u32 D45 = 0; + u32 D46 = 0; + u32 D47 = 0; + u32 D48 = 0; + u32 D49 = 0; + u32 D50 = 0; + u32 D51 = 0; + u32 D52 = 0; + u32 D53 = 0; + u32 D54 = 0; + u32 D55 = 0xffffffff; + u32 D56 = 0; + u32 D57 = 0; + u32 D58 = 0xffffffff; + u32 D59 = 0; + u32 D60 = 0; + u32 D61 = 0xffffffff; + u32 D62 = 0xffffffff; + u32 D63 = 0xffffffff; - u32 D00 = 0; - u32 D01 = 0; - u32 D02 = 0; - u32 D03 = 0xffffffff; - u32 D04 = 0; - u32 D05 = 0xffffffff; - u32 D06 = 0xffffffff; - u32 D07 = 0xffffffff; - u32 D08 = 0; - u32 D09 = 0; - u32 D10 = 0; - u32 D11 = 0; - u32 D12 = 0; - u32 D13 = 0xffffffff; - u32 D14 = 0; - u32 D15 = 0; - u32 D16 = 0xffffffff; - u32 D17 = 0xffffffff; - u32 D18 = 0; - u32 D19 = 0; - u32 D20 = 0; - u32 D21 = 0; - u32 D22 = 0xffffffff; - u32 D23 = 0; - u32 D24 = 0xffffffff; - u32 D25 = 0; - u32 D26 = 0xffffffff; - u32 D27 = 0; - u32 D28 = 0xffffffff; - u32 D29 = 0xffffffff; - u32 D30 = 0xffffffff; - u32 D31 = 0xffffffff; - u32 D32 = 0; - u32 D33 = 0; - u32 D34 = 0; - u32 D35 = 0; - u32 D36 = 0; - u32 D37 = 0; - u32 D38 = 0; - u32 D39 = 0; - u32 D40 = 0xffffffff; - u32 D41 = 0xffffffff; - u32 D42 = 0xffffffff; - u32 D43 = 0; - u32 D44 = 0xffffffff; - u32 D45 = 0; - u32 D46 = 0; - u32 D47 = 0; - u32 D48 = 0; - u32 D49 = 0; - u32 D50 = 0; - u32 D51 = 0; - u32 D52 = 0; - u32 D53 = 0; - u32 D54 = 0; - u32 D55 = 0xffffffff; - u32 D56 = 0; - u32 D57 = 0; - u32 D58 = 0xffffffff; - u32 D59 = 0; - u32 D60 = 0; - u32 D61 = 0xffffffff; - u32 D62 = 0xffffffff; - u32 D63 = 0xffffffff; + DES + ( + k00, k01, k02, k03, k04, k05, k06, + k07, k08, k09, k10, k11, k12, k13, + k14, k15, k16, k17, k18, k19, k20, + k21, k22, k23, k24, k25, k26, k27, + k28, k29, k30, k31, K32, K33, K34, + K35, K36, K37, K38, K39, K40, K41, + K42, K43, K44, K45, K46, K47, K48, + K49, K50, K51, K52, K53, K54, K55, + &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, + &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, + &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, + &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, + &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, + &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, + &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, + &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 + ); - DES - ( - k00, k01, k02, k03, k04, k05, k06, - k07, k08, k09, k10, k11, k12, k13, - k14, k15, k16, k17, k18, k19, k20, - k21, k22, k23, k24, k25, k26, k27, - k28, k29, k30, k31, K32, K33, K34, - K35, K36, K37, K38, K39, K40, K41, - K42, K43, K44, K45, K46, K47, K48, - K49, K50, K51, K52, K53, K54, K55, - &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, - &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, - &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, - &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, - &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, - &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, - &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, - &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 - ); + u32 tmpResult = 0; - u32 tmpResult = 0; + tmpResult |= D00 ^ S00; + tmpResult |= D01 ^ S01; + tmpResult |= D02 ^ S02; + tmpResult |= D03 ^ S03; + tmpResult |= D04 ^ S04; + tmpResult |= D05 ^ S05; + tmpResult |= D06 ^ S06; + tmpResult |= D07 ^ S07; + tmpResult |= D08 ^ S08; + tmpResult |= D09 ^ S09; + tmpResult |= D10 ^ S10; + tmpResult |= D11 ^ S11; + tmpResult |= D12 ^ S12; + tmpResult |= D13 ^ S13; + tmpResult |= D14 ^ S14; + tmpResult |= D15 ^ S15; - tmpResult |= D00 ^ S00; - tmpResult |= D01 ^ S01; - tmpResult |= D02 ^ S02; - tmpResult |= D03 ^ S03; - tmpResult |= D04 ^ S04; - tmpResult |= D05 ^ S05; - tmpResult |= D06 ^ S06; - tmpResult |= D07 ^ S07; - tmpResult |= D08 ^ S08; - tmpResult |= D09 ^ S09; - tmpResult |= D10 ^ S10; - tmpResult |= D11 ^ S11; - tmpResult |= D12 ^ S12; - tmpResult |= D13 ^ S13; - tmpResult |= D14 ^ S14; - tmpResult |= D15 ^ S15; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D16 ^ S16; + tmpResult |= D17 ^ S17; + tmpResult |= D18 ^ S18; + tmpResult |= D19 ^ S19; + tmpResult |= D20 ^ S20; + tmpResult |= D21 ^ S21; + tmpResult |= D22 ^ S22; + tmpResult |= D23 ^ S23; + tmpResult |= D24 ^ S24; + tmpResult |= D25 ^ S25; + tmpResult |= D26 ^ S26; + tmpResult |= D27 ^ S27; + tmpResult |= D28 ^ S28; + tmpResult |= D29 ^ S29; + tmpResult |= D30 ^ S30; + tmpResult |= D31 ^ S31; - tmpResult |= D16 ^ S16; - tmpResult |= D17 ^ S17; - tmpResult |= D18 ^ S18; - tmpResult |= D19 ^ S19; - tmpResult |= D20 ^ S20; - tmpResult |= D21 ^ S21; - tmpResult |= D22 ^ S22; - tmpResult |= D23 ^ S23; - tmpResult |= D24 ^ S24; - tmpResult |= D25 ^ S25; - tmpResult |= D26 ^ S26; - tmpResult |= D27 ^ S27; - tmpResult |= D28 ^ S28; - tmpResult |= D29 ^ S29; - tmpResult |= D30 ^ S30; - tmpResult |= D31 ^ S31; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D32 ^ S32; + tmpResult |= D33 ^ S33; + tmpResult |= D34 ^ S34; + tmpResult |= D35 ^ S35; + tmpResult |= D36 ^ S36; + tmpResult |= D37 ^ S37; + tmpResult |= D38 ^ S38; + tmpResult |= D39 ^ S39; + tmpResult |= D40 ^ S40; + tmpResult |= D41 ^ S41; + tmpResult |= D42 ^ S42; + tmpResult |= D43 ^ S43; + tmpResult |= D44 ^ S44; + tmpResult |= D45 ^ S45; + tmpResult |= D46 ^ S46; + tmpResult |= D47 ^ S47; - tmpResult |= D32 ^ S32; - tmpResult |= D33 ^ S33; - tmpResult |= D34 ^ S34; - tmpResult |= D35 ^ S35; - tmpResult |= D36 ^ S36; - tmpResult |= D37 ^ S37; - tmpResult |= D38 ^ S38; - tmpResult |= D39 ^ S39; - tmpResult |= D40 ^ S40; - tmpResult |= D41 ^ S41; - tmpResult |= D42 ^ S42; - tmpResult |= D43 ^ S43; - tmpResult |= D44 ^ S44; - tmpResult |= D45 ^ S45; - tmpResult |= D46 ^ S46; - tmpResult |= D47 ^ S47; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D48 ^ S48; + tmpResult |= D49 ^ S49; + tmpResult |= D50 ^ S50; + tmpResult |= D51 ^ S51; + tmpResult |= D52 ^ S52; + tmpResult |= D53 ^ S53; + tmpResult |= D54 ^ S54; + tmpResult |= D55 ^ S55; + tmpResult |= D56 ^ S56; + tmpResult |= D57 ^ S57; + tmpResult |= D58 ^ S58; + tmpResult |= D59 ^ S59; + tmpResult |= D60 ^ S60; + tmpResult |= D61 ^ S61; + tmpResult |= D62 ^ S62; + tmpResult |= D63 ^ S63; - tmpResult |= D48 ^ S48; - tmpResult |= D49 ^ S49; - tmpResult |= D50 ^ S50; - tmpResult |= D51 ^ S51; - tmpResult |= D52 ^ S52; - tmpResult |= D53 ^ S53; - tmpResult |= D54 ^ S54; - tmpResult |= D55 ^ S55; - tmpResult |= D56 ^ S56; - tmpResult |= D57 ^ S57; - tmpResult |= D58 ^ S58; - tmpResult |= D59 ^ S59; - tmpResult |= D60 ^ S60; - tmpResult |= D61 ^ S61; - tmpResult |= D62 ^ S62; - tmpResult |= D63 ^ S63; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + const u32 slice = ffz (tmpResult); - const u32 slice = ffz (tmpResult); - - #ifdef KERNEL_STATIC - #include COMPARE_S - #endif + #ifdef KERNEL_STATIC + #include COMPARE_S + #endif + } } diff --git a/OpenCL/m03200-pure.cl b/OpenCL/m03200-pure.cl index d4eaac064..282e2d20b 100644 --- a/OpenCL/m03200-pure.cl +++ b/OpenCL/m03200-pure.cl @@ -356,6 +356,10 @@ CONSTANT_VK u32a c_pbox[18] = L ^= P[17]; \ } +#ifdef DYNAMIC_LOCAL +extern __shared__ u32 lm[]; +#endif + DECLSPEC void expand_key (u32 *E, u32 *W, const int len) { u8 *E_ptr = (u8 *) E; @@ -456,6 +460,12 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m03200_init (KERN_ATTR_TMPS P[i] = c_pbox[i]; } + #ifdef DYNAMIC_LOCAL + LOCAL_AS u32 *S0 = lm + (lid * 1024) + 0; + LOCAL_AS u32 *S1 = lm + (lid * 1024) + 256; + LOCAL_AS u32 *S2 = lm + (lid * 1024) + 512; + LOCAL_AS u32 *S3 = lm + (lid * 1024) + 768; + #else LOCAL_VK u32 S0_all[FIXED_LOCAL_SIZE][256]; LOCAL_VK u32 S1_all[FIXED_LOCAL_SIZE][256]; LOCAL_VK u32 S2_all[FIXED_LOCAL_SIZE][256]; @@ -465,6 +475,7 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m03200_init (KERN_ATTR_TMPS LOCAL_AS u32 *S1 = S1_all[lid]; LOCAL_AS u32 *S2 = S2_all[lid]; LOCAL_AS u32 *S3 = S3_all[lid]; + #endif for (u32 i = 0; i < 256; i++) { @@ -614,6 +625,12 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m03200_loop (KERN_ATTR_TMPS P[i] = tmps[gid].P[i]; } + #ifdef DYNAMIC_LOCAL + LOCAL_AS u32 *S0 = lm + (lid * 1024) + 0; + LOCAL_AS u32 *S1 = lm + (lid * 1024) + 256; + LOCAL_AS u32 *S2 = lm + (lid * 1024) + 512; + LOCAL_AS u32 *S3 = lm + (lid * 1024) + 768; + #else LOCAL_VK u32 S0_all[FIXED_LOCAL_SIZE][256]; LOCAL_VK u32 S1_all[FIXED_LOCAL_SIZE][256]; LOCAL_VK u32 S2_all[FIXED_LOCAL_SIZE][256]; @@ -623,6 +640,7 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m03200_loop (KERN_ATTR_TMPS LOCAL_AS u32 *S1 = S1_all[lid]; LOCAL_AS u32 *S2 = S2_all[lid]; LOCAL_AS u32 *S3 = S3_all[lid]; + #endif for (u32 i = 0; i < 256; i++) { @@ -799,6 +817,12 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m03200_comp (KERN_ATTR_TMPS P[i] = tmps[gid].P[i]; } + #ifdef DYNAMIC_LOCAL + LOCAL_AS u32 *S0 = lm + (lid * 1024) + 0; + LOCAL_AS u32 *S1 = lm + (lid * 1024) + 256; + LOCAL_AS u32 *S2 = lm + (lid * 1024) + 512; + LOCAL_AS u32 *S3 = lm + (lid * 1024) + 768; + #else LOCAL_VK u32 S0_all[FIXED_LOCAL_SIZE][256]; LOCAL_VK u32 S1_all[FIXED_LOCAL_SIZE][256]; LOCAL_VK u32 S2_all[FIXED_LOCAL_SIZE][256]; @@ -808,6 +832,7 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m03200_comp (KERN_ATTR_TMPS LOCAL_AS u32 *S1 = S1_all[lid]; LOCAL_AS u32 *S2 = S2_all[lid]; LOCAL_AS u32 *S3 = S3_all[lid]; + #endif for (u32 i = 0; i < 256; i++) { diff --git a/OpenCL/m05500_a0-optimized.cl b/OpenCL/m05500_a0-optimized.cl index 6a5c8451c..03dfe4f7a 100644 --- a/OpenCL/m05500_a0-optimized.cl +++ b/OpenCL/m05500_a0-optimized.cl @@ -356,7 +356,7 @@ CONSTANT_VK u32a c_skb[8][64] = #define BOX(i,n,S) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_SPtrans)[64]) +DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) { u32x r = data[0]; u32x l = data[1]; @@ -398,7 +398,7 @@ DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCA iv[1] = r; } -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_skb)[64]) +DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_skb)[64]) { u32x tt; @@ -516,6 +516,8 @@ KERNEL_FQ void m05500_m04 (KERN_ATTR_RULES ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -542,6 +544,13 @@ KERNEL_FQ void m05500_m04 (KERN_ATTR_RULES ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -729,6 +738,8 @@ KERNEL_FQ void m05500_s04 (KERN_ATTR_RULES ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -755,6 +766,13 @@ KERNEL_FQ void m05500_s04 (KERN_ATTR_RULES ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m05500_a0-pure.cl b/OpenCL/m05500_a0-pure.cl index 7681eea15..ac9c30f35 100644 --- a/OpenCL/m05500_a0-pure.cl +++ b/OpenCL/m05500_a0-pure.cl @@ -356,7 +356,7 @@ CONSTANT_VK u32a c_skb[8][64] = #define BOX(i,n,S) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif -DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, LOCAL_AS u32 (*s_SPtrans)[64]) +DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) { u32 r = data[0]; u32 l = data[1]; @@ -398,7 +398,7 @@ DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, LOCAL_AS iv[1] = r; } -DECLSPEC void _des_crypt_keysetup (u32 c, u32 d, u32 *Kc, u32 *Kd, LOCAL_AS u32 (*s_skb)[64]) +DECLSPEC void _des_crypt_keysetup (u32 c, u32 d, u32 *Kc, u32 *Kd, SHM_TYPE u32 (*s_skb)[64]) { u32 tt; @@ -516,6 +516,8 @@ KERNEL_FQ void m05500_mxx (KERN_ATTR_RULES ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -542,6 +544,13 @@ KERNEL_FQ void m05500_mxx (KERN_ATTR_RULES ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -640,6 +649,8 @@ KERNEL_FQ void m05500_sxx (KERN_ATTR_RULES ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -666,6 +677,13 @@ KERNEL_FQ void m05500_sxx (KERN_ATTR_RULES ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m05500_a1-optimized.cl b/OpenCL/m05500_a1-optimized.cl index d4ae2526a..39a7ed212 100644 --- a/OpenCL/m05500_a1-optimized.cl +++ b/OpenCL/m05500_a1-optimized.cl @@ -354,7 +354,7 @@ CONSTANT_VK u32a c_skb[8][64] = #define BOX(i,n,S) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_SPtrans)[64]) +DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) { u32x r = data[0]; u32x l = data[1]; @@ -396,7 +396,7 @@ DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCA iv[1] = r; } -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_skb)[64]) +DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_skb)[64]) { u32x tt; @@ -514,6 +514,8 @@ KERNEL_FQ void m05500_m04 (KERN_ATTR_BASIC ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -540,6 +542,13 @@ KERNEL_FQ void m05500_m04 (KERN_ATTR_BASIC ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -780,6 +789,8 @@ KERNEL_FQ void m05500_s04 (KERN_ATTR_BASIC ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -806,6 +817,13 @@ KERNEL_FQ void m05500_s04 (KERN_ATTR_BASIC ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m05500_a1-pure.cl b/OpenCL/m05500_a1-pure.cl index 28b5a627c..c53e12357 100644 --- a/OpenCL/m05500_a1-pure.cl +++ b/OpenCL/m05500_a1-pure.cl @@ -354,7 +354,7 @@ CONSTANT_VK u32a c_skb[8][64] = #define BOX(i,n,S) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif -DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, LOCAL_AS u32 (*s_SPtrans)[64]) +DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) { u32 r = data[0]; u32 l = data[1]; @@ -396,7 +396,7 @@ DECLSPEC void _des_crypt_encrypt (u32 *iv, u32 *data, u32 *Kc, u32 *Kd, LOCAL_AS iv[1] = r; } -DECLSPEC void _des_crypt_keysetup (u32 c, u32 d, u32 *Kc, u32 *Kd, LOCAL_AS u32 (*s_skb)[64]) +DECLSPEC void _des_crypt_keysetup (u32 c, u32 d, u32 *Kc, u32 *Kd, SHM_TYPE u32 (*s_skb)[64]) { u32 tt; @@ -514,6 +514,8 @@ KERNEL_FQ void m05500_mxx (KERN_ATTR_BASIC ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -540,6 +542,13 @@ KERNEL_FQ void m05500_mxx (KERN_ATTR_BASIC ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -636,6 +645,8 @@ KERNEL_FQ void m05500_sxx (KERN_ATTR_BASIC ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -662,6 +673,13 @@ KERNEL_FQ void m05500_sxx (KERN_ATTR_BASIC ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m05500_a3-optimized.cl b/OpenCL/m05500_a3-optimized.cl index 90a3c3b14..a52b1cc7c 100644 --- a/OpenCL/m05500_a3-optimized.cl +++ b/OpenCL/m05500_a3-optimized.cl @@ -354,7 +354,7 @@ CONSTANT_VK u32a c_skb[8][64] = #define BOX(i,n,S) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_SPtrans)[64]) +DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) { u32x r = data[0]; u32x l = data[1]; @@ -396,7 +396,7 @@ DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCA iv[1] = r; } -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_skb)[64]) +DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_skb)[64]) { u32x tt; @@ -500,7 +500,7 @@ DECLSPEC void transform_netntlmv1_key (const u32x w0, const u32x w1, u32x *out) | ((k[7] & 0xff) << 24); } -DECLSPEC void m05500m (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) +DECLSPEC void m05500m (SHM_TYPE u32 (*s_SPtrans)[64], SHM_TYPE u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) { /** * modifier @@ -657,7 +657,7 @@ DECLSPEC void m05500m (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], } } -DECLSPEC void m05500s (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) +DECLSPEC void m05500s (SHM_TYPE u32 (*s_SPtrans)[64], SHM_TYPE u32 (*s_skb)[64], u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) { /** * modifier @@ -847,6 +847,8 @@ KERNEL_FQ void m05500_m04 (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -873,6 +875,13 @@ KERNEL_FQ void m05500_m04 (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -921,6 +930,8 @@ KERNEL_FQ void m05500_m08 (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -947,6 +958,13 @@ KERNEL_FQ void m05500_m08 (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -995,6 +1013,8 @@ KERNEL_FQ void m05500_m16 (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -1021,6 +1041,13 @@ KERNEL_FQ void m05500_m16 (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -1069,6 +1096,8 @@ KERNEL_FQ void m05500_s04 (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -1095,6 +1124,13 @@ KERNEL_FQ void m05500_s04 (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -1143,6 +1179,8 @@ KERNEL_FQ void m05500_s08 (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -1169,6 +1207,13 @@ KERNEL_FQ void m05500_s08 (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -1217,6 +1262,8 @@ KERNEL_FQ void m05500_s16 (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -1243,6 +1290,13 @@ KERNEL_FQ void m05500_s16 (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m05500_a3-pure.cl b/OpenCL/m05500_a3-pure.cl index 25e6392fb..e691330cd 100644 --- a/OpenCL/m05500_a3-pure.cl +++ b/OpenCL/m05500_a3-pure.cl @@ -354,7 +354,7 @@ CONSTANT_VK u32a c_skb[8][64] = #define BOX(i,n,S) make_u32x ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7], (S)[(n)][(i).s8], (S)[(n)][(i).s9], (S)[(n)][(i).sa], (S)[(n)][(i).sb], (S)[(n)][(i).sc], (S)[(n)][(i).sd], (S)[(n)][(i).se], (S)[(n)][(i).sf]) #endif -DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_SPtrans)[64]) +DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_SPtrans)[64]) { u32x r = data[0]; u32x l = data[1]; @@ -396,7 +396,7 @@ DECLSPEC void _des_crypt_encrypt (u32x *iv, u32x *data, u32x *Kc, u32x *Kd, LOCA iv[1] = r; } -DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, LOCAL_AS u32 (*s_skb)[64]) +DECLSPEC void _des_crypt_keysetup (u32x c, u32x d, u32x *Kc, u32x *Kd, SHM_TYPE u32 (*s_skb)[64]) { u32x tt; @@ -514,6 +514,8 @@ KERNEL_FQ void m05500_mxx (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -540,6 +542,13 @@ KERNEL_FQ void m05500_mxx (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** @@ -649,6 +658,8 @@ KERNEL_FQ void m05500_sxx (KERN_ATTR_VECTOR ()) * sbox, kbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_SPtrans[8][64]; LOCAL_VK u32 s_skb[8][64]; @@ -675,6 +686,13 @@ KERNEL_FQ void m05500_sxx (KERN_ATTR_VECTOR ()) SYNC_THREADS (); + #else + + CONSTANT_AS u32a (*s_SPtrans)[64] = c_SPtrans; + CONSTANT_AS u32a (*s_skb)[64] = c_skb; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m06100_a0-optimized.cl b/OpenCL/m06100_a0-optimized.cl index 7b1c6eee9..51d05c983 100644 --- a/OpenCL/m06100_a0-optimized.cl +++ b/OpenCL/m06100_a0-optimized.cl @@ -16,9 +16,9 @@ #include "inc_hash_whirlpool.cl" #endif -DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { - whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06100_m04 (KERN_ATTR_RULES ()) @@ -37,36 +37,39 @@ KERNEL_FQ void m06100_m04 (KERN_ATTR_RULES ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -147,7 +150,7 @@ KERNEL_FQ void m06100_m04 (KERN_ATTR_RULES ()) dgst[14] = 0; dgst[15] = 0; - whirlpool_transform_transport_vector (w, dgst, s_Ch, s_Cl); + whirlpool_transform_transport_vector (w, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); COMPARE_M_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } @@ -177,36 +180,39 @@ KERNEL_FQ void m06100_s04 (KERN_ATTR_RULES ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -299,7 +305,7 @@ KERNEL_FQ void m06100_s04 (KERN_ATTR_RULES ()) dgst[14] = 0; dgst[15] = 0; - whirlpool_transform_transport_vector (w, dgst, s_Ch, s_Cl); + whirlpool_transform_transport_vector (w, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); COMPARE_S_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } diff --git a/OpenCL/m06100_a0-pure.cl b/OpenCL/m06100_a0-pure.cl index 408512f66..a6e8cf2e8 100644 --- a/OpenCL/m06100_a0-pure.cl +++ b/OpenCL/m06100_a0-pure.cl @@ -32,36 +32,39 @@ KERNEL_FQ void m06100_mxx (KERN_ATTR_RULES ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -85,7 +88,7 @@ KERNEL_FQ void m06100_mxx (KERN_ATTR_RULES ()) whirlpool_ctx_t ctx; - whirlpool_init (&ctx, s_Ch, s_Cl); + whirlpool_init (&ctx, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_swap (&ctx, tmp.i, tmp.pw_len); @@ -116,36 +119,39 @@ KERNEL_FQ void m06100_sxx (KERN_ATTR_RULES ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -181,7 +187,7 @@ KERNEL_FQ void m06100_sxx (KERN_ATTR_RULES ()) whirlpool_ctx_t ctx; - whirlpool_init (&ctx, s_Ch, s_Cl); + whirlpool_init (&ctx, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_swap (&ctx, tmp.i, tmp.pw_len); diff --git a/OpenCL/m06100_a1-optimized.cl b/OpenCL/m06100_a1-optimized.cl index 54a9f492f..55ec3dcaf 100644 --- a/OpenCL/m06100_a1-optimized.cl +++ b/OpenCL/m06100_a1-optimized.cl @@ -14,9 +14,9 @@ #include "inc_hash_whirlpool.cl" #endif -DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { - whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06100_m04 (KERN_ATTR_BASIC ()) @@ -35,36 +35,39 @@ KERNEL_FQ void m06100_m04 (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -203,7 +206,7 @@ KERNEL_FQ void m06100_m04 (KERN_ATTR_BASIC ()) dgst[14] = 0; dgst[15] = 0; - whirlpool_transform_transport_vector (w, dgst, s_Ch, s_Cl); + whirlpool_transform_transport_vector (w, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); COMPARE_M_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } @@ -233,36 +236,39 @@ KERNEL_FQ void m06100_s04 (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -413,7 +419,7 @@ KERNEL_FQ void m06100_s04 (KERN_ATTR_BASIC ()) dgst[14] = 0; dgst[15] = 0; - whirlpool_transform_transport_vector (w, dgst, s_Ch, s_Cl); + whirlpool_transform_transport_vector (w, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); COMPARE_S_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } diff --git a/OpenCL/m06100_a1-pure.cl b/OpenCL/m06100_a1-pure.cl index 7d7693177..4863fc2e5 100644 --- a/OpenCL/m06100_a1-pure.cl +++ b/OpenCL/m06100_a1-pure.cl @@ -30,36 +30,39 @@ KERNEL_FQ void m06100_mxx (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -71,7 +74,7 @@ KERNEL_FQ void m06100_mxx (KERN_ATTR_BASIC ()) whirlpool_ctx_t ctx0; - whirlpool_init (&ctx0, s_Ch, s_Cl); + whirlpool_init (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); @@ -112,36 +115,39 @@ KERNEL_FQ void m06100_sxx (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -165,7 +171,7 @@ KERNEL_FQ void m06100_sxx (KERN_ATTR_BASIC ()) whirlpool_ctx_t ctx0; - whirlpool_init (&ctx0, s_Ch, s_Cl); + whirlpool_init (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); diff --git a/OpenCL/m06100_a3-optimized.cl b/OpenCL/m06100_a3-optimized.cl index e61112e07..f1d4204f5 100644 --- a/OpenCL/m06100_a3-optimized.cl +++ b/OpenCL/m06100_a3-optimized.cl @@ -14,12 +14,12 @@ #include "inc_hash_whirlpool.cl" #endif -DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void whirlpool_transform_transport_vector (const u32x *w, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { - whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w + 0, w + 4, w + 8, w + 12, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } -DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), SHM_TYPE u32 (*s_Cl)[256], SHM_TYPE u32 (*s_Ch)[256]) +DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { /** * modifier @@ -82,13 +82,13 @@ DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER dgst[14] = 0; dgst[15] = 0; - whirlpool_transform_transport_vector (w, dgst, s_Ch, s_Cl); + whirlpool_transform_transport_vector (w, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); COMPARE_M_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } } -DECLSPEC void m06100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), SHM_TYPE u32 (*s_Cl)[256], SHM_TYPE u32 (*s_Ch)[256]) +DECLSPEC void m06100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC (), SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { /** * modifier @@ -163,7 +163,7 @@ DECLSPEC void m06100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER dgst[14] = 0; dgst[15] = 0; - whirlpool_transform_transport_vector (w, dgst, s_Ch, s_Cl); + whirlpool_transform_transport_vector (w, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); COMPARE_S_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } @@ -185,36 +185,39 @@ KERNEL_FQ void m06100_m04 (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -258,7 +261,7 @@ KERNEL_FQ void m06100_m04 (KERN_ATTR_BASIC ()) * main */ - m06100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_Cl, s_Ch); + m06100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06100_m08 (KERN_ATTR_BASIC ()) @@ -277,36 +280,39 @@ KERNEL_FQ void m06100_m08 (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -350,7 +356,7 @@ KERNEL_FQ void m06100_m08 (KERN_ATTR_BASIC ()) * main */ - m06100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_Cl, s_Ch); + m06100m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06100_m16 (KERN_ATTR_BASIC ()) @@ -373,36 +379,39 @@ KERNEL_FQ void m06100_s04 (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -446,7 +455,7 @@ KERNEL_FQ void m06100_s04 (KERN_ATTR_BASIC ()) * main */ - m06100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_Cl, s_Ch); + m06100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06100_s08 (KERN_ATTR_BASIC ()) @@ -465,36 +474,39 @@ KERNEL_FQ void m06100_s08 (KERN_ATTR_BASIC ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -538,7 +550,7 @@ KERNEL_FQ void m06100_s08 (KERN_ATTR_BASIC ()) * main */ - m06100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_Cl, s_Ch); + m06100s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06100_s16 (KERN_ATTR_BASIC ()) diff --git a/OpenCL/m06100_a3-pure.cl b/OpenCL/m06100_a3-pure.cl index 8e4038c99..14851dc2b 100644 --- a/OpenCL/m06100_a3-pure.cl +++ b/OpenCL/m06100_a3-pure.cl @@ -30,36 +30,39 @@ KERNEL_FQ void m06100_mxx (KERN_ATTR_VECTOR ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -94,7 +97,7 @@ KERNEL_FQ void m06100_mxx (KERN_ATTR_VECTOR ()) whirlpool_ctx_vector_t ctx; - whirlpool_init_vector (&ctx, s_Ch, s_Cl); + whirlpool_init_vector (&ctx, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_vector (&ctx, w, pw_len); @@ -125,36 +128,39 @@ KERNEL_FQ void m06100_sxx (KERN_ATTR_VECTOR ()) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -201,7 +207,7 @@ KERNEL_FQ void m06100_sxx (KERN_ATTR_VECTOR ()) whirlpool_ctx_vector_t ctx; - whirlpool_init_vector (&ctx, s_Ch, s_Cl); + whirlpool_init_vector (&ctx, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); whirlpool_update_vector (&ctx, w, pw_len); diff --git a/OpenCL/m06231-pure.cl b/OpenCL/m06231-pure.cl index a25207ee9..302f6d735 100644 --- a/OpenCL/m06231-pure.cl +++ b/OpenCL/m06231-pure.cl @@ -45,7 +45,7 @@ typedef struct tc_tmp } tc_tmp_t; -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -64,7 +64,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = ipad[14]; digest[15] = ipad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -83,7 +83,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = digest[ 0]; w0[1] = digest[ 1]; @@ -119,7 +119,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = opad[14]; digest[15] = opad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -138,7 +138,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) @@ -168,36 +168,39 @@ KERNEL_FQ void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -269,7 +272,7 @@ KERNEL_FQ void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -380,36 +383,39 @@ KERNEL_FQ void m06231_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -515,7 +521,7 @@ KERNEL_FQ void m06231_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) w3[2] = dgst[14]; w3[3] = dgst[15]; - hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); out[ 0] ^= dgst[ 0]; out[ 1] ^= dgst[ 1]; @@ -628,45 +634,6 @@ KERNEL_FQ void m06231_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #endif - /** - * Whirlpool shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; - - #endif - if (gid >= gid_max) return; u32 ukey1[8]; diff --git a/OpenCL/m06232-pure.cl b/OpenCL/m06232-pure.cl index 8569df4c1..a547273e0 100644 --- a/OpenCL/m06232-pure.cl +++ b/OpenCL/m06232-pure.cl @@ -45,7 +45,7 @@ typedef struct tc_tmp } tc_tmp_t; -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -64,7 +64,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = ipad[14]; digest[15] = ipad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -83,7 +83,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = digest[ 0]; w0[1] = digest[ 1]; @@ -119,7 +119,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = opad[14]; digest[15] = opad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -138,7 +138,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) @@ -168,36 +168,39 @@ KERNEL_FQ void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -269,7 +272,7 @@ KERNEL_FQ void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -380,36 +383,39 @@ KERNEL_FQ void m06232_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -515,7 +521,7 @@ KERNEL_FQ void m06232_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) w3[2] = dgst[14]; w3[3] = dgst[15]; - hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); out[ 0] ^= dgst[ 0]; out[ 1] ^= dgst[ 1]; @@ -628,45 +634,6 @@ KERNEL_FQ void m06232_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #endif - /** - * Whirlpool shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; - - #endif - if (gid >= gid_max) return; u32 ukey1[8]; diff --git a/OpenCL/m06233-pure.cl b/OpenCL/m06233-pure.cl index f996cf6f0..b7737d0b4 100644 --- a/OpenCL/m06233-pure.cl +++ b/OpenCL/m06233-pure.cl @@ -45,7 +45,7 @@ typedef struct tc_tmp } tc_tmp_t; -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -64,7 +64,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = ipad[14]; digest[15] = ipad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -83,7 +83,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = digest[ 0]; w0[1] = digest[ 1]; @@ -119,7 +119,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = opad[14]; digest[15] = opad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -138,7 +138,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) @@ -168,36 +168,39 @@ KERNEL_FQ void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -269,7 +272,7 @@ KERNEL_FQ void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -380,36 +383,39 @@ KERNEL_FQ void m06233_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -515,7 +521,7 @@ KERNEL_FQ void m06233_loop (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) w3[2] = dgst[14]; w3[3] = dgst[15]; - hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); out[ 0] ^= dgst[ 0]; out[ 1] ^= dgst[ 1]; @@ -628,45 +634,6 @@ KERNEL_FQ void m06233_comp (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) #endif - /** - * Whirlpool shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; - - #endif - if (gid >= gid_max) return; u32 ukey1[8]; diff --git a/OpenCL/m06500-pure.cl b/OpenCL/m06500-pure.cl index 73a154a64..7da04c694 100644 --- a/OpenCL/m06500-pure.cl +++ b/OpenCL/m06500-pure.cl @@ -119,74 +119,69 @@ KERNEL_FQ void m06500_init (KERN_ATTR_TMPS (sha512aix_tmp_t)) sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); - for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) - { - sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + w0[0] = 1; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; - w0[0] = j; - w0[1] = 0; - w0[2] = 0; - w0[3] = 0; - w1[0] = 0; - w1[1] = 0; - w1[2] = 0; - w1[3] = 0; - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - w4[0] = 0; - w4[1] = 0; - w4[2] = 0; - w4[3] = 0; - w5[0] = 0; - w5[1] = 0; - w5[2] = 0; - w5[3] = 0; - w6[0] = 0; - w6[1] = 0; - w6[2] = 0; - w6[3] = 0; - w7[0] = 0; - w7[1] = 0; - w7[2] = 0; - w7[3] = 0; + sha512_hmac_update_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7, 4); - sha512_hmac_update_128 (&sha512_hmac_ctx2, w0, w1, w2, w3, w4, w5, w6, w7, 4); + sha512_hmac_final (&sha512_hmac_ctx); - sha512_hmac_final (&sha512_hmac_ctx2); + tmps[gid].dgst[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].dgst[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].dgst[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].dgst[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].dgst[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].dgst[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].dgst[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].dgst[7] = sha512_hmac_ctx.opad.h[7]; - tmps[gid].dgst[i + 0] = sha512_hmac_ctx2.opad.h[0]; - tmps[gid].dgst[i + 1] = sha512_hmac_ctx2.opad.h[1]; - tmps[gid].dgst[i + 2] = sha512_hmac_ctx2.opad.h[2]; - tmps[gid].dgst[i + 3] = sha512_hmac_ctx2.opad.h[3]; - tmps[gid].dgst[i + 4] = sha512_hmac_ctx2.opad.h[4]; - tmps[gid].dgst[i + 5] = sha512_hmac_ctx2.opad.h[5]; - tmps[gid].dgst[i + 6] = sha512_hmac_ctx2.opad.h[6]; - tmps[gid].dgst[i + 7] = sha512_hmac_ctx2.opad.h[7]; - - tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; - tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; - tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; - tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; - tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; - tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; - tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; - tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; - } + tmps[gid].out[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].out[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].out[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].out[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].out[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].out[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].out[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].out[7] = sha512_hmac_ctx.opad.h[7]; } KERNEL_FQ void m06500_loop (KERN_ATTR_TMPS (sha512aix_tmp_t)) @@ -216,103 +211,100 @@ KERNEL_FQ void m06500_loop (KERN_ATTR_TMPS (sha512aix_tmp_t)) opad[6] = pack64v (tmps, opad, gid, 6); opad[7] = pack64v (tmps, opad, gid, 7); - for (u32 i = 0; i < 8; i += 8) + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, 0); + dgst[1] = pack64v (tmps, dgst, gid, 1); + dgst[2] = pack64v (tmps, dgst, gid, 2); + dgst[3] = pack64v (tmps, dgst, gid, 3); + dgst[4] = pack64v (tmps, dgst, gid, 4); + dgst[5] = pack64v (tmps, dgst, gid, 5); + dgst[6] = pack64v (tmps, dgst, gid, 6); + dgst[7] = pack64v (tmps, dgst, gid, 7); + + out[0] = pack64v (tmps, out, gid, 0); + out[1] = pack64v (tmps, out, gid, 1); + out[2] = pack64v (tmps, out, gid, 2); + out[3] = pack64v (tmps, out, gid, 3); + out[4] = pack64v (tmps, out, gid, 4); + out[5] = pack64v (tmps, out, gid, 5); + out[6] = pack64v (tmps, out, gid, 6); + out[7] = pack64v (tmps, out, gid, 7); + + for (u32 j = 0; j < loop_cnt; j++) { - u64x dgst[8]; - u64x out[8]; + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; - dgst[0] = pack64v (tmps, dgst, gid, i + 0); - dgst[1] = pack64v (tmps, dgst, gid, i + 1); - dgst[2] = pack64v (tmps, dgst, gid, i + 2); - dgst[3] = pack64v (tmps, dgst, gid, i + 3); - dgst[4] = pack64v (tmps, dgst, gid, i + 4); - dgst[5] = pack64v (tmps, dgst, gid, i + 5); - dgst[6] = pack64v (tmps, dgst, gid, i + 6); - dgst[7] = pack64v (tmps, dgst, gid, i + 7); + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; - out[0] = pack64v (tmps, out, gid, i + 0); - out[1] = pack64v (tmps, out, gid, i + 1); - out[2] = pack64v (tmps, out, gid, i + 2); - out[3] = pack64v (tmps, out, gid, i + 3); - out[4] = pack64v (tmps, out, gid, i + 4); - out[5] = pack64v (tmps, out, gid, i + 5); - out[6] = pack64v (tmps, out, gid, i + 6); - out[7] = pack64v (tmps, out, gid, i + 7); + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); - for (u32 j = 0; j < loop_cnt; j++) - { - u32x w0[4]; - u32x w1[4]; - u32x w2[4]; - u32x w3[4]; - u32x w4[4]; - u32x w5[4]; - u32x w6[4]; - u32x w7[4]; - - w0[0] = h32_from_64 (dgst[0]); - w0[1] = l32_from_64 (dgst[0]); - w0[2] = h32_from_64 (dgst[1]); - w0[3] = l32_from_64 (dgst[1]); - w1[0] = h32_from_64 (dgst[2]); - w1[1] = l32_from_64 (dgst[2]); - w1[2] = h32_from_64 (dgst[3]); - w1[3] = l32_from_64 (dgst[3]); - w2[0] = h32_from_64 (dgst[4]); - w2[1] = l32_from_64 (dgst[4]); - w2[2] = h32_from_64 (dgst[5]); - w2[3] = l32_from_64 (dgst[5]); - w3[0] = h32_from_64 (dgst[6]); - w3[1] = l32_from_64 (dgst[6]); - w3[2] = h32_from_64 (dgst[7]); - w3[3] = l32_from_64 (dgst[7]); - w4[0] = 0x80000000; - w4[1] = 0; - w4[2] = 0; - w4[3] = 0; - w5[0] = 0; - w5[1] = 0; - w5[2] = 0; - w5[3] = 0; - w6[0] = 0; - w6[1] = 0; - w6[2] = 0; - w6[3] = 0; - w7[0] = 0; - w7[1] = 0; - w7[2] = 0; - w7[3] = (128 + 64) * 8; - - hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); - - out[0] ^= dgst[0]; - out[1] ^= dgst[1]; - out[2] ^= dgst[2]; - out[3] ^= dgst[3]; - out[4] ^= dgst[4]; - out[5] ^= dgst[5]; - out[6] ^= dgst[6]; - out[7] ^= dgst[7]; - } - - unpack64v (tmps, dgst, gid, i + 0, dgst[0]); - unpack64v (tmps, dgst, gid, i + 1, dgst[1]); - unpack64v (tmps, dgst, gid, i + 2, dgst[2]); - unpack64v (tmps, dgst, gid, i + 3, dgst[3]); - unpack64v (tmps, dgst, gid, i + 4, dgst[4]); - unpack64v (tmps, dgst, gid, i + 5, dgst[5]); - unpack64v (tmps, dgst, gid, i + 6, dgst[6]); - unpack64v (tmps, dgst, gid, i + 7, dgst[7]); - - unpack64v (tmps, out, gid, i + 0, out[0]); - unpack64v (tmps, out, gid, i + 1, out[1]); - unpack64v (tmps, out, gid, i + 2, out[2]); - unpack64v (tmps, out, gid, i + 3, out[3]); - unpack64v (tmps, out, gid, i + 4, out[4]); - unpack64v (tmps, out, gid, i + 5, out[5]); - unpack64v (tmps, out, gid, i + 6, out[6]); - unpack64v (tmps, out, gid, i + 7, out[7]); + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; } + + unpack64v (tmps, dgst, gid, 0, dgst[0]); + unpack64v (tmps, dgst, gid, 1, dgst[1]); + unpack64v (tmps, dgst, gid, 2, dgst[2]); + unpack64v (tmps, dgst, gid, 3, dgst[3]); + unpack64v (tmps, dgst, gid, 4, dgst[4]); + unpack64v (tmps, dgst, gid, 5, dgst[5]); + unpack64v (tmps, dgst, gid, 6, dgst[6]); + unpack64v (tmps, dgst, gid, 7, dgst[7]); + + unpack64v (tmps, out, gid, 0, out[0]); + unpack64v (tmps, out, gid, 1, out[1]); + unpack64v (tmps, out, gid, 2, out[2]); + unpack64v (tmps, out, gid, 3, out[3]); + unpack64v (tmps, out, gid, 4, out[4]); + unpack64v (tmps, out, gid, 5, out[5]); + unpack64v (tmps, out, gid, 6, out[6]); + unpack64v (tmps, out, gid, 7, out[7]); } KERNEL_FQ void m06500_comp (KERN_ATTR_TMPS (sha512aix_tmp_t)) diff --git a/OpenCL/m07000_a3-optimized.cl b/OpenCL/m07000_a3-optimized.cl index 5757962da..0ab3f796e 100644 --- a/OpenCL/m07000_a3-optimized.cl +++ b/OpenCL/m07000_a3-optimized.cl @@ -32,9 +32,9 @@ DECLSPEC void m07000m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER u32 salt_buf2[4]; u32 salt_buf3[4]; - salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2]; + salt_buf0[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); salt_buf0[3] = 0; salt_buf1[0] = 0; salt_buf1[1] = 0; @@ -56,12 +56,12 @@ DECLSPEC void m07000m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER u32 magic_buf2[4]; u32 magic_buf3[4]; - magic_buf0[0] = FORTIGATE_A; - magic_buf0[1] = FORTIGATE_B; - magic_buf0[2] = FORTIGATE_C; - magic_buf0[3] = FORTIGATE_D; - magic_buf1[0] = FORTIGATE_E; - magic_buf1[1] = FORTIGATE_F; + magic_buf0[0] = hc_swap32_S (FORTIGATE_A); + magic_buf0[1] = hc_swap32_S (FORTIGATE_B); + magic_buf0[2] = hc_swap32_S (FORTIGATE_C); + magic_buf0[3] = hc_swap32_S (FORTIGATE_D); + magic_buf1[0] = hc_swap32_S (FORTIGATE_E); + magic_buf1[1] = hc_swap32_S (FORTIGATE_F); magic_buf1[2] = 0; magic_buf1[3] = 0; magic_buf2[0] = 0; @@ -77,7 +77,7 @@ DECLSPEC void m07000m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER const u32 salt_pw_len = salt_len + pw_len; - switch_buffer_by_offset_le_S (magic_buf0, magic_buf1, magic_buf2, magic_buf3, salt_pw_len); + switch_buffer_by_offset_be_S (magic_buf0, magic_buf1, magic_buf2, magic_buf3, salt_pw_len); salt_buf0[0] |= magic_buf0[0]; salt_buf0[1] |= magic_buf0[1]; @@ -98,7 +98,7 @@ DECLSPEC void m07000m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER const u32 final_len = salt_len + pw_len + magic_len; - append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, final_len); + append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, final_len ^ 3); /** * loop @@ -158,20 +158,20 @@ DECLSPEC void m07000m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER * sha1 */ - u32x w0_t = hc_swap32 (t0[0]); - u32x w1_t = hc_swap32 (t0[1]); - u32x w2_t = hc_swap32 (t0[2]); - u32x w3_t = hc_swap32 (t0[3]); - u32x w4_t = hc_swap32 (t1[0]); - u32x w5_t = hc_swap32 (t1[1]); - u32x w6_t = hc_swap32 (t1[2]); - u32x w7_t = hc_swap32 (t1[3]); - u32x w8_t = hc_swap32 (t2[0]); - u32x w9_t = hc_swap32 (t2[1]); - u32x wa_t = hc_swap32 (t2[2]); - u32x wb_t = hc_swap32 (t2[3]); - u32x wc_t = hc_swap32 (t3[0]); - u32x wd_t = hc_swap32 (t3[1]); + u32x w0_t = t0[0]; + u32x w1_t = t0[1]; + u32x w2_t = t0[2]; + u32x w3_t = t0[3]; + u32x w4_t = t1[0]; + u32x w5_t = t1[1]; + u32x w6_t = t1[2]; + u32x w7_t = t1[3]; + u32x w8_t = t2[0]; + u32x w9_t = t2[1]; + u32x wa_t = t2[2]; + u32x wb_t = t2[3]; + u32x wc_t = t3[0]; + u32x wd_t = t3[1]; u32x we_t = 0; u32x wf_t = final_len * 8; @@ -299,9 +299,9 @@ DECLSPEC void m07000s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER u32 salt_buf2[4]; u32 salt_buf3[4]; - salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2]; + salt_buf0[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); salt_buf0[3] = 0; salt_buf1[0] = 0; salt_buf1[1] = 0; @@ -323,12 +323,12 @@ DECLSPEC void m07000s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER u32 magic_buf2[4]; u32 magic_buf3[4]; - magic_buf0[0] = FORTIGATE_A; - magic_buf0[1] = FORTIGATE_B; - magic_buf0[2] = FORTIGATE_C; - magic_buf0[3] = FORTIGATE_D; - magic_buf1[0] = FORTIGATE_E; - magic_buf1[1] = FORTIGATE_F; + magic_buf0[0] = hc_swap32_S (FORTIGATE_A); + magic_buf0[1] = hc_swap32_S (FORTIGATE_B); + magic_buf0[2] = hc_swap32_S (FORTIGATE_C); + magic_buf0[3] = hc_swap32_S (FORTIGATE_D); + magic_buf1[0] = hc_swap32_S (FORTIGATE_E); + magic_buf1[1] = hc_swap32_S (FORTIGATE_F); magic_buf1[2] = 0; magic_buf1[3] = 0; magic_buf2[0] = 0; @@ -344,7 +344,7 @@ DECLSPEC void m07000s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER const u32 salt_pw_len = salt_len + pw_len; - switch_buffer_by_offset_le_S (magic_buf0, magic_buf1, magic_buf2, magic_buf3, salt_pw_len); + switch_buffer_by_offset_be_S (magic_buf0, magic_buf1, magic_buf2, magic_buf3, salt_pw_len); salt_buf0[0] |= magic_buf0[0]; salt_buf0[1] |= magic_buf0[1]; @@ -365,7 +365,7 @@ DECLSPEC void m07000s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER const u32 final_len = salt_len + pw_len + magic_len; - append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, final_len); + append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, final_len ^ 3); /** * digest @@ -443,20 +443,20 @@ DECLSPEC void m07000s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER * sha1 */ - u32x w0_t = hc_swap32 (t0[0]); - u32x w1_t = hc_swap32 (t0[1]); - u32x w2_t = hc_swap32 (t0[2]); - u32x w3_t = hc_swap32 (t0[3]); - u32x w4_t = hc_swap32 (t1[0]); - u32x w5_t = hc_swap32 (t1[1]); - u32x w6_t = hc_swap32 (t1[2]); - u32x w7_t = hc_swap32 (t1[3]); - u32x w8_t = hc_swap32 (t2[0]); - u32x w9_t = hc_swap32 (t2[1]); - u32x wa_t = hc_swap32 (t2[2]); - u32x wb_t = hc_swap32 (t2[3]); - u32x wc_t = hc_swap32 (t3[0]); - u32x wd_t = hc_swap32 (t3[1]); + u32x w0_t = t0[0]; + u32x w1_t = t0[1]; + u32x w2_t = t0[2]; + u32x w3_t = t0[3]; + u32x w4_t = t1[0]; + u32x w5_t = t1[1]; + u32x w6_t = t1[2]; + u32x w7_t = t1[3]; + u32x w8_t = t2[0]; + u32x w9_t = t2[1]; + u32x wa_t = t2[2]; + u32x wb_t = t2[3]; + u32x wc_t = t3[0]; + u32x wd_t = t3[1]; u32x we_t = 0; u32x wf_t = final_len * 8; diff --git a/OpenCL/m07000_a3-pure.cl b/OpenCL/m07000_a3-pure.cl index db6f00a5f..aca25c9df 100644 --- a/OpenCL/m07000_a3-pure.cl +++ b/OpenCL/m07000_a3-pure.cl @@ -62,7 +62,7 @@ KERNEL_FQ void m07000_mxx (KERN_ATTR_VECTOR ()) sha1_init_vector_from_scalar (&ctx, &ctx0); - sha1_update_vector_swap (&ctx, w, pw_len); + sha1_update_vector (&ctx, w, pw_len); /** * pepper @@ -163,7 +163,7 @@ KERNEL_FQ void m07000_sxx (KERN_ATTR_VECTOR ()) sha1_init_vector_from_scalar (&ctx, &ctx0); - sha1_update_vector_swap (&ctx, w, pw_len); + sha1_update_vector (&ctx, w, pw_len); /** * pepper diff --git a/OpenCL/m07300_a0-optimized.cl b/OpenCL/m07300_a0-optimized.cl index 35f4a3639..2deb27bac 100644 --- a/OpenCL/m07300_a0-optimized.cl +++ b/OpenCL/m07300_a0-optimized.cl @@ -118,13 +118,22 @@ KERNEL_FQ void m07300_m04 (KERN_ATTR_RULES_ESALT (rakp_t)) * modifier */ + const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); /** - * base + * s_msg */ - const u64 gid = get_global_id (0); + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; @@ -186,40 +195,40 @@ KERNEL_FQ void m07300_m04 (KERN_ATTR_RULES_ESALT (rakp_t)) for (esalt_left = esalt_size, esalt_off = 0; esalt_left >= 56; esalt_left -= 64, esalt_off += 16) { - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; - w3[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 14]; - w3[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 15]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; + w3[2] = s_esalt_buf[esalt_off + 14]; + w3[3] = s_esalt_buf[esalt_off + 15]; sha1_transform_vector (w0, w1, w2, w3, ipad); } - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; w3[2] = 0; w3[3] = (64 + esalt_size) * 8; @@ -245,13 +254,22 @@ KERNEL_FQ void m07300_s04 (KERN_ATTR_RULES_ESALT (rakp_t)) * modifier */ + const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); /** - * base + * s_msg */ - const u64 gid = get_global_id (0); + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; @@ -325,40 +343,40 @@ KERNEL_FQ void m07300_s04 (KERN_ATTR_RULES_ESALT (rakp_t)) for (esalt_left = esalt_size, esalt_off = 0; esalt_left >= 56; esalt_left -= 64, esalt_off += 16) { - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; - w3[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 14]; - w3[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 15]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; + w3[2] = s_esalt_buf[esalt_off + 14]; + w3[3] = s_esalt_buf[esalt_off + 15]; sha1_transform_vector (w0, w1, w2, w3, ipad); } - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; w3[2] = 0; w3[3] = (64 + esalt_size) * 8; diff --git a/OpenCL/m07300_a1-optimized.cl b/OpenCL/m07300_a1-optimized.cl index 83fce7cf9..21e1e0d2f 100644 --- a/OpenCL/m07300_a1-optimized.cl +++ b/OpenCL/m07300_a1-optimized.cl @@ -116,13 +116,22 @@ KERNEL_FQ void m07300_m04 (KERN_ATTR_ESALT (rakp_t)) * modifier */ + const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); /** - * base + * s_msg */ - const u64 gid = get_global_id (0); + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; @@ -252,40 +261,40 @@ KERNEL_FQ void m07300_m04 (KERN_ATTR_ESALT (rakp_t)) for (esalt_left = esalt_size, esalt_off = 0; esalt_left >= 56; esalt_left -= 64, esalt_off += 16) { - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; - w3[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 14]; - w3[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 15]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; + w3[2] = s_esalt_buf[esalt_off + 14]; + w3[3] = s_esalt_buf[esalt_off + 15]; sha1_transform_vector (w0, w1, w2, w3, ipad); } - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; w3[2] = 0; w3[3] = (64 + esalt_size) * 8; @@ -311,13 +320,22 @@ KERNEL_FQ void m07300_s04 (KERN_ATTR_ESALT (rakp_t)) * modifier */ + const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); /** - * base + * s_msg */ - const u64 gid = get_global_id (0); + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; @@ -459,40 +477,40 @@ KERNEL_FQ void m07300_s04 (KERN_ATTR_ESALT (rakp_t)) for (esalt_left = esalt_size, esalt_off = 0; esalt_left >= 56; esalt_left -= 64, esalt_off += 16) { - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; - w3[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 14]; - w3[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 15]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; + w3[2] = s_esalt_buf[esalt_off + 14]; + w3[3] = s_esalt_buf[esalt_off + 15]; sha1_transform_vector (w0, w1, w2, w3, ipad); } - w0[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; + w0[0] = s_esalt_buf[esalt_off + 0]; + w0[1] = s_esalt_buf[esalt_off + 1]; + w0[2] = s_esalt_buf[esalt_off + 2]; + w0[3] = s_esalt_buf[esalt_off + 3]; + w1[0] = s_esalt_buf[esalt_off + 4]; + w1[1] = s_esalt_buf[esalt_off + 5]; + w1[2] = s_esalt_buf[esalt_off + 6]; + w1[3] = s_esalt_buf[esalt_off + 7]; + w2[0] = s_esalt_buf[esalt_off + 8]; + w2[1] = s_esalt_buf[esalt_off + 9]; + w2[2] = s_esalt_buf[esalt_off + 10]; + w2[3] = s_esalt_buf[esalt_off + 11]; + w3[0] = s_esalt_buf[esalt_off + 12]; + w3[1] = s_esalt_buf[esalt_off + 13]; w3[2] = 0; w3[3] = (64 + esalt_size) * 8; diff --git a/OpenCL/m07300_a3-optimized.cl b/OpenCL/m07300_a3-optimized.cl index b3b74c963..a8a2904a7 100644 --- a/OpenCL/m07300_a3-optimized.cl +++ b/OpenCL/m07300_a3-optimized.cl @@ -110,7 +110,7 @@ DECLSPEC void hmac_sha1_run (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, sha1_transform_vector (w0, w1, w2, w3, digest); } -DECLSPEC void m07300m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (rakp_t)) +DECLSPEC void m07300m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (rakp_t), LOCAL_AS u32 *s_esalt_buf) { /** * modifier @@ -175,40 +175,40 @@ DECLSPEC void m07300m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER for (esalt_left = esalt_size, esalt_off = 0; esalt_left >= 56; esalt_left -= 64, esalt_off += 16) { - w0_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; - w3_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 14]; - w3_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 15]; + w0_t[0] = s_esalt_buf[esalt_off + 0]; + w0_t[1] = s_esalt_buf[esalt_off + 1]; + w0_t[2] = s_esalt_buf[esalt_off + 2]; + w0_t[3] = s_esalt_buf[esalt_off + 3]; + w1_t[0] = s_esalt_buf[esalt_off + 4]; + w1_t[1] = s_esalt_buf[esalt_off + 5]; + w1_t[2] = s_esalt_buf[esalt_off + 6]; + w1_t[3] = s_esalt_buf[esalt_off + 7]; + w2_t[0] = s_esalt_buf[esalt_off + 8]; + w2_t[1] = s_esalt_buf[esalt_off + 9]; + w2_t[2] = s_esalt_buf[esalt_off + 10]; + w2_t[3] = s_esalt_buf[esalt_off + 11]; + w3_t[0] = s_esalt_buf[esalt_off + 12]; + w3_t[1] = s_esalt_buf[esalt_off + 13]; + w3_t[2] = s_esalt_buf[esalt_off + 14]; + w3_t[3] = s_esalt_buf[esalt_off + 15]; sha1_transform_vector (w0_t, w1_t, w2_t, w3_t, ipad); } - w0_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; + w0_t[0] = s_esalt_buf[esalt_off + 0]; + w0_t[1] = s_esalt_buf[esalt_off + 1]; + w0_t[2] = s_esalt_buf[esalt_off + 2]; + w0_t[3] = s_esalt_buf[esalt_off + 3]; + w1_t[0] = s_esalt_buf[esalt_off + 4]; + w1_t[1] = s_esalt_buf[esalt_off + 5]; + w1_t[2] = s_esalt_buf[esalt_off + 6]; + w1_t[3] = s_esalt_buf[esalt_off + 7]; + w2_t[0] = s_esalt_buf[esalt_off + 8]; + w2_t[1] = s_esalt_buf[esalt_off + 9]; + w2_t[2] = s_esalt_buf[esalt_off + 10]; + w2_t[3] = s_esalt_buf[esalt_off + 11]; + w3_t[0] = s_esalt_buf[esalt_off + 12]; + w3_t[1] = s_esalt_buf[esalt_off + 13]; w3_t[2] = 0; w3_t[3] = (64 + esalt_size) * 8; @@ -220,7 +220,7 @@ DECLSPEC void m07300m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER } } -DECLSPEC void m07300s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (rakp_t)) +DECLSPEC void m07300s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (rakp_t), LOCAL_AS u32 *s_esalt_buf) { /** * modifier @@ -297,40 +297,40 @@ DECLSPEC void m07300s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER for (esalt_left = esalt_size, esalt_off = 0; esalt_left >= 56; esalt_left -= 64, esalt_off += 16) { - w0_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; - w3_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 14]; - w3_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 15]; + w0_t[0] = s_esalt_buf[esalt_off + 0]; + w0_t[1] = s_esalt_buf[esalt_off + 1]; + w0_t[2] = s_esalt_buf[esalt_off + 2]; + w0_t[3] = s_esalt_buf[esalt_off + 3]; + w1_t[0] = s_esalt_buf[esalt_off + 4]; + w1_t[1] = s_esalt_buf[esalt_off + 5]; + w1_t[2] = s_esalt_buf[esalt_off + 6]; + w1_t[3] = s_esalt_buf[esalt_off + 7]; + w2_t[0] = s_esalt_buf[esalt_off + 8]; + w2_t[1] = s_esalt_buf[esalt_off + 9]; + w2_t[2] = s_esalt_buf[esalt_off + 10]; + w2_t[3] = s_esalt_buf[esalt_off + 11]; + w3_t[0] = s_esalt_buf[esalt_off + 12]; + w3_t[1] = s_esalt_buf[esalt_off + 13]; + w3_t[2] = s_esalt_buf[esalt_off + 14]; + w3_t[3] = s_esalt_buf[esalt_off + 15]; sha1_transform_vector (w0_t, w1_t, w2_t, w3_t, ipad); } - w0_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 0]; - w0_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 1]; - w0_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 2]; - w0_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 3]; - w1_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 4]; - w1_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 5]; - w1_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 6]; - w1_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 7]; - w2_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 8]; - w2_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 9]; - w2_t[2] = esalt_bufs[digests_offset].salt_buf[esalt_off + 10]; - w2_t[3] = esalt_bufs[digests_offset].salt_buf[esalt_off + 11]; - w3_t[0] = esalt_bufs[digests_offset].salt_buf[esalt_off + 12]; - w3_t[1] = esalt_bufs[digests_offset].salt_buf[esalt_off + 13]; + w0_t[0] = s_esalt_buf[esalt_off + 0]; + w0_t[1] = s_esalt_buf[esalt_off + 1]; + w0_t[2] = s_esalt_buf[esalt_off + 2]; + w0_t[3] = s_esalt_buf[esalt_off + 3]; + w1_t[0] = s_esalt_buf[esalt_off + 4]; + w1_t[1] = s_esalt_buf[esalt_off + 5]; + w1_t[2] = s_esalt_buf[esalt_off + 6]; + w1_t[3] = s_esalt_buf[esalt_off + 7]; + w2_t[0] = s_esalt_buf[esalt_off + 8]; + w2_t[1] = s_esalt_buf[esalt_off + 9]; + w2_t[2] = s_esalt_buf[esalt_off + 10]; + w2_t[3] = s_esalt_buf[esalt_off + 11]; + w3_t[0] = s_esalt_buf[esalt_off + 12]; + w3_t[1] = s_esalt_buf[esalt_off + 13]; w3_t[2] = 0; w3_t[3] = (64 + esalt_size) * 8; @@ -345,13 +345,32 @@ DECLSPEC void m07300s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER KERNEL_FQ void m07300_m04 (KERN_ATTR_ESALT (rakp_t)) { /** - * base + * modifier */ const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * s_msg + */ + + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; + /** + * base + */ + u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -386,19 +405,38 @@ KERNEL_FQ void m07300_m04 (KERN_ATTR_ESALT (rakp_t)) * main */ - m07300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_esalt_buf); } KERNEL_FQ void m07300_m08 (KERN_ATTR_ESALT (rakp_t)) { /** - * base + * modifier */ const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * s_msg + */ + + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; + /** + * base + */ + u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -433,19 +471,38 @@ KERNEL_FQ void m07300_m08 (KERN_ATTR_ESALT (rakp_t)) * main */ - m07300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_esalt_buf); } KERNEL_FQ void m07300_m16 (KERN_ATTR_ESALT (rakp_t)) { /** - * base + * modifier */ const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * s_msg + */ + + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; + /** + * base + */ + u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -480,19 +537,38 @@ KERNEL_FQ void m07300_m16 (KERN_ATTR_ESALT (rakp_t)) * main */ - m07300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_esalt_buf); } KERNEL_FQ void m07300_s04 (KERN_ATTR_ESALT (rakp_t)) { /** - * base + * modifier */ const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * s_msg + */ + + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; + /** + * base + */ + u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -527,19 +603,38 @@ KERNEL_FQ void m07300_s04 (KERN_ATTR_ESALT (rakp_t)) * main */ - m07300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_esalt_buf); } KERNEL_FQ void m07300_s08 (KERN_ATTR_ESALT (rakp_t)) { /** - * base + * modifier */ const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * s_msg + */ + + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; + /** + * base + */ + u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -574,19 +669,38 @@ KERNEL_FQ void m07300_s08 (KERN_ATTR_ESALT (rakp_t)) * main */ - m07300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_esalt_buf); } KERNEL_FQ void m07300_s16 (KERN_ATTR_ESALT (rakp_t)) { /** - * base + * modifier */ const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * s_msg + */ + + LOCAL_VK u32 s_esalt_buf[128]; + + for (u32 i = lid; i < 128; i += lsz) + { + s_esalt_buf[i] = esalt_bufs[digests_offset].salt_buf[i]; + } + + SYNC_THREADS (); if (gid >= gid_max) return; + /** + * base + */ + u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -621,5 +735,5 @@ KERNEL_FQ void m07300_s16 (KERN_ATTR_ESALT (rakp_t)) * main */ - m07300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max, s_esalt_buf); } diff --git a/OpenCL/m07400-optimized.cl b/OpenCL/m07400-optimized.cl index 5d8cf6af0..d8d0393ed 100644 --- a/OpenCL/m07400-optimized.cl +++ b/OpenCL/m07400-optimized.cl @@ -14,6 +14,8 @@ #define COMPARE_S "inc_comp_single.cl" #define COMPARE_M "inc_comp_multi.cl" +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + typedef struct sha256crypt_tmp { // pure version @@ -24,33 +26,6 @@ typedef struct sha256crypt_tmp } sha256crypt_tmp_t; -DECLSPEC void sha256_transform_transport (const u32 *w, u32 *digest) -{ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - - w0[0] = hc_swap32_S (w[ 0]); - w0[1] = hc_swap32_S (w[ 1]); - w0[2] = hc_swap32_S (w[ 2]); - w0[3] = hc_swap32_S (w[ 3]); - w1[0] = hc_swap32_S (w[ 4]); - w1[1] = hc_swap32_S (w[ 5]); - w1[2] = hc_swap32_S (w[ 6]); - w1[3] = hc_swap32_S (w[ 7]); - w2[0] = hc_swap32_S (w[ 8]); - w2[1] = hc_swap32_S (w[ 9]); - w2[2] = hc_swap32_S (w[10]); - w2[3] = hc_swap32_S (w[11]); - w3[0] = hc_swap32_S (w[12]); - w3[1] = hc_swap32_S (w[13]); - w3[2] = hc_swap32_S (w[14]); - w3[3] = hc_swap32_S (w[15]); - - sha256_transform (w0, w1, w2, w3, digest); -} - DECLSPEC void init_ctx (u32 *digest) { digest[0] = SHA256M_A; @@ -63,76 +38,29 @@ DECLSPEC void init_ctx (u32 *digest) digest[7] = SHA256M_H; } -DECLSPEC void bzero16 (u32 *block) -{ - block[ 0] = 0; - block[ 1] = 0; - block[ 2] = 0; - block[ 3] = 0; - block[ 4] = 0; - block[ 5] = 0; - block[ 6] = 0; - block[ 7] = 0; - block[ 8] = 0; - block[ 9] = 0; - block[10] = 0; - block[11] = 0; - block[12] = 0; - block[13] = 0; - block[14] = 0; - block[15] = 0; -} - -DECLSPEC void bswap8 (u32 *block) -{ - block[ 0] = hc_swap32_S (block[ 0]); - block[ 1] = hc_swap32_S (block[ 1]); - block[ 2] = hc_swap32_S (block[ 2]); - block[ 3] = hc_swap32_S (block[ 3]); - block[ 4] = hc_swap32_S (block[ 4]); - block[ 5] = hc_swap32_S (block[ 5]); - block[ 6] = hc_swap32_S (block[ 6]); - block[ 7] = hc_swap32_S (block[ 7]); -} - DECLSPEC u32 memcat16 (u32 *block, const u32 offset, const u32 *append, const u32 append_len) { - u32 tmp0; - u32 tmp1; - u32 tmp2; - u32 tmp3; - u32 tmp4; - - #if defined IS_AMD || defined IS_GENERIC u32 in0 = append[0]; u32 in1 = append[1]; u32 in2 = append[2]; u32 in3 = append[3]; - tmp0 = hc_bytealign ( 0, in0, offset); - tmp1 = hc_bytealign (in0, in1, offset); - tmp2 = hc_bytealign (in1, in2, offset); - tmp3 = hc_bytealign (in2, in3, offset); - tmp4 = hc_bytealign (in3, 0, offset); + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be (in3, 0, offset); #endif #ifdef IS_NV - const int offset_mod_4 = offset & 3; + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; - const int offset_minus_4 = 4 - offset_mod_4; - - const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; - - u32 in0 = append[0]; - u32 in1 = append[1]; - u32 in2 = append[2]; - u32 in3 = append[3]; - - tmp0 = hc_byte_perm ( 0, in0, selector); - tmp1 = hc_byte_perm (in0, in1, selector); - tmp2 = hc_byte_perm (in1, in2, selector); - tmp3 = hc_byte_perm (in2, in3, selector); - tmp4 = hc_byte_perm (in3, 0, selector); + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (0, in3, selector); #endif switch (offset / 4) @@ -232,45 +160,30 @@ DECLSPEC u32 memcat16 (u32 *block, const u32 offset, const u32 *append, const u3 DECLSPEC u32 memcat16c (u32 *block, const u32 offset, const u32 *append, const u32 append_len, u32 *digest) { - u32 tmp0; - u32 tmp1; - u32 tmp2; - u32 tmp3; - u32 tmp4; - - #if defined IS_AMD || defined IS_GENERIC u32 in0 = append[0]; u32 in1 = append[1]; u32 in2 = append[2]; u32 in3 = append[3]; - tmp0 = hc_bytealign ( 0, in0, offset); - tmp1 = hc_bytealign (in0, in1, offset); - tmp2 = hc_bytealign (in1, in2, offset); - tmp3 = hc_bytealign (in2, in3, offset); - tmp4 = hc_bytealign (in3, 0, offset); + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be (in3, 0, offset); #endif #ifdef IS_NV - const int offset_mod_4 = offset & 3; + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; - const int offset_minus_4 = 4 - offset_mod_4; - - const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; - - u32 in0 = append[0]; - u32 in1 = append[1]; - u32 in2 = append[2]; - u32 in3 = append[3]; - - tmp0 = hc_byte_perm ( 0, in0, selector); - tmp1 = hc_byte_perm (in0, in1, selector); - tmp2 = hc_byte_perm (in1, in2, selector); - tmp3 = hc_byte_perm (in2, in3, selector); - tmp4 = hc_byte_perm (in3, 0, selector); + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (0, in3, selector); #endif - u32 carry[4] = { 0, 0, 0, 0 }; + u32 carry[4] = { 0 }; switch (offset / 4) { @@ -378,57 +291,487 @@ DECLSPEC u32 memcat16c (u32 *block, const u32 offset, const u32 *append, const u { new_len -= 64; - sha256_transform_transport (block, digest); + sha256_transform (block + 0, block + 4, block + 8, block + 12, digest); - bzero16 (block); - - block[0] = carry[0]; - block[1] = carry[1]; - block[2] = carry[2]; - block[3] = carry[3]; + block[ 0] = carry[0]; + block[ 1] = carry[1]; + block[ 2] = carry[2]; + block[ 3] = carry[3]; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; } return new_len; } -DECLSPEC u32 memcat20 (u32 *block, const u32 offset, const u32 *append, const u32 append_len) +DECLSPEC u32 memcat16s (u32 *block, const u32 offset, const u32 *append, const u32 append_len) { - u32 tmp0; - u32 tmp1; - u32 tmp2; - u32 tmp3; - u32 tmp4; - - #if defined IS_AMD || defined IS_GENERIC u32 in0 = append[0]; u32 in1 = append[1]; u32 in2 = append[2]; u32 in3 = append[3]; + u32 in4 = append[4]; - tmp0 = hc_bytealign ( 0, in0, offset); - tmp1 = hc_bytealign (in0, in1, offset); - tmp2 = hc_bytealign (in1, in2, offset); - tmp3 = hc_bytealign (in2, in3, offset); - tmp4 = hc_bytealign (in3, 0, offset); + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be (in3, in4, offset); + const u32 tmp5 = hc_bytealign_be (in4, 0, offset); #endif #ifdef IS_NV - const int offset_mod_4 = offset & 3; + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; - const int offset_minus_4 = 4 - offset_mod_4; + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (in4, in3, selector); + const u32 tmp5 = hc_byte_perm_S (0, in4, selector); + #endif - const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; + switch (offset / 4) + { + case 0: block[ 0] |= tmp0; + block[ 1] = tmp1; + block[ 2] = tmp2; + block[ 3] = tmp3; + block[ 4] = tmp4; + block[ 5] = tmp5; + break; + case 1: block[ 1] |= tmp0; + block[ 2] = tmp1; + block[ 3] = tmp2; + block[ 4] = tmp3; + block[ 5] = tmp4; + block[ 6] = tmp5; + break; + case 2: block[ 2] |= tmp0; + block[ 3] = tmp1; + block[ 4] = tmp2; + block[ 5] = tmp3; + block[ 6] = tmp4; + block[ 7] = tmp5; + break; + case 3: block[ 3] |= tmp0; + block[ 4] = tmp1; + block[ 5] = tmp2; + block[ 6] = tmp3; + block[ 7] = tmp4; + block[ 8] = tmp5; + break; + case 4: block[ 4] |= tmp0; + block[ 5] = tmp1; + block[ 6] = tmp2; + block[ 7] = tmp3; + block[ 8] = tmp4; + block[ 9] = tmp5; + break; + case 5: block[ 5] |= tmp0; + block[ 6] = tmp1; + block[ 7] = tmp2; + block[ 8] = tmp3; + block[ 9] = tmp4; + block[10] = tmp5; + break; + case 6: block[ 6] |= tmp0; + block[ 7] = tmp1; + block[ 8] = tmp2; + block[ 9] = tmp3; + block[10] = tmp4; + block[11] = tmp5; + break; + case 7: block[ 7] |= tmp0; + block[ 8] = tmp1; + block[ 9] = tmp2; + block[10] = tmp3; + block[11] = tmp4; + block[12] = tmp5; + break; + case 8: block[ 8] |= tmp0; + block[ 9] = tmp1; + block[10] = tmp2; + block[11] = tmp3; + block[12] = tmp4; + block[13] = tmp5; + break; + case 9: block[ 9] |= tmp0; + block[10] = tmp1; + block[11] = tmp2; + block[12] = tmp3; + block[13] = tmp4; + block[14] = tmp5; + break; + case 10: block[10] |= tmp0; + block[11] = tmp1; + block[12] = tmp2; + block[13] = tmp3; + block[14] = tmp4; + block[15] = tmp5; + break; + case 11: block[11] |= tmp0; + block[12] = tmp1; + block[13] = tmp2; + block[14] = tmp3; + block[15] = tmp4; + break; + case 12: block[12] |= tmp0; + block[13] = tmp1; + block[14] = tmp2; + block[15] = tmp3; + break; + case 13: block[13] |= tmp0; + block[14] = tmp1; + block[15] = tmp2; + break; + case 14: block[14] |= tmp0; + block[15] = tmp1; + break; + case 15: block[15] |= tmp0; + break; + } + u32 new_len = offset + append_len; + + return new_len; +} + +DECLSPEC u32 memcat16sc (u32 *block, const u32 offset, const u32 *append, const u32 append_len, u32 *digest) +{ + u32 in0 = append[0]; + u32 in1 = append[1]; + u32 in2 = append[2]; + u32 in3 = append[3]; + u32 in4 = append[4]; + + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be (in3, in4, offset); + const u32 tmp5 = hc_bytealign_be (in4, 0, offset); + #endif + + #ifdef IS_NV + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; + + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (in4, in3, selector); + const u32 tmp5 = hc_byte_perm_S (0, in4, selector); + #endif + + u32 carry[5] = { 0 }; + + switch (offset / 4) + { + case 0: block[ 0] |= tmp0; + block[ 1] = tmp1; + block[ 2] = tmp2; + block[ 3] = tmp3; + block[ 4] = tmp4; + block[ 5] = tmp5; + break; + case 1: block[ 1] |= tmp0; + block[ 2] = tmp1; + block[ 3] = tmp2; + block[ 4] = tmp3; + block[ 5] = tmp4; + block[ 6] = tmp5; + break; + case 2: block[ 2] |= tmp0; + block[ 3] = tmp1; + block[ 4] = tmp2; + block[ 5] = tmp3; + block[ 6] = tmp4; + block[ 7] = tmp5; + break; + case 3: block[ 3] |= tmp0; + block[ 4] = tmp1; + block[ 5] = tmp2; + block[ 6] = tmp3; + block[ 7] = tmp4; + block[ 8] = tmp5; + break; + case 4: block[ 4] |= tmp0; + block[ 5] = tmp1; + block[ 6] = tmp2; + block[ 7] = tmp3; + block[ 8] = tmp4; + block[ 9] = tmp5; + break; + case 5: block[ 5] |= tmp0; + block[ 6] = tmp1; + block[ 7] = tmp2; + block[ 8] = tmp3; + block[ 9] = tmp4; + block[10] = tmp5; + break; + case 6: block[ 6] |= tmp0; + block[ 7] = tmp1; + block[ 8] = tmp2; + block[ 9] = tmp3; + block[10] = tmp4; + block[11] = tmp5; + break; + case 7: block[ 7] |= tmp0; + block[ 8] = tmp1; + block[ 9] = tmp2; + block[10] = tmp3; + block[11] = tmp4; + block[12] = tmp5; + break; + case 8: block[ 8] |= tmp0; + block[ 9] = tmp1; + block[10] = tmp2; + block[11] = tmp3; + block[12] = tmp4; + block[13] = tmp5; + break; + case 9: block[ 9] |= tmp0; + block[10] = tmp1; + block[11] = tmp2; + block[12] = tmp3; + block[13] = tmp4; + block[14] = tmp5; + break; + case 10: block[10] |= tmp0; + block[11] = tmp1; + block[12] = tmp2; + block[13] = tmp3; + block[14] = tmp4; + block[15] = tmp5; + break; + case 11: block[11] |= tmp0; + block[12] = tmp1; + block[13] = tmp2; + block[14] = tmp3; + block[15] = tmp4; + carry[ 0] = tmp5; + break; + case 12: block[12] |= tmp0; + block[13] = tmp1; + block[14] = tmp2; + block[15] = tmp3; + carry[ 0] = tmp4; + carry[ 1] = tmp5; + break; + case 13: block[13] |= tmp0; + block[14] = tmp1; + block[15] = tmp2; + carry[ 0] = tmp3; + carry[ 1] = tmp4; + carry[ 2] = tmp5; + break; + case 14: block[14] |= tmp0; + block[15] = tmp1; + carry[ 0] = tmp2; + carry[ 1] = tmp3; + carry[ 2] = tmp4; + carry[ 3] = tmp5; + break; + case 15: block[15] |= tmp0; + carry[ 0] = tmp1; + carry[ 1] = tmp2; + carry[ 2] = tmp3; + carry[ 3] = tmp4; + carry[ 4] = tmp5; + break; + } + + u32 new_len = offset + append_len; + + if (new_len >= 64) + { + new_len -= 64; + + sha256_transform (block + 0, block + 4, block + 8, block + 12, digest); + + block[ 0] = carry[0]; + block[ 1] = carry[1]; + block[ 2] = carry[2]; + block[ 3] = carry[3]; + block[ 4] = carry[4]; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + } + + return new_len; +} + +DECLSPEC void truncate_block_5x4_be_S (u32 *w0, const u32 len) +{ + switch (len) + { + case 0: + w0[0] = 0; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 1: + w0[0] &= 0xff000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 2: + w0[0] &= 0xffff0000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 3: + w0[0] &= 0xffffff00; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 4: + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 5: + w0[1] &= 0xff000000; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 6: + w0[1] &= 0xffff0000; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 7: + w0[1] &= 0xffffff00; + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 8: + w0[2] = 0; + w0[3] = 0; + w0[4] = 0; + break; + + case 9: + w0[2] &= 0xff000000; + w0[3] = 0; + w0[4] = 0; + break; + + case 10: + w0[2] &= 0xffff0000; + w0[3] = 0; + w0[4] = 0; + break; + + case 11: + w0[2] &= 0xffffff00; + w0[3] = 0; + w0[4] = 0; + break; + + case 12: + w0[3] = 0; + w0[4] = 0; + break; + + case 13: + w0[3] &= 0xff000000; + w0[4] = 0; + break; + + case 14: + w0[3] &= 0xffff0000; + w0[4] = 0; + break; + + case 15: + w0[3] &= 0xffffff00; + w0[4] = 0; + break; + + case 16: + w0[4] = 0; + break; + + case 17: + w0[4] &= 0xff000000; + break; + + case 18: + w0[4] &= 0xffff0000; + break; + + case 19: + w0[4] &= 0xffffff00; + break; + } +} + +DECLSPEC u32 memcat20 (u32 *block, const u32 offset, const u32 *append, const u32 append_len) +{ u32 in0 = append[0]; u32 in1 = append[1]; u32 in2 = append[2]; u32 in3 = append[3]; - tmp0 = hc_byte_perm ( 0, in0, selector); - tmp1 = hc_byte_perm (in0, in1, selector); - tmp2 = hc_byte_perm (in1, in2, selector); - tmp3 = hc_byte_perm (in2, in3, selector); - tmp4 = hc_byte_perm (in3, 0, selector); + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be_S ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be_S (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be_S (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be_S (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be_S (in3, 0, offset); + #endif + + #ifdef IS_NV + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; + + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (0, in3, selector); #endif switch (offset / 4) @@ -529,6 +872,36 @@ DECLSPEC u32 memcat20 (u32 *block, const u32 offset, const u32 *append, const u3 block[18] = tmp3; block[19] = tmp4; break; + case 16: block[16] |= tmp0; + block[17] = tmp1; + block[18] = tmp2; + block[19] = tmp3; + block[20] = tmp4; + break; + case 17: block[17] |= tmp0; + block[18] = tmp1; + block[19] = tmp2; + block[20] = tmp3; + block[21] = tmp4; + break; + case 18: block[18] |= tmp0; + block[19] = tmp1; + block[20] = tmp2; + block[21] = tmp3; + block[22] = tmp4; + break; + case 19: block[19] |= tmp0; + block[20] = tmp1; + block[21] = tmp2; + block[22] = tmp3; + block[23] = tmp4; + break; + case 20: block[20] |= tmp0; + block[21] = tmp1; + block[22] = tmp2; + block[23] = tmp3; + block[24] = tmp4; + break; } return offset + append_len; @@ -536,44 +909,28 @@ DECLSPEC u32 memcat20 (u32 *block, const u32 offset, const u32 *append, const u3 DECLSPEC u32 memcat20_x80 (u32 *block, const u32 offset, const u32 *append, const u32 append_len) { - u32 tmp0; - u32 tmp1; - u32 tmp2; - u32 tmp3; - u32 tmp4; - - #if defined IS_AMD || defined IS_GENERIC u32 in0 = append[0]; u32 in1 = append[1]; u32 in2 = append[2]; u32 in3 = append[3]; - u32 in4 = 0x80; + u32 in4 = 0x80000000; - tmp0 = hc_bytealign ( 0, in0, offset); - tmp1 = hc_bytealign (in0, in1, offset); - tmp2 = hc_bytealign (in1, in2, offset); - tmp3 = hc_bytealign (in2, in3, offset); - tmp4 = hc_bytealign (in3, in4, offset); + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be_S ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be_S (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be_S (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be_S (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be_S (in3, in4, offset); #endif #ifdef IS_NV - const int offset_mod_4 = offset & 3; + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; - const int offset_minus_4 = 4 - offset_mod_4; - - const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff; - - u32 in0 = append[0]; - u32 in1 = append[1]; - u32 in2 = append[2]; - u32 in3 = append[3]; - u32 in4 = 0x80; - - tmp0 = hc_byte_perm ( 0, in0, selector); - tmp1 = hc_byte_perm (in0, in1, selector); - tmp2 = hc_byte_perm (in1, in2, selector); - tmp3 = hc_byte_perm (in2, in3, selector); - tmp4 = hc_byte_perm (in3, in4, selector); + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (in4, in3, selector); #endif switch (offset / 4) @@ -674,6 +1031,99 @@ DECLSPEC u32 memcat20_x80 (u32 *block, const u32 offset, const u32 *append, cons block[18] = tmp3; block[19] = tmp4; break; + case 16: block[16] |= tmp0; + block[17] = tmp1; + block[18] = tmp2; + block[19] = tmp3; + block[20] = tmp4; + break; + case 17: block[17] |= tmp0; + block[18] = tmp1; + block[19] = tmp2; + block[20] = tmp3; + block[21] = tmp4; + break; + case 18: block[18] |= tmp0; + block[19] = tmp1; + block[20] = tmp2; + block[21] = tmp3; + block[22] = tmp4; + break; + case 19: block[19] |= tmp0; + block[20] = tmp1; + block[21] = tmp2; + block[22] = tmp3; + block[23] = tmp4; + break; + case 20: block[20] |= tmp0; + block[21] = tmp1; + block[22] = tmp2; + block[23] = tmp3; + block[24] = tmp4; + break; + } + + return offset + append_len; +} + +DECLSPEC u32 memcat24 (u32 *block, const u32 offset, const u32 *append, const u32 append_len) +{ + u32 in0 = append[0]; + u32 in1 = append[1]; + u32 in2 = append[2]; + u32 in3 = append[3]; + u32 in4 = append[4]; + + #if defined IS_AMD || defined IS_GENERIC + const u32 tmp0 = hc_bytealign_be_S ( 0, in0, offset); + const u32 tmp1 = hc_bytealign_be_S (in0, in1, offset); + const u32 tmp2 = hc_bytealign_be_S (in1, in2, offset); + const u32 tmp3 = hc_bytealign_be_S (in2, in3, offset); + const u32 tmp4 = hc_bytealign_be_S (in3, in4, offset); + const u32 tmp5 = hc_bytealign_be_S (in4, 0, offset); + #endif + + #ifdef IS_NV + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; + + const u32 tmp0 = hc_byte_perm_S (in0, 0, selector); + const u32 tmp1 = hc_byte_perm_S (in1, in0, selector); + const u32 tmp2 = hc_byte_perm_S (in2, in1, selector); + const u32 tmp3 = hc_byte_perm_S (in3, in2, selector); + const u32 tmp4 = hc_byte_perm_S (in4, in3, selector); + const u32 tmp5 = hc_byte_perm_S (0, in4, selector); + #endif + + switch (offset / 4) + { + case 0: block[ 0] |= tmp0; + block[ 1] = tmp1; + block[ 2] = tmp2; + block[ 3] = tmp3; + block[ 4] = tmp4; + block[ 5] = tmp5; + break; + case 1: block[ 1] |= tmp0; + block[ 2] = tmp1; + block[ 3] = tmp2; + block[ 4] = tmp3; + block[ 5] = tmp4; + block[ 6] = tmp5; + break; + case 2: block[ 2] |= tmp0; + block[ 3] = tmp1; + block[ 4] = tmp2; + block[ 5] = tmp3; + block[ 6] = tmp4; + block[ 7] = tmp5; + break; + case 3: block[ 3] |= tmp0; + block[ 4] = tmp1; + block[ 5] = tmp2; + block[ 6] = tmp3; + block[ 7] = tmp4; + block[ 8] = tmp5; + break; } return offset + append_len; @@ -691,25 +1141,26 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) u32 w0[4]; - w0[0] = pws[gid].i[0]; - w0[1] = pws[gid].i[1]; - w0[2] = pws[gid].i[2]; - w0[3] = pws[gid].i[3]; + w0[0] = hc_swap32_S (pws[gid].i[0]); + w0[1] = hc_swap32_S (pws[gid].i[1]); + w0[2] = hc_swap32_S (pws[gid].i[2]); + w0[3] = hc_swap32_S (pws[gid].i[3]); - const u32 pw_len = pws[gid].pw_len & 63; + const u32 pw_len = MIN (pws[gid].pw_len, 15); /** * salt */ - u32 salt_buf[4]; + u32 salt_buf[5]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); - u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = MIN (salt_bufs[salt_pos].salt_len, 20); /** * buffers @@ -720,6 +1171,23 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) u32 block[16]; + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + u32 alt_result[8]; u32 p_bytes[8]; u32 s_bytes[8]; @@ -728,33 +1196,25 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) block_len = 0; - bzero16 (block); - /* Add key. */ block_len = memcat16 (block, block_len, w0, pw_len); /* Add salt. */ - block_len = memcat16 (block, block_len, salt_buf, salt_len); + block_len = memcat16s (block, block_len, salt_buf, salt_len); /* Add key again. */ block_len = memcat16 (block, block_len, w0, pw_len); - append_0x80_1x16 (block, block_len); + append_0x80_1x16 (block, block_len ^ 3); - block[15] = hc_swap32_S (block_len * 8); + block[15] = block_len * 8; init_ctx (alt_result); - sha256_transform_transport (block, alt_result); - - bswap8 (alt_result); - - block_len = 0; - - bzero16 (block); + sha256_transform (block + 0, block + 4, block + 8, block + 12, alt_result); u32 alt_result_tmp[8]; @@ -767,7 +1227,26 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) alt_result_tmp[6] = 0; alt_result_tmp[7] = 0; - truncate_block_4x4_le_S (alt_result_tmp, pw_len); + truncate_block_4x4_be_S (alt_result_tmp, pw_len); + + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + + block_len = 0; /* Add the key string. */ @@ -777,7 +1256,7 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) characters and it ends at the first `$' character (for compatibility with existing implementations). */ - block_len = memcat16 (block, block_len, salt_buf, salt_len); + block_len = memcat16s (block, block_len, salt_buf, salt_len); /* Now get result of this (32 bytes) and add it to the other context. */ @@ -817,20 +1296,33 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) } } - append_0x80_1x16 (block, block_len); + append_0x80_1x16 (block, block_len ^ 3); if (block_len >= 56) { - sha256_transform_transport (block, alt_result); + sha256_transform (block + 0, block + 4, block + 8, block + 12, alt_result); - bzero16 (block); + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; } - block[15] = hc_swap32_S (transform_len * 8); + block[15] = transform_len * 8; - sha256_transform_transport (block, alt_result); - - bswap8 (alt_result); + sha256_transform (block + 0, block + 4, block + 8, block + 12, alt_result); tmps[gid].alt_result[0] = alt_result[0]; tmps[gid].alt_result[1] = alt_result[1]; @@ -843,11 +1335,26 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) /* Start computation of P byte sequence. */ - block_len = 0; - transform_len = 0; - bzero16 (block); + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + + block_len = 0; /* For every character in the password add the entire password. */ @@ -862,22 +1369,35 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) /* Finish the digest. */ - append_0x80_1x16 (block, block_len); + append_0x80_1x16 (block, block_len ^ 3); if (block_len >= 56) { - sha256_transform_transport (block, p_bytes); + sha256_transform (block + 0, block + 4, block + 8, block + 12, p_bytes); - bzero16 (block); + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; } - block[15] = hc_swap32_S (transform_len * 8); + block[15] = transform_len * 8; - sha256_transform_transport (block, p_bytes); + sha256_transform (block + 0, block + 4, block + 8, block + 12, p_bytes); - bswap8 (p_bytes); - - truncate_block_4x4_le_S (p_bytes, pw_len); + truncate_block_4x4_be_S (p_bytes, pw_len); tmps[gid].p_bytes[0] = p_bytes[0]; tmps[gid].p_bytes[1] = p_bytes[1]; @@ -886,46 +1406,75 @@ KERNEL_FQ void m07400_init (KERN_ATTR_TMPS (sha256crypt_tmp_t)) /* Start computation of S byte sequence. */ - block_len = 0; - transform_len = 0; - bzero16 (block); + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + + block_len = 0; /* For every character in the password add the entire password. */ init_ctx (s_bytes); - for (u32 j = 0; j < 16 + (alt_result[0] & 0xff); j++) + for (u32 j = 0; j < 16 + (alt_result[0] >> 24); j++) { - block_len = memcat16c (block, block_len, salt_buf, salt_len, s_bytes); + block_len = memcat16sc (block, block_len, salt_buf, salt_len, s_bytes); transform_len += salt_len; } /* Finish the digest. */ - append_0x80_1x16 (block, block_len); + append_0x80_1x16 (block, block_len ^ 3); if (block_len >= 56) { - sha256_transform_transport (block, s_bytes); + sha256_transform (block + 0, block + 4, block + 8, block + 12, s_bytes); - bzero16 (block); + block[ 0] = 0; + block[ 1] = 0; + block[ 2] = 0; + block[ 3] = 0; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; } - block[15] = hc_swap32_S (transform_len * 8); + block[15] = transform_len * 8; - sha256_transform_transport (block, s_bytes); + sha256_transform (block + 0, block + 4, block + 8, block + 12, s_bytes); - bswap8 (s_bytes); - - truncate_block_4x4_le_S (s_bytes, salt_len); + truncate_block_5x4_be_S (s_bytes, salt_len); tmps[gid].s_bytes[0] = s_bytes[0]; tmps[gid].s_bytes[1] = s_bytes[1]; tmps[gid].s_bytes[2] = s_bytes[2]; tmps[gid].s_bytes[3] = s_bytes[3]; + tmps[gid].s_bytes[4] = s_bytes[4]; } KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) @@ -938,7 +1487,7 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) if (gid >= gid_max) return; - const u32 pw_len = pws[gid].pw_len & 63; + const u32 pw_len = MIN (pws[gid].pw_len, 15); /** * base @@ -951,21 +1500,13 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) p_bytes[2] = tmps[gid].p_bytes[2]; p_bytes[3] = tmps[gid].p_bytes[3]; - u32 p_bytes_x80[4]; - - p_bytes_x80[0] = tmps[gid].p_bytes[0]; - p_bytes_x80[1] = tmps[gid].p_bytes[1]; - p_bytes_x80[2] = tmps[gid].p_bytes[2]; - p_bytes_x80[3] = tmps[gid].p_bytes[3]; - - append_0x80_1x4 (p_bytes_x80, pw_len); - - u32 s_bytes[4]; + u32 s_bytes[5]; s_bytes[0] = tmps[gid].s_bytes[0]; s_bytes[1] = tmps[gid].s_bytes[1]; s_bytes[2] = tmps[gid].s_bytes[2]; s_bytes[3] = tmps[gid].s_bytes[3]; + s_bytes[4] = tmps[gid].s_bytes[4]; // 4 extra bytes for MySQL 7.5+ hashes u32 alt_result[8]; @@ -978,7 +1519,18 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) alt_result[6] = tmps[gid].alt_result[6]; alt_result[7] = tmps[gid].alt_result[7]; - u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = MIN (salt_bufs[salt_pos].salt_len, 20); + + // just an optimization + + u32 p_bytes_x80[4]; + + p_bytes_x80[0] = p_bytes[0]; + p_bytes_x80[1] = p_bytes[1]; + p_bytes_x80[2] = p_bytes[2]; + p_bytes_x80[3] = p_bytes[3]; + + append_0x80_1x4_S (p_bytes_x80, pw_len ^ 3); /* Repeatedly run the collected hash value through SHA256 to burn CPU cycles. */ @@ -989,10 +1541,7 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) init_ctx (tmp); - u32 block[32]; - - bzero16 (&block[ 0]); - bzero16 (&block[16]); + u32 block[25]; u32 block_len = 0; @@ -1002,30 +1551,79 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) if (j1) { - block[0] = p_bytes[0]; - block[1] = p_bytes[1]; - block[2] = p_bytes[2]; - block[3] = p_bytes[3]; + block[ 0] = p_bytes[0]; + block[ 1] = p_bytes[1]; + block[ 2] = p_bytes[2]; + block[ 3] = p_bytes[3]; + block[ 4] = 0; + block[ 5] = 0; + block[ 6] = 0; + block[ 7] = 0; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + block[16] = 0; + block[17] = 0; + block[18] = 0; + block[19] = 0; + block[20] = 0; + block[21] = 0; + block[22] = 0; + block[23] = 0; + block[24] = 0; block_len = pw_len; + + if (j3) + { + block_len = memcat24 (block, block_len, s_bytes, salt_len); + } } else { - block[0] = alt_result[0]; - block[1] = alt_result[1]; - block[2] = alt_result[2]; - block[3] = alt_result[3]; - block[4] = alt_result[4]; - block[5] = alt_result[5]; - block[6] = alt_result[6]; - block[7] = alt_result[7]; + block[ 0] = alt_result[0]; + block[ 1] = alt_result[1]; + block[ 2] = alt_result[2]; + block[ 3] = alt_result[3]; + block[ 4] = alt_result[4]; + block[ 5] = alt_result[5]; + block[ 6] = alt_result[6]; + block[ 7] = alt_result[7]; + block[ 8] = 0; + block[ 9] = 0; + block[10] = 0; + block[11] = 0; + block[12] = 0; + block[13] = 0; + block[14] = 0; + block[15] = 0; + block[16] = 0; + block[17] = 0; + block[18] = 0; + block[19] = 0; + block[20] = 0; + block[21] = 0; + block[22] = 0; + block[23] = 0; + block[24] = 0; block_len = 32; - } - if (j3) - { - block_len = memcat20 (block, block_len, s_bytes, salt_len); + if (j3) + { + block[ 8] = s_bytes[0]; + block[ 9] = s_bytes[1]; + block[10] = s_bytes[2]; + block[11] = s_bytes[3]; + block[12] = s_bytes[4]; + + block_len += salt_len; + } } if (j7) @@ -1045,17 +1643,17 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) if (block_len >= 56) { - sha256_transform_transport (block, tmp); + sha256_transform (block + 0, block + 4, block + 8, block + 12, tmp); block[ 0] = block[16]; block[ 1] = block[17]; block[ 2] = block[18]; block[ 3] = block[19]; - block[ 4] = 0; - block[ 5] = 0; - block[ 6] = 0; - block[ 7] = 0; - block[ 8] = 0; + block[ 4] = block[20]; + block[ 5] = block[21]; + block[ 6] = block[22]; + block[ 7] = block[23]; + block[ 8] = block[24]; block[ 9] = 0; block[10] = 0; block[11] = 0; @@ -1065,11 +1663,10 @@ KERNEL_FQ void m07400_loop (KERN_ATTR_TMPS (sha256crypt_tmp_t)) block[15] = 0; } - block[15] = hc_swap32_S (block_len * 8); + block[14] = 0; + block[15] = block_len * 8; - sha256_transform_transport (block, tmp); - - bswap8 (tmp); + sha256_transform (block + 0, block + 4, block + 8, block + 12, tmp); alt_result[0] = tmp[0]; alt_result[1] = tmp[1]; @@ -1103,10 +1700,10 @@ KERNEL_FQ void m07400_comp (KERN_ATTR_TMPS (sha256crypt_tmp_t)) const u64 lid = get_local_id (0); - const u32 r0 = tmps[gid].alt_result[0]; - const u32 r1 = tmps[gid].alt_result[1]; - const u32 r2 = tmps[gid].alt_result[2]; - const u32 r3 = tmps[gid].alt_result[3]; + const u32 r0 = hc_swap32_S (tmps[gid].alt_result[0]); + const u32 r1 = hc_swap32_S (tmps[gid].alt_result[1]); + const u32 r2 = hc_swap32_S (tmps[gid].alt_result[2]); + const u32 r3 = hc_swap32_S (tmps[gid].alt_result[3]); #define il_pos 0 diff --git a/OpenCL/m07800_a0-optimized.cl b/OpenCL/m07800_a0-optimized.cl index 4d86b2858..8f921f42f 100644 --- a/OpenCL/m07800_a0-optimized.cl +++ b/OpenCL/m07800_a0-optimized.cl @@ -17,30 +17,90 @@ #include "inc_hash_sha1.cl" #endif -CONSTANT_VK u32a theMagicArray[64] = +CONSTANT_VK u32a theMagicArray[80][16] = { - 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, - 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, - 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, - 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, - 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f, 0x37af944c, 0x29085282, 0xb23b4e37, 0x9f170791, 0x113bfdcd, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + { 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194 }, + { 0xac51149f, 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f }, + { 0x51149f67, 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b }, + { 0x149f6754, 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1 }, + { 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b }, + { 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06 }, + { 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605 }, + { 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d }, + { 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03 }, + { 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d }, + { 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e }, + { 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13 }, + { 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a }, + { 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e }, + { 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a }, + { 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a }, + { 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8 }, + { 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9 }, + { 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c }, + { 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14 }, + { 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417 }, + { 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758 }, + { 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7 }, + { 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a }, + { 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6 }, + { 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1 }, + { 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199 }, + { 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963 }, + { 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a }, + { 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7 }, + { 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd }, + { 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70 }, + { 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3 }, + { 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6 }, + { 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e }, + { 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74 }, + { 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413 }, + { 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303 }, + { 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9 }, + { 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b }, + { 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04 }, + { 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426 }, + { 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698 }, + { 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7 }, + { 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726 }, + { 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a }, + { 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92 }, + { 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293 }, + { 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325 }, + { 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0 }, + { 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2 }, + { 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d }, + { 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23 }, + { 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed }, + { 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63 }, + { 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379 }, + { 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d }, + { 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13 }, + { 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332 }, + { 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa }, + { 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c }, + { 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35 }, + { 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502 }, + { 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a }, + { 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3 }, + { 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3 }, + { 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd }, + { 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e }, + { 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a }, + { 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24 }, + { 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf }, + { 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51 }, + { 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3 }, + { 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c }, + { 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd }, + { 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55 }, + { 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f }, + { 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c, 0xcd559f37 }, + { 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd, 0x559f37af }, + { 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55, 0x9f37af94 }, }; -DECLSPEC u32 GETSHIFTEDINT_CONST (CONSTANT_AS u32a *a, const int n) -{ - const int d = n / 4; - const int m = n & 3; - - u64 tmp = hl32_to_64_S (a[d + 0], a[d + 1]); - - tmp <<= m * 8; - - return h32_from_64_S (tmp); -} - DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) { const int d = n / 4; @@ -56,20 +116,52 @@ DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif + + if (gid >= gid_max) return; + /** * modifier */ - const u64 lid = get_local_id (0); - - /** - * base - */ - - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - u32 pw_buf0[4]; u32 pw_buf1[4]; @@ -90,14 +182,14 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -114,6 +206,15 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + /** * SAP */ @@ -140,7 +241,7 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, out_len); const u32x pw_salt_len = out_len + salt_len; @@ -150,20 +251,20 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -191,33 +292,33 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -227,49 +328,61 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, out_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = out_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -278,17 +391,21 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_RULES ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_M_SIMD (digest[3], digest[4], digest[2], digest[1]); } @@ -304,20 +421,52 @@ KERNEL_FQ void m07800_m16 (KERN_ATTR_RULES ()) KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif + + if (gid >= gid_max) return; + /** * modifier */ - const u64 lid = get_local_id (0); - - /** - * base - */ - - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - u32 pw_buf0[4]; u32 pw_buf1[4]; @@ -338,14 +487,14 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -374,6 +523,15 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + /** * SAP */ @@ -400,7 +558,7 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, out_len); const u32x pw_salt_len = out_len + salt_len; @@ -410,20 +568,20 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -451,33 +609,33 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -487,49 +645,61 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, out_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = out_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -538,17 +708,21 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_RULES ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_S_SIMD (digest[3], digest[4], digest[2], digest[1]); } diff --git a/OpenCL/m07800_a1-optimized.cl b/OpenCL/m07800_a1-optimized.cl index cc552143f..5b43a174d 100644 --- a/OpenCL/m07800_a1-optimized.cl +++ b/OpenCL/m07800_a1-optimized.cl @@ -15,30 +15,90 @@ #include "inc_hash_sha1.cl" #endif -CONSTANT_VK u32a theMagicArray[64] = +CONSTANT_VK u32a theMagicArray[80][16] = { - 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, - 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, - 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, - 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, - 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f, 0x37af944c, 0x29085282, 0xb23b4e37, 0x9f170791, 0x113bfdcd, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + { 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194 }, + { 0xac51149f, 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f }, + { 0x51149f67, 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b }, + { 0x149f6754, 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1 }, + { 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b }, + { 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06 }, + { 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605 }, + { 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d }, + { 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03 }, + { 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d }, + { 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e }, + { 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13 }, + { 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a }, + { 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e }, + { 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a }, + { 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a }, + { 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8 }, + { 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9 }, + { 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c }, + { 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14 }, + { 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417 }, + { 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758 }, + { 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7 }, + { 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a }, + { 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6 }, + { 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1 }, + { 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199 }, + { 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963 }, + { 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a }, + { 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7 }, + { 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd }, + { 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70 }, + { 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3 }, + { 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6 }, + { 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e }, + { 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74 }, + { 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413 }, + { 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303 }, + { 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9 }, + { 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b }, + { 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04 }, + { 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426 }, + { 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698 }, + { 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7 }, + { 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726 }, + { 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a }, + { 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92 }, + { 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293 }, + { 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325 }, + { 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0 }, + { 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2 }, + { 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d }, + { 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23 }, + { 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed }, + { 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63 }, + { 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379 }, + { 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d }, + { 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13 }, + { 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332 }, + { 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa }, + { 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c }, + { 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35 }, + { 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502 }, + { 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a }, + { 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3 }, + { 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3 }, + { 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd }, + { 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e }, + { 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a }, + { 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24 }, + { 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf }, + { 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51 }, + { 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3 }, + { 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c }, + { 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd }, + { 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55 }, + { 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f }, + { 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c, 0xcd559f37 }, + { 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd, 0x559f37af }, + { 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55, 0x9f37af94 }, }; -DECLSPEC u32 GETSHIFTEDINT_CONST (CONSTANT_AS u32a *a, const int n) -{ - const int d = n / 4; - const int m = n & 3; - - u64 tmp = hl32_to_64_S (a[d + 0], a[d + 1]); - - tmp <<= m * 8; - - return h32_from_64_S (tmp); -} - DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) { const int d = n / 4; @@ -54,17 +114,45 @@ DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) { - /** - * modifier - */ - - const u64 lid = get_local_id (0); - - /** - * base - */ - const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -88,14 +176,14 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -172,6 +260,23 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) w3[2] = wordl3[2] | wordr3[2]; w3[3] = wordl3[3] | wordr3[3]; + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + /** * SAP */ @@ -198,7 +303,7 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, pw_len); const u32x pw_salt_len = pw_len + salt_len; @@ -208,20 +313,20 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -249,33 +354,33 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -285,49 +390,61 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = hc_swap32_S (w2[0]); - final[ 9] = hc_swap32_S (w2[1]); - final[10] = hc_swap32_S (w2[2]); - final[11] = hc_swap32_S (w2[3]); - final[12] = hc_swap32_S (w3[0]); - final[13] = hc_swap32_S (w3[1]); - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -336,17 +453,21 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_M_SIMD (digest[3], digest[4], digest[2], digest[1]); } @@ -362,17 +483,45 @@ KERNEL_FQ void m07800_m16 (KERN_ATTR_BASIC ()) KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) { - /** - * modifier - */ - - const u64 lid = get_local_id (0); - - /** - * base - */ - const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -396,14 +545,14 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -492,6 +641,23 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) w3[2] = wordl3[2] | wordr3[2]; w3[3] = wordl3[3] | wordr3[3]; + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + /** * SAP */ @@ -518,7 +684,7 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, pw_len); const u32x pw_salt_len = pw_len + salt_len; @@ -528,20 +694,20 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -569,33 +735,33 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -605,49 +771,61 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = hc_swap32_S (w2[0]); - final[ 9] = hc_swap32_S (w2[1]); - final[10] = hc_swap32_S (w2[2]); - final[11] = hc_swap32_S (w2[3]); - final[12] = hc_swap32_S (w3[0]); - final[13] = hc_swap32_S (w3[1]); - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -656,17 +834,21 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_S_SIMD (digest[3], digest[4], digest[2], digest[1]); } diff --git a/OpenCL/m07800_a3-optimized.cl b/OpenCL/m07800_a3-optimized.cl index de22475f0..a5370badb 100644 --- a/OpenCL/m07800_a3-optimized.cl +++ b/OpenCL/m07800_a3-optimized.cl @@ -15,30 +15,90 @@ #include "inc_hash_sha1.cl" #endif -CONSTANT_VK u32a theMagicArray[64] = +CONSTANT_VK u32a theMagicArray[80][16] = { - 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, - 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, - 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, - 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, - 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f, 0x37af944c, 0x29085282, 0xb23b4e37, 0x9f170791, 0x113bfdcd, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + { 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194 }, + { 0xac51149f, 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f }, + { 0x51149f67, 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b }, + { 0x149f6754, 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1 }, + { 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b }, + { 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06 }, + { 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605 }, + { 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d }, + { 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03 }, + { 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d }, + { 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e }, + { 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13 }, + { 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a }, + { 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e }, + { 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a }, + { 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a }, + { 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8 }, + { 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9 }, + { 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c }, + { 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14 }, + { 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417 }, + { 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758 }, + { 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7 }, + { 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a }, + { 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6 }, + { 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1 }, + { 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199 }, + { 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963 }, + { 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a }, + { 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7 }, + { 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd }, + { 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70 }, + { 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3 }, + { 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6 }, + { 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e }, + { 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74 }, + { 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413 }, + { 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303 }, + { 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9 }, + { 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b }, + { 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04 }, + { 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426 }, + { 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698 }, + { 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7 }, + { 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726 }, + { 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a }, + { 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92 }, + { 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293 }, + { 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325 }, + { 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0 }, + { 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2 }, + { 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d }, + { 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23 }, + { 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed }, + { 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63 }, + { 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379 }, + { 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d }, + { 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13 }, + { 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332 }, + { 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa }, + { 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c }, + { 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35 }, + { 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502 }, + { 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a }, + { 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3 }, + { 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3 }, + { 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd }, + { 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e }, + { 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a }, + { 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24 }, + { 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf }, + { 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51 }, + { 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3 }, + { 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c }, + { 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd }, + { 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55 }, + { 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f }, + { 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c, 0xcd559f37 }, + { 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd, 0x559f37af }, + { 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55, 0x9f37af94 }, }; -DECLSPEC u32 GETSHIFTEDINT_CONST (CONSTANT_AS u32a *a, const int n) -{ - const int d = n / 4; - const int m = n & 3; - - u64 tmp = hl32_to_64_S (a[d + 0], a[d + 1]); - - tmp <<= m * 8; - - return h32_from_64_S (tmp); -} - DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) { const int d = n / 4; @@ -52,7 +112,7 @@ DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) a[d + 1] = l32_from_64_S (tmp); } -DECLSPEC void m07800m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +DECLSPEC void m07800m (SHM_TYPE u32a (*s_theMagicArray)[16], u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) { /** * modifier @@ -165,33 +225,33 @@ DECLSPEC void m07800m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -201,47 +261,59 @@ DECLSPEC void m07800m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = w0[0]; - final[ 1] = w0[1]; - final[ 2] = w0[2]; - final[ 3] = w0[3]; - final[ 4] = w1[0]; - final[ 5] = w1[1]; - final[ 6] = w1[2]; - final[ 7] = w1[3]; - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] @@ -252,23 +324,27 @@ DECLSPEC void m07800m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_M_SIMD (digest[3], digest[4], digest[2], digest[1]); } } -DECLSPEC void m07800s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +DECLSPEC void m07800s (SHM_TYPE u32a (*s_theMagicArray)[16], u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) { /** * modifier @@ -393,33 +469,33 @@ DECLSPEC void m07800s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -429,47 +505,59 @@ DECLSPEC void m07800s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = w0[0]; - final[ 1] = w0[1]; - final[ 2] = w0[2]; - final[ 3] = w0[3]; - final[ 4] = w1[0]; - final[ 5] = w1[1]; - final[ 6] = w1[2]; - final[ 7] = w1[3]; - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] @@ -480,17 +568,21 @@ DECLSPEC void m07800s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_S_SIMD (digest[3], digest[4], digest[2], digest[1]); } @@ -498,11 +590,45 @@ DECLSPEC void m07800s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -510,8 +636,6 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -546,16 +670,50 @@ KERNEL_FQ void m07800_m04 (KERN_ATTR_BASIC ()) * main */ - m07800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07800m (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07800_m08 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -563,8 +721,6 @@ KERNEL_FQ void m07800_m08 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -599,7 +755,7 @@ KERNEL_FQ void m07800_m08 (KERN_ATTR_BASIC ()) * main */ - m07800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07800m (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07800_m16 (KERN_ATTR_BASIC ()) @@ -608,11 +764,45 @@ KERNEL_FQ void m07800_m16 (KERN_ATTR_BASIC ()) KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -620,8 +810,6 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -656,16 +844,50 @@ KERNEL_FQ void m07800_s04 (KERN_ATTR_BASIC ()) * main */ - m07800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07800s (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07800_s08 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -673,8 +895,6 @@ KERNEL_FQ void m07800_s08 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -709,7 +929,7 @@ KERNEL_FQ void m07800_s08 (KERN_ATTR_BASIC ()) * main */ - m07800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07800s (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07800_s16 (KERN_ATTR_BASIC ()) diff --git a/OpenCL/m07801_a0-optimized.cl b/OpenCL/m07801_a0-optimized.cl index aeb9b95d0..ba695ee76 100644 --- a/OpenCL/m07801_a0-optimized.cl +++ b/OpenCL/m07801_a0-optimized.cl @@ -17,30 +17,90 @@ #include "inc_hash_sha1.cl" #endif -CONSTANT_VK u32a theMagicArray[64] = +CONSTANT_VK u32a theMagicArray[80][16] = { - 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, - 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, - 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, - 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, - 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f, 0x37af944c, 0x29085282, 0xb23b4e37, 0x9f170791, 0x113bfdcd, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + { 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194 }, + { 0xac51149f, 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f }, + { 0x51149f67, 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b }, + { 0x149f6754, 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1 }, + { 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b }, + { 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06 }, + { 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605 }, + { 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d }, + { 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03 }, + { 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d }, + { 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e }, + { 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13 }, + { 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a }, + { 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e }, + { 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a }, + { 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a }, + { 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8 }, + { 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9 }, + { 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c }, + { 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14 }, + { 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417 }, + { 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758 }, + { 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7 }, + { 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a }, + { 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6 }, + { 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1 }, + { 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199 }, + { 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963 }, + { 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a }, + { 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7 }, + { 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd }, + { 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70 }, + { 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3 }, + { 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6 }, + { 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e }, + { 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74 }, + { 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413 }, + { 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303 }, + { 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9 }, + { 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b }, + { 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04 }, + { 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426 }, + { 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698 }, + { 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7 }, + { 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726 }, + { 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a }, + { 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92 }, + { 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293 }, + { 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325 }, + { 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0 }, + { 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2 }, + { 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d }, + { 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23 }, + { 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed }, + { 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63 }, + { 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379 }, + { 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d }, + { 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13 }, + { 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332 }, + { 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa }, + { 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c }, + { 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35 }, + { 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502 }, + { 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a }, + { 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3 }, + { 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3 }, + { 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd }, + { 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e }, + { 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a }, + { 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24 }, + { 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf }, + { 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51 }, + { 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3 }, + { 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c }, + { 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd }, + { 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55 }, + { 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f }, + { 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c, 0xcd559f37 }, + { 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd, 0x559f37af }, + { 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55, 0x9f37af94 }, }; -DECLSPEC u32 GETSHIFTEDINT_CONST (CONSTANT_AS u32a *a, const int n) -{ - const int d = n / 4; - const int m = n & 3; - - u64 tmp = hl32_to_64_S (a[d + 0], a[d + 1]); - - tmp <<= m * 8; - - return h32_from_64_S (tmp); -} - DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) { const int d = n / 4; @@ -56,20 +116,52 @@ DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif + + if (gid >= gid_max) return; + /** * modifier */ - const u64 lid = get_local_id (0); - - /** - * base - */ - - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - u32 pw_buf0[4]; u32 pw_buf1[4]; @@ -90,14 +182,14 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -114,6 +206,15 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + /** * SAP */ @@ -140,7 +241,7 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, out_len); const u32x pw_salt_len = out_len + salt_len; @@ -150,20 +251,20 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -191,33 +292,33 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -227,49 +328,61 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, out_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = out_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -278,17 +391,21 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_RULES ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_M_SIMD (0, 0, digest[2] & 0xffff0000, digest[1]); } @@ -304,20 +421,52 @@ KERNEL_FQ void m07801_m16 (KERN_ATTR_RULES ()) KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif + + if (gid >= gid_max) return; + /** * modifier */ - const u64 lid = get_local_id (0); - - /** - * base - */ - - const u64 gid = get_global_id (0); - - if (gid >= gid_max) return; - u32 pw_buf0[4]; u32 pw_buf1[4]; @@ -338,14 +487,14 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -374,6 +523,15 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + /** * SAP */ @@ -400,7 +558,7 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, out_len); const u32x pw_salt_len = out_len + salt_len; @@ -410,20 +568,20 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -451,33 +609,33 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -487,49 +645,61 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, out_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = out_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -538,17 +708,21 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_RULES ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_S_SIMD (0, 0, digest[2] & 0xffff0000, digest[1]); } diff --git a/OpenCL/m07801_a1-optimized.cl b/OpenCL/m07801_a1-optimized.cl index 8d055619c..96c5a9e73 100644 --- a/OpenCL/m07801_a1-optimized.cl +++ b/OpenCL/m07801_a1-optimized.cl @@ -15,30 +15,90 @@ #include "inc_hash_sha1.cl" #endif -CONSTANT_VK u32a theMagicArray[64] = +CONSTANT_VK u32a theMagicArray[80][16] = { - 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, - 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, - 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, - 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, - 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f, 0x37af944c, 0x29085282, 0xb23b4e37, 0x9f170791, 0x113bfdcd, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + { 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194 }, + { 0xac51149f, 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f }, + { 0x51149f67, 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b }, + { 0x149f6754, 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1 }, + { 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b }, + { 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06 }, + { 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605 }, + { 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d }, + { 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03 }, + { 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d }, + { 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e }, + { 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13 }, + { 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a }, + { 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e }, + { 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a }, + { 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a }, + { 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8 }, + { 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9 }, + { 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c }, + { 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14 }, + { 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417 }, + { 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758 }, + { 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7 }, + { 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a }, + { 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6 }, + { 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1 }, + { 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199 }, + { 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963 }, + { 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a }, + { 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7 }, + { 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd }, + { 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70 }, + { 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3 }, + { 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6 }, + { 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e }, + { 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74 }, + { 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413 }, + { 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303 }, + { 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9 }, + { 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b }, + { 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04 }, + { 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426 }, + { 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698 }, + { 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7 }, + { 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726 }, + { 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a }, + { 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92 }, + { 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293 }, + { 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325 }, + { 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0 }, + { 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2 }, + { 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d }, + { 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23 }, + { 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed }, + { 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63 }, + { 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379 }, + { 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d }, + { 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13 }, + { 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332 }, + { 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa }, + { 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c }, + { 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35 }, + { 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502 }, + { 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a }, + { 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3 }, + { 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3 }, + { 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd }, + { 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e }, + { 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a }, + { 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24 }, + { 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf }, + { 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51 }, + { 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3 }, + { 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c }, + { 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd }, + { 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55 }, + { 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f }, + { 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c, 0xcd559f37 }, + { 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd, 0x559f37af }, + { 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55, 0x9f37af94 }, }; -DECLSPEC u32 GETSHIFTEDINT_CONST (CONSTANT_AS u32a *a, const int n) -{ - const int d = n / 4; - const int m = n & 3; - - u64 tmp = hl32_to_64_S (a[d + 0], a[d + 1]); - - tmp <<= m * 8; - - return h32_from_64_S (tmp); -} - DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) { const int d = n / 4; @@ -54,17 +114,45 @@ DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) { - /** - * modifier - */ - - const u64 lid = get_local_id (0); - - /** - * base - */ - const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -88,14 +176,14 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -172,6 +260,23 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) w3[2] = wordl3[2] | wordr3[2]; w3[3] = wordl3[3] | wordr3[3]; + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + /** * SAP */ @@ -198,7 +303,7 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, pw_len); const u32x pw_salt_len = pw_len + salt_len; @@ -208,20 +313,20 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -249,33 +354,33 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -285,49 +390,61 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = hc_swap32_S (w2[0]); - final[ 9] = hc_swap32_S (w2[1]); - final[10] = hc_swap32_S (w2[2]); - final[11] = hc_swap32_S (w2[3]); - final[12] = hc_swap32_S (w3[0]); - final[13] = hc_swap32_S (w3[1]); - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -336,17 +453,21 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_M_SIMD (0, 0, digest[2] & 0xffff0000, digest[1]); } @@ -362,17 +483,45 @@ KERNEL_FQ void m07801_m16 (KERN_ATTR_BASIC ()) KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) { - /** - * modifier - */ - - const u64 lid = get_local_id (0); - - /** - * base - */ - const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -396,14 +545,14 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) u32 salt_buf[8]; - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - salt_buf[2] = salt_bufs[salt_pos].salt_buf[2]; - salt_buf[3] = salt_bufs[salt_pos].salt_buf[3]; - salt_buf[4] = salt_bufs[salt_pos].salt_buf[4]; - salt_buf[5] = salt_bufs[salt_pos].salt_buf[5]; - salt_buf[6] = salt_bufs[salt_pos].salt_buf[6]; - salt_buf[7] = salt_bufs[salt_pos].salt_buf[7]; + salt_buf[0] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[0]); + salt_buf[1] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[1]); + salt_buf[2] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[2]); + salt_buf[3] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[3]); + salt_buf[4] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[4]); + salt_buf[5] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[5]); + salt_buf[6] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[6]); + salt_buf[7] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[7]); const u32 salt_len = salt_bufs[salt_pos].salt_len; @@ -492,6 +641,23 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) w3[2] = wordl3[2] | wordr3[2]; w3[3] = wordl3[3] | wordr3[3]; + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = hc_swap32_S (w3[2]); + w3[3] = hc_swap32_S (w3[3]); + /** * SAP */ @@ -518,7 +684,7 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) s3[2] = 0; s3[3] = 0; - switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + switch_buffer_by_offset_be_S (s0, s1, s2, s3, pw_len); const u32x pw_salt_len = pw_len + salt_len; @@ -528,20 +694,20 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) u32 final[32]; - final[ 0] = hc_swap32_S (w0[0] | s0[0]); - final[ 1] = hc_swap32_S (w0[1] | s0[1]); - final[ 2] = hc_swap32_S (w0[2] | s0[2]); - final[ 3] = hc_swap32_S (w0[3] | s0[3]); - final[ 4] = hc_swap32_S (w1[0] | s1[0]); - final[ 5] = hc_swap32_S (w1[1] | s1[1]); - final[ 6] = hc_swap32_S (w1[2] | s1[2]); - final[ 7] = hc_swap32_S (w1[3] | s1[3]); - final[ 8] = hc_swap32_S (w2[0] | s2[0]); - final[ 9] = hc_swap32_S (w2[1] | s2[1]); - final[10] = hc_swap32_S (w2[2] | s2[2]); - final[11] = hc_swap32_S (w2[3] | s2[3]); - final[12] = hc_swap32_S (w3[0] | s3[0]); - final[13] = hc_swap32_S (w3[1] | s3[1]); + final[ 0] = w0[0] | s0[0]; + final[ 1] = w0[1] | s0[1]; + final[ 2] = w0[2] | s0[2]; + final[ 3] = w0[3] | s0[3]; + final[ 4] = w1[0] | s1[0]; + final[ 5] = w1[1] | s1[1]; + final[ 6] = w1[2] | s1[2]; + final[ 7] = w1[3] | s1[3]; + final[ 8] = w2[0] | s2[0]; + final[ 9] = w2[1] | s2[1]; + final[10] = w2[2] | s2[2]; + final[11] = w2[3] | s2[3]; + final[12] = w3[0] | s3[0]; + final[13] = w3[1] | s3[1]; final[14] = 0; final[15] = pw_salt_len * 8; final[16] = 0; @@ -569,33 +735,33 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -605,49 +771,61 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = hc_swap32_S (w0[0]); - final[ 1] = hc_swap32_S (w0[1]); - final[ 2] = hc_swap32_S (w0[2]); - final[ 3] = hc_swap32_S (w0[3]); - final[ 4] = hc_swap32_S (w1[0]); - final[ 5] = hc_swap32_S (w1[1]); - final[ 6] = hc_swap32_S (w1[2]); - final[ 7] = hc_swap32_S (w1[3]); - final[ 8] = hc_swap32_S (w2[0]); - final[ 9] = hc_swap32_S (w2[1]); - final[10] = hc_swap32_S (w2[2]); - final[11] = hc_swap32_S (w2[3]); - final[12] = hc_swap32_S (w3[0]); - final[13] = hc_swap32_S (w3[1]); - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { - const u32 tmp = hc_swap32_S (salt_buf[i / 4]); // attention, int[] not char[] + const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] SETSHIFTEDINT (final, final_len + i, tmp); } @@ -656,17 +834,21 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_S_SIMD (0, 0, digest[2] & 0xffff0000, digest[1]); } diff --git a/OpenCL/m07801_a3-optimized.cl b/OpenCL/m07801_a3-optimized.cl index 7de9f2a11..7c3d987f6 100644 --- a/OpenCL/m07801_a3-optimized.cl +++ b/OpenCL/m07801_a3-optimized.cl @@ -15,30 +15,90 @@ #include "inc_hash_sha1.cl" #endif -CONSTANT_VK u32a theMagicArray[64] = +CONSTANT_VK u32a theMagicArray[80][16] = { - 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, - 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, - 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, - 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, - 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f, 0x37af944c, 0x29085282, 0xb23b4e37, 0x9f170791, 0x113bfdcd, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + { 0x91ac5114, 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194 }, + { 0xac51149f, 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f }, + { 0x51149f67, 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b }, + { 0x149f6754, 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1 }, + { 0x9f675443, 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b }, + { 0x67544324, 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06 }, + { 0x544324e7, 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605 }, + { 0x4324e73b, 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d }, + { 0x24e73be0, 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03 }, + { 0xe73be028, 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d }, + { 0x3be02874, 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e }, + { 0xe028747b, 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13 }, + { 0x28747bc2, 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a }, + { 0x747bc286, 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e }, + { 0x7bc28633, 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a }, + { 0xc2863313, 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a }, + { 0x863313eb, 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8 }, + { 0x3313eb5a, 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9 }, + { 0x13eb5a4f, 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c }, + { 0xeb5a4fcb, 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14 }, + { 0x5a4fcb5c, 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417 }, + { 0x4fcb5c08, 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758 }, + { 0xcb5c080a, 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7 }, + { 0x5c080a73, 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a }, + { 0x080a7337, 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6 }, + { 0x0a73370e, 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1 }, + { 0x73370e5d, 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199 }, + { 0x370e5d1c, 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963 }, + { 0x0e5d1c2f, 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a }, + { 0x5d1c2f33, 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7 }, + { 0x1c2f338f, 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd }, + { 0x2f338fe6, 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70 }, + { 0x338fe6e5, 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3 }, + { 0x8fe6e5f8, 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6 }, + { 0xe6e5f89b, 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e }, + { 0xe5f89bae, 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74 }, + { 0xf89baedd, 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413 }, + { 0x9baedd16, 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303 }, + { 0xaedd16f2, 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9 }, + { 0xdd16f24b, 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b }, + { 0x16f24b8d, 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04 }, + { 0xf24b8d2c, 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426 }, + { 0x4b8d2ce1, 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698 }, + { 0x8d2ce1d4, 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7 }, + { 0x2ce1d4dc, 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726 }, + { 0xe1d4dcb0, 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a }, + { 0xd4dcb0cb, 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92 }, + { 0xdcb0cbdf, 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293 }, + { 0xb0cbdf9d, 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325 }, + { 0xcbdf9dd4, 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0 }, + { 0xdf9dd470, 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2 }, + { 0x9dd4706d, 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d }, + { 0xd4706d17, 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23 }, + { 0x706d17f9, 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed }, + { 0x6d17f94d, 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63 }, + { 0x17f94d42, 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379 }, + { 0xf94d423f, 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d }, + { 0x4d423f9b, 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13 }, + { 0x423f9b1b, 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332 }, + { 0x3f9b1b11, 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa }, + { 0x9b1b1194, 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c }, + { 0x1b11949f, 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35 }, + { 0x11949f5b, 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502 }, + { 0x949f5bc1, 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a }, + { 0x9f5bc19b, 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3 }, + { 0x5bc19b06, 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3 }, + { 0xc19b0605, 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd }, + { 0x9b06059d, 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e }, + { 0x06059d03, 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a }, + { 0x059d039d, 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24 }, + { 0x9d039d5e, 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf }, + { 0x039d5e13, 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51 }, + { 0x9d5e138a, 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3 }, + { 0x5e138a1e, 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c }, + { 0x138a1e9a, 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd }, + { 0x8a1e9a6a, 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55 }, + { 0x1e9a6ae8, 0xd97c1417, 0x58c72af6, 0xa199630a, 0xd7fd70c3, 0xf65e7413, 0x03c90b04, 0x2698f726, 0x8a929325, 0xb0a20d23, 0xed63796d, 0x1332fa3c, 0x35029aa3, 0xb3dd8e0a, 0x24bf51c3, 0x7ccd559f }, + { 0x9a6ae8d9, 0x7c141758, 0xc72af6a1, 0x99630ad7, 0xfd70c3f6, 0x5e741303, 0xc90b0426, 0x98f7268a, 0x929325b0, 0xa20d23ed, 0x63796d13, 0x32fa3c35, 0x029aa3b3, 0xdd8e0a24, 0xbf51c37c, 0xcd559f37 }, + { 0x6ae8d97c, 0x141758c7, 0x2af6a199, 0x630ad7fd, 0x70c3f65e, 0x741303c9, 0x0b042698, 0xf7268a92, 0x9325b0a2, 0x0d23ed63, 0x796d1332, 0xfa3c3502, 0x9aa3b3dd, 0x8e0a24bf, 0x51c37ccd, 0x559f37af }, + { 0xe8d97c14, 0x1758c72a, 0xf6a19963, 0x0ad7fd70, 0xc3f65e74, 0x1303c90b, 0x042698f7, 0x268a9293, 0x25b0a20d, 0x23ed6379, 0x6d1332fa, 0x3c35029a, 0xa3b3dd8e, 0x0a24bf51, 0xc37ccd55, 0x9f37af94 }, }; -DECLSPEC u32 GETSHIFTEDINT_CONST (CONSTANT_AS u32a *a, const int n) -{ - const int d = n / 4; - const int m = n & 3; - - u64 tmp = hl32_to_64_S (a[d + 0], a[d + 1]); - - tmp <<= m * 8; - - return h32_from_64_S (tmp); -} - DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) { const int d = n / 4; @@ -52,7 +112,7 @@ DECLSPEC void SETSHIFTEDINT (u32 *a, const int n, const u32 v) a[d + 1] = l32_from_64_S (tmp); } -DECLSPEC void m07801m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +DECLSPEC void m07801m (SHM_TYPE u32a (*s_theMagicArray)[16], u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) { /** * modifier @@ -165,33 +225,33 @@ DECLSPEC void m07801m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -201,47 +261,59 @@ DECLSPEC void m07801m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = w0[0]; - final[ 1] = w0[1]; - final[ 2] = w0[2]; - final[ 3] = w0[3]; - final[ 4] = w1[0]; - final[ 5] = w1[1]; - final[ 6] = w1[2]; - final[ 7] = w1[3]; - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] @@ -252,23 +324,27 @@ DECLSPEC void m07801m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_M_SIMD (0, 0, digest[2] & 0xffff0000, digest[1]); } } -DECLSPEC void m07801s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +DECLSPEC void m07801s (SHM_TYPE u32a (*s_theMagicArray)[16], u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) { /** * modifier @@ -393,33 +469,33 @@ DECLSPEC void m07801s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform (&final[0], &final[4], &final[8], &final[12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); // prepare magic array range u32 lengthMagicArray = 0x20; u32 offsetMagicArray = 0; - lengthMagicArray += ((digest[0] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[0] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 16) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 8) & 0xff) % 6; - lengthMagicArray += ((digest[1] >> 0) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 24) & 0xff) % 6; - lengthMagicArray += ((digest[2] >> 16) & 0xff) % 6; - offsetMagicArray += ((digest[2] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[2] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[3] >> 0) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 24) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 16) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 8) & 0xff) % 8; - offsetMagicArray += ((digest[4] >> 0) & 0xff) % 8; + lengthMagicArray += unpack_v8d_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[0]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8b_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8a_from_v32_S (digest[1]) % 6; + lengthMagicArray += unpack_v8d_from_v32_S (digest[2]) % 6; + lengthMagicArray += unpack_v8c_from_v32_S (digest[2]) % 6; + offsetMagicArray += unpack_v8b_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[2]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[3]) & 7; + offsetMagicArray += unpack_v8d_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8c_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8b_from_v32_S (digest[4]) & 7; + offsetMagicArray += unpack_v8a_from_v32_S (digest[4]) & 7; // final @@ -429,47 +505,59 @@ DECLSPEC void m07801s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER digest[3] = SHA1M_D; digest[4] = SHA1M_E; - final[ 0] = w0[0]; - final[ 1] = w0[1]; - final[ 2] = w0[2]; - final[ 3] = w0[3]; - final[ 4] = w1[0]; - final[ 5] = w1[1]; - final[ 6] = w1[2]; - final[ 7] = w1[3]; - final[ 8] = 0; - final[ 9] = 0; - final[10] = 0; - final[11] = 0; - final[12] = 0; - final[13] = 0; - final[14] = 0; - final[15] = 0; - - u32 final_len = pw_len; - - u32 i; - // append MagicArray - for (i = 0; i < lengthMagicArray - 4; i += 4) - { - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i); + final[ 0] = s_theMagicArray[offsetMagicArray][ 0]; + final[ 1] = s_theMagicArray[offsetMagicArray][ 1]; + final[ 2] = s_theMagicArray[offsetMagicArray][ 2]; + final[ 3] = s_theMagicArray[offsetMagicArray][ 3]; + final[ 4] = s_theMagicArray[offsetMagicArray][ 4]; + final[ 5] = s_theMagicArray[offsetMagicArray][ 5]; + final[ 6] = s_theMagicArray[offsetMagicArray][ 6]; + final[ 7] = s_theMagicArray[offsetMagicArray][ 7]; + final[ 8] = s_theMagicArray[offsetMagicArray][ 8]; + final[ 9] = s_theMagicArray[offsetMagicArray][ 9]; + final[10] = s_theMagicArray[offsetMagicArray][10]; + final[11] = s_theMagicArray[offsetMagicArray][11]; + final[12] = s_theMagicArray[offsetMagicArray][12]; + final[13] = s_theMagicArray[offsetMagicArray][13]; + final[14] = s_theMagicArray[offsetMagicArray][14]; + final[15] = s_theMagicArray[offsetMagicArray][15]; + final[16] = 0; + final[17] = 0; + final[18] = 0; + final[19] = 0; + final[20] = 0; + final[21] = 0; + final[22] = 0; + final[23] = 0; + final[24] = 0; + final[25] = 0; + final[26] = 0; + final[27] = 0; + final[28] = 0; + final[29] = 0; + final[30] = 0; + final[31] = 0; - SETSHIFTEDINT (final, final_len + i, tmp); - } + truncate_block_16x4_be_S (final + 0, final + 4, final + 8, final + 12, lengthMagicArray); - const u32 mask = 0xffffffff << (((4 - (lengthMagicArray - i)) & 3) * 8); + switch_buffer_by_offset_8x4_be_S (final + 0, final + 4, final + 8, final + 12, final + 16, final + 20, final + 24, final + 28, pw_len); - const u32 tmp = GETSHIFTEDINT_CONST (theMagicArray, offsetMagicArray + i) & mask; + final[0] |= w0[0]; + final[1] |= w0[1]; + final[2] |= w0[2]; + final[3] |= w0[3]; + final[4] |= w1[0]; + final[5] |= w1[1]; + final[6] |= w1[2]; + final[7] |= w1[3]; - SETSHIFTEDINT (final, final_len + i, tmp); - - final_len += lengthMagicArray; + u32 final_len = pw_len + lengthMagicArray; // append Salt - for (i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 + for (int i = 0; i < salt_len + 1; i += 4) // +1 for the 0x80 { const u32 tmp = salt_buf[i / 4]; // attention, int[] not char[] @@ -480,17 +568,21 @@ DECLSPEC void m07801s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER // calculate - int left; - int off; - - for (left = final_len, off = 0; left >= 56; left -= 64, off += 16) + if (final_len >= 56) { - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + final[30] = 0; + final[31] = final_len * 8; + + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + sha1_transform (final + 16, final + 20, final + 24, final + 28, digest); } + else + { + final[14] = 0; + final[15] = final_len * 8; - final[off + 15] = final_len * 8; - - sha1_transform (&final[off + 0], &final[off + 4], &final[off + 8], &final[off + 12], digest); + sha1_transform (final + 0, final + 4, final + 8, final + 12, digest); + } COMPARE_S_SIMD (0, 0, digest[2] & 0xffff0000, digest[1]); } @@ -498,11 +590,45 @@ DECLSPEC void m07801s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -510,8 +636,6 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -546,16 +670,50 @@ KERNEL_FQ void m07801_m04 (KERN_ATTR_BASIC ()) * main */ - m07801m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07801m (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07801_m08 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -563,8 +721,6 @@ KERNEL_FQ void m07801_m08 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -599,7 +755,7 @@ KERNEL_FQ void m07801_m08 (KERN_ATTR_BASIC ()) * main */ - m07801m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07801m (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07801_m16 (KERN_ATTR_BASIC ()) @@ -608,11 +764,45 @@ KERNEL_FQ void m07801_m16 (KERN_ATTR_BASIC ()) KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -620,8 +810,6 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -656,16 +844,50 @@ KERNEL_FQ void m07801_s04 (KERN_ATTR_BASIC ()) * main */ - m07801s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07801s (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07801_s08 (KERN_ATTR_BASIC ()) { + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + /** - * base + * aes shared */ - const u64 gid = get_global_id (0); + #ifdef REAL_SHM + + LOCAL_VK u32 s_theMagicArray[80][16]; + + for (u32 i = lid; i < 80; i += lsz) + { + s_theMagicArray[i][ 0] = theMagicArray[i][ 0]; + s_theMagicArray[i][ 1] = theMagicArray[i][ 1]; + s_theMagicArray[i][ 2] = theMagicArray[i][ 2]; + s_theMagicArray[i][ 3] = theMagicArray[i][ 3]; + s_theMagicArray[i][ 4] = theMagicArray[i][ 4]; + s_theMagicArray[i][ 5] = theMagicArray[i][ 5]; + s_theMagicArray[i][ 6] = theMagicArray[i][ 6]; + s_theMagicArray[i][ 7] = theMagicArray[i][ 7]; + s_theMagicArray[i][ 8] = theMagicArray[i][ 8]; + s_theMagicArray[i][ 9] = theMagicArray[i][ 9]; + s_theMagicArray[i][10] = theMagicArray[i][10]; + s_theMagicArray[i][11] = theMagicArray[i][11]; + s_theMagicArray[i][12] = theMagicArray[i][12]; + s_theMagicArray[i][13] = theMagicArray[i][13]; + s_theMagicArray[i][14] = theMagicArray[i][14]; + s_theMagicArray[i][15] = theMagicArray[i][15]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_theMagicArray)[16] = theMagicArray; + + #endif if (gid >= gid_max) return; @@ -673,8 +895,6 @@ KERNEL_FQ void m07801_s08 (KERN_ATTR_BASIC ()) * modifier */ - //const u64 lid = get_local_id (0); - u32 w0[4]; w0[0] = pws[gid].i[ 0]; @@ -709,7 +929,7 @@ KERNEL_FQ void m07801_s08 (KERN_ATTR_BASIC ()) * main */ - m07801s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + m07801s (s_theMagicArray, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m07801_s16 (KERN_ATTR_BASIC ()) diff --git a/OpenCL/m07900-pure.cl b/OpenCL/m07900-pure.cl index 32b381d33..0d33a1644 100644 --- a/OpenCL/m07900-pure.cl +++ b/OpenCL/m07900-pure.cl @@ -66,18 +66,6 @@ KERNEL_FQ void m07900_loop (KERN_ATTR_TMPS (drupal7_tmp_t)) const u32 pw_len = pws[gid].pw_len; - u32 w[64] = { 0 }; - - for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) - { - w[idx] = pws[gid].i[idx]; - } - - for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) - { - w[idx] = hc_swap32_S (w[idx]); - } - /** * load */ @@ -120,7 +108,7 @@ KERNEL_FQ void m07900_loop (KERN_ATTR_TMPS (drupal7_tmp_t)) sha512_ctx.len = 64; - sha512_update (&sha512_ctx, w, pw_len); + sha512_update_global_swap (&sha512_ctx, pws[gid].i, pw_len); sha512_final (&sha512_ctx); @@ -158,7 +146,7 @@ KERNEL_FQ void m07900_loop (KERN_ATTR_TMPS (drupal7_tmp_t)) sha512_ctx.len = 64; - sha512_update (&sha512_ctx, w, pw_len); + sha512_update_global_swap (&sha512_ctx, pws[gid].i, pw_len); sha512_final (&sha512_ctx); diff --git a/OpenCL/m08600_a0-pure.cl b/OpenCL/m08600_a0-pure.cl index 486362174..1098de8f3 100644 --- a/OpenCL/m08600_a0-pure.cl +++ b/OpenCL/m08600_a0-pure.cl @@ -16,7 +16,9 @@ #include "inc_simd.cl" #endif -CONSTANT_VK u32a lotus_magic_table[256] = +// we just double this buffer so we can safe the & 0xff ;) + +CONSTANT_VK u32a lotus_magic_table[512] = { 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, @@ -50,6 +52,39 @@ CONSTANT_VK u32a lotus_magic_table[256] = 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, + + 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, + 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, + 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, + 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, + 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, + 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, + 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, + 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, + 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, + 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, + 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, + 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, + 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, + 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, + 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, + 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, + 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, + 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, + 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, + 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, + 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, + 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, + 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, + 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, + 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, + 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, + 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, + 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, + 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, + 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, + 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, + 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, }; #if VECT_SIZE == 1 @@ -244,9 +279,9 @@ KERNEL_FQ void m08600_mxx (KERN_ATTR_RULES ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -308,9 +343,9 @@ KERNEL_FQ void m08600_sxx (KERN_ATTR_RULES ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } diff --git a/OpenCL/m08600_a1-pure.cl b/OpenCL/m08600_a1-pure.cl index 1260a50cf..8d92c046f 100644 --- a/OpenCL/m08600_a1-pure.cl +++ b/OpenCL/m08600_a1-pure.cl @@ -14,7 +14,9 @@ #include "inc_simd.cl" #endif -CONSTANT_VK u32a lotus_magic_table[256] = +// we just double this buffer so we can safe the & 0xff ;) + +CONSTANT_VK u32a lotus_magic_table[512] = { 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, @@ -48,6 +50,39 @@ CONSTANT_VK u32a lotus_magic_table[256] = 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, + + 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, + 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, + 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, + 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, + 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, + 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, + 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, + 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, + 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, + 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, + 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, + 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, + 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, + 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, + 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, + 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, + 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, + 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, + 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, + 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, + 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, + 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, + 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, + 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, + 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, + 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, + 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, + 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, + 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, + 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, + 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, + 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, }; #if VECT_SIZE == 1 @@ -242,9 +277,9 @@ KERNEL_FQ void m08600_mxx (KERN_ATTR_BASIC ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -366,9 +401,9 @@ KERNEL_FQ void m08600_sxx (KERN_ATTR_BASIC ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } diff --git a/OpenCL/m08600_a3-pure.cl b/OpenCL/m08600_a3-pure.cl index fc58fcc34..58550b5c1 100644 --- a/OpenCL/m08600_a3-pure.cl +++ b/OpenCL/m08600_a3-pure.cl @@ -13,7 +13,9 @@ #include "inc_simd.cl" #endif -CONSTANT_VK u32a lotus_magic_table[256] = +// we just double this buffer so we can safe the & 0xff ;) + +CONSTANT_VK u32a lotus_magic_table[512] = { 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, @@ -47,6 +49,39 @@ CONSTANT_VK u32a lotus_magic_table[256] = 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, + + 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, + 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, + 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, + 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, + 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, + 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, + 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, + 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, + 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, + 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, + 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, + 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, + 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, + 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, + 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, + 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, + 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, + 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, + 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, + 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, + 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, + 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, + 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, + 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, + 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, + 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, + 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, + 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, + 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, + 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, + 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, + 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, }; #if VECT_SIZE == 1 @@ -347,9 +382,9 @@ KERNEL_FQ void m08600_mxx (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -404,9 +439,9 @@ KERNEL_FQ void m08600_sxx (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } diff --git a/OpenCL/m08700_a0-optimized.cl b/OpenCL/m08700_a0-optimized.cl index 2922cfb39..65d34fdb9 100644 --- a/OpenCL/m08700_a0-optimized.cl +++ b/OpenCL/m08700_a0-optimized.cl @@ -16,7 +16,9 @@ #include "inc_simd.cl" #endif -CONSTANT_VK u32a lotus_magic_table[256] = +// we just double this buffer so we can safe the & 0xff ;) + +CONSTANT_VK u32a lotus_magic_table[512] = { 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, @@ -50,6 +52,39 @@ CONSTANT_VK u32a lotus_magic_table[256] = 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, + + 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, + 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, + 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, + 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, + 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, + 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, + 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, + 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, + 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, + 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, + 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, + 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, + 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, + 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, + 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, + 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, + 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, + 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, + 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, + 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, + 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, + 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, + 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, + 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, + 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, + 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, + 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, + 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, + 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, + 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, + 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, + 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, }; #if VECT_SIZE == 1 @@ -89,17 +124,17 @@ DECLSPEC void lotus_mix (u32x *in, LOCAL_AS u32 *s_lotus_magic_table) u32x tmp_in = in[j]; u32x tmp_out = 0; - p = (p + s--) & 0xff; p = ((tmp_in >> 0) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 0; - p = (p + s--) & 0xff; p = ((tmp_in >> 8) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 8; - p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 16; - p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 24; + p = p + s--; p = ((tmp_in >> 0) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 0; + p = p + s--; p = ((tmp_in >> 8) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 8; + p = p + s--; p = ((tmp_in >> 16) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 16; + p = p + s--; p = ((tmp_in >> 24) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 24; in[j] = tmp_out; } } } -DECLSPEC void lotus_transform_password (u32x *in, u32x *out, LOCAL_AS u32 *s_lotus_magic_table) +DECLSPEC void lotus_transform_password (const u32x *in, u32x *out, LOCAL_AS u32 *s_lotus_magic_table) { u32x t = out[3] >> 24; @@ -281,9 +316,9 @@ KERNEL_FQ void m08700_m04 (KERN_ATTR_RULES ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -468,9 +503,9 @@ KERNEL_FQ void m08700_s04 (KERN_ATTR_RULES ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } diff --git a/OpenCL/m08700_a1-optimized.cl b/OpenCL/m08700_a1-optimized.cl index 02d3873c3..745475445 100644 --- a/OpenCL/m08700_a1-optimized.cl +++ b/OpenCL/m08700_a1-optimized.cl @@ -14,7 +14,9 @@ #include "inc_simd.cl" #endif -CONSTANT_VK u32a lotus_magic_table[256] = +// we just double this buffer so we can safe the & 0xff ;) + +CONSTANT_VK u32a lotus_magic_table[512] = { 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, @@ -48,6 +50,39 @@ CONSTANT_VK u32a lotus_magic_table[256] = 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, + + 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, + 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, + 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, + 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, + 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, + 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, + 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, + 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, + 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, + 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, + 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, + 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, + 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, + 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, + 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, + 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, + 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, + 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, + 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, + 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, + 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, + 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, + 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, + 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, + 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, + 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, + 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, + 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, + 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, + 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, + 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, + 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, }; #if VECT_SIZE == 1 @@ -87,17 +122,17 @@ DECLSPEC void lotus_mix (u32x *in, LOCAL_AS u32 *s_lotus_magic_table) u32x tmp_in = in[j]; u32x tmp_out = 0; - p = (p + s--) & 0xff; p = ((tmp_in >> 0) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 0; - p = (p + s--) & 0xff; p = ((tmp_in >> 8) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 8; - p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 16; - p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 24; + p = p + s--; p = ((tmp_in >> 0) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 0; + p = p + s--; p = ((tmp_in >> 8) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 8; + p = p + s--; p = ((tmp_in >> 16) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 16; + p = p + s--; p = ((tmp_in >> 24) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 24; in[j] = tmp_out; } } } -DECLSPEC void lotus_transform_password (u32x *in, u32x *out, LOCAL_AS u32 *s_lotus_magic_table) +DECLSPEC void lotus_transform_password (const u32x *in, u32x *out, LOCAL_AS u32 *s_lotus_magic_table) { u32x t = out[3] >> 24; @@ -279,9 +314,9 @@ KERNEL_FQ void m08700_m04 (KERN_ATTR_BASIC ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -526,9 +561,9 @@ KERNEL_FQ void m08700_s04 (KERN_ATTR_BASIC ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } diff --git a/OpenCL/m08700_a3-optimized.cl b/OpenCL/m08700_a3-optimized.cl index f15b3722d..2a13fd3d8 100644 --- a/OpenCL/m08700_a3-optimized.cl +++ b/OpenCL/m08700_a3-optimized.cl @@ -13,7 +13,9 @@ #include "inc_simd.cl" #endif -CONSTANT_VK u32a lotus_magic_table[256] = +// we just double this buffer so we can safe the & 0xff ;) + +CONSTANT_VK u32a lotus_magic_table[512] = { 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, @@ -47,6 +49,39 @@ CONSTANT_VK u32a lotus_magic_table[256] = 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, + + 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, + 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, + 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, + 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, + 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, + 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, + 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, + 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, + 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, + 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, + 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, + 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, + 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, + 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, + 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, + 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, + 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, + 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, + 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, + 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, + 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, + 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, + 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, + 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, + 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, + 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, + 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, + 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, + 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, + 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, + 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, + 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab, }; #define BOX(S,i) (S)[(i)] @@ -88,17 +123,17 @@ DECLSPEC void lotus_mix (u32x *in, LOCAL_AS u32 *s_lotus_magic_table) u32x tmp_in = in[j]; u32x tmp_out = 0; - p = (p + s--) & 0xff; p = ((tmp_in >> 0) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 0; - p = (p + s--) & 0xff; p = ((tmp_in >> 8) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 8; - p = (p + s--) & 0xff; p = ((tmp_in >> 16) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 16; - p = (p + s--) & 0xff; p = ((tmp_in >> 24) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 24; + p = p + s--; p = ((tmp_in >> 0) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 0; + p = p + s--; p = ((tmp_in >> 8) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 8; + p = p + s--; p = ((tmp_in >> 16) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 16; + p = p + s--; p = ((tmp_in >> 24) & 0xff) ^ BOX1 (s_lotus_magic_table, p); tmp_out |= p << 24; in[j] = tmp_out; } } } -DECLSPEC void lotus_transform_password (u32x *in, u32x *out, LOCAL_AS u32 *s_lotus_magic_table) +DECLSPEC void lotus_transform_password (const u32x *in, u32x *out, LOCAL_AS u32 *s_lotus_magic_table) { u32x t = out[3] >> 24; @@ -558,9 +593,9 @@ KERNEL_FQ void m08700_m04 (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -626,9 +661,9 @@ KERNEL_FQ void m08700_m08 (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -694,9 +729,9 @@ KERNEL_FQ void m08700_m16 (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -762,9 +797,9 @@ KERNEL_FQ void m08700_s04 (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -830,9 +865,9 @@ KERNEL_FQ void m08700_s08 (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } @@ -898,9 +933,9 @@ KERNEL_FQ void m08700_s16 (KERN_ATTR_VECTOR ()) * sbox */ - LOCAL_VK u32 s_lotus_magic_table[256]; + LOCAL_VK u32 s_lotus_magic_table[512]; - for (u32 i = lid; i < 256; i += lsz) + for (u32 i = lid; i < 512; i += lsz) { s_lotus_magic_table[i] = lotus_magic_table[i]; } diff --git a/OpenCL/m09100-pure.cl b/OpenCL/m09100-pure.cl index 8ccc65020..14ab60f9e 100644 --- a/OpenCL/m09100-pure.cl +++ b/OpenCL/m09100-pure.cl @@ -27,6 +27,42 @@ typedef struct lotus8_tmp } lotus8_tmp_t; +CONSTANT_VK u32a bin2asc[256] = +{ + 0x00003030, 0x00003130, 0x00003230, 0x00003330, 0x00003430, 0x00003530, 0x00003630, 0x00003730, + 0x00003830, 0x00003930, 0x00004130, 0x00004230, 0x00004330, 0x00004430, 0x00004530, 0x00004630, + 0x00003031, 0x00003131, 0x00003231, 0x00003331, 0x00003431, 0x00003531, 0x00003631, 0x00003731, + 0x00003831, 0x00003931, 0x00004131, 0x00004231, 0x00004331, 0x00004431, 0x00004531, 0x00004631, + 0x00003032, 0x00003132, 0x00003232, 0x00003332, 0x00003432, 0x00003532, 0x00003632, 0x00003732, + 0x00003832, 0x00003932, 0x00004132, 0x00004232, 0x00004332, 0x00004432, 0x00004532, 0x00004632, + 0x00003033, 0x00003133, 0x00003233, 0x00003333, 0x00003433, 0x00003533, 0x00003633, 0x00003733, + 0x00003833, 0x00003933, 0x00004133, 0x00004233, 0x00004333, 0x00004433, 0x00004533, 0x00004633, + 0x00003034, 0x00003134, 0x00003234, 0x00003334, 0x00003434, 0x00003534, 0x00003634, 0x00003734, + 0x00003834, 0x00003934, 0x00004134, 0x00004234, 0x00004334, 0x00004434, 0x00004534, 0x00004634, + 0x00003035, 0x00003135, 0x00003235, 0x00003335, 0x00003435, 0x00003535, 0x00003635, 0x00003735, + 0x00003835, 0x00003935, 0x00004135, 0x00004235, 0x00004335, 0x00004435, 0x00004535, 0x00004635, + 0x00003036, 0x00003136, 0x00003236, 0x00003336, 0x00003436, 0x00003536, 0x00003636, 0x00003736, + 0x00003836, 0x00003936, 0x00004136, 0x00004236, 0x00004336, 0x00004436, 0x00004536, 0x00004636, + 0x00003037, 0x00003137, 0x00003237, 0x00003337, 0x00003437, 0x00003537, 0x00003637, 0x00003737, + 0x00003837, 0x00003937, 0x00004137, 0x00004237, 0x00004337, 0x00004437, 0x00004537, 0x00004637, + 0x00003038, 0x00003138, 0x00003238, 0x00003338, 0x00003438, 0x00003538, 0x00003638, 0x00003738, + 0x00003838, 0x00003938, 0x00004138, 0x00004238, 0x00004338, 0x00004438, 0x00004538, 0x00004638, + 0x00003039, 0x00003139, 0x00003239, 0x00003339, 0x00003439, 0x00003539, 0x00003639, 0x00003739, + 0x00003839, 0x00003939, 0x00004139, 0x00004239, 0x00004339, 0x00004439, 0x00004539, 0x00004639, + 0x00003041, 0x00003141, 0x00003241, 0x00003341, 0x00003441, 0x00003541, 0x00003641, 0x00003741, + 0x00003841, 0x00003941, 0x00004141, 0x00004241, 0x00004341, 0x00004441, 0x00004541, 0x00004641, + 0x00003042, 0x00003142, 0x00003242, 0x00003342, 0x00003442, 0x00003542, 0x00003642, 0x00003742, + 0x00003842, 0x00003942, 0x00004142, 0x00004242, 0x00004342, 0x00004442, 0x00004542, 0x00004642, + 0x00003043, 0x00003143, 0x00003243, 0x00003343, 0x00003443, 0x00003543, 0x00003643, 0x00003743, + 0x00003843, 0x00003943, 0x00004143, 0x00004243, 0x00004343, 0x00004443, 0x00004543, 0x00004643, + 0x00003044, 0x00003144, 0x00003244, 0x00003344, 0x00003444, 0x00003544, 0x00003644, 0x00003744, + 0x00003844, 0x00003944, 0x00004144, 0x00004244, 0x00004344, 0x00004444, 0x00004544, 0x00004644, + 0x00003045, 0x00003145, 0x00003245, 0x00003345, 0x00003445, 0x00003545, 0x00003645, 0x00003745, + 0x00003845, 0x00003945, 0x00004145, 0x00004245, 0x00004345, 0x00004445, 0x00004545, 0x00004645, + 0x00003046, 0x00003146, 0x00003246, 0x00003346, 0x00003446, 0x00003546, 0x00003646, 0x00003746, + 0x00003846, 0x00003946, 0x00004146, 0x00004246, 0x00004346, 0x00004446, 0x00004546, 0x00004646, +}; + CONSTANT_VK u32a lotus64_table[64] = { '0', '1', '2', '3', '4', '5', '6', '7', @@ -79,7 +115,7 @@ CONSTANT_VK u32a lotus_magic_table[256] = #define BOX1(S,i) (S)[(i)] -DECLSPEC void lotus_mix (u32 *in, LOCAL_AS const u32 *s_lotus_magic_table) +DECLSPEC void lotus_mix (u32 *in, SHM_TYPE const u32 *s_lotus_magic_table) { u8 p = 0; @@ -102,7 +138,7 @@ DECLSPEC void lotus_mix (u32 *in, LOCAL_AS const u32 *s_lotus_magic_table) } } -DECLSPEC void lotus_transform_password (const u32 *in, u32 *out, LOCAL_AS const u32 *s_lotus_magic_table) +DECLSPEC void lotus_transform_password (const u32 *in, u32 *out, SHM_TYPE const u32 *s_lotus_magic_table) { u8 t = (u8) (out[3] >> 24); @@ -199,7 +235,7 @@ DECLSPEC void pad (u32 *w, const u32 len) } } -DECLSPEC void mdtransform_norecalc (u32 *state, const u32 *block, LOCAL_AS const u32 *s_lotus_magic_table) +DECLSPEC void mdtransform_norecalc (u32 *state, const u32 *block, SHM_TYPE const u32 *s_lotus_magic_table) { u32 x[12]; @@ -224,14 +260,14 @@ DECLSPEC void mdtransform_norecalc (u32 *state, const u32 *block, LOCAL_AS const state[3] = x[3]; } -DECLSPEC void mdtransform (u32 *state, u32 *checksum, const u32 *block, LOCAL_AS const u32 *s_lotus_magic_table) +DECLSPEC void mdtransform (u32 *state, u32 *checksum, const u32 *block, SHM_TYPE const u32 *s_lotus_magic_table) { mdtransform_norecalc (state, block, s_lotus_magic_table); lotus_transform_password (block, checksum, s_lotus_magic_table); } -DECLSPEC void domino_big_md (const u32 *saved_key, const u32 size, u32 *state, LOCAL_AS const u32 *s_lotus_magic_table) +DECLSPEC void domino_big_md (const u32 *saved_key, const u32 size, u32 *state, SHM_TYPE const u32 *s_lotus_magic_table) { u32 checksum[4]; @@ -402,6 +438,8 @@ KERNEL_FQ void m09100_init (KERN_ATTR_TMPS (lotus8_tmp_t)) * sbox */ + #ifdef REAL_SHM + LOCAL_VK u32 s_lotus_magic_table[256]; for (u32 i = lid; i < 256; i += lsz) @@ -413,15 +451,19 @@ KERNEL_FQ void m09100_init (KERN_ATTR_TMPS (lotus8_tmp_t)) for (u32 i = lid; i < 256; i += lsz) { - const u32 i0 = (i >> 0) & 15; - const u32 i1 = (i >> 4) & 15; - - l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 8 - | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 0; + l_bin2asc[i] = bin2asc[i]; } SYNC_THREADS (); + #else + + CONSTANT_AS u32a *s_lotus_magic_table = lotus_magic_table; + + CONSTANT_AS u32a *l_bin2asc = bin2asc; + + #endif + if (gid >= gid_max) return; /** diff --git a/OpenCL/m09500-pure.cl b/OpenCL/m09500-pure.cl index b2ebe70d9..77b1d8e55 100644 --- a/OpenCL/m09500-pure.cl +++ b/OpenCL/m09500-pure.cl @@ -271,12 +271,15 @@ KERNEL_FQ void m09500_comp (KERN_ATTR_TMPS_ESALT (office2010_tmp_t, office2010_t AES128_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + const u32 digest_cur = digests_offset + loop_pos; + u32 data[4]; - data[0] = esalt_bufs[digests_offset].encryptedVerifier[0]; - data[1] = esalt_bufs[digests_offset].encryptedVerifier[1]; - data[2] = esalt_bufs[digests_offset].encryptedVerifier[2]; - data[3] = esalt_bufs[digests_offset].encryptedVerifier[3]; + data[0] = esalt_bufs[digest_cur].encryptedVerifier[0]; + data[1] = esalt_bufs[digest_cur].encryptedVerifier[1]; + data[2] = esalt_bufs[digest_cur].encryptedVerifier[2]; + data[3] = esalt_bufs[digest_cur].encryptedVerifier[3]; + u32 out[4]; diff --git a/OpenCL/m09800_a0-optimized.cl b/OpenCL/m09800_a0-optimized.cl index ffa5c1388..3257c0cbb 100644 --- a/OpenCL/m09800_a0-optimized.cl +++ b/OpenCL/m09800_a0-optimized.cl @@ -17,11 +17,15 @@ #include "inc_hash_sha1.cl" #endif +#define MIN_NULL_BYTES 10 + typedef struct oldoffice34 { u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; @@ -252,21 +256,21 @@ KERNEL_FQ void m09800_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32 digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -279,6 +283,8 @@ KERNEL_FQ void m09800_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; @@ -337,7 +343,93 @@ KERNEL_FQ void m09800_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) rc4_next_16 (rc4_key, 16, j, digest, out); - COMPARE_M_SIMD (out[0], out[1], out[2], out[3]); + // initial compare + + int digest_pos = find_hash (out, digests_cnt, &digests_buf[digests_offset]); + + if (digest_pos == -1) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + const u32 final_hash_pos = digests_offset + digest_pos; + + if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); + } } } @@ -464,21 +556,21 @@ KERNEL_FQ void m09800_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32 digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -491,6 +583,8 @@ KERNEL_FQ void m09800_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; @@ -549,7 +643,92 @@ KERNEL_FQ void m09800_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) rc4_next_16 (rc4_key, 16, j, digest, out); - COMPARE_S_SIMD (out[0], out[1], out[2], out[3]); + // initial compare + + if (out[0] != search[0]) continue; + if (out[1] != search[1]) continue; + if (out[2] != search[2]) continue; + if (out[3] != search[3]) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } } } diff --git a/OpenCL/m09800_a1-optimized.cl b/OpenCL/m09800_a1-optimized.cl index 07bfb15ca..891d7ca67 100644 --- a/OpenCL/m09800_a1-optimized.cl +++ b/OpenCL/m09800_a1-optimized.cl @@ -15,11 +15,15 @@ #include "inc_hash_sha1.cl" #endif +#define MIN_NULL_BYTES 10 + typedef struct oldoffice34 { u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; @@ -300,21 +304,21 @@ KERNEL_FQ void m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32 digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -327,6 +331,8 @@ KERNEL_FQ void m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; @@ -385,7 +391,93 @@ KERNEL_FQ void m09800_m04 (KERN_ATTR_ESALT (oldoffice34_t)) rc4_next_16 (rc4_key, 16, j, digest, out); - COMPARE_M_SIMD (out[0], out[1], out[2], out[3]); + // initial compare + + int digest_pos = find_hash (out, digests_cnt, &digests_buf[digests_offset]); + + if (digest_pos == -1) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + const u32 final_hash_pos = digests_offset + digest_pos; + + if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); + } } } @@ -562,21 +654,21 @@ KERNEL_FQ void m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32 digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -589,6 +681,8 @@ KERNEL_FQ void m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; @@ -647,7 +741,92 @@ KERNEL_FQ void m09800_s04 (KERN_ATTR_ESALT (oldoffice34_t)) rc4_next_16 (rc4_key, 16, j, digest, out); - COMPARE_S_SIMD (out[0], out[1], out[2], out[3]); + // initial compare + + if (out[0] != search[0]) continue; + if (out[1] != search[1]) continue; + if (out[2] != search[2]) continue; + if (out[3] != search[3]) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } } } diff --git a/OpenCL/m09800_a3-optimized.cl b/OpenCL/m09800_a3-optimized.cl index 303b177a8..8315abfdf 100644 --- a/OpenCL/m09800_a3-optimized.cl +++ b/OpenCL/m09800_a3-optimized.cl @@ -12,11 +12,15 @@ #include "inc_hash_sha1.cl" #endif +#define MIN_NULL_BYTES 10 + typedef struct oldoffice34 { u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; @@ -223,21 +227,21 @@ DECLSPEC void m09800m (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u3 w3_t[2] = 0; w3_t[3] = pw_salt_len * 8; - u32 digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform (w0_t, w1_t, w2_t, w3_t, digest); + sha1_transform (w0_t, w1_t, w2_t, w3_t, pass_hash); - w0_t[0] = digest[0]; - w0_t[1] = digest[1]; - w0_t[2] = digest[2]; - w0_t[3] = digest[3]; - w1_t[0] = digest[4]; + w0_t[0] = pass_hash[0]; + w0_t[1] = pass_hash[1]; + w0_t[2] = pass_hash[2]; + w0_t[3] = pass_hash[3]; + w1_t[0] = pass_hash[4]; w1_t[1] = 0; w1_t[2] = 0x80000000; w1_t[3] = 0; @@ -250,6 +254,8 @@ DECLSPEC void m09800m (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u3 w3_t[2] = 0; w3_t[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; @@ -308,7 +314,93 @@ DECLSPEC void m09800m (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u3 rc4_next_16 (rc4_key, 16, j, digest, out); - COMPARE_M_SIMD (out[0], out[1], out[2], out[3]); + // initial compare + + int digest_pos = find_hash (out, digests_cnt, &digests_buf[digests_offset]); + + if (digest_pos == -1) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + const u32 final_hash_pos = digests_offset + digest_pos; + + if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); + } } } @@ -403,21 +495,21 @@ DECLSPEC void m09800s (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u3 w3_t[2] = 0; w3_t[3] = pw_salt_len * 8; - u32 digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform (w0_t, w1_t, w2_t, w3_t, digest); + sha1_transform (w0_t, w1_t, w2_t, w3_t, pass_hash); - w0_t[0] = digest[0]; - w0_t[1] = digest[1]; - w0_t[2] = digest[2]; - w0_t[3] = digest[3]; - w1_t[0] = digest[4]; + w0_t[0] = pass_hash[0]; + w0_t[1] = pass_hash[1]; + w0_t[2] = pass_hash[2]; + w0_t[3] = pass_hash[3]; + w1_t[0] = pass_hash[4]; w1_t[1] = 0; w1_t[2] = 0x80000000; w1_t[3] = 0; @@ -430,6 +522,8 @@ DECLSPEC void m09800s (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u3 w3_t[2] = 0; w3_t[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; @@ -488,7 +582,92 @@ DECLSPEC void m09800s (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u3 rc4_next_16 (rc4_key, 16, j, digest, out); - COMPARE_S_SIMD (out[0], out[1], out[2], out[3]); + // initial compare + + if (out[0] != search[0]) continue; + if (out[1] != search[1]) continue; + if (out[2] != search[2]) continue; + if (out[3] != search[3]) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } } } diff --git a/OpenCL/m09810_a0-optimized.cl b/OpenCL/m09810_a0-optimized.cl index 5db2264a6..3b911251c 100644 --- a/OpenCL/m09810_a0-optimized.cl +++ b/OpenCL/m09810_a0-optimized.cl @@ -22,6 +22,8 @@ typedef struct oldoffice34 u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; diff --git a/OpenCL/m09810_a1-optimized.cl b/OpenCL/m09810_a1-optimized.cl index 69ecab5c3..b488cdf49 100644 --- a/OpenCL/m09810_a1-optimized.cl +++ b/OpenCL/m09810_a1-optimized.cl @@ -20,6 +20,8 @@ typedef struct oldoffice34 u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; diff --git a/OpenCL/m09810_a3-optimized.cl b/OpenCL/m09810_a3-optimized.cl index 495adc734..760dcb932 100644 --- a/OpenCL/m09810_a3-optimized.cl +++ b/OpenCL/m09810_a3-optimized.cl @@ -20,6 +20,8 @@ typedef struct oldoffice34 u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; diff --git a/OpenCL/m09820_a0-optimized.cl b/OpenCL/m09820_a0-optimized.cl index 0e9a95ca6..3f4bfeb2b 100644 --- a/OpenCL/m09820_a0-optimized.cl +++ b/OpenCL/m09820_a0-optimized.cl @@ -3,7 +3,8 @@ * License.....: MIT */ -#define NEW_SIMD_CODE +//too much register pressure +//#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -16,15 +17,142 @@ #include "inc_hash_sha1.cl" #endif +#define MIN_NULL_BYTES 10 + typedef struct oldoffice34 { u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; +typedef struct +{ + u8 S[256]; + + u32 wtf_its_faster; + +} RC4_KEY; + +DECLSPEC void swap (LOCAL_AS RC4_KEY *rc4_key, const u8 i, const u8 j) +{ + u8 tmp; + + tmp = rc4_key->S[i]; + rc4_key->S[i] = rc4_key->S[j]; + rc4_key->S[j] = tmp; +} + +DECLSPEC void rc4_init_16 (LOCAL_AS RC4_KEY *rc4_key, const u32 *data) +{ + u32 v = 0x03020100; + u32 a = 0x04040404; + + LOCAL_AS u32 *ptr = (LOCAL_AS u32 *) rc4_key->S; + + #ifdef _unroll + #pragma unroll + #endif + for (u32 i = 0; i < 64; i++) + { + *ptr++ = v; v += a; + } + + u32 j = 0; + + for (u32 i = 0; i < 16; i++) + { + u32 idx = i * 16; + + u32 v; + + v = data[0]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[1]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[2]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[3]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + } +} + +DECLSPEC u8 rc4_next_16 (LOCAL_AS RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u32 *out) +{ + #ifdef _unroll + #pragma unroll + #endif + for (u32 k = 0; k < 4; k++) + { + u32 xor4 = 0; + + u8 idx; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 0; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 8; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 16; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 24; + + out[k] = in[k] ^ xor4; + } + + return j; +} + KERNEL_FQ void m09820_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) { /** @@ -55,6 +183,14 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; + /** + * shared + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + LOCAL_AS RC4_KEY *rc4_key = &rc4_keys[lid]; + /** * salt */ @@ -107,21 +243,21 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32x digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -134,20 +270,110 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, digest); digest[0] = hc_swap32 (digest[0]); digest[1] = hc_swap32 (digest[1]) & 0xff; digest[2] = 0; digest[3] = 0; - COMPARE_M_SIMD (digest[0], digest[1], digest[2], digest[3]); + // initial compare + + int digest_pos = find_hash (digest, digests_cnt, &digests_buf[digests_offset]); + + if (digest_pos == -1) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + u32 out[4]; + + u32 j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + const u32 final_hash_pos = digests_offset + digest_pos; + + if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); + } } } @@ -189,6 +415,14 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; + /** + * shared + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + LOCAL_AS RC4_KEY *rc4_key = &rc4_keys[lid]; + /** * salt */ @@ -253,21 +487,21 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32x digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -280,20 +514,107 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_RULES_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, digest); digest[0] = hc_swap32 (digest[0]); digest[1] = hc_swap32 (digest[1]) & 0xff; digest[2] = 0; digest[3] = 0; - COMPARE_S_SIMD (digest[0], digest[1], digest[2], digest[3]); + // initial compare + + if (digest[0] != search[0]) continue; + if (digest[1] != search[1]) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + u32 out[4]; + + u32 j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } } } diff --git a/OpenCL/m09820_a1-optimized.cl b/OpenCL/m09820_a1-optimized.cl index 028b3d28f..bedc61bb8 100644 --- a/OpenCL/m09820_a1-optimized.cl +++ b/OpenCL/m09820_a1-optimized.cl @@ -3,7 +3,8 @@ * License.....: MIT */ -#define NEW_SIMD_CODE +//too much register pressure +//#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -14,15 +15,142 @@ #include "inc_hash_sha1.cl" #endif +#define MIN_NULL_BYTES 10 + typedef struct oldoffice34 { u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; +typedef struct +{ + u8 S[256]; + + u32 wtf_its_faster; + +} RC4_KEY; + +DECLSPEC void swap (LOCAL_AS RC4_KEY *rc4_key, const u8 i, const u8 j) +{ + u8 tmp; + + tmp = rc4_key->S[i]; + rc4_key->S[i] = rc4_key->S[j]; + rc4_key->S[j] = tmp; +} + +DECLSPEC void rc4_init_16 (LOCAL_AS RC4_KEY *rc4_key, const u32 *data) +{ + u32 v = 0x03020100; + u32 a = 0x04040404; + + LOCAL_AS u32 *ptr = (LOCAL_AS u32 *) rc4_key->S; + + #ifdef _unroll + #pragma unroll + #endif + for (u32 i = 0; i < 64; i++) + { + *ptr++ = v; v += a; + } + + u32 j = 0; + + for (u32 i = 0; i < 16; i++) + { + u32 idx = i * 16; + + u32 v; + + v = data[0]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[1]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[2]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[3]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + } +} + +DECLSPEC u8 rc4_next_16 (LOCAL_AS RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u32 *out) +{ + #ifdef _unroll + #pragma unroll + #endif + for (u32 k = 0; k < 4; k++) + { + u32 xor4 = 0; + + u8 idx; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 0; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 8; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 16; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 24; + + out[k] = in[k] ^ xor4; + } + + return j; +} + KERNEL_FQ void m09820_m04 (KERN_ATTR_ESALT (oldoffice34_t)) { /** @@ -53,6 +181,14 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_l_len = pws[gid].pw_len & 63; + /** + * shared + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + LOCAL_AS RC4_KEY *rc4_key = &rc4_keys[lid]; + /** * salt */ @@ -155,21 +291,21 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32x digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -182,20 +318,110 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, digest); digest[0] = hc_swap32 (digest[0]); digest[1] = hc_swap32 (digest[1]) & 0xff; digest[2] = 0; digest[3] = 0; - COMPARE_M_SIMD (digest[0], digest[1], digest[2], digest[3]); + // initial compare + + int digest_pos = find_hash (digest, digests_cnt, &digests_buf[digests_offset]); + + if (digest_pos == -1) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + u32 out[4]; + + u32 j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + const u32 final_hash_pos = digests_offset + digest_pos; + + if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); + } } } @@ -237,6 +463,14 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_l_len = pws[gid].pw_len & 63; + /** + * shared + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + LOCAL_AS RC4_KEY *rc4_key = &rc4_keys[lid]; + /** * salt */ @@ -351,21 +585,21 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_ESALT (oldoffice34_t)) w0[1] = salt_buf[1]; w0[0] = salt_buf[0]; - u32x digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, pass_hash); - w0[0] = digest[0]; - w0[1] = digest[1]; - w0[2] = digest[2]; - w0[3] = digest[3]; - w1[0] = digest[4]; + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; w1[1] = 0; w1[2] = 0x80000000; w1[3] = 0; @@ -378,20 +612,107 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_ESALT (oldoffice34_t)) w3[2] = 0; w3[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform_vector (w0, w1, w2, w3, digest); + sha1_transform (w0, w1, w2, w3, digest); digest[0] = hc_swap32 (digest[0]); digest[1] = hc_swap32 (digest[1]) & 0xff; digest[2] = 0; digest[3] = 0; - COMPARE_S_SIMD (digest[0], digest[1], digest[2], digest[3]); + // initial compare + + if (digest[0] != search[0]) continue; + if (digest[1] != search[1]) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + u32 out[4]; + + u32 j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } } } diff --git a/OpenCL/m09820_a3-optimized.cl b/OpenCL/m09820_a3-optimized.cl index cde918d0e..a0c0a568d 100644 --- a/OpenCL/m09820_a3-optimized.cl +++ b/OpenCL/m09820_a3-optimized.cl @@ -3,7 +3,8 @@ * License.....: MIT */ -#define NEW_SIMD_CODE +//too much register pressure +//#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -14,16 +15,143 @@ #include "inc_hash_sha1.cl" #endif +#define MIN_NULL_BYTES 10 + typedef struct oldoffice34 { u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; -DECLSPEC void m09820m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice34_t)) +typedef struct +{ + u8 S[256]; + + u32 wtf_its_faster; + +} RC4_KEY; + +DECLSPEC void swap (LOCAL_AS RC4_KEY *rc4_key, const u8 i, const u8 j) +{ + u8 tmp; + + tmp = rc4_key->S[i]; + rc4_key->S[i] = rc4_key->S[j]; + rc4_key->S[j] = tmp; +} + +DECLSPEC void rc4_init_16 (LOCAL_AS RC4_KEY *rc4_key, const u32 *data) +{ + u32 v = 0x03020100; + u32 a = 0x04040404; + + LOCAL_AS u32 *ptr = (LOCAL_AS u32 *) rc4_key->S; + + #ifdef _unroll + #pragma unroll + #endif + for (u32 i = 0; i < 64; i++) + { + *ptr++ = v; v += a; + } + + u32 j = 0; + + for (u32 i = 0; i < 16; i++) + { + u32 idx = i * 16; + + u32 v; + + v = data[0]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[1]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[2]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + + v = data[3]; + + j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++; + j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++; + } +} + +DECLSPEC u8 rc4_next_16 (LOCAL_AS RC4_KEY *rc4_key, u8 i, u8 j, const u32 *in, u32 *out) +{ + #ifdef _unroll + #pragma unroll + #endif + for (u32 k = 0; k < 4; k++) + { + u32 xor4 = 0; + + u8 idx; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 0; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 8; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 16; + + i += 1; + j += rc4_key->S[i]; + + swap (rc4_key, i, j); + + idx = rc4_key->S[i] + rc4_key->S[j]; + + xor4 |= rc4_key->S[idx] << 24; + + out[k] = in[k] ^ xor4; + } + + return j; +} + +DECLSPEC void m09820m (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice34_t)) { /** * modifier @@ -32,6 +160,12 @@ DECLSPEC void m09820m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + /** + * shared + */ + + LOCAL_AS RC4_KEY *rc4_key = &rc4_keys[lid]; + /** * salt */ @@ -81,21 +215,21 @@ DECLSPEC void m09820m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER w3_t[2] = 0; w3_t[3] = (pw_len + 16) * 8; - u32x digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform_vector (w0_t, w1_t, w2_t, w3_t, digest); + sha1_transform (w0_t, w1_t, w2_t, w3_t, pass_hash); - w0_t[0] = digest[0]; - w0_t[1] = digest[1]; - w0_t[2] = digest[2]; - w0_t[3] = digest[3]; - w1_t[0] = digest[4]; + w0_t[0] = pass_hash[0]; + w0_t[1] = pass_hash[1]; + w0_t[2] = pass_hash[2]; + w0_t[3] = pass_hash[3]; + w1_t[0] = pass_hash[4]; w1_t[1] = 0; w1_t[2] = 0x80000000; w1_t[3] = 0; @@ -108,24 +242,114 @@ DECLSPEC void m09820m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER w3_t[2] = 0; w3_t[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform_vector (w0_t, w1_t, w2_t, w3_t, digest); + sha1_transform (w0_t, w1_t, w2_t, w3_t, digest); digest[0] = hc_swap32 (digest[0]); digest[1] = hc_swap32 (digest[1]) & 0xff; digest[2] = 0; digest[3] = 0; - COMPARE_M_SIMD (digest[0], digest[1], digest[2], digest[3]); + // initial compare + + int digest_pos = find_hash (digest, digests_cnt, &digests_buf[digests_offset]); + + if (digest_pos == -1) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + u32 out[4]; + + u32 j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + const u32 final_hash_pos = digests_offset + digest_pos; + + if (atomic_inc (&hashes_shown[final_hash_pos]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, final_hash_pos, gid, il_pos, 0, 0); + } } } -DECLSPEC void m09820s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice34_t)) +DECLSPEC void m09820s (LOCAL_AS RC4_KEY *rc4_keys, u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_ESALT (oldoffice34_t)) { /** * modifier @@ -134,6 +358,12 @@ DECLSPEC void m09820s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER const u64 gid = get_global_id (0); const u64 lid = get_local_id (0); + /** + * shared + */ + + LOCAL_AS RC4_KEY *rc4_key = &rc4_keys[lid]; + /** * salt */ @@ -195,21 +425,21 @@ DECLSPEC void m09820s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER w3_t[2] = 0; w3_t[3] = (pw_len + 16) * 8; - u32x digest[5]; + u32 pass_hash[5]; - digest[0] = SHA1M_A; - digest[1] = SHA1M_B; - digest[2] = SHA1M_C; - digest[3] = SHA1M_D; - digest[4] = SHA1M_E; + pass_hash[0] = SHA1M_A; + pass_hash[1] = SHA1M_B; + pass_hash[2] = SHA1M_C; + pass_hash[3] = SHA1M_D; + pass_hash[4] = SHA1M_E; - sha1_transform_vector (w0_t, w1_t, w2_t, w3_t, digest); + sha1_transform (w0_t, w1_t, w2_t, w3_t, pass_hash); - w0_t[0] = digest[0]; - w0_t[1] = digest[1]; - w0_t[2] = digest[2]; - w0_t[3] = digest[3]; - w1_t[0] = digest[4]; + w0_t[0] = pass_hash[0]; + w0_t[1] = pass_hash[1]; + w0_t[2] = pass_hash[2]; + w0_t[3] = pass_hash[3]; + w1_t[0] = pass_hash[4]; w1_t[1] = 0; w1_t[2] = 0x80000000; w1_t[3] = 0; @@ -222,20 +452,107 @@ DECLSPEC void m09820s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER w3_t[2] = 0; w3_t[3] = (20 + 4) * 8; + u32 digest[5]; + digest[0] = SHA1M_A; digest[1] = SHA1M_B; digest[2] = SHA1M_C; digest[3] = SHA1M_D; digest[4] = SHA1M_E; - sha1_transform_vector (w0_t, w1_t, w2_t, w3_t, digest); + sha1_transform (w0_t, w1_t, w2_t, w3_t, digest); digest[0] = hc_swap32 (digest[0]); digest[1] = hc_swap32 (digest[1]) & 0xff; digest[2] = 0; digest[3] = 0; - COMPARE_S_SIMD (digest[0], digest[1], digest[2], digest[3]); + // initial compare + + if (digest[0] != search[0]) continue; + if (digest[1] != search[1]) continue; + + if (esalt_bufs[digests_offset].secondBlockLen != 0) + { + w0[0] = pass_hash[0]; + w0[1] = pass_hash[1]; + w0[2] = pass_hash[2]; + w0[3] = pass_hash[3]; + w1[0] = pass_hash[4]; + w1[1] = 0x01000000; + w1[2] = 0x80000000; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (20 + 4) * 8; + + digest[0] = SHA1M_A; + digest[1] = SHA1M_B; + digest[2] = SHA1M_C; + digest[3] = SHA1M_D; + digest[4] = SHA1M_E; + + sha1_transform (w0, w1, w2, w3, digest); + + digest[0] = hc_swap32_S (digest[0]); + digest[1] = hc_swap32_S (digest[1]); + digest[2] = 0; + digest[3] = 0; + + digest[1] &= 0xff; // only 40-bit key + + // second block decrypt: + + rc4_init_16 (rc4_key, digest); + + u32 secondBlockData[4]; + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[0]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[1]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[2]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[3]; + + u32 out[4]; + + u32 j = rc4_next_16 (rc4_key, 0, 0, secondBlockData, out); + + int null_bytes = 0; + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + secondBlockData[0] = esalt_bufs[digests_offset].secondBlockData[4]; + secondBlockData[1] = esalt_bufs[digests_offset].secondBlockData[5]; + secondBlockData[2] = esalt_bufs[digests_offset].secondBlockData[6]; + secondBlockData[3] = esalt_bufs[digests_offset].secondBlockData[7]; + + rc4_next_16 (rc4_key, 16, j, secondBlockData, out); + + for (int k = 0; k < 4; k++) + { + if ((out[k] & 0x000000ff) == 0) null_bytes++; + if ((out[k] & 0x0000ff00) == 0) null_bytes++; + if ((out[k] & 0x00ff0000) == 0) null_bytes++; + if ((out[k] & 0xff000000) == 0) null_bytes++; + } + + if (null_bytes < MIN_NULL_BYTES) continue; + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } } } @@ -279,7 +596,13 @@ KERNEL_FQ void m09820_m04 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; - m09820m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + /** + * main + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + m09820m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m09820_m08 (KERN_ATTR_ESALT (oldoffice34_t)) @@ -322,7 +645,13 @@ KERNEL_FQ void m09820_m08 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; - m09820m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + /** + * main + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + m09820m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m09820_m16 (KERN_ATTR_ESALT (oldoffice34_t)) @@ -365,7 +694,13 @@ KERNEL_FQ void m09820_m16 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; - m09820m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + /** + * main + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + m09820m (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m09820_s04 (KERN_ATTR_ESALT (oldoffice34_t)) @@ -408,7 +743,13 @@ KERNEL_FQ void m09820_s04 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; - m09820s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + /** + * main + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + m09820s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m09820_s08 (KERN_ATTR_ESALT (oldoffice34_t)) @@ -451,7 +792,13 @@ KERNEL_FQ void m09820_s08 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; - m09820s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + /** + * main + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + m09820s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } KERNEL_FQ void m09820_s16 (KERN_ATTR_ESALT (oldoffice34_t)) @@ -494,5 +841,11 @@ KERNEL_FQ void m09820_s16 (KERN_ATTR_ESALT (oldoffice34_t)) const u32 pw_len = pws[gid].pw_len & 63; - m09820s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); + /** + * main + */ + + LOCAL_VK RC4_KEY rc4_keys[64]; + + m09820s (rc4_keys, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); } diff --git a/OpenCL/m10700-pure.cl b/OpenCL/m10700-pure.cl index f43c024cf..7351d5c7a 100644 --- a/OpenCL/m10700-pure.cl +++ b/OpenCL/m10700-pure.cl @@ -257,8 +257,10 @@ DECLSPEC void sha256_final_aes (sha256_ctx_t *ctx, const u32 *aes_ks, u32 *aes_i sha256_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); } -DECLSPEC void sha384_update_aes_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +DECLSPEC u32 sha384_update_aes_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { + u32 ex = 0; + MAYBE_VOLATILE const int pos = ctx->len & 127; ctx->len += len; @@ -355,6 +357,8 @@ DECLSPEC void sha384_update_aes_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w6, ctx->w6, s_te0, s_te1, s_te2, s_te3, s_te4); aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w7, ctx->w7, s_te0, s_te1, s_te2, s_te3, s_te4); + ex = ctx->w7[3] & 0xff; + sha384_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); ctx->w0[0] = c0[0]; @@ -390,6 +394,8 @@ DECLSPEC void sha384_update_aes_128 (sha384_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w ctx->w7[2] = c7[2]; ctx->w7[3] = c7[3]; } + + return ex; } DECLSPEC void sha384_update_aes (sha384_ctx_t *ctx, const u32 *w, const int len, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) @@ -480,14 +486,21 @@ DECLSPEC void sha384_update_aes (sha384_ctx_t *ctx, const u32 *w, const int len, sha384_update_aes_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); } -DECLSPEC void sha384_final_aes (sha384_ctx_t *ctx, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +DECLSPEC u32 sha384_final_aes (sha384_ctx_t *ctx, const u32 ex, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { + u32 ret = ex; + int pos = ctx->len & 127; - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w0, ctx->w0, s_te0, s_te1, s_te2, s_te3, s_te4); - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w1, ctx->w1, s_te0, s_te1, s_te2, s_te3, s_te4); - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w2, ctx->w2, s_te0, s_te1, s_te2, s_te3, s_te4); - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w3, ctx->w3, s_te0, s_te1, s_te2, s_te3, s_te4); + if (pos) + { + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w0, ctx->w0, s_te0, s_te1, s_te2, s_te3, s_te4); + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w1, ctx->w1, s_te0, s_te1, s_te2, s_te3, s_te4); + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w2, ctx->w2, s_te0, s_te1, s_te2, s_te3, s_te4); + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w3, ctx->w3, s_te0, s_te1, s_te2, s_te3, s_te4); + + ret = ctx->w3[3] & 0xff; + } append_0x80_8x4_S (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, pos ^ 3); @@ -533,10 +546,14 @@ DECLSPEC void sha384_final_aes (sha384_ctx_t *ctx, const u32 *aes_ks, u32 *aes_i ctx->w7[3] = ctx->len * 8; sha384_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); + + return ret; } -DECLSPEC void sha512_update_aes_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +DECLSPEC u32 sha512_update_aes_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *w4, u32 *w5, u32 *w6, u32 *w7, const int len, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { + u32 ex = 0; + MAYBE_VOLATILE const int pos = ctx->len & 127; ctx->len += len; @@ -633,6 +650,8 @@ DECLSPEC void sha512_update_aes_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w6, ctx->w6, s_te0, s_te1, s_te2, s_te3, s_te4); aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w7, ctx->w7, s_te0, s_te1, s_te2, s_te3, s_te4); + ex = ctx->w7[3] & 0xff; + sha512_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); ctx->w0[0] = c0[0]; @@ -668,6 +687,8 @@ DECLSPEC void sha512_update_aes_128 (sha512_ctx_t *ctx, u32 *w0, u32 *w1, u32 *w ctx->w7[2] = c7[2]; ctx->w7[3] = c7[3]; } + + return ex; } DECLSPEC void sha512_update_aes (sha512_ctx_t *ctx, const u32 *w, const int len, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) @@ -758,14 +779,21 @@ DECLSPEC void sha512_update_aes (sha512_ctx_t *ctx, const u32 *w, const int len, sha512_update_aes_128 (ctx, w0, w1, w2, w3, w4, w5, w6, w7, len - pos1, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); } -DECLSPEC void sha512_final_aes (sha512_ctx_t *ctx, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +DECLSPEC u32 sha512_final_aes (sha512_ctx_t *ctx, const u32 ex, const u32 *aes_ks, u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) { + u32 ret = ex; + int pos = ctx->len & 127; - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w0, ctx->w0, s_te0, s_te1, s_te2, s_te3, s_te4); - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w1, ctx->w1, s_te0, s_te1, s_te2, s_te3, s_te4); - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w2, ctx->w2, s_te0, s_te1, s_te2, s_te3, s_te4); - aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w3, ctx->w3, s_te0, s_te1, s_te2, s_te3, s_te4); + if (pos) + { + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w0, ctx->w0, s_te0, s_te1, s_te2, s_te3, s_te4); + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w1, ctx->w1, s_te0, s_te1, s_te2, s_te3, s_te4); + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w2, ctx->w2, s_te0, s_te1, s_te2, s_te3, s_te4); + aes128_encrypt_cbc (aes_ks, aes_iv, ctx->w3, ctx->w3, s_te0, s_te1, s_te2, s_te3, s_te4); + + ret = ctx->w3[3] & 0xff; + } append_0x80_8x4_S (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, pos ^ 3); @@ -811,6 +839,8 @@ DECLSPEC void sha512_final_aes (sha512_ctx_t *ctx, const u32 *aes_ks, u32 *aes_i ctx->w7[3] = ctx->len * 8; sha512_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h); + + return ret; } DECLSPEC int find_sum (const u32 *w, const u32 pw_len, u32 *bb, const u32 *aes_ks, const u32 *aes_iv, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) @@ -1040,12 +1070,10 @@ DECLSPEC u32 do_round (const u32 *w, const u32 pw_len, pdf17l8_tmp_t *tmp, SHM_T w7[2] = 0; w7[3] = 0; - sha384_update_aes_128 (&ctx384, w0, w1, w2, w3, w4, w5, w6, w7, tmp->dgst_len, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); + ex = sha384_update_aes_128 (&ctx384, w0, w1, w2, w3, w4, w5, w6, w7, tmp->dgst_len, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); } - sha384_final_aes (&ctx384, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); - - ex = ctx384.w3[3] & 0xff; + ex = sha384_final_aes (&ctx384, ex, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); tmp->dgst32[ 0] = h32_from_64_S (ctx384.h[0]); tmp->dgst32[ 1] = l32_from_64_S (ctx384.h[0]); @@ -1109,12 +1137,10 @@ DECLSPEC u32 do_round (const u32 *w, const u32 pw_len, pdf17l8_tmp_t *tmp, SHM_T w7[2] = 0; w7[3] = 0; - sha512_update_aes_128 (&ctx512, w0, w1, w2, w3, w4, w5, w6, w7, tmp->dgst_len, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); + ex = sha512_update_aes_128 (&ctx512, w0, w1, w2, w3, w4, w5, w6, w7, tmp->dgst_len, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); } - sha512_final_aes (&ctx512, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); - - ex = ctx512.w3[3] & 0xff; + ex = sha512_final_aes (&ctx512, ex, aes_ks, aes_iv, s_te0, s_te1, s_te2, s_te3, s_te4); tmp->dgst32[ 0] = h32_from_64_S (ctx512.h[0]); tmp->dgst32[ 1] = l32_from_64_S (ctx512.h[0]); @@ -1230,6 +1256,8 @@ KERNEL_FQ void m10700_loop (KERN_ATTR_TMPS_ESALT (pdf17l8_tmp_t, pdf_t)) const u32 pw_len = pws[gid].pw_len; + if (pw_len == 0) return; + u32 w[64] = { 0 }; for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) diff --git a/OpenCL/m11300-pure.cl b/OpenCL/m11300-pure.cl index c734b102c..994721f3b 100644 --- a/OpenCL/m11300-pure.cl +++ b/OpenCL/m11300-pure.cl @@ -26,6 +26,9 @@ typedef struct bitcoin_wallet u32 cry_master_buf[64]; u32 cry_master_len; + u32 cry_salt_buf[16]; + u32 cry_salt_len; + } bitcoin_wallet_t; DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) @@ -293,47 +296,56 @@ KERNEL_FQ void m11300_comp (KERN_ATTR_TMPS_ESALT (bitcoin_wallet_tmp_t, bitcoin_ key[6] = h32_from_64_S (dgst[3]); key[7] = l32_from_64_S (dgst[3]); - u32 iv[4]; - - iv[0] = h32_from_64_S (dgst[4]); - iv[1] = l32_from_64_S (dgst[4]); - iv[2] = h32_from_64_S (dgst[5]); - iv[3] = l32_from_64_S (dgst[5]); - #define KEYLEN 60 u32 ks[KEYLEN]; AES256_set_decrypt_key (ks, key, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + u32 i = esalt_bufs[digests_offset].cry_master_len - 32; + + u32 iv[4]; + + iv[0] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 0]); + iv[1] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 1]); + iv[2] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 2]); + iv[3] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 3]); + + i += 16; + + u32 data[4]; + + data[0] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 0]); + data[1] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 1]); + data[2] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 2]); + data[3] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 3]); + u32 out[4]; - for (u32 i = 0; i < esalt_bufs[digests_offset].cry_master_len; i += 16) + AES256_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + u32 pad = 0; + + if (esalt_bufs[digests_offset].cry_salt_len != 18) { - u32 data[4]; + /* most wallets */ + pad = 0x10101010; - data[0] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 0]); - data[1] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 1]); - data[2] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 2]); - data[3] = hc_swap32_S (esalt_bufs[digests_offset].cry_master_buf[(i / 4) + 3]); - - AES256_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4); - - out[0] ^= iv[0]; - out[1] ^= iv[1]; - out[2] ^= iv[2]; - out[3] ^= iv[3]; - - iv[0] = data[0]; - iv[1] = data[1]; - iv[2] = data[2]; - iv[3] = data[3]; + if (out[0] != pad) return; + if (out[1] != pad) return; + } + else + { + /* Nexus legacy wallet */ + pad = 0x08080808; } - if ((out[0] == 0x10101010) - && (out[1] == 0x10101010) - && (out[2] == 0x10101010) - && (out[3] == 0x10101010)) + if (out[2] == pad && out[3] == pad) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { diff --git a/OpenCL/m11600-optimized.cl b/OpenCL/m11600-optimized.cl new file mode 100644 index 000000000..835522f44 --- /dev/null +++ b/OpenCL/m11600-optimized.cl @@ -0,0 +1,255 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_hash_sha256.cl" +#endif + +typedef struct seven_zip_tmp +{ + u32 h[8]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + int len; + +} seven_zip_tmp_t; + +typedef struct +{ + u32 ukey[8]; + + u32 hook_success; + +} seven_zip_hook_t; + +#define PUTCHAR(a,p,c) ((u8 *)(a))[(p)] = (u8) (c) +#define GETCHAR(a,p) ((u8 *)(a))[(p)] + +#define PUTCHAR_BE(a,p,c) ((u8 *)(a))[(p) ^ 3] = (u8) (c) +#define GETCHAR_BE(a,p) ((u8 *)(a))[(p) ^ 3] + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +KERNEL_FQ void m11600_init (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + tmps[gid].h[0] = SHA256M_A; + tmps[gid].h[1] = SHA256M_B; + tmps[gid].h[2] = SHA256M_C; + tmps[gid].h[3] = SHA256M_D; + tmps[gid].h[4] = SHA256M_E; + tmps[gid].h[5] = SHA256M_F; + tmps[gid].h[6] = SHA256M_G; + tmps[gid].h[7] = SHA256M_H; + + tmps[gid].len = 0; +} + +KERNEL_FQ void m11600_loop (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf[5]; + + pw_buf[0] = pws[gid].i[0]; + pw_buf[1] = pws[gid].i[1]; + pw_buf[2] = pws[gid].i[2]; + pw_buf[3] = pws[gid].i[3]; + pw_buf[4] = pws[gid].i[4]; + + const u32 pw_len = MIN (pws[gid].pw_len, 20); + + // this is large enough to hold all possible w[] arrays for 64 iterations + + #define LARGEBLOCK_ELEMS ((40 + 8) * 16) + + u32 largeblock[LARGEBLOCK_ELEMS]; + + u8 *ptr = (u8 *) largeblock; + + for (u32 i = 0; i < LARGEBLOCK_ELEMS; i++) largeblock[i] = 0; + + u32 loop_pos_pos = loop_pos; + + for (u32 i = 0, p = 0; i < 64; i++) + { + for (u32 j = 0; j < pw_len; j++, p += 2) + { + PUTCHAR_BE (largeblock, p, GETCHAR (pw_buf, j)); + } + + const u8 byte2 = unpack_v8c_from_v32_S (loop_pos_pos); + const u8 byte3 = unpack_v8d_from_v32_S (loop_pos_pos); + + PUTCHAR_BE (largeblock, p + 2, byte2); + PUTCHAR_BE (largeblock, p + 3, byte3); + + loop_pos_pos++; + + p += 8; + } + + u32 h[8]; + + h[0] = tmps[gid].h[0]; + h[1] = tmps[gid].h[1]; + h[2] = tmps[gid].h[2]; + h[3] = tmps[gid].h[3]; + h[4] = tmps[gid].h[4]; + h[5] = tmps[gid].h[5]; + h[6] = tmps[gid].h[6]; + h[7] = tmps[gid].h[7]; + + const int iter64 = (pw_len * 2) + 8; + + loop_pos_pos = loop_pos; + + for (u32 i = 0; i < loop_cnt; i += 64) + { + // iteration set + for (u32 i = 0, p = pw_len * 2; i < 64; i++, p += iter64) + { + const u8 byte0 = unpack_v8a_from_v32_S (loop_pos_pos); + const u8 byte1 = unpack_v8b_from_v32_S (loop_pos_pos); + + PUTCHAR_BE (largeblock, p + 0, byte0); + PUTCHAR_BE (largeblock, p + 1, byte1); + + loop_pos_pos++; + } + + // full 64 byte buffer + for (int j = 0, j16 = 0; j < iter64; j++, j16 += 16) + { + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = largeblock[j16 + 0]; + w0[1] = largeblock[j16 + 1]; + w0[2] = largeblock[j16 + 2]; + w0[3] = largeblock[j16 + 3]; + w1[0] = largeblock[j16 + 4]; + w1[1] = largeblock[j16 + 5]; + w1[2] = largeblock[j16 + 6]; + w1[3] = largeblock[j16 + 7]; + w2[0] = largeblock[j16 + 8]; + w2[1] = largeblock[j16 + 9]; + w2[2] = largeblock[j16 + 10]; + w2[3] = largeblock[j16 + 11]; + w3[0] = largeblock[j16 + 12]; + w3[1] = largeblock[j16 + 13]; + w3[2] = largeblock[j16 + 14]; + w3[3] = largeblock[j16 + 15]; + + sha256_transform (w0, w1, w2, w3, h); + } + } + + tmps[gid].len += loop_cnt * iter64; + + tmps[gid].h[0] = h[0]; + tmps[gid].h[1] = h[1]; + tmps[gid].h[2] = h[2]; + tmps[gid].h[3] = h[3]; + tmps[gid].h[4] = h[4]; + tmps[gid].h[5] = h[5]; + tmps[gid].h[6] = h[6]; + tmps[gid].h[7] = h[7]; +} + +KERNEL_FQ void m11600_hook23 (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * context load + */ + + u32 h[8]; + + h[0] = tmps[gid].h[0]; + h[1] = tmps[gid].h[1]; + h[2] = tmps[gid].h[2]; + h[3] = tmps[gid].h[3]; + h[4] = tmps[gid].h[4]; + h[5] = tmps[gid].h[5]; + h[6] = tmps[gid].h[6]; + h[7] = tmps[gid].h[7]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = tmps[gid].len * 8; + + sha256_transform (w0, w1, w2, w3, h); + + hooks[gid].ukey[0] = hc_swap32_S (h[0]); + hooks[gid].ukey[1] = hc_swap32_S (h[1]); + hooks[gid].ukey[2] = hc_swap32_S (h[2]); + hooks[gid].ukey[3] = hc_swap32_S (h[3]); + hooks[gid].ukey[4] = hc_swap32_S (h[4]); + hooks[gid].ukey[5] = hc_swap32_S (h[5]); + hooks[gid].ukey[6] = hc_swap32_S (h[6]); + hooks[gid].ukey[7] = hc_swap32_S (h[7]); +} + +KERNEL_FQ void m11600_comp (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + if (hooks[gid].hook_success == 1) + { + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); + } + + return; + } +} diff --git a/OpenCL/m11600-pure.cl b/OpenCL/m11600-pure.cl index 545a0545c..481deb161 100644 --- a/OpenCL/m11600-pure.cl +++ b/OpenCL/m11600-pure.cl @@ -289,46 +289,49 @@ KERNEL_FQ void m11600_hook23 (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_h * context load */ - sha256_ctx_t ctx; + u32 h[8]; - ctx.h[0] = tmps[gid].h[0]; - ctx.h[1] = tmps[gid].h[1]; - ctx.h[2] = tmps[gid].h[2]; - ctx.h[3] = tmps[gid].h[3]; - ctx.h[4] = tmps[gid].h[4]; - ctx.h[5] = tmps[gid].h[5]; - ctx.h[6] = tmps[gid].h[6]; - ctx.h[7] = tmps[gid].h[7]; + h[0] = tmps[gid].h[0]; + h[1] = tmps[gid].h[1]; + h[2] = tmps[gid].h[2]; + h[3] = tmps[gid].h[3]; + h[4] = tmps[gid].h[4]; + h[5] = tmps[gid].h[5]; + h[6] = tmps[gid].h[6]; + h[7] = tmps[gid].h[7]; - ctx.w0[0] = tmps[gid].w0[0]; - ctx.w0[1] = tmps[gid].w0[1]; - ctx.w0[2] = tmps[gid].w0[2]; - ctx.w0[3] = tmps[gid].w0[3]; - ctx.w1[0] = tmps[gid].w1[0]; - ctx.w1[1] = tmps[gid].w1[1]; - ctx.w1[2] = tmps[gid].w1[2]; - ctx.w1[3] = tmps[gid].w1[3]; - ctx.w2[0] = tmps[gid].w2[0]; - ctx.w2[1] = tmps[gid].w2[1]; - ctx.w2[2] = tmps[gid].w2[2]; - ctx.w2[3] = tmps[gid].w2[3]; - ctx.w3[0] = tmps[gid].w3[0]; - ctx.w3[1] = tmps[gid].w3[1]; - ctx.w3[2] = tmps[gid].w3[2]; - ctx.w3[3] = tmps[gid].w3[3]; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; - ctx.len = tmps[gid].len; + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = tmps[gid].len * 8; - sha256_final (&ctx); + sha256_transform (w0, w1, w2, w3, h); - hooks[gid].ukey[0] = hc_swap32_S (ctx.h[0]); - hooks[gid].ukey[1] = hc_swap32_S (ctx.h[1]); - hooks[gid].ukey[2] = hc_swap32_S (ctx.h[2]); - hooks[gid].ukey[3] = hc_swap32_S (ctx.h[3]); - hooks[gid].ukey[4] = hc_swap32_S (ctx.h[4]); - hooks[gid].ukey[5] = hc_swap32_S (ctx.h[5]); - hooks[gid].ukey[6] = hc_swap32_S (ctx.h[6]); - hooks[gid].ukey[7] = hc_swap32_S (ctx.h[7]); + hooks[gid].ukey[0] = hc_swap32_S (h[0]); + hooks[gid].ukey[1] = hc_swap32_S (h[1]); + hooks[gid].ukey[2] = hc_swap32_S (h[2]); + hooks[gid].ukey[3] = hc_swap32_S (h[3]); + hooks[gid].ukey[4] = hc_swap32_S (h[4]); + hooks[gid].ukey[5] = hc_swap32_S (h[5]); + hooks[gid].ukey[6] = hc_swap32_S (h[6]); + hooks[gid].ukey[7] = hc_swap32_S (h[7]); } KERNEL_FQ void m11600_comp (KERN_ATTR_TMPS_HOOKS (seven_zip_tmp_t, seven_zip_hook_t)) diff --git a/OpenCL/m12400-pure.cl b/OpenCL/m12400-pure.cl index 7e913a518..41b0adf6f 100644 --- a/OpenCL/m12400-pure.cl +++ b/OpenCL/m12400-pure.cl @@ -726,40 +726,6 @@ KERNEL_FQ void m12400_loop (KERN_ATTR_TMPS (bsdicrypt_tmp_t)) _des_crypt_encrypt (iv, mask, loop_cnt, Kc, Kd, s_SPtrans); - tmps[gid].Kc[ 0] = Kc[ 0]; - tmps[gid].Kc[ 1] = Kc[ 1]; - tmps[gid].Kc[ 2] = Kc[ 2]; - tmps[gid].Kc[ 3] = Kc[ 3]; - tmps[gid].Kc[ 4] = Kc[ 4]; - tmps[gid].Kc[ 5] = Kc[ 5]; - tmps[gid].Kc[ 6] = Kc[ 6]; - tmps[gid].Kc[ 7] = Kc[ 7]; - tmps[gid].Kc[ 8] = Kc[ 8]; - tmps[gid].Kc[ 9] = Kc[ 9]; - tmps[gid].Kc[10] = Kc[10]; - tmps[gid].Kc[11] = Kc[11]; - tmps[gid].Kc[12] = Kc[12]; - tmps[gid].Kc[13] = Kc[13]; - tmps[gid].Kc[14] = Kc[14]; - tmps[gid].Kc[15] = Kc[15]; - - tmps[gid].Kd[ 0] = Kd[ 0]; - tmps[gid].Kd[ 1] = Kd[ 1]; - tmps[gid].Kd[ 2] = Kd[ 2]; - tmps[gid].Kd[ 3] = Kd[ 3]; - tmps[gid].Kd[ 4] = Kd[ 4]; - tmps[gid].Kd[ 5] = Kd[ 5]; - tmps[gid].Kd[ 6] = Kd[ 6]; - tmps[gid].Kd[ 7] = Kd[ 7]; - tmps[gid].Kd[ 8] = Kd[ 8]; - tmps[gid].Kd[ 9] = Kd[ 9]; - tmps[gid].Kd[10] = Kd[10]; - tmps[gid].Kd[11] = Kd[11]; - tmps[gid].Kd[12] = Kd[12]; - tmps[gid].Kd[13] = Kd[13]; - tmps[gid].Kd[14] = Kd[14]; - tmps[gid].Kd[15] = Kd[15]; - tmps[gid].iv[0] = iv[0]; tmps[gid].iv[1] = iv[1]; } diff --git a/OpenCL/m12500-optimized.cl b/OpenCL/m12500-optimized.cl new file mode 100644 index 000000000..d3e91121e --- /dev/null +++ b/OpenCL/m12500-optimized.cl @@ -0,0 +1,397 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_hash_sha1.cl" +#include "inc_cipher_aes.cl" +#endif + +#define COMPARE_S "inc_comp_single.cl" +#define COMPARE_M "inc_comp_multi.cl" + +#define ROUNDS 0x40000 + +#define PUTCHAR(a,p,c) ((u8 *)(a))[(p)] = (u8) (c) +#define GETCHAR(a,p) ((u8 *)(a))[(p)] + +#define PUTCHAR_BE(a,p,c) ((u8 *)(a))[(p) ^ 3] = (u8) (c) +#define GETCHAR_BE(a,p) ((u8 *)(a))[(p) ^ 3] + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +typedef struct pbkdf2_sha1 +{ + u32 salt_buf[64]; + +} pbkdf2_sha1_t; + +typedef struct rar3_tmp +{ + u32 dgst[17][5]; + +} rar3_tmp_t; + +KERNEL_FQ void m12500_init (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + tmps[gid].dgst[0][0] = SHA1M_A; + tmps[gid].dgst[0][1] = SHA1M_B; + tmps[gid].dgst[0][2] = SHA1M_C; + tmps[gid].dgst[0][3] = SHA1M_D; + tmps[gid].dgst[0][4] = SHA1M_E; +} + +KERNEL_FQ void m12500_loop (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf[5]; + + pw_buf[0] = pws[gid].i[0]; + pw_buf[1] = pws[gid].i[1]; + pw_buf[2] = pws[gid].i[2]; + pw_buf[3] = pws[gid].i[3]; + pw_buf[4] = pws[gid].i[4]; + + const u32 pw_len = MIN (pws[gid].pw_len, 20); + + u32 salt_buf[2]; + + salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = 8; + + // this is large enough to hold all possible w[] arrays for 64 iterations + + #define LARGEBLOCK_ELEMS ((40 + 8 + 3) * 16) + + u32 largeblock[LARGEBLOCK_ELEMS]; + + for (u32 i = 0; i < LARGEBLOCK_ELEMS; i++) largeblock[i] = 0; + + for (u32 i = 0, p = 0; i < 64; i++) + { + for (u32 j = 0; j < pw_len; j++, p += 2) + { + PUTCHAR_BE (largeblock, p, GETCHAR (pw_buf, j)); + } + + for (u32 j = 0; j < salt_len; j++, p += 1) + { + PUTCHAR_BE (largeblock, p, GETCHAR (salt_buf, j)); + } + + PUTCHAR_BE (largeblock, p + 2, (loop_pos >> 16) & 0xff); + + p += 3; + } + + const u32 p3 = (pw_len * 2) + salt_len + 3; + + const u32 init_pos = loop_pos / (ROUNDS / 16); + + u32 dgst[5]; + + dgst[0] = tmps[gid].dgst[init_pos][0]; + dgst[1] = tmps[gid].dgst[init_pos][1]; + dgst[2] = tmps[gid].dgst[init_pos][2]; + dgst[3] = tmps[gid].dgst[init_pos][3]; + dgst[4] = tmps[gid].dgst[init_pos][4]; + + u32 iter = loop_pos; + + for (u32 i = 0; i < 256; i += 4) + { + for (u32 j = 0; j < 64; j++) + { + const u32 p = ((j + 1) * p3) - 2; + + PUTCHAR_BE (largeblock, p, iter >> 8); + } + + for (u32 k = 0; k < 4; k++) + { + for (u32 j = 0; j < 64; j++) + { + const u32 p = ((j + 1) * p3) - 3; + + PUTCHAR_BE (largeblock, p, iter >> 0); + + iter++; + } + + for (u32 j = 0; j < p3; j++) + { + const u32 j16 = j * 16; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = largeblock[j16 + 0]; + w0[1] = largeblock[j16 + 1]; + w0[2] = largeblock[j16 + 2]; + w0[3] = largeblock[j16 + 3]; + w1[0] = largeblock[j16 + 4]; + w1[1] = largeblock[j16 + 5]; + w1[2] = largeblock[j16 + 6]; + w1[3] = largeblock[j16 + 7]; + w2[0] = largeblock[j16 + 8]; + w2[1] = largeblock[j16 + 9]; + w2[2] = largeblock[j16 + 10]; + w2[3] = largeblock[j16 + 11]; + w3[0] = largeblock[j16 + 12]; + w3[1] = largeblock[j16 + 13]; + w3[2] = largeblock[j16 + 14]; + w3[3] = largeblock[j16 + 15]; + + sha1_transform (w0, w1, w2, w3, dgst); + } + } + } + + tmps[gid].dgst[init_pos + 1][0] = dgst[0]; + tmps[gid].dgst[init_pos + 1][1] = dgst[1]; + tmps[gid].dgst[init_pos + 1][2] = dgst[2]; + tmps[gid].dgst[init_pos + 1][3] = dgst[3]; + tmps[gid].dgst[init_pos + 1][4] = dgst[4]; +} + +KERNEL_FQ void m12500_comp (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 pw_len = MIN (pws[gid].pw_len, 20); + + const u32 salt_len = 8; + + const u32 p3 = (pw_len * 2) + salt_len + 3; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (p3 * ROUNDS) * 8; + + u32 dgst[5]; + + dgst[0] = tmps[gid].dgst[16][0]; + dgst[1] = tmps[gid].dgst[16][1]; + dgst[2] = tmps[gid].dgst[16][2]; + dgst[3] = tmps[gid].dgst[16][3]; + dgst[4] = tmps[gid].dgst[16][4]; + + sha1_transform (w0, w1, w2, w3, dgst); + + u32 ukey[4]; + + ukey[0] = hc_swap32_S (dgst[0]); + ukey[1] = hc_swap32_S (dgst[1]); + ukey[2] = hc_swap32_S (dgst[2]); + ukey[3] = hc_swap32_S (dgst[3]); + + u32 ks[44]; + + AES128_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 data[4]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + + u32 out[4]; + + AES128_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + u32 iv[4]; + + iv[0] = 0; + iv[1] = 0; + iv[2] = 0; + iv[3] = 0; + + for (int i = 0; i < 16; i++) + { + u32 pw_buf[5]; + + pw_buf[0] = pws[gid].i[0]; + pw_buf[1] = pws[gid].i[1]; + pw_buf[2] = pws[gid].i[2]; + pw_buf[3] = pws[gid].i[3]; + pw_buf[4] = pws[gid].i[4]; + + //const u32 pw_len = pws[gid].pw_len; + + u32 salt_buf[2]; + + salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + + //const u32 salt_len = 8; + + //const u32 p3 = (pw_len * 2) + salt_len + 3; + + u32 w[16]; + + w[ 0] = 0; + w[ 1] = 0; + w[ 2] = 0; + w[ 3] = 0; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = 0; + + u32 p = 0; + + for (u32 j = 0; j < pw_len; j++, p += 2) + { + PUTCHAR_BE (w, p, GETCHAR (pw_buf, j)); + } + + for (u32 j = 0; j < salt_len; j++, p += 1) + { + PUTCHAR_BE (w, p, GETCHAR (salt_buf, j)); + } + + const u32 iter_pos = i * (ROUNDS / 16); + + PUTCHAR_BE (w, p + 0, (iter_pos >> 0) & 0xff); + PUTCHAR_BE (w, p + 1, (iter_pos >> 8) & 0xff); + PUTCHAR_BE (w, p + 2, (iter_pos >> 16) & 0xff); + + PUTCHAR_BE (w, p3, 0x80); + + w[15] = ((iter_pos + 1) * p3) * 8; + + u32 dgst[5]; + + dgst[0] = tmps[gid].dgst[i][0]; + dgst[1] = tmps[gid].dgst[i][1]; + dgst[2] = tmps[gid].dgst[i][2]; + dgst[3] = tmps[gid].dgst[i][3]; + dgst[4] = tmps[gid].dgst[i][4]; + + sha1_transform (w + 0, w + 4, w + 8, w + 12, dgst); + + PUTCHAR (iv, i, dgst[4] & 0xff); + } + + out[0] ^= hc_swap32_S (iv[0]); + out[1] ^= hc_swap32_S (iv[1]); + out[2] ^= hc_swap32_S (iv[2]); + out[3] ^= hc_swap32_S (iv[3]); + + const u32 r0 = out[0]; + const u32 r1 = out[1]; + const u32 r2 = 0; + const u32 r3 = 0; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m12500-pure.cl b/OpenCL/m12500-pure.cl index dbcd97121..24b0a8f05 100644 --- a/OpenCL/m12500-pure.cl +++ b/OpenCL/m12500-pure.cl @@ -37,132 +37,105 @@ typedef struct rar3_tmp } rar3_tmp_t; -DECLSPEC void sha1_transform_intern (const u32 *w, u32 *digest) +DECLSPEC void memcat8c_be (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 len, const u32 append, u32 *digest) { - u32 A = digest[0]; - u32 B = digest[1]; - u32 C = digest[2]; - u32 D = digest[3]; - u32 E = digest[4]; + const u32 func_len = len & 63; - u32 w0_t = w[ 0]; - u32 w1_t = w[ 1]; - u32 w2_t = w[ 2]; - u32 w3_t = w[ 3]; - u32 w4_t = w[ 4]; - u32 w5_t = w[ 5]; - u32 w6_t = w[ 6]; - u32 w7_t = w[ 7]; - u32 w8_t = w[ 8]; - u32 w9_t = w[ 9]; - u32 wa_t = w[10]; - u32 wb_t = w[11]; - u32 wc_t = w[12]; - u32 wd_t = w[13]; - u32 we_t = w[14]; - u32 wf_t = w[15]; + //const u32 mod = func_len & 3; + const u32 div = func_len / 4; - #undef K - #define K SHA1C00 + u32 tmp0; + u32 tmp1; - SHA1_STEP (SHA1_F0o, A, B, C, D, E, w0_t); - SHA1_STEP (SHA1_F0o, E, A, B, C, D, w1_t); - SHA1_STEP (SHA1_F0o, D, E, A, B, C, w2_t); - SHA1_STEP (SHA1_F0o, C, D, E, A, B, w3_t); - SHA1_STEP (SHA1_F0o, B, C, D, E, A, w4_t); - SHA1_STEP (SHA1_F0o, A, B, C, D, E, w5_t); - SHA1_STEP (SHA1_F0o, E, A, B, C, D, w6_t); - SHA1_STEP (SHA1_F0o, D, E, A, B, C, w7_t); - SHA1_STEP (SHA1_F0o, C, D, E, A, B, w8_t); - SHA1_STEP (SHA1_F0o, B, C, D, E, A, w9_t); - SHA1_STEP (SHA1_F0o, A, B, C, D, E, wa_t); - SHA1_STEP (SHA1_F0o, E, A, B, C, D, wb_t); - SHA1_STEP (SHA1_F0o, D, E, A, B, C, wc_t); - SHA1_STEP (SHA1_F0o, C, D, E, A, B, wd_t); - SHA1_STEP (SHA1_F0o, B, C, D, E, A, we_t); - SHA1_STEP (SHA1_F0o, A, B, C, D, E, wf_t); - w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, E, A, B, C, D, w0_t); - w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, D, E, A, B, C, w1_t); - w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, C, D, E, A, B, w2_t); - w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, B, C, D, E, A, w3_t); + #if defined IS_AMD || defined IS_GENERIC + tmp0 = hc_bytealign_be (0, append, func_len); + tmp1 = hc_bytealign_be (append, 0, func_len); + #endif - #undef K - #define K SHA1C01 + #ifdef IS_NV + const int selector = (0x76543210 >> ((func_len & 3) * 4)) & 0xffff; - w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w4_t); - w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w5_t); - w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w6_t); - w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w7_t); - w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w8_t); - w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w9_t); - wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wa_t); - wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, wb_t); - wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, wc_t); - wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wd_t); - we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, we_t); - wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wf_t); - w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w0_t); - w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w1_t); - w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w2_t); - w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w3_t); - w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w4_t); - w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w5_t); - w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w6_t); - w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w7_t); + tmp0 = hc_byte_perm (append, 0, selector); + tmp1 = hc_byte_perm (0, append, selector); + #endif - #undef K - #define K SHA1C02 + u32 carry = 0; - w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w8_t); - w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w9_t); - wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, wa_t); - wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, wb_t); - wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, wc_t); - wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, wd_t); - we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, we_t); - wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, wf_t); - w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, w0_t); - w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, w1_t); - w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w2_t); - w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w3_t); - w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, w4_t); - w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, w5_t); - w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, w6_t); - w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w7_t); - w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w8_t); - w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, w9_t); - wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, wa_t); - wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, wb_t); + switch (div) + { + case 0: w0[0] |= tmp0; + w0[1] = tmp1; + break; + case 1: w0[1] |= tmp0; + w0[2] = tmp1; + break; + case 2: w0[2] |= tmp0; + w0[3] = tmp1; + break; + case 3: w0[3] |= tmp0; + w1[0] = tmp1; + break; + case 4: w1[0] |= tmp0; + w1[1] = tmp1; + break; + case 5: w1[1] |= tmp0; + w1[2] = tmp1; + break; + case 6: w1[2] |= tmp0; + w1[3] = tmp1; + break; + case 7: w1[3] |= tmp0; + w2[0] = tmp1; + break; + case 8: w2[0] |= tmp0; + w2[1] = tmp1; + break; + case 9: w2[1] |= tmp0; + w2[2] = tmp1; + break; + case 10: w2[2] |= tmp0; + w2[3] = tmp1; + break; + case 11: w2[3] |= tmp0; + w3[0] = tmp1; + break; + case 12: w3[0] |= tmp0; + w3[1] = tmp1; + break; + case 13: w3[1] |= tmp0; + w3[2] = tmp1; + break; + case 14: w3[2] |= tmp0; + w3[3] = tmp1; + break; + case 15: w3[3] |= tmp0; + carry = tmp1; + break; + } - #undef K - #define K SHA1C03 + const u32 new_len = func_len + 3; - wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, wc_t); - wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wd_t); - we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, we_t); - wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, wf_t); - w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w0_t); - w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w1_t); - w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w2_t); - w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w3_t); - w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w4_t); - w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w5_t); - w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w6_t); - w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w7_t); - w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w8_t); - w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w9_t); - wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wa_t); - wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, wb_t); - wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wc_t); - wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, wd_t); - we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, we_t); - wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wf_t); + if (new_len >= 64) + { + sha1_transform (w0, w1, w2, w3, digest); - digest[0] += A; - digest[1] += B; - digest[2] += C; - digest[3] += D; - digest[4] += E; + w0[0] = carry; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + } } KERNEL_FQ void m12500_init (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) @@ -180,6 +153,14 @@ KERNEL_FQ void m12500_init (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) tmps[gid].dgst[0][2] = SHA1M_C; tmps[gid].dgst[0][3] = SHA1M_D; tmps[gid].dgst[0][4] = SHA1M_E; + + /** + * context save + */ + + sha1_ctx_t ctx; + + sha1_init (&ctx); } KERNEL_FQ void m12500_loop (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) @@ -188,96 +169,68 @@ KERNEL_FQ void m12500_loop (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) if (gid >= gid_max) return; - u32 pw_buf[5]; + /** + * base + */ - pw_buf[0] = pws[gid].i[0]; - pw_buf[1] = pws[gid].i[1]; - pw_buf[2] = pws[gid].i[2]; - pw_buf[3] = pws[gid].i[3]; - pw_buf[4] = pws[gid].i[4]; + const u32 pw_len = pws[gid].pw_len; - const u32 pw_len = MIN (pws[gid].pw_len, 20); + u32 w[64] = { 0 }; - u32 salt_buf[2]; + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + u32 salt_buf[16]; + + salt_buf[ 0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[ 1] = salt_bufs[salt_pos].salt_buf[1]; + salt_buf[ 2] = 0; + salt_buf[ 3] = 0; + salt_buf[ 4] = 0; + salt_buf[ 5] = 0; + salt_buf[ 6] = 0; + salt_buf[ 7] = 0; + salt_buf[ 8] = 0; + salt_buf[ 9] = 0; + salt_buf[10] = 0; + salt_buf[11] = 0; + salt_buf[12] = 0; + salt_buf[13] = 0; + salt_buf[14] = 0; + salt_buf[15] = 0; const u32 salt_len = 8; - // this is large enough to hold all possible w[] arrays for 64 iterations - - #define LARGEBLOCK_ELEMS ((40 + 8 + 3) * 16) - - u32 largeblock[LARGEBLOCK_ELEMS]; - - for (u32 i = 0; i < LARGEBLOCK_ELEMS; i++) largeblock[i] = 0; - - for (u32 i = 0, p = 0; i < 64; i++) - { - for (u32 j = 0; j < pw_len; j++, p += 2) - { - PUTCHAR_BE (largeblock, p, GETCHAR (pw_buf, j)); - } - - for (u32 j = 0; j < salt_len; j++, p += 1) - { - PUTCHAR_BE (largeblock, p, GETCHAR (salt_buf, j)); - } - - PUTCHAR_BE (largeblock, p + 2, (loop_pos >> 16) & 0xff); - - p += 3; - } - - const u32 p3 = (pw_len * 2) + salt_len + 3; - const u32 init_pos = loop_pos / (ROUNDS / 16); - u32 dgst[5]; + sha1_ctx_t ctx; - dgst[0] = tmps[gid].dgst[init_pos][0]; - dgst[1] = tmps[gid].dgst[init_pos][1]; - dgst[2] = tmps[gid].dgst[init_pos][2]; - dgst[3] = tmps[gid].dgst[init_pos][3]; - dgst[4] = tmps[gid].dgst[init_pos][4]; + sha1_init (&ctx); - u32 iter = loop_pos; + ctx.h[0] = tmps[gid].dgst[init_pos][0]; + ctx.h[1] = tmps[gid].dgst[init_pos][1]; + ctx.h[2] = tmps[gid].dgst[init_pos][2]; + ctx.h[3] = tmps[gid].dgst[init_pos][3]; + ctx.h[4] = tmps[gid].dgst[init_pos][4]; - for (u32 i = 0; i < 256; i += 4) + for (u32 i = 0, j = loop_pos; i < 16384; i++, j++) { - for (u32 j = 0; j < 64; j++) - { - const u32 p = ((j + 1) * p3) - 2; + sha1_update_utf16le_swap (&ctx, w, pw_len); - PUTCHAR_BE (largeblock, p, iter >> 8); - } + sha1_update_swap (&ctx, salt_buf, salt_len); - for (u32 k = 0; k < 4; k++) - { - for (u32 j = 0; j < 64; j++) - { - const u32 p = ((j + 1) * p3) - 3; + memcat8c_be (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.len, hc_swap32_S (j), ctx.h); - PUTCHAR_BE (largeblock, p, iter >> 0); - - iter++; - } - - for (u32 j = 0; j < p3; j++) - { - const u32 j16 = j * 16; - - sha1_transform_intern (&largeblock[j16], dgst); - } - } + ctx.len += 3; } - tmps[gid].dgst[init_pos + 1][0] = dgst[0]; - tmps[gid].dgst[init_pos + 1][1] = dgst[1]; - tmps[gid].dgst[init_pos + 1][2] = dgst[2]; - tmps[gid].dgst[init_pos + 1][3] = dgst[3]; - tmps[gid].dgst[init_pos + 1][4] = dgst[4]; + tmps[gid].dgst[init_pos + 1][0] = ctx.h[0]; + tmps[gid].dgst[init_pos + 1][1] = ctx.h[1]; + tmps[gid].dgst[init_pos + 1][2] = ctx.h[2]; + tmps[gid].dgst[init_pos + 1][3] = ctx.h[3]; + tmps[gid].dgst[init_pos + 1][4] = ctx.h[4]; } KERNEL_FQ void m12500_comp (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) @@ -343,47 +296,76 @@ KERNEL_FQ void m12500_comp (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) * base */ - const u32 pw_len = MIN (pws[gid].pw_len, 20); + const u32 pw_len = pws[gid].pw_len; + + u32 w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + u32 salt_buf[16]; + + salt_buf[ 0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[ 1] = salt_bufs[salt_pos].salt_buf[1]; + salt_buf[ 2] = 0; + salt_buf[ 3] = 0; + salt_buf[ 4] = 0; + salt_buf[ 5] = 0; + salt_buf[ 6] = 0; + salt_buf[ 7] = 0; + salt_buf[ 8] = 0; + salt_buf[ 9] = 0; + salt_buf[10] = 0; + salt_buf[11] = 0; + salt_buf[12] = 0; + salt_buf[13] = 0; + salt_buf[14] = 0; + salt_buf[15] = 0; const u32 salt_len = 8; const u32 p3 = (pw_len * 2) + salt_len + 3; - u32 w_buf[16]; + u32 h[5]; - w_buf[ 0] = 0x80000000; - w_buf[ 1] = 0; - w_buf[ 2] = 0; - w_buf[ 3] = 0; - w_buf[ 4] = 0; - w_buf[ 5] = 0; - w_buf[ 6] = 0; - w_buf[ 7] = 0; - w_buf[ 8] = 0; - w_buf[ 9] = 0; - w_buf[10] = 0; - w_buf[11] = 0; - w_buf[12] = 0; - w_buf[13] = 0; - w_buf[14] = 0; - w_buf[15] = (p3 * ROUNDS) * 8; + h[0] = tmps[gid].dgst[16][0]; + h[1] = tmps[gid].dgst[16][1]; + h[2] = tmps[gid].dgst[16][2]; + h[3] = tmps[gid].dgst[16][3]; + h[4] = tmps[gid].dgst[16][4]; - u32 dgst[5]; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; - dgst[0] = tmps[gid].dgst[16][0]; - dgst[1] = tmps[gid].dgst[16][1]; - dgst[2] = tmps[gid].dgst[16][2]; - dgst[3] = tmps[gid].dgst[16][3]; - dgst[4] = tmps[gid].dgst[16][4]; + w0[0] = 0x80000000; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (ROUNDS * p3) * 8; - sha1_transform_intern (w_buf, dgst); + sha1_transform (w0, w1, w2, w3, h); u32 ukey[4]; - ukey[0] = hc_swap32_S (dgst[0]); - ukey[1] = hc_swap32_S (dgst[1]); - ukey[2] = hc_swap32_S (dgst[2]); - ukey[3] = hc_swap32_S (dgst[3]); + ukey[0] = hc_swap32_S (h[0]); + ukey[1] = hc_swap32_S (h[1]); + ukey[2] = hc_swap32_S (h[2]); + ukey[3] = hc_swap32_S (h[3]); u32 ks[44]; @@ -409,77 +391,31 @@ KERNEL_FQ void m12500_comp (KERN_ATTR_TMPS_ESALT (rar3_tmp_t, pbkdf2_sha1_t)) for (int i = 0; i < 16; i++) { - u32 pw_buf[5]; + sha1_ctx_t ctx; - pw_buf[0] = pws[gid].i[0]; - pw_buf[1] = pws[gid].i[1]; - pw_buf[2] = pws[gid].i[2]; - pw_buf[3] = pws[gid].i[3]; - pw_buf[4] = pws[gid].i[4]; + sha1_init (&ctx); - //const u32 pw_len = pws[gid].pw_len; - - u32 salt_buf[2]; - - salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; - salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; - - //const u32 salt_len = 8; - - //const u32 p3 = (pw_len * 2) + salt_len + 3; - - u32 w[16]; - - w[ 0] = 0; - w[ 1] = 0; - w[ 2] = 0; - w[ 3] = 0; - w[ 4] = 0; - w[ 5] = 0; - w[ 6] = 0; - w[ 7] = 0; - w[ 8] = 0; - w[ 9] = 0; - w[10] = 0; - w[11] = 0; - w[12] = 0; - w[13] = 0; - w[14] = 0; - w[15] = 0; - - u32 p = 0; - - for (u32 j = 0; j < pw_len; j++, p += 2) - { - PUTCHAR_BE (w, p, GETCHAR (pw_buf, j)); - } - - for (u32 j = 0; j < salt_len; j++, p += 1) - { - PUTCHAR_BE (w, p, GETCHAR (salt_buf, j)); - } + ctx.h[0] = tmps[gid].dgst[i][0]; + ctx.h[1] = tmps[gid].dgst[i][1]; + ctx.h[2] = tmps[gid].dgst[i][2]; + ctx.h[3] = tmps[gid].dgst[i][3]; + ctx.h[4] = tmps[gid].dgst[i][4]; const u32 iter_pos = i * (ROUNDS / 16); - PUTCHAR_BE (w, p + 0, (iter_pos >> 0) & 0xff); - PUTCHAR_BE (w, p + 1, (iter_pos >> 8) & 0xff); - PUTCHAR_BE (w, p + 2, (iter_pos >> 16) & 0xff); + ctx.len = iter_pos * p3; - PUTCHAR_BE (w, p3, 0x80); + sha1_update_utf16le_swap (&ctx, w, pw_len); - w[15] = ((iter_pos + 1) * p3) * 8; + sha1_update_swap (&ctx, salt_buf, salt_len); - u32 dgst[5]; + memcat8c_be (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.len, hc_swap32_S (iter_pos), ctx.h); - dgst[0] = tmps[gid].dgst[i][0]; - dgst[1] = tmps[gid].dgst[i][1]; - dgst[2] = tmps[gid].dgst[i][2]; - dgst[3] = tmps[gid].dgst[i][3]; - dgst[4] = tmps[gid].dgst[i][4]; + ctx.len += 3; - sha1_transform_intern (w, dgst); + sha1_final (&ctx); - PUTCHAR (iv, i, dgst[4] & 0xff); + PUTCHAR (iv, i, ctx.h[4] & 0xff); } out[0] ^= hc_swap32_S (iv[0]); diff --git a/OpenCL/m12700-pure.cl b/OpenCL/m12700-pure.cl index 8fc00d476..8a4cd983a 100644 --- a/OpenCL/m12700-pure.cl +++ b/OpenCL/m12700-pure.cl @@ -28,6 +28,20 @@ typedef struct mywallet_tmp } mywallet_tmp_t; +DECLSPEC int is_valid_char (const u32 v) +{ + if ((v & 0xff000000) < 0x09000000) return 0; + if ((v & 0xff000000) > 0x7e000000) return 0; + if ((v & 0x00ff0000) < 0x00090000) return 0; + if ((v & 0x00ff0000) > 0x007e0000) return 0; + if ((v & 0x0000ff00) < 0x00000900) return 0; + if ((v & 0x0000ff00) > 0x00007e00) return 0; + if ((v & 0x000000ff) < 0x00000009) return 0; + if ((v & 0x000000ff) > 0x0000007e) return 0; + + return 1; +} + DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; @@ -318,121 +332,52 @@ KERNEL_FQ void m12700_comp (KERN_ATTR_TMPS (mywallet_tmp_t)) AES256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 data[4]; + u32 iv[4]; - data[0] = salt_bufs[salt_pos].salt_buf[4]; - data[1] = salt_bufs[salt_pos].salt_buf[5]; - data[2] = salt_bufs[salt_pos].salt_buf[6]; - data[3] = salt_bufs[salt_pos].salt_buf[7]; + iv[0] = salt_bufs[salt_pos].salt_buf[0]; + iv[1] = salt_bufs[salt_pos].salt_buf[1]; + iv[2] = salt_bufs[salt_pos].salt_buf[2]; + iv[3] = salt_bufs[salt_pos].salt_buf[3]; - u32 out[4]; + // decrypted data should be a JSON string consisting only of ASCII chars (0x09-0x7e) - AES256_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4); - - out[0] ^= salt_bufs[salt_pos].salt_buf[0]; - out[1] ^= salt_bufs[salt_pos].salt_buf[1]; - out[2] ^= salt_bufs[salt_pos].salt_buf[2]; - out[3] ^= salt_bufs[salt_pos].salt_buf[3]; - - out[0] = hc_swap32_S (out[0]); - out[1] = hc_swap32_S (out[1]); - out[2] = hc_swap32_S (out[2]); - out[3] = hc_swap32_S (out[3]); - - if ((out[0] & 0xff) != '{') return; - - char *pt = (char *) out; - - for (int i = 1; i < 16 - 6; i++) + for (u32 i = 4; i < 16; i += 4) { - // "guid" - if ((pt[i + 0] == '"') && (pt[i + 1] == 'g') && (pt[i + 2] == 'u') && (pt[i + 3] == 'i') && (pt[i + 4] == 'd') && (pt[i + 5] == '"')) - { - const u32 r0 = data[0]; - const u32 r1 = data[1]; - const u32 r2 = data[2]; - const u32 r3 = data[3]; + u32 data[4]; - #ifdef KERNEL_STATIC - #define il_pos 0 - #endif + data[0] = salt_bufs[salt_pos].salt_buf[i + 0]; + data[1] = salt_bufs[salt_pos].salt_buf[i + 1]; + data[2] = salt_bufs[salt_pos].salt_buf[i + 2]; + data[3] = salt_bufs[salt_pos].salt_buf[i + 3]; - #include COMPARE_M - } + u32 out[4]; - // "tx_no - if ((pt[i + 0] == '"') && (pt[i + 1] == 't') && (pt[i + 2] == 'x') && (pt[i + 3] == '_') && (pt[i + 4] == 'n') && (pt[i + 5] == 'o')) - { - const u32 r0 = data[0]; - const u32 r1 = data[1]; - const u32 r2 = data[2]; - const u32 r3 = data[3]; + AES256_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4); - #define il_pos 0 + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif - } + if (is_valid_char (out[0]) == 0) return; + if (is_valid_char (out[1]) == 0) return; + if (is_valid_char (out[2]) == 0) return; + if (is_valid_char (out[3]) == 0) return; - // "share - if ((pt[i + 0] == '"') && (pt[i + 1] == 's') && (pt[i + 2] == 'h') && (pt[i + 3] == 'a') && (pt[i + 4] == 'r') && (pt[i + 5] == 'e')) - { - const u32 r0 = data[0]; - const u32 r1 = data[1]; - const u32 r2 = data[2]; - const u32 r3 = data[3]; - - #ifdef KERNEL_STATIC - #define il_pos 0 - #endif - - #include COMPARE_M - } - - // "doubl - if ((pt[i + 0] == '"') && (pt[i + 1] == 'd') && (pt[i + 2] == 'o') && (pt[i + 3] == 'u') && (pt[i + 4] == 'b') && (pt[i + 5] == 'l')) - { - const u32 r0 = data[0]; - const u32 r1 = data[1]; - const u32 r2 = data[2]; - const u32 r3 = data[3]; - - #define il_pos 0 - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif - } - - // "addre - if ((pt[i + 0] == '"') && (pt[i + 1] == 'a') && (pt[i + 2] == 'd') && (pt[i + 3] == 'd') && (pt[i + 4] == 'r') && (pt[i + 5] == 'a')) - { - const u32 r0 = data[0]; - const u32 r1 = data[1]; - const u32 r2 = data[2]; - const u32 r3 = data[3]; - - #define il_pos 0 - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif - } - - // "keys" - if ((pt[i + 0] == '"') && (pt[i + 1] == 'k') && (pt[i + 2] == 'e') && (pt[i + 3] == 'y') && (pt[i + 4] == 's') && (pt[i + 5] == '"')) - { - const u32 r0 = data[0]; - const u32 r1 = data[1]; - const u32 r2 = data[2]; - const u32 r3 = data[3]; - - #define il_pos 0 - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif - } + iv[0] = data[0]; + iv[1] = data[1]; + iv[2] = data[2]; + iv[3] = data[3]; } + + const u32 r0 = salt_bufs[salt_pos].salt_buf[4]; + const u32 r1 = salt_bufs[salt_pos].salt_buf[5]; + const u32 r2 = salt_bufs[salt_pos].salt_buf[6]; + const u32 r3 = salt_bufs[salt_pos].salt_buf[7]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif } diff --git a/OpenCL/m13600-pure.cl b/OpenCL/m13600-pure.cl index 915b7a5f6..3de444bdb 100644 --- a/OpenCL/m13600-pure.cl +++ b/OpenCL/m13600-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -43,7 +43,7 @@ typedef struct zip2 } zip2_t; -DECLSPEC void hmac_sha1_run (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *ipad, u32 *opad, u32 *digest) +DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) { digest[0] = ipad[0]; digest[1] = ipad[1]; @@ -51,7 +51,7 @@ DECLSPEC void hmac_sha1_run (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *ipad, u32 digest[3] = ipad[3]; digest[4] = ipad[4]; - sha1_transform (w0, w1, w2, w3, digest); + sha1_transform_vector (w0, w1, w2, w3, digest); w0[0] = digest[0]; w0[1] = digest[1]; @@ -76,7 +76,7 @@ DECLSPEC void hmac_sha1_run (u32 *w0, u32 *w1, u32 *w2, u32 *w3, u32 *ipad, u32 digest[3] = opad[3]; digest[4] = opad[4]; - sha1_transform (w0, w1, w2, w3, digest); + sha1_transform_vector (w0, w1, w2, w3, digest); } KERNEL_FQ void m13600_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha1_tmp_t, zip2_t)) @@ -192,22 +192,22 @@ KERNEL_FQ void m13600_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha1_tmp_t, zip2_t)) { const u64 gid = get_global_id (0); - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; - u32 ipad[5]; - u32 opad[5]; + u32x ipad[5]; + u32x opad[5]; - ipad[0] = tmps[gid].ipad[0]; - ipad[1] = tmps[gid].ipad[1]; - ipad[2] = tmps[gid].ipad[2]; - ipad[3] = tmps[gid].ipad[3]; - ipad[4] = tmps[gid].ipad[4]; + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); - opad[0] = tmps[gid].opad[0]; - opad[1] = tmps[gid].opad[1]; - opad[2] = tmps[gid].opad[2]; - opad[3] = tmps[gid].opad[3]; - opad[4] = tmps[gid].opad[4]; + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); const u32 verify_bytes = esalt_bufs[digests_offset].verify_bytes; @@ -233,27 +233,27 @@ KERNEL_FQ void m13600_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha1_tmp_t, zip2_t)) { const u32 i5 = i * 5; - u32 dgst[5]; - u32 out[5]; + u32x dgst[5]; + u32x out[5]; - dgst[0] = tmps[gid].dgst[i5 + 0]; - dgst[1] = tmps[gid].dgst[i5 + 1]; - dgst[2] = tmps[gid].dgst[i5 + 2]; - dgst[3] = tmps[gid].dgst[i5 + 3]; - dgst[4] = tmps[gid].dgst[i5 + 4]; + dgst[0] = packv (tmps, dgst, gid, i5 + 0); + dgst[1] = packv (tmps, dgst, gid, i5 + 1); + dgst[2] = packv (tmps, dgst, gid, i5 + 2); + dgst[3] = packv (tmps, dgst, gid, i5 + 3); + dgst[4] = packv (tmps, dgst, gid, i5 + 4); - out[0] = tmps[gid].out[i5 + 0]; - out[1] = tmps[gid].out[i5 + 1]; - out[2] = tmps[gid].out[i5 + 2]; - out[3] = tmps[gid].out[i5 + 3]; - out[4] = tmps[gid].out[i5 + 4]; + out[0] = packv (tmps, out, gid, i5 + 0); + out[1] = packv (tmps, out, gid, i5 + 1); + out[2] = packv (tmps, out, gid, i5 + 2); + out[3] = packv (tmps, out, gid, i5 + 3); + out[4] = packv (tmps, out, gid, i5 + 4); for (u32 j = 0; j < loop_cnt; j++) { - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; w0[0] = dgst[0]; w0[1] = dgst[1]; @@ -272,7 +272,7 @@ KERNEL_FQ void m13600_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha1_tmp_t, zip2_t)) w3[2] = 0; w3[3] = (64 + 20) * 8; - hmac_sha1_run (w0, w1, w2, w3, ipad, opad, dgst); + hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst); out[0] ^= dgst[0]; out[1] ^= dgst[1]; @@ -283,22 +283,22 @@ KERNEL_FQ void m13600_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha1_tmp_t, zip2_t)) if (i == iter_stop - 1) // 2 byte optimization check { - if (mode == 1) if ((out[3] >> 16) != verify_bytes) break; - if (mode == 2) if ((out[2] >> 16) != verify_bytes) break; - if (mode == 3) if ((out[1] >> 16) != verify_bytes) break; + if (mode == 1) if (MATCHES_NONE_VS ((out[3] >> 16), verify_bytes)) break; + if (mode == 2) if (MATCHES_NONE_VS ((out[2] >> 16), verify_bytes)) break; + if (mode == 3) if (MATCHES_NONE_VS ((out[1] >> 16), verify_bytes)) break; } - tmps[gid].dgst[i5 + 0] = dgst[0]; - tmps[gid].dgst[i5 + 1] = dgst[1]; - tmps[gid].dgst[i5 + 2] = dgst[2]; - tmps[gid].dgst[i5 + 3] = dgst[3]; - tmps[gid].dgst[i5 + 4] = dgst[4]; + unpackv (tmps, dgst, gid, i5 + 0, dgst[0]); + unpackv (tmps, dgst, gid, i5 + 1, dgst[1]); + unpackv (tmps, dgst, gid, i5 + 2, dgst[2]); + unpackv (tmps, dgst, gid, i5 + 3, dgst[3]); + unpackv (tmps, dgst, gid, i5 + 4, dgst[4]); - tmps[gid].out[i5 + 0] = out[0]; - tmps[gid].out[i5 + 1] = out[1]; - tmps[gid].out[i5 + 2] = out[2]; - tmps[gid].out[i5 + 3] = out[3]; - tmps[gid].out[i5 + 4] = out[4]; + unpackv (tmps, out, gid, i5 + 0, out[0]); + unpackv (tmps, out, gid, i5 + 1, out[1]); + unpackv (tmps, out, gid, i5 + 2, out[2]); + unpackv (tmps, out, gid, i5 + 3, out[3]); + unpackv (tmps, out, gid, i5 + 4, out[4]); } } diff --git a/OpenCL/m13711-pure.cl b/OpenCL/m13711-pure.cl index a74b318a6..52ebd1c3a 100644 --- a/OpenCL/m13711-pure.cl +++ b/OpenCL/m13711-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -252,61 +253,8 @@ KERNEL_FQ void m13711_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) KERNEL_FQ void m13711_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -407,11 +355,13 @@ KERNEL_FQ void m13711_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; + unpackv (tmps, pim_key, gid, i + 0, out[0]); + unpackv (tmps, pim_key, gid, i + 1, out[1]); + unpackv (tmps, pim_key, gid, i + 2, out[2]); + unpackv (tmps, pim_key, gid, i + 3, out[3]); + unpackv (tmps, pim_key, gid, i + 4, out[4]); + + tmps[gid].pim_check = pim; } } @@ -427,10 +377,78 @@ KERNEL_FQ void m13711_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 3, out[3]); unpackv (tmps, out, gid, i + 4, out[4]); } +} - if (pim == 0) return; +KERNEL_FQ void m13711_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13711_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) diff --git a/OpenCL/m13712-pure.cl b/OpenCL/m13712-pure.cl index d754ae7df..c7e3d4b30 100644 --- a/OpenCL/m13712-pure.cl +++ b/OpenCL/m13712-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -303,61 +304,8 @@ KERNEL_FQ void m13712_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) KERNEL_FQ void m13712_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -458,11 +406,13 @@ KERNEL_FQ void m13712_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; + unpackv (tmps, pim_key, gid, i + 0, out[0]); + unpackv (tmps, pim_key, gid, i + 1, out[1]); + unpackv (tmps, pim_key, gid, i + 2, out[2]); + unpackv (tmps, pim_key, gid, i + 3, out[3]); + unpackv (tmps, pim_key, gid, i + 4, out[4]); + + tmps[gid].pim_check = pim; } } @@ -478,11 +428,83 @@ KERNEL_FQ void m13712_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 3, out[3]); unpackv (tmps, out, gid, i + 4, out[4]); } +} - if (pim == 0) return; +KERNEL_FQ void m13712_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13712_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) diff --git a/OpenCL/m13713-pure.cl b/OpenCL/m13713-pure.cl index db6dc593f..fb42974a8 100644 --- a/OpenCL/m13713-pure.cl +++ b/OpenCL/m13713-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -368,61 +369,8 @@ KERNEL_FQ void m13713_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) KERNEL_FQ void m13713_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -523,11 +471,13 @@ KERNEL_FQ void m13713_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; + unpackv (tmps, pim_key, gid, i + 0, out[0]); + unpackv (tmps, pim_key, gid, i + 1, out[1]); + unpackv (tmps, pim_key, gid, i + 2, out[2]); + unpackv (tmps, pim_key, gid, i + 3, out[3]); + unpackv (tmps, pim_key, gid, i + 4, out[4]); + + tmps[gid].pim_check = pim; } } @@ -543,12 +493,88 @@ KERNEL_FQ void m13713_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 3, out[3]); unpackv (tmps, out, gid, i + 4, out[4]); } +} - if (pim == 0) return; +KERNEL_FQ void m13713_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13713_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl index 3dbabb69d..e15638438 100644 --- a/OpenCL/m13721-pure.cl +++ b/OpenCL/m13721-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc64_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_tmp_t; @@ -355,61 +356,8 @@ KERNEL_FQ void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) KERNEL_FQ void m13721_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * shared lookup table - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -545,14 +493,16 @@ KERNEL_FQ void m13721_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpack64v (tmps, pim_key, gid, i + 0, out[0]); + unpack64v (tmps, pim_key, gid, i + 1, out[1]); + unpack64v (tmps, pim_key, gid, i + 2, out[2]); + unpack64v (tmps, pim_key, gid, i + 3, out[3]); + unpack64v (tmps, pim_key, gid, i + 4, out[4]); + unpack64v (tmps, pim_key, gid, i + 5, out[5]); + unpack64v (tmps, pim_key, gid, i + 6, out[6]); + unpack64v (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -574,10 +524,78 @@ KERNEL_FQ void m13721_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13721_loop_extended (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13721_comp (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl index 9b74f8d41..b2aa906b6 100644 --- a/OpenCL/m13722-pure.cl +++ b/OpenCL/m13722-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc64_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_tmp_t; @@ -406,61 +407,8 @@ KERNEL_FQ void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) KERNEL_FQ void m13722_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * shared lookup table - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -596,14 +544,16 @@ KERNEL_FQ void m13722_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpack64v (tmps, pim_key, gid, i + 0, out[0]); + unpack64v (tmps, pim_key, gid, i + 1, out[1]); + unpack64v (tmps, pim_key, gid, i + 2, out[2]); + unpack64v (tmps, pim_key, gid, i + 3, out[3]); + unpack64v (tmps, pim_key, gid, i + 4, out[4]); + unpack64v (tmps, pim_key, gid, i + 5, out[5]); + unpack64v (tmps, pim_key, gid, i + 6, out[6]); + unpack64v (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -625,11 +575,83 @@ KERNEL_FQ void m13722_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13722_loop_extended (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13722_comp (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl index ec722c387..da755b629 100644 --- a/OpenCL/m13723-pure.cl +++ b/OpenCL/m13723-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc64_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_tmp_t; @@ -471,61 +472,8 @@ KERNEL_FQ void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) KERNEL_FQ void m13723_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * shared lookup table - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -661,14 +609,16 @@ KERNEL_FQ void m13723_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpack64v (tmps, pim_key, gid, i + 0, out[0]); + unpack64v (tmps, pim_key, gid, i + 1, out[1]); + unpack64v (tmps, pim_key, gid, i + 2, out[2]); + unpack64v (tmps, pim_key, gid, i + 3, out[3]); + unpack64v (tmps, pim_key, gid, i + 4, out[4]); + unpack64v (tmps, pim_key, gid, i + 5, out[5]); + unpack64v (tmps, pim_key, gid, i + 6, out[6]); + unpack64v (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -690,12 +640,88 @@ KERNEL_FQ void m13723_loop (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13723_loop_extended (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13723_comp (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) diff --git a/OpenCL/m13731-pure.cl b/OpenCL/m13731-pure.cl index b729f07a5..de76defc5 100644 --- a/OpenCL/m13731-pure.cl +++ b/OpenCL/m13731-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -86,7 +87,7 @@ DECLSPEC int check_header_0512 (GLOBAL_AS const vc_t *esalt_bufs, GLOBAL_AS u32 return -1; } -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -105,7 +106,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = ipad[14]; digest[15] = ipad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -124,7 +125,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = digest[ 0]; w0[1] = digest[ 1]; @@ -160,7 +161,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = opad[14]; digest[15] = opad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -179,7 +180,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) @@ -209,36 +210,39 @@ KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -310,7 +314,7 @@ KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -415,93 +419,45 @@ KERNEL_FQ void m13731_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - /** * Whirlpool shared */ #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -638,7 +594,7 @@ KERNEL_FQ void m13731_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) w3[2] = dgst[14]; w3[3] = dgst[15]; - hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); out[ 0] ^= dgst[ 0]; out[ 1] ^= dgst[ 1]; @@ -661,22 +617,24 @@ KERNEL_FQ void m13731_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[ 0]; - tmps[gid].pim_key[i + 1] = out[ 1]; - tmps[gid].pim_key[i + 2] = out[ 2]; - tmps[gid].pim_key[i + 3] = out[ 3]; - tmps[gid].pim_key[i + 4] = out[ 4]; - tmps[gid].pim_key[i + 5] = out[ 5]; - tmps[gid].pim_key[i + 6] = out[ 6]; - tmps[gid].pim_key[i + 7] = out[ 7]; - tmps[gid].pim_key[i + 8] = out[ 8]; - tmps[gid].pim_key[i + 9] = out[ 9]; - tmps[gid].pim_key[i + 10] = out[10]; - tmps[gid].pim_key[i + 11] = out[11]; - tmps[gid].pim_key[i + 12] = out[12]; - tmps[gid].pim_key[i + 13] = out[13]; - tmps[gid].pim_key[i + 14] = out[14]; - tmps[gid].pim_key[i + 15] = out[15]; + unpackv (tmps, pim_key, gid, i + 0, out[ 0]); + unpackv (tmps, pim_key, gid, i + 1, out[ 1]); + unpackv (tmps, pim_key, gid, i + 2, out[ 2]); + unpackv (tmps, pim_key, gid, i + 3, out[ 3]); + unpackv (tmps, pim_key, gid, i + 4, out[ 4]); + unpackv (tmps, pim_key, gid, i + 5, out[ 5]); + unpackv (tmps, pim_key, gid, i + 6, out[ 6]); + unpackv (tmps, pim_key, gid, i + 7, out[ 7]); + unpackv (tmps, pim_key, gid, i + 8, out[ 8]); + unpackv (tmps, pim_key, gid, i + 9, out[ 9]); + unpackv (tmps, pim_key, gid, i + 10, out[10]); + unpackv (tmps, pim_key, gid, i + 11, out[11]); + unpackv (tmps, pim_key, gid, i + 12, out[12]); + unpackv (tmps, pim_key, gid, i + 13, out[13]); + unpackv (tmps, pim_key, gid, i + 14, out[14]); + unpackv (tmps, pim_key, gid, i + 15, out[15]); + + tmps[gid].pim_check = pim; } } @@ -714,10 +672,78 @@ KERNEL_FQ void m13731_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 14, out[14]); unpackv (tmps, out, gid, i + 15, out[15]); } +} - if (pim == 0) return; +KERNEL_FQ void m13731_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13731_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) @@ -777,45 +803,6 @@ KERNEL_FQ void m13731_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) #endif - /** - * Whirlpool shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; - - #endif - if (gid >= gid_max) return; if (tmps[gid].pim) diff --git a/OpenCL/m13732-pure.cl b/OpenCL/m13732-pure.cl index 057efa707..2fb26cb25 100644 --- a/OpenCL/m13732-pure.cl +++ b/OpenCL/m13732-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -137,7 +138,7 @@ DECLSPEC int check_header_1024 (GLOBAL_AS const vc_t *esalt_bufs, GLOBAL_AS u32 return -1; } -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -156,7 +157,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = ipad[14]; digest[15] = ipad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -175,7 +176,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = digest[ 0]; w0[1] = digest[ 1]; @@ -211,7 +212,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = opad[14]; digest[15] = opad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -230,7 +231,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) @@ -260,36 +261,39 @@ KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -361,7 +365,7 @@ KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -466,93 +470,45 @@ KERNEL_FQ void m13732_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - /** * Whirlpool shared */ #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -689,7 +645,7 @@ KERNEL_FQ void m13732_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) w3[2] = dgst[14]; w3[3] = dgst[15]; - hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); out[ 0] ^= dgst[ 0]; out[ 1] ^= dgst[ 1]; @@ -712,22 +668,24 @@ KERNEL_FQ void m13732_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[ 0]; - tmps[gid].pim_key[i + 1] = out[ 1]; - tmps[gid].pim_key[i + 2] = out[ 2]; - tmps[gid].pim_key[i + 3] = out[ 3]; - tmps[gid].pim_key[i + 4] = out[ 4]; - tmps[gid].pim_key[i + 5] = out[ 5]; - tmps[gid].pim_key[i + 6] = out[ 6]; - tmps[gid].pim_key[i + 7] = out[ 7]; - tmps[gid].pim_key[i + 8] = out[ 8]; - tmps[gid].pim_key[i + 9] = out[ 9]; - tmps[gid].pim_key[i + 10] = out[10]; - tmps[gid].pim_key[i + 11] = out[11]; - tmps[gid].pim_key[i + 12] = out[12]; - tmps[gid].pim_key[i + 13] = out[13]; - tmps[gid].pim_key[i + 14] = out[14]; - tmps[gid].pim_key[i + 15] = out[15]; + unpackv (tmps, pim_key, gid, i + 0, out[ 0]); + unpackv (tmps, pim_key, gid, i + 1, out[ 1]); + unpackv (tmps, pim_key, gid, i + 2, out[ 2]); + unpackv (tmps, pim_key, gid, i + 3, out[ 3]); + unpackv (tmps, pim_key, gid, i + 4, out[ 4]); + unpackv (tmps, pim_key, gid, i + 5, out[ 5]); + unpackv (tmps, pim_key, gid, i + 6, out[ 6]); + unpackv (tmps, pim_key, gid, i + 7, out[ 7]); + unpackv (tmps, pim_key, gid, i + 8, out[ 8]); + unpackv (tmps, pim_key, gid, i + 9, out[ 9]); + unpackv (tmps, pim_key, gid, i + 10, out[10]); + unpackv (tmps, pim_key, gid, i + 11, out[11]); + unpackv (tmps, pim_key, gid, i + 12, out[12]); + unpackv (tmps, pim_key, gid, i + 13, out[13]); + unpackv (tmps, pim_key, gid, i + 14, out[14]); + unpackv (tmps, pim_key, gid, i + 15, out[15]); + + tmps[gid].pim_check = pim; } } @@ -765,11 +723,83 @@ KERNEL_FQ void m13732_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 14, out[14]); unpackv (tmps, out, gid, i + 15, out[15]); } +} - if (pim == 0) return; +KERNEL_FQ void m13732_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13732_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) @@ -829,45 +859,6 @@ KERNEL_FQ void m13732_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) #endif - /** - * Whirlpool shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; - - #endif - if (gid >= gid_max) return; if (tmps[gid].pim) diff --git a/OpenCL/m13733-pure.cl b/OpenCL/m13733-pure.cl index 79c8767cd..e39be38e3 100644 --- a/OpenCL/m13733-pure.cl +++ b/OpenCL/m13733-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -202,7 +203,7 @@ DECLSPEC int check_header_1536 (GLOBAL_AS const vc_t *esalt_bufs, GLOBAL_AS u32 return -1; } -DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u32 (*s_Ch)[256], SHM_TYPE u32 (*s_Cl)[256]) +DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest, SHM_TYPE u64 *s_MT0, SHM_TYPE u64 *s_MT1, SHM_TYPE u64 *s_MT2, SHM_TYPE u64 *s_MT3, SHM_TYPE u64 *s_MT4, SHM_TYPE u64 *s_MT5, SHM_TYPE u64 *s_MT6, SHM_TYPE u64 *s_MT7) { digest[ 0] = ipad[ 0]; digest[ 1] = ipad[ 1]; @@ -221,7 +222,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = ipad[14]; digest[15] = ipad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -240,7 +241,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = digest[ 0]; w0[1] = digest[ 1]; @@ -276,7 +277,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x digest[14] = opad[14]; digest[15] = opad[15]; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); w0[0] = 0x80000000; w0[1] = 0; @@ -295,7 +296,7 @@ DECLSPEC void hmac_whirlpool_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x w3[2] = 0; w3[3] = (64 + 64) * 8; - whirlpool_transform_vector (w0, w1, w2, w3, digest, s_Ch, s_Cl); + whirlpool_transform_vector (w0, w1, w2, w3, digest, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); } KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) @@ -325,36 +326,39 @@ KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -426,7 +430,7 @@ KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_Ch, s_Cl); + whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -531,93 +535,45 @@ KERNEL_FQ void m13733_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - /** * Whirlpool shared */ #ifdef REAL_SHM - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; for (u32 i = lid; i < 256; i += lsz) { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; } SYNC_THREADS (); #else - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; #endif @@ -754,7 +710,7 @@ KERNEL_FQ void m13733_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) w3[2] = dgst[14]; w3[3] = dgst[15]; - hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_Ch, s_Cl); + hmac_whirlpool_run_V (w0, w1, w2, w3, ipad, opad, dgst, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); out[ 0] ^= dgst[ 0]; out[ 1] ^= dgst[ 1]; @@ -777,22 +733,24 @@ KERNEL_FQ void m13733_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[ 0]; - tmps[gid].pim_key[i + 1] = out[ 1]; - tmps[gid].pim_key[i + 2] = out[ 2]; - tmps[gid].pim_key[i + 3] = out[ 3]; - tmps[gid].pim_key[i + 4] = out[ 4]; - tmps[gid].pim_key[i + 5] = out[ 5]; - tmps[gid].pim_key[i + 6] = out[ 6]; - tmps[gid].pim_key[i + 7] = out[ 7]; - tmps[gid].pim_key[i + 8] = out[ 8]; - tmps[gid].pim_key[i + 9] = out[ 9]; - tmps[gid].pim_key[i + 10] = out[10]; - tmps[gid].pim_key[i + 11] = out[11]; - tmps[gid].pim_key[i + 12] = out[12]; - tmps[gid].pim_key[i + 13] = out[13]; - tmps[gid].pim_key[i + 14] = out[14]; - tmps[gid].pim_key[i + 15] = out[15]; + unpackv (tmps, pim_key, gid, i + 0, out[ 0]); + unpackv (tmps, pim_key, gid, i + 1, out[ 1]); + unpackv (tmps, pim_key, gid, i + 2, out[ 2]); + unpackv (tmps, pim_key, gid, i + 3, out[ 3]); + unpackv (tmps, pim_key, gid, i + 4, out[ 4]); + unpackv (tmps, pim_key, gid, i + 5, out[ 5]); + unpackv (tmps, pim_key, gid, i + 6, out[ 6]); + unpackv (tmps, pim_key, gid, i + 7, out[ 7]); + unpackv (tmps, pim_key, gid, i + 8, out[ 8]); + unpackv (tmps, pim_key, gid, i + 9, out[ 9]); + unpackv (tmps, pim_key, gid, i + 10, out[10]); + unpackv (tmps, pim_key, gid, i + 11, out[11]); + unpackv (tmps, pim_key, gid, i + 12, out[12]); + unpackv (tmps, pim_key, gid, i + 13, out[13]); + unpackv (tmps, pim_key, gid, i + 14, out[14]); + unpackv (tmps, pim_key, gid, i + 15, out[15]); + + tmps[gid].pim_check = pim; } } @@ -830,12 +788,88 @@ KERNEL_FQ void m13733_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 14, out[14]); unpackv (tmps, out, gid, i + 15, out[15]); } +} - if (pim == 0) return; +KERNEL_FQ void m13733_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13733_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) @@ -895,45 +929,6 @@ KERNEL_FQ void m13733_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) #endif - /** - * Whirlpool shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_Ch[8][256]; - LOCAL_VK u32 s_Cl[8][256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_Ch[0][i] = Ch[0][i]; - s_Ch[1][i] = Ch[1][i]; - s_Ch[2][i] = Ch[2][i]; - s_Ch[3][i] = Ch[3][i]; - s_Ch[4][i] = Ch[4][i]; - s_Ch[5][i] = Ch[5][i]; - s_Ch[6][i] = Ch[6][i]; - s_Ch[7][i] = Ch[7][i]; - - s_Cl[0][i] = Cl[0][i]; - s_Cl[1][i] = Cl[1][i]; - s_Cl[2][i] = Cl[2][i]; - s_Cl[3][i] = Cl[3][i]; - s_Cl[4][i] = Cl[4][i]; - s_Cl[5][i] = Cl[5][i]; - s_Cl[6][i] = Cl[6][i]; - s_Cl[7][i] = Cl[7][i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a (*s_Ch)[256] = Ch; - CONSTANT_AS u32a (*s_Cl)[256] = Cl; - - #endif - if (gid >= gid_max) return; if (tmps[gid].pim) diff --git a/OpenCL/m13751-pure.cl b/OpenCL/m13751-pure.cl index 405d5c277..fef508f58 100644 --- a/OpenCL/m13751-pure.cl +++ b/OpenCL/m13751-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -287,61 +288,8 @@ KERNEL_FQ void m13751_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) KERNEL_FQ void m13751_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -486,14 +434,16 @@ KERNEL_FQ void m13751_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpackv (tmps, pim_key, gid, i + 0, out[0]); + unpackv (tmps, pim_key, gid, i + 1, out[1]); + unpackv (tmps, pim_key, gid, i + 2, out[2]); + unpackv (tmps, pim_key, gid, i + 3, out[3]); + unpackv (tmps, pim_key, gid, i + 4, out[4]); + unpackv (tmps, pim_key, gid, i + 5, out[5]); + unpackv (tmps, pim_key, gid, i + 6, out[6]); + unpackv (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -515,10 +465,78 @@ KERNEL_FQ void m13751_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 6, out[6]); unpackv (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13751_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13751_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) diff --git a/OpenCL/m13752-pure.cl b/OpenCL/m13752-pure.cl index fbc4c5574..786bbff9b 100644 --- a/OpenCL/m13752-pure.cl +++ b/OpenCL/m13752-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -338,61 +339,8 @@ KERNEL_FQ void m13752_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) KERNEL_FQ void m13752_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -508,14 +456,16 @@ KERNEL_FQ void m13752_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpackv (tmps, pim_key, gid, i + 0, out[0]); + unpackv (tmps, pim_key, gid, i + 1, out[1]); + unpackv (tmps, pim_key, gid, i + 2, out[2]); + unpackv (tmps, pim_key, gid, i + 3, out[3]); + unpackv (tmps, pim_key, gid, i + 4, out[4]); + unpackv (tmps, pim_key, gid, i + 5, out[5]); + unpackv (tmps, pim_key, gid, i + 6, out[6]); + unpackv (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -537,11 +487,83 @@ KERNEL_FQ void m13752_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 6, out[6]); unpackv (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13752_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13752_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) diff --git a/OpenCL/m13753-pure.cl b/OpenCL/m13753-pure.cl index 9e7fd752d..ba414dc58 100644 --- a/OpenCL/m13753-pure.cl +++ b/OpenCL/m13753-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -52,6 +52,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -403,61 +404,8 @@ KERNEL_FQ void m13753_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) KERNEL_FQ void m13753_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { const u64 gid = get_global_id (0); - const u64 lid = get_local_id (0); - const u64 lsz = get_local_size (0); - /** - * aes shared - */ - - #ifdef REAL_SHM - - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - - SYNC_THREADS (); - - #else - - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - - #endif - - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -573,14 +521,16 @@ KERNEL_FQ void m13753_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpackv (tmps, pim_key, gid, i + 0, out[0]); + unpackv (tmps, pim_key, gid, i + 1, out[1]); + unpackv (tmps, pim_key, gid, i + 2, out[2]); + unpackv (tmps, pim_key, gid, i + 3, out[3]); + unpackv (tmps, pim_key, gid, i + 4, out[4]); + unpackv (tmps, pim_key, gid, i + 5, out[5]); + unpackv (tmps, pim_key, gid, i + 6, out[6]); + unpackv (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -602,12 +552,88 @@ KERNEL_FQ void m13753_loop (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) unpackv (tmps, out, gid, i + 6, out[6]); unpackv (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13753_loop_extended (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13753_comp (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) diff --git a/OpenCL/m13771-pure.cl b/OpenCL/m13771-pure.cl index 821ab8141..14235fd43 100644 --- a/OpenCL/m13771-pure.cl +++ b/OpenCL/m13771-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -55,6 +55,7 @@ typedef struct vc64_sbog_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_sbog_tmp_t; @@ -380,33 +381,6 @@ KERNEL_FQ void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - LOCAL_VK u64a s_sbob_sl64[8][256]; for (u32 i = lid; i < 256; i += lsz) @@ -425,23 +399,11 @@ KERNEL_FQ void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) #else - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - CONSTANT_AS u64a (*s_sbob_sl64)[256] = sbob512_sl64; #endif - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -578,14 +540,16 @@ KERNEL_FQ void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpack64v (tmps, pim_key, gid, i + 0, out[0]); + unpack64v (tmps, pim_key, gid, i + 1, out[1]); + unpack64v (tmps, pim_key, gid, i + 2, out[2]); + unpack64v (tmps, pim_key, gid, i + 3, out[3]); + unpack64v (tmps, pim_key, gid, i + 4, out[4]); + unpack64v (tmps, pim_key, gid, i + 5, out[5]); + unpack64v (tmps, pim_key, gid, i + 6, out[6]); + unpack64v (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -607,10 +571,78 @@ KERNEL_FQ void m13771_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13771_loop_extended (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13771_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index 7e8ef5b83..72ebb4701 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -55,6 +55,7 @@ typedef struct vc64_sbog_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_sbog_tmp_t; @@ -431,33 +432,6 @@ KERNEL_FQ void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - LOCAL_VK u64a s_sbob_sl64[8][256]; for (u32 i = lid; i < 256; i += lsz) @@ -476,23 +450,11 @@ KERNEL_FQ void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) #else - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - CONSTANT_AS u64a (*s_sbob_sl64)[256] = sbob512_sl64; #endif - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -629,14 +591,16 @@ KERNEL_FQ void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpack64v (tmps, pim_key, gid, i + 0, out[0]); + unpack64v (tmps, pim_key, gid, i + 1, out[1]); + unpack64v (tmps, pim_key, gid, i + 2, out[2]); + unpack64v (tmps, pim_key, gid, i + 3, out[3]); + unpack64v (tmps, pim_key, gid, i + 4, out[4]); + unpack64v (tmps, pim_key, gid, i + 5, out[5]); + unpack64v (tmps, pim_key, gid, i + 6, out[6]); + unpack64v (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -658,11 +622,83 @@ KERNEL_FQ void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13772_loop_extended (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13772_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index 1fad87e9e..8463f792f 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -3,7 +3,7 @@ * License.....: MIT */ -//#define NEW_SIMD_CODE +#define NEW_SIMD_CODE #ifdef KERNEL_STATIC #include "inc_vendor.h" @@ -55,6 +55,7 @@ typedef struct vc64_sbog_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_sbog_tmp_t; @@ -496,33 +497,6 @@ KERNEL_FQ void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) #ifdef REAL_SHM - LOCAL_VK u32 s_td0[256]; - LOCAL_VK u32 s_td1[256]; - LOCAL_VK u32 s_td2[256]; - LOCAL_VK u32 s_td3[256]; - LOCAL_VK u32 s_td4[256]; - - LOCAL_VK u32 s_te0[256]; - LOCAL_VK u32 s_te1[256]; - LOCAL_VK u32 s_te2[256]; - LOCAL_VK u32 s_te3[256]; - LOCAL_VK u32 s_te4[256]; - - for (u32 i = lid; i < 256; i += lsz) - { - s_td0[i] = td0[i]; - s_td1[i] = td1[i]; - s_td2[i] = td2[i]; - s_td3[i] = td3[i]; - s_td4[i] = td4[i]; - - s_te0[i] = te0[i]; - s_te1[i] = te1[i]; - s_te2[i] = te2[i]; - s_te3[i] = te3[i]; - s_te4[i] = te4[i]; - } - LOCAL_VK u64a s_sbob_sl64[8][256]; for (u32 i = lid; i < 256; i += lsz) @@ -541,23 +515,11 @@ KERNEL_FQ void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) #else - CONSTANT_AS u32a *s_td0 = td0; - CONSTANT_AS u32a *s_td1 = td1; - CONSTANT_AS u32a *s_td2 = td2; - CONSTANT_AS u32a *s_td3 = td3; - CONSTANT_AS u32a *s_td4 = td4; - - CONSTANT_AS u32a *s_te0 = te0; - CONSTANT_AS u32a *s_te1 = te1; - CONSTANT_AS u32a *s_te2 = te2; - CONSTANT_AS u32a *s_te3 = te3; - CONSTANT_AS u32a *s_te4 = te4; - CONSTANT_AS u64a (*s_sbob_sl64)[256] = sbob512_sl64; #endif - if (gid >= gid_max) return; + if ((gid * VECT_SIZE) >= gid_max) return; // this is the pim range check // it is guaranteed that only 0 or 1 innerloops will match a "pim" mark (each 1000 iterations) @@ -694,14 +656,16 @@ KERNEL_FQ void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) if (j == pim_at) { - tmps[gid].pim_key[i + 0] = out[0]; - tmps[gid].pim_key[i + 1] = out[1]; - tmps[gid].pim_key[i + 2] = out[2]; - tmps[gid].pim_key[i + 3] = out[3]; - tmps[gid].pim_key[i + 4] = out[4]; - tmps[gid].pim_key[i + 5] = out[5]; - tmps[gid].pim_key[i + 6] = out[6]; - tmps[gid].pim_key[i + 7] = out[7]; + unpack64v (tmps, pim_key, gid, i + 0, out[0]); + unpack64v (tmps, pim_key, gid, i + 1, out[1]); + unpack64v (tmps, pim_key, gid, i + 2, out[2]); + unpack64v (tmps, pim_key, gid, i + 3, out[3]); + unpack64v (tmps, pim_key, gid, i + 4, out[4]); + unpack64v (tmps, pim_key, gid, i + 5, out[5]); + unpack64v (tmps, pim_key, gid, i + 6, out[6]); + unpack64v (tmps, pim_key, gid, i + 7, out[7]); + + tmps[gid].pim_check = pim; } } @@ -723,12 +687,88 @@ KERNEL_FQ void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) unpack64v (tmps, out, gid, i + 6, out[6]); unpack64v (tmps, out, gid, i + 7, out[7]); } +} - if (pim == 0) return; +KERNEL_FQ void m13773_loop_extended (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); - if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; - if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) tmps[gid].pim = pim; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + const u32 pim_check = tmps[gid].pim_check; + + if (pim_check) + { + if (check_header_0512 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1024 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + if (check_header_1536 (esalt_bufs, tmps[gid].pim_key, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4) != -1) + { + tmps[gid].pim = pim_check; + } + + tmps[gid].pim_check = 0; + } } KERNEL_FQ void m13773_comp (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) diff --git a/OpenCL/m14000_a3-pure.cl b/OpenCL/m14000_a3-pure.cl index 7d1b33e8a..5f3abca84 100644 --- a/OpenCL/m14000_a3-pure.cl +++ b/OpenCL/m14000_a3-pure.cl @@ -16,7 +16,6 @@ #define COMPARE_M "inc_comp_multi_bs.cl" #ifdef IS_NV -#undef _unroll #define KXX_DECL #endif @@ -1903,78 +1902,6 @@ KERNEL_FQ void m14000_mxx (KERN_ATTR_BITSLICE ()) u32 D62 = d62; u32 D63 = d63; - /** - * digest - */ - - const u32 s0 = digests_buf[0].digest_buf[0]; - const u32 s1 = digests_buf[0].digest_buf[1]; - - #define S00 (((s0 >> 0) & 1) ? -1 : 0) - #define S01 (((s0 >> 1) & 1) ? -1 : 0) - #define S02 (((s0 >> 2) & 1) ? -1 : 0) - #define S03 (((s0 >> 3) & 1) ? -1 : 0) - #define S04 (((s0 >> 4) & 1) ? -1 : 0) - #define S05 (((s0 >> 5) & 1) ? -1 : 0) - #define S06 (((s0 >> 6) & 1) ? -1 : 0) - #define S07 (((s0 >> 7) & 1) ? -1 : 0) - #define S08 (((s0 >> 8) & 1) ? -1 : 0) - #define S09 (((s0 >> 9) & 1) ? -1 : 0) - #define S10 (((s0 >> 10) & 1) ? -1 : 0) - #define S11 (((s0 >> 11) & 1) ? -1 : 0) - #define S12 (((s0 >> 12) & 1) ? -1 : 0) - #define S13 (((s0 >> 13) & 1) ? -1 : 0) - #define S14 (((s0 >> 14) & 1) ? -1 : 0) - #define S15 (((s0 >> 15) & 1) ? -1 : 0) - #define S16 (((s0 >> 16) & 1) ? -1 : 0) - #define S17 (((s0 >> 17) & 1) ? -1 : 0) - #define S18 (((s0 >> 18) & 1) ? -1 : 0) - #define S19 (((s0 >> 19) & 1) ? -1 : 0) - #define S20 (((s0 >> 20) & 1) ? -1 : 0) - #define S21 (((s0 >> 21) & 1) ? -1 : 0) - #define S22 (((s0 >> 22) & 1) ? -1 : 0) - #define S23 (((s0 >> 23) & 1) ? -1 : 0) - #define S24 (((s0 >> 24) & 1) ? -1 : 0) - #define S25 (((s0 >> 25) & 1) ? -1 : 0) - #define S26 (((s0 >> 26) & 1) ? -1 : 0) - #define S27 (((s0 >> 27) & 1) ? -1 : 0) - #define S28 (((s0 >> 28) & 1) ? -1 : 0) - #define S29 (((s0 >> 29) & 1) ? -1 : 0) - #define S30 (((s0 >> 30) & 1) ? -1 : 0) - #define S31 (((s0 >> 31) & 1) ? -1 : 0) - #define S32 (((s1 >> 0) & 1) ? -1 : 0) - #define S33 (((s1 >> 1) & 1) ? -1 : 0) - #define S34 (((s1 >> 2) & 1) ? -1 : 0) - #define S35 (((s1 >> 3) & 1) ? -1 : 0) - #define S36 (((s1 >> 4) & 1) ? -1 : 0) - #define S37 (((s1 >> 5) & 1) ? -1 : 0) - #define S38 (((s1 >> 6) & 1) ? -1 : 0) - #define S39 (((s1 >> 7) & 1) ? -1 : 0) - #define S40 (((s1 >> 8) & 1) ? -1 : 0) - #define S41 (((s1 >> 9) & 1) ? -1 : 0) - #define S42 (((s1 >> 10) & 1) ? -1 : 0) - #define S43 (((s1 >> 11) & 1) ? -1 : 0) - #define S44 (((s1 >> 12) & 1) ? -1 : 0) - #define S45 (((s1 >> 13) & 1) ? -1 : 0) - #define S46 (((s1 >> 14) & 1) ? -1 : 0) - #define S47 (((s1 >> 15) & 1) ? -1 : 0) - #define S48 (((s1 >> 16) & 1) ? -1 : 0) - #define S49 (((s1 >> 17) & 1) ? -1 : 0) - #define S50 (((s1 >> 18) & 1) ? -1 : 0) - #define S51 (((s1 >> 19) & 1) ? -1 : 0) - #define S52 (((s1 >> 20) & 1) ? -1 : 0) - #define S53 (((s1 >> 21) & 1) ? -1 : 0) - #define S54 (((s1 >> 22) & 1) ? -1 : 0) - #define S55 (((s1 >> 23) & 1) ? -1 : 0) - #define S56 (((s1 >> 24) & 1) ? -1 : 0) - #define S57 (((s1 >> 25) & 1) ? -1 : 0) - #define S58 (((s1 >> 26) & 1) ? -1 : 0) - #define S59 (((s1 >> 27) & 1) ? -1 : 0) - #define S60 (((s1 >> 28) & 1) ? -1 : 0) - #define S61 (((s1 >> 29) & 1) ? -1 : 0) - #define S62 (((s1 >> 30) & 1) ? -1 : 0) - #define S63 (((s1 >> 31) & 1) ? -1 : 0) - /** * base */ @@ -2043,230 +1970,227 @@ KERNEL_FQ void m14000_mxx (KERN_ATTR_BITSLICE ()) * inner loop */ - #ifdef IS_CUDA - const u32 pc_pos = (blockIdx.y * blockDim.y) + threadIdx.y; - #else - const u32 pc_pos = get_global_id (1); - #endif - - const u32 il_pos = pc_pos * 32; - - u32 k00 = K00; - u32 k01 = K01; - u32 k02 = K02; - u32 k03 = K03; - u32 k04 = K04; - u32 k05 = K05; - u32 k06 = K06; - u32 k07 = K07; - u32 k08 = K08; - u32 k09 = K09; - u32 k10 = K10; - u32 k11 = K11; - u32 k12 = K12; - u32 k13 = K13; - u32 k14 = K14; - u32 k15 = K15; - u32 k16 = K16; - u32 k17 = K17; - u32 k18 = K18; - u32 k19 = K19; - u32 k20 = K20; - u32 k21 = K21; - u32 k22 = K22; - u32 k23 = K23; - u32 k24 = K24; - u32 k25 = K25; - u32 k26 = K26; - u32 k27 = K27; - - k00 |= words_buf_s[pc_pos].b[ 0]; - k01 |= words_buf_s[pc_pos].b[ 1]; - k02 |= words_buf_s[pc_pos].b[ 2]; - k03 |= words_buf_s[pc_pos].b[ 3]; - k04 |= words_buf_s[pc_pos].b[ 4]; - k05 |= words_buf_s[pc_pos].b[ 5]; - k06 |= words_buf_s[pc_pos].b[ 6]; - k07 |= words_buf_s[pc_pos].b[ 7]; - k08 |= words_buf_s[pc_pos].b[ 8]; - k09 |= words_buf_s[pc_pos].b[ 9]; - k10 |= words_buf_s[pc_pos].b[10]; - k11 |= words_buf_s[pc_pos].b[11]; - k12 |= words_buf_s[pc_pos].b[12]; - k13 |= words_buf_s[pc_pos].b[13]; - k14 |= words_buf_s[pc_pos].b[14]; - k15 |= words_buf_s[pc_pos].b[15]; - k16 |= words_buf_s[pc_pos].b[16]; - k17 |= words_buf_s[pc_pos].b[17]; - k18 |= words_buf_s[pc_pos].b[18]; - k19 |= words_buf_s[pc_pos].b[19]; - k20 |= words_buf_s[pc_pos].b[20]; - k21 |= words_buf_s[pc_pos].b[21]; - k22 |= words_buf_s[pc_pos].b[22]; - k23 |= words_buf_s[pc_pos].b[23]; - k24 |= words_buf_s[pc_pos].b[24]; - k25 |= words_buf_s[pc_pos].b[25]; - k26 |= words_buf_s[pc_pos].b[26]; - k27 |= words_buf_s[pc_pos].b[27]; - - DES - ( - k00, k01, k02, k03, k04, k05, k06, - k07, k08, k09, k10, k11, k12, k13, - k14, k15, k16, k17, k18, k19, k20, - k21, k22, k23, k24, k25, k26, k27, - K28, K29, K30, K31, K32, K33, K34, - K35, K36, K37, K38, K39, K40, K41, - K42, K43, K44, K45, K46, K47, K48, - K49, K50, K51, K52, K53, K54, K55, - &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, - &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, - &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, - &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, - &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, - &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, - &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, - &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 - ); - - u32 out[64]; - - out[ 0] = D00; - out[ 1] = D01; - out[ 2] = D02; - out[ 3] = D03; - out[ 4] = D04; - out[ 5] = D05; - out[ 6] = D06; - out[ 7] = D07; - out[ 8] = D08; - out[ 9] = D09; - out[10] = D10; - out[11] = D11; - out[12] = D12; - out[13] = D13; - out[14] = D14; - out[15] = D15; - out[16] = D16; - out[17] = D17; - out[18] = D18; - out[19] = D19; - out[20] = D20; - out[21] = D21; - out[22] = D22; - out[23] = D23; - out[24] = D24; - out[25] = D25; - out[26] = D26; - out[27] = D27; - out[28] = D28; - out[29] = D29; - out[30] = D30; - out[31] = D31; - out[32] = D32; - out[33] = D33; - out[34] = D34; - out[35] = D35; - out[36] = D36; - out[37] = D37; - out[38] = D38; - out[39] = D39; - out[40] = D40; - out[41] = D41; - out[42] = D42; - out[43] = D43; - out[44] = D44; - out[45] = D45; - out[46] = D46; - out[47] = D47; - out[48] = D48; - out[49] = D49; - out[50] = D50; - out[51] = D51; - out[52] = D52; - out[53] = D53; - out[54] = D54; - out[55] = D55; - out[56] = D56; - out[57] = D57; - out[58] = D58; - out[59] = D59; - out[60] = D60; - out[61] = D61; - out[62] = D62; - out[63] = D63; - - if (digests_cnt < 16) + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += 32) { - for (u32 d = 0; d < digests_cnt; d++) + u32 k00 = K00; + u32 k01 = K01; + u32 k02 = K02; + u32 k03 = K03; + u32 k04 = K04; + u32 k05 = K05; + u32 k06 = K06; + u32 k07 = K07; + u32 k08 = K08; + u32 k09 = K09; + u32 k10 = K10; + u32 k11 = K11; + u32 k12 = K12; + u32 k13 = K13; + u32 k14 = K14; + u32 k15 = K15; + u32 k16 = K16; + u32 k17 = K17; + u32 k18 = K18; + u32 k19 = K19; + u32 k20 = K20; + u32 k21 = K21; + u32 k22 = K22; + u32 k23 = K23; + u32 k24 = K24; + u32 k25 = K25; + u32 k26 = K26; + u32 k27 = K27; + + const u32 pc_pos = il_pos / 32; + + k00 |= words_buf_s[pc_pos].b[ 0]; + k01 |= words_buf_s[pc_pos].b[ 1]; + k02 |= words_buf_s[pc_pos].b[ 2]; + k03 |= words_buf_s[pc_pos].b[ 3]; + k04 |= words_buf_s[pc_pos].b[ 4]; + k05 |= words_buf_s[pc_pos].b[ 5]; + k06 |= words_buf_s[pc_pos].b[ 6]; + k07 |= words_buf_s[pc_pos].b[ 7]; + k08 |= words_buf_s[pc_pos].b[ 8]; + k09 |= words_buf_s[pc_pos].b[ 9]; + k10 |= words_buf_s[pc_pos].b[10]; + k11 |= words_buf_s[pc_pos].b[11]; + k12 |= words_buf_s[pc_pos].b[12]; + k13 |= words_buf_s[pc_pos].b[13]; + k14 |= words_buf_s[pc_pos].b[14]; + k15 |= words_buf_s[pc_pos].b[15]; + k16 |= words_buf_s[pc_pos].b[16]; + k17 |= words_buf_s[pc_pos].b[17]; + k18 |= words_buf_s[pc_pos].b[18]; + k19 |= words_buf_s[pc_pos].b[19]; + k20 |= words_buf_s[pc_pos].b[20]; + k21 |= words_buf_s[pc_pos].b[21]; + k22 |= words_buf_s[pc_pos].b[22]; + k23 |= words_buf_s[pc_pos].b[23]; + k24 |= words_buf_s[pc_pos].b[24]; + k25 |= words_buf_s[pc_pos].b[25]; + k26 |= words_buf_s[pc_pos].b[26]; + k27 |= words_buf_s[pc_pos].b[27]; + + DES + ( + k00, k01, k02, k03, k04, k05, k06, + k07, k08, k09, k10, k11, k12, k13, + k14, k15, k16, k17, k18, k19, k20, + k21, k22, k23, k24, k25, k26, k27, + K28, K29, K30, K31, K32, K33, K34, + K35, K36, K37, K38, K39, K40, K41, + K42, K43, K44, K45, K46, K47, K48, + K49, K50, K51, K52, K53, K54, K55, + &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, + &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, + &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, + &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, + &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, + &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, + &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, + &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 + ); + + u32 out[64]; + + out[ 0] = D00; + out[ 1] = D01; + out[ 2] = D02; + out[ 3] = D03; + out[ 4] = D04; + out[ 5] = D05; + out[ 6] = D06; + out[ 7] = D07; + out[ 8] = D08; + out[ 9] = D09; + out[10] = D10; + out[11] = D11; + out[12] = D12; + out[13] = D13; + out[14] = D14; + out[15] = D15; + out[16] = D16; + out[17] = D17; + out[18] = D18; + out[19] = D19; + out[20] = D20; + out[21] = D21; + out[22] = D22; + out[23] = D23; + out[24] = D24; + out[25] = D25; + out[26] = D26; + out[27] = D27; + out[28] = D28; + out[29] = D29; + out[30] = D30; + out[31] = D31; + out[32] = D32; + out[33] = D33; + out[34] = D34; + out[35] = D35; + out[36] = D36; + out[37] = D37; + out[38] = D38; + out[39] = D39; + out[40] = D40; + out[41] = D41; + out[42] = D42; + out[43] = D43; + out[44] = D44; + out[45] = D45; + out[46] = D46; + out[47] = D47; + out[48] = D48; + out[49] = D49; + out[50] = D50; + out[51] = D51; + out[52] = D52; + out[53] = D53; + out[54] = D54; + out[55] = D55; + out[56] = D56; + out[57] = D57; + out[58] = D58; + out[59] = D59; + out[60] = D60; + out[61] = D61; + out[62] = D62; + out[63] = D63; + + if (digests_cnt < 16) { - const u32 final_hash_pos = digests_offset + d; + for (u32 d = 0; d < digests_cnt; d++) + { + const u32 final_hash_pos = digests_offset + d; - if (hashes_shown[final_hash_pos]) continue; + if (hashes_shown[final_hash_pos]) continue; - u32 search[2]; + u32 search[2]; - search[0] = digests_buf[final_hash_pos].digest_buf[DGST_R0]; - search[1] = digests_buf[final_hash_pos].digest_buf[DGST_R1]; + search[0] = digests_buf[final_hash_pos].digest_buf[DGST_R0]; + search[1] = digests_buf[final_hash_pos].digest_buf[DGST_R1]; - u32 tmpResult = 0; + u32 tmpResult = 0; + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 0; i < 32; i++) + { + const u32 b0 = -((search[0] >> i) & 1); + const u32 b1 = -((search[1] >> i) & 1); + + tmpResult |= out[ 0 + i] ^ b0; + tmpResult |= out[32 + i] ^ b1; + } + + if (tmpResult == 0xffffffff) continue; + + const u32 slice = ffz (tmpResult); + + const u32 r0 = search[0]; + const u32 r1 = search[1]; + const u32 r2 = 0; + const u32 r3 = 0; + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif + } + } + else + { + u32 out0[32]; + u32 out1[32]; #ifdef _unroll #pragma unroll #endif for (int i = 0; i < 32; i++) { - const u32 b0 = -((search[0] >> i) & 1); - const u32 b1 = -((search[1] >> i) & 1); - - tmpResult |= out[ 0 + i] ^ b0; - tmpResult |= out[32 + i] ^ b1; + out0[i] = out[ 0 + i]; + out1[i] = out[32 + i]; } - if (tmpResult == 0xffffffff) continue; + transpose32c (out0); + transpose32c (out1); - const u32 slice = ffz (tmpResult); - - const u32 r0 = search[0]; - const u32 r1 = search[1]; - const u32 r2 = 0; - const u32 r3 = 0; - - #ifdef KERNEL_STATIC - #include COMPARE_M + #ifdef _unroll + #pragma unroll #endif - } - } - else - { - u32 out0[32]; - u32 out1[32]; + for (int slice = 0; slice < 32; slice++) + { + const u32 r0 = out0[slice]; + const u32 r1 = out1[slice]; + const u32 r2 = 0; + const u32 r3 = 0; - #ifdef _unroll - #pragma unroll - #endif - for (int i = 0; i < 32; i++) - { - out0[i] = out[ 0 + i]; - out1[i] = out[32 + i]; - } - - transpose32c (out0); - transpose32c (out1); - - #ifdef _unroll - #pragma unroll - #endif - for (int slice = 0; slice < 32; slice++) - { - const u32 r0 = out0[slice]; - const u32 r1 = out1[slice]; - const u32 r2 = 0; - const u32 r3 = 0; - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif + } } } } @@ -2426,70 +2350,70 @@ KERNEL_FQ void m14000_sxx (KERN_ATTR_BITSLICE ()) const u32 s0 = digests_buf[0].digest_buf[0]; const u32 s1 = digests_buf[0].digest_buf[1]; - #define S00 (((s0 >> 0) & 1) ? -1 : 0) - #define S01 (((s0 >> 1) & 1) ? -1 : 0) - #define S02 (((s0 >> 2) & 1) ? -1 : 0) - #define S03 (((s0 >> 3) & 1) ? -1 : 0) - #define S04 (((s0 >> 4) & 1) ? -1 : 0) - #define S05 (((s0 >> 5) & 1) ? -1 : 0) - #define S06 (((s0 >> 6) & 1) ? -1 : 0) - #define S07 (((s0 >> 7) & 1) ? -1 : 0) - #define S08 (((s0 >> 8) & 1) ? -1 : 0) - #define S09 (((s0 >> 9) & 1) ? -1 : 0) - #define S10 (((s0 >> 10) & 1) ? -1 : 0) - #define S11 (((s0 >> 11) & 1) ? -1 : 0) - #define S12 (((s0 >> 12) & 1) ? -1 : 0) - #define S13 (((s0 >> 13) & 1) ? -1 : 0) - #define S14 (((s0 >> 14) & 1) ? -1 : 0) - #define S15 (((s0 >> 15) & 1) ? -1 : 0) - #define S16 (((s0 >> 16) & 1) ? -1 : 0) - #define S17 (((s0 >> 17) & 1) ? -1 : 0) - #define S18 (((s0 >> 18) & 1) ? -1 : 0) - #define S19 (((s0 >> 19) & 1) ? -1 : 0) - #define S20 (((s0 >> 20) & 1) ? -1 : 0) - #define S21 (((s0 >> 21) & 1) ? -1 : 0) - #define S22 (((s0 >> 22) & 1) ? -1 : 0) - #define S23 (((s0 >> 23) & 1) ? -1 : 0) - #define S24 (((s0 >> 24) & 1) ? -1 : 0) - #define S25 (((s0 >> 25) & 1) ? -1 : 0) - #define S26 (((s0 >> 26) & 1) ? -1 : 0) - #define S27 (((s0 >> 27) & 1) ? -1 : 0) - #define S28 (((s0 >> 28) & 1) ? -1 : 0) - #define S29 (((s0 >> 29) & 1) ? -1 : 0) - #define S30 (((s0 >> 30) & 1) ? -1 : 0) - #define S31 (((s0 >> 31) & 1) ? -1 : 0) - #define S32 (((s1 >> 0) & 1) ? -1 : 0) - #define S33 (((s1 >> 1) & 1) ? -1 : 0) - #define S34 (((s1 >> 2) & 1) ? -1 : 0) - #define S35 (((s1 >> 3) & 1) ? -1 : 0) - #define S36 (((s1 >> 4) & 1) ? -1 : 0) - #define S37 (((s1 >> 5) & 1) ? -1 : 0) - #define S38 (((s1 >> 6) & 1) ? -1 : 0) - #define S39 (((s1 >> 7) & 1) ? -1 : 0) - #define S40 (((s1 >> 8) & 1) ? -1 : 0) - #define S41 (((s1 >> 9) & 1) ? -1 : 0) - #define S42 (((s1 >> 10) & 1) ? -1 : 0) - #define S43 (((s1 >> 11) & 1) ? -1 : 0) - #define S44 (((s1 >> 12) & 1) ? -1 : 0) - #define S45 (((s1 >> 13) & 1) ? -1 : 0) - #define S46 (((s1 >> 14) & 1) ? -1 : 0) - #define S47 (((s1 >> 15) & 1) ? -1 : 0) - #define S48 (((s1 >> 16) & 1) ? -1 : 0) - #define S49 (((s1 >> 17) & 1) ? -1 : 0) - #define S50 (((s1 >> 18) & 1) ? -1 : 0) - #define S51 (((s1 >> 19) & 1) ? -1 : 0) - #define S52 (((s1 >> 20) & 1) ? -1 : 0) - #define S53 (((s1 >> 21) & 1) ? -1 : 0) - #define S54 (((s1 >> 22) & 1) ? -1 : 0) - #define S55 (((s1 >> 23) & 1) ? -1 : 0) - #define S56 (((s1 >> 24) & 1) ? -1 : 0) - #define S57 (((s1 >> 25) & 1) ? -1 : 0) - #define S58 (((s1 >> 26) & 1) ? -1 : 0) - #define S59 (((s1 >> 27) & 1) ? -1 : 0) - #define S60 (((s1 >> 28) & 1) ? -1 : 0) - #define S61 (((s1 >> 29) & 1) ? -1 : 0) - #define S62 (((s1 >> 30) & 1) ? -1 : 0) - #define S63 (((s1 >> 31) & 1) ? -1 : 0) + const u32 S00 = (((s0 >> 0) & 1) ? -1 : 0); + const u32 S01 = (((s0 >> 1) & 1) ? -1 : 0); + const u32 S02 = (((s0 >> 2) & 1) ? -1 : 0); + const u32 S03 = (((s0 >> 3) & 1) ? -1 : 0); + const u32 S04 = (((s0 >> 4) & 1) ? -1 : 0); + const u32 S05 = (((s0 >> 5) & 1) ? -1 : 0); + const u32 S06 = (((s0 >> 6) & 1) ? -1 : 0); + const u32 S07 = (((s0 >> 7) & 1) ? -1 : 0); + const u32 S08 = (((s0 >> 8) & 1) ? -1 : 0); + const u32 S09 = (((s0 >> 9) & 1) ? -1 : 0); + const u32 S10 = (((s0 >> 10) & 1) ? -1 : 0); + const u32 S11 = (((s0 >> 11) & 1) ? -1 : 0); + const u32 S12 = (((s0 >> 12) & 1) ? -1 : 0); + const u32 S13 = (((s0 >> 13) & 1) ? -1 : 0); + const u32 S14 = (((s0 >> 14) & 1) ? -1 : 0); + const u32 S15 = (((s0 >> 15) & 1) ? -1 : 0); + const u32 S16 = (((s0 >> 16) & 1) ? -1 : 0); + const u32 S17 = (((s0 >> 17) & 1) ? -1 : 0); + const u32 S18 = (((s0 >> 18) & 1) ? -1 : 0); + const u32 S19 = (((s0 >> 19) & 1) ? -1 : 0); + const u32 S20 = (((s0 >> 20) & 1) ? -1 : 0); + const u32 S21 = (((s0 >> 21) & 1) ? -1 : 0); + const u32 S22 = (((s0 >> 22) & 1) ? -1 : 0); + const u32 S23 = (((s0 >> 23) & 1) ? -1 : 0); + const u32 S24 = (((s0 >> 24) & 1) ? -1 : 0); + const u32 S25 = (((s0 >> 25) & 1) ? -1 : 0); + const u32 S26 = (((s0 >> 26) & 1) ? -1 : 0); + const u32 S27 = (((s0 >> 27) & 1) ? -1 : 0); + const u32 S28 = (((s0 >> 28) & 1) ? -1 : 0); + const u32 S29 = (((s0 >> 29) & 1) ? -1 : 0); + const u32 S30 = (((s0 >> 30) & 1) ? -1 : 0); + const u32 S31 = (((s0 >> 31) & 1) ? -1 : 0); + const u32 S32 = (((s1 >> 0) & 1) ? -1 : 0); + const u32 S33 = (((s1 >> 1) & 1) ? -1 : 0); + const u32 S34 = (((s1 >> 2) & 1) ? -1 : 0); + const u32 S35 = (((s1 >> 3) & 1) ? -1 : 0); + const u32 S36 = (((s1 >> 4) & 1) ? -1 : 0); + const u32 S37 = (((s1 >> 5) & 1) ? -1 : 0); + const u32 S38 = (((s1 >> 6) & 1) ? -1 : 0); + const u32 S39 = (((s1 >> 7) & 1) ? -1 : 0); + const u32 S40 = (((s1 >> 8) & 1) ? -1 : 0); + const u32 S41 = (((s1 >> 9) & 1) ? -1 : 0); + const u32 S42 = (((s1 >> 10) & 1) ? -1 : 0); + const u32 S43 = (((s1 >> 11) & 1) ? -1 : 0); + const u32 S44 = (((s1 >> 12) & 1) ? -1 : 0); + const u32 S45 = (((s1 >> 13) & 1) ? -1 : 0); + const u32 S46 = (((s1 >> 14) & 1) ? -1 : 0); + const u32 S47 = (((s1 >> 15) & 1) ? -1 : 0); + const u32 S48 = (((s1 >> 16) & 1) ? -1 : 0); + const u32 S49 = (((s1 >> 17) & 1) ? -1 : 0); + const u32 S50 = (((s1 >> 18) & 1) ? -1 : 0); + const u32 S51 = (((s1 >> 19) & 1) ? -1 : 0); + const u32 S52 = (((s1 >> 20) & 1) ? -1 : 0); + const u32 S53 = (((s1 >> 21) & 1) ? -1 : 0); + const u32 S54 = (((s1 >> 22) & 1) ? -1 : 0); + const u32 S55 = (((s1 >> 23) & 1) ? -1 : 0); + const u32 S56 = (((s1 >> 24) & 1) ? -1 : 0); + const u32 S57 = (((s1 >> 25) & 1) ? -1 : 0); + const u32 S58 = (((s1 >> 26) & 1) ? -1 : 0); + const u32 S59 = (((s1 >> 27) & 1) ? -1 : 0); + const u32 S60 = (((s1 >> 28) & 1) ? -1 : 0); + const u32 S61 = (((s1 >> 29) & 1) ? -1 : 0); + const u32 S62 = (((s1 >> 30) & 1) ? -1 : 0); + const u32 S63 = (((s1 >> 31) & 1) ? -1 : 0); /** * base @@ -2559,173 +2483,170 @@ KERNEL_FQ void m14000_sxx (KERN_ATTR_BITSLICE ()) * inner loop */ - #ifdef IS_CUDA - const u32 pc_pos = (blockIdx.y * blockDim.y) + threadIdx.y; - #else - const u32 pc_pos = get_global_id (1); - #endif + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += 32) + { + u32 k00 = K00; + u32 k01 = K01; + u32 k02 = K02; + u32 k03 = K03; + u32 k04 = K04; + u32 k05 = K05; + u32 k06 = K06; + u32 k07 = K07; + u32 k08 = K08; + u32 k09 = K09; + u32 k10 = K10; + u32 k11 = K11; + u32 k12 = K12; + u32 k13 = K13; + u32 k14 = K14; + u32 k15 = K15; + u32 k16 = K16; + u32 k17 = K17; + u32 k18 = K18; + u32 k19 = K19; + u32 k20 = K20; + u32 k21 = K21; + u32 k22 = K22; + u32 k23 = K23; + u32 k24 = K24; + u32 k25 = K25; + u32 k26 = K26; + u32 k27 = K27; - const u32 il_pos = pc_pos * 32; + const u32 pc_pos = il_pos / 32; - u32 k00 = K00; - u32 k01 = K01; - u32 k02 = K02; - u32 k03 = K03; - u32 k04 = K04; - u32 k05 = K05; - u32 k06 = K06; - u32 k07 = K07; - u32 k08 = K08; - u32 k09 = K09; - u32 k10 = K10; - u32 k11 = K11; - u32 k12 = K12; - u32 k13 = K13; - u32 k14 = K14; - u32 k15 = K15; - u32 k16 = K16; - u32 k17 = K17; - u32 k18 = K18; - u32 k19 = K19; - u32 k20 = K20; - u32 k21 = K21; - u32 k22 = K22; - u32 k23 = K23; - u32 k24 = K24; - u32 k25 = K25; - u32 k26 = K26; - u32 k27 = K27; + k00 |= words_buf_s[pc_pos].b[ 0]; + k01 |= words_buf_s[pc_pos].b[ 1]; + k02 |= words_buf_s[pc_pos].b[ 2]; + k03 |= words_buf_s[pc_pos].b[ 3]; + k04 |= words_buf_s[pc_pos].b[ 4]; + k05 |= words_buf_s[pc_pos].b[ 5]; + k06 |= words_buf_s[pc_pos].b[ 6]; + k07 |= words_buf_s[pc_pos].b[ 7]; + k08 |= words_buf_s[pc_pos].b[ 8]; + k09 |= words_buf_s[pc_pos].b[ 9]; + k10 |= words_buf_s[pc_pos].b[10]; + k11 |= words_buf_s[pc_pos].b[11]; + k12 |= words_buf_s[pc_pos].b[12]; + k13 |= words_buf_s[pc_pos].b[13]; + k14 |= words_buf_s[pc_pos].b[14]; + k15 |= words_buf_s[pc_pos].b[15]; + k16 |= words_buf_s[pc_pos].b[16]; + k17 |= words_buf_s[pc_pos].b[17]; + k18 |= words_buf_s[pc_pos].b[18]; + k19 |= words_buf_s[pc_pos].b[19]; + k20 |= words_buf_s[pc_pos].b[20]; + k21 |= words_buf_s[pc_pos].b[21]; + k22 |= words_buf_s[pc_pos].b[22]; + k23 |= words_buf_s[pc_pos].b[23]; + k24 |= words_buf_s[pc_pos].b[24]; + k25 |= words_buf_s[pc_pos].b[25]; + k26 |= words_buf_s[pc_pos].b[26]; + k27 |= words_buf_s[pc_pos].b[27]; - k00 |= words_buf_s[pc_pos].b[ 0]; - k01 |= words_buf_s[pc_pos].b[ 1]; - k02 |= words_buf_s[pc_pos].b[ 2]; - k03 |= words_buf_s[pc_pos].b[ 3]; - k04 |= words_buf_s[pc_pos].b[ 4]; - k05 |= words_buf_s[pc_pos].b[ 5]; - k06 |= words_buf_s[pc_pos].b[ 6]; - k07 |= words_buf_s[pc_pos].b[ 7]; - k08 |= words_buf_s[pc_pos].b[ 8]; - k09 |= words_buf_s[pc_pos].b[ 9]; - k10 |= words_buf_s[pc_pos].b[10]; - k11 |= words_buf_s[pc_pos].b[11]; - k12 |= words_buf_s[pc_pos].b[12]; - k13 |= words_buf_s[pc_pos].b[13]; - k14 |= words_buf_s[pc_pos].b[14]; - k15 |= words_buf_s[pc_pos].b[15]; - k16 |= words_buf_s[pc_pos].b[16]; - k17 |= words_buf_s[pc_pos].b[17]; - k18 |= words_buf_s[pc_pos].b[18]; - k19 |= words_buf_s[pc_pos].b[19]; - k20 |= words_buf_s[pc_pos].b[20]; - k21 |= words_buf_s[pc_pos].b[21]; - k22 |= words_buf_s[pc_pos].b[22]; - k23 |= words_buf_s[pc_pos].b[23]; - k24 |= words_buf_s[pc_pos].b[24]; - k25 |= words_buf_s[pc_pos].b[25]; - k26 |= words_buf_s[pc_pos].b[26]; - k27 |= words_buf_s[pc_pos].b[27]; + DES + ( + k00, k01, k02, k03, k04, k05, k06, + k07, k08, k09, k10, k11, k12, k13, + k14, k15, k16, k17, k18, k19, k20, + k21, k22, k23, k24, k25, k26, k27, + K28, K29, K30, K31, K32, K33, K34, + K35, K36, K37, K38, K39, K40, K41, + K42, K43, K44, K45, K46, K47, K48, + K49, K50, K51, K52, K53, K54, K55, + &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, + &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, + &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, + &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, + &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, + &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, + &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, + &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 + ); - DES - ( - k00, k01, k02, k03, k04, k05, k06, - k07, k08, k09, k10, k11, k12, k13, - k14, k15, k16, k17, k18, k19, k20, - k21, k22, k23, k24, k25, k26, k27, - K28, K29, K30, K31, K32, K33, K34, - K35, K36, K37, K38, K39, K40, K41, - K42, K43, K44, K45, K46, K47, K48, - K49, K50, K51, K52, K53, K54, K55, - &D00, &D01, &D02, &D03, &D04, &D05, &D06, &D07, - &D08, &D09, &D10, &D11, &D12, &D13, &D14, &D15, - &D16, &D17, &D18, &D19, &D20, &D21, &D22, &D23, - &D24, &D25, &D26, &D27, &D28, &D29, &D30, &D31, - &D32, &D33, &D34, &D35, &D36, &D37, &D38, &D39, - &D40, &D41, &D42, &D43, &D44, &D45, &D46, &D47, - &D48, &D49, &D50, &D51, &D52, &D53, &D54, &D55, - &D56, &D57, &D58, &D59, &D60, &D61, &D62, &D63 - ); + u32 tmpResult = 0; - u32 tmpResult = 0; + tmpResult |= D00 ^ S00; + tmpResult |= D01 ^ S01; + tmpResult |= D02 ^ S02; + tmpResult |= D03 ^ S03; + tmpResult |= D04 ^ S04; + tmpResult |= D05 ^ S05; + tmpResult |= D06 ^ S06; + tmpResult |= D07 ^ S07; + tmpResult |= D08 ^ S08; + tmpResult |= D09 ^ S09; + tmpResult |= D10 ^ S10; + tmpResult |= D11 ^ S11; + tmpResult |= D12 ^ S12; + tmpResult |= D13 ^ S13; + tmpResult |= D14 ^ S14; + tmpResult |= D15 ^ S15; - tmpResult |= D00 ^ S00; - tmpResult |= D01 ^ S01; - tmpResult |= D02 ^ S02; - tmpResult |= D03 ^ S03; - tmpResult |= D04 ^ S04; - tmpResult |= D05 ^ S05; - tmpResult |= D06 ^ S06; - tmpResult |= D07 ^ S07; - tmpResult |= D08 ^ S08; - tmpResult |= D09 ^ S09; - tmpResult |= D10 ^ S10; - tmpResult |= D11 ^ S11; - tmpResult |= D12 ^ S12; - tmpResult |= D13 ^ S13; - tmpResult |= D14 ^ S14; - tmpResult |= D15 ^ S15; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D16 ^ S16; + tmpResult |= D17 ^ S17; + tmpResult |= D18 ^ S18; + tmpResult |= D19 ^ S19; + tmpResult |= D20 ^ S20; + tmpResult |= D21 ^ S21; + tmpResult |= D22 ^ S22; + tmpResult |= D23 ^ S23; + tmpResult |= D24 ^ S24; + tmpResult |= D25 ^ S25; + tmpResult |= D26 ^ S26; + tmpResult |= D27 ^ S27; + tmpResult |= D28 ^ S28; + tmpResult |= D29 ^ S29; + tmpResult |= D30 ^ S30; + tmpResult |= D31 ^ S31; - tmpResult |= D16 ^ S16; - tmpResult |= D17 ^ S17; - tmpResult |= D18 ^ S18; - tmpResult |= D19 ^ S19; - tmpResult |= D20 ^ S20; - tmpResult |= D21 ^ S21; - tmpResult |= D22 ^ S22; - tmpResult |= D23 ^ S23; - tmpResult |= D24 ^ S24; - tmpResult |= D25 ^ S25; - tmpResult |= D26 ^ S26; - tmpResult |= D27 ^ S27; - tmpResult |= D28 ^ S28; - tmpResult |= D29 ^ S29; - tmpResult |= D30 ^ S30; - tmpResult |= D31 ^ S31; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D32 ^ S32; + tmpResult |= D33 ^ S33; + tmpResult |= D34 ^ S34; + tmpResult |= D35 ^ S35; + tmpResult |= D36 ^ S36; + tmpResult |= D37 ^ S37; + tmpResult |= D38 ^ S38; + tmpResult |= D39 ^ S39; + tmpResult |= D40 ^ S40; + tmpResult |= D41 ^ S41; + tmpResult |= D42 ^ S42; + tmpResult |= D43 ^ S43; + tmpResult |= D44 ^ S44; + tmpResult |= D45 ^ S45; + tmpResult |= D46 ^ S46; + tmpResult |= D47 ^ S47; - tmpResult |= D32 ^ S32; - tmpResult |= D33 ^ S33; - tmpResult |= D34 ^ S34; - tmpResult |= D35 ^ S35; - tmpResult |= D36 ^ S36; - tmpResult |= D37 ^ S37; - tmpResult |= D38 ^ S38; - tmpResult |= D39 ^ S39; - tmpResult |= D40 ^ S40; - tmpResult |= D41 ^ S41; - tmpResult |= D42 ^ S42; - tmpResult |= D43 ^ S43; - tmpResult |= D44 ^ S44; - tmpResult |= D45 ^ S45; - tmpResult |= D46 ^ S46; - tmpResult |= D47 ^ S47; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + tmpResult |= D48 ^ S48; + tmpResult |= D49 ^ S49; + tmpResult |= D50 ^ S50; + tmpResult |= D51 ^ S51; + tmpResult |= D52 ^ S52; + tmpResult |= D53 ^ S53; + tmpResult |= D54 ^ S54; + tmpResult |= D55 ^ S55; + tmpResult |= D56 ^ S56; + tmpResult |= D57 ^ S57; + tmpResult |= D58 ^ S58; + tmpResult |= D59 ^ S59; + tmpResult |= D60 ^ S60; + tmpResult |= D61 ^ S61; + tmpResult |= D62 ^ S62; + tmpResult |= D63 ^ S63; - tmpResult |= D48 ^ S48; - tmpResult |= D49 ^ S49; - tmpResult |= D50 ^ S50; - tmpResult |= D51 ^ S51; - tmpResult |= D52 ^ S52; - tmpResult |= D53 ^ S53; - tmpResult |= D54 ^ S54; - tmpResult |= D55 ^ S55; - tmpResult |= D56 ^ S56; - tmpResult |= D57 ^ S57; - tmpResult |= D58 ^ S58; - tmpResult |= D59 ^ S59; - tmpResult |= D60 ^ S60; - tmpResult |= D61 ^ S61; - tmpResult |= D62 ^ S62; - tmpResult |= D63 ^ S63; + if (tmpResult == 0xffffffff) continue; - if (tmpResult == 0xffffffff) return; + const u32 slice = ffz (tmpResult); - const u32 slice = ffz (tmpResult); - - #ifdef KERNEL_STATIC - #include COMPARE_S - #endif + #ifdef KERNEL_STATIC + #include COMPARE_S + #endif + } } diff --git a/OpenCL/m14100_a3-pure.cl b/OpenCL/m14100_a3-pure.cl index 4b46cf5e8..3722e271a 100644 --- a/OpenCL/m14100_a3-pure.cl +++ b/OpenCL/m14100_a3-pure.cl @@ -549,6 +549,26 @@ DECLSPEC void m14100m (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], salt_buf0[0] = salt_bufs[salt_pos].salt_buf_pc[0]; salt_buf0[1] = salt_bufs[salt_pos].salt_buf_pc[1]; + /** + * Precompute fixed key scheduler + */ + + const u32x c = (w[2]); + const u32x d = (w[3]); + + u32x Kc[16]; + u32x Kd[16]; + + _des_crypt_keysetup (c, d, Kc, Kd, s_skb); + + const u32x e = (w[4]); + const u32x f = (w[5]); + + u32x Ke[16]; + u32x Kf[16]; + + _des_crypt_keysetup (e, f, Ke, Kf, s_skb); + /** * loop */ @@ -584,28 +604,12 @@ DECLSPEC void m14100m (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], /* Second Pass */ - const u32x c = (w[2]); - const u32x d = (w[3]); - - u32x Kc[16]; - u32x Kd[16]; - - _des_crypt_keysetup (c, d, Kc, Kd, s_skb); - u32x p2[2]; _des_crypt_decrypt (p2, p1, Kc, Kd, s_SPtrans); /* Third Pass */ - const u32x e = (w[4]); - const u32x f = (w[5]); - - u32x Ke[16]; - u32x Kf[16]; - - _des_crypt_keysetup (e, f, Ke, Kf, s_skb); - u32x iv[2]; _des_crypt_encrypt (iv, p2, Ke, Kf, s_SPtrans); @@ -634,17 +638,60 @@ DECLSPEC void m14100s (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], salt_buf0[0] = salt_bufs[salt_pos].salt_buf_pc[0]; salt_buf0[1] = salt_bufs[salt_pos].salt_buf_pc[1]; + /** + * Precompute fixed key scheduler + */ + + u32x iv[2]; + + iv[0] = digests_buf[digests_offset].digest_buf[0]; + iv[1] = digests_buf[digests_offset].digest_buf[1]; + + const u32x e = (w[4]); + const u32x f = (w[5]); + + u32x Ke[16]; + u32x Kf[16]; + + _des_crypt_keysetup (e, f, Ke, Kf, s_skb); + + u32x p2[2]; + + _des_crypt_decrypt (p2, iv, Ke, Kf, s_SPtrans); + + const u32x c = (w[2]); + const u32x d = (w[3]); + + u32x Kc[16]; + u32x Kd[16]; + + _des_crypt_keysetup (c, d, Kc, Kd, s_skb); + + u32x p1[2]; + + _des_crypt_encrypt (p1, p2, Kc, Kd, s_SPtrans); + /** * digest */ + #if VECT_SIZE == 1 const u32 search[4] = { - digests_buf[digests_offset].digest_buf[DGST_R0], - digests_buf[digests_offset].digest_buf[DGST_R1], + p1[0], + p1[1], 0, 0 }; + #else + const u32 search[4] = + { + p1[0].s0, + p1[1].s0, + 0, + 0 + }; + #endif /** * loop @@ -679,37 +726,13 @@ DECLSPEC void m14100s (LOCAL_AS u32 (*s_SPtrans)[64], LOCAL_AS u32 (*s_skb)[64], _des_crypt_encrypt (p1, data, Ka, Kb, s_SPtrans); - /* Second Pass */ + /* Second Pass was precomputed */ - const u32x c = (w[2]); - const u32x d = (w[3]); - - u32x Kc[16]; - u32x Kd[16]; - - _des_crypt_keysetup (c, d, Kc, Kd, s_skb); - - u32x p2[2]; - - _des_crypt_decrypt (p2, p1, Kc, Kd, s_SPtrans); - - /* Third Pass */ - - const u32x e = (w[4]); - const u32x f = (w[5]); - - u32x Ke[16]; - u32x Kf[16]; - - _des_crypt_keysetup (e, f, Ke, Kf, s_skb); - - u32x iv[2]; - - _des_crypt_encrypt (iv, p2, Ke, Kf, s_SPtrans); + /* Third Pass was precomputed */ u32x z = 0; - COMPARE_S_SIMD (iv[0], iv[1], z, z); + COMPARE_S_SIMD (p1[0], p1[1], z, z); } } diff --git a/OpenCL/m15300-pure.cl b/OpenCL/m15300-pure.cl index 9a2b01cf3..f49c5c410 100644 --- a/OpenCL/m15300-pure.cl +++ b/OpenCL/m15300-pure.cl @@ -442,8 +442,6 @@ KERNEL_FQ void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) iv[0] = hc_swap32_S (tmps[gid].out[6]); iv[1] = hc_swap32_S (tmps[gid].out[7]); - u32 decrypted[26]; - /* Construct 3DES keys */ const u32 a = (key[0]); @@ -470,62 +468,123 @@ KERNEL_FQ void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) _des_crypt_keysetup (e, f, Ke, Kf, s_skb); - u32 contents_pos; - u32 contents_off; - u32 wx_off; + u32 p1[2]; + u32 p2[2]; + u32 out[2]; - for (wx_off = 0, contents_pos = 0, contents_off = 0; contents_pos < esalt_bufs[digests_offset].contents_len; wx_off += 2, contents_pos += 8, contents_off += 2) + u32 hmac_data[4]; + + hmac_data[0] = hc_swap32_S (esalt_bufs[digests_offset].contents[0]); + hmac_data[1] = hc_swap32_S (esalt_bufs[digests_offset].contents[1]); + hmac_data[2] = hc_swap32_S (esalt_bufs[digests_offset].contents[2]); + hmac_data[3] = hc_swap32_S (esalt_bufs[digests_offset].contents[3]); + + u32 expected_key[4]; + + expected_key[0] = hc_swap32_S (esalt_bufs[digests_offset].contents[4]); + expected_key[1] = hc_swap32_S (esalt_bufs[digests_offset].contents[5]); + expected_key[2] = hc_swap32_S (esalt_bufs[digests_offset].contents[6]); + expected_key[3] = hc_swap32_S (esalt_bufs[digests_offset].contents[7]); + + u32 last_iv[2]; + + last_iv[0] = hc_swap32_S (esalt_bufs[digests_offset].contents[8]); + last_iv[1] = hc_swap32_S (esalt_bufs[digests_offset].contents[9]); + + u32 last_key[16]; + + last_key[ 0] = hc_swap32_S (esalt_bufs[digests_offset].contents[10]); + last_key[ 1] = hc_swap32_S (esalt_bufs[digests_offset].contents[11]); + last_key[ 2] = hc_swap32_S (esalt_bufs[digests_offset].contents[12]); + last_key[ 3] = hc_swap32_S (esalt_bufs[digests_offset].contents[13]); + last_key[ 4] = hc_swap32_S (esalt_bufs[digests_offset].contents[14]); + last_key[ 5] = hc_swap32_S (esalt_bufs[digests_offset].contents[15]); + last_key[ 6] = hc_swap32_S (esalt_bufs[digests_offset].contents[16]); + last_key[ 7] = hc_swap32_S (esalt_bufs[digests_offset].contents[17]); + last_key[ 8] = hc_swap32_S (esalt_bufs[digests_offset].contents[18]); + last_key[ 9] = hc_swap32_S (esalt_bufs[digests_offset].contents[19]); + last_key[10] = hc_swap32_S (esalt_bufs[digests_offset].contents[20]); + last_key[11] = hc_swap32_S (esalt_bufs[digests_offset].contents[21]); + last_key[12] = hc_swap32_S (esalt_bufs[digests_offset].contents[22]); + last_key[13] = hc_swap32_S (esalt_bufs[digests_offset].contents[23]); + last_key[14] = hc_swap32_S (esalt_bufs[digests_offset].contents[24]); + last_key[15] = hc_swap32_S (esalt_bufs[digests_offset].contents[25]); + + // hmac_data + + _des_crypt_decrypt (p1, hmac_data + 0, Ke, Kf, s_SPtrans); + _des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans); + _des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + + iv[0] = hmac_data[0]; + iv[1] = hmac_data[1]; + + hmac_data[0] = out[0]; + hmac_data[1] = out[1]; + + _des_crypt_decrypt (p1, hmac_data + 2, Ke, Kf, s_SPtrans); + _des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans); + _des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + + iv[0] = hmac_data[2]; + iv[1] = hmac_data[3]; + + hmac_data[2] = out[0]; + hmac_data[3] = out[1]; + + // expected_key + + _des_crypt_decrypt (p1, expected_key + 0, Ke, Kf, s_SPtrans); + _des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans); + _des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + + iv[0] = expected_key[0]; + iv[1] = expected_key[1]; + + expected_key[0] = out[0]; + expected_key[1] = out[1]; + + _des_crypt_decrypt (p1, expected_key + 2, Ke, Kf, s_SPtrans); + _des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans); + _des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + + iv[0] = expected_key[2]; + iv[1] = expected_key[3]; + + expected_key[2] = out[0]; + expected_key[3] = out[1]; + + // last_key + + iv[0] = last_iv[0]; + iv[1] = last_iv[1]; + + for (int off = 0; off < 16; off += 2) { - /* First Pass */ - - u32 data[2]; - - data[0] = hc_swap32_S (esalt_bufs[digests_offset].contents[contents_off + 0]); - data[1] = hc_swap32_S (esalt_bufs[digests_offset].contents[contents_off + 1]); - - u32 p1[2]; - - _des_crypt_decrypt (p1, data, Ke, Kf, s_SPtrans); - - /* Second Pass */ - - u32 p2[2]; - - _des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans); - - /* Third Pass */ - - u32 out[2]; - - _des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans); + _des_crypt_decrypt (p1, last_key + off, Ke, Kf, s_SPtrans); + _des_crypt_encrypt (p2, p1, Kc, Kd, s_SPtrans); + _des_crypt_decrypt (out, p2, Ka, Kb, s_SPtrans); out[0] ^= iv[0]; out[1] ^= iv[1]; - decrypted[wx_off + 0] = out[0]; - decrypted[wx_off + 1] = out[1]; + iv[0] = last_key[off + 0]; + iv[1] = last_key[off + 1]; - iv[0] = data[0]; - iv[1] = data[1]; - } - - u32 hmacSalt[4]; - u32 expectedHmac[4]; - u32 lastKey[16]; - - hmacSalt[0] = hc_swap32_S (decrypted[0]); - hmacSalt[1] = hc_swap32_S (decrypted[1]); - hmacSalt[2] = hc_swap32_S (decrypted[2]); - hmacSalt[3] = hc_swap32_S (decrypted[3]); - - expectedHmac[0] = hc_swap32_S (decrypted[4 + 0]); - expectedHmac[1] = hc_swap32_S (decrypted[4 + 1]); - expectedHmac[2] = hc_swap32_S (decrypted[4 + 2]); - expectedHmac[3] = hc_swap32_S (decrypted[4 + 3]); - - for(int i = 0; i < 16; i++) - { - lastKey[i] = decrypted[i + 26 - 16]; + last_key[off + 0] = out[0]; + last_key[off + 1] = out[1]; } w0[0] = tmps[gid].userKey[0]; @@ -549,10 +608,10 @@ KERNEL_FQ void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) sha1_hmac_init_64 (&ctx, w0, w1, w2, w3); - w0[0] = hmacSalt[0]; - w0[1] = hmacSalt[1]; - w0[2] = hmacSalt[2]; - w0[3] = hmacSalt[3]; + w0[0] = hc_swap32_S (hmac_data[0]); + w0[1] = hc_swap32_S (hmac_data[1]); + w0[2] = hc_swap32_S (hmac_data[2]); + w0[3] = hc_swap32_S (hmac_data[3]); w1[0] = 0; w1[1] = 0; w1[2] = 0; @@ -589,22 +648,22 @@ KERNEL_FQ void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) sha1_hmac_init_64 (&ctx, w0, w1, w2, w3); - w0[0] = hc_swap32_S (lastKey[ 0]); - w0[1] = hc_swap32_S (lastKey[ 1]); - w0[2] = hc_swap32_S (lastKey[ 2]); - w0[3] = hc_swap32_S (lastKey[ 3]); - w1[0] = hc_swap32_S (lastKey[ 4]); - w1[1] = hc_swap32_S (lastKey[ 5]); - w1[2] = hc_swap32_S (lastKey[ 6]); - w1[3] = hc_swap32_S (lastKey[ 7]); - w2[0] = hc_swap32_S (lastKey[ 8]); - w2[1] = hc_swap32_S (lastKey[ 9]); - w2[2] = hc_swap32_S (lastKey[10]); - w2[3] = hc_swap32_S (lastKey[11]); - w3[0] = hc_swap32_S (lastKey[12]); - w3[1] = hc_swap32_S (lastKey[13]); - w3[2] = hc_swap32_S (lastKey[14]); - w3[3] = hc_swap32_S (lastKey[15]); + w0[0] = hc_swap32_S (last_key[ 0]); + w0[1] = hc_swap32_S (last_key[ 1]); + w0[2] = hc_swap32_S (last_key[ 2]); + w0[3] = hc_swap32_S (last_key[ 3]); + w1[0] = hc_swap32_S (last_key[ 4]); + w1[1] = hc_swap32_S (last_key[ 5]); + w1[2] = hc_swap32_S (last_key[ 6]); + w1[3] = hc_swap32_S (last_key[ 7]); + w2[0] = hc_swap32_S (last_key[ 8]); + w2[1] = hc_swap32_S (last_key[ 9]); + w2[2] = hc_swap32_S (last_key[10]); + w2[3] = hc_swap32_S (last_key[11]); + w3[0] = hc_swap32_S (last_key[12]); + w3[1] = hc_swap32_S (last_key[13]); + w3[2] = hc_swap32_S (last_key[14]); + w3[3] = hc_swap32_S (last_key[15]); sha1_hmac_update_64 (&ctx, w0, w1, w2, w3, 64); @@ -612,10 +671,10 @@ KERNEL_FQ void m15300_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v1_t, dpapimk_t)) #define il_pos 0 - if ((expectedHmac[0] == ctx.opad.h[0]) - && (expectedHmac[1] == ctx.opad.h[1]) - && (expectedHmac[2] == ctx.opad.h[2]) - && (expectedHmac[3] == ctx.opad.h[3])) + if ((expected_key[0] == hc_swap32_S (ctx.opad.h[0])) + && (expected_key[1] == hc_swap32_S (ctx.opad.h[1])) + && (expected_key[2] == hc_swap32_S (ctx.opad.h[2])) + && (expected_key[3] == hc_swap32_S (ctx.opad.h[3]))) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { diff --git a/OpenCL/m15400_a0-optimized.cl b/OpenCL/m15400_a0-optimized.cl index 294e086e0..c87d53ba2 100644 --- a/OpenCL/m15400_a0-optimized.cl +++ b/OpenCL/m15400_a0-optimized.cl @@ -128,9 +128,39 @@ DECLSPEC void chacha20_transform (const u32x *w0, const u32x *w1, const u32 *pos * Generate a second 64 byte keystream */ - ctx[12]++; + ctx[12] += 1; - if (all(ctx[12] == 0)) ctx[13]++; + #if VECT_SIZE == 1 + if (ctx[12] == 0) ctx[13] += 1; + #endif + + #if VECT_SIZE >= 2 + if (ctx[12].s0 == 0) ctx[13].s0 += 1; + if (ctx[12].s1 == 0) ctx[13].s1 += 1; + #endif + + #if VECT_SIZE >= 4 + if (ctx[12].s2 == 0) ctx[13].s2 += 1; + if (ctx[12].s3 == 0) ctx[13].s3 += 1; + #endif + + #if VECT_SIZE >= 8 + if (ctx[12].s4 == 0) ctx[13].s4 += 1; + if (ctx[12].s5 == 0) ctx[13].s5 += 1; + if (ctx[12].s6 == 0) ctx[13].s6 += 1; + if (ctx[12].s7 == 0) ctx[13].s7 += 1; + #endif + + #if VECT_SIZE >= 16 + if (ctx[12].s8 == 0) ctx[13].s8 += 1; + if (ctx[12].s9 == 0) ctx[13].s9 += 1; + if (ctx[12].sa == 0) ctx[13].sa += 1; + if (ctx[12].sb == 0) ctx[13].sb += 1; + if (ctx[12].sc == 0) ctx[13].sc += 1; + if (ctx[12].sd == 0) ctx[13].sd += 1; + if (ctx[12].se == 0) ctx[13].se += 1; + if (ctx[12].sf == 0) ctx[13].sf += 1; + #endif x[16] = ctx[ 0]; x[17] = ctx[ 1]; diff --git a/OpenCL/m15400_a1-optimized.cl b/OpenCL/m15400_a1-optimized.cl index 94de59707..7b1ab79c9 100644 --- a/OpenCL/m15400_a1-optimized.cl +++ b/OpenCL/m15400_a1-optimized.cl @@ -126,9 +126,39 @@ DECLSPEC void chacha20_transform (const u32x *w0, const u32x *w1, const u32 *pos * Generate a second 64 byte keystream */ - ctx[12]++; + ctx[12] += 1; - if (all(ctx[12] == 0)) ctx[13]++; + #if VECT_SIZE == 1 + if (ctx[12] == 0) ctx[13] += 1; + #endif + + #if VECT_SIZE >= 2 + if (ctx[12].s0 == 0) ctx[13].s0 += 1; + if (ctx[12].s1 == 0) ctx[13].s1 += 1; + #endif + + #if VECT_SIZE >= 4 + if (ctx[12].s2 == 0) ctx[13].s2 += 1; + if (ctx[12].s3 == 0) ctx[13].s3 += 1; + #endif + + #if VECT_SIZE >= 8 + if (ctx[12].s4 == 0) ctx[13].s4 += 1; + if (ctx[12].s5 == 0) ctx[13].s5 += 1; + if (ctx[12].s6 == 0) ctx[13].s6 += 1; + if (ctx[12].s7 == 0) ctx[13].s7 += 1; + #endif + + #if VECT_SIZE >= 16 + if (ctx[12].s8 == 0) ctx[13].s8 += 1; + if (ctx[12].s9 == 0) ctx[13].s9 += 1; + if (ctx[12].sa == 0) ctx[13].sa += 1; + if (ctx[12].sb == 0) ctx[13].sb += 1; + if (ctx[12].sc == 0) ctx[13].sc += 1; + if (ctx[12].sd == 0) ctx[13].sd += 1; + if (ctx[12].se == 0) ctx[13].se += 1; + if (ctx[12].sf == 0) ctx[13].sf += 1; + #endif x[16] = ctx[ 0]; x[17] = ctx[ 1]; diff --git a/OpenCL/m15400_a3-optimized.cl b/OpenCL/m15400_a3-optimized.cl index 7f0782b71..5923316f1 100644 --- a/OpenCL/m15400_a3-optimized.cl +++ b/OpenCL/m15400_a3-optimized.cl @@ -126,9 +126,39 @@ DECLSPEC void chacha20_transform (const u32x *w0, const u32x *w1, const u32 *pos * Generate a second 64 byte keystream */ - ctx[12]++; + ctx[12] += 1; - if (all(ctx[12] == 0)) ctx[13]++; + #if VECT_SIZE == 1 + if (ctx[12] == 0) ctx[13] += 1; + #endif + + #if VECT_SIZE >= 2 + if (ctx[12].s0 == 0) ctx[13].s0 += 1; + if (ctx[12].s1 == 0) ctx[13].s1 += 1; + #endif + + #if VECT_SIZE >= 4 + if (ctx[12].s2 == 0) ctx[13].s2 += 1; + if (ctx[12].s3 == 0) ctx[13].s3 += 1; + #endif + + #if VECT_SIZE >= 8 + if (ctx[12].s4 == 0) ctx[13].s4 += 1; + if (ctx[12].s5 == 0) ctx[13].s5 += 1; + if (ctx[12].s6 == 0) ctx[13].s6 += 1; + if (ctx[12].s7 == 0) ctx[13].s7 += 1; + #endif + + #if VECT_SIZE >= 16 + if (ctx[12].s8 == 0) ctx[13].s8 += 1; + if (ctx[12].s9 == 0) ctx[13].s9 += 1; + if (ctx[12].sa == 0) ctx[13].sa += 1; + if (ctx[12].sb == 0) ctx[13].sb += 1; + if (ctx[12].sc == 0) ctx[13].sc += 1; + if (ctx[12].sd == 0) ctx[13].sd += 1; + if (ctx[12].se == 0) ctx[13].se += 1; + if (ctx[12].sf == 0) ctx[13].sf += 1; + #endif x[16] = ctx[ 0]; x[17] = ctx[ 1]; diff --git a/OpenCL/m15900-pure.cl b/OpenCL/m15900-pure.cl index 2c2dd5adb..82a47cee5 100644 --- a/OpenCL/m15900-pure.cl +++ b/OpenCL/m15900-pure.cl @@ -599,57 +599,111 @@ KERNEL_FQ void m15900_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v2_t, dpapimk_t)) AES256_set_decrypt_key (ks, key, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - /* 144 bytes */ - u32 decrypted[36] = { 0 }; + u32 out[4]; - u32 contents_pos; - u32 contents_off; - u32 wx_off; + u32 hmac_data[4]; - for (wx_off = 0, contents_pos = 0, contents_off = 0; contents_pos < esalt_bufs[digests_offset].contents_len; wx_off += 4, contents_pos += 16, contents_off += 4) + hmac_data[0] = esalt_bufs[digests_offset].contents[0]; + hmac_data[1] = esalt_bufs[digests_offset].contents[1]; + hmac_data[2] = esalt_bufs[digests_offset].contents[2]; + hmac_data[3] = esalt_bufs[digests_offset].contents[3]; + + u32 expected_key[4]; + + expected_key[0] = esalt_bufs[digests_offset].contents[4]; + expected_key[1] = esalt_bufs[digests_offset].contents[5]; + expected_key[2] = esalt_bufs[digests_offset].contents[6]; + expected_key[3] = esalt_bufs[digests_offset].contents[7]; + + u32 last_iv[4]; + + last_iv[0] = esalt_bufs[digests_offset].contents[16]; + last_iv[1] = esalt_bufs[digests_offset].contents[17]; + last_iv[2] = esalt_bufs[digests_offset].contents[18]; + last_iv[3] = esalt_bufs[digests_offset].contents[19]; + + u32 last_key[16]; + + last_key[ 0] = esalt_bufs[digests_offset].contents[20]; + last_key[ 1] = esalt_bufs[digests_offset].contents[21]; + last_key[ 2] = esalt_bufs[digests_offset].contents[22]; + last_key[ 3] = esalt_bufs[digests_offset].contents[23]; + last_key[ 4] = esalt_bufs[digests_offset].contents[24]; + last_key[ 5] = esalt_bufs[digests_offset].contents[25]; + last_key[ 6] = esalt_bufs[digests_offset].contents[26]; + last_key[ 7] = esalt_bufs[digests_offset].contents[27]; + last_key[ 8] = esalt_bufs[digests_offset].contents[28]; + last_key[ 9] = esalt_bufs[digests_offset].contents[29]; + last_key[10] = esalt_bufs[digests_offset].contents[30]; + last_key[11] = esalt_bufs[digests_offset].contents[31]; + last_key[12] = esalt_bufs[digests_offset].contents[32]; + last_key[13] = esalt_bufs[digests_offset].contents[33]; + last_key[14] = esalt_bufs[digests_offset].contents[34]; + last_key[15] = esalt_bufs[digests_offset].contents[35]; + + // hmac_data + + AES256_decrypt (ks, hmac_data, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + iv[0] = hmac_data[0]; + iv[1] = hmac_data[1]; + iv[2] = hmac_data[2]; + iv[3] = hmac_data[3]; + + hmac_data[0] = out[0]; + hmac_data[1] = out[1]; + hmac_data[2] = out[2]; + hmac_data[3] = out[3]; + + // expected_key + + AES256_decrypt (ks, expected_key, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + iv[0] = expected_key[0]; + iv[1] = expected_key[1]; + iv[2] = expected_key[2]; + iv[3] = expected_key[3]; + + expected_key[0] = out[0]; + expected_key[1] = out[1]; + expected_key[2] = out[2]; + expected_key[3] = out[3]; + + // last_key + + iv[0] = last_iv[0]; + iv[1] = last_iv[1]; + iv[2] = last_iv[2]; + iv[3] = last_iv[3]; + + for (int off = 0; off < 16; off += 4) { - u32 data[4]; - - data[0] = esalt_bufs[digests_offset].contents[contents_off + 0]; - data[1] = esalt_bufs[digests_offset].contents[contents_off + 1]; - data[2] = esalt_bufs[digests_offset].contents[contents_off + 2]; - data[3] = esalt_bufs[digests_offset].contents[contents_off + 3]; - - u32 out[4]; - - AES256_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4); + AES256_decrypt (ks, last_key + off, out, s_td0, s_td1, s_td2, s_td3, s_td4); out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - decrypted[wx_off + 0] = out[0]; - decrypted[wx_off + 1] = out[1]; - decrypted[wx_off + 2] = out[2]; - decrypted[wx_off + 3] = out[3]; + iv[0] = last_key[off + 0]; + iv[1] = last_key[off + 1]; + iv[2] = last_key[off + 2]; + iv[3] = last_key[off + 3]; - iv[0] = data[0]; - iv[1] = data[1]; - iv[2] = data[2]; - iv[3] = data[3]; - - if (contents_off == 32) break; - } - - u32 hmacSalt[4]; - u32 expectedHmac[16]; - u32 lastKey[16]; - - hmacSalt[0] = decrypted[0]; - hmacSalt[1] = decrypted[1]; - hmacSalt[2] = decrypted[2]; - hmacSalt[3] = decrypted[3]; - - for(int i = 0; i < 16; i++) - { - expectedHmac[i] = decrypted[i + 4]; - lastKey[i] = decrypted[i + 36 - 16]; + last_key[off + 0] = out[0]; + last_key[off + 1] = out[1]; + last_key[off + 2] = out[2]; + last_key[off + 3] = out[3]; } w0[0] = tmps[gid].userKey[0]; @@ -689,10 +743,10 @@ KERNEL_FQ void m15900_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v2_t, dpapimk_t)) sha512_hmac_init_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7); - w0[0] = hmacSalt[0]; - w0[1] = hmacSalt[1]; - w0[2] = hmacSalt[2]; - w0[3] = hmacSalt[3]; + w0[0] = hmac_data[0]; + w0[1] = hmac_data[1]; + w0[2] = hmac_data[2]; + w0[3] = hmac_data[3]; w1[0] = 0; w1[1] = 0; w1[2] = 0; @@ -761,22 +815,22 @@ KERNEL_FQ void m15900_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v2_t, dpapimk_t)) sha512_hmac_init_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7); - w0[0] = lastKey[ 0]; - w0[1] = lastKey[ 1]; - w0[2] = lastKey[ 2]; - w0[3] = lastKey[ 3]; - w1[0] = lastKey[ 4]; - w1[1] = lastKey[ 5]; - w1[2] = lastKey[ 6]; - w1[3] = lastKey[ 7]; - w2[0] = lastKey[ 8]; - w2[1] = lastKey[ 9]; - w2[2] = lastKey[10]; - w2[3] = lastKey[11]; - w3[0] = lastKey[12]; - w3[1] = lastKey[13]; - w3[2] = lastKey[14]; - w3[3] = lastKey[15]; + w0[0] = last_key[ 0]; + w0[1] = last_key[ 1]; + w0[2] = last_key[ 2]; + w0[3] = last_key[ 3]; + w1[0] = last_key[ 4]; + w1[1] = last_key[ 5]; + w1[2] = last_key[ 6]; + w1[3] = last_key[ 7]; + w2[0] = last_key[ 8]; + w2[1] = last_key[ 9]; + w2[2] = last_key[10]; + w2[3] = last_key[11]; + w3[0] = last_key[12]; + w3[1] = last_key[13]; + w3[2] = last_key[14]; + w3[3] = last_key[15]; w4[0] = 0; w4[1] = 0; w4[2] = 0; @@ -800,10 +854,10 @@ KERNEL_FQ void m15900_comp (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v2_t, dpapimk_t)) #define il_pos 0 - if ((expectedHmac[0] == h32_from_64_S (ctx.opad.h[0])) - && (expectedHmac[1] == l32_from_64_S (ctx.opad.h[0])) - && (expectedHmac[2] == h32_from_64_S (ctx.opad.h[1])) - && (expectedHmac[3] == l32_from_64_S (ctx.opad.h[1]))) + if ((expected_key[0] == h32_from_64_S (ctx.opad.h[0])) + && (expected_key[1] == l32_from_64_S (ctx.opad.h[0])) + && (expected_key[2] == h32_from_64_S (ctx.opad.h[1])) + && (expected_key[3] == l32_from_64_S (ctx.opad.h[1]))) { if (atomic_inc (&hashes_shown[digests_offset]) == 0) { diff --git a/OpenCL/m16600_a0-optimized.cl b/OpenCL/m16600_a0-optimized.cl index d5baafd3f..952a06c83 100644 --- a/OpenCL/m16600_a0-optimized.cl +++ b/OpenCL/m16600_a0-optimized.cl @@ -106,6 +106,26 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) const u32 pw_len = pws[gid].pw_len & 63; + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -348,30 +368,16 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -384,7 +390,7 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -400,7 +406,7 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): @@ -512,6 +518,26 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) const u32 pw_len = pws[gid].pw_len & 63; + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -754,30 +780,16 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -790,7 +802,7 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -806,7 +818,7 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): diff --git a/OpenCL/m16600_a0-pure.cl b/OpenCL/m16600_a0-pure.cl index f5e29d805..551e751d2 100644 --- a/OpenCL/m16600_a0-pure.cl +++ b/OpenCL/m16600_a0-pure.cl @@ -94,6 +94,26 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) COPY_PW (pws[gid]); + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -162,30 +182,16 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -198,7 +204,7 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -214,7 +220,7 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): @@ -306,6 +312,26 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) COPY_PW (pws[gid]); + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -374,30 +400,16 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -410,7 +422,7 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -426,7 +438,7 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_RULES_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): diff --git a/OpenCL/m16600_a1-optimized.cl b/OpenCL/m16600_a1-optimized.cl index 7896a77e5..72aba70f5 100644 --- a/OpenCL/m16600_a1-optimized.cl +++ b/OpenCL/m16600_a1-optimized.cl @@ -104,6 +104,26 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) const u32 pw_l_len = pws[gid].pw_len & 63; + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -404,30 +424,16 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -440,7 +446,7 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -456,7 +462,7 @@ KERNEL_FQ void m16600_m04 (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): @@ -568,6 +574,26 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_ESALT (electrum_wallet_t)) const u32 pw_l_len = pws[gid].pw_len & 63; + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -868,30 +894,16 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -904,7 +916,7 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -920,7 +932,7 @@ KERNEL_FQ void m16600_s04 (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): diff --git a/OpenCL/m16600_a1-pure.cl b/OpenCL/m16600_a1-pure.cl index dde2ad588..976c72176 100644 --- a/OpenCL/m16600_a1-pure.cl +++ b/OpenCL/m16600_a1-pure.cl @@ -96,6 +96,26 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -158,30 +178,16 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -194,7 +200,7 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -210,7 +216,7 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): @@ -306,6 +312,26 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_ESALT (electrum_wallet_t)) sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -368,30 +394,16 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -404,7 +416,7 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -420,7 +432,7 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): diff --git a/OpenCL/m16600_a3-optimized.cl b/OpenCL/m16600_a3-optimized.cl index cfe2a1d9d..bf0ed87fd 100644 --- a/OpenCL/m16600_a3-optimized.cl +++ b/OpenCL/m16600_a3-optimized.cl @@ -31,6 +31,26 @@ DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a const u64 gid = get_global_id (0); + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -41,255 +61,100 @@ DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a { const u32x w0r = ix_create_bft (bfs_buf, il_pos); - const u32x w0 = w0l | w0r; + const u32x w0lr = w0l | w0r; - u32x w0_t = w0; - u32x w1_t = w[ 1]; - u32x w2_t = w[ 2]; - u32x w3_t = w[ 3]; - u32x w4_t = w[ 4]; - u32x w5_t = w[ 5]; - u32x w6_t = w[ 6]; - u32x w7_t = w[ 7]; - u32x w8_t = w[ 8]; - u32x w9_t = w[ 9]; - u32x wa_t = w[10]; - u32x wb_t = w[11]; - u32x wc_t = w[12]; - u32x wd_t = w[13]; - u32x we_t = w[14]; - u32x wf_t = w[15]; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; - u32x a = SHA256M_A; - u32x b = SHA256M_B; - u32x c = SHA256M_C; - u32x d = SHA256M_D; - u32x e = SHA256M_E; - u32x f = SHA256M_F; - u32x g = SHA256M_G; - u32x h = SHA256M_H; + w0[0] = w0lr; + w0[1] = w[ 1]; + w0[2] = w[ 2]; + w0[3] = w[ 3]; + w1[0] = w[ 4]; + w1[1] = w[ 5]; + w1[2] = w[ 6]; + w1[3] = w[ 7]; + w2[0] = w[ 8]; + w2[1] = w[ 9]; + w2[2] = w[10]; + w2[3] = w[11]; + w3[0] = w[12]; + w3[1] = w[13]; + w3[2] = w[14]; + w3[3] = w[15]; - SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); - SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); - SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); - SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); - SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); - SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); - SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); - SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); - SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); - SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); - SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); - SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); - SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); - SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); - SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); - SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + u32 digest[8]; - w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); - w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); - w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); - w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); - w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); - w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); - w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); - w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); - w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); - w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); - wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); - wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); - wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); - wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); - we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); - wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + digest[0] = SHA256M_A; + digest[1] = SHA256M_B; + digest[2] = SHA256M_C; + digest[3] = SHA256M_D; + digest[4] = SHA256M_E; + digest[5] = SHA256M_F; + digest[6] = SHA256M_G; + digest[7] = SHA256M_H; - w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); - w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); - w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); - w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); - w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); - w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); - w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); - w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); - w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); - w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); - wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); - wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); - wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); - wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); - we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); - wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + sha256_transform (w0, w1, w2, w3, digest); - w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); - w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); - w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); - w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); - w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); - w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); - w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); - w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); - w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); - w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); - wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); - wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); - wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); - wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); - we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); - wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 32 * 8; - a += SHA256M_A; - b += SHA256M_B; - c += SHA256M_C; - d += SHA256M_D; - e += SHA256M_E; - f += SHA256M_F; - g += SHA256M_G; - h += SHA256M_H; + digest[0] = SHA256M_A; + digest[1] = SHA256M_B; + digest[2] = SHA256M_C; + digest[3] = SHA256M_D; + digest[4] = SHA256M_E; + digest[5] = SHA256M_F; + digest[6] = SHA256M_G; + digest[7] = SHA256M_H; - w0_t = a; - w1_t = b; - w2_t = c; - w3_t = d; - w4_t = e; - w5_t = f; - w6_t = g; - w7_t = h; - w8_t = 0x80000000; - w9_t = 0; - wa_t = 0; - wb_t = 0; - wc_t = 0; - wd_t = 0; - we_t = 0; - wf_t = 32 * 8; - - a = SHA256M_A; - b = SHA256M_B; - c = SHA256M_C; - d = SHA256M_D; - e = SHA256M_E; - f = SHA256M_F; - g = SHA256M_G; - h = SHA256M_H; - - SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); - SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); - SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); - SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); - SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); - SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); - SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); - SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); - SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); - SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); - SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); - SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); - SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); - SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); - SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); - SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); - - w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); - w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); - w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); - w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); - w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); - w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); - w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); - w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); - w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); - w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); - wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); - wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); - wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); - wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); - we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); - wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); - - w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); - w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); - w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); - w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); - w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); - w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); - w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); - w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); - w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); - w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); - wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); - wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); - wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); - wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); - we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); - wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); - - w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); - w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); - w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); - w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); - w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); - w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); - w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); - w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); - w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); - w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); - wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); - wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); - wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); - wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); - we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); - wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); - - a += SHA256M_A; - b += SHA256M_B; - c += SHA256M_C; - d += SHA256M_D; - e += SHA256M_E; - f += SHA256M_F; - g += SHA256M_G; - h += SHA256M_H; + sha256_transform (w0, w1, w2, w3, digest); u32 ukey[8]; - ukey[0] = hc_swap32_S (a); - ukey[1] = hc_swap32_S (b); - ukey[2] = hc_swap32_S (c); - ukey[3] = hc_swap32_S (d); - ukey[4] = hc_swap32_S (e); - ukey[5] = hc_swap32_S (f); - ukey[6] = hc_swap32_S (g); - ukey[7] = hc_swap32_S (h); + ukey[0] = digest[0]; + ukey[1] = digest[1]; + ukey[2] = digest[2]; + ukey[3] = digest[3]; + ukey[4] = digest[4]; + ukey[5] = digest[5]; + ukey[6] = digest[6]; + ukey[7] = digest[7]; #define KEYLEN 60 u32 ks[KEYLEN]; - aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + aes256_ExpandKey (ks, ukey, s_te0, s_te1, s_te2, s_te3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + aes256_InvertKey (ks, s_te1, s_td0, s_td1, s_td2, s_td3); u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -302,7 +167,7 @@ DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -318,7 +183,7 @@ DECLSPEC void m16600 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): diff --git a/OpenCL/m16600_a3-pure.cl b/OpenCL/m16600_a3-pure.cl index 49667e50a..b7ead62fd 100644 --- a/OpenCL/m16600_a3-pure.cl +++ b/OpenCL/m16600_a3-pure.cl @@ -99,6 +99,26 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) w[idx] = pws[gid].i[idx]; } + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -171,30 +191,16 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -207,7 +213,7 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -223,7 +229,7 @@ KERNEL_FQ void m16600_mxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): @@ -322,6 +328,26 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) w[idx] = pws[gid].i[idx]; } + /** + * data + */ + + const u32 salt_type = esalt_bufs[digests_offset].salt_type; + + u32 encrypted[4]; + + encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; + encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; + encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; + encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + /** * loop */ @@ -394,30 +420,16 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); - u32 encrypted[4]; - - encrypted[0] = esalt_bufs[digests_offset].encrypted[0]; - encrypted[1] = esalt_bufs[digests_offset].encrypted[1]; - encrypted[2] = esalt_bufs[digests_offset].encrypted[2]; - encrypted[3] = esalt_bufs[digests_offset].encrypted[3]; - u32 out[4]; aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); - u32 iv[4]; - - iv[0] = esalt_bufs[digests_offset].iv[0]; - iv[1] = esalt_bufs[digests_offset].iv[1]; - iv[2] = esalt_bufs[digests_offset].iv[2]; - iv[3] = esalt_bufs[digests_offset].iv[3]; - out[0] ^= iv[0]; out[1] ^= iv[1]; out[2] ^= iv[2]; out[3] ^= iv[3]; - if (esalt_bufs[digests_offset].salt_type == 1) + if (salt_type == 1) { if (is_valid_hex_32 (out[0]) == 0) continue; if (is_valid_hex_32 (out[1]) == 0) continue; @@ -430,7 +442,7 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 2) + if (salt_type == 2) { if ((u8) (out[0] >> 0) != 'x') continue; if ((u8) (out[0] >> 8) != 'p') continue; @@ -446,7 +458,7 @@ KERNEL_FQ void m16600_sxx (KERN_ATTR_VECTOR_ESALT (electrum_wallet_t)) } } - if (esalt_bufs[digests_offset].salt_type == 3) + if (salt_type == 3) { // check PKCS7 padding (either 13 times 0x0d or 12 times 0x0c at the end, we only check 12 bytes, it's enough): diff --git a/OpenCL/m18700_a1-optimized.cl b/OpenCL/m18700_a1-optimized.cl index 18ea7ffbd..584cdcd54 100644 --- a/OpenCL/m18700_a1-optimized.cl +++ b/OpenCL/m18700_a1-optimized.cl @@ -15,7 +15,7 @@ #include "inc_hash_md5.cl" #endif -DECLSPEC u32 hashCode_g (const u32 init, GLOBAL_AS u32 *w, const u32 pw_len) +DECLSPEC u32 hashCode_g (const u32 init, GLOBAL_AS const u32 *w, const u32 pw_len) { u32 hash = init; diff --git a/OpenCL/m18700_a1-pure.cl b/OpenCL/m18700_a1-pure.cl index 1f69f8e90..2a34b7911 100644 --- a/OpenCL/m18700_a1-pure.cl +++ b/OpenCL/m18700_a1-pure.cl @@ -14,7 +14,7 @@ #include "inc_hash_md5.cl" #endif -DECLSPEC u32 hashCode_g (const u32 init, GLOBAL_AS u32 *w, const u32 pw_len) +DECLSPEC u32 hashCode_g (const u32 init, GLOBAL_AS const u32 *w, const u32 pw_len) { u32 hash = init; diff --git a/OpenCL/m20900_a1-pure.cl b/OpenCL/m20900_a1-pure.cl index 7c8474c56..710fa8be2 100644 --- a/OpenCL/m20900_a1-pure.cl +++ b/OpenCL/m20900_a1-pure.cl @@ -80,7 +80,7 @@ KERNEL_FQ void m20900_mxx (KERN_ATTR_BASIC ()) u32 w1[4]; u32 w2[4]; u32 w3[4]; - + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) { sha1_ctx_t ctx0 = ctx00; diff --git a/OpenCL/m21200_a1-pure.cl b/OpenCL/m21200_a1-pure.cl index c06f0d633..4442de477 100644 --- a/OpenCL/m21200_a1-pure.cl +++ b/OpenCL/m21200_a1-pure.cl @@ -97,7 +97,7 @@ KERNEL_FQ void m21200_mxx (KERN_ATTR_BASIC ()) u32 w1[4]; u32 w2[4]; u32 w3[4]; - + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) { md5_ctx_t ctx1 = ctx11; diff --git a/OpenCL/m21600-pure.cl b/OpenCL/m21600-pure.cl new file mode 100644 index 000000000..670e31b57 --- /dev/null +++ b/OpenCL/m21600-pure.cl @@ -0,0 +1,343 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" +#endif + +#define COMPARE_S "inc_comp_single.cl" +#define COMPARE_M "inc_comp_multi.cl" + +typedef struct web2py_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[16]; + u64 out[16]; + +} web2py_sha512_tmp_t; + +DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +KERNEL_FQ void m21600_init (KERN_ATTR_TMPS (web2py_sha512_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_global_swap (&sha512_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx2, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha512_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha512_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha512_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha512_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha512_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha512_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha512_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha512_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +KERNEL_FQ void m21600_loop (KERN_ATTR_TMPS (web2py_sha512_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= gid_max) return; + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, i + 0); + dgst[1] = pack64v (tmps, dgst, gid, i + 1); + dgst[2] = pack64v (tmps, dgst, gid, i + 2); + dgst[3] = pack64v (tmps, dgst, gid, i + 3); + dgst[4] = pack64v (tmps, dgst, gid, i + 4); + dgst[5] = pack64v (tmps, dgst, gid, i + 5); + dgst[6] = pack64v (tmps, dgst, gid, i + 6); + dgst[7] = pack64v (tmps, dgst, gid, i + 7); + + out[0] = pack64v (tmps, out, gid, i + 0); + out[1] = pack64v (tmps, out, gid, i + 1); + out[2] = pack64v (tmps, out, gid, i + 2); + out[3] = pack64v (tmps, out, gid, i + 3); + out[4] = pack64v (tmps, out, gid, i + 4); + out[5] = pack64v (tmps, out, gid, i + 5); + out[6] = pack64v (tmps, out, gid, i + 6); + out[7] = pack64v (tmps, out, gid, i + 7); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpack64v (tmps, dgst, gid, i + 0, dgst[0]); + unpack64v (tmps, dgst, gid, i + 1, dgst[1]); + unpack64v (tmps, dgst, gid, i + 2, dgst[2]); + unpack64v (tmps, dgst, gid, i + 3, dgst[3]); + unpack64v (tmps, dgst, gid, i + 4, dgst[4]); + unpack64v (tmps, dgst, gid, i + 5, dgst[5]); + unpack64v (tmps, dgst, gid, i + 6, dgst[6]); + unpack64v (tmps, dgst, gid, i + 7, dgst[7]); + + unpack64v (tmps, out, gid, i + 0, out[0]); + unpack64v (tmps, out, gid, i + 1, out[1]); + unpack64v (tmps, out, gid, i + 2, out[2]); + unpack64v (tmps, out, gid, i + 3, out[3]); + unpack64v (tmps, out, gid, i + 4, out[4]); + unpack64v (tmps, out, gid, i + 5, out[5]); + unpack64v (tmps, out, gid, i + 6, out[6]); + unpack64v (tmps, out, gid, i + 7, out[7]); + } +} + +KERNEL_FQ void m21600_comp (KERN_ATTR_TMPS (web2py_sha512_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + const u64 lid = get_local_id (0); + + const u64 a = hc_swap64_S (tmps[gid].out[0]); + const u64 b = hc_swap64_S (tmps[gid].out[1]); + + const u32 r0 = l32_from_64_S (a); + const u32 r1 = h32_from_64_S (a); + const u32 r2 = l32_from_64_S (b); + const u32 r3 = h32_from_64_S (b); + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m21700-pure.cl b/OpenCL/m21700-pure.cl new file mode 100644 index 000000000..45bd04ee0 --- /dev/null +++ b/OpenCL/m21700-pure.cl @@ -0,0 +1,438 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#include "inc_hash_sha512.cl" +#include "inc_ecc_secp256k1.cl" +#endif + +#define COMPARE_M "inc_comp_multi.cl" + +typedef struct electrum +{ + secp256k1_t coords; + + u32 data_buf[4096]; + u32 data_len; + +} electrum_t; + +typedef struct electrum_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[8]; + u64 out[8]; + +} electrum_tmp_t; + +DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +KERNEL_FQ void m21700_init (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_global_swap (&sha512_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = 1; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx); + + tmps[gid].dgst[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].dgst[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].dgst[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].dgst[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].dgst[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].dgst[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].dgst[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].dgst[7] = sha512_hmac_ctx.opad.h[7]; + + tmps[gid].out[0] = tmps[gid].dgst[0]; + tmps[gid].out[1] = tmps[gid].dgst[1]; + tmps[gid].out[2] = tmps[gid].dgst[2]; + tmps[gid].out[3] = tmps[gid].dgst[3]; + tmps[gid].out[4] = tmps[gid].dgst[4]; + tmps[gid].out[5] = tmps[gid].dgst[5]; + tmps[gid].out[6] = tmps[gid].dgst[6]; + tmps[gid].out[7] = tmps[gid].dgst[7]; +} + +KERNEL_FQ void m21700_loop (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= gid_max) return; + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, 0); + dgst[1] = pack64v (tmps, dgst, gid, 1); + dgst[2] = pack64v (tmps, dgst, gid, 2); + dgst[3] = pack64v (tmps, dgst, gid, 3); + dgst[4] = pack64v (tmps, dgst, gid, 4); + dgst[5] = pack64v (tmps, dgst, gid, 5); + dgst[6] = pack64v (tmps, dgst, gid, 6); + dgst[7] = pack64v (tmps, dgst, gid, 7); + + out[0] = pack64v (tmps, out, gid, 0); + out[1] = pack64v (tmps, out, gid, 1); + out[2] = pack64v (tmps, out, gid, 2); + out[3] = pack64v (tmps, out, gid, 3); + out[4] = pack64v (tmps, out, gid, 4); + out[5] = pack64v (tmps, out, gid, 5); + out[6] = pack64v (tmps, out, gid, 6); + out[7] = pack64v (tmps, out, gid, 7); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpack64v (tmps, dgst, gid, 0, dgst[0]); + unpack64v (tmps, dgst, gid, 1, dgst[1]); + unpack64v (tmps, dgst, gid, 2, dgst[2]); + unpack64v (tmps, dgst, gid, 3, dgst[3]); + unpack64v (tmps, dgst, gid, 4, dgst[4]); + unpack64v (tmps, dgst, gid, 5, dgst[5]); + unpack64v (tmps, dgst, gid, 6, dgst[6]); + unpack64v (tmps, dgst, gid, 7, dgst[7]); + + unpack64v (tmps, out, gid, 0, out[0]); + unpack64v (tmps, out, gid, 1, out[1]); + unpack64v (tmps, out, gid, 2, out[2]); + unpack64v (tmps, out, gid, 3, out[3]); + unpack64v (tmps, out, gid, 4, out[4]); + unpack64v (tmps, out, gid, 5, out[5]); + unpack64v (tmps, out, gid, 6, out[6]); + unpack64v (tmps, out, gid, 7, out[7]); +} + +KERNEL_FQ void m21700_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u64 out[8]; + + out[0] = tmps[gid].out[0]; + out[1] = tmps[gid].out[1]; + out[2] = tmps[gid].out[2]; + out[3] = tmps[gid].out[3]; + out[4] = tmps[gid].out[4]; + out[5] = tmps[gid].out[5]; + out[6] = tmps[gid].out[6]; + out[7] = tmps[gid].out[7]; + + /* + * First calculate the modulo of the pbkdf2 hash with SECP256K1_N: + */ + + u32 a[16]; + + a[ 0] = h32_from_64_S (out[0]); + a[ 1] = l32_from_64_S (out[0]); + a[ 2] = h32_from_64_S (out[1]); + a[ 3] = l32_from_64_S (out[1]); + a[ 4] = h32_from_64_S (out[2]); + a[ 5] = l32_from_64_S (out[2]); + a[ 6] = h32_from_64_S (out[3]); + a[ 7] = l32_from_64_S (out[3]); + a[ 8] = h32_from_64_S (out[4]); + a[ 9] = l32_from_64_S (out[4]); + a[10] = h32_from_64_S (out[5]); + a[11] = l32_from_64_S (out[5]); + a[12] = h32_from_64_S (out[6]); + a[13] = l32_from_64_S (out[6]); + a[14] = h32_from_64_S (out[7]); + a[15] = l32_from_64_S (out[7]); + + mod_512 (a); + + // copy the last 256 bit (32 bytes) of modulo (a): + + u32 tweak[8]; + + tweak[0] = a[15]; + tweak[1] = a[14]; + tweak[2] = a[13]; + tweak[3] = a[12]; + tweak[4] = a[11]; + tweak[5] = a[10]; + tweak[6] = a[ 9]; + tweak[7] = a[ 8]; + + + /* + * the main secp256k1 point multiplication by a scalar/tweak: + */ + + GLOBAL_AS secp256k1_t *coords = (GLOBAL_AS secp256k1_t *) &esalt_bufs[digests_offset].coords; + + u32 pubkey[64] = { 0 }; // for point_mul () we need: 1 + 32 bytes (for sha512 () we need more) + + point_mul (pubkey, tweak, coords); + + + /* + * sha512 () of the pubkey: + */ + + sha512_ctx_t sha512_ctx; + + sha512_init (&sha512_ctx); + sha512_update (&sha512_ctx, pubkey, 33); // 33 because of 32 byte curve point + sign + sha512_final (&sha512_ctx); + + + /* + * sha256-hmac () of the data_buf + */ + + GLOBAL_AS u32 *data_buf = (GLOBAL_AS u32 *) esalt_bufs[digests_offset].data_buf; + + u32 data_len = esalt_bufs[digests_offset].data_len; + + u32 key[16] = { 0 }; + + key[0] = h32_from_64_S (sha512_ctx.h[4]); + key[1] = l32_from_64_S (sha512_ctx.h[4]); + key[2] = h32_from_64_S (sha512_ctx.h[5]); + key[3] = l32_from_64_S (sha512_ctx.h[5]); + + key[4] = h32_from_64_S (sha512_ctx.h[6]); + key[5] = l32_from_64_S (sha512_ctx.h[6]); + key[6] = h32_from_64_S (sha512_ctx.h[7]); + key[7] = l32_from_64_S (sha512_ctx.h[7]); + + sha256_hmac_ctx_t sha256_ctx; + + sha256_hmac_init (&sha256_ctx, key, 32); + + sha256_hmac_update_global_swap (&sha256_ctx, data_buf, data_len); + + sha256_hmac_final (&sha256_ctx); + + const u32 r0 = sha256_ctx.opad.h[0]; + const u32 r1 = sha256_ctx.opad.h[1]; + const u32 r2 = sha256_ctx.opad.h[2]; + const u32 r3 = sha256_ctx.opad.h[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m21800-pure.cl b/OpenCL/m21800-pure.cl new file mode 100644 index 000000000..fc447c94a --- /dev/null +++ b/OpenCL/m21800-pure.cl @@ -0,0 +1,615 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" +#include "inc_ecc_secp256k1.cl" +#include "inc_cipher_aes.cl" +#include "inc_zip_inflate.cl" +#endif + +typedef struct electrum +{ + secp256k1_t coords; + + u32 data_buf[256]; + +} electrum_t; + +typedef struct electrum_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[8]; + u64 out[8]; + +} electrum_tmp_t; + +DECLSPEC void hmac_sha512_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *w4, u32x *w5, u32x *w6, u32x *w7, u64x *ipad, u64x *opad, u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +KERNEL_FQ void m21800_init (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_global_swap (&sha512_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = 1; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx); + + tmps[gid].dgst[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].dgst[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].dgst[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].dgst[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].dgst[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].dgst[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].dgst[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].dgst[7] = sha512_hmac_ctx.opad.h[7]; + + tmps[gid].out[0] = tmps[gid].dgst[0]; + tmps[gid].out[1] = tmps[gid].dgst[1]; + tmps[gid].out[2] = tmps[gid].dgst[2]; + tmps[gid].out[3] = tmps[gid].dgst[3]; + tmps[gid].out[4] = tmps[gid].dgst[4]; + tmps[gid].out[5] = tmps[gid].dgst[5]; + tmps[gid].out[6] = tmps[gid].dgst[6]; + tmps[gid].out[7] = tmps[gid].dgst[7]; +} + +KERNEL_FQ void m21800_loop (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= gid_max) return; + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, 0); + dgst[1] = pack64v (tmps, dgst, gid, 1); + dgst[2] = pack64v (tmps, dgst, gid, 2); + dgst[3] = pack64v (tmps, dgst, gid, 3); + dgst[4] = pack64v (tmps, dgst, gid, 4); + dgst[5] = pack64v (tmps, dgst, gid, 5); + dgst[6] = pack64v (tmps, dgst, gid, 6); + dgst[7] = pack64v (tmps, dgst, gid, 7); + + out[0] = pack64v (tmps, out, gid, 0); + out[1] = pack64v (tmps, out, gid, 1); + out[2] = pack64v (tmps, out, gid, 2); + out[3] = pack64v (tmps, out, gid, 3); + out[4] = pack64v (tmps, out, gid, 4); + out[5] = pack64v (tmps, out, gid, 5); + out[6] = pack64v (tmps, out, gid, 6); + out[7] = pack64v (tmps, out, gid, 7); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpack64v (tmps, dgst, gid, 0, dgst[0]); + unpack64v (tmps, dgst, gid, 1, dgst[1]); + unpack64v (tmps, dgst, gid, 2, dgst[2]); + unpack64v (tmps, dgst, gid, 3, dgst[3]); + unpack64v (tmps, dgst, gid, 4, dgst[4]); + unpack64v (tmps, dgst, gid, 5, dgst[5]); + unpack64v (tmps, dgst, gid, 6, dgst[6]); + unpack64v (tmps, dgst, gid, 7, dgst[7]); + + unpack64v (tmps, out, gid, 0, out[0]); + unpack64v (tmps, out, gid, 1, out[1]); + unpack64v (tmps, out, gid, 2, out[2]); + unpack64v (tmps, out, gid, 3, out[3]); + unpack64v (tmps, out, gid, 4, out[4]); + unpack64v (tmps, out, gid, 5, out[5]); + unpack64v (tmps, out, gid, 6, out[6]); + unpack64v (tmps, out, gid, 7, out[7]); +} + +KERNEL_FQ void m21800_comp (KERN_ATTR_TMPS_ESALT (electrum_tmp_t, electrum_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + + /* + * Start by copying/aligning the data + */ + + u64 out[8]; + + out[0] = tmps[gid].out[0]; + out[1] = tmps[gid].out[1]; + out[2] = tmps[gid].out[2]; + out[3] = tmps[gid].out[3]; + out[4] = tmps[gid].out[4]; + out[5] = tmps[gid].out[5]; + out[6] = tmps[gid].out[6]; + out[7] = tmps[gid].out[7]; + + /* + * First calculate the modulo of the pbkdf2 hash with SECP256K1_N: + */ + + u32 a[16]; + + a[ 0] = h32_from_64_S (out[0]); + a[ 1] = l32_from_64_S (out[0]); + a[ 2] = h32_from_64_S (out[1]); + a[ 3] = l32_from_64_S (out[1]); + a[ 4] = h32_from_64_S (out[2]); + a[ 5] = l32_from_64_S (out[2]); + a[ 6] = h32_from_64_S (out[3]); + a[ 7] = l32_from_64_S (out[3]); + a[ 8] = h32_from_64_S (out[4]); + a[ 9] = l32_from_64_S (out[4]); + a[10] = h32_from_64_S (out[5]); + a[11] = l32_from_64_S (out[5]); + a[12] = h32_from_64_S (out[6]); + a[13] = l32_from_64_S (out[6]); + a[14] = h32_from_64_S (out[7]); + a[15] = l32_from_64_S (out[7]); + + mod_512 (a); + + // copy the last 256 bit (32 bytes) of modulo (a): + + u32 tweak[8]; + + tweak[0] = a[15]; + tweak[1] = a[14]; + tweak[2] = a[13]; + tweak[3] = a[12]; + tweak[4] = a[11]; + tweak[5] = a[10]; + tweak[6] = a[ 9]; + tweak[7] = a[ 8]; + + + /* + * the main secp256k1 point multiplication by a scalar/tweak: + */ + + GLOBAL_AS secp256k1_t *coords = (GLOBAL_AS secp256k1_t *) &esalt_bufs[digests_offset].coords; + + u32 pubkey[64] = { 0 }; // for point_mul () we need: 1 + 32 bytes (for sha512 () we need more) + + point_mul (pubkey, tweak, coords); + + + /* + * sha512 () of the pubkey: + */ + + sha512_ctx_t sha512_ctx; + + sha512_init (&sha512_ctx); + sha512_update (&sha512_ctx, pubkey, 33); // 33 because of 32 byte curve point + sign + sha512_final (&sha512_ctx); + + // ... now we have the result in sha512_ctx.h[0]...sha512_ctx.h[7] + + u32 iv[4]; + + iv[0] = h32_from_64_S (sha512_ctx.h[0]); + iv[1] = l32_from_64_S (sha512_ctx.h[0]); + iv[2] = h32_from_64_S (sha512_ctx.h[1]); + iv[3] = l32_from_64_S (sha512_ctx.h[1]); + + iv[0] = hc_swap32_S (iv[0]); + iv[1] = hc_swap32_S (iv[1]); + iv[2] = hc_swap32_S (iv[2]); + iv[3] = hc_swap32_S (iv[3]); + + u32 key[4]; + + key[0] = h32_from_64_S (sha512_ctx.h[2]); + key[1] = l32_from_64_S (sha512_ctx.h[2]); + key[2] = h32_from_64_S (sha512_ctx.h[3]); + key[3] = l32_from_64_S (sha512_ctx.h[3]); + + key[0] = hc_swap32_S (key[0]); + key[1] = hc_swap32_S (key[1]); + key[2] = hc_swap32_S (key[2]); + key[3] = hc_swap32_S (key[3]); + + + /* + * AES decrypt the data_buf + */ + + // init AES + + #define KEYLEN 44 + + u32 ks[KEYLEN]; + + aes128_set_decrypt_key (ks, key, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + // #define AES_LEN 1024 + // in my tests it also worked with only 128 input bytes ! + #define AES_LEN 128 + #define AES_LEN_DIV_4 32 + + u32 buf_full[AES_LEN_DIV_4]; + + // we need to run it at least once: + + GLOBAL_AS u32 *data_buf = (GLOBAL_AS u32 *) esalt_bufs[digests_offset].data_buf; + + u32 data[4]; + + data[0] = data_buf[0]; + data[1] = data_buf[1]; + data[2] = data_buf[2]; + data[3] = data_buf[3]; + + u32 buf[4]; + + aes128_decrypt (ks, data, buf, s_td0, s_td1, s_td2, s_td3, s_td4); + + buf[0] ^= iv[0]; + + // early reject + + if ((buf[0] & 0x0006ffff) != 0x00049c78) return; // allow 0b100 or 0b101 at the end of 3rd byte + + buf[1] ^= iv[1]; + buf[2] ^= iv[2]; + buf[3] ^= iv[3]; + + buf_full[0] = buf[0]; + buf_full[1] = buf[1]; + buf_full[2] = buf[2]; + buf_full[3] = buf[3]; + + iv[0] = data[0]; + iv[1] = data[1]; + iv[2] = data[2]; + iv[3] = data[3]; + + // for AES_LEN > 16 we need to loop + + for (int i = 16, j = 4; i < AES_LEN; i += 16, j += 4) + { + data[0] = data_buf[j + 0]; + data[1] = data_buf[j + 1]; + data[2] = data_buf[j + 2]; + data[3] = data_buf[j + 3]; + + aes128_decrypt (ks, data, buf, s_td0, s_td1, s_td2, s_td3, s_td4); + + buf[0] ^= iv[0]; + buf[1] ^= iv[1]; + buf[2] ^= iv[2]; + buf[3] ^= iv[3]; + + iv[0] = data[0]; + iv[1] = data[1]; + iv[2] = data[2]; + iv[3] = data[3]; + + buf_full[j + 0] = buf[0]; + buf_full[j + 1] = buf[1]; + buf_full[j + 2] = buf[2]; + buf_full[j + 3] = buf[3]; + } + + + /* + * zlib inflate/decompress: + */ + + mz_stream infstream; + + infstream.opaque = Z_NULL; + + // input: + + infstream.avail_in = AES_LEN; + infstream.next_in = (u8 *) buf_full; + + // output: + + #define OUT_SIZE 16 + + u8 tmp[OUT_SIZE]; + + infstream.avail_out = OUT_SIZE; + infstream.next_out = tmp; + + + // decompress it: + + inflate_state pStream; + + mz_inflateInit2 (&infstream, MAX_WBITS, &pStream); + + const int zlib_ret = inflate (&infstream, Z_NO_FLUSH); + + if ((zlib_ret != MZ_OK) && (zlib_ret != MZ_STREAM_END)) + { + return; + } + + + /* + * Verify if decompressed data is either: + * - "{\n \"" or + * - "{\r\n \"" + */ + + if (((tmp[0] == 0x7b) && (tmp[1] == 0x0a) && (tmp[2] == 0x20) && (tmp[3] == 0x20) && + (tmp[4] == 0x20) && (tmp[5] == 0x20) && (tmp[6] == 0x22)) || + ((tmp[0] == 0x7b) && (tmp[1] == 0x0d) && (tmp[2] == 0x0a) && (tmp[3] == 0x20) && + (tmp[4] == 0x20) && (tmp[5] == 0x20) && (tmp[6] == 0x20) && (tmp[7] == 0x22))) + { + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); + } + + return; + } +} diff --git a/OpenCL/m22000-pure.cl b/OpenCL/m22000-pure.cl new file mode 100644 index 000000000..954f62ce3 --- /dev/null +++ b/OpenCL/m22000-pure.cl @@ -0,0 +1,1038 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_md5.cl" +#include "inc_hash_sha1.cl" +#include "inc_hash_sha256.cl" +#include "inc_cipher_aes.cl" +#else +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.h" +#include "inc_common.h" +#include "inc_simd.h" +#include "inc_hash_md5.h" +#include "inc_hash_sha1.h" +#include "inc_hash_sha256.h" +#include "inc_cipher_aes.h" +#endif + +#define COMPARE_S "inc_comp_single.cl" +#define COMPARE_M "inc_comp_multi.cl" + +typedef struct wpa_pbkdf2_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[10]; + u32 out[10]; + +} wpa_pbkdf2_tmp_t; + +typedef struct wpa +{ + u32 essid_buf[16]; + u32 essid_len; + + u32 mac_ap[2]; + u32 mac_sta[2]; + + u32 type; // 1 = PMKID, 2 = EAPOL + + // PMKID specific + + u32 pmkid[4]; + u32 pmkid_data[16]; + + // EAPOL specific + + u32 keymic[4]; + u32 anonce[8]; + + u32 keyver; + + u32 eapol[64 + 16]; + u32 eapol_len; + + u32 pke[32]; + + int message_pair_chgd; + u32 message_pair; + + int nonce_error_corrections_chgd; + int nonce_error_corrections; + + int nonce_compare; + int detected_le; + int detected_be; + +} wpa_t; + +DECLSPEC void make_kn (u32 *k) +{ + u32 kl[4]; + u32 kr[4]; + + kl[0] = (k[0] << 1) & 0xfefefefe; + kl[1] = (k[1] << 1) & 0xfefefefe; + kl[2] = (k[2] << 1) & 0xfefefefe; + kl[3] = (k[3] << 1) & 0xfefefefe; + + kr[0] = (k[0] >> 7) & 0x01010101; + kr[1] = (k[1] >> 7) & 0x01010101; + kr[2] = (k[2] >> 7) & 0x01010101; + kr[3] = (k[3] >> 7) & 0x01010101; + + const u32 c = kr[0] & 1; + + kr[0] = kr[0] >> 8 | kr[1] << 24; + kr[1] = kr[1] >> 8 | kr[2] << 24; + kr[2] = kr[2] >> 8 | kr[3] << 24; + kr[3] = kr[3] >> 8; + + k[0] = kl[0] | kr[0]; + k[1] = kl[1] | kr[1]; + k[2] = kl[2] | kr[2]; + k[3] = kl[3] | kr[3]; + + k[3] ^= c * 0x87000000; +} + +DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m22000_init (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init_global_swap (&sha1_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha1_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha1_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha1_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha1_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha1_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = sha1_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha1_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha1_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha1_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha1_hmac_ctx.opad.h[4]; + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, esalt_bufs[digests_offset].essid_buf, esalt_bufs[digests_offset].essid_len); + + for (u32 i = 0, j = 1; i < 8; i += 5, j += 1) + { + sha1_hmac_ctx_t sha1_hmac_ctx2 = sha1_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx2, w0, w1, w2, w3, 4); + + sha1_hmac_final (&sha1_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha1_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha1_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha1_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha1_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha1_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +KERNEL_FQ void m22000_loop (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= gid_max) return; + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 8; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < loop_cnt; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } +} + +KERNEL_FQ void m22000_comp (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + // not in use here, special case... +} + +KERNEL_FQ void m22000_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 out0[4]; + u32 out1[4]; + + out0[0] = tmps[gid].out[0]; + out0[1] = tmps[gid].out[1]; + out0[2] = tmps[gid].out[2]; + out0[3] = tmps[gid].out[3]; + out1[0] = tmps[gid].out[4]; + out1[1] = tmps[gid].out[5]; + out1[2] = tmps[gid].out[6]; + out1[3] = tmps[gid].out[7]; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + u32 pke[32]; + + pke[ 0] = wpa->pke[ 0]; + pke[ 1] = wpa->pke[ 1]; + pke[ 2] = wpa->pke[ 2]; + pke[ 3] = wpa->pke[ 3]; + pke[ 4] = wpa->pke[ 4]; + pke[ 5] = wpa->pke[ 5]; + pke[ 6] = wpa->pke[ 6]; + pke[ 7] = wpa->pke[ 7]; + pke[ 8] = wpa->pke[ 8]; + pke[ 9] = wpa->pke[ 9]; + pke[10] = wpa->pke[10]; + pke[11] = wpa->pke[11]; + pke[12] = wpa->pke[12]; + pke[13] = wpa->pke[13]; + pke[14] = wpa->pke[14]; + pke[15] = wpa->pke[15]; + pke[16] = wpa->pke[16]; + pke[17] = wpa->pke[17]; + pke[18] = wpa->pke[18]; + pke[19] = wpa->pke[19]; + pke[20] = wpa->pke[20]; + pke[21] = wpa->pke[21]; + pke[22] = wpa->pke[22]; + pke[23] = wpa->pke[23]; + pke[24] = wpa->pke[24]; + pke[25] = wpa->pke[25]; + pke[26] = wpa->pke[26]; + pke[27] = wpa->pke[27]; + pke[28] = wpa->pke[28]; + pke[29] = wpa->pke[29]; + pke[30] = wpa->pke[30]; + pke[31] = wpa->pke[31]; + + u32 z[4]; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + + u32 to; + + u32 m0; + u32 m1; + + if (wpa->nonce_compare < 0) + { + m0 = pke[15] & ~0x000000ff; + m1 = pke[16] & ~0xffffff00; + + to = pke[15] << 24 + | pke[16] >> 8; + } + else + { + m0 = pke[23] & ~0x000000ff; + m1 = pke[24] & ~0xffffff00; + + to = pke[23] << 24 + | pke[24] >> 8; + } + + u32 bo_loops = wpa->detected_le + wpa->detected_be; + + bo_loops = (bo_loops == 0) ? 2 : bo_loops; + + const u32 nonce_error_corrections = wpa->nonce_error_corrections; + + for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++) + { + for (u32 bo_pos = 0; bo_pos < bo_loops; bo_pos++) + { + u32 t = to; + + if (bo_loops == 1) + { + if (wpa->detected_le == 1) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (wpa->detected_be == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + else + { + if (bo_pos == 0) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (bo_pos == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + + if (wpa->nonce_compare < 0) + { + pke[15] = m0 | (t >> 24); + pke[16] = m1 | (t << 8); + } + else + { + pke[23] = m0 | (t >> 24); + pke[24] = m1 | (t << 8); + } + + sha1_hmac_ctx_t ctx1; + + sha1_hmac_init_64 (&ctx1, out0, out1, z, z); + + sha1_hmac_update (&ctx1, pke, 100); + + sha1_hmac_final (&ctx1); + + ctx1.opad.h[0] = hc_swap32_S (ctx1.opad.h[0]); + ctx1.opad.h[1] = hc_swap32_S (ctx1.opad.h[1]); + ctx1.opad.h[2] = hc_swap32_S (ctx1.opad.h[2]); + ctx1.opad.h[3] = hc_swap32_S (ctx1.opad.h[3]); + + md5_hmac_ctx_t ctx2; + + md5_hmac_init_64 (&ctx2, ctx1.opad.h, z, z, z); + + md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len); + + md5_hmac_final (&ctx2); + + ctx2.opad.h[0] = hc_swap32_S (ctx2.opad.h[0]); + ctx2.opad.h[1] = hc_swap32_S (ctx2.opad.h[1]); + ctx2.opad.h[2] = hc_swap32_S (ctx2.opad.h[2]); + ctx2.opad.h[3] = hc_swap32_S (ctx2.opad.h[3]); + + /** + * final compare + */ + + if ((ctx2.opad.h[0] == wpa->keymic[0]) + && (ctx2.opad.h[1] == wpa->keymic[1]) + && (ctx2.opad.h[2] == wpa->keymic[2]) + && (ctx2.opad.h[3] == wpa->keymic[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + } + } +} + +KERNEL_FQ void m22000_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 out0[4]; + u32 out1[4]; + + out0[0] = tmps[gid].out[0]; + out0[1] = tmps[gid].out[1]; + out0[2] = tmps[gid].out[2]; + out0[3] = tmps[gid].out[3]; + out1[0] = tmps[gid].out[4]; + out1[1] = tmps[gid].out[5]; + out1[2] = tmps[gid].out[6]; + out1[3] = tmps[gid].out[7]; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + u32 pke[32]; + + pke[ 0] = wpa->pke[ 0]; + pke[ 1] = wpa->pke[ 1]; + pke[ 2] = wpa->pke[ 2]; + pke[ 3] = wpa->pke[ 3]; + pke[ 4] = wpa->pke[ 4]; + pke[ 5] = wpa->pke[ 5]; + pke[ 6] = wpa->pke[ 6]; + pke[ 7] = wpa->pke[ 7]; + pke[ 8] = wpa->pke[ 8]; + pke[ 9] = wpa->pke[ 9]; + pke[10] = wpa->pke[10]; + pke[11] = wpa->pke[11]; + pke[12] = wpa->pke[12]; + pke[13] = wpa->pke[13]; + pke[14] = wpa->pke[14]; + pke[15] = wpa->pke[15]; + pke[16] = wpa->pke[16]; + pke[17] = wpa->pke[17]; + pke[18] = wpa->pke[18]; + pke[19] = wpa->pke[19]; + pke[20] = wpa->pke[20]; + pke[21] = wpa->pke[21]; + pke[22] = wpa->pke[22]; + pke[23] = wpa->pke[23]; + pke[24] = wpa->pke[24]; + pke[25] = wpa->pke[25]; + pke[26] = wpa->pke[26]; + pke[27] = wpa->pke[27]; + pke[28] = wpa->pke[28]; + pke[29] = wpa->pke[29]; + pke[30] = wpa->pke[30]; + pke[31] = wpa->pke[31]; + + u32 z[4]; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + + u32 to; + + u32 m0; + u32 m1; + + if (wpa->nonce_compare < 0) + { + m0 = pke[15] & ~0x000000ff; + m1 = pke[16] & ~0xffffff00; + + to = pke[15] << 24 + | pke[16] >> 8; + } + else + { + m0 = pke[23] & ~0x000000ff; + m1 = pke[24] & ~0xffffff00; + + to = pke[23] << 24 + | pke[24] >> 8; + } + + u32 bo_loops = wpa->detected_le + wpa->detected_be; + + bo_loops = (bo_loops == 0) ? 2 : bo_loops; + + const u32 nonce_error_corrections = wpa->nonce_error_corrections; + + for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++) + { + for (u32 bo_pos = 0; bo_pos < bo_loops; bo_pos++) + { + u32 t = to; + + if (bo_loops == 1) + { + if (wpa->detected_le == 1) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (wpa->detected_be == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + else + { + if (bo_pos == 0) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (bo_pos == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + + if (wpa->nonce_compare < 0) + { + pke[15] = m0 | (t >> 24); + pke[16] = m1 | (t << 8); + } + else + { + pke[23] = m0 | (t >> 24); + pke[24] = m1 | (t << 8); + } + + sha1_hmac_ctx_t ctx1; + + sha1_hmac_init_64 (&ctx1, out0, out1, z, z); + + sha1_hmac_update (&ctx1, pke, 100); + + sha1_hmac_final (&ctx1); + + sha1_hmac_ctx_t ctx2; + + sha1_hmac_init_64 (&ctx2, ctx1.opad.h, z, z, z); + + sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len); + + sha1_hmac_final (&ctx2); + + /** + * final compare + */ + + if ((ctx2.opad.h[0] == wpa->keymic[0]) + && (ctx2.opad.h[1] == wpa->keymic[1]) + && (ctx2.opad.h[2] == wpa->keymic[2]) + && (ctx2.opad.h[3] == wpa->keymic[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + } + } +} + +KERNEL_FQ void m22000_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + /** + * aes shared + */ + + #ifdef REAL_SHM + + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + #ifdef IS_CUDA + __syncthreads(); + #else + SYNC_THREADS (); + #endif + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 out0[4]; + u32 out1[4]; + + out0[0] = tmps[gid].out[0]; + out0[1] = tmps[gid].out[1]; + out0[2] = tmps[gid].out[2]; + out0[3] = tmps[gid].out[3]; + out1[0] = tmps[gid].out[4]; + out1[1] = tmps[gid].out[5]; + out1[2] = tmps[gid].out[6]; + out1[3] = tmps[gid].out[7]; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + u32 pke[32]; + + pke[ 0] = wpa->pke[ 0]; + pke[ 1] = wpa->pke[ 1]; + pke[ 2] = wpa->pke[ 2]; + pke[ 3] = wpa->pke[ 3]; + pke[ 4] = wpa->pke[ 4]; + pke[ 5] = wpa->pke[ 5]; + pke[ 6] = wpa->pke[ 6]; + pke[ 7] = wpa->pke[ 7]; + pke[ 8] = wpa->pke[ 8]; + pke[ 9] = wpa->pke[ 9]; + pke[10] = wpa->pke[10]; + pke[11] = wpa->pke[11]; + pke[12] = wpa->pke[12]; + pke[13] = wpa->pke[13]; + pke[14] = wpa->pke[14]; + pke[15] = wpa->pke[15]; + pke[16] = wpa->pke[16]; + pke[17] = wpa->pke[17]; + pke[18] = wpa->pke[18]; + pke[19] = wpa->pke[19]; + pke[20] = wpa->pke[20]; + pke[21] = wpa->pke[21]; + pke[22] = wpa->pke[22]; + pke[23] = wpa->pke[23]; + pke[24] = wpa->pke[24]; + pke[25] = wpa->pke[25]; + pke[26] = wpa->pke[26]; + pke[27] = wpa->pke[27]; + pke[28] = wpa->pke[28]; + pke[29] = wpa->pke[29]; + pke[30] = wpa->pke[30]; + pke[31] = wpa->pke[31]; + + u32 z[4]; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + + u32 to; + + u32 m0; + u32 m1; + + if (wpa->nonce_compare < 0) + { + m0 = pke[15] & ~0x000000ff; + m1 = pke[16] & ~0xffffff00; + + to = pke[15] << 24 + | pke[16] >> 8; + } + else + { + m0 = pke[23] & ~0x000000ff; + m1 = pke[24] & ~0xffffff00; + + to = pke[23] << 24 + | pke[24] >> 8; + } + + u32 bo_loops = wpa->detected_le + wpa->detected_be; + + bo_loops = (bo_loops == 0) ? 2 : bo_loops; + + const u32 nonce_error_corrections = wpa->nonce_error_corrections; + + for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++) + { + for (u32 bo_pos = 0; bo_pos < bo_loops; bo_pos++) + { + u32 t = to; + + if (bo_loops == 1) + { + if (wpa->detected_le == 1) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (wpa->detected_be == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + else + { + if (bo_pos == 0) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (bo_pos == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + + if (wpa->nonce_compare < 0) + { + pke[15] = m0 | (t >> 24); + pke[16] = m1 | (t << 8); + } + else + { + pke[23] = m0 | (t >> 24); + pke[24] = m1 | (t << 8); + } + + sha256_hmac_ctx_t ctx1; + + sha256_hmac_init_64 (&ctx1, out0, out1, z, z); + + sha256_hmac_update (&ctx1, pke, 102); + + sha256_hmac_final (&ctx1); + + ctx1.opad.h[0] = hc_swap32_S (ctx1.opad.h[0]); + ctx1.opad.h[1] = hc_swap32_S (ctx1.opad.h[1]); + ctx1.opad.h[2] = hc_swap32_S (ctx1.opad.h[2]); + ctx1.opad.h[3] = hc_swap32_S (ctx1.opad.h[3]); + + // AES CMAC + + u32 ks[44]; + + aes128_set_encrypt_key (ks, ctx1.opad.h, s_te0, s_te1, s_te2, s_te3); + + u32 m[4]; + + m[0] = 0; + m[1] = 0; + m[2] = 0; + m[3] = 0; + + u32 iv[4]; + + iv[0] = 0; + iv[1] = 0; + iv[2] = 0; + iv[3] = 0; + + int eapol_left; + int eapol_idx; + + for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4) + { + m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0]; + m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1]; + m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2]; + m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3]; + + aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4); + } + + m[0] = wpa->eapol[eapol_idx + 0]; + m[1] = wpa->eapol[eapol_idx + 1]; + m[2] = wpa->eapol[eapol_idx + 2]; + m[3] = wpa->eapol[eapol_idx + 3]; + + u32 k[4]; + + k[0] = 0; + k[1] = 0; + k[2] = 0; + k[3] = 0; + + aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4); + + make_kn (k); + + if (eapol_left < 16) + { + make_kn (k); + } + + m[0] ^= k[0]; + m[1] ^= k[1]; + m[2] ^= k[2]; + m[3] ^= k[3]; + + m[0] ^= iv[0]; + m[1] ^= iv[1]; + m[2] ^= iv[2]; + m[3] ^= iv[3]; + + u32 keymic[4]; + + keymic[0] = 0; + keymic[1] = 0; + keymic[2] = 0; + keymic[3] = 0; + + aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4); + + /** + * final compare + */ + + keymic[0] = hc_swap32_S (keymic[0]); + keymic[1] = hc_swap32_S (keymic[1]); + keymic[2] = hc_swap32_S (keymic[2]); + keymic[3] = hc_swap32_S (keymic[3]); + + if ((keymic[0] == wpa->keymic[0]) + && (keymic[1] == wpa->keymic[1]) + && (keymic[2] == wpa->keymic[2]) + && (keymic[3] == wpa->keymic[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + } + } +} + +KERNEL_FQ void m22000_aux4 (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w[16]; + + w[ 0] = tmps[gid].out[0]; + w[ 1] = tmps[gid].out[1]; + w[ 2] = tmps[gid].out[2]; + w[ 3] = tmps[gid].out[3]; + w[ 4] = tmps[gid].out[4]; + w[ 5] = tmps[gid].out[5]; + w[ 6] = tmps[gid].out[6]; + w[ 7] = tmps[gid].out[7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = 0; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init (&sha1_hmac_ctx, w, 32); + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, wpa->pmkid_data, 20); + + sha1_hmac_final (&sha1_hmac_ctx); + + const u32 r0 = sha1_hmac_ctx.opad.h[0]; + const u32 r1 = sha1_hmac_ctx.opad.h[1]; + const u32 r2 = sha1_hmac_ctx.opad.h[2]; + const u32 r3 = sha1_hmac_ctx.opad.h[3]; + + #ifdef KERNEL_STATIC + + #define il_pos 0 + #include COMPARE_M + + #else + + if ((hc_swap32_S (r0) == wpa->pmkid[0]) + && (hc_swap32_S (r1) == wpa->pmkid[1]) + && (hc_swap32_S (r2) == wpa->pmkid[2]) + && (hc_swap32_S (r3) == wpa->pmkid[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + + #endif +} diff --git a/OpenCL/m22001-pure.cl b/OpenCL/m22001-pure.cl new file mode 100644 index 000000000..e3a9d23f9 --- /dev/null +++ b/OpenCL/m22001-pure.cl @@ -0,0 +1,945 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_md5.cl" +#include "inc_hash_sha1.cl" +#include "inc_hash_sha256.cl" +#include "inc_cipher_aes.cl" +#else +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.h" +#include "inc_common.h" +#include "inc_simd.h" +#include "inc_hash_md5.h" +#include "inc_hash_sha1.h" +#include "inc_hash_sha256.h" +#include "inc_cipher_aes.h" +#endif + +#define COMPARE_S "inc_comp_single.cl" +#define COMPARE_M "inc_comp_multi.cl" + +typedef struct wpa_pmk_tmp +{ + u32 out[8]; + +} wpa_pmk_tmp_t; + +typedef struct wpa +{ + u32 essid_buf[16]; + u32 essid_len; + + u32 mac_ap[2]; + u32 mac_sta[2]; + + u32 type; // 1 = PMKID, 2 = EAPOL + + // PMKID specific + + u32 pmkid[4]; + u32 pmkid_data[16]; + + // EAPOL specific + + u32 keymic[4]; + u32 anonce[8]; + + u32 keyver; + + u32 eapol[64 + 16]; + u32 eapol_len; + + u32 pke[32]; + + int message_pair_chgd; + u32 message_pair; + + int nonce_error_corrections_chgd; + int nonce_error_corrections; + + int nonce_compare; + int detected_le; + int detected_be; + +} wpa_t; + +#ifdef KERNEL_STATIC +DECLSPEC u8 hex_convert (const u8 c) +{ + return (c & 15) + (c >> 6) * 9; +} + +DECLSPEC u8 hex_to_u8 (const u8 *hex) +{ + u8 v = 0; + + v |= ((u8) hex_convert (hex[1]) << 0); + v |= ((u8) hex_convert (hex[0]) << 4); + + return (v); +} +#endif + +DECLSPEC void make_kn (u32 *k) +{ + u32 kl[4]; + u32 kr[4]; + + kl[0] = (k[0] << 1) & 0xfefefefe; + kl[1] = (k[1] << 1) & 0xfefefefe; + kl[2] = (k[2] << 1) & 0xfefefefe; + kl[3] = (k[3] << 1) & 0xfefefefe; + + kr[0] = (k[0] >> 7) & 0x01010101; + kr[1] = (k[1] >> 7) & 0x01010101; + kr[2] = (k[2] >> 7) & 0x01010101; + kr[3] = (k[3] >> 7) & 0x01010101; + + const u32 c = kr[0] & 1; + + kr[0] = kr[0] >> 8 | kr[1] << 24; + kr[1] = kr[1] >> 8 | kr[2] << 24; + kr[2] = kr[2] >> 8 | kr[3] << 24; + kr[3] = kr[3] >> 8; + + k[0] = kl[0] | kr[0]; + k[1] = kl[1] | kr[1]; + k[2] = kl[2] | kr[2]; + k[3] = kl[3] | kr[3]; + + k[3] ^= c * 0x87000000; +} + +DECLSPEC void hmac_sha1_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m22001_init (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 in[16]; + + in[ 0] = pws[gid].i[ 0]; + in[ 1] = pws[gid].i[ 1]; + in[ 2] = pws[gid].i[ 2]; + in[ 3] = pws[gid].i[ 3]; + in[ 4] = pws[gid].i[ 4]; + in[ 5] = pws[gid].i[ 5]; + in[ 6] = pws[gid].i[ 6]; + in[ 7] = pws[gid].i[ 7]; + in[ 8] = pws[gid].i[ 8]; + in[ 9] = pws[gid].i[ 9]; + in[10] = pws[gid].i[10]; + in[11] = pws[gid].i[11]; + in[12] = pws[gid].i[12]; + in[13] = pws[gid].i[13]; + in[14] = pws[gid].i[14]; + in[15] = pws[gid].i[15]; + + u8 *in_ptr = (u8 *) in; + + u32 out[8]; + + u8 *out_ptr = (u8 *) out; + + for (int i = 0, j = 0; i < 32; i += 1, j += 2) + { + out_ptr[i] = hex_to_u8 (in_ptr + j); + } + + tmps[gid].out[0] = hc_swap32_S (out[0]); + tmps[gid].out[1] = hc_swap32_S (out[1]); + tmps[gid].out[2] = hc_swap32_S (out[2]); + tmps[gid].out[3] = hc_swap32_S (out[3]); + tmps[gid].out[4] = hc_swap32_S (out[4]); + tmps[gid].out[5] = hc_swap32_S (out[5]); + tmps[gid].out[6] = hc_swap32_S (out[6]); + tmps[gid].out[7] = hc_swap32_S (out[7]); +} + +KERNEL_FQ void m22001_loop (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + // not in use here, special case... +} + +KERNEL_FQ void m22001_comp (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + // not in use here, special case... +} + +KERNEL_FQ void m22001_aux1 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 out0[4]; + u32 out1[4]; + + out0[0] = tmps[gid].out[0]; + out0[1] = tmps[gid].out[1]; + out0[2] = tmps[gid].out[2]; + out0[3] = tmps[gid].out[3]; + out1[0] = tmps[gid].out[4]; + out1[1] = tmps[gid].out[5]; + out1[2] = tmps[gid].out[6]; + out1[3] = tmps[gid].out[7]; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + u32 pke[32]; + + pke[ 0] = wpa->pke[ 0]; + pke[ 1] = wpa->pke[ 1]; + pke[ 2] = wpa->pke[ 2]; + pke[ 3] = wpa->pke[ 3]; + pke[ 4] = wpa->pke[ 4]; + pke[ 5] = wpa->pke[ 5]; + pke[ 6] = wpa->pke[ 6]; + pke[ 7] = wpa->pke[ 7]; + pke[ 8] = wpa->pke[ 8]; + pke[ 9] = wpa->pke[ 9]; + pke[10] = wpa->pke[10]; + pke[11] = wpa->pke[11]; + pke[12] = wpa->pke[12]; + pke[13] = wpa->pke[13]; + pke[14] = wpa->pke[14]; + pke[15] = wpa->pke[15]; + pke[16] = wpa->pke[16]; + pke[17] = wpa->pke[17]; + pke[18] = wpa->pke[18]; + pke[19] = wpa->pke[19]; + pke[20] = wpa->pke[20]; + pke[21] = wpa->pke[21]; + pke[22] = wpa->pke[22]; + pke[23] = wpa->pke[23]; + pke[24] = wpa->pke[24]; + pke[25] = wpa->pke[25]; + pke[26] = wpa->pke[26]; + pke[27] = wpa->pke[27]; + pke[28] = wpa->pke[28]; + pke[29] = wpa->pke[29]; + pke[30] = wpa->pke[30]; + pke[31] = wpa->pke[31]; + + u32 z[4]; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + + u32 to; + + u32 m0; + u32 m1; + + if (wpa->nonce_compare < 0) + { + m0 = pke[15] & ~0x000000ff; + m1 = pke[16] & ~0xffffff00; + + to = pke[15] << 24 + | pke[16] >> 8; + } + else + { + m0 = pke[23] & ~0x000000ff; + m1 = pke[24] & ~0xffffff00; + + to = pke[23] << 24 + | pke[24] >> 8; + } + + u32 bo_loops = wpa->detected_le + wpa->detected_be; + + bo_loops = (bo_loops == 0) ? 2 : bo_loops; + + const u32 nonce_error_corrections = wpa->nonce_error_corrections; + + for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++) + { + for (u32 bo_pos = 0; bo_pos < bo_loops; bo_pos++) + { + u32 t = to; + + if (bo_loops == 1) + { + if (wpa->detected_le == 1) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (wpa->detected_be == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + else + { + if (bo_pos == 0) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (bo_pos == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + + if (wpa->nonce_compare < 0) + { + pke[15] = m0 | (t >> 24); + pke[16] = m1 | (t << 8); + } + else + { + pke[23] = m0 | (t >> 24); + pke[24] = m1 | (t << 8); + } + + sha1_hmac_ctx_t ctx1; + + sha1_hmac_init_64 (&ctx1, out0, out1, z, z); + + sha1_hmac_update (&ctx1, pke, 100); + + sha1_hmac_final (&ctx1); + + ctx1.opad.h[0] = hc_swap32_S (ctx1.opad.h[0]); + ctx1.opad.h[1] = hc_swap32_S (ctx1.opad.h[1]); + ctx1.opad.h[2] = hc_swap32_S (ctx1.opad.h[2]); + ctx1.opad.h[3] = hc_swap32_S (ctx1.opad.h[3]); + + md5_hmac_ctx_t ctx2; + + md5_hmac_init_64 (&ctx2, ctx1.opad.h, z, z, z); + + md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len); + + md5_hmac_final (&ctx2); + + ctx2.opad.h[0] = hc_swap32_S (ctx2.opad.h[0]); + ctx2.opad.h[1] = hc_swap32_S (ctx2.opad.h[1]); + ctx2.opad.h[2] = hc_swap32_S (ctx2.opad.h[2]); + ctx2.opad.h[3] = hc_swap32_S (ctx2.opad.h[3]); + + /** + * final compare + */ + + if ((ctx2.opad.h[0] == wpa->keymic[0]) + && (ctx2.opad.h[1] == wpa->keymic[1]) + && (ctx2.opad.h[2] == wpa->keymic[2]) + && (ctx2.opad.h[3] == wpa->keymic[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + } + } +} + +KERNEL_FQ void m22001_aux2 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 out0[4]; + u32 out1[4]; + + out0[0] = tmps[gid].out[0]; + out0[1] = tmps[gid].out[1]; + out0[2] = tmps[gid].out[2]; + out0[3] = tmps[gid].out[3]; + out1[0] = tmps[gid].out[4]; + out1[1] = tmps[gid].out[5]; + out1[2] = tmps[gid].out[6]; + out1[3] = tmps[gid].out[7]; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + u32 pke[32]; + + pke[ 0] = wpa->pke[ 0]; + pke[ 1] = wpa->pke[ 1]; + pke[ 2] = wpa->pke[ 2]; + pke[ 3] = wpa->pke[ 3]; + pke[ 4] = wpa->pke[ 4]; + pke[ 5] = wpa->pke[ 5]; + pke[ 6] = wpa->pke[ 6]; + pke[ 7] = wpa->pke[ 7]; + pke[ 8] = wpa->pke[ 8]; + pke[ 9] = wpa->pke[ 9]; + pke[10] = wpa->pke[10]; + pke[11] = wpa->pke[11]; + pke[12] = wpa->pke[12]; + pke[13] = wpa->pke[13]; + pke[14] = wpa->pke[14]; + pke[15] = wpa->pke[15]; + pke[16] = wpa->pke[16]; + pke[17] = wpa->pke[17]; + pke[18] = wpa->pke[18]; + pke[19] = wpa->pke[19]; + pke[20] = wpa->pke[20]; + pke[21] = wpa->pke[21]; + pke[22] = wpa->pke[22]; + pke[23] = wpa->pke[23]; + pke[24] = wpa->pke[24]; + pke[25] = wpa->pke[25]; + pke[26] = wpa->pke[26]; + pke[27] = wpa->pke[27]; + pke[28] = wpa->pke[28]; + pke[29] = wpa->pke[29]; + pke[30] = wpa->pke[30]; + pke[31] = wpa->pke[31]; + + u32 z[4]; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + + u32 to; + + u32 m0; + u32 m1; + + if (wpa->nonce_compare < 0) + { + m0 = pke[15] & ~0x000000ff; + m1 = pke[16] & ~0xffffff00; + + to = pke[15] << 24 + | pke[16] >> 8; + } + else + { + m0 = pke[23] & ~0x000000ff; + m1 = pke[24] & ~0xffffff00; + + to = pke[23] << 24 + | pke[24] >> 8; + } + + u32 bo_loops = wpa->detected_le + wpa->detected_be; + + bo_loops = (bo_loops == 0) ? 2 : bo_loops; + + const u32 nonce_error_corrections = wpa->nonce_error_corrections; + + for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++) + { + for (u32 bo_pos = 0; bo_pos < bo_loops; bo_pos++) + { + u32 t = to; + + if (bo_loops == 1) + { + if (wpa->detected_le == 1) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (wpa->detected_be == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + else + { + if (bo_pos == 0) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (bo_pos == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + + if (wpa->nonce_compare < 0) + { + pke[15] = m0 | (t >> 24); + pke[16] = m1 | (t << 8); + } + else + { + pke[23] = m0 | (t >> 24); + pke[24] = m1 | (t << 8); + } + + sha1_hmac_ctx_t ctx1; + + sha1_hmac_init_64 (&ctx1, out0, out1, z, z); + + sha1_hmac_update (&ctx1, pke, 100); + + sha1_hmac_final (&ctx1); + + sha1_hmac_ctx_t ctx2; + + sha1_hmac_init_64 (&ctx2, ctx1.opad.h, z, z, z); + + sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len); + + sha1_hmac_final (&ctx2); + + /** + * final compare + */ + + if ((ctx2.opad.h[0] == wpa->keymic[0]) + && (ctx2.opad.h[1] == wpa->keymic[1]) + && (ctx2.opad.h[2] == wpa->keymic[2]) + && (ctx2.opad.h[3] == wpa->keymic[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + } + } +} + +KERNEL_FQ void m22001_aux3 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + /** + * aes shared + */ + + #ifdef REAL_SHM + + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + #ifdef IS_CUDA + __syncthreads(); + #else + SYNC_THREADS (); + #endif + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 out0[4]; + u32 out1[4]; + + out0[0] = tmps[gid].out[0]; + out0[1] = tmps[gid].out[1]; + out0[2] = tmps[gid].out[2]; + out0[3] = tmps[gid].out[3]; + out1[0] = tmps[gid].out[4]; + out1[1] = tmps[gid].out[5]; + out1[2] = tmps[gid].out[6]; + out1[3] = tmps[gid].out[7]; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + u32 pke[32]; + + pke[ 0] = wpa->pke[ 0]; + pke[ 1] = wpa->pke[ 1]; + pke[ 2] = wpa->pke[ 2]; + pke[ 3] = wpa->pke[ 3]; + pke[ 4] = wpa->pke[ 4]; + pke[ 5] = wpa->pke[ 5]; + pke[ 6] = wpa->pke[ 6]; + pke[ 7] = wpa->pke[ 7]; + pke[ 8] = wpa->pke[ 8]; + pke[ 9] = wpa->pke[ 9]; + pke[10] = wpa->pke[10]; + pke[11] = wpa->pke[11]; + pke[12] = wpa->pke[12]; + pke[13] = wpa->pke[13]; + pke[14] = wpa->pke[14]; + pke[15] = wpa->pke[15]; + pke[16] = wpa->pke[16]; + pke[17] = wpa->pke[17]; + pke[18] = wpa->pke[18]; + pke[19] = wpa->pke[19]; + pke[20] = wpa->pke[20]; + pke[21] = wpa->pke[21]; + pke[22] = wpa->pke[22]; + pke[23] = wpa->pke[23]; + pke[24] = wpa->pke[24]; + pke[25] = wpa->pke[25]; + pke[26] = wpa->pke[26]; + pke[27] = wpa->pke[27]; + pke[28] = wpa->pke[28]; + pke[29] = wpa->pke[29]; + pke[30] = wpa->pke[30]; + pke[31] = wpa->pke[31]; + + u32 z[4]; + + z[0] = 0; + z[1] = 0; + z[2] = 0; + z[3] = 0; + + u32 to; + + u32 m0; + u32 m1; + + if (wpa->nonce_compare < 0) + { + m0 = pke[15] & ~0x000000ff; + m1 = pke[16] & ~0xffffff00; + + to = pke[15] << 24 + | pke[16] >> 8; + } + else + { + m0 = pke[23] & ~0x000000ff; + m1 = pke[24] & ~0xffffff00; + + to = pke[23] << 24 + | pke[24] >> 8; + } + + u32 bo_loops = wpa->detected_le + wpa->detected_be; + + bo_loops = (bo_loops == 0) ? 2 : bo_loops; + + const u32 nonce_error_corrections = wpa->nonce_error_corrections; + + for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++) + { + for (u32 bo_pos = 0; bo_pos < bo_loops; bo_pos++) + { + u32 t = to; + + if (bo_loops == 1) + { + if (wpa->detected_le == 1) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (wpa->detected_be == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + else + { + if (bo_pos == 0) + { + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + } + else if (bo_pos == 1) + { + t = hc_swap32_S (t); + + t -= nonce_error_corrections / 2; + t += nonce_error_correction; + + t = hc_swap32_S (t); + } + } + + if (wpa->nonce_compare < 0) + { + pke[15] = m0 | (t >> 24); + pke[16] = m1 | (t << 8); + } + else + { + pke[23] = m0 | (t >> 24); + pke[24] = m1 | (t << 8); + } + + sha256_hmac_ctx_t ctx1; + + sha256_hmac_init_64 (&ctx1, out0, out1, z, z); + + sha256_hmac_update (&ctx1, pke, 102); + + sha256_hmac_final (&ctx1); + + ctx1.opad.h[0] = hc_swap32_S (ctx1.opad.h[0]); + ctx1.opad.h[1] = hc_swap32_S (ctx1.opad.h[1]); + ctx1.opad.h[2] = hc_swap32_S (ctx1.opad.h[2]); + ctx1.opad.h[3] = hc_swap32_S (ctx1.opad.h[3]); + + // AES CMAC + + u32 ks[44]; + + aes128_set_encrypt_key (ks, ctx1.opad.h, s_te0, s_te1, s_te2, s_te3); + + u32 m[4]; + + m[0] = 0; + m[1] = 0; + m[2] = 0; + m[3] = 0; + + u32 iv[4]; + + iv[0] = 0; + iv[1] = 0; + iv[2] = 0; + iv[3] = 0; + + int eapol_left; + int eapol_idx; + + for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4) + { + m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0]; + m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1]; + m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2]; + m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3]; + + aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4); + } + + m[0] = wpa->eapol[eapol_idx + 0]; + m[1] = wpa->eapol[eapol_idx + 1]; + m[2] = wpa->eapol[eapol_idx + 2]; + m[3] = wpa->eapol[eapol_idx + 3]; + + u32 k[4]; + + k[0] = 0; + k[1] = 0; + k[2] = 0; + k[3] = 0; + + aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4); + + make_kn (k); + + if (eapol_left < 16) + { + make_kn (k); + } + + m[0] ^= k[0]; + m[1] ^= k[1]; + m[2] ^= k[2]; + m[3] ^= k[3]; + + m[0] ^= iv[0]; + m[1] ^= iv[1]; + m[2] ^= iv[2]; + m[3] ^= iv[3]; + + u32 keymic[4]; + + keymic[0] = 0; + keymic[1] = 0; + keymic[2] = 0; + keymic[3] = 0; + + aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4); + + /** + * final compare + */ + + keymic[0] = hc_swap32_S (keymic[0]); + keymic[1] = hc_swap32_S (keymic[1]); + keymic[2] = hc_swap32_S (keymic[2]); + keymic[3] = hc_swap32_S (keymic[3]); + + if ((keymic[0] == wpa->keymic[0]) + && (keymic[1] == wpa->keymic[1]) + && (keymic[2] == wpa->keymic[2]) + && (keymic[3] == wpa->keymic[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + } + } +} + +KERNEL_FQ void m22001_aux4 (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w[16]; + + w[ 0] = tmps[gid].out[0]; + w[ 1] = tmps[gid].out[1]; + w[ 2] = tmps[gid].out[2]; + w[ 3] = tmps[gid].out[3]; + w[ 4] = tmps[gid].out[4]; + w[ 5] = tmps[gid].out[5]; + w[ 6] = tmps[gid].out[6]; + w[ 7] = tmps[gid].out[7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = 0; + + const u32 digest_pos = loop_pos; + + const u32 digest_cur = digests_offset + digest_pos; + + GLOBAL_AS const wpa_t *wpa = &esalt_bufs[digest_cur]; + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init (&sha1_hmac_ctx, w, 32); + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, wpa->pmkid_data, 20); + + sha1_hmac_final (&sha1_hmac_ctx); + + const u32 r0 = sha1_hmac_ctx.opad.h[0]; + const u32 r1 = sha1_hmac_ctx.opad.h[1]; + const u32 r2 = sha1_hmac_ctx.opad.h[2]; + const u32 r3 = sha1_hmac_ctx.opad.h[3]; + + #ifdef KERNEL_STATIC + + #define il_pos 0 + #include COMPARE_M + + #else + + if ((hc_swap32_S (r0) == wpa->pmkid[0]) + && (hc_swap32_S (r1) == wpa->pmkid[1]) + && (hc_swap32_S (r2) == wpa->pmkid[2]) + && (hc_swap32_S (r3) == wpa->pmkid[3])) + { + if (atomic_inc (&hashes_shown[digest_cur]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0, 0, 0); + } + } + + #endif +} diff --git a/OpenCL/m22100-pure.cl b/OpenCL/m22100-pure.cl new file mode 100644 index 000000000..3a5f60b84 --- /dev/null +++ b/OpenCL/m22100-pure.cl @@ -0,0 +1,576 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#include "inc_cipher_aes.cl" +#endif + +#define ITERATION_BITLOCKER 0x100000 +#define SALT_LEN_BITLOCKER 16 +#define IV_LEN_BITLOCKER 12 +#define DATA_LEN_BITLOCKER 60 + +typedef struct bitlocker +{ + u32 type; + u32 iv[4]; + u32 data[15]; + u32 wb_ke_pc[ITERATION_BITLOCKER][48]; + +} bitlocker_t; + +typedef struct bitlocker_tmp +{ + u32 last_hash[8]; + u32 init_hash[8]; + +} bitlocker_tmp_t; + +#ifdef REAL_SHM +#define SHM_TYPE2 LOCAL_AS +#else +#define SHM_TYPE2 GLOBAL_AS const +#endif + +DECLSPEC void sha256_transform_vector_pc (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u32x *digest, SHM_TYPE2 u32 *s_wb_ke_pc) +{ + u32x a = digest[0]; + u32x b = digest[1]; + u32x c = digest[2]; + u32x d = digest[3]; + u32x e = digest[4]; + u32x f = digest[5]; + u32x g = digest[6]; + u32x h = digest[7]; + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = w3[2]; + u32x wf_t = w3[3]; + + #define ROUND_EXPAND_PC(i) \ + { \ + w0_t = s_wb_ke_pc[i + 0]; \ + w1_t = s_wb_ke_pc[i + 1]; \ + w2_t = s_wb_ke_pc[i + 2]; \ + w3_t = s_wb_ke_pc[i + 3]; \ + w4_t = s_wb_ke_pc[i + 4]; \ + w5_t = s_wb_ke_pc[i + 5]; \ + w6_t = s_wb_ke_pc[i + 6]; \ + w7_t = s_wb_ke_pc[i + 7]; \ + w8_t = s_wb_ke_pc[i + 8]; \ + w9_t = s_wb_ke_pc[i + 9]; \ + wa_t = s_wb_ke_pc[i + 10]; \ + wb_t = s_wb_ke_pc[i + 11]; \ + wc_t = s_wb_ke_pc[i + 12]; \ + wd_t = s_wb_ke_pc[i + 13]; \ + we_t = s_wb_ke_pc[i + 14]; \ + wf_t = s_wb_ke_pc[i + 15]; \ + } + + #define ROUND_STEP(i) \ + { \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha256[i + 0]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha256[i + 1]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha256[i + 2]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha256[i + 3]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha256[i + 4]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha256[i + 5]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha256[i + 6]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha256[i + 7]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha256[i + 8]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha256[i + 9]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha256[i + 10]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha256[i + 11]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha256[i + 12]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha256[i + 13]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, k_sha256[i + 14]); \ + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha256[i + 15]); \ + } + + ROUND_STEP (0); + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 16; i < 64; i += 16) + { + ROUND_EXPAND_PC (i - 16); ROUND_STEP (i); + } + + #undef ROUND_EXPAND_PC + #undef ROUND_STEP + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; +} + +KERNEL_FQ void m22100_init (KERN_ATTR_TMPS_ESALT (bitlocker_tmp_t, bitlocker_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + // sha256 of utf16le converted password: + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_utf16le_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + sha256_final (&ctx0); + + u32 w[16] = { 0 }; // 64 bytes blocks/aligned, we need 32 bytes + + w[0] = ctx0.h[0]; + w[1] = ctx0.h[1]; + w[2] = ctx0.h[2]; + w[3] = ctx0.h[3]; + w[4] = ctx0.h[4]; + w[5] = ctx0.h[5]; + w[6] = ctx0.h[6]; + w[7] = ctx0.h[7]; + + // sha256 of sha256: + + sha256_ctx_t ctx1; + + sha256_init (&ctx1); + sha256_update (&ctx1, w, 32); + sha256_final (&ctx1); + + // set tmps: + + tmps[gid].init_hash[0] = ctx1.h[0]; + tmps[gid].init_hash[1] = ctx1.h[1]; + tmps[gid].init_hash[2] = ctx1.h[2]; + tmps[gid].init_hash[3] = ctx1.h[3]; + tmps[gid].init_hash[4] = ctx1.h[4]; + tmps[gid].init_hash[5] = ctx1.h[5]; + tmps[gid].init_hash[6] = ctx1.h[6]; + tmps[gid].init_hash[7] = ctx1.h[7]; + + tmps[gid].last_hash[0] = 0; + tmps[gid].last_hash[1] = 0; + tmps[gid].last_hash[2] = 0; + tmps[gid].last_hash[3] = 0; + tmps[gid].last_hash[4] = 0; + tmps[gid].last_hash[5] = 0; + tmps[gid].last_hash[6] = 0; + tmps[gid].last_hash[7] = 0; +} + +KERNEL_FQ void m22100_loop (KERN_ATTR_TMPS_ESALT (bitlocker_tmp_t, bitlocker_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + // init + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = packv (tmps, last_hash, gid, 0); // last_hash + w0[1] = packv (tmps, last_hash, gid, 1); + w0[2] = packv (tmps, last_hash, gid, 2); + w0[3] = packv (tmps, last_hash, gid, 3); + w1[0] = packv (tmps, last_hash, gid, 4); + w1[1] = packv (tmps, last_hash, gid, 5); + w1[2] = packv (tmps, last_hash, gid, 6); + w1[3] = packv (tmps, last_hash, gid, 7); + w2[0] = packv (tmps, init_hash, gid, 0); // init_hash + w2[1] = packv (tmps, init_hash, gid, 1); + w2[2] = packv (tmps, init_hash, gid, 2); + w2[3] = packv (tmps, init_hash, gid, 3); + w3[0] = packv (tmps, init_hash, gid, 4); + w3[1] = packv (tmps, init_hash, gid, 5); + w3[2] = packv (tmps, init_hash, gid, 6); + w3[3] = packv (tmps, init_hash, gid, 7); + + // salt to register + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + t0[0] = salt_bufs[salt_pos].salt_buf[0]; + t0[1] = salt_bufs[salt_pos].salt_buf[1]; + t0[2] = salt_bufs[salt_pos].salt_buf[2]; + t0[3] = salt_bufs[salt_pos].salt_buf[3]; + t1[0] = 0; + t1[1] = 0; + t1[2] = 0x80000000; + t1[3] = 0; + t2[0] = 0; + t2[1] = 0; + t2[2] = 0; + t2[3] = 0; + t3[0] = 0; + t3[1] = 0; + t3[2] = 0; + t3[3] = 88 * 8; + + /** + * load FIXED_ITER_INCR full w[] precomputed KE buffers into shared memory since its all static data + * in order for this to work we need to set a fixed loop count to FIXED_ITER_TOTAL in module + */ + + #define FIXED_ITER_TOTAL 4096 + #define FIXED_ITER_INCR 8 // seems to be a good trade-off between memory reads and available registers + + #ifdef REAL_SHM + LOCAL_VK u32 s_wb_ke_pc[FIXED_ITER_INCR][48]; + #else + GLOBAL_AS const u32 (*s_wb_ke_pc)[48]; + #endif + + for (u32 t = 0; t < FIXED_ITER_TOTAL; t += FIXED_ITER_INCR) + { + #ifdef REAL_SHM + + /** + * On NVIDIA, the __sync_threads() is not working as expected if called from inside a loop. + * This is a unique situation across all hashcat kernels so far. + * From CUDA manual: + * __syncthreads() is allowed in conditional code but only if the conditional evaluates identically across the entire thread block, + * otherwise the code execution is likely to hang or produce unintended side effects. + * NVIDIA OpenCL runtime is also affected, but other OpenCL runtimes work as they should. + * An workaround exists by disabling shared memory access. Speed drop is around 4%. + * Another workaround is to let only a single thread do all the work while all other threads wait for it to finish. Speed drop is around 0.05%. + + // original code + for (int i = lid; i < FIXED_ITER_INCR; i += lsz) + { + for (int j = 0; j < 48; j++) // first 16 set to register + { + s_wb_ke_pc[i][j] = esalt_bufs[digests_offset].wb_ke_pc[loop_pos + t + i][j]; + } + } + + */ + + if (lid == 0) + { + for (int i = 0; i < FIXED_ITER_INCR; i++) + { + for (int j = 0; j < 48; j++) // first 16 set to register + { + s_wb_ke_pc[i][j] = esalt_bufs[digests_offset].wb_ke_pc[loop_pos + t + i][j]; + } + } + } + + SYNC_THREADS (); + + #else + + s_wb_ke_pc = &esalt_bufs[digests_offset].wb_ke_pc[loop_pos + t]; + + #endif + + // main loop + + for (u32 i = 0, j = loop_pos + t; i < FIXED_ITER_INCR; i++, j++) + { + u32x digest[8]; + + digest[0] = SHA256M_A; + digest[1] = SHA256M_B; + digest[2] = SHA256M_C; + digest[3] = SHA256M_D; + digest[4] = SHA256M_E; + digest[5] = SHA256M_F; + digest[6] = SHA256M_G; + digest[7] = SHA256M_H; + + sha256_transform_vector (w0, w1, w2, w3, digest); + + t1[0] = hc_swap32_S (j); // only moving part + + sha256_transform_vector_pc (t0, t1, t2, t3, digest, s_wb_ke_pc[i]); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + } + } + + unpackv (tmps, last_hash, gid, 0, w0[0]); + unpackv (tmps, last_hash, gid, 1, w0[1]); + unpackv (tmps, last_hash, gid, 2, w0[2]); + unpackv (tmps, last_hash, gid, 3, w0[3]); + unpackv (tmps, last_hash, gid, 4, w1[0]); + unpackv (tmps, last_hash, gid, 5, w1[1]); + unpackv (tmps, last_hash, gid, 6, w1[2]); + unpackv (tmps, last_hash, gid, 7, w1[3]); +} + +KERNEL_FQ void m22100_comp (KERN_ATTR_TMPS_ESALT (bitlocker_tmp_t, bitlocker_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /* + * AES decrypt the data_buf + */ + + // init AES + + u32 ukey[8]; + + ukey[0] = tmps[gid].last_hash[0]; + ukey[1] = tmps[gid].last_hash[1]; + ukey[2] = tmps[gid].last_hash[2]; + ukey[3] = tmps[gid].last_hash[3]; + ukey[4] = tmps[gid].last_hash[4]; + ukey[5] = tmps[gid].last_hash[5]; + ukey[6] = tmps[gid].last_hash[6]; + ukey[7] = tmps[gid].last_hash[7]; + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + AES256_set_encrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3); + + // decrypt: + + u32 iv[4]; + + iv[0] = esalt_bufs[digests_offset].iv[0]; + iv[1] = esalt_bufs[digests_offset].iv[1]; + iv[2] = esalt_bufs[digests_offset].iv[2]; + iv[3] = esalt_bufs[digests_offset].iv[3]; + + // in total we've 60 bytes: we need out0 (16 bytes) to out3 (16 bytes) for MAC verification + + // 1 + + u32 out1[4]; + + AES256_encrypt (ks, iv, out1, s_te0, s_te1, s_te2, s_te3, s_te4); + + // some early reject: + + out1[0] ^= esalt_bufs[digests_offset].data[4]; // skip MAC for now (first 16 bytes) + + if ((out1[0] & 0xffff0000) != 0x2c000000) return; // data_size must be 0x2c00 + + + out1[1] ^= esalt_bufs[digests_offset].data[5]; + + if ((out1[1] & 0xffff0000) != 0x01000000) return; // version must be 0x0100 + + + out1[2] ^= esalt_bufs[digests_offset].data[6]; + + if ((out1[2] & 0x00ff0000) != 0x00200000) return; // v2 must be 0x20 + + if ((out1[2] >> 24) > 0x05) return; // v1 must be <= 5 + + // if no MAC verification should be performed, we are already done: + + u32 type = esalt_bufs[digests_offset].type; + + if (type == 0) + { + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); + } + + return; + } + + out1[3] ^= esalt_bufs[digests_offset].data[7]; + + /* + * Decrypt the whole data buffer for MAC verification (type == 1): + */ + + // 0 + + iv[3] = iv[3] & 0xff000000; // xx000000 + + u32 out0[4]; + + AES256_encrypt (ks, iv, out0, s_te0, s_te1, s_te2, s_te3, s_te4); + + out0[0] ^= esalt_bufs[digests_offset].data[0]; + out0[1] ^= esalt_bufs[digests_offset].data[1]; + out0[2] ^= esalt_bufs[digests_offset].data[2]; + out0[3] ^= esalt_bufs[digests_offset].data[3]; + + // 2 + + // add 2 because we already did block 1 for the early reject + + iv[3] += 2; // xx000002 + + u32 out2[4]; + + AES256_encrypt (ks, iv, out2, s_te0, s_te1, s_te2, s_te3, s_te4); + + out2[0] ^= esalt_bufs[digests_offset].data[ 8]; + out2[1] ^= esalt_bufs[digests_offset].data[ 9]; + out2[2] ^= esalt_bufs[digests_offset].data[10]; + out2[3] ^= esalt_bufs[digests_offset].data[11]; + + // 3 + + iv[3] += 1; // xx000003 + + u32 out3[4]; // actually only 3 needed + + AES256_encrypt (ks, iv, out3, s_te0, s_te1, s_te2, s_te3, s_te4); + + out3[0] ^= esalt_bufs[digests_offset].data[12]; + out3[1] ^= esalt_bufs[digests_offset].data[13]; + out3[2] ^= esalt_bufs[digests_offset].data[14]; + + // compute MAC: + + // out1 + + iv[0] = (iv[0] & 0x00ffffff) | 0x3a000000; + iv[3] = (iv[3] & 0xff000000) | 0x0000002c; + + u32 mac[4]; + + AES256_encrypt (ks, iv, mac, s_te0, s_te1, s_te2, s_te3, s_te4); + + iv[0] = mac[0] ^ out1[0]; + iv[1] = mac[1] ^ out1[1]; + iv[2] = mac[2] ^ out1[2]; + iv[3] = mac[3] ^ out1[3]; + + // out2 + + AES256_encrypt (ks, iv, mac, s_te0, s_te1, s_te2, s_te3, s_te4); + + iv[0] = mac[0] ^ out2[0]; + iv[1] = mac[1] ^ out2[1]; + iv[2] = mac[2] ^ out2[2]; + iv[3] = mac[3] ^ out2[3]; + + // out3 + + AES256_encrypt (ks, iv, mac, s_te0, s_te1, s_te2, s_te3, s_te4); + + iv[0] = mac[0] ^ out3[0]; + iv[1] = mac[1] ^ out3[1]; + iv[2] = mac[2] ^ out3[2]; + iv[3] = mac[3]; + + // final + + AES256_encrypt (ks, iv, mac, s_te0, s_te1, s_te2, s_te3, s_te4); + + if (mac[0] != out0[0]) return; + if (mac[1] != out0[1]) return; + if (mac[2] != out0[2]) return; + if (mac[3] != out0[3]) return; + + // if we end up here, we are sure to have found the correct password: + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, 0, 0, 0); + } +} diff --git a/OpenCL/m22200_a0-optimized.cl b/OpenCL/m22200_a0-optimized.cl new file mode 100644 index 000000000..8c0e51b03 --- /dev/null +++ b/OpenCL/m22200_a0-optimized.cl @@ -0,0 +1,382 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_rp_optimized.h" +#include "inc_rp_optimized.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" +#endif + +DECLSPEC void sha512_transform_intern (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u64x *digest) +{ + u64x w0_t = hl32_to_64 (w0[0], w0[1]); + u64x w1_t = hl32_to_64 (w0[2], w0[3]); + u64x w2_t = hl32_to_64 (w1[0], w1[1]); + u64x w3_t = hl32_to_64 (w1[2], w1[3]); + u64x w4_t = hl32_to_64 (w2[0], w2[1]); + u64x w5_t = hl32_to_64 (w2[2], w2[3]); + u64x w6_t = hl32_to_64 (w3[0], w3[1]); + u64x w7_t = 0; + u64x w8_t = 0; + u64x w9_t = 0; + u64x wa_t = 0; + u64x wb_t = 0; + u64x wc_t = 0; + u64x wd_t = 0; + u64x we_t = 0; + u64x wf_t = hl32_to_64 (w3[2], w3[3]); + + u64x a = digest[0]; + u64x b = digest[1]; + u64x c = digest[2]; + u64x d = digest[3]; + u64x e = digest[4]; + u64x f = digest[5]; + u64x g = digest[6]; + u64x h = digest[7]; + + #define ROUND_EXPAND() \ + { \ + w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t); \ + w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t); \ + w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t); \ + w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t); \ + w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t); \ + w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t); \ + w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t); \ + w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t); \ + w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t); \ + w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t); \ + wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t); \ + wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t); \ + wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t); \ + wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t); \ + we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t); \ + wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t); \ + } + + #define ROUND_STEP(i) \ + { \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha512[i + 0]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha512[i + 1]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha512[i + 2]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha512[i + 3]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha512[i + 4]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha512[i + 5]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha512[i + 6]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha512[i + 7]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha512[i + 8]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha512[i + 9]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha512[i + 10]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha512[i + 11]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha512[i + 12]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha512[i + 13]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k_sha512[i + 14]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha512[i + 15]); \ + } + + ROUND_STEP (0); + + #ifdef IS_CUDA + ROUND_EXPAND (); ROUND_STEP (16); + ROUND_EXPAND (); ROUND_STEP (32); + ROUND_EXPAND (); ROUND_STEP (48); + ROUND_EXPAND (); ROUND_STEP (64); + #else + #ifdef _unroll + #pragma unroll + #endif + for (int i = 16; i < 80; i += 16) + { + ROUND_EXPAND (); ROUND_STEP (i); + } + #endif + + /* rev + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + */ + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; +} + +KERNEL_FQ void m22200_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[2]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_4x4_VV (w0, w1, w2, w3, out_len + 1); + + w0[0] = hc_swap32 (w0[0]); + w0[1] = hc_swap32 (w0[1]); + w0[2] = hc_swap32 (w0[2]); + w0[3] = hc_swap32 (w0[3]); + w1[0] = hc_swap32 (w1[0]); + w1[1] = hc_swap32 (w1[1]); + w1[2] = hc_swap32 (w1[2]); + w1[3] = hc_swap32 (w1[3]); + w2[0] = hc_swap32 (w2[0]); + + /** + * prepend salt + */ + + const u32x out_salt_len = out_len + salt_len; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = salt_buf0[0]; + w0_t[1] = salt_buf0[1]; + w0_t[2] = w0[0]; + w0_t[3] = w0[1]; + w1_t[0] = w0[2]; + w1_t[1] = w0[3]; + w1_t[2] = w1[0]; + w1_t[3] = w1[1]; + w2_t[0] = w1[2]; + w2_t[1] = w1[3]; + w2_t[2] = w2[0]; + w2_t[3] = 0; + w3_t[0] = 0; + w3_t[1] = 0; + w3_t[2] = 0; + w3_t[3] = (out_salt_len + 1) * 8; + u64x digest[8]; + + digest[0] = SHA512M_A; + digest[1] = SHA512M_B; + digest[2] = SHA512M_C; + digest[3] = SHA512M_D; + digest[4] = SHA512M_E; + digest[5] = SHA512M_F; + digest[6] = SHA512M_G; + digest[7] = SHA512M_H; + + sha512_transform_intern (w0_t, w1_t, w2_t, w3_t, digest); + + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22200_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22200_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[2]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_4x4_VV (w0, w1, w2, w3, out_len + 1); + + w0[0] = hc_swap32 (w0[0]); + w0[1] = hc_swap32 (w0[1]); + w0[2] = hc_swap32 (w0[2]); + w0[3] = hc_swap32 (w0[3]); + w1[0] = hc_swap32 (w1[0]); + w1[1] = hc_swap32 (w1[1]); + w1[2] = hc_swap32 (w1[2]); + w1[3] = hc_swap32 (w1[3]); + w2[0] = hc_swap32 (w2[0]); + + /** + * prepend salt + */ + + const u32x out_salt_len = out_len + salt_len; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = salt_buf0[0]; + w0_t[1] = salt_buf0[1]; + w0_t[2] = w0[0]; + w0_t[3] = w0[1]; + w1_t[0] = w0[2]; + w1_t[1] = w0[3]; + w1_t[2] = w1[0]; + w1_t[3] = w1[1]; + w2_t[0] = w1[2]; + w2_t[1] = w1[3]; + w2_t[2] = w2[0]; + w2_t[3] = 0; + w3_t[0] = 0; + w3_t[1] = 0; + w3_t[2] = 0; + w3_t[3] = (out_salt_len + 1) * 8; + + u64x digest[8]; + + digest[0] = SHA512M_A; + digest[1] = SHA512M_B; + digest[2] = SHA512M_C; + digest[3] = SHA512M_D; + digest[4] = SHA512M_E; + digest[5] = SHA512M_F; + digest[6] = SHA512M_G; + digest[7] = SHA512M_H; + + sha512_transform_intern (w0_t, w1_t, w2_t, w3_t, digest); + + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22200_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m22200_a0-pure.cl b/OpenCL/m22200_a0-pure.cl new file mode 100644 index 000000000..ce07ea73a --- /dev/null +++ b/OpenCL/m22200_a0-pure.cl @@ -0,0 +1,133 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_rp.h" +#include "inc_rp.cl" +#include "inc_scalar.cl" +#include "inc_hash_sha512.cl" +#endif + +KERNEL_FQ void m22200_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 z[32] = { 0 }; + + COPY_PW (pws[gid]); + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha512_ctx_t ctx = ctx0; + + sha512_update_swap (&ctx, tmp.i, tmp.pw_len); + + sha512_update (&ctx, z, 1); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 z[32] = { 0 }; + + COPY_PW (pws[gid]); + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha512_ctx_t ctx = ctx0; + + sha512_update_swap (&ctx, tmp.i, tmp.pw_len); + + sha512_update (&ctx, z, 1); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22200_a1-optimized.cl b/OpenCL/m22200_a1-optimized.cl new file mode 100644 index 000000000..39ca46c20 --- /dev/null +++ b/OpenCL/m22200_a1-optimized.cl @@ -0,0 +1,511 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" +#endif + +DECLSPEC void sha512_transform_intern (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u64x *digest) +{ + u64x w0_t = hl32_to_64 (w0[0], w0[1]); + u64x w1_t = hl32_to_64 (w0[2], w0[3]); + u64x w2_t = hl32_to_64 (w1[0], w1[1]); + u64x w3_t = hl32_to_64 (w1[2], w1[3]); + u64x w4_t = hl32_to_64 (w2[0], w2[1]); + u64x w5_t = hl32_to_64 (w2[2], w2[3]); + u64x w6_t = hl32_to_64 (w3[0], w3[1]); + u64x w7_t = 0; + u64x w8_t = 0; + u64x w9_t = 0; + u64x wa_t = 0; + u64x wb_t = 0; + u64x wc_t = 0; + u64x wd_t = 0; + u64x we_t = 0; + u64x wf_t = hl32_to_64 (w3[2], w3[3]); + + u64x a = digest[0]; + u64x b = digest[1]; + u64x c = digest[2]; + u64x d = digest[3]; + u64x e = digest[4]; + u64x f = digest[5]; + u64x g = digest[6]; + u64x h = digest[7]; + + #define ROUND_EXPAND() \ + { \ + w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t); \ + w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t); \ + w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t); \ + w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t); \ + w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t); \ + w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t); \ + w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t); \ + w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t); \ + w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t); \ + w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t); \ + wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t); \ + wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t); \ + wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t); \ + wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t); \ + we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t); \ + wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t); \ + } + + #define ROUND_STEP(i) \ + { \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha512[i + 0]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha512[i + 1]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha512[i + 2]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha512[i + 3]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha512[i + 4]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha512[i + 5]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha512[i + 6]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha512[i + 7]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha512[i + 8]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha512[i + 9]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha512[i + 10]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha512[i + 11]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha512[i + 12]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha512[i + 13]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k_sha512[i + 14]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha512[i + 15]); \ + } + + ROUND_STEP (0); + + #ifdef IS_CUDA + ROUND_EXPAND (); ROUND_STEP (16); + ROUND_EXPAND (); ROUND_STEP (32); + ROUND_EXPAND (); ROUND_STEP (48); + ROUND_EXPAND (); ROUND_STEP (64); + #else + #ifdef _unroll + #pragma unroll + #endif + for (int i = 16; i < 80; i += 16) + { + ROUND_EXPAND (); ROUND_STEP (i); + } + #endif + + /* rev + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + */ + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; +} + +KERNEL_FQ void m22200_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[2]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + + append_0x80_4x4_VV (w0, w1, w2, w3, pw_len + 1); + + w0[0] = hc_swap32 (w0[0]); + w0[1] = hc_swap32 (w0[1]); + w0[2] = hc_swap32 (w0[2]); + w0[3] = hc_swap32 (w0[3]); + w1[0] = hc_swap32 (w1[0]); + w1[1] = hc_swap32 (w1[1]); + w1[2] = hc_swap32 (w1[2]); + w1[3] = hc_swap32 (w1[3]); + w2[0] = hc_swap32 (w2[0]); + w2[1] = hc_swap32 (w2[1]); + w2[2] = hc_swap32 (w2[2]); + w2[3] = hc_swap32 (w2[3]); + + /** + * prepend salt + */ + + const u32x pw_salt_len = pw_len + salt_len; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = salt_buf0[0]; + w0_t[1] = salt_buf0[1]; + w0_t[2] = w0[0]; + w0_t[3] = w0[1]; + w1_t[0] = w0[2]; + w1_t[1] = w0[3]; + w1_t[2] = w1[0]; + w1_t[3] = w1[1]; + w2_t[0] = w1[2]; + w2_t[1] = w1[3]; + w2_t[2] = w2[0]; + w2_t[3] = w2[1]; + w3_t[0] = w2[2]; + w3_t[1] = w2[3]; + w3_t[2] = 0; + w3_t[3] = (pw_salt_len + 1) * 8; + + u64x digest[8]; + + digest[0] = SHA512M_A; + digest[1] = SHA512M_B; + digest[2] = SHA512M_C; + digest[3] = SHA512M_D; + digest[4] = SHA512M_E; + digest[5] = SHA512M_F; + digest[6] = SHA512M_G; + digest[7] = SHA512M_H; + + sha512_transform_intern (w0_t, w1_t, w2_t, w3_t, digest); + + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22200_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22200_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[2]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + + append_0x80_4x4_VV (w0, w1, w2, w3, pw_len + 1); + + w0[0] = hc_swap32 (w0[0]); + w0[1] = hc_swap32 (w0[1]); + w0[2] = hc_swap32 (w0[2]); + w0[3] = hc_swap32 (w0[3]); + w1[0] = hc_swap32 (w1[0]); + w1[1] = hc_swap32 (w1[1]); + w1[2] = hc_swap32 (w1[2]); + w1[3] = hc_swap32 (w1[3]); + w2[0] = hc_swap32 (w2[0]); + w2[1] = hc_swap32 (w2[1]); + w2[2] = hc_swap32 (w2[2]); + w2[3] = hc_swap32 (w2[3]); + + /** + * prepend salt + */ + + const u32x pw_salt_len = pw_len + salt_len; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = salt_buf0[0]; + w0_t[1] = salt_buf0[1]; + w0_t[2] = w0[0]; + w0_t[3] = w0[1]; + w1_t[0] = w0[2]; + w1_t[1] = w0[3]; + w1_t[2] = w1[0]; + w1_t[3] = w1[1]; + w2_t[0] = w1[2]; + w2_t[1] = w1[3]; + w2_t[2] = w2[0]; + w2_t[3] = w2[1]; + w3_t[0] = w2[2]; + w3_t[1] = w2[3]; + w3_t[2] = 0; + w3_t[3] = (pw_salt_len + 1) * 8; + + u64x digest[8]; + + digest[0] = SHA512M_A; + digest[1] = SHA512M_B; + digest[2] = SHA512M_C; + digest[3] = SHA512M_D; + digest[4] = SHA512M_E; + digest[5] = SHA512M_F; + digest[6] = SHA512M_G; + digest[7] = SHA512M_H; + + sha512_transform_intern (w0_t, w1_t, w2_t, w3_t, digest); + + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22200_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m22200_a1-pure.cl b/OpenCL/m22200_a1-pure.cl new file mode 100644 index 000000000..5ee5567af --- /dev/null +++ b/OpenCL/m22200_a1-pure.cl @@ -0,0 +1,124 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_scalar.cl" +#include "inc_hash_sha512.cl" +#endif + +KERNEL_FQ void m22200_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 z[32] = { 0 }; + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + sha512_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + sha512_ctx_t ctx = ctx0; + + sha512_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha512_update (&ctx, z, 1); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + + +KERNEL_FQ void m22200_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 z[32] = { 0 }; + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + sha512_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + sha512_ctx_t ctx = ctx0; + + sha512_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha512_update (&ctx, z, 1); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22200_a3-optimized.cl b/OpenCL/m22200_a3-optimized.cl new file mode 100644 index 000000000..c04f8c8c4 --- /dev/null +++ b/OpenCL/m22200_a3-optimized.cl @@ -0,0 +1,735 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" +#endif + +DECLSPEC void sha512_transform_intern (const u32x *w0, const u32x *w1, const u32x *w2, const u32x *w3, u64x *digest) +{ + u64x w0_t = hl32_to_64 (w0[0], w0[1]); + u64x w1_t = hl32_to_64 (w0[2], w0[3]); + u64x w2_t = hl32_to_64 (w1[0], w1[1]); + u64x w3_t = hl32_to_64 (w1[2], w1[3]); + u64x w4_t = hl32_to_64 (w2[0], w2[1]); + u64x w5_t = hl32_to_64 (w2[2], w2[3]); + u64x w6_t = hl32_to_64 (w3[0], w3[1]); + u64x w7_t = 0; + u64x w8_t = 0; + u64x w9_t = 0; + u64x wa_t = 0; + u64x wb_t = 0; + u64x wc_t = 0; + u64x wd_t = 0; + u64x we_t = 0; + u64x wf_t = hl32_to_64 (w3[2], w3[3]); + + u64x a = digest[0]; + u64x b = digest[1]; + u64x c = digest[2]; + u64x d = digest[3]; + u64x e = digest[4]; + u64x f = digest[5]; + u64x g = digest[6]; + u64x h = digest[7]; + + #define ROUND_EXPAND() \ + { \ + w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t); \ + w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t); \ + w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t); \ + w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t); \ + w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t); \ + w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t); \ + w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t); \ + w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t); \ + w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t); \ + w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t); \ + wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t); \ + wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t); \ + wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t); \ + wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t); \ + we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t); \ + wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t); \ + } + + #define ROUND_STEP(i) \ + { \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha512[i + 0]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha512[i + 1]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha512[i + 2]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha512[i + 3]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha512[i + 4]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha512[i + 5]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha512[i + 6]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha512[i + 7]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha512[i + 8]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha512[i + 9]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha512[i + 10]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha512[i + 11]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha512[i + 12]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha512[i + 13]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k_sha512[i + 14]); \ + SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha512[i + 15]); \ + } + + ROUND_STEP (0); + + #ifdef IS_CUDA + ROUND_EXPAND (); ROUND_STEP (16); + ROUND_EXPAND (); ROUND_STEP (32); + ROUND_EXPAND (); ROUND_STEP (48); + ROUND_EXPAND (); ROUND_STEP (64); + #else + #ifdef _unroll + #pragma unroll + #endif + for (int i = 16; i < 80; i += 16) + { + ROUND_EXPAND (); ROUND_STEP (i); + } + #endif + + /* rev + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + */ + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; +} + +DECLSPEC void m22200m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + /** + * salt + */ + + u32 salt_buf0[2]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + /** + * loop + */ + + const u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = salt_buf0[0]; + w0_t[1] = salt_buf0[1]; + w0_t[2] = w0lr; + w0_t[3] = w0[1]; + w1_t[0] = w0[2]; + w1_t[1] = w0[3]; + w1_t[2] = w1[0]; + w1_t[3] = w1[1]; + w2_t[0] = w1[2]; + w2_t[1] = w1[3]; + w2_t[2] = w2[0]; + w2_t[3] = w2[1]; + w3_t[0] = w2[2]; + w3_t[1] = w2[3]; + w3_t[2] = 0; + w3_t[3] = (pw_salt_len + 1) * 8; + + u64x digest[8]; + + digest[0] = SHA512M_A; + digest[1] = SHA512M_B; + digest[2] = SHA512M_C; + digest[3] = SHA512M_D; + digest[4] = SHA512M_E; + digest[5] = SHA512M_F; + digest[6] = SHA512M_G; + digest[7] = SHA512M_H; + + sha512_transform_intern (w0_t, w1_t, w2_t, w3_t, digest); + + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +DECLSPEC void m22200s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + /** + * salt + */ + + u32 salt_buf0[2]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + const u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = salt_buf0[0]; + w0_t[1] = salt_buf0[1]; + w0_t[2] = w0lr; + w0_t[3] = w0[1]; + w1_t[0] = w0[2]; + w1_t[1] = w0[3]; + w1_t[2] = w1[0]; + w1_t[3] = w1[1]; + w2_t[0] = w1[2]; + w2_t[1] = w1[3]; + w2_t[2] = w2[0]; + w2_t[3] = w2[1]; + w3_t[0] = w2[2]; + w3_t[1] = w2[3]; + w3_t[2] = 0; + w3_t[3] = (pw_salt_len + 1) * 8; + + u64x digest[8]; + + digest[0] = SHA512M_A; + digest[1] = SHA512M_B; + digest[2] = SHA512M_C; + digest[3] = SHA512M_D; + digest[4] = SHA512M_E; + digest[5] = SHA512M_F; + digest[6] = SHA512M_G; + digest[7] = SHA512M_H; + + sha512_transform_intern (w0_t, w1_t, w2_t, w3_t, digest); + + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * base + */ + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + + append_0x80_2x4_S (w0, w1, pw_len + 1); + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + + /** + * main + */ + + m22200m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22200_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * base + */ + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + + append_0x80_3x4_S (w0, w1, w2, pw_len + 1); + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + + /** + * main + */ + + m22200m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22200_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * base + */ + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = 0; + w3[3] = 0; + + append_0x80_4x4_S (w0, w1, w2, w3, pw_len + 1); + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = 0; + w3[3] = 0; + + /** + * main + */ + + m22200m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22200_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * base + */ + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + + append_0x80_2x4_S (w0, w1, pw_len + 1); + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + + /** + * main + */ + + m22200s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22200_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * base + */ + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + + append_0x80_3x4_S (w0, w1, w2, pw_len + 1); + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + + /** + * main + */ + + m22200s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22200_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * base + */ + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = 0; + w3[3] = 0; + + append_0x80_4x4_S (w0, w1, w2, w3, pw_len + 1); + + w0[0] = hc_swap32_S (w0[0]); + w0[1] = hc_swap32_S (w0[1]); + w0[2] = hc_swap32_S (w0[2]); + w0[3] = hc_swap32_S (w0[3]); + w1[0] = hc_swap32_S (w1[0]); + w1[1] = hc_swap32_S (w1[1]); + w1[2] = hc_swap32_S (w1[2]); + w1[3] = hc_swap32_S (w1[3]); + w2[0] = hc_swap32_S (w2[0]); + w2[1] = hc_swap32_S (w2[1]); + w2[2] = hc_swap32_S (w2[2]); + w2[3] = hc_swap32_S (w2[3]); + w3[0] = hc_swap32_S (w3[0]); + w3[1] = hc_swap32_S (w3[1]); + w3[2] = 0; + w3[3] = 0; + + /** + * main + */ + + m22200s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} diff --git a/OpenCL/m22200_a3-pure.cl b/OpenCL/m22200_a3-pure.cl new file mode 100644 index 000000000..294230f5e --- /dev/null +++ b/OpenCL/m22200_a3-pure.cl @@ -0,0 +1,157 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha512.cl" +#endif + +KERNEL_FQ void m22200_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32x z[32] = { 0 }; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha512_ctx_vector_t ctx; + + sha512_init_vector_from_scalar (&ctx, &ctx0); + + sha512_update_vector (&ctx, w, pw_len); + + sha512_update_vector (&ctx, z, 1); + + sha512_final_vector (&ctx); + + const u32x r0 = l32_from_64 (ctx.h[7]); + const u32x r1 = h32_from_64 (ctx.h[7]); + const u32x r2 = l32_from_64 (ctx.h[3]); + const u32x r3 = h32_from_64 (ctx.h[3]); + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22200_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32x z[32] = { 0 }; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha512_ctx_vector_t ctx; + + sha512_init_vector_from_scalar (&ctx, &ctx0); + + sha512_update_vector (&ctx, w, pw_len); + + sha512_update_vector (&ctx, z, 1); + + sha512_final_vector (&ctx); + + const u32x r0 = l32_from_64 (ctx.h[7]); + const u32x r1 = h32_from_64 (ctx.h[7]); + const u32x r2 = l32_from_64 (ctx.h[3]); + const u32x r3 = h32_from_64 (ctx.h[3]); + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22300_a0-optimized.cl b/OpenCL/m22300_a0-optimized.cl new file mode 100644 index 000000000..8ca94cb57 --- /dev/null +++ b/OpenCL/m22300_a0-optimized.cl @@ -0,0 +1,574 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_rp_optimized.h" +#include "inc_rp_optimized.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#endif + +#define SHA256_STEP_REV(a,b,c,d,e,f,g,h) \ +{ \ + u32 t2 = SHA256_S2_S(b) + SHA256_F0o(b,c,d); \ + u32 t1 = a - t2; \ + a = b; \ + b = c; \ + c = d; \ + d = e - t1; \ + e = f; \ + f = g; \ + g = h; \ + h = 0; \ +} + +KERNEL_FQ void m22300_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * prepend salt + */ + + const u32x out_salt_len = out_len + salt_len; + + switch_buffer_by_offset_le_VV (w0, w1, w2, w3, salt_len); + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_salt_len); + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + const u32x salt_out_salt_len = salt_len + out_len + salt_len; + + append_0x80_4x4_VV (w0, w1, w2, w3, salt_out_salt_len); + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = salt_out_salt_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + COMPARE_M_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m22300_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22300_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22300_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * reverse + */ + + u32 a_rev = digests_buf[digests_offset].digest_buf[0]; + u32 b_rev = digests_buf[digests_offset].digest_buf[1]; + u32 c_rev = digests_buf[digests_offset].digest_buf[2]; + u32 d_rev = digests_buf[digests_offset].digest_buf[3]; + u32 e_rev = digests_buf[digests_offset].digest_buf[4]; + u32 f_rev = digests_buf[digests_offset].digest_buf[5]; + u32 g_rev = digests_buf[digests_offset].digest_buf[6]; + u32 h_rev = digests_buf[digests_offset].digest_buf[7]; + + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * prepend salt + */ + + const u32x out_salt_len = out_len + salt_len; + + switch_buffer_by_offset_le_VV (w0, w1, w2, w3, salt_len); + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_salt_len); + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + const u32x salt_out_salt_len = salt_len + out_len + salt_len; + + append_0x80_4x4_VV (w0, w1, w2, w3, salt_out_salt_len); + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = salt_out_salt_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + + if (MATCHES_NONE_VS (h, d_rev)) continue; + + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + COMPARE_S_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m22300_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22300_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m22300_a0-pure.cl b/OpenCL/m22300_a0-pure.cl new file mode 100644 index 000000000..bfb212751 --- /dev/null +++ b/OpenCL/m22300_a0-pure.cl @@ -0,0 +1,147 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_rp.h" +#include "inc_rp.cl" +#include "inc_scalar.cl" +#include "inc_hash_sha256.cl" +#endif + +KERNEL_FQ void m22300_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[idx]); + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update (&ctx0, s, salt_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx = ctx0; + + sha256_update_swap (&ctx, tmp.i, tmp.pw_len); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22300_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[idx]); + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update (&ctx0, s, salt_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx = ctx0; + + sha256_update_swap (&ctx, tmp.i, tmp.pw_len); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22300_a1-optimized.cl b/OpenCL/m22300_a1-optimized.cl new file mode 100644 index 000000000..ce683086f --- /dev/null +++ b/OpenCL/m22300_a1-optimized.cl @@ -0,0 +1,692 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#endif + +#define SHA256_STEP_REV(a,b,c,d,e,f,g,h) \ +{ \ + u32 t2 = SHA256_S2_S(b) + SHA256_F0o(b,c,d); \ + u32 t1 = a - t2; \ + a = b; \ + b = c; \ + c = d; \ + d = e - t1; \ + e = f; \ + f = g; \ + g = h; \ + h = 0; \ +} + +KERNEL_FQ void m22300_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * prepend salt + */ + + switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_salt_len); + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + const u32x salt_pw_salt_len = salt_len + pw_len + salt_len; + + append_0x80_4x4_VV (w0, w1, w2, w3, salt_pw_salt_len); + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = salt_pw_salt_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + COMPARE_M_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m22300_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22300_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22300_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * reverse + */ + + u32 a_rev = digests_buf[digests_offset].digest_buf[0]; + u32 b_rev = digests_buf[digests_offset].digest_buf[1]; + u32 c_rev = digests_buf[digests_offset].digest_buf[2]; + u32 d_rev = digests_buf[digests_offset].digest_buf[3]; + u32 e_rev = digests_buf[digests_offset].digest_buf[4]; + u32 f_rev = digests_buf[digests_offset].digest_buf[5]; + u32 g_rev = digests_buf[digests_offset].digest_buf[6]; + u32 h_rev = digests_buf[digests_offset].digest_buf[7]; + + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * prepend salt + */ + + switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_salt_len); + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + const u32x salt_pw_salt_len = salt_len + pw_len + salt_len; + + append_0x80_4x4_VV (w0, w1, w2, w3, salt_pw_salt_len); + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = salt_pw_salt_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + + if (MATCHES_NONE_VS (h, d_rev)) continue; + + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + COMPARE_S_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m22300_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22300_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m22300_a1-pure.cl b/OpenCL/m22300_a1-pure.cl new file mode 100644 index 000000000..018bdc6f9 --- /dev/null +++ b/OpenCL/m22300_a1-pure.cl @@ -0,0 +1,137 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_scalar.cl" +#include "inc_hash_sha256.cl" +#endif + +KERNEL_FQ void m22300_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[idx]); + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update (&ctx0, s, salt_len); + + sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + sha256_ctx_t ctx = ctx0; + + sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22300_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[salt_pos].salt_buf[idx]); + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update (&ctx0, s, salt_len); + + sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + sha256_ctx_t ctx = ctx0; + + sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22300_a3-optimized.cl b/OpenCL/m22300_a3-optimized.cl new file mode 100644 index 000000000..338c6ce46 --- /dev/null +++ b/OpenCL/m22300_a3-optimized.cl @@ -0,0 +1,826 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#endif + +#define SHA256_STEP_REV(a,b,c,d,e,f,g,h) \ +{ \ + u32 t2 = SHA256_S2_S(b) + SHA256_F0o(b,c,d); \ + u32 t1 = a - t2; \ + a = b; \ + b = c; \ + c = d; \ + d = e - t1; \ + e = f; \ + f = g; \ + g = h; \ + h = 0; \ +} + +DECLSPEC void m22300m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15]; + + u32 salt_buf0_t[4]; + u32 salt_buf1_t[4]; + u32 salt_buf2_t[4]; + u32 salt_buf3_t[4]; + + salt_buf0_t[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0_t[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0_t[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0_t[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1_t[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1_t[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1_t[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1_t[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2_t[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2_t[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2_t[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2_t[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3_t[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3_t[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3_t[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3_t[3] = salt_bufs[salt_pos].salt_buf[15]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + const u32 salt_pw_salt_len = salt_len + pw_len + salt_len; + + switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_salt_len); + + salt_buf0[0] |= salt_buf0_t[0]; + salt_buf0[1] |= salt_buf0_t[1]; + salt_buf0[2] |= salt_buf0_t[2]; + salt_buf0[3] |= salt_buf0_t[3]; + salt_buf1[0] |= salt_buf1_t[0]; + salt_buf1[1] |= salt_buf1_t[1]; + salt_buf1[2] |= salt_buf1_t[2]; + salt_buf1[3] |= salt_buf1_t[3]; + salt_buf2[0] |= salt_buf2_t[0]; + salt_buf2[1] |= salt_buf2_t[1]; + salt_buf2[2] |= salt_buf2_t[2]; + salt_buf2[3] |= salt_buf2_t[3]; + salt_buf3[0] |= salt_buf3_t[0]; + salt_buf3[1] |= salt_buf3_t[1]; + salt_buf3[2] |= salt_buf3_t[2]; + salt_buf3[3] |= salt_buf3_t[3]; + + append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_pw_salt_len); + + /** + * loop + */ + + const u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + t0[0] = hc_swap32 (w0lr ); + t0[1] = hc_swap32 (w0[1]); + t0[2] = hc_swap32 (w0[2]); + t0[3] = hc_swap32 (w0[3]); + t1[0] = hc_swap32 (w1[0]); + t1[1] = hc_swap32 (w1[1]); + t1[2] = hc_swap32 (w1[2]); + t1[3] = hc_swap32 (w1[3]); + t2[0] = hc_swap32 (w2[0]); + t2[1] = hc_swap32 (w2[1]); + t2[2] = hc_swap32 (w2[2]); + t2[3] = hc_swap32 (w2[3]); + t3[0] = hc_swap32 (w3[0]); + t3[1] = hc_swap32 (w3[1]); + t3[2] = hc_swap32 (w3[2]); + t3[3] = hc_swap32 (w3[3]); + + /** + * put the password after the first salt, but before the second salt + */ + + switch_buffer_by_offset_le (t0, t1, t2, t3, salt_len); + + t0[0] |= salt_buf0[0]; + t0[1] |= salt_buf0[1]; + t0[2] |= salt_buf0[2]; + t0[3] |= salt_buf0[3]; + t1[0] |= salt_buf1[0]; + t1[1] |= salt_buf1[1]; + t1[2] |= salt_buf1[2]; + t1[3] |= salt_buf1[3]; + t2[0] |= salt_buf2[0]; + t2[1] |= salt_buf2[1]; + t2[2] |= salt_buf2[2]; + t2[3] |= salt_buf2[3]; + t3[0] |= salt_buf3[0]; + t3[1] |= salt_buf3[1]; + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (t0[0]); + u32x w1_t = hc_swap32 (t0[1]); + u32x w2_t = hc_swap32 (t0[2]); + u32x w3_t = hc_swap32 (t0[3]); + u32x w4_t = hc_swap32 (t1[0]); + u32x w5_t = hc_swap32 (t1[1]); + u32x w6_t = hc_swap32 (t1[2]); + u32x w7_t = hc_swap32 (t1[3]); + u32x w8_t = hc_swap32 (t2[0]); + u32x w9_t = hc_swap32 (t2[1]); + u32x wa_t = hc_swap32 (t2[2]); + u32x wb_t = hc_swap32 (t2[3]); + u32x wc_t = hc_swap32 (t3[0]); + u32x wd_t = hc_swap32 (t3[1]); + u32x we_t = 0; + u32x wf_t = salt_pw_salt_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + COMPARE_M_SIMD (d, h, c, g); + } +} + +DECLSPEC void m22300s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * reverse + */ + + u32 a_rev = digests_buf[digests_offset].digest_buf[0]; + u32 b_rev = digests_buf[digests_offset].digest_buf[1]; + u32 c_rev = digests_buf[digests_offset].digest_buf[2]; + u32 d_rev = digests_buf[digests_offset].digest_buf[3]; + u32 e_rev = digests_buf[digests_offset].digest_buf[4]; + u32 f_rev = digests_buf[digests_offset].digest_buf[5]; + u32 g_rev = digests_buf[digests_offset].digest_buf[6]; + u32 h_rev = digests_buf[digests_offset].digest_buf[7]; + + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + SHA256_STEP_REV (a_rev, b_rev, c_rev, d_rev, e_rev, f_rev, g_rev, h_rev); + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15]; + + u32 salt_buf0_t[4]; + u32 salt_buf1_t[4]; + u32 salt_buf2_t[4]; + u32 salt_buf3_t[4]; + + salt_buf0_t[0] = salt_bufs[salt_pos].salt_buf[ 0]; + salt_buf0_t[1] = salt_bufs[salt_pos].salt_buf[ 1]; + salt_buf0_t[2] = salt_bufs[salt_pos].salt_buf[ 2]; + salt_buf0_t[3] = salt_bufs[salt_pos].salt_buf[ 3]; + salt_buf1_t[0] = salt_bufs[salt_pos].salt_buf[ 4]; + salt_buf1_t[1] = salt_bufs[salt_pos].salt_buf[ 5]; + salt_buf1_t[2] = salt_bufs[salt_pos].salt_buf[ 6]; + salt_buf1_t[3] = salt_bufs[salt_pos].salt_buf[ 7]; + salt_buf2_t[0] = salt_bufs[salt_pos].salt_buf[ 8]; + salt_buf2_t[1] = salt_bufs[salt_pos].salt_buf[ 9]; + salt_buf2_t[2] = salt_bufs[salt_pos].salt_buf[10]; + salt_buf2_t[3] = salt_bufs[salt_pos].salt_buf[11]; + salt_buf3_t[0] = salt_bufs[salt_pos].salt_buf[12]; + salt_buf3_t[1] = salt_bufs[salt_pos].salt_buf[13]; + salt_buf3_t[2] = salt_bufs[salt_pos].salt_buf[14]; + salt_buf3_t[3] = salt_bufs[salt_pos].salt_buf[15]; + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + const u32 salt_pw_salt_len = salt_len + pw_len + salt_len; + + switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_salt_len); + + salt_buf0[0] |= salt_buf0_t[0]; + salt_buf0[1] |= salt_buf0_t[1]; + salt_buf0[2] |= salt_buf0_t[2]; + salt_buf0[3] |= salt_buf0_t[3]; + salt_buf1[0] |= salt_buf1_t[0]; + salt_buf1[1] |= salt_buf1_t[1]; + salt_buf1[2] |= salt_buf1_t[2]; + salt_buf1[3] |= salt_buf1_t[3]; + salt_buf2[0] |= salt_buf2_t[0]; + salt_buf2[1] |= salt_buf2_t[1]; + salt_buf2[2] |= salt_buf2_t[2]; + salt_buf2[3] |= salt_buf2_t[3]; + salt_buf3[0] |= salt_buf3_t[0]; + salt_buf3[1] |= salt_buf3_t[1]; + salt_buf3[2] |= salt_buf3_t[2]; + salt_buf3[3] |= salt_buf3_t[3]; + + append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_pw_salt_len); + + /** + * loop + */ + + const u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + t0[0] = hc_swap32 (w0lr ); + t0[1] = hc_swap32 (w0[1]); + t0[2] = hc_swap32 (w0[2]); + t0[3] = hc_swap32 (w0[3]); + t1[0] = hc_swap32 (w1[0]); + t1[1] = hc_swap32 (w1[1]); + t1[2] = hc_swap32 (w1[2]); + t1[3] = hc_swap32 (w1[3]); + t2[0] = hc_swap32 (w2[0]); + t2[1] = hc_swap32 (w2[1]); + t2[2] = hc_swap32 (w2[2]); + t2[3] = hc_swap32 (w2[3]); + t3[0] = hc_swap32 (w3[0]); + t3[1] = hc_swap32 (w3[1]); + t3[2] = hc_swap32 (w3[2]); + t3[3] = hc_swap32 (w3[3]); + + /** + * put the password after the first salt, but before the second salt + */ + + switch_buffer_by_offset_le (t0, t1, t2, t3, salt_len); + + t0[0] |= salt_buf0[0]; + t0[1] |= salt_buf0[1]; + t0[2] |= salt_buf0[2]; + t0[3] |= salt_buf0[3]; + t1[0] |= salt_buf1[0]; + t1[1] |= salt_buf1[1]; + t1[2] |= salt_buf1[2]; + t1[3] |= salt_buf1[3]; + t2[0] |= salt_buf2[0]; + t2[1] |= salt_buf2[1]; + t2[2] |= salt_buf2[2]; + t2[3] |= salt_buf2[3]; + t3[0] |= salt_buf3[0]; + t3[1] |= salt_buf3[1]; + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (t0[0]); + u32x w1_t = hc_swap32 (t0[1]); + u32x w2_t = hc_swap32 (t0[2]); + u32x w3_t = hc_swap32 (t0[3]); + u32x w4_t = hc_swap32 (t1[0]); + u32x w5_t = hc_swap32 (t1[1]); + u32x w6_t = hc_swap32 (t1[2]); + u32x w7_t = hc_swap32 (t1[3]); + u32x w8_t = hc_swap32 (t2[0]); + u32x w9_t = hc_swap32 (t2[1]); + u32x wa_t = hc_swap32 (t2[2]); + u32x wb_t = hc_swap32 (t2[3]); + u32x wc_t = hc_swap32 (t3[0]); + u32x wd_t = hc_swap32 (t3[1]); + u32x we_t = 0; + u32x wf_t = salt_pw_salt_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + + if (MATCHES_NONE_VS (h, d_rev)) continue; + + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + COMPARE_S_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m22300_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22300_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22300_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22300_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22300_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22300_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = 0; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} diff --git a/OpenCL/m22300_a3-pure.cl b/OpenCL/m22300_a3-pure.cl new file mode 100644 index 000000000..398027754 --- /dev/null +++ b/OpenCL/m22300_a3-pure.cl @@ -0,0 +1,171 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#endif + +KERNEL_FQ void m22300_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[salt_pos].salt_buf[idx]); + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx; + + sha256_init_vector_from_scalar (&ctx, &ctx0); + + sha256_update_vector (&ctx, w, pw_len); + + sha256_update_vector (&ctx, s, salt_len); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m22300_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[digests_offset].digest_buf[DGST_R0], + digests_buf[digests_offset].digest_buf[DGST_R1], + digests_buf[digests_offset].digest_buf[DGST_R2], + digests_buf[digests_offset].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[salt_pos].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[salt_pos].salt_buf[idx]); + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[salt_pos].salt_buf, salt_bufs[salt_pos].salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx; + + sha256_init_vector_from_scalar (&ctx, &ctx0); + + sha256_update_vector (&ctx, w, pw_len); + + sha256_update_vector (&ctx, s, salt_len); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22400-pure.cl b/OpenCL/m22400-pure.cl new file mode 100644 index 000000000..c8dded678 --- /dev/null +++ b/OpenCL/m22400-pure.cl @@ -0,0 +1,297 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_sha256.cl" +#endif + +#define COMPARE_S "inc_comp_single.cl" +#define COMPARE_M "inc_comp_multi.cl" + +typedef struct aescrypt +{ + u32 iv[4]; + u32 key[8]; + +} aescrypt_t; + +typedef struct aescrypt_tmp +{ + u32 pass[144]; + int len; + +} aescrypt_tmp_t; + +KERNEL_FQ void m22400_init (KERN_ATTR_TMPS_ESALT (aescrypt_tmp_t, aescrypt_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + // salt: + + u32 s[16] = { 0 }; // 64-byte aligned + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + s[2] = salt_bufs[salt_pos].salt_buf[2]; + s[3] = salt_bufs[salt_pos].salt_buf[3]; + + // convert password to utf16le: + + const u32 pw_len = pws[gid].pw_len; + + const u32 pw_len_utf16le = pw_len * 2; + + u32 w[144] = { 0 }; + + for (u32 i = 0, j = 0; i < 64; i += 4, j += 8) + { + u32 in[4]; + + in[0] = pws[gid].i[i + 0]; + in[1] = pws[gid].i[i + 1]; + in[2] = pws[gid].i[i + 2]; + in[3] = pws[gid].i[i + 3]; + + u32 out0[4]; + u32 out1[4]; + + make_utf16le_S (in, out0, out1); + + w[j + 0] = hc_swap32_S (out0[0]); + w[j + 1] = hc_swap32_S (out0[1]); + w[j + 2] = hc_swap32_S (out0[2]); + w[j + 3] = hc_swap32_S (out0[3]); + w[j + 4] = hc_swap32_S (out1[0]); + w[j + 5] = hc_swap32_S (out1[1]); + w[j + 6] = hc_swap32_S (out1[2]); + w[j + 7] = hc_swap32_S (out1[3]); + } + + // sha256: + + sha256_ctx_t ctx; + + sha256_init (&ctx); + sha256_update (&ctx, s, 32); + sha256_update (&ctx, w, pw_len_utf16le); + sha256_final (&ctx); + + // set tmps: + + #ifdef _unroll + #pragma unroll + #endif + for (int i = 127; i >= 0; i--) // create some space for the first digest without extra buffer + { + w[8 + i] = w[i]; + } + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + w[4] = ctx.h[4]; + w[5] = ctx.h[5]; + w[6] = ctx.h[6]; + w[7] = ctx.h[7]; + + const u32 final_len = 32 + pw_len_utf16le; + + const u32 idx_floor = (final_len / 64) * 16; + const u32 idx_ceil = ((final_len & 63) >= 56) ? idx_floor + 16 : idx_floor; + + append_0x80_4x4_S (&w[idx_floor + 0], &w[idx_floor + 4], &w[idx_floor + 8], &w[idx_floor + 12], (final_len & 63) ^ 3); + + w[idx_ceil + 14] = 0; + w[idx_ceil + 15] = final_len * 8; + + #ifdef _unroll + #pragma unroll + #endif + for (u32 i = 0; i < 144; i++) + { + tmps[gid].pass[i] = w[i]; + } + + tmps[gid].len = final_len; +} + +KERNEL_FQ void m22400_loop (KERN_ATTR_TMPS_ESALT (aescrypt_tmp_t, aescrypt_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + // init + + u32 w[144]; + + #ifdef _unroll + #pragma unroll + #endif + for (u32 i = 0; i < 144; i++) + { + w[i] = tmps[gid].pass[i]; + } + + const int pw_len = tmps[gid].len; + + // main loop + + for (u32 i = 0; i < loop_cnt; i++) + { + u32 h[8]; + + h[0] = SHA256M_A; + h[1] = SHA256M_B; + h[2] = SHA256M_C; + h[3] = SHA256M_D; + h[4] = SHA256M_E; + h[5] = SHA256M_F; + h[6] = SHA256M_G; + h[7] = SHA256M_H; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + int left; + int idx; + + for (left = pw_len, idx = 0; left >= 56; left -= 64, idx += 16) + { + w0[0] = w[idx + 0]; + w0[1] = w[idx + 1]; + w0[2] = w[idx + 2]; + w0[3] = w[idx + 3]; + w1[0] = w[idx + 4]; + w1[1] = w[idx + 5]; + w1[2] = w[idx + 6]; + w1[3] = w[idx + 7]; + w2[0] = w[idx + 8]; + w2[1] = w[idx + 9]; + w2[2] = w[idx + 10]; + w2[3] = w[idx + 11]; + w3[0] = w[idx + 12]; + w3[1] = w[idx + 13]; + w3[2] = w[idx + 14]; + w3[3] = w[idx + 15]; + + sha256_transform (w0, w1, w2, w3, h); + } + + w0[0] = w[idx + 0]; + w0[1] = w[idx + 1]; + w0[2] = w[idx + 2]; + w0[3] = w[idx + 3]; + w1[0] = w[idx + 4]; + w1[1] = w[idx + 5]; + w1[2] = w[idx + 6]; + w1[3] = w[idx + 7]; + w2[0] = w[idx + 8]; + w2[1] = w[idx + 9]; + w2[2] = w[idx + 10]; + w2[3] = w[idx + 11]; + w3[0] = w[idx + 12]; + w3[1] = w[idx + 13]; + w3[2] = w[idx + 14]; + w3[3] = w[idx + 15]; + + sha256_transform (w0, w1, w2, w3, h); + + w[0] = h[0]; + w[1] = h[1]; + w[2] = h[2]; + w[3] = h[3]; + w[4] = h[4]; + w[5] = h[5]; + w[6] = h[6]; + w[7] = h[7]; + } + + tmps[gid].pass[0] = w[0]; + tmps[gid].pass[1] = w[1]; + tmps[gid].pass[2] = w[2]; + tmps[gid].pass[3] = w[3]; + tmps[gid].pass[4] = w[4]; + tmps[gid].pass[5] = w[5]; + tmps[gid].pass[6] = w[6]; + tmps[gid].pass[7] = w[7]; +} + +KERNEL_FQ void m22400_comp (KERN_ATTR_TMPS_ESALT (aescrypt_tmp_t, aescrypt_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + // digest + + u32 dgst[16] = { 0 }; + + dgst[0] = tmps[gid].pass[0]; + dgst[1] = tmps[gid].pass[1]; + dgst[2] = tmps[gid].pass[2]; + dgst[3] = tmps[gid].pass[3]; + dgst[4] = tmps[gid].pass[4]; + dgst[5] = tmps[gid].pass[5]; + dgst[6] = tmps[gid].pass[6]; + dgst[7] = tmps[gid].pass[7]; + + // IV + + u32 data[16] = { 0 }; + + data[ 0] = esalt_bufs[digests_offset].iv[0]; + data[ 1] = esalt_bufs[digests_offset].iv[1]; + data[ 2] = esalt_bufs[digests_offset].iv[2]; + data[ 3] = esalt_bufs[digests_offset].iv[3]; + + // key + + data[ 4] = esalt_bufs[digests_offset].key[0]; + data[ 5] = esalt_bufs[digests_offset].key[1]; + data[ 6] = esalt_bufs[digests_offset].key[2]; + data[ 7] = esalt_bufs[digests_offset].key[3]; + data[ 8] = esalt_bufs[digests_offset].key[4]; + data[ 9] = esalt_bufs[digests_offset].key[5]; + data[10] = esalt_bufs[digests_offset].key[6]; + data[11] = esalt_bufs[digests_offset].key[7]; + + /* + * HMAC-SHA256: + */ + + sha256_hmac_ctx_t ctx; + + sha256_hmac_init (&ctx, dgst, 32); + sha256_hmac_update (&ctx, data, 48); + sha256_hmac_final (&ctx); + + const u32 r0 = ctx.opad.h[DGST_R0]; + const u32 r1 = ctx.opad.h[DGST_R1]; + const u32 r2 = ctx.opad.h[DGST_R2]; + const u32 r3 = ctx.opad.h[DGST_R3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m22500_a0-optimized.cl b/OpenCL/m22500_a0-optimized.cl new file mode 100644 index 000000000..6c91fbe65 --- /dev/null +++ b/OpenCL/m22500_a0-optimized.cl @@ -0,0 +1,1220 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_rp_optimized.h" +#include "inc_rp_optimized.cl" +#include "inc_simd.cl" +#include "inc_hash_md5.cl" +#include "inc_cipher_aes.cl" +#endif + +DECLSPEC int is_valid_bitcoinj_8 (const u8 v) +{ + // .abcdefghijklmnopqrstuvwxyz + + if (v > (u8) 'z') return 0; + if (v < (u8) '.') return 0; + + if ((v > (u8) '.') && (v < (u8) 'a')) return 0; + + return 1; +} + +KERNEL_FQ void m22500_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf[2]; + + salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf[0]; + s0[1] = salt_buf[1]; + s0[2] = 0x80; + s0[3] = 0; + s1[0] = 0; + s1[1] = 0; + s1[2] = 0; + s1[3] = 0; + s2[0] = 0; + s2[1] = 0; + s2[2] = 0; + s2[3] = 0; + s3[0] = 0; + s3[1] = 0; + s3[2] = 0; + s3[3] = 0; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + + const u32x pw_salt_len = out_len + 8; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] = pw_salt_len * 8; + w3[3] = 0; + + /** + * key1 = md5 ($pass . $salt): + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 ukey[8]; + + ukey[0] = a; + ukey[1] = b; + ukey[2] = c; + ukey[3] = d; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + const u32x dgst_pw_salt_len = 16 + pw_salt_len; + + w3[3] = 0; + w3[2] = dgst_pw_salt_len * 8; + w3[1] = w2[1]; + w3[0] = w2[0]; + w2[3] = w1[3]; + w2[2] = w1[2]; + w2[1] = w1[1]; + w2[0] = w1[0]; + w1[3] = w0[3]; + w1[2] = w0[2]; + w1[1] = w0[1]; + w1[0] = w0[0]; + w0[3] = d; + w0[2] = c; + w0[1] = b; + w0[0] = a; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + ukey[4] = a; + ukey[5] = b; + ukey[6] = c; + ukey[7] = d; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w0[0] = a; + w0[1] = b; + w0[2] = c; + w0[3] = d; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 iv[4]; + + iv[0] = a; + iv[1] = b; + iv[2] = c; + iv[3] = d; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22500_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22500_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf[2]; + + salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf[0]; + s0[1] = salt_buf[1]; + s0[2] = 0x80; + s0[3] = 0; + s1[0] = 0; + s1[1] = 0; + s1[2] = 0; + s1[3] = 0; + s2[0] = 0; + s2[1] = 0; + s2[2] = 0; + s2[3] = 0; + s3[0] = 0; + s3[1] = 0; + s3[2] = 0; + s3[3] = 0; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + + const u32x pw_salt_len = out_len + 8; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] = pw_salt_len * 8; + w3[3] = 0; + + /** + * key1 = md5 ($pass . $salt): + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 ukey[8]; + + ukey[0] = a; + ukey[1] = b; + ukey[2] = c; + ukey[3] = d; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + const u32x dgst_pw_salt_len = 16 + pw_salt_len; + + w3[3] = 0; + w3[2] = dgst_pw_salt_len * 8; + w3[1] = w2[1]; + w3[0] = w2[0]; + w2[3] = w1[3]; + w2[2] = w1[2]; + w2[1] = w1[1]; + w2[0] = w1[0]; + w1[3] = w0[3]; + w1[2] = w0[2]; + w1[1] = w0[1]; + w1[0] = w0[0]; + w0[3] = d; + w0[2] = c; + w0[1] = b; + w0[0] = a; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + ukey[4] = a; + ukey[5] = b; + ukey[6] = c; + ukey[7] = d; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w0[0] = a; + w0[1] = b; + w0[2] = c; + w0[3] = d; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 iv[4]; + + iv[0] = a; + iv[1] = b; + iv[2] = c; + iv[3] = d; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m22500_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m22500_a0-pure.cl b/OpenCL/m22500_a0-pure.cl new file mode 100644 index 000000000..f52f646d8 --- /dev/null +++ b/OpenCL/m22500_a0-pure.cl @@ -0,0 +1,622 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_rp.h" +#include "inc_rp.cl" +#include "inc_scalar.cl" +#include "inc_hash_md5.cl" +#include "inc_cipher_aes.cl" +#endif + +DECLSPEC int is_valid_bitcoinj_8 (const u8 v) +{ + // .abcdefghijklmnopqrstuvwxyz + + if (v > (u8) 'z') return 0; + if (v < (u8) '.') return 0; + + if ((v > (u8) '.') && (v < (u8) 'a')) return 0; + + return 1; +} + +KERNEL_FQ void m22500_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + COPY_PW (pws[gid]); + + /** + * salt + */ + + u32 s[64] = { 0 }; + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + /** + * key1 = md5 ($pass . $salt): + */ + + md5_ctx_t ctx; + + md5_init (&ctx); + md5_update (&ctx, tmp.i, tmp.pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 ukey[8]; + + ukey[0] = ctx.h[0]; + ukey[1] = ctx.h[1]; + ukey[2] = ctx.h[2]; + ukey[3] = ctx.h[3]; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update () + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + md5_update (&ctx, tmp.i, tmp.pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + ukey[4] = ctx.h[0]; + ukey[5] = ctx.h[1]; + ukey[6] = ctx.h[2]; + ukey[7] = ctx.h[3]; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + md5_update (&ctx, tmp.i, tmp.pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 iv[4]; + + iv[0] = ctx.h[0]; + iv[1] = ctx.h[1]; + iv[2] = ctx.h[2]; + iv[3] = ctx.h[3]; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + COPY_PW (pws[gid]); + + /** + * salt + */ + + u32 s[64] = { 0 }; + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + /** + * key1 = md5 ($pass . $salt): + */ + + md5_ctx_t ctx; + + md5_init (&ctx); + md5_update (&ctx, tmp.i, tmp.pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 ukey[8]; + + ukey[0] = ctx.h[0]; + ukey[1] = ctx.h[1]; + ukey[2] = ctx.h[2]; + ukey[3] = ctx.h[3]; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update () + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + md5_update (&ctx, tmp.i, tmp.pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + ukey[4] = ctx.h[0]; + ukey[5] = ctx.h[1]; + ukey[6] = ctx.h[2]; + ukey[7] = ctx.h[3]; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + md5_update (&ctx, tmp.i, tmp.pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 iv[4]; + + iv[0] = ctx.h[0]; + iv[1] = ctx.h[1]; + iv[2] = ctx.h[2]; + iv[3] = ctx.h[3]; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} diff --git a/OpenCL/m22500_a1-optimized.cl b/OpenCL/m22500_a1-optimized.cl new file mode 100644 index 000000000..9637b7b86 --- /dev/null +++ b/OpenCL/m22500_a1-optimized.cl @@ -0,0 +1,1339 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_scalar.cl" +#include "inc_simd.cl" +#include "inc_hash_md5.cl" +#include "inc_cipher_aes.cl" +#endif + +DECLSPEC int is_valid_bitcoinj_8 (const u8 v) +{ + // .abcdefghijklmnopqrstuvwxyz + + if (v > (u8) 'z') return 0; + if (v < (u8) '.') return 0; + + if ((v > (u8) '.') && (v < (u8) 'a')) return 0; + + return 1; +} + +KERNEL_FQ void m22500_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf[2]; + + salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf[0]; + s0[1] = salt_buf[1]; + s0[2] = 0x80; + s0[3] = 0; + s1[0] = 0; + s1[1] = 0; + s1[2] = 0; + s1[3] = 0; + s2[0] = 0; + s2[1] = 0; + s2[2] = 0; + s2[3] = 0; + s3[0] = 0; + s3[1] = 0; + s3[2] = 0; + s3[3] = 0; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + + const u32x pw_salt_len = pw_len + 8; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] = pw_salt_len * 8; + w3[3] = 0; + + /** + * key1 = md5 ($pass . $salt): + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 ukey[8]; + + ukey[0] = a; + ukey[1] = b; + ukey[2] = c; + ukey[3] = d; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + const u32x dgst_pw_salt_len = 16 + pw_salt_len; + + w3[3] = 0; + w3[2] = dgst_pw_salt_len * 8; + w3[1] = w2[1]; + w3[0] = w2[0]; + w2[3] = w1[3]; + w2[2] = w1[2]; + w2[1] = w1[1]; + w2[0] = w1[0]; + w1[3] = w0[3]; + w1[2] = w0[2]; + w1[1] = w0[1]; + w1[0] = w0[0]; + w0[3] = d; + w0[2] = c; + w0[1] = b; + w0[0] = a; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + ukey[4] = a; + ukey[5] = b; + ukey[6] = c; + ukey[7] = d; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w0[0] = a; + w0[1] = b; + w0[2] = c; + w0[3] = d; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 iv[4]; + + iv[0] = a; + iv[1] = b; + iv[2] = c; + iv[3] = d; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22500_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22500_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf[2]; + + salt_buf[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf[0]; + s0[1] = salt_buf[1]; + s0[2] = 0x80; + s0[3] = 0; + s1[0] = 0; + s1[1] = 0; + s1[2] = 0; + s1[3] = 0; + s2[0] = 0; + s2[1] = 0; + s2[2] = 0; + s2[3] = 0; + s3[0] = 0; + s3[1] = 0; + s3[2] = 0; + s3[3] = 0; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + + const u32x pw_salt_len = pw_len + 8; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] = pw_salt_len * 8; + w3[3] = 0; + + /** + * key1 = md5 ($pass . $salt): + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 ukey[8]; + + ukey[0] = a; + ukey[1] = b; + ukey[2] = c; + ukey[3] = d; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + const u32x dgst_pw_salt_len = 16 + pw_salt_len; + + w3[3] = 0; + w3[2] = dgst_pw_salt_len * 8; + w3[1] = w2[1]; + w3[0] = w2[0]; + w2[3] = w1[3]; + w2[2] = w1[2]; + w2[1] = w1[1]; + w2[0] = w1[0]; + w1[3] = w0[3]; + w1[2] = w0[2]; + w1[1] = w0[1]; + w1[0] = w0[0]; + w0[3] = d; + w0[2] = c; + w0[1] = b; + w0[0] = a; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + ukey[4] = a; + ukey[5] = b; + ukey[6] = c; + ukey[7] = d; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w0[0] = a; + w0[1] = b; + w0[2] = c; + w0[3] = d; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 iv[4]; + + iv[0] = a; + iv[1] = b; + iv[2] = c; + iv[3] = d; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m22500_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m22500_a1-pure.cl b/OpenCL/m22500_a1-pure.cl new file mode 100644 index 000000000..4f9bc963f --- /dev/null +++ b/OpenCL/m22500_a1-pure.cl @@ -0,0 +1,632 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_scalar.cl" +#include "inc_hash_md5.cl" +#include "inc_cipher_aes.cl" +#endif + +DECLSPEC int is_valid_bitcoinj_8 (const u8 v) +{ + // .abcdefghijklmnopqrstuvwxyz + + if (v > (u8) 'z') return 0; + if (v < (u8) '.') return 0; + + if ((v > (u8) '.') && (v < (u8) 'a')) return 0; + + return 1; +} + +KERNEL_FQ void m22500_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * salt + */ + + u32 s[64] = { 0 }; + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + /** + * key1 = md5 ($pass . $salt): + */ + + md5_ctx_t ctx = ctx0; + + md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 ukey[8]; + + ukey[0] = ctx.h[0]; + ukey[1] = ctx.h[1]; + ukey[2] = ctx.h[2]; + ukey[3] = ctx.h[3]; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update () + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx, s, 8); + md5_final (&ctx); + + ukey[4] = ctx.h[0]; + ukey[5] = ctx.h[1]; + ukey[6] = ctx.h[2]; + ukey[7] = ctx.h[3]; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 iv[4]; + + iv[0] = ctx.h[0]; + iv[1] = ctx.h[1]; + iv[2] = ctx.h[2]; + iv[3] = ctx.h[3]; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * salt + */ + + u32 s[64] = { 0 }; + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + /** + * key1 = md5 ($pass . $salt): + */ + + md5_ctx_t ctx = ctx0; + + md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 ukey[8]; + + ukey[0] = ctx.h[0]; + ukey[1] = ctx.h[1]; + ukey[2] = ctx.h[2]; + ukey[3] = ctx.h[3]; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + u32 w[16] = { 0 }; // we need 64-bit alignment for md5_update () + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx, s, 8); + md5_final (&ctx); + + ukey[4] = ctx.h[0]; + ukey[5] = ctx.h[1]; + ukey[6] = ctx.h[2]; + ukey[7] = ctx.h[3]; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w[0] = ctx.h[0]; + w[1] = ctx.h[1]; + w[2] = ctx.h[2]; + w[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, w, 16); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + md5_update_global (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 iv[4]; + + iv[0] = ctx.h[0]; + iv[1] = ctx.h[1]; + iv[2] = ctx.h[2]; + iv[3] = ctx.h[3]; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} diff --git a/OpenCL/m22500_a3-optimized.cl b/OpenCL/m22500_a3-optimized.cl new file mode 100644 index 000000000..cf37c4288 --- /dev/null +++ b/OpenCL/m22500_a3-optimized.cl @@ -0,0 +1,1175 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_md5.cl" +#include "inc_cipher_aes.cl" +#endif + +DECLSPEC int is_valid_bitcoinj_8 (const u8 v) +{ + // .abcdefghijklmnopqrstuvwxyz + + if (v > (u8) 'z') return 0; + if (v < (u8) '.') return 0; + + if ((v > (u8) '.') && (v < (u8) 'a')) return 0; + + return 1; +} + +DECLSPEC void m22500 (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a *s_te2, SHM_TYPE u32a *s_te3, SHM_TYPE u32a *s_te4, SHM_TYPE u32a *s_td0, SHM_TYPE u32a *s_td1, SHM_TYPE u32a *s_td2, SHM_TYPE u32a *s_td3, SHM_TYPE u32a *s_td4, u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + /** + * salt + */ + + u32 salt_buf0[4]; + + salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0]; + salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1]; + salt_buf0[2] = 0x80; + salt_buf0[3] = 0; + + u32 salt_buf1[4] = { 0 }; + u32 salt_buf2[4] = { 0 }; + u32 salt_buf3[4] = { 0 }; + + const u32 pw_salt_len = pw_len + 8; + + switch_buffer_by_offset_le_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, pw_len); + + w[ 0] |= salt_buf0[0]; + w[ 1] |= salt_buf0[1]; + w[ 2] |= salt_buf0[2]; + w[ 3] |= salt_buf0[3]; + w[ 4] |= salt_buf1[0]; + w[ 5] |= salt_buf1[1]; + w[ 6] |= salt_buf1[2]; + w[ 7] |= salt_buf1[3]; + w[ 8] |= salt_buf2[0]; + w[ 9] |= salt_buf2[1]; + w[10] |= salt_buf2[2]; + w[11] |= salt_buf2[3]; + w[12] |= salt_buf3[0]; + w[13] |= salt_buf3[1]; + w[14] = pw_salt_len * 8; + w[15] = 0; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * base + */ + + const u32 F_w0c00 = 0u + MD5C00; + const u32 F_w1c01 = w[ 1] + MD5C01; + const u32 F_w2c02 = w[ 2] + MD5C02; + const u32 F_w3c03 = w[ 3] + MD5C03; + const u32 F_w4c04 = w[ 4] + MD5C04; + const u32 F_w5c05 = w[ 5] + MD5C05; + const u32 F_w6c06 = w[ 6] + MD5C06; + const u32 F_w7c07 = w[ 7] + MD5C07; + const u32 F_w8c08 = w[ 8] + MD5C08; + const u32 F_w9c09 = w[ 9] + MD5C09; + const u32 F_wac0a = w[10] + MD5C0a; + const u32 F_wbc0b = w[11] + MD5C0b; + const u32 F_wcc0c = w[12] + MD5C0c; + const u32 F_wdc0d = w[13] + MD5C0d; + const u32 F_wec0e = w[14] + MD5C0e; + const u32 F_wfc0f = w[15] + MD5C0f; + + const u32 G_w1c10 = w[ 1] + MD5C10; + const u32 G_w6c11 = w[ 6] + MD5C11; + const u32 G_wbc12 = w[11] + MD5C12; + const u32 G_w0c13 = 0u + MD5C13; + const u32 G_w5c14 = w[ 5] + MD5C14; + const u32 G_wac15 = w[10] + MD5C15; + const u32 G_wfc16 = w[15] + MD5C16; + const u32 G_w4c17 = w[ 4] + MD5C17; + const u32 G_w9c18 = w[ 9] + MD5C18; + const u32 G_wec19 = w[14] + MD5C19; + const u32 G_w3c1a = w[ 3] + MD5C1a; + const u32 G_w8c1b = w[ 8] + MD5C1b; + const u32 G_wdc1c = w[13] + MD5C1c; + const u32 G_w2c1d = w[ 2] + MD5C1d; + const u32 G_w7c1e = w[ 7] + MD5C1e; + const u32 G_wcc1f = w[12] + MD5C1f; + + const u32 H_w5c20 = w[ 5] + MD5C20; + const u32 H_w8c21 = w[ 8] + MD5C21; + const u32 H_wbc22 = w[11] + MD5C22; + const u32 H_wec23 = w[14] + MD5C23; + const u32 H_w1c24 = w[ 1] + MD5C24; + const u32 H_w4c25 = w[ 4] + MD5C25; + const u32 H_w7c26 = w[ 7] + MD5C26; + const u32 H_wac27 = w[10] + MD5C27; + const u32 H_wdc28 = w[13] + MD5C28; + const u32 H_w0c29 = 0u + MD5C29; + const u32 H_w3c2a = w[ 3] + MD5C2a; + const u32 H_w6c2b = w[ 6] + MD5C2b; + const u32 H_w9c2c = w[ 9] + MD5C2c; + const u32 H_wcc2d = w[12] + MD5C2d; + const u32 H_wfc2e = w[15] + MD5C2e; + const u32 H_w2c2f = w[ 2] + MD5C2f; + + const u32 I_w0c30 = 0u + MD5C30; + const u32 I_w7c31 = w[ 7] + MD5C31; + const u32 I_wec32 = w[14] + MD5C32; + const u32 I_w5c33 = w[ 5] + MD5C33; + const u32 I_wcc34 = w[12] + MD5C34; + const u32 I_w3c35 = w[ 3] + MD5C35; + const u32 I_wac36 = w[10] + MD5C36; + const u32 I_w1c37 = w[ 1] + MD5C37; + const u32 I_w8c38 = w[ 8] + MD5C38; + const u32 I_wfc39 = w[15] + MD5C39; + const u32 I_w6c3a = w[ 6] + MD5C3a; + const u32 I_wdc3b = w[13] + MD5C3b; + const u32 I_w4c3c = w[ 4] + MD5C3c; + const u32 I_wbc3d = w[11] + MD5C3d; + const u32 I_w2c3e = w[ 2] + MD5C3e; + const u32 I_w9c3f = w[ 9] + MD5C3f; + + /** + * loop + */ + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + /** + * key1 = md5 ($pass . $salt): + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0, F_w0c00, MD5S00); + MD5_STEP0(MD5_Fo, d, a, b, c, F_w1c01, MD5S01); + MD5_STEP0(MD5_Fo, c, d, a, b, F_w2c02, MD5S02); + MD5_STEP0(MD5_Fo, b, c, d, a, F_w3c03, MD5S03); + MD5_STEP0(MD5_Fo, a, b, c, d, F_w4c04, MD5S00); + MD5_STEP0(MD5_Fo, d, a, b, c, F_w5c05, MD5S01); + MD5_STEP0(MD5_Fo, c, d, a, b, F_w6c06, MD5S02); + MD5_STEP0(MD5_Fo, b, c, d, a, F_w7c07, MD5S03); + MD5_STEP0(MD5_Fo, a, b, c, d, F_w8c08, MD5S00); + MD5_STEP0(MD5_Fo, d, a, b, c, F_w9c09, MD5S01); + MD5_STEP0(MD5_Fo, c, d, a, b, F_wac0a, MD5S02); + MD5_STEP0(MD5_Fo, b, c, d, a, F_wbc0b, MD5S03); + MD5_STEP0(MD5_Fo, a, b, c, d, F_wcc0c, MD5S00); + MD5_STEP0(MD5_Fo, d, a, b, c, F_wdc0d, MD5S01); + MD5_STEP0(MD5_Fo, c, d, a, b, F_wec0e, MD5S02); + MD5_STEP0(MD5_Fo, b, c, d, a, F_wfc0f, MD5S03); + + MD5_STEP0(MD5_Go, a, b, c, d, G_w1c10, MD5S10); + MD5_STEP0(MD5_Go, d, a, b, c, G_w6c11, MD5S11); + MD5_STEP0(MD5_Go, c, d, a, b, G_wbc12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0, G_w0c13, MD5S13); + MD5_STEP0(MD5_Go, a, b, c, d, G_w5c14, MD5S10); + MD5_STEP0(MD5_Go, d, a, b, c, G_wac15, MD5S11); + MD5_STEP0(MD5_Go, c, d, a, b, G_wfc16, MD5S12); + MD5_STEP0(MD5_Go, b, c, d, a, G_w4c17, MD5S13); + MD5_STEP0(MD5_Go, a, b, c, d, G_w9c18, MD5S10); + MD5_STEP0(MD5_Go, d, a, b, c, G_wec19, MD5S11); + MD5_STEP0(MD5_Go, c, d, a, b, G_w3c1a, MD5S12); + MD5_STEP0(MD5_Go, b, c, d, a, G_w8c1b, MD5S13); + MD5_STEP0(MD5_Go, a, b, c, d, G_wdc1c, MD5S10); + MD5_STEP0(MD5_Go, d, a, b, c, G_w2c1d, MD5S11); + MD5_STEP0(MD5_Go, c, d, a, b, G_w7c1e, MD5S12); + MD5_STEP0(MD5_Go, b, c, d, a, G_wcc1f, MD5S13); + + u32x t; + + MD5_STEP0(MD5_H1, a, b, c, d, H_w5c20, MD5S20); + MD5_STEP0(MD5_H2, d, a, b, c, H_w8c21, MD5S21); + MD5_STEP0(MD5_H1, c, d, a, b, H_wbc22, MD5S22); + MD5_STEP0(MD5_H2, b, c, d, a, H_wec23, MD5S23); + MD5_STEP0(MD5_H1, a, b, c, d, H_w1c24, MD5S20); + MD5_STEP0(MD5_H2, d, a, b, c, H_w4c25, MD5S21); + MD5_STEP0(MD5_H1, c, d, a, b, H_w7c26, MD5S22); + MD5_STEP0(MD5_H2, b, c, d, a, H_wac27, MD5S23); + MD5_STEP0(MD5_H1, a, b, c, d, H_wdc28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0, H_w0c29, MD5S21); + MD5_STEP0(MD5_H1, c, d, a, b, H_w3c2a, MD5S22); + MD5_STEP0(MD5_H2, b, c, d, a, H_w6c2b, MD5S23); + MD5_STEP0(MD5_H1, a, b, c, d, H_w9c2c, MD5S20); + MD5_STEP0(MD5_H2, d, a, b, c, H_wcc2d, MD5S21); + MD5_STEP0(MD5_H1, c, d, a, b, H_wfc2e, MD5S22); + MD5_STEP0(MD5_H2, b, c, d, a, H_w2c2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0, I_w0c30, MD5S30); + MD5_STEP0(MD5_I , d, a, b, c, I_w7c31, MD5S31); + MD5_STEP0(MD5_I , c, d, a, b, I_wec32, MD5S32); + MD5_STEP0(MD5_I , b, c, d, a, I_w5c33, MD5S33); + MD5_STEP0(MD5_I , a, b, c, d, I_wcc34, MD5S30); + MD5_STEP0(MD5_I , d, a, b, c, I_w3c35, MD5S31); + MD5_STEP0(MD5_I , c, d, a, b, I_wac36, MD5S32); + MD5_STEP0(MD5_I , b, c, d, a, I_w1c37, MD5S33); + MD5_STEP0(MD5_I , a, b, c, d, I_w8c38, MD5S30); + MD5_STEP0(MD5_I , d, a, b, c, I_wfc39, MD5S31); + MD5_STEP0(MD5_I , c, d, a, b, I_w6c3a, MD5S32); + MD5_STEP0(MD5_I , b, c, d, a, I_wdc3b, MD5S33); + MD5_STEP0(MD5_I , a, b, c, d, I_w4c3c, MD5S30); + MD5_STEP0(MD5_I , d, a, b, c, I_wbc3d, MD5S31); + MD5_STEP0(MD5_I , c, d, a, b, I_w2c3e, MD5S32); + MD5_STEP0(MD5_I , b, c, d, a, I_w9c3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 ukey[8]; + + ukey[0] = a; + ukey[1] = b; + ukey[2] = c; + ukey[3] = d; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + const u32x dgst_pw_salt_len = 16 + pw_salt_len; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = a; + w0_t[1] = b; + w0_t[2] = c; + w0_t[3] = d; + + w1_t[0] = w0; + w1_t[1] = w[1]; + w1_t[2] = w[2]; + w1_t[3] = w[3]; + + w2_t[0] = w[4]; + w2_t[1] = w[5]; + w2_t[2] = w[6]; + w2_t[3] = w[7]; + + w3_t[0] = w[8]; + w3_t[1] = w[9]; + w3_t[2] = dgst_pw_salt_len * 8; + w3_t[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + ukey[4] = a; + ukey[5] = b; + ukey[6] = c; + ukey[7] = d; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + w0_t[0] = a; + w0_t[1] = b; + w0_t[2] = c; + w0_t[3] = d; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += MD5M_A; + b += MD5M_B; + c += MD5M_C; + d += MD5M_D; + + u32 iv[4]; + + iv[0] = a; + iv[1] = b; + iv[2] = c; + iv[3] = d; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_m04 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22500 (s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22500_m08 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22500 (s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22500_m16 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22500 (s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22500_s04 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22500 (s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22500_s08 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22500 (s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} + +KERNEL_FQ void m22500_s16 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m22500 (s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, combs_mode, gid_max); +} diff --git a/OpenCL/m22500_a3-pure.cl b/OpenCL/m22500_a3-pure.cl new file mode 100644 index 000000000..d7db084a7 --- /dev/null +++ b/OpenCL/m22500_a3-pure.cl @@ -0,0 +1,650 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#include "inc_simd.cl" +#include "inc_hash_md5.cl" +#include "inc_cipher_aes.cl" +#endif + +DECLSPEC int is_valid_bitcoinj_8 (const u8 v) +{ + // .abcdefghijklmnopqrstuvwxyz + + if (v > (u8) 'z') return 0; + if (v < (u8) '.') return 0; + + if ((v > (u8) '.') && (v < (u8) 'a')) return 0; + + return 1; +} + +KERNEL_FQ void m22500_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * salt + */ + + u32 s[64] = { 0 }; + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + /** + * key1 = md5 ($pass . $salt): + */ + + md5_ctx_t ctx; + + md5_init (&ctx); + md5_update (&ctx, w, pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 ukey[8]; + + ukey[0] = ctx.h[0]; + ukey[1] = ctx.h[1]; + ukey[2] = ctx.h[2]; + ukey[3] = ctx.h[3]; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + u32 h[16] = { 0 }; // we need 64-bit alignment for md5_update () + + h[0] = ctx.h[0]; + h[1] = ctx.h[1]; + h[2] = ctx.h[2]; + h[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, h, 16); + md5_update (&ctx, w, pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + ukey[4] = ctx.h[0]; + ukey[5] = ctx.h[1]; + ukey[6] = ctx.h[2]; + ukey[7] = ctx.h[3]; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + h[0] = ctx.h[0]; + h[1] = ctx.h[1]; + h[2] = ctx.h[2]; + h[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, h, 16); + md5_update (&ctx, w, pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 iv[4]; + + iv[0] = ctx.h[0]; + iv[1] = ctx.h[1]; + iv[2] = ctx.h[2]; + iv[3] = ctx.h[3]; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} + +KERNEL_FQ void m22500_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * salt + */ + + u32 s[64] = { 0 }; + + s[0] = salt_bufs[salt_pos].salt_buf[0]; + s[1] = salt_bufs[salt_pos].salt_buf[1]; + + u32 data[8]; + + data[0] = salt_bufs[salt_pos].salt_buf[2]; + data[1] = salt_bufs[salt_pos].salt_buf[3]; + data[2] = salt_bufs[salt_pos].salt_buf[4]; + data[3] = salt_bufs[salt_pos].salt_buf[5]; + data[4] = salt_bufs[salt_pos].salt_buf[6]; + data[5] = salt_bufs[salt_pos].salt_buf[7]; + data[6] = salt_bufs[salt_pos].salt_buf[8]; + data[7] = salt_bufs[salt_pos].salt_buf[9]; + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + /** + * key1 = md5 ($pass . $salt): + */ + + md5_ctx_t ctx; + + md5_init (&ctx); + md5_update (&ctx, w, pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 ukey[8]; + + ukey[0] = ctx.h[0]; + ukey[1] = ctx.h[1]; + ukey[2] = ctx.h[2]; + ukey[3] = ctx.h[3]; + + /** + * key2 = md5 ($key1 . $pass . $salt): + */ + + u32 h[16] = { 0 }; // we need 64-bit alignment for md5_update () + + h[0] = ctx.h[0]; + h[1] = ctx.h[1]; + h[2] = ctx.h[2]; + h[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, h, 16); + md5_update (&ctx, w, pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + ukey[4] = ctx.h[0]; + ukey[5] = ctx.h[1]; + ukey[6] = ctx.h[2]; + ukey[7] = ctx.h[3]; + + /** + * iv = md5 ($key2 . $pass . $salt): + */ + + h[0] = ctx.h[0]; + h[1] = ctx.h[1]; + h[2] = ctx.h[2]; + h[3] = ctx.h[3]; + + md5_init (&ctx); + md5_update (&ctx, h, 16); + md5_update (&ctx, w, pw_len); + md5_update (&ctx, s, 8); + md5_final (&ctx); + + u32 iv[4]; + + iv[0] = ctx.h[0]; + iv[1] = ctx.h[1]; + iv[2] = ctx.h[2]; + iv[3] = ctx.h[3]; + + /** + * AES-256-CBC: + */ + + #define KEYLEN 60 + + u32 ks[KEYLEN]; + + aes256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + u32 encrypted[4]; + + encrypted[0] = data[0]; + encrypted[1] = data[1]; + encrypted[2] = data[2]; + encrypted[3] = data[3]; + + u32 out[4]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + + // first char of decrypted wallet data must be K, L, Q, 5, # or \n + + const u32 first_byte = out[0] & 0xff; + + if ((first_byte != 0x4b) && // K + (first_byte != 0x4c) && // L + (first_byte != 0x51) && // Q + (first_byte != 0x35) && // 5 + (first_byte != 0x23) && // # + (first_byte != 0x0a)) // \n + { + continue; + } + + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if ((first_byte == 0x4b) || // K => MultiBit Classic Wallet + (first_byte == 0x4c) || // L + (first_byte == 0x51) || // Q + (first_byte == 0x35)) // 5 + { + // base58 check: + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + if (is_valid_base58_32 (out[0]) == 0) continue; + if (is_valid_base58_32 (out[1]) == 0) continue; + if (is_valid_base58_32 (out[2]) == 0) continue; + if (is_valid_base58_32 (out[3]) == 0) continue; + } + else if (first_byte == 0x0a) // \n => bitcoinj + { + if ((out[0] & 0x0000ff00) > 0x00007e00) continue; // second_byte + + // check for "org." substring: + + if ((out[0] & 0xffff0000) != 0x726f0000) continue; // "ro" (byte swapped) + if ((out[1] & 0x0000ffff) != 0x00002e67) continue; // ".g" + + if (is_valid_bitcoinj_8 (out[1] >> 16) == 0) continue; // byte 6 (counting from 0) + if (is_valid_bitcoinj_8 (out[1] >> 24) == 0) continue; // byte 7 + + if (is_valid_bitcoinj_8 (out[2] >> 0) == 0) continue; // byte 8 + if (is_valid_bitcoinj_8 (out[2] >> 8) == 0) continue; // byte 9 + if (is_valid_bitcoinj_8 (out[2] >> 16) == 0) continue; // byte 10 + if (is_valid_bitcoinj_8 (out[2] >> 24) == 0) continue; // byte 11 + + if (is_valid_bitcoinj_8 (out[3] >> 0) == 0) continue; // byte 12 + if (is_valid_bitcoinj_8 (out[3] >> 8) == 0) continue; // byte 13 + } + else // if (first_byte == 0x23) // # => KnCGroup Bitcoin Wallet + { + // Full string would be: + // "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + // check for "# KEEP YOUR PRIV" substring: + + if (out[0] != 0x454b2023) continue; // "EK #" (byte swapped) + if (out[1] != 0x59205045) continue; // "Y PE" + if (out[2] != 0x2052554f) continue; // " RUO" + if (out[3] != 0x56495250) continue; // "VIRP" + + iv[0] = encrypted[0]; + iv[1] = encrypted[1]; + iv[2] = encrypted[2]; + iv[3] = encrypted[3]; + + encrypted[0] = data[4]; + encrypted[1] = data[5]; + encrypted[2] = data[6]; + encrypted[3] = data[7]; + + aes256_decrypt (ks, encrypted, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + // check for "ATE KEYS SAFE! A" substring: + + if (out[0] != 0x20455441) continue; // " ETA" (byte swapped) + if (out[1] != 0x5359454b) continue; // "SYEK" + if (out[2] != 0x46415320) continue; // "FAS " + if (out[3] != 0x41202145) continue; // "A !E" + } + + if (atomic_inc (&hashes_shown[digests_offset]) == 0) + { + mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, 0, digests_offset + 0, gid, il_pos, 0, 0); + } + } +} diff --git a/OpenCL/markov_be.cl b/OpenCL/markov_be.cl index a69e5e691..8463bcfe2 100644 --- a/OpenCL/markov_be.cl +++ b/OpenCL/markov_be.cl @@ -52,17 +52,79 @@ KERNEL_FQ void l_markov (GLOBAL_AS pw_t *pws_buf_l, GLOBAL_AS const cs_t *root_c if (gid >= gid_max) return; - u32 pw_buf[64] = { 0 }; - generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_l_len, pw_r_len, mask80, bits14, bits15, off + gid); + pw_t pw; - #pragma unroll - for (int idx = 0; idx < 64; idx++) - { - pws_buf_l[gid].i[idx] = pw_buf[idx]; - } + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; - pws_buf_l[gid].pw_len = pw_l_len + pw_r_len; + pw.pw_len = pw_l_len + pw_r_len; + + generate_pw (pw.i, root_css_buf, markov_css_buf, pw_l_len, pw_r_len, mask80, bits14, bits15, off + gid); + + pws_buf_l[gid] = pw; } KERNEL_FQ void r_markov (GLOBAL_AS bf_t *pws_buf_r, GLOBAL_AS const cs_t *root_css_buf, GLOBAL_AS const cs_t *markov_css_buf, const u64 off, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max) @@ -71,11 +133,76 @@ KERNEL_FQ void r_markov (GLOBAL_AS bf_t *pws_buf_r, GLOBAL_AS const cs_t *root_c if (gid >= gid_max) return; - u32 pw_buf[64] = { 0 }; + pw_t pw; - generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_r_len, 0, 0, 0, 0, off + gid); + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; - pws_buf_r[gid].i = pw_buf[0]; + generate_pw (pw.i, root_css_buf, markov_css_buf, pw_r_len, 0, 0, 0, 0, off + gid); + + pws_buf_r[gid].i = pw.i[0]; } KERNEL_FQ void C_markov (GLOBAL_AS pw_t *pws_buf, GLOBAL_AS const cs_t *root_css_buf, GLOBAL_AS const cs_t *markov_css_buf, const u64 off, const u32 pw_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max) @@ -84,15 +211,76 @@ KERNEL_FQ void C_markov (GLOBAL_AS pw_t *pws_buf, GLOBAL_AS const cs_t *root_css if (gid >= gid_max) return; - u32 pw_buf[64] = { 0 }; + pw_t pw; - generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_len, 0, mask80, bits14, bits15, off + gid); + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; - #pragma unroll - for (int idx = 0; idx < 64; idx++) - { - pws_buf[gid].i[idx] = pw_buf[idx]; - } + pw.pw_len = pw_len; - pws_buf[gid].pw_len = pw_len; + generate_pw (pw.i, root_css_buf, markov_css_buf, pw_len, 0, mask80, bits14, bits15, off + gid); + + pws_buf[gid] = pw; } diff --git a/OpenCL/markov_le.cl b/OpenCL/markov_le.cl index f1feb7819..530b8acc4 100644 --- a/OpenCL/markov_le.cl +++ b/OpenCL/markov_le.cl @@ -52,17 +52,78 @@ KERNEL_FQ void l_markov (GLOBAL_AS pw_t *pws_buf_l, GLOBAL_AS const cs_t *root_c if (gid >= gid_max) return; - u32 pw_buf[64] = { 0 }; + pw_t pw; - generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_l_len, pw_r_len, mask80, bits14, bits15, off + gid); + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; - #pragma unroll - for (int idx = 0; idx < 64; idx++) - { - pws_buf_l[gid].i[idx] = pw_buf[idx]; - } + pw.pw_len = pw_l_len + pw_r_len; - pws_buf_l[gid].pw_len = pw_l_len + pw_r_len; + generate_pw (pw.i, root_css_buf, markov_css_buf, pw_l_len, pw_r_len, mask80, bits14, bits15, off + gid); + + pws_buf_l[gid] = pw; } KERNEL_FQ void r_markov (GLOBAL_AS bf_t *pws_buf_r, GLOBAL_AS const cs_t *root_css_buf, GLOBAL_AS const cs_t *markov_css_buf, const u64 off, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max) @@ -71,11 +132,76 @@ KERNEL_FQ void r_markov (GLOBAL_AS bf_t *pws_buf_r, GLOBAL_AS const cs_t *root_c if (gid >= gid_max) return; - u32 pw_buf[64] = { 0 }; + pw_t pw; - generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_r_len, 0, 0, 0, 0, off + gid); + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; - pws_buf_r[gid].i = pw_buf[0]; + generate_pw (pw.i, root_css_buf, markov_css_buf, pw_r_len, 0, 0, 0, 0, off + gid); + + pws_buf_r[gid].i = pw.i[0]; } KERNEL_FQ void C_markov (GLOBAL_AS pw_t *pws_buf, GLOBAL_AS const cs_t *root_css_buf, GLOBAL_AS const cs_t *markov_css_buf, const u64 off, const u32 pw_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max) @@ -84,15 +210,76 @@ KERNEL_FQ void C_markov (GLOBAL_AS pw_t *pws_buf, GLOBAL_AS const cs_t *root_css if (gid >= gid_max) return; - u32 pw_buf[64] = { 0 }; + pw_t pw; - generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_len, 0, mask80, bits14, bits15, off + gid); + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; - #pragma unroll - for (int idx = 0; idx < 64; idx++) - { - pws_buf[gid].i[idx] = pw_buf[idx]; - } + pw.pw_len = pw_len; - pws_buf[gid].pw_len = pw_len; + generate_pw (pw.i, root_css_buf, markov_css_buf, pw_len, 0, mask80, bits14, bits15, off + gid); + + pws_buf[gid] = pw; } diff --git a/OpenCL/shared.cl b/OpenCL/shared.cl new file mode 100644 index 000000000..47c37c3c6 --- /dev/null +++ b/OpenCL/shared.cl @@ -0,0 +1,214 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifdef KERNEL_STATIC +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.cl" +#include "inc_common.cl" +#endif + +DECLSPEC void gpu_decompress_entry (GLOBAL_AS pw_idx_t *pws_idx, GLOBAL_AS u32 *pws_comp, pw_t *buf, const u64 gid) +{ + const u32 off = pws_idx[gid].off; + const u32 cnt = pws_idx[gid].cnt; + const u32 len = pws_idx[gid].len; + + pw_t pw; + + pw.i[ 0] = 0; + pw.i[ 1] = 0; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; + + pw.pw_len = len; + + for (u32 i = 0, j = off; i < cnt; i++, j++) + { + pw.i[i] = pws_comp[j]; + } + + *buf = pw; +} + +KERNEL_FQ void gpu_decompress (GLOBAL_AS pw_idx_t *pws_idx, GLOBAL_AS u32 *pws_comp, GLOBAL_AS pw_t *pws_buf, const u64 gid_max) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + pw_t pw; + + gpu_decompress_entry (pws_idx, pws_comp, &pw, gid); + + pws_buf[gid] = pw; +} + +KERNEL_FQ void gpu_memset (GLOBAL_AS uint4 *buf, const u32 value, const u64 gid_max) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + uint4 r; + + #if defined IS_NATIVE + r = value; + #elif defined IS_OPENCL + r.s0 = value; + r.s1 = value; + r.s2 = value; + r.s3 = value; + #elif defined IS_CUDA + r.x = value; + r.y = value; + r.z = value; + r.w = value; + #endif + + buf[gid] = r; +} + +KERNEL_FQ void gpu_atinit (GLOBAL_AS pw_t *buf, const u64 gid_max) +{ + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + const u32 l32 = l32_from_64_S (gid); + const u32 h32 = h32_from_64_S (gid); + + pw_t pw; + + pw.i[ 0] = 0x5c5c5c5c ^ l32; + pw.i[ 1] = 0x36363636 ^ h32; + pw.i[ 2] = 0; + pw.i[ 3] = 0; + pw.i[ 4] = 0; + pw.i[ 5] = 0; + pw.i[ 6] = 0; + pw.i[ 7] = 0; + pw.i[ 8] = 0; + pw.i[ 9] = 0; + pw.i[10] = 0; + pw.i[11] = 0; + pw.i[12] = 0; + pw.i[13] = 0; + pw.i[14] = 0; + pw.i[15] = 0; + pw.i[16] = 0; + pw.i[17] = 0; + pw.i[18] = 0; + pw.i[19] = 0; + pw.i[20] = 0; + pw.i[21] = 0; + pw.i[22] = 0; + pw.i[23] = 0; + pw.i[24] = 0; + pw.i[25] = 0; + pw.i[26] = 0; + pw.i[27] = 0; + pw.i[28] = 0; + pw.i[29] = 0; + pw.i[30] = 0; + pw.i[31] = 0; + pw.i[32] = 0; + pw.i[33] = 0; + pw.i[34] = 0; + pw.i[35] = 0; + pw.i[36] = 0; + pw.i[37] = 0; + pw.i[38] = 0; + pw.i[39] = 0; + pw.i[40] = 0; + pw.i[41] = 0; + pw.i[42] = 0; + pw.i[43] = 0; + pw.i[44] = 0; + pw.i[45] = 0; + pw.i[46] = 0; + pw.i[47] = 0; + pw.i[48] = 0; + pw.i[49] = 0; + pw.i[50] = 0; + pw.i[51] = 0; + pw.i[52] = 0; + pw.i[53] = 0; + pw.i[54] = 0; + pw.i[55] = 0; + pw.i[56] = 0; + pw.i[57] = 0; + pw.i[58] = 0; + pw.i[59] = 0; + pw.i[60] = 0; + pw.i[61] = 0; + pw.i[62] = 0; + pw.i[63] = 0; // yep that's faster + + //pw.pw_len = 1 + (l32 & 15); + pw.pw_len = 7; // some algorithms are very sensible on this (example: 12500) + + buf[gid] = pw; +} diff --git a/README.md b/README.md index e215a055b..438dd77f3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## *hashcat* ## -**hashcat** is the world's fastest and most advanced password recovery utility, supporting five unique modes of attack for over 200 highly-optimized hashing algorithms. hashcat currently supports CPUs, GPUs, and other hardware accelerators on Linux, Windows, and macOS, and has facilities to help enable distributed password cracking. +**hashcat** is the world's fastest and most advanced password recovery utility, supporting five unique modes of attack for over 300 highly-optimized hashing algorithms. hashcat currently supports CPUs, GPUs, and other hardware accelerators on Linux, Windows, and macOS, and has facilities to help enable distributed password cracking. ### License ### diff --git a/docs/changes.txt b/docs/changes.txt index 42bb6124b..5c002432b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -4,31 +4,44 @@ ## Feature ## -- Fully modularized hash-mode integration via plugin interface and converted all existing hash-modes +- Fully modularized hash-mode integration via plugin interface and conversion of all existing hash-modes - Refactor hashcat backend interface to allow adding compute API other than OpenCL -- Added CUDA as a new compute API to hashcat backend (enables hashcat to run on NVIDIA Jetson or IBM POWER9) +- Added CUDA as a new compute API to hashcat backend (enables hashcat to run on NVIDIA Jetson, IBM POWER9 w/ Nvidia V100, etc.) +- Added new options --backend-ignore-cuda and --backend-ingore-opencl to ignore CUDA and/or OpenCL interface from being load on startup +- Added new parameter --brain-server-timer to specify the seconds for the next scheduled backup +- Added new way to specify the outfile format, the new --outfile-format now also supports timestamps - Support use of all available GPU memory using CUDA backend +- Support use of all available CPU cores for hash-mode specific hooks - Support on-the-fly loading of compressed wordlists in zip and gzip format -- Support for inline VeraCrypt PIM Brute-Force +- Support for inline VeraCrypt PIM brute-force - Support deflate decompression for the 7-Zip hash-mode using zlib hook - Added documentation on hashcat brain, slow-candidate and keyboard-layout mapping features +- Keep output of --show and --left in the original ordering of the input hash file ## ## Algorithms ## +- Added hash-mode: AES Crypt (SHA256) - Added hash-mode: Android Backup - Added hash-mode: AuthMe sha256 +- Added hash-mode: BitLocker - Added hash-mode: BitShares v0.x - Added hash-mode: Blockchain, My Wallet, Second Password (SHA256) +- Added hash-mode: Citrix NetScaler (SHA512) - Added hash-mode: DiskCryptor -- Added hash-mode: Electrum Wallet (Salt-Type 3) +- Added hash-mode: Electrum Wallet (Salt-Type 3-5) - Added hash-mode: Huawei Router sha1(md5($pass).$salt) - Added hash-mode: Java Object hashCode() - Added hash-mode: Kerberos 5 Pre-Auth etype 17 (AES128-CTS-HMAC-SHA1-96) - Added hash-mode: Kerberos 5 Pre-Auth etype 18 (AES256-CTS-HMAC-SHA1-96) - Added hash-mode: Kerberos 5 TGS-REP etype 17 (AES128-CTS-HMAC-SHA1-96) - Added hash-mode: Kerberos 5 TGS-REP etype 18 (AES256-CTS-HMAC-SHA1-96) +- Added hash-mode: md5($salt.sha1($salt.$pass)) +- Added hash-mode: md5(sha1($pass).md5($pass).sha1($pass)) +- Added hash-mode: md5(sha1($salt).md5($pass)) +- Added hash-mode: MultiBit Classic .key (MD5) +- Added hash-mode: MySQL $A$ (sha256crypt) - Added hash-mode: Open Document Format (ODF) 1.1 (SHA-1, Blowfish) - Added hash-mode: Open Document Format (ODF) 1.2 (SHA-256, AES) - Added hash-mode: Oracle Transportation Management (SHA256) @@ -40,34 +53,44 @@ - Added hash-mode: QNX /etc/shadow (MD5) - Added hash-mode: QNX /etc/shadow (SHA256) - Added hash-mode: QNX /etc/shadow (SHA512) +- Added hash-mode: RedHat 389-DS LDAP (PBKDF2-HMAC-SHA256) - Added hash-mode: Ruby on Rails Restful-Authentication -- Added hash-mode: SolarWinds Orion -- Added hash-mode: md5($salt.sha1($salt.$pass)) -- Added hash-mode: md5(sha1($pass).md5($pass).sha1($pass)) -- Added hash-mode: md5(sha1($salt).md5($pass)) - Added hash-mode: sha1(md5(md5($pass))) - Added hash-mode: sha1(md5($pass.$salt)) - Added hash-mode: sha1(md5($pass).$salt) - Added hash-mode: sha1($salt1.$pass.$salt2) - Added hash-mode: sha256(md5($pass)) -- Added hash-mode: sha256(sha256_bin(pass)) +- Added hash-mode: sha256($salt.$pass.$salt) +- Added hash-mode: sha256(sha256_bin($pass)) - Added hash-mode: sha256(sha256($pass).$salt) +- Added hash-mode: SolarWinds Orion +- Added hash-mode: Telegram client app passcode (SHA256) +- Added hash-mode: Web2py pbkdf2-sha512 +- Added hash-mode: WPA-PBKDF2-PMKID+EAPOL +- Added hash-mode: WPA-PMK-PMKID+EAPOL ## ## Bugs ## - Fixed buffer overflow in build_plain() function +- Fixed buffer overflow in mp_add_cs_buf() function - Fixed copy/paste error leading to invalid "Integer overflow detected in keyspace of mask" in attack-mode 6 and 7 +- Fixed cracking multiple Office hashes (modes 9500, 9600) with the same salt +- Fixed cracking of Blockchain, My Wallet (V1 and V2) hashes with unexpected decrypted data - Fixed cracking of Cisco-PIX and Cisco-ASA MD5 passwords in mask-attack mode if mask > length 16 - Fixed cracking of Electrum Wallet Salt-Type 2 hashes - Fixed cracking of NetNTLMv1 passwords in mask-attack mode if mask > length 16 (optimized kernels only) +- Fixed cracking of VeraCrypt Streebog-512 hashes (CPU only) - Fixed cracking raw Streebog-HMAC 256 and 512 hashes with password of length >= 64 - Fixed cracking raw Whirlpool hashes cracking with password of length >= 32 - Fixed incorrect progress-only result in a special race condition - Fixed invalid call of mp_css_utf16le_expand()/mp_css_utf16be_expand() in a slow-candidate session - Fixed invalid password truncation in attack-mode 1 if final password is longer than 32 character +- Fixed invalid use of --hex-wordlist if encoded wordlist string is larger than length 256 - Fixed maximum password length limit which was announced as 256 but actually was 255 +- Fixed out-of-boundary read in pure kernel rule engine rule 'p' if parameter is set to 2 or higher +- Fixed out-of-boundary write to decrypted[] in DPAPI masterkey file v1 kernel - Fixed output of IKE PSK (mode 5300 and 5400) hashes to have separators at right position - Fixed output password of "e" rule in pure and cpu rule engine if separator character is also the first letter - Fixed problem with the usage of the hexadecimal notations (\x00-\xff) within rules @@ -85,21 +108,26 @@ - Building: Fix for library compilation failure due to multiple defenition of sbob_xx64() - Building: Updated BUILD.md - Cracking bcrypt and Password Safe v2: Use a feedback from the compute API backend to dynamically find out optimal thread count +- Dictstat: On Windows, the st_ino attribute in the stat struct is not set which can lead to invalid cache hits. Added the filename to the database entry. - Documents: Added README on how to build hashcat on MSYS2 -- Filehandling: Print a truncation warning in case an oversized line was detected +- File handling: Print a truncation warning when an oversized line is detected - My Wallet: Added additional plaintext pattern used in newer versions +- Office cracking: Support hash format with second block data for 40-bit oldoffice files (eliminates false positives) - OpenCL Runtime: Disable OpenCL kernel cache on Apple for Intel CPU (throws CL_BUILD_PROGRAM_FAILURE for no reason) -- OpenCL Runtime: Do not run a shared- and constant-memory size check if their memory type is of type global memory (typically CPU) -- OpenCL Runtime: Improve ROCM detection and make sure to not confuse with recent AMDGPU drivers +- OpenCL Runtime: Do not run shared- and constant-memory size checks if their memory type is of type global memory (typically CPU) +- OpenCL Runtime: Improve ROCm detection and make sure to not confuse with recent AMDGPU drivers - OpenCL Runtime: Not using amd_bytealign (amd_bitalign is fine) on AMDGPU driver drastically reduces JiT segfaults -- OpenCL Runtime: Unlocked maximum thread count +- OpenCL Runtime: Unlocked maximum thread count for NVIDIA GPU - OpenCL Runtime: Update unstable mode warnings for Apple and AMDGPU drivers - OpenCL Runtime: Workaround JiT compiler error on AMDGPU driver compiling WPA-EAPOL-PBKDF2 OpenCL kernel -- OpenCL Runtime: Workaround JiT compiler error on ROCM 2.3 driver if the 'inline' keyword is used in function declaration +- OpenCL Runtime: Workaround JiT compiler error on ROCm 2.3 driver if the 'inline' keyword is used in function declaration - OpenCL Runtime: Workaround memory allocation error on AMD driver on Windows leading to CL_MEM_OBJECT_ALLOCATION_FAILURE - OpenCL Runtime: Workaround ROCm OpenCL driver problem trying to write temporary file into readonly folder by setting TMPDIR +- OpenCL Runtime: Allow the kernel to access post-48k shared memory region on CUDA. Requires both module and kernel preparation - Startup Checks: Improved the pidfile check: Do not just check for existing PID but also check executable filename +- Startup Checks: Prevent the user to modify options which are overwritten automatically in benchmark mode - Startup Screen: Add extra warning when using --force +- Startup Screen: Add extra warning when using --keep-guessing - Startup Screen: Provide an estimate of host memory requirements for the requested attack - Status Screen: Added brain status for all devices - Status Screen: Added remaining counts and changed recovered count logic @@ -113,7 +141,7 @@ ## Technical ## -- Binary Distribution: Removed 32 bit binary executables +- Binary Distribution: Removed 32-bit binary executables - Building: On macOS, switch from ar to /usr/bin/ar to improve building compatibility - Building: Skipping Travis/Appveyor build for non-code changes - Codebase: Cleanup of many unused rc_* variables @@ -127,13 +155,17 @@ - Hash-mode 1460 (HMAC-SHA256 (key = $salt)): Allow up to 64 byte of salt - Hash-Mode 1680x (WPA-PMKID) specific: Changed separator character from '*' to ':' - Hash-Mode 8300 (DNSSEC (NSEC3)) specific: Allow empty salt +- Hash-Mode 12500 (RAR3-hp): Allow cracking of passwords up to length 64 - Keep Guessing: No longer automatically activate --keep-guessing for modes 9720, 9820, 14900 and 18100 +- Keep Guessing: No longer mark hashes as cracked/removed when in potfile - Kernel Cache: Reactivate OpenCL runtime specific kernel caches - Kernel Compile: Removed -cl-std= from all kernel build options since we're compatible to all OpenCL versions - OpenCL Kernels: Fix OpenCL compiler warning on double precision constants +- OpenCL Kernels: Moved "gpu_decompress", "gpu_memset" and "gpu_atinit" into shared.cl in order to reduce compile time +- OpenCL Options: Set --spin-damp to 0 (disabled) by default. With the CUDA backend this workaround became deprecated - OpenCL Options: Removed --opencl-platforms filter in order to force backend device numbers to stay constant - Parsers: switched from strtok() to strtok_r() for thread safety -- Requirements: Add new requirement for NVIDIA GPU: CUDA Toolkit (10.1 or later) +- Requirements: Add new requirement for NVIDIA GPU: CUDA Toolkit (9.0 or later) - Requirements: Update runtime check for minimum NVIDIA driver version from 367.x to 418.56 or later - Test Script: Switched from /bin/bash to generic /bin/sh and updated code accordingly diff --git a/docs/credits.txt b/docs/credits.txt index e89ffe2a3..403a6f261 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -56,6 +56,7 @@ Other contributors to hashcat * LZMA-SDK by Igor Pavlov * zlib by Jean-loup Gailly and Mark Adler * win-iconv by Yukihiro Nakadaira +* micro-ecc by Ken MacKay (used as reference for some secp256k1 operations) # Furthermore the following persons helped the project: @@ -77,4 +78,7 @@ Rick "Minga" Redman and KoreLogic (@CrackMeIfYouCan) Brandon Chalk (@brandoncasaba) * Kerberos Pre-Auth 17/18 kernel module, ported from @Fist0urs TGS kernel modules +Jamie Riden +* Web2py pbkdf2-sha512 plugin + !!! All the package maintainer of hashcat !!! diff --git a/docs/hashcat-plugin-development-guide.md b/docs/hashcat-plugin-development-guide.md new file mode 100644 index 000000000..b764145b6 --- /dev/null +++ b/docs/hashcat-plugin-development-guide.md @@ -0,0 +1,813 @@ +# Hashcat Plugin Development Guide # + +The purpose of this document is to introduce you to the development of plugins for hashcat 6.0.0 and newer. We will update this document regularly and add more detailed content. The content in its current state includes enough details to write easy, medium and hard plugins. + +With hashcat 6.0.0, a new interface has been designed which enables you to add new hash-modes more easily than in older hashcat versions. The plugin interface is an essential new feature of hashcat 6.0.0. + +One of our goals was to have the new interface to be independent from future versions of hashcat. This is achieved by hashcat loading your plugin code dynamically from a .so/.dll/.dylib library on startup. Another goal was to give the author of the plugin the option to share the plugin as source or in binary form. This is achieved by a clear separation between hashcat core code and plugin code. There is no longer a need to change hashcat core sources in order to add a new hash-mode. All existing hash-modes (300+) from older hashcat versions have been refactored to this new interface. + +We are well aware that as a developer you want to see as little change as possible on this interface. That is why our third goal was to get the interface to a fairly final state and minimize the risk of changing it once it is released. That is not an easy task. When you are designing such an interface, there is always a chance that you are missing some details for rare use cases. The refactorization of the 300+ existing hash-modes served both as a reference check and a feasibility study. We do not plan to change the interface except if there is a strong need for it. For that unlikely event of a major change, there is an automatic version check which is added automatically to your module at compile time. + +To make kernel development as easy as possible, we have already started in previous hashcat versions to include GPU-optimized OpenSSL-like crypto interfaces and finalized it with hashcat 6.0.0. If you are familiar with that interface, you know it typically uses a chain of context init(), update() and final() function calls. In all refactored pure kernel sources, you can see this interface type design being used. It is also our hope that the structure of the well known interface will make it easy for developers to use the existing kernel source as a useful reference. + +Developing a hashcat plugin can be very overwhelming at first. Do not get discouraged by it. After the first plugin, you will already feel practiced - and you will soon realize that the development steps are always the same. + +## Plugin Structure ## + +Let us jump right in. To develop a plugin for hashcat, you basically just need to create two files: + +* Module: This is where you do all the initial hash-mode configuration work. It is the code which executes on the CPU of the host system. Note that we are not talking about the compute-intense crypto stuff. For instance, the module is responsible for decoding of the hash file entries and to copy the data to the standardized hashcat memory structures. It features many different functions which you can use for special handling of your hash file data. You can choose much easier the rich library for decoding, encoding and converting you want to use. The modules are stored in the folder `src/modules/`. +* Kernel: This is the place where you put the real crypto implementation of your hash mode. This is the time-consuming code which is executed on the compute devices. The kernels are stored in the folder `OpenCL/`. Note that CUDA kernels also will be stored in that folder and have a .cl filename suffix. This may change in the future. + +You will read the terms "module" and "kernel" quite often from now on. Just for terminology, the combination of both "module" and "kernel" is what we call a hashcat "plugin". + +There is an -optional- third file: The unit-test stub. In this file you can implement the crypto scheme of your hash-mode from a "high-level" perspective. The stub is then called from hashcat's own testing suite. The goal is to test your hashcat plugin implementation by comparing the results of the unit-test stub with the results created from hashcat itself while using your plugin. It will automatically generate random passwords, salts, hashes, etc. for you and compare everything in very deep detail - so you can be sure your plugin implementation works in all different attack modes and most importantly also in some corner cases that might exist. + +## Before the code ## + +You need to code in the C language. If you are a C beginner, this may be a bit too hard, but if you have programming skills in C or if you have crypto programming skills in a different programming language, you should be able to write a hashcat plugin. While you have this documentation as a reference, it won't give you all the information (rarely used module functions or kernel function etc) you need. Be prepared to study existing code from other plugins for information. + +Rule number one: It is pointless to start developing a plugin if you do not have a deep understanding of the algorithm which you want to implement. Writing a plugin is a multi-layered process which you have to approach step by step. You never write the plugin from start to finish in a giant leap. Since we are working on a very low level, there is a big need for small milestones where you can stop and control intermediate values. For instance, if you want to implement a hash-mode which does md5(sha1($p)), then you implement sha1($p) first. At this point it makes sense to add a milestone to control the intermediate hash before you continue implementing the md5(). But where do you get these intermediate control values from? The answer is simple: from proof-of-concept code which you already have or write yourself first. It does not matter which language that this POC is written in, as long as you know how to breakpoint or how to manipulate the POC in order to print the wanted intermediate values. + +One more thing. You need to make an essential decision before you start with your implementation. You need to categorize your algorithm beforehand. Based on the details of the algorithm, it is either a so-called "fast" or a "slow" kernel type. This decision cannot be changed easily afterwards, so take your time. Do not worry, the right answer to this decision is simple and you can derive it from some algorithm details. + +Rule of thumb: + +* More than 100 iterations from whatever crypto primitive? -> slow kernel +* Expected less than 10 million guesses per second per GPU? -> slow kernel + +Otherwise you probably want to develop a "fast" kernel. Note that the most crypto primitives that would need to be implemented as a fast kernel already are implemented. However, if you actually want to write a "fast" kernel the main goal is to workaround the PCI Express bottleneck. For a more detailed explanation on how to calculate the bandwidth please have a look here: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#does_the_pci-express_speed_have_any_influence_on_cracking_speed. To workaround this bottleneck, you need to write attack-mode specific kernels. These kernels have a very special structure, but from a development perspective you just write your code in a "block" inside another level of a for() loop, the remaining parts are similar to what is used in a typical slow kernel. + +However, I expect most people reading this document want to write a "slow" kernel. Luckily, writing a slow kernel is easier to start with. Most of the time, you will find the compute-intense code in a kernel you can copy/paste from other kernels or the GPU crypto library and it is just for the final comparison/verification that you need to put in some brain power. + +Another preparation you need to make before you start coding is to pick the right hash-mode number. To make it short, there is some logic to this, but it is not easy to explain. + +* If you do not want to push your code to hashcat upstream, simply pick a number between 90000 and 100000. We will not use this range in the upstream repository. This way we can avoid any collisions in the numbering system. +* If you plan to contribute your code to hashcat upstream, please follow these guidelines: Think in steps of 100's, so that your hash-mode ends with 00. Go to hashcat GitHub master and check for the highest hash-mode being used (For example, see src/modules/). Select a number by yourself which ends with 00 and that is a number which is between 1000 and 2000 higher than the current highest existing hash-mode. For instance, if the highest value is 21500, then a valid hash-mode number for your plugin could be 22800. The moment when you PR your code, we will reserve a fixed hash-mode number for you. The changes afterwards will cost only a few minutes of time. + +## Development Environment ## + +In theory there is no special hardware required for hashcat plugin development. However, there are some recommendations that we can give you: + +* Stick as close as possible to the hardware on which the plugin is supposed to run on. For instance, If you write a plugin which is supposed to be used by pentesters (like Kerberos), you probably want to use a mobile GPU for development. If you write a plugin which is probably used on private computers (like crypto-currency wallets), use a discrete mid-range GPU. If you write a plugin being used in digital forensics (like TC), you probably want to use a discrete high-end GPU. +* If you plan to use an NVIDIA GPU you will have the least unwanted side effects. Additionally this has the advantage you can test it on both the new CUDA and the old OpenCL backend. Since hashcat version 6.0.0 there is a backend which supports both compute API. Note that you will need to install the CUDA SDK in case you want to use the CUDA backend. The CUDA SDK is required for both developing and running CUDA kernels. This goes back to the problem that the NVIDIA driver does not support JIT compiling the kernels. That is the advantage of OpenCL over CUDA. You only need the drivers and the ICD installed. +* If you plan to use an AMD GPU, please use ROCm drivers. This limits you to use Linux. At the time of writing this document, the use of amdgpu-pro drivers is a pain. Do yourself a favor and do not try to develop on amdgpu-pro drivers. +* If you plan to use a CPU for development, make sure that you install and use the Intel OpenCL Runtime. Interestingly, even if you are using an AMD CPU, the Intel runtime runs very smoothly with them. Do not try to use MESA, POCL or Beignet/NEO drivers. Also note that on a CPU there is no such thing like shared memory that we have on GPUs. If your algorithm is making heavy use of shared memory you will not see the effects of it. + +One of the most important factors for choosing the right compute API is that it supports using printf() from inside the kernel. In the past this way of debugging was not possible, which made kernel development a real pain. With the current OpenCL drivers this works pretty well. Get used to the idea that printf() becomes your primary debugging utility. Since you only write a very small piece of code in the kernel it is not as bad as you may think. + +Personally, I like to write my plugins on Linux, but of course you can also use macOS or Windows. All regular runtimes support debugging functionalities on all operating systems. + +Some more remarks for the hardware of your development platform: + +* Since you will recompile the kernel (via the JiT) very often. To avoid getting frustrated waiting for the compiler to finish, I think it is very beneficial to have a high clocked CPU. The number of cores is not very important (for development system). +* Limit the system to a single GPU only. Otherwise the code is compiled for each GPU in the system. While the code is cached after the same GPU types, the memory allocation can not. Each additional GPU will significantly increase your startup time. Start on a single GPU, then switch to a multi GPU system at a later point in time. +* High-End GPUs can have a negative effect on development since they ship with a lot of specialized hardware instructions. Since the JiT will always try to optimize your code as much as possible, these additional instructions will complicate the optimizers task. +* Low-END GPUs can have a negative effect on development since they lack resources. You will maybe write your code in a too resource saving way, hurting the performance on a High-End GPUs. + +My Development at the time of writing this document (beginning of 2020) is an Intel I5 generation 6 with a regular SSD and 16GB memory. The system runs on Ubuntu 18.04 Server. The GPU is an NVIDIA GTX 980. Additionally I am using Intel OpenCL runtime, but only to test the code on the CPU afterwards. + +Before you actually start with your implementation make sure you have already cloned hashcat from GitHub master, that you are able to compile it on your system and that it runs smoothly. Make sure you have a clean installation with no previous version artifacts laying around. + +## Test Suite ## + +The optional unit-test stub originally was made only to automate the task of plugin verification. It is written intentionally in a different language (Perl) and not in C. From our perspective this has a lot of advantages and benefits. Despite of the language the input and the output data of any hashing/encryption algorithm should be the same. If they match, then your plugin implementation is very likely to be working correctly. + +From our experience in the last years adding new hashcat hash-modes we cannot stress enough how important it is to have a POC (as described earlier) to print intermediate values. If we do not already have some sort of POC, we use this optional unit-test stub as a POC replacement. Writing a unit-test is typically done from a high-level programming language, thus Perl is a good candidate to do so, but there is also some unit-test stubs written in python. At this point we already created some synergy because you can use it as a POC to start with the development and later it acts as a normal unit-test stub and you do not have to write it twice. If you do not care about POC's and unit-test you can directly jump to the module subsection from here. + +The Test Suite is a Perl Framework. The main program (tools/test.pl) loads at runtime the hash-mode specific code written like a plugin. The structure of this perl module is standardized. We have already mentioned that all existing code to the 300+ hash-modes from previous hashcat versions have been refactored. Also all 300+ hash-mode specific unit-test stubs have been refactored into this new Test Suite Framework. The same way the before mentioned modules and kernels act as a reference, the unit-test stubs can also be used as reference. In most of the cases you can simply copy/paste from an existing unit-test stubs, change a small piece of code and both are ready, the POC and the unit-test stub. + +The test suite itself consists of two files: + +* tools/test.pl: This program generates random passwords, salts and loads the unit-test stub code which you will develop. +* tools/test.sh: This script compares the generated passwords from test.pl with the output from hashcat. It calls the hashcat binary multiple times, each time with a different set options to test your implementation on a deep level. + +The filename of your unit-test stub has to be: tools/test_modules/m[hash_mode].pm + +### test.pl ### + +The tools/test.pl Script has three different use cases: + +* Single (default) +* Passthrough +* Verify + +When calling tools/test.pl from the command line, the first parameter you have to give is the use case type. It should be either "single", "passthrough" or "verify". + +You need to implement three methods in your unit test stub. Note that the use cases are not directly related to the methods. You need to implement all three, then you can make use of all three use cases: + +* module_constraints() +* module_generate_hash() +* module_verify_hash() + +The second parameter is the hash-mode itself. In case of "verify" you have to give some additional parameters. For the exact syntax please see `tools/test.pl --help`. + +In order to get `tools/test.pl` running you need to install a lot of perl modules. To help you install them quickly, we have developed a simple script `tools/install_modules.sh`. You may want to take a look inside before you execute it. At this time, none of the perl modules require a special version which means you can also use the perl modules which your distribution offers to you (if you prefer it that way, for instance the GCrypt perl module with `apt install libcrypt-gcrypt-perl` on Debian/Ubuntu). + +#### Single Mode #### + +In single mode, a number of random passwords are generated for the selected hash mode. Each of the generated passwords is passed to the module_generate_hash() method (which is one of the methods you have to populate with code) and thus a hash is generated. In the end, both information, password and final hash line (which typically also contains the salt) are output to stdout, so that you can execute the output as if it would be a real shell script. If your hash-mode requires one (or more) salts, this will also be created automatically. The most important thing is that test.pl generates passwords of different lengths, with the guarantee that the minimum and maximum length password are always included. + +Attention: The testing suite expects that the module_generate_hash() method will return the output of the final hash line. You have to return this as a string in the exact format that hashcat will later accept. + +If your implementation contains optimizations based on the password length (for example 0x80's, zero based options, etc.) then you would also want to verify that such optimizations also work with all possible password lengths. Therefore, another function must exist in your stub: module_constraints(). + +The module_constraints() method is easy to understand. It returns exactly 5 integer pairs. These pairs always define a range, therefore they consist of a minimum and a maximum number. The order of the pairs is the following: + +* Pure-Mode-PW-Constraints +* Pure-Mode-Salt-Constraints +* Optimized-Mode-PW-Constraints +* Optimized-Mode-Salt-Constraints +* Optimized-Combined-PW-and-Salt-Constraints + +If you do not need one of the named pairs or the pair does not make sense because it is not applicable, you must use -1 for minimum and maximum. Please note that there is a strong difference between pure and optimized kernels. We have not discussed this concept so far, therefore let us stick to pure kernels. With a few exceptions, slow hash types have no implementation of an optimized mode, because the performance does not drop too much because of register pressure, but because of the iteration count, which you cannot optimize. We will come to the different kernel modes in the kernel section. + +Another important note about salts. Often one or more salts are needed. Possible iteration counts, IV or random content data can also be seen here as "salt". This data can be so different that it does not fit into a single policy / interface. Therefore, test.pl cannot standardize this complex situation. For simple forms of salts only, test.pl provides you with a simple form of random salt data. You can specify the length constraints (min/max) of the salt data in the constraints section. In more complex situations, you will not be able to avoid creating your own salts by calling some helper functions that test.pl provides you with, directly in the module_generate_hash() method. + +Example: + +``` +my $iter = shift // 10000; +my $user_salt = shift // random_hex_string (128) +my $ck_salt = shift // random_hex_string (128) +my $user_iv = shift // random_hex_string (32) +``` + +#### Passthrough Mode ##### + +In passthrough mode, test.pl expects the *passwords* from you, quite the opposite of single mode where they were generated automatically. Every password that you send via stdin (e.g. pipe) is passed to the module_generate_hash() method and the resulting hash is sent to stdout. The rest is identical to single mode. + +Example: + +``` +$ echo hashcat | tools/test.pl passthrough 1600 +$apr1$93341$gNT2pItX5h6Lc/XjTWuyb1 +``` + +Note: In this specific case the newline character after the password (compare it to `echo -n hashcat`) is used as a delimiter between the lines/passwords and therefore not considered part of the password (remember that `echo hashcat | md5sum` for instance produces "wrong" results, in general, because of the extra newline). + +#### Verify Mode ##### + +In verify mode you go one step further than in single or in passthrough mode. In two different files you give both, a specific hash and in another file the (same) hash including the matching password. The goal is that the expected hash is generated from the module_generate_hash() method, which is then compared with the input from the first file. If the comparison passed, the original hash is written in a third file. + +This is where the module_verify_hash() method is used for the first time. In this method, you have to break down the hash line into its individual parts, especially those components that are absolutely necessary to reconstruct the exact same hash. For instance, if the algorithm needs one or more salts, then this salt must be extracted. Finally you call the module_generate_hash() using the extracted components (salts, iteration counts etc). + +At this point we need to go back to the module_generate_hash() function. To make the verification work. It is necessary that your module_generate_hash() function recognizes whether a salt has been newly generated and, if this is the case, only then actually generate a random salt yourself (as described in the single mode). + +Here is a real life example from Android Backup plugin (tools/test_modules/m18900.pm) + +``` +sub module_generate_hash +{ + my $masterkey_blob = shift; + ... + if (defined $masterkey_blob) + { + # verify call, write code to use the given salt + } + else + { + # regular call, write code to generate random salt + } + ... +``` + +The script is called with the following command line parameters: + +``` +perl tools/test.pl verify 18900 hash_list.txt cracked_list.txt verified_list.txt +``` + +After the command line parameter "verify" the hash mode is specified ("18900" in this example), followed by the original hash list (hash_list.txt) without passwords. After the hashfile the path of the file with the list of cracked hashes, including passwords is given. The format of this file is simply hash[:salt]:password the same way as hashcat would output them. Note that you can have multiple lines. The third parameter specifies the output file. It contains the lines that have been verified as correct and that also appear in the original hash list. + +You should also always test that the exit code of test.pl is 0, otherwise it could be that the output file was not overwritten. + +The verify mode is an excellent replacement for a missing POC. + +### test.sh ### + +The test.sh is an overlay for test.pl, which actually calls the hashcat binary based on the return values from test.pl in single mode (it interacts with both). The test.sh shell script also compares the return values of the hashcat binary with the expected result. This includes tests such as whether all hashes have been cracked, whether the associated password is the correct one and not any other from the test.pl return, whether the output hash is displayed in the correct format, etc. + +Furthermore, the script has many different options (when called in the command line) with which you can narrow down to specific tests. You typically want to make use of this feature, because a complete test run across all hash modes can take several days. + +The main options: + +* Select hash type (-m): Test only a special hash-mode +* Select test mode (-t): Test either single-hash or multi-hash kernel +* Select attack mode (-a): Test a special attack mode. With a slow hash, this is automatically switches to a straight attack, because there are no attack-mode specific kernel implementations + +If the options are not set, attack-mode 0 for hash-mode 0 is executed. To see additional options, see tools/test.sh --help + + + + +## Module ## + +The first really needed ingredient to create a plugin is the module. The module is a single .c source code file in which you can freely implement the 68 different interface functions or add your own auxiliary functions. No worries, I have never had a module which required me to implement all 68 functions. Many functions are really only required in special cases. In the best cast you only need to implement 2 functions. + +The integration in hashcat is very easy. Your module is compiled to a .so shared object on Linux (or .dll on Windows and .dylib on macOS). The moment when hashcat starts, it loads the shared object corresponding to the hashmode the user specified by the -m option (default is -m 0). + +The path in which you have to store your module is `src/modules/module_XXXXX.c`. From there the module is compiled as a shared object into the folder `$(SHARED_FOLDER)/modules/module_XXXXX.[so|dll|dylib]`. The XXXXX is the hash-mode number (with leading zeros). There is no need to adjust any hashcat core sources. The makefile `src/Makefile` automatically finds the module you added and compiles it with the necessary flags. + +If you run hashcat under linux or macOS without the `make install` target from the current working directory, then `$SHARED_FOLDER` typically equals the current working directory. On Windows it is always the current working directory because there is no install target in the makefile. A modification of the Makefile is probably only necessary in exceptional cases, i.e. if your module requires an external library. In this case and if you want to contribute the plugin to upstream, then we have to coordinate the development. Please contact us directly in such cases. + +There is no need to implement any black magic into the module. A module covers exactly what you would expect from plugin, which is this: + +* Attack type (fast hash or slow hash) +* Digest size and orderings +* Salt type +* Hash name and category +* Kernel number +* Various optimizers and workflow options +* Hash and Password for self-test purpose +* Decoder and Encoder +* Password and Salt length limits +* Hook functions +* JiT compiler options + +Namely, these configurations take place in a variety of optional functions that you provide in every module. There is a few mandatory functions which need to be implemented: + +* module_init() +* module_hash_decode() +* module_hash_encode() +* module_attack_exec() +* module_dgst_pos0() +* module_dgst_pos1() +* module_dgst_pos2() +* module_dgst_pos3() +* module_dgst_size() +* module_hash_category() +* module_hash_name() +* module_kern_type() +* module_opti_type() +* module_opts_type() +* module_salt_type() +* module_st_hash() +* module_st_pass() + +At first glance, this looks a bit overwhelming. But in fact, all of these functions (apart from the first three) are only configuration parameters. You may wonder why we have not designed the module by simply setting a macro/number item for each of the configurations. But we wanted to give you the opportunity to change this configuration at runtime and not just at compile time. For example, if you only want to use a specific optimizer but only if the user runs the kernel on a GPU and not if the user runs it on a CPU. But this actually goes into deep detail. In reality, it usually looks like this: + +``` +static const char *HASH_NAME = "MD5"; +... +const char *module_hash_name (...) { return HASH_NAME; } +... +module_ctx->module_hash_name = module_hash_name; +``` + +As you can see here, there is a so-called module_ctx object. Here you register all functions that you have implemented in your module and which should be used by hashcat. A list of all functions and their prototypes can be found under `include/modules.h`. + +Hashcat will automatically call the module_init() function when it loads your module. In this function, you simply register all the functions that you have programmed by assigning it to module_ctx. + +Example: + +``` +module_ctx->module_hash_name = module_hash_name; +``` + +For all functions that you do not use, please use the macro MODULE_DEFAULT. Using this macro, hashcat can see that its module_ctx_t structure is in the correct version (if you only want to distribute a binary). For instance, if a new function is added in a future version, the structure in the binary-distributed older version is one address too short and contains the value NULL. With this approach, hashcat can ensure that you work with your compatible module_ctx_t structure. + +The only two mandatory functions that you normally have to program for a minimal plugin integration, are the decoder function module_hash_decode() and the encoder function module_hash_encode(). The other remaining mandatory function which typically only consists of static configuration items, but not code. Here is each of them explained: + +### module_attack_exec() ### + +There are only two different types that have already been discussed in the "Before the code" chapter. Here you determine whether your kernel is slow or fast hash. + +* ATTACK_EXEC_OUTSIDE_KERNEL -> slow hash +* ATTACK_EXEC_INSIDE_KERNEL -> fast hash + +The naming goes back to how the password candidate generator was implemented in the past. If the hash is a slow hash, reading a password candidate from GPU memory does not have any relevant impact on the performance. Therefore we can execute the password candidate generator in a standalone kernel and call it beforehand (there are actually three: STRAIGHT, COMBINATOR, MASK). The kernel then writes the resulting candidates to GPU memory. After that, hashcat calls the hash-type specific _init kernel function which loads the candidates from GPU memory. + +If the crypto of the kernel is very fast, reading from GPU memory would create a bottleneck. For fast hashes we need a different approach. We load a "base" passwords from GPU memory to GPU registers, but only at the start of the kernel, in the "outer" loop. Then we enter an inner loop inside the kernel in which we iterate through a (limited) number of modifications and apply them to the base word. Note: this is what we call the kernel-loops. We can modify the candidate on a register level which keeps the memory access very low. In hashcat we have three base attack modes (STRAIGHT, COMBINATOR, MASK), for each of which we need to implement a specific kernel. The only difference is how we apply the modification on the base password candidate. + +I will explain more about the details in the kernel section, but this already explains why writing a slow hash kernel is much easier. It is just one kernel, not three. + +Example: + +``` +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +``` + +### module_dgst_pos0() - module_dgst_pos3() ### + +Before we can understand exactly why this is here, we must briefly note the following: + +Cracking passwords is about time. That means depending on the speed of your kernel, iteration count, etc. you will never be able to try out a certain amount of password candidates. For instance, take NTLM. This hash mode is calculated on a high-end GPU like a 2080Ti with approx. 100GH/s. If we assume that you have 8 of these GPUs in a node and if we assume that you have 1,000,000 nodes, then you will still need roughly 6,500 billion years to try out 2^127 password candidates. What I want to say with this: there is an upper limit of password candidates we can search through because we are always limited in time, no matter how much money we spent on hardware. Or from a different angle: It does not matter how many bits a hash actually outputs because what actually prevents guaranteed cracking is not its output bit size but only time to go through a specific keyspace. At this time of writing I assume with a multi million dollar budget you can search through a maximum of 56 bits per second. If we assume a runtime of 10 years we can cover another 30 bits. So it is safe to say we can never search through a keyspace which is larger than roughly 90 bits. Therefore it is safe to store only 128 bits of it in a lookup database in hashcat. That means even for SHA512 with 512 bits, we are actually only interested in 128 bits of it. That is great, so we only need to test for 128 bits instead of 512 bits and save some clocks. + +That means that you have to "select" these 128 bits. This makes particular sense because a cryptographic algorithm can never calculate all of its bits at the same time in its implementation. For instance, in MD5 (128 bit) the first 32 bits are calculated first, but then followed by the last 32 bits, then the penultimate 32 bits, etc. Exactly this effect which must exist in all hash algorithms is exploited by the hashcat optimizers. After the first 32 bits are known they are checked against the database if they do not exist, no further steps of the crypto algorithm need to be calculated. This order is given in an index of 32 bit integers. That means for MD5 the first check index is 0 and the second index is not 1 but 3, etc. + +To find the right values for you, just take a deep look into your crypto algorithm and figure out which parts (in 32 bit blocks) of the output hash is finished first, which one finishes next, and so on. + +Example: + +``` +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +``` + +For slow hashes, you will normally set the "order" to 0, 1, 2 and 3, because such optimizations are of little importance here. + +### module_dgst_size() ### + +As you can see in the previous section, only 128 bits of the target hash are tested, but the hash must be saved entirely so that it can later be converted from its binary form back to its original form. Only you can know the size of the hash you are storing, but hashcat needs this information so that it can allocate necessary memory buffers. + +Important: Hashcat will provide this buffer of the size you specified in a void buffer which you will use as *digest_buf in the decoder/encoder. + +Some macros already exist because they have already been used in many modules before. A list of the well known digest sizes already defined can be found in `include/types.h`. + +Example: + +``` +static const u32 DGST_SIZE = DGST_SIZE_4_4; +``` + +This scheme is a bit cryptic. It goes back to the following logic: We store 32 bit values (each 4 byte) and we have 4 of them, in that order. So the macro results in 16 bytes (128 bits). + +Tip: If you have a real hash as a target, this is relatively self-explanatory. But if you are not using a real target hash, but for example some encrypted data, then it makes more sense to save this data in an "esalt" struct. From there only save the encrypted data (for example the first 16 bytes) as a digest replacement. Encrypted text has a sufficiently high entropy to provide the uniqueness that hashcat expects in the digest buffer. An "esalt" is described at the end of this document because there is two different types of salt structures used in hashcat code. + +### module_hash_category() ### + +This configuration has no influence on the process in hashcat, but only serves for documentation. The only time that hashcat is currently using this information is when it is called with --help. Here the modes are first sorted by category. A list of the categories already defined can be found in `include/types.h`. + +Example: + +``` +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; +``` + +If you want to add a category/type, that is not a problem. But since a change like this would change hashcat's core source, you should use a separate pull request (PR) in GIT. + +### module_hash_name() ### + +This configuration has no influence on the process in hashcat, but only serves for documentation. It is a simple string that you can name as you like. It is then displayed in the status view or in the --help menu. + +Tip: Try to limit the length to a maximum of 48 characters, otherwise it may exceed the maximum column size in the --help menu. + +Example: + +``` +static const char *HASH_NAME = "MD5"; +``` + +### module_kern_type() ### + +Here you specify the kernel hash mode number that this module should load. A kernel is always located under `OpenCL/mXXXXX_a[0|1|3]-[optimized|pure].cl`. This configuration is possible because of the feature to use a kernel from different modules. A good example of this is PBKDF2-HMAC-SHA512 which is used for both GRUB2 and macOS 10.8. + +In theory, one could imagine implementing all such hash modes in a huge single kernel in this way, but such a kernel would become very inefficient due to the number of branches. Again, this is a trade off from readability/maintainability vs. performance. Since a password cracker is a product in which high performance is one of the most important properties, it usually ends up in a dedicated kernel for each hash mode. A look at the `OpenCL/` folder will confirm that. + +Example: + +``` +static const u64 KERN_TYPE = 7100; +``` + +### module_opti_type() ### + +This configuration item is a bitmask field. There are a few switches which you can enable and disable. But be careful, some of them have the potential to break your plugin. I recommend being very cautious using these flags. As always, the list of flags can be found here: `include/types.h`. I will comment the ones which exist right now: + +* OPTI_TYPE_OPTIMIZED_KERNEL: This flag indicates if an optimized kernel should be used (otherwise a pure kernel will be used). It can be set by the hashcat user by passing the -O option on the command line or by hashcat if it detects that no pure kernel for that particular hash-mode exists in the `OpenCL/` folder. Note that it can also be automatically deactivated by hashcat if the user set the -O option on the command line but no optimized kernel was found. Do not set this flag from within your module. +* OPTI_TYPE_ZERO_BYTE: This indicates that the zero byte auto-optimizer is active. I have described the zero byte optimizations here: https://hashcat.net/events/p13/js-ocohaaaa.pdf. Note that with today's OpenCL/CUDA JiT many optimizations that had to be optimized by hand are done by these compilers automatically. Therefore this flag acts as a documentation flag only (it is shown as an optimizer on hashcat startup). Some other optimizers are actually used by the kernel. The downside of this is that you cannot disable these kinds of Jit compiler optimizations selectively. You can only disable them all by using the `-cl-opt-disable` flag in the JiT compiler options. there is a special function module_jit_build_options() which you can use if you want to pass it to the JiT compiler. +* OPTI_TYPE_PRECOMPUTE_INIT: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_MEET_IN_MIDDLE: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_EARLY_SKIP: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_NOT_SALTED: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_NOT_ITERATED: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_PREPENDED_SALT: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_APPENDED_SALT: Appended salts can be optimized as if they do not exist in some circumstances. Typically this flag makes sense for generic raw hash primitives. For instance, sha1($p.$s). This flag copies the salt data to the end of a mask in an -a 3 attack automatically. From the perspective of the mask processor (password candidate generator) the salt is a static part given by the user as part of the password. By doing so, we can save the append branch of the salt in the inner loop of the kernel which improves the performance. If the hash cracks, hashcat will automatically remove it from the mask. +* OPTI_TYPE_SINGLE_HASH: For fast hashes this will select the sXX kernels instead of the mXX kernels. The sXX kernels do not need to go through a bloom filter and no binary tree search is performed. Instead, they will store the target hash (which is just a single one) on the register level. As a result, the comparison will be much faster, and the speed improves. This flag is set by hashcat automatically on startup. Do not set this flag from within your module. +* OPTI_TYPE_SINGLE_SALT: similar to OPTI_TYPE_ZERO_BYTE. +* OPTI_TYPE_BRUTE_FORCE: This flag is a requirement for some other flags, such as OPTI_TYPE_APPENDED_SALT. Only when this flag is active, can OPTI_TYPE_APPENDED_SALT be exploited. This flag is set by hashcat automatically on startup. Do not set this flag from within your module. +* OPTI_TYPE_RAW_HASH: This flag is a requirement for some other flags, such as OPTI_TYPE_APPENDED_SALT. If this flag is active, then OPTI_TYPE_APPENDED_SALT can be exploited. This flag needs to be set from within the module, based on whether the kernel can make use of OPTI_TYPE_APPENDED_SALT. +* OPTI_TYPE_SLOW_HASH_SIMD_INIT: This flag tells the hashcat host binary to divide the number of work items with the size of the vector being used. The *_init kernel needs to be written using vector data types. Vector data types have a strong impact on CPU performance, since they will be translated from the OpenCL JiT into SSE2/AVX/AVX2/XOP instructions. Modern GPUs use scalar data types thus there is no benefit from using vector data types. This is not recommended for *_init kernels because it makes the kernel much more complicated while at the same time the _init kernel is called only once per password guess. +* OPTI_TYPE_SLOW_HASH_SIMD_LOOP: see OPTI_TYPE_SLOW_HASH_SIMD_INIT but for *_loop kernels. If it is possible for your *_loop kernel to be written in vector data types, this is highly recommended. You will typically find this option being used if the _loop kernel does not do any data-dependent branching. +* OPTI_TYPE_SLOW_HASH_SIMD_COMP: see OPTI_TYPE_SLOW_HASH_SIMD_INIT but for *_comp kernels. +* OPTI_TYPE_USES_BITS_8: This flag is passed to the JiT and helps optimize some of the GPU library functions at compile time. The configuration defines the bitsize of the underlying crypto primitive. +* OPTI_TYPE_USES_BITS_16: see OPTI_TYPE_USES_BITS_8 +* OPTI_TYPE_USES_BITS_32: see OPTI_TYPE_USES_BITS_8. This is the default in case no OPTI_TYPE_USES_BITS_* flag is being used. Almost all traditional crypto primitives use 32 bits: MD4, MD5, SHA1, SHA256, RipeMD160, etc. +* OPTI_TYPE_USES_BITS_64: see OPTI_TYPE_USES_BITS_8. It is important to set this flag in case your crypto primitive uses 64 bit integers. Examples: SHA512, Blake2, SHA3, Streebog, etc. +* OPTI_TYPE_REGISTER_LIMIT: This flag limits the maximum register counter to 128. This flag only has an effect on NVIDIA devices since the NVIDIA compiler is the only one that supports it. Only a few algorithms really benefit from it. It is worth testing to see if there is a performance increase, otherwise, do not use it. + +### module_hash_decode() ### + +The decoder function is the function that is called again and again for every line in your hashfile. We also call this sometimes the hash parser. Here you have to program the logic which decodes the line into its components and then stores them in the standardized data structure which hashcat understands. + +Typically hash files are text files in which each hash is stored in a single line. Before the decoder function is called, Hashcat opens the hash file and scans the number of lines. Based on this information, it pre-allocates memory buffers for the hash digest, the salt and the esalt so you do not need to allocate any buffers from inside the decoder. If you allocate buffers from inside the decoder, you must free them as well. The size of the digest is based on what is returned from module_dgst_size(). The salt_t is a fixed size structure and the esalt size is known from module_esalt_size(). There is also some more rarely used buffers like module_hook_salt_size() but the logic is always the same. Hashcat simply multiplies the size of all these different structures by the number of lines. It then rewinds the file handle and starts iterating. For each iteration of these input lines, the module_hash_decode() function is called. The input pointer points to the new hash line and the output pointers point to the corresponding previously allocated buffers. You can directly access the pointers to store the digest, salt, esalt and other buffers without any offsets. + +In hashcat there are two different types of salt structures. It is essential to understand them; please read the section "About salts" at the end of this document first. If you are unaware about the different concepts of salt_t and esalt, you really need to read that section before you continue this section. + +For instance, if your crypto algorithm is something like MD5(MD5($pass.$salt)), then you can expect to find both a hash and a salt in each of your hash lines. In the decoder function, it is up to you to split these two parts (typically by using the tokenizer - please read the tokenizer section below) and copy them into a standardized hashcat structure. + +You are also responsible for checking the boundaries of all the input data. The tokenizer helps you with some very specific validation routines beforehand, but some very specific tests can be done only by you. If there is an error, you can simply return from this function by setting a specific error code, such as PARSER_HASH_VALUE or some other descriptive output. As always, a list of available error codes can be found in the `include/types.h` header. If everything works okay, you need to return this function with PARSER_OK. + +If you are working with salts, you need to guarantee you have set the salt_buf[] array and salt_len value. If you are writing a slow kernel, you need to guarantee you have set the salt_iter value. Please read the "About salts" section if you do not know what these variables are. + +In addition to the input line and the output buffers, there are some extra buffers available for you in the decoder functions. For instance, the *hashconfig structure. Sometimes you need to execute different branches of code in the decoder, based on the user options being set. For instance, if the user sets the -O option on the command line, you can detect this from inside the decoder by checking the OPTI_TYPE_OPTIMIZED_KERNEL in hashconfig->opti_type. A good example for this is `src/modules/module_00000.c` which exploits the fact that you can reverse the Merkle-Damgard construction in optimized kernels since it is guaranteed that the password is never longer than 55 characters. + +A typical decoder function covers the following actions (not all of them always apply): + +* If esalt: cast esalt to plugin specific data types +* Cast void* digest array to either u32* or u64* array, based on what your algorithm uses. This is the digest buffer which is also copied to the compute devices. We will write to this buffer at the end of the function. +* Initialize tokenizer +* Configure the number of tokens based on the format of your hash lines +* Configure each token based on the format of your hash lines +* Run the tokenizer, check its result and return in case of an error +* Cast the tokenizer pointer to an element specific pointer +* Do additional boundary/limits checks on the specific pointers you just created and return in case of an error +* Convert the element specific pointers and typically write them to some local variables +* If slow hash: Set the iteration count +* Copy data (IV, salts, digests) to hashcat buffers +* Adapt buffers/variables (typically byte swaps for endianness or precomputations) based on user options +* Return with PARSER_OK + +### module_hash_encode() ### + +The opposite is the case with the encoder function. It is only called up as soon as hashcat has to provide the user with the hash in its original hash form. For instance, if a hash is cracked or in the status display (with single hashes). Typically you will find a number of snprintf() statements here, but for more details, there is an extra section below. + +Important: Keep in mind the input buffer you get access to in the encoders are probably reused again in a later point of time. If you need to modify values before printing it to the user, make sure to not write into the original buffers. Instead, create a local buffer, copy the data to that buffer, and modify it in there. + +The final hash should go to line_buf[] array and the length of the data in this array is the return value of the function itself. + +Note: the general rule is that the kernel code should not do any unnecessary repetition of data manipulation (e.g byte swaps etc) because it should run as fast as possible. Instead, the encoder and decoder are host functions that are normally only executed very rarely - and therefore it is not a problem if they need to change the data a little bit to pre-compute, or adapt the data to make it look nice in the output. + +### module_opts_type() ### + +This configuration item is a bitmask field and is very similar to the module_opti_type() function. The main difference is that here you configure general options of the workflow and not optimization specific settings. As always, the list of flags can be found here: `include/types.h`. The following list contains the flags currently supported: + +* OPTS_TYPE_PT_UTF16LE: This option will generate a password based on a given mask but in UTF16LE encoding instead of raw 8 bit encoding. There are two important things to mention. First, the encoding is not a true UTF16 encoding. There is no iconv conversion done. It is a naive implementation which works by just putting zero bytes in between the characters. This is a performance-relevant optimization. This works fine for any characters that would not need utf8 to be displayed/used correctly (in other words, everything that is covered with the hashcat ?a character set). Second, it is effective only for fast hash kernels and only in -a 3 attacks. For all other attack mode kernels for fast hashes, you need to use the *_utf16le() specific functions for pure kernels or the make_utf16le() function for optimized kernels from inside the kernel manually. For slow hashes you need to use the *_utf16le() specific functions manually, too. +* OPTS_TYPE_PT_UTF16BE: Same as OPTS_TYPE_PT_UTF16LE but using big endian byte order. +* OPTS_TYPE_PT_UPPER: This needs to be used in case your hash is designed to uppercase (not capitalize!) the password before it hashes it. A good example is the LM hash. When the flag is used, this option is always active no matter which attack mode or fast vs slow hash. Note that a user can override this by using a rule which lowercases the password. +* OPTS_TYPE_PT_LOWER: Same as OPTS_TYPE_PT_UPPER but lowercase the password. +* OPTS_TYPE_PT_ADD01: This will append a 0x01 to the password. Some algorithms use stop bits like this to mark the end of the data input stream. The idea is to workaround unwanted collisions so we need to do so, too. This is effective only for fast hash kernels and only in -a 3 attacks. For all other attack mode kernels for fast hashes you need to add the 0x01 byte yourself from inside the kernel manually, typically with functions like append_0x01_4x4_S() or similar. For slow hashes, if you use the crypto libraries, they typically handle this for you. +* OPTS_TYPE_PT_ADD02: Same as OPTS_TYPE_PT_ADD01 but use 0x02 byte instead. +* OPTS_TYPE_PT_ADD06: Same as OPTS_TYPE_PT_ADD01 but use 0x06 byte instead. +* OPTS_TYPE_PT_ADD80: Same as OPTS_TYPE_PT_ADD01 but use 0x80 byte instead. +* OPTS_TYPE_PT_ADDBITS14: Same as OPTS_TYPE_PT_ADD01 but add the length of the password * 8 to the 14th' 32 bit integer (Typically algorithms using little endian: MD4, MD5, RipeMD160, etc). +* OPTS_TYPE_PT_ADDBITS15: Same OPTS_TYPE_PT_ADD01 but add the length of the password * 8 to the 15th' 32 bit integer (Typically algorithms using big endian: SHA1, SHA256, etc). +* OPTS_TYPE_PT_GENERATE_LE: Generate passwords from mask in little endian byte order. This is the default if no OPTS_TYPE_PT_GENERATE_* option is set. +* OPTS_TYPE_PT_GENERATE_BE: Generate passwords from mask in big endian byte order. +* OPTS_TYPE_PT_NEVERCRACK: This option tells hashcat to continue cracking the same hashes after they have been cracked - typically, for algorithms that are known to produce a lot of false positives or to collide easily. If the user uses the --keep-guessing command line option, this option is automatically added to the opts_type variable. Do not set this option from the module. +* OPTS_TYPE_PT_ALWAYS_ASCII: This option prevents hashcat to automatically convert a password into the $HEX[...] encoding type. This automatic conversion is typically performed if the password itself contains the same character as the hash line separator character. +* OPTS_TYPE_PT_ALWAYS_HEXIFY: This option forces all the cracked passwords to be written always in hex. In this case neither "$HEX[", nor "]", is added. +* OPTS_TYPE_PT_LM: Special handling for LM passwords: all lower, 7 max, ... +* OPTS_TYPE_PT_HEX: Assume that all input data like wordlist and masks are always given in hex +* OPTS_TYPE_ST_UTF16LE: Same as OPTS_TYPE_PT_UTF16LE but applied on the salt buffer. +* OPTS_TYPE_ST_UTF16BE: Same as OPTS_TYPE_PT_UTF16BE but applied on the salt buffer. +* OPTS_TYPE_ST_UPPER: Same as OPTS_TYPE_PT_UPPER but applied on the salt buffer. +* OPTS_TYPE_ST_LOWER: Same as OPTS_TYPE_PT_LOWER but applied on the salt buffer. +* OPTS_TYPE_ST_ADD01: Same as OPTS_TYPE_PT_ADD01 but applied on the salt buffer. +* OPTS_TYPE_ST_ADD02: Same as OPTS_TYPE_PT_ADD02 but applied on the salt buffer. +* OPTS_TYPE_ST_ADD80: Same as OPTS_TYPE_PT_ADD80 but applied on the salt buffer. +* OPTS_TYPE_ST_ADDBITS14: Same as OPTS_TYPE_PT_ADDBITS14 but applied on the salt buffer. +* OPTS_TYPE_ST_ADDBITS15: Same as OPTS_TYPE_PT_ADDBITS15 but applied on the salt buffer. +* OPTS_TYPE_ST_HEX: Same as OPTS_TYPE_PT_HEX but applied on the salt buffer. +* OPTS_TYPE_ST_BASE64: Same as OPTS_TYPE_ST_HEX but using base64 encoding. +* OPTS_TYPE_HASH_COPY: This copies the original input hash line as it is into a buffer so that it can be used later. This is required if the original input hash line ships with the same data which is not copied into salt_t or esalt buffer because it is overhead data which is not used in any way. The hash line is copied to the buffer hash_info->orighash and can be used from the encoder function by simply returning hash_info->orighash. Please do not abuse this functionality, for two reasons: First, by being able to reconstruct the original hash line from only the hashcat data we verify that the correct amount of data has been stored in the hashcat memory structures (IOW, it is a good verification process). Second, the host memory requirement for saving this data increases drastically. +* OPTS_TYPE_HASH_SPLIT: This needs to be used if the hash actually contains multiple hashes in the same hash line. A good example is the LM hash which is typically stored as a 128 bit hash, but actually is built on two 64 bit hashes. +* OPTS_TYPE_LOOP_EXTENDED: This flag can be used if you want to execute a *_loop_extended kernel directly each time a _loop kernel is finished. This actually means directly after each _loop kernel invocation when no final values are ready. The _loop kernel typically only iterates for a maximum of 1024 iterations and then returns. This provides low kernel runtimes, which reduces GPU screen lags and avoids driver watchdog events. However, some algorithms can be exploited by working on exactly these intermediate values. +* OPTS_TYPE_HOOK12: Execute a hook kernel (CPU code) between _init and _loop kernel. A hook kernel is a normal kernel which can be used to select/copy very specific intermediate data and copy it to a so-called hook transfer buffer. This transfer buffer exists on both GPU and CPU. After the kernel is completed, the GPU buffer is copied to the corresponding CPU buffer so it can be processed. Then, the real hook function from your module is called from which you can read the intermediate data, process it as you need and then store it back. After your CPU function is finished, the buffer is copied back to the GPU automatically. The typical use case for this is if you need to deal with algorithms which include libraries which have no GPU implementation. Hashcat will automatically spawn a number of threads for you, so this is a multi threaded process. All buffers which are not constant buffers are thread-safe. +* OPTS_TYPE_HOOK23: Same as OPTS_TYPE_HOOK12 but the hook is between the _loop and the _comp kernel. Do not confuse this with OPTS_TYPE_LOOP_EXTENDED. A hook is always when the final values are ready to be processed. We believe most algorithms that need hook code will use this hook instead of OPTS_TYPE_HOOK12. +* OPTS_TYPE_INIT2: Some algorithms (usually updated from previous crypto schemes) execute two different types of compute intensive derivation functions. A good example is iTunes 10+. In iTunes 9 there is an algorithm with 10,000 iterations of SHA256. However, Apple updated this algorithm to be backward compatible. They use the output of the iTunes 9 KDF as the password to a new KDF which is 10,000,000 iterations of SHA256. The problem is that even for a KDF with 10,000 iteration we need to split this. In this instance we split this into 10 calls to a _loop kernel with 1,000 iteration otherwise users get massive screen lags or some watchdogs restart the drivers. In such a case, you can use OPTS_TYPE_INIT2 and OPTS_TYPE_LOOP2 kernels where you can execute the updated KDF with 10,000,000 iterations and also split it into 1,000 iteration chunks. +* OPTS_TYPE_LOOP2: See OPTS_TYPE_INIT2 +* OPTS_TYPE_AUX1: Some hash algorithms, often those with backward compatibility, share the same KDF (for instance, PBKDF2-HMAC-SHA1) but also use the derived key differently, depending on a version number. In theory you can check this version in the _comp kernel and build two different branches inside the _comp kernel. In many cases this is implemented like this. The AUX kernels are an alternative where you can assign the different branches to specific kernels. This greatly reduces instruction cache misses and helps the JiT to produce better code. It can also help in cases where both branches require a certain amount of shared memory that is larger then you are able to allocate. In case you use AUX kernels, the _comp kernel is executed, but it is expected to be empty. +* OPTS_TYPE_AUX2: See OPTS_TYPE_AUX1, but for a different branch. +* OPTS_TYPE_AUX3: See OPTS_TYPE_AUX1, but for a different branch. +* OPTS_TYPE_AUX4: See OPTS_TYPE_AUX1, but for a different branch. +* OPTS_TYPE_BINARY_HASHFILE: Use this in case your hash file contains binary data. As you can imagine, a bit of special handling is required. For normal hash files with only text data, hashcat reads the file line by line and for each line the decoder function is called. For binary data you can decide yourself if you want to use hashcat to load the binary data and present it in the line_buf[] buffer or if you want to iterate through the binary data yourself. If you select the first variant (default) this has the disadvantage that you can only load a single hash. If you want to load multiple hashes from binary data, then you need to understand that it is unknown to hashcat how to iterate through different "hashes" because it cannot know the binary structure. However, hashcat needs to know the number of hashes that are included in the binary file in order to allocate the required memory structure. In the first step, hashcat calls the module function module_hash_binary_count() in which you need to return the number of hashes which will be read from this particular binary data. In a second step, the module function module_hash_binary_parse() is called in which you have to implement the logic to iterate through the different hashes yourself. In theory there is no need to provide module_hash_decode() because it is not called by hashcat, however in the spirit of good programming we recommend to stick to this function for binary hashes as well. Use the module_hash_binary_parse() to load the binary data and prepare the chunks and then call module_hash_decode() and provide the hash. Then regularly parse the data in module_hash_decode() and copy its data to hashcat structures. For easy single hash loading of binary data you can take a look at `src/modules/module_05200.c` and for a multi hash example take a look at `src/modules/module_02500.c`. Note that for the WPA example there is also a lot of other functions involved to deal with binary data, such as writing the binary data in case a hash was cracked. +* OPTS_TYPE_KEYBOARD_MAPPING: there are a few algorithms which support the remapping of characters from inside the kernel. The configuration of the mapping can be loaded from the hashcat host binary on startup, thus it is required to set this option to let the hashcat host binary know that your kernel will support this functionality. Please read `docs/keyboard-layout-mapping.md` for a detailed explanation. +* OPTS_TYPE_DEEP_COMP_KERNEL: This option is used for algorithms that use a salt which is related but unlinked from the esalt. Use this in case you want the hashcat host binary to iterate through the different esalts in the _comp kernel for you. This is a very complex scenario which requires a detailed explanation. Please refer to the section "Data Structures: salt_t vs esalt" at the end of this documentation. A good example is `src/modules/module_22000.c`. +* OPTS_TYPE_TM_KERNEL: This option works for fast hashes only. It enables you to run a special transpose multiplier (TM) kernel prior to each kernel invocation. This can be handy for bitsliced kernels where you have to transpose the multiplier data, for instance in a 32x32 matrix. Typically doing this kind of operation forces you to use fixed kernel loop count, so that you have guaranteed fixed size data blocks to transpose. You can do so by using the same fixed value from module_kernel_loops_min() and module_kernel_loops_max(). However, a transpose matrix is just application. Feel free to exploit this kernel for your own needs. +* OPTS_TYPE_SUGGEST_KG: This option prints a warning screen to the user on startup of hashcat. You can use this option to inform the user that your plugin is known to emit collisions and/or false positives and to suggest use of the --keep-guessing option. We do not want to enable this option by default - otherwise, the user would have no chance to disable it since there is no --no-keep-guessing option. +* OPTS_TYPE_COPY_TMPS: This option tells the hashcat host binary to copy the `tmps` data structure from the compute device to the host in case a hash was cracked. In order to access this data, you need to implement and register the module function module_build_plain_postprocess(). There are several scenarios in which this can be useful. For instance, if you have a weak algorithm that could be exploited to leak portions of the password and you use this leaked data to speed up your attacks, you still need to know the leaked data on the host to copy it to the password buffer before printing it to the user. A good example for this is PKZIP `src/modules/module_20510.c` which leaks the first 6 bytes of the password. Another scenario is the PIM brute force in VeraCrypt. The PIM in this case can be seen as an additional numeric password. In case we crack it, the user needs to know both the password and the PIM in order to mount the volume. +* OPTS_TYPE_POTFILE_NOPASS: This option simply prevents the hashcat host binary from adding a cracked hash to the potfile. For instance, if a specific hashing algorithm is implemented with several hash formats and therefore your plugins hash format shares the same format with a different plugin hash format (think of it like a format clash where the potfile parser could not really decide if it is the correct hash format to accept). A good example is the WPA PMK, which cannot be used to login to a specific WPA network directly. There could be other reasons for not printing the cracked hashes to the potfile. +* OPTS_TYPE_DYNAMIC_SHARED: This is a very special option which tells the hashcat host binary to query the real available shared memory on a device for a particular kernel. In addition it will also register the queried amount of shared memory from the host. On NVIDIA, this allows us to use the full available shared memory (regions in the post 48k range), though we still need to prepare the kernel in order to make use of the dynamic allocated shared memory. A good example is the bcrypt kernel `OpenCL/m03200-pure.cl`. + +### module_salt_type() ### + +This option tells hashcat that your hash is salted. Not all hashes are salted (mainly raw hashes have no salt). If they are salted, hashcat needs to know which strategy to use for storing the hashes. Here are the possible options: + +* SALT_TYPE_NONE: This type is used if the hash is not salted. +* SALT_TYPE_EMBEDDED: This type is used if you have a strict hash format ruleset and you do not need to give the user the opportunity to use --hex-salt. You should use this type if there are dedicated extraction tools for your hash or if you are under the control of the extraction tool (so that you can make changes to it). +* SALT_TYPE_GENERIC: This type is used if you have a generic salt, that is if the salt is part of a hash line which does not go back to a strict formatting ruleset. Typically if you need to implement a hash mode for which you know there are multiple exporting tools that work slightly differently. This mode is required if you want to enable the use of --hex-salt for the user. +* SALT_TYPE_VIRTUAL: This type is used if you want to reuse an existing kernel implementation of a hash mode which normally expects a salt, but for this variant you want to support loading a hash file in a format that does not ship with a salt. You will generate a `virtual` salt that is always the same (typically empty) and set the data in the decoder function accordingly. A good example for this is md5(md5($p)) which shares the same kernel with vBull (which is md5(md5($p).$s). + +### module_st_hash() ### + +Here you provide a hash for the self-test functionality. You also need to provide the correct password for this hash later. Please only use artificial hashes which you generated yourself. Typically this is a hash with the password "hashcat" which you have generated by using test.pl in passthrough mode. + +Note that this hash will also be used as reference for the benchmark mode. In some rare circumstances to have a not too long running iteration count to reduce startup time delays. A good example for this is iTunes 10+ `src/modules/module_14800.c`. This can also be done using test.pl. + +The --example-hashes command line argument together with a specific hash mode (-m) will also instruct hashcat to show the example hash and example password. + +### module_st_pass() ### + +This is the password to crack the hash given in module_st_hash() for the self-test functionality. + +## Kernel ## + +This is the second necessary ingredient for creating a plugin. Particular attention should be paid to the development of the kernel. Compiling the kernel takes a relatively long time, so both hashcat and the various compute APIs try to save a binary kernel in a cached structure. This serves to reduce the startup time and it is important for the user experience (UX). This however can be a pain as a developer. + +NOTE: You -must- manually delete all cached kernels with every change to your kernel code. This is -very- important! + +``` +$ rm -rf kernels/ +``` + +Note: `make clean` will automatically remove all cached kernels, but the recompilation with `make` of the whole hashcat binary will of course take much longer and this is therefore not recommended. + +Keep in mind that a GPU is a multi-core device; hashcat will always try to utilize the parallelization power of the hardware as much as possible. This can be undesirable behavior while you are developing a kernel. Especially when you start using printf() - your console can get flooded easily with debugging information because hundreds of work items will be executed. Keep in mind that the printf() will be called for every workitem. + +Additionally, there are a couple of kernel invocations which are unwanted when developing a kernel. They go back to the self-test functionality and the autotune engine. Both features are important for user experience. Keep in mind that the input password for these kernels invocation are not based on the password candidate you expect. It is therefore recommended to disable these features while developing the kernel. + +To enable some of the special developing functionalities - for example, to disable the autotune - you need to unlock these undocumented features first. The first step is to enable debugging in `src/Makefile` by setting DEBUG to `1`. Run a `make clean` afterwards. + +Typically you want to develop the kernel with the least amount of unwanted side effects and we should invest in some proper preparation before actually starting writing code. A good example for this is the hash which you are using. Hashcat supports the hash given at the command line, but the command line can create unwanted side effects. For instance, the `$` character could be part of the hash and you forgot to quote it correctly. The safer way is to write the hash and the password into separate files, as this will generally avoid any problems with interpretation from the shell. Of course this is not required, but it is the mindset which I am trying to emphasize. + +Additionally there is a couple of command line parameters that you want to use: + +* --potfile-disable: The moment when your implementation is almost complete and you start cracking the hash for the first time as expected it is very likely it will turn out some other things are not perfect. For instance, the encoding of the cracked hash. So you need to change some code and run hashcat again to verify this option will prevent hashcat from writing the cracked hash to the potfile. This will allow you to restart hashcat without the need to remove the potfile manually. +* --self-test-disable: The self-test feature serves to test the kernel each time the user starts hashcat to ensure it works on the users hardware as expected. Hashcat does not know you are implementing a new kernel, so it will call the kernel you are implementing, too. This has two unwanted side-effects. First, it will print a self-test failure which is clear to us, but not to hashcat. Second and more relevant, if you use printf(), it is very likely to print values which you are not expecting. This is because you are expecting values based on the hash or password you gave on the command line, not the values produced by the self-test hash or self-test password. If you use the same hash and password, you may wonder why it is printed twice. +* -n 1 -u 1 -T 1: The combination of these three options with these exact values will disable the auto tune. This is hardcoded into hashcat. This is an undocumented feature. The auto tune will create the same problems as the self-test feature. +* --quiet: When you are expecting printf() results, try to limit the hashcat output to a minimum. The printf() itself is not affected by this option. +* --backend-vector-width 1: Only required if you are developing the kernel by using a CPU as compute device. Printing elements from vector data types is possible (for instance `printf (a.s1);`), but we should avoid any influence. Some OpenCL runtimes even support printf() of a vector data type, which results in very weird outputs. +* -d 1: In case you have multi compute devices in your system, limit it to a single compute device. This is to reduce startup and JiT compile time. + +Typically a developer command line for hashcat looks the following: + +``` +$ rm -rf kernels $HOME/.nv; ./hashcat -m XXXXX hash.txt word.txt --potfile-disable --self-test-disable -n 1 -u 1 -T 1 --quiet --backend-vector-width 1 -d 1 +``` + +If you need to printf from without a _loop kernel, keep in mind that you need to add a branching manually for a specific loop position. + +``` +if ((loop_pos + i) == 0) printf ("%08x\n", a); +``` + +Some last recommendations about printf() itself. Printing a string %s is not recommended. Missing zero bytes or big endian byte order can be very confusing. Instead try to use only the %08x template for everything. Especially for strings this makes a lot of sense, if for example you want to find unexpected non zero bytes. This can be done by calling printf() multiple times. Get used to this and it will simplify a lot of things for you. + +To decide which type of kernel you want to write (pure or optimized), here are some recommendations when to write an optimized kernel implementation: + +* If your algorithm can be optimized by artificially limiting the password or salt length to a specific range it makes sense to have an optimized kernel implementation. But note, this does not exclude the need for a pure kernel implementation for longer passwords. +* If your algorithm is limited to a maximum length per password, for example 8 characters, the previous recommendation applies the same way. But in this case it does not even make any sense to have a pure kernel implementation because the optimized kernels hashcat support passwords up to length 31. +* If your algorithm has some known weaknesses you probably cannot use the hashcat crypto library because to have full control you have to re-implement the hash in your own function. A good example is NTLM and the meet-in-the-middle optimization. If no hashcat crypto library is being used, you probably want to implement this in an optimized kernel. +* If your algorithm can be optimized based on the chosen attack-mode, it should be covered using an optimized kernel because you probably need to re-implement the hash in your own function. + +These recommendations apply for both fast and slow hashes. + +In most cases, however, the code for the hash is exactly the same. In these cases you probably want to only implement a pure kernel. + +### Kernel parameters ### + +Hashcat will call all kernels with exactly the same parameters. In most cases only a few of the parameters are used, but on the other hand they do not have a negative impact on the performance. Having a fixed prototype for all kernels makes it easier to work with all the different buffers and generally makes it easier to read kernels from other people. + +There is no need for you to change anything. This section is only for information. While it is not relevant for you to know all the different parameters, at least some of them are important to know. Never write to any of them directly unless you know about the implications. Use the macros provided if you want to write something. Most of the buffer you do not even need to read from. The ones that are interesting for reading I will mark in the description. + +* pw_t *pws: In fast hash kernel mode, this is the buffer of the base passwords. In slow hash kernel mode, this is the buffer of the passwords. You want to read from this buffer. There is one entry for each work item. +* kernel_rule_t *rules_buf: This is the buffer which holds the configuration of the modifier rules. In fast hash mode you want to read this buffer from the inner loop in your _a0 kernels. +* pw_t *combs_buf: This is the buffer which holds the modifier passwords. In fast hash mode you want to read this buffer from the inner loop in your _a1 kernels. +* void *bfs_buf: This is the buffer which holds the modifier part of the password mask. In fast hash mode you want to read this buffer from the inner loop in your _a3 kernels. +* void *tmps: This is the generic context buffer. It is available only in slow hash kernel mode. In slow hash mode you want to read and write this buffer. There is one entry for each work item. +* void *hooks: This is the generic hook buffer. It is available only in slow hash kernel mode and if hooks are enabled. In slow hash mode you want to read and write this buffer. There is one entry for each work item. +* u32 *bitmaps_buf_s1_a: This is the bitmap for the bloom filter which is used in a fast-hash multi-hash kernel. +* u32 *bitmaps_buf_s1_b: See bitmaps_buf_s1_a. +* u32 *bitmaps_buf_s1_c: See bitmaps_buf_s1_a. +* u32 *bitmaps_buf_s1_d: See bitmaps_buf_s1_a. +* u32 *bitmaps_buf_s2_a: See bitmaps_buf_s1_a. +* u32 *bitmaps_buf_s2_b: See bitmaps_buf_s1_a. +* u32 *bitmaps_buf_s2_c: See bitmaps_buf_s1_a. +* u32 *bitmaps_buf_s2_d: See bitmaps_buf_s1_a. +* plain_t *plains_buf: This is where hashcat stores the index to the base password and the modifier (if used) of a cracked hash. This buffer is used by hashcat to reproduce the password on the host and print it to the user along with the hash. The buffer has as many entries as there are unique digests. +* digest_t *digests_buf: This is the one big buffer which holds all unique digests. It is searched using a binary search after the hash passed the bloom filter. +* u32 *hashes_shown: This is a buffer which marks individual hashes as cracked after they have been cracked. This way we do not report the same hash cracked twice or more often. +* salt_t *salt_bufs: This is the buffer which holds the fixed size salt data. See the salt_t section below for details. If you are using a fixed size salt data, read from here. There are as many entries as there are unique salt_t buffers, but you do not need to iterate through them from inside the kernel. Use the "salt_pos" variable (see below) to index the current one. +* void *esalt_bufs: This is the buffer which holds the generic size salt data. You need to cast this type from inside the kernel manually. There are as many entries as there are unique digests, but you do not need to iterate through them from inside the kernel. Use the "digests_offset" variable (see below) to index the current one. +* u32 *d_return_buf: This buffer is used to indicate to hashcat that a hash has been cracked and should be shown to the user. +* void *d_extra0_buf: This buffer is used to workaround the OpenCL memory limitation that only a maximum of 1/4 of the total device memory can be used from a single allocation. Some algorithms, especially memory hard algorithms, can make use of this. +* void *d_extra1_buf: See d_extra0_buf. +* void *d_extra2_buf: See d_extra0_buf. +* void *d_extra3_buf: See d_extra0_buf. +* u32 bitmap_mask: This is the mask for the bloom filter. It depends on the bitmap size which was automatically calculated from hashcat on startup. +* u32 bitmap_shift1: This is the shift of the individual hash elements which is used for the bitmaps of type 1. There are two different data shifts to reduce the number of collisions in the bitmap. +* u32 bitmap_shift2: See bitmap_shift1. +* u32 salt_pos: This variable is used to index the current salt_t entry. You want to use this when you access the salt_bufs buffer. +* u32 loop_pos: This is the current iteration number to start with. If you have a slow hash kernel, this variable is relevant in the _loop kernel. Since the _loop kernel is limited to a maximum iteration count of 1024, some algorithms have higher iteration counts and have iteration count depending logic implemented. +* u32 loop_cnt: This is the number of iteration counts to loop in the inner loop in the _loop kernel. Typically not higher than 1024. +* u32 il_cnt: This is the number of iteration counts to loop in the inner loop in a fast hash kernel. Typically not higher than 1024. There is no offset needed because the modification buffers are maintained by hashcat and never exceed 512 entries. This enables hashcat to store the modifiers in the constant memory of the device. +* u32 digests_cnt: This is the total number of unique digests in the digests_buf array of the current salt. It is important for the binary search. +* u32 digests_offset: This is the offset to the first entry or unique digests in the digests_buf array of the current salt. It is important for the binary search. +* u32 combs_mode: This is a specific configuration for combinator based attack in slow hash mode. It defines which side (left or right) is the base and which is the modifier side. You want to access this variable from your _a1 kernels. +* u64 gid_max: This is the total number of unique work items started from the host program. Each work item needs to identify itself using the `get_global_id (0);` and check if the number is smaller than this variable. This goes back to the requirement of clEnqueueNDRangeKernel() that the total number of work items has to be a multiple of the thread count and therefore could be higher than the actual number of password candidates to test. If such a work item accidentally would crack the hash, the host binary would run into a out of boundary read because it could not find the corresponding base password. + +The large number of kernel parameters can be confusing when writing a kernel. But since they never change, we can easily replace them with a macro. There is a couple of kernel parameter replacement macros where you need to choose one from for your kernel: + +* KERN_ATTR_BASIC(): Use this in your fast hash kernel if this is attack mode 1 or 3 and not using vector data types. +* KERN_ATTR_BITSLICE(): Use this your fast hash kernel is using a bitsliced implementation. This requires the modifier buffers to be preprocessed with a TM kernel beforehand. +* KERN_ATTR_ESALT(e): Use this if your fast hash kernel uses an esalt structure. +* KERN_ATTR_RULES(): Use this in your fast hash kernel if this is attack mode 0. +* KERN_ATTR_RULES_ESALT(e): Use this in your fast hash kernel if this is attack mode 0 and uses an esalt structure. +* KERN_ATTR_TMPS(t): Use this if your slow hash kernel only uses a tmps structure. +* KERN_ATTR_TMPS_ESALT(t,e): Use this if your slow hash kernel uses a tmps structure and an esalt structure. +* KERN_ATTR_TMPS_HOOKS(t,h): Use this if your slow hash kernel uses a tmps structure and a hook structure. +* KERN_ATTR_TMPS_HOOKS_ESALT(t,h,e): Use this if your slow hash kernel uses a tmps structure, a hook structure and an esalt structure. +* KERN_ATTR_VECTOR(): Use this if your fast hash kernel uses vector data types in the inner loop. Note: Only valid for -a 3 kernels. +* KERN_ATTR_VECTOR_ESALT(e): Use this if your fast hash kernel uses vector data types in the inner loop and uses an esalt structure. Note: Only valid for -a 3 kernels. + +### Kernel: fast hash type ### + +The fast hash type is needed if we are cracking a hash that is so fast to compute that the PCI express bottleneck is taking more time than to compute the hash. These raw hashes are designed to compute very fast intentionally. They typically consist of only binary or arithmetic operations either with none or limited memory access. That means they often can be implemented on register level. On the other hand, if we need to access any memory structures just to provide the password candidates, it will hurt the performance significantly. Therefore the general concept of a fast hash kernel is to load a base password candidate directly onto a register and run a for() loop within the kernel which modifies the base password candidate. + +The modification is depending on the attack-mode. Hashcat supports 5 different attack-modes with the -a command line flag (0, 1, 3, 6 and 7) but attack-mode 6 and attack-mode 7 share the same kernel code with attack-mode 1. This means we have to implement three kernels. These kernels are implemented in three kernel source files (0, 1, 3). Based on the attack-mode selected by the user on startup, hashcat will load the corresponding kernel. + +The file name convention for fast hashes is: `OpenCL/mXXXXX_a[0|1|3]-[pure|optimized].cl` + +#### Kernel: fast hash type (optimized) #### + +As you can see from this convention, you actually have to implement six kernels if you want to add a full featured fast hash mode to hashcat. It is up to you if you want to save some time only implementing a pure kernel, only an optimized kernel or both. But in each case you must implement all three attack modes to support all the different attack types supported by hashcat. + +Remember we only need to have those three different implementations due to the different ways the password candidate is generated. You may think it would be easier to have like three branches but these branches would already decrease the performance drastically. + +Each fast hash kernel source in optimized mode has to provide the following kernel functions with this convention: `mXXXXX_[m|s][04|08|16]`. + +As always, the XXXXX is the hash mode with leading zeros. The `m` or `s` defines the multi-hash and single-hash implementation. In single hashes, often we can store the target hash on the register which makes the final test much faster compared to checking it on GPU memory. The `m` and `s` therefore often look almost the same. The only difference is that in the `s` kernel at some point you will store the target hash in a register. The final comparison function macro for `m` is COMPARE_M_SIMD() and for `s` is COMPARE_S_SIMD(). +For single-hash this will add code to do on-register comparison. For multi-hash this will add the code to run the bloom filter and a binary tree search. For both cases, the macros expect you to provide 4 times 32 bit values in the same order as you have configured in the module functions module_dgst_pos0() - module_dgst_pos3(). Note that it always has to be 4 times 32 bit values, also for hashes which provide much more or much less bits output size. See the sections about `module_dgst_pos0()` - `module_dgst_pos3()` for details. + +There are some kernels where using vector data types are beneficial even if they are executed on compute devices which have no native support for vector data types. A good example is NTLM running on a high end GPU. The performance gain comes from how the algorithm works and that there is in total 60 instructions that can be precomputed based only on the scalar base password. The base password never changes. The vectorization is done only in the inner loop, but from there it can access the precomputed (scalar) values from the outer loop. It saves both, instructions and resources. This is done automatically by the compiler because the structure of hashcat kernels allows the compiler to optimize it. + +#### Kernel: fast hash type (pure) #### + +The main purpose of pure kernels is to support long passwords (and salts) up to length 256. However, pure kernels are much easier to write than optimized kernels. First, it is only a single-hash and a multi-hash kernel to code. Second, it is expected you use the hashcat crypto libraries, for instance `OpenCL/inc_hash_sha256.cl`. To use the hashcat crypto libraries requires some detailed knowledge, please check the section on the hashcat crypto library below. + +Each fast hash kernel source in pure mode has to provide the following kernel functions with this convention: `mXXXXX_[mxx|sxx]`. + +The pure kernels are supposed to run slower than optimized kernels, but it is hard to define a percentage which shows the performance difference because it largely depends on what kind of optimization you can use. For instance, for NTLM in which you can do meet-in-the-middle tests, the optimized kernel is around three times faster than the pure kernel. On contrary, for SHA256-HMAC they have exactly the same performance. + +### Kernel: slow hash type ### + +Do not get the word "slow" in "slow kernel" wrong. This only means that the expected speed is so slow (or better said, the algorithm is so demanding) that the PCI Express Bottleneck is no longer relevant. + +The slow hash kernel also supports pure and optimized kernel implementations. + +In most cases you will develop only pure kernel implementations. An optimized slow hash implementation makes sense only if the _loop kernel uses parts of data (like the password or a salt) in its original form. Then you can do password length based optimizations. A good example is `OpenCL/m00500-optimized.cl`. However, these kernels are rare and therefore I will only describe the pure kernel implementation. There is also a specific kernel that I recommend looking at, `OpenCL/m00500-pure.cl`, you can use it for comparison. + +As already mentioned, most slow hash modes do not use password length specific kernels like in a fast hash kernel. There is no "s04", "s08" kernels or anything like this. Dedicated single and multi-hash kernels also do not exist in this case, because it wouldn't make any sense or performance difference. + +There are three kernels you need to implement. This means that you need to split the algorithm into a part which is done for initialization, a part which does the iterations (typically the part of the code which makes it slow) and final part where you do some comparisons or tests to see if the derived key matches. These kernels are: + +* mXXXXX_init: This is the first kernel which is called. In here you load the password candidate, convert it to UTF16 or a different endianness if needed, then store some precomputed values or crypto primitive contexts derived from passwords and salts and initialize the `tmps` buffer. +* mXXXXX_loop: This is where you put the real work intensive computation. Typically KDFs become slow artificially. They use a fast crypto primitive to produce some hash output and then use this hash output as input to another "round", and so on. There are some exceptions to this like scrypt, but in most cases there are some sort of iterations involved. Put them here. Note that hashcat will never execute all iterations in one big loop. This would create a very laggy screen to the user and some driver watch dogs will kill the kernel because it will think the algorithm hangs due to the long runtime. Typically no more than 1024 iterations per kernel invocation are executed (you can override this value, but only within the module). In order to achieve this we need to read the current context state from a special buffer `tmps` (which is explained below in detail) at the beginning of the kernel, then do the iterations in a loop and finally store the context state to the `tmps` buffer. When the _loop kernel is called again, it reads the `tmps` buffer which we set in the previous _loop kernel and continues from there. This goes up to the point that salt->salt_iter is reached. +* mXXXXX_comp: This kernel is called after the _loop kernel finished with the last iteration. Basically this is when the KDF is finished deriving some sort of key. This key often is used to decrypt some data. For some more generic KDF, the key can be used like a hash and you just call the macro to look it up in the database. This typically is the part which takes the most time to develop because the code is more complex. Often you have to match some patterns or test for known plaintexts but this is fresh code which you probably won't find in any of the other kernels. The _init and _loop kernels often can simply be copied from other kernels. The simple _loop kernel typically is much slower compared to the more complicated _comp kernel. That means it is often not worth to spend too much effort into optimization of the _comp kernel. + +It is obvious, but the kernels are executed in exactly this order: mXXXXX_init, mXXXXX_loop(N), mXXXXX_comp. + +Along with the three kernels goes a context buffer called `tmps` which is accessible for read and write by all three kernels. The data type of this buffer is a void* and you cast it to a structure you need from inside the kernel. Hashcat knows about the size of the buffer because you returned it in the module in the module_tmp_size() method. This buffer is unique for every work item executed on the compute device. This means that hashcat will allocate a buffer on the compute device which has the size of your structure multiplied with the maximum possible work items which was discovered by the auto tuner. Each password candidate has its own `tmps` buffer allocated. The buffer is thread safe and free to be read or written to. You do not need to care about race conditions, mutexes, etc. + +Typically it goes like this: + +* In the "mXXXXX_init" kernel you write into `tmps` at the end. +* In the "mXXXXX_loop" kernel you read from `tmps` at the beginning and write into `tmps` at the end. +* In the "mXXXXX_comp" kernel you read from `tmps` at the beginning. + +For slow hashes it is recommended to use vector data types if your algorithm allows to do so. If you use vector data types, use it in the _loop kernel only. Make sure to inform hashcat about using the appropriate opts_type option (see modules section). + +## Hashcat Crypto Library ## + +The hashcat crypto library interface is very close to the OpenSSL interface with the typical Init(), Update() and Final() calls. But there are some important differences: + +* The OpenSSL interface is designed with the idea the library is executed on a device which supports 8 bit, 32 bit and 64 bit registers. The hashcat crypto library is designed with the idea it is executed on a device which supports -only- 32 bit registers (like a GPU). +* The OpenSSL interface does not support the use of vector data types. This makes sense since in a typical use case scenario of OpenSSL there is no need to compute multiple keys based on multiple passwords at the same time. However, if we want to utilize special CPU instructions like SSE2, AVX2, XOP, etc. we need to write our code using vector data types. This enables the OpenCL runtime to do the translation. The hashcat crypto library therefore supports both scalar and vector data types as input data, but you need to use a different context data type. For instance, sha1_ctx_vector_t instead of sha1_ctx_t. + +Working with the hashcat crypto libraries is straightforward. There are however some limitations you need to know about and you need to align with. The functions are designed to make it more easy for you to develop kernels, but they are written with performance in mind. This is achieved by using different optimization techniques. For instance, a crypto library cannot know how much data the user will provide. It therefore has to keep some buffers in the context to maintain some offsets. Each update() typically changes the buffer values and the offset. Typically you would code this by using some pointers. But pointers are poison for high performance. The computation of the address requires at least a temporary register, one or more mul() and another add() instruction call. This can be avoided. To do so, most of the code is using large switch() statements to enable the kernel compiler to translate a lot of code directly to register without the need to use an address to access a certain value in an array. But this goes too deep. Check `OpenCL/inc_common.cl` if you want to know more about the details. + +The most important limits are the following: + +* Functions are not converting data to the native endianness operation mode of whatever crypto primitive you are using. This is different to regular crypto libraries and can create a lot of headache if you are not used to this! You need to convert the data manually (typically just a hc_swap32() or hc_swap64() call). Keep in mind that all compute devices supported by OpenCL which I know of, operate in LE byte order. For instance, MD5 is using LE byte order. This means that you do not need to swap any data. However, SHA1 has a BE byte order and you need to convert the data. This is why it is so important to have a POC to verify intermediate result values. +* The buffer you provide must be padded to a size of a multiple of the block size of whatever crypto primitive you are using. For example 64 byte for MD5, SHA256, etc. and 128 byte for SHA512 and others. If you do not know the block sizes, check the algorithm specs. For instance, if you want to statically append a 5 byte string to a password from inside the kernel, you could use `sha1_update (&ctx, buf, 5);`, the important thing here is that buf[] must be declared as u32 buf[16]. That is because the block size of SHA1 is 64 byte. +* The buffer also needs to be zero padded. If only the first 5 byte of this 64 byte buffer is used, the remaining 59 bytes need to be set to zero. +* This goes back to how hashcat actually appends the data to the buffer in the context. Keep in mind, in OpenCL/CUDA there is no such thing as memcpy(). Of course you could write it yourself, but you will run into the performance problems explained above. Instead we are using switch(), followed by shifting the data to the final offset and then OR the temporary buffer to the existing buffer. This only works if the unused data is set to zero and the buffer has a known size. +* Shifting the buffer data changes the data. While you can reuse the buffer keep in mind you have to re-initialize the data. This is not the case if the buffers are global memory buffers. +* Note that none of the limitations are tested from the hashcat crypto library. You need to be careful or you will run into errors like out of boundary read/writes or have unexpected data. + +Note that the type of buffer which holds the data is relevant, too. There are specific functions for working with local memory arrays and global memory arrays. + +Often there is also a function which does the byte swapping for you. For instance, there is not only sha1_update() but there is also sha1_update_swap(). The prototypes are the same. There is also sha1_update_utf16le() and sha1_update_utf16le_swap(). I am sure you got the idea. If some helper function is missing, feel free to commit it to upstream but in a dedicated PR. + +Since hashcat 6.0.0 it is also possible to use the hashcat crypto library from the host code. This is done by the emulation macros. To use a library, you just need to include `emu_inc_hash_sha1.h` or appropriate. Keep in mind that the limitations are exactly the same as if you use them from inside a kernel. A good example is `src/wordlist.c` or `src/modules/module_12600.c`. + +## About Salts ## + +In hashcat, we have two different types of salt structures. There is a fixed size data type and a generic size data type. This goes back to how hashcat was created and how it evolved over time. However, it turned out the concept still works very good even with the most complex algorithms of today. + +### salt_t ### + +The salt_t is a fixed size data type which is defined in `OpenCL/inc_types.cl` and holds a number of configuration settings and buffers with different meanings. However, they all are using 32 bit integers exclusively. This goes back to the fact that GPU registers are always 32 bit. You can work with 8 bit integers, but will make the GPU slower because it has to emulate an 8 bit register behavior (which is done transparently from your perspective). We however are trying to avoid this by sticking to u32 data type buffers for your entire kernel to achieve best performance. I will now explain the components of the salt_t structure in detail: + +* u32 salt_buf[64]: This is the main buffer to store your salt in. The salt is limited to 64 times 32 bit (which is 4 bytes, 4 * 8 bits) elements, so 256 bytes. You need to guarantee that your salt buffer will never exceed 256 bytes, otherwise you can not store the salt in the salt_t structure. But for most cases, this is enough. If the salt buffer exceeds the 256 byte range, you need to use an esalt structure which is explained later. +* u32 salt_buf_pc[64]: This is an additional buffer to store precomputed values (typically based on the salt buffer). For instance, if you have an algorithm like sha1($p.md5($s)) you do not need to compute the md5($s) part for every try. It is enough to compute it once. The buffer is used to store the result of the md5($s) which you can access from within your kernel. +* u32 salt_len: This is just the length of the data stored in salt_buf[], in bytes. It is important that this value is also used during the salt buffer unique check on hashcat startup. Since the data stored as a salt is in binary, hashcat needs to know the length of this data to compare with other elements in the array. Keep this in mind and make sure to set a useful value, even if you are using a faked salt. +* u32 salt_len_pc: Same as salt_len but for the precomputed buffer. Set to 0 if there is no precomputed buffer, but keep in mind 0 is the default so in most cases you do not touch this. +* u32 salt_iter: This value holds the iteration count of your algorithm. This applies to slow hash kernels only and is used only in the _loop kernel. Note that some KDF (like PBKDF2) count their initialization round (in the _init kernel) as 1, thus you need to subtract 1 from the salt_iter count for this group of algorithms. +* u32 salt_iter2: Same as salt_iter, but for plugins which make use of a secondary loop kernel and which have set the option OPTS_TYPE_LOOP2. +* u32 salt_sign[2]: This option is most commonly used to recreate the original iteration count, salt buffer or even digest buffer set from a hash which is sometimes ambiguous. A good instance is DEScrypt, where there is a 64 bit digest encoded in an 11 byte base64 encoded string which results in 66 bit. Some applications do not zero the last 2 bits before encoding, resulting in multiple digest values for the same password. Since we need to store the real hash in our digest buffers we also need to save the remaining 2 bit in case the hash ever gets cracked and when we need to print the original hash to the console or output file. +* u32 digests_cnt: This value holds the number of digests which belong to this particular salt. After hashcat finishes decoding all the hashes from your hash file, it starts sorting and removing duplicates. At this time, it will also find possible multiple digest values which belong to the same salt. This allows hashcat to optimize the attack. This option is maintained by hashcat, do not modify it. +* u32 digests_done: This value holds the number of cracked digests which belong to a particular salt. If this number equals the number stored in digests_cnt, then hashcat knows it can remove this salt element for all upcoming kernel invocations. This speeds up the cracking process while hashcat is running. This option is maintained by hashcat, do not modify it. +* u32 digests_offset: This value keeps track of the information at which point in the digest buffer the sorted section of all the digests belonging to this particular salt starts. Since all digests, no matter which salt they belong to, are stored in one big array of u32 values we need to keep track of the starting point per unique salt. This value is important in the binary search which runs on the kernel. This option is maintained by hashcat, do not modify it. +* u32 scrypt_N: Some leftover for scrypt based algorithms from a time when there was no esalt. This option is maintained by hashcat, do not modify it. +* u32 scrypt_r: See scrypt_N. +* u32 scrypt_p: See scrypt_N. + +### esalt ### + +Of course there are also generic buffers in case the data of your hash mode simply covers additional data like encrypted data, IV, etc. or simply salt buffers which are too long to fit into the standardized salt_t structure. To define your own struct, you need to define it in the module as well as in the kernel. Since both source codes are independent from each other, you need to maintain them and guarantee that they are synchronized. The esalt buffers and structs in the corresponding `src/modules/` and `OpenCL/` plugin files need to be the same and any change in one of these esalt structs in one of these source files would need to be accompanied by a change of the other file too. Other than that, it is a simple process. As described in the decoder section, hashcat needs to know the size of the structure so it can allocate enough memory space for it at the initialization phase. In order to inform the hashcat host binary of the esalt size, you must provide it via the function module_esalt_size(). It could be either a maximum size (upper limit) or a constant size. This depends on the algorithm. +That is all. You can now cast the void *esalt_buf which is provided to you in the decoder and encoder functions to your esalt structure type. Note this address is maintained by hashcat. It guarantees a fresh buffer for each invocation of module_hash_decode(). Therefore, you can simply cast it for instance like this: + +``` +wpa_eapol_t *wpa_eapol = (wpa_eapol_t *) esalt_buf; +``` + +You can access the esalt from the encoder function and read the data the exact same way by casting it to your esalt struct. + +Important: No matter if you are going to use an esalt or not, you always need to fill the salt_buf[] array and set the salt_len for it. + +Important: In case you write a slow hash, you need to set the salt_iter element. Also never forget to implement module_esalt_size() if you use an esalt. + +## Data Structures: salt_t vs esalt ## + +Hashcat has a generic data structure to handle "easy" salts (salt_t) and an open data structure one, that you can define yourself in case the generic data structure does not fit your needs (esalt). An "easy" salt is a single buffer salt of less than 256 byte (can be binary). The open data structure is called "esalt". + +It is important to understand the difference between the generic salt_t struct and the esalt struct (which you create on your own). In fact it is essential to distinguish them. Based on the data we assign to the salt_t struct, hashcat sorts and groups all digests belonging to this particular salt_t first by the salt buffer content in salt->salt_buf[]. We can see it as a top level grouping. With the data we assign to the esalt, hashcat sorts and groups all hashes, but on a level below. Like in a SQL Statement when we do something like: + +`SELECT digest FROM hashes GROUP BY salt_t,esalt` + +But why is that? It is an optimization. If we have different data stored in salt_t and esalt, hashcat expects us to access salt_t data in the _init kernel and expects us to access the data of our esalt only from the _comp kernel. But that is an optional step and probably something of which you did not think of if you never wrote a hashcat plugin before. + +A good example is the WPA mode. The crypto scheme in this mode requires multiple salt fields (IVs, mac addresses, encrypted data, etc). To derive the PMK master key (the slow part in the algorithms), only the ESSID (the network name) is required. If we want to crack WPA, typically we capture multiple handshakes, however all handshakes could be belonging to the same network. If we are clever we can exploit this weakness. In the parser we would set only the ESSID in the salt_t struct and all other data (IV, MAC addresses, etc.) go into the esalt. By doing so, hashcat will only spawn that many _init and _loop kernels as there are unique ESSIDs in the generic salt_t buffers. If we have captured 100 handshakes of the same network, hashcat only needs to run the compute intensive _loop kernel one time, not 100 times. But how to use the _comp kernel in this case? + +Now let us talk about the three different types of _comp kernels. The first type is if we have an easy crypto algorithm which only contains a single salt buffer in the salt_t struct. Imagine we have ten real hashes but they all share the same salt. In such a case there is still no need to run the _init and the slow _loop kernel ten times. A single invocation of both is enough. In the _comp kernel hashcat will search a database if the digest exists in a database which is important. We only need to search this database for the existence of the hash, we do not need to decrypt something. This database is created automatically by hashcat at the very start. Every digest which we assign to the digest_t struct will be sorted and stored inside this database. Inside the _comp kernel, if we assign the final digest to r0 - r4 and call the #include COMPARE_M macro, the database gets searched. This code is highly optimized and is using a bloom filter and an additional binary tree search. So it can handle millions of hashes very efficiently. See `OpenCL/m00500-pure.cl` as an easy example. + +Sometimes this is not enough. For instance, if we do not have a final digest which we could search for "existence" in the database. This happens if we have to decrypt some data and match the content of the decrypted data against some known pattern. It is obvious if we match data in this case we can not search the data for existence, right? In this case we actually need to iterate through all entries in the database. This is something very irregular from the general hashcat concept but there is a way to deal with it. Of course, if you only support single targets this is not a problem. The recommended way to deal with this is to verify if the salt_buf data you are using is unique. The goal is to force hashcat to call the _comp kernel as many times as it loads unique hashes from your hash list and iterates through all of them individually. If we choose to use this mode, it is essential for the salt_t buffer to be exactly as unique as the esalt buffer (the same number of entries). This could be achieved by using parts of encrypted data and copying it to salt->salt_buf[]. Hashcat will be forced to increment the `digests_offset` variable for each iteration which gives you the opportunity to index the different hashes individually. A good example for such a _comp kernel can be found in `OpenCL/m14700-pure.cl`. + +There is even a third mode which is close to the second mode, but does not have the disadvantage of syncing the salt_t with the esalt, giving you the opportunity to exploit salt specific vulnerabilities in the algorithm (like in WPA). This mode can be activated by setting OPTS_TYPE_DEEP_COMP_KERNEL flag in the module. In this case hashcat will know that it has to call the _comp kernel for that many entries that are bound to a unique salt_t entry. So far there are only two algorithms which make use of that. This mode should therefore only be used in very rare cases and is discouraged if not applicable. See `OpenCL/m22000-pure.cl` as an example. + +Most kernels today go for the second mode. However, if possible we should use the first mode because it is much more elegant. There is a trick to step down from the second mode to the first mode. In case we need to match some data after decryption but we know 100% of the data it is better to encrypt the known plaintext data instead of decrypting the encrypted data. In this case our final value can be searched in a database for "existence" and we can operate in first mode (i.e. make a "lookup"). + +## Tokenizer ## + +The tokenizer is basically a CSV parser but with some special features. When it comes to loading hash files it is sometimes not so easy. The hash files often have been generated by extraction tools which do not follow CSV rules very carefully. Often the CSV is broken because of missing escape characters, quotation or other problems. Additionally, the tokenizer covers a preliminary data sanitization and data length check. + +Of course we could have used a regular expression engine to do the same. But if you think of the potential multi million hash entries in hash files the tokenizer is much faster than a regular expression. Also the tokenizer offers configuration items that are known to be relevant when it comes to parsing hashes. The configuration of the tokenizer is very easy to read for third parties and gives an easy overview of how the hash lines are separated from a standardized perspective. + +One very unique feature is that the tokenizer allows you to have both dynamic length columns and fixed length columns in the same hash line. This is sometimes the only way to read a hash line. Another unique feature is that it allows you to change the separator character for different columns in the same hash line. This is why you have to specify the separator character for each column separately. + +The first step after declaring the tokenizer context buffer is to create its configuration. There is just one mandatory parameter and a maximum of 128 optional configuration items (columns). The mandatory configuration item needs to be set to the number of columns/fields which the hash line includes. Note that this is a fixed value. For more complex hash lines with a dynamic column count you need to create multiple tokenizer instances (e.g. use a second configuration, if the first one failed), but in most of the times this is not required. + +``` +token_t token; + +token.token_cnt = 1; +``` + +For a very simple, unsalted hash there is just one column: the hash. If this is a MD5 hash, it is typically encoded as a hex string of exact size 32 byte. These properties we can configure for the first column: + +``` +token.len_min[0] = 32; +token.len_max[0] = 32; +token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; +``` + +The parameters len_min and len_max always define a valid range in bytes. Since it is always 32 byte, we simply set 32 to both parameters. With the configuration item `TOKEN_ATTR_VERIFY_LENGTH` we inform the tokenizer to verify the data length. If the length does not match, we will refuse the hash. The same goes for the configuration item `TOKEN_ATTR_VERIFY_HEX`. As you can imagine, this informs the tokenizer to verify if the data contains only hex characters (no matter the case). For more verification configuration items please see `includes/types.h`. + +Finally the tokenizer is called. If any of the verification configuration items do not pass, the tokenizer will return a specific error code. As always, the error codes can be found in `includes/types.h`. + +``` +const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + +if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); +``` + +If everything went well up to this point, the tokenizer has placed the pointer addresses for the start to each of the columns in the token.buf[] array and the corresponding length in the token.len[] array. For instance, if there is only one column, the pointer address in token.buf[0] will be populated as well as token.len[0]. If you have two columns (token_cnt = 2), there will also be token.buf[1] and token.len[1], and so on. + +As always, you can use the tokenizer configurations in the existing modules as a reference, especially for complex hash lines. + +For hash lines with multiple columns, we need to use for each column either TOKEN_ATTR_FIXED_LENGTH (see below) or configure the separator character. The separator has to be a single byte character and is set using the "sep" parameter. + +``` +token.sep[0] = ':'; +token.len_min[0] = 32; +token.len_max[0] = 32; +token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + +token.len_min[1] = 0; +token.len_max[1] = 32; +token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; +``` + +In the above example you can see that we have hard-coded the separator character to ':'. In addition, this type of configuration the tokenizer will refuse the hash line if the separator was not found. You can also use the hashconfig->separator character if you want to use the separator character the hashcat user set using the -p command line option (default being ':'). + +There is one more configuration item which I want to describe: + +* TOKEN_ATTR_FIXED_LENGTH: This is for columns of which you know the exact length -and- which are not followed by a separator character. In this case you do not need to set the parameters "len_min" and "len_max", but you need to set the parameter "len" instead. This is a typical pitfall if you copy/paste configuration settings from other modules and switch from a dynamic length to a fixed length. Do not forget to also change the parameter name ("len_min"/"len_max" instead of just "len") and the indices. + diff --git a/docs/license.txt b/docs/license.txt index f000a072c..48d77100c 100644 --- a/docs/license.txt +++ b/docs/license.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2019 Jens Steube +Copyright (c) 2015-2020 Jens Steube Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/limits.txt b/docs/limits.txt index 884a781be..0ee928080 100644 --- a/docs/limits.txt +++ b/docs/limits.txt @@ -22,6 +22,17 @@ Important: That does not mean UTF-16 file content, which is fully supported. It only means the filename itself. +## +## Hashing algorithms that internally use UTF-16 characters could in special cases lead to false negatives +## + +The UTF-16 conversion implementation used within the kernel code is very elementary and for performance +reasons does not respect all complicated encoding rules required to correctly convert, for instance, ASCII +or UTF-8 to UTF-16LE (or UTF-16BE). + +The implementation most likely fails with multi-byte characters, because we basically add a zero byte every +second byte within the kernel conversion code. + ## ## The use of --keep-guessing eventually skips reporting duplicate passwords ## diff --git a/docs/readme.txt b/docs/readme.txt index dc1da35d9..372197e3d 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -15,7 +15,7 @@ AMD GPUs on Windows require "AMD Radeon Software Crimson Edition" (15.12 or late Intel CPUs require "OpenCL Runtime for Intel Core and Intel Xeon Processors" (16.1.1 or later) Intel GPUs on Linux require "OpenCL 2.0 GPU Driver Package for Linux" (2.0 or later) Intel GPUs on Windows require "OpenCL Driver for Intel Iris and Intel HD Graphics" -NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 or later) +NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (9.0 or later) ## ## Features @@ -41,7 +41,7 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - Supports automatic keyspace ordering markov-chains - Built-in benchmarking system - Integrated thermal watchdog -- 200+ Hash-types implemented with performance in mind +- 300+ Hash-types implemented with performance in mind ## ## Hash-Types @@ -69,7 +69,6 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - Keccak-256 - Keccak-384 - Keccak-512 -- sha256(sha256_bin(pass)) - Whirlpool - SipHash - BitShares v0.x - sha512(sha512_bin(pass)) @@ -103,9 +102,11 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - sha1(utf16le($pass).$salt) - sha256($pass.$salt) - sha256($salt.$pass) +- sha256($salt.$pass.$salt) - sha256($salt.utf16le($pass)) - sha256(md5($pass)) - sha256(sha256($pass).$salt) +- sha256(sha256_bin($pass)) - sha256(utf16le($pass).$salt) - sha512($pass.$salt) - sha512($salt.$pass) @@ -144,10 +145,8 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - SIP digest authentication (MD5) - IKE-PSK MD5 - IKE-PSK SHA1 -- WPA-EAPOL-PBKDF2 -- WPA-EAPOL-PMK -- WPA-PMKID-PBKDF2 -- WPA-PMKID-PMK +- WPA-PBKDF2-PMKID+EAPOL +- WPA-PMK-PMKID+EAPOL - IPMI2 RAKP HMAC-SHA1 - CRAM-MD5 - iSCSI CHAP authentication, MD5(CHAP) @@ -162,6 +161,7 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - NetNTLMv1 / NetNTLMv1+ESS - NetNTLMv2 - Skype +- Telegram client app passcode (SHA256) - PostgreSQL CRAM (MD5) - MySQL CRAM (SHA1) - RACF @@ -195,7 +195,8 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - Cisco-IOS $9$ (scrypt) - Cisco-IOS type 4 (SHA256) - Cisco-PIX MD5 -- Citrix NetScaler +- Citrix NetScaler (SHA1) +- Citrix NetScaler (SHA512) - Domain Cached Credentials (DCC), MS Cache - Domain Cached Credentials 2 (DCC2), MS Cache 2 - FortiGate (FortiOS) @@ -212,12 +213,14 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - Oracle T: Type (Oracle 12+) - MySQL323 - MySQL4.1/MySQL5 +- MySQL $A$ (sha256crypt) - Sybase ASE - hMailServer - DNSSEC (NSEC3) - CRAM-MD5 Dovecot - SSHA-256(Base64), LDAP {SSHA256} - SSHA-512(Base64), LDAP {SSHA512} +- RedHat 389-DS LDAP (PBKDF2-HMAC-SHA256) - FileZilla Server >= 0.9.55 - ColdFusion 10+ - Apache $apr1$ MD5, md5apr1, MD5 (APR) @@ -239,6 +242,8 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - Oracle Transportation Management (SHA256) - Huawei sha1(md5($pass).$salt) - AuthMe sha256 +- AES Crypt (SHA256) +- BitLocker - eCryptfs - LUKS - VeraCrypt @@ -274,13 +279,14 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - LastPass + LastPass sniffed - KeePass 1 (AES/Twofish) and KeePass 2 (AES) - Bitcoin/Litecoin wallet.dat -- Electrum Wallet (Salt-Type 1-3) +- Electrum Wallet (Salt-Type 1-5) - Blockchain, My Wallet - Blockchain, My Wallet, V2 - Blockchain, My Wallet, Second Password (SHA256) - Ethereum Pre-Sale Wallet, PBKDF2-HMAC-SHA256 - Ethereum Wallet, PBKDF2-HMAC-SHA256 - Ethereum Wallet, SCRYPT +- MultiBit Classic .key (MD5) - 7-Zip - RAR3-hp - RAR5 @@ -304,8 +310,6 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - SMF (Simple Machines Forum) > v1.1 - MediaWiki B type - Redmine -- Django (PBKDF2-SHA256) -- Django (SHA-1) - Joomla < 2.5.18 - OpenCart - PrestaShop @@ -314,6 +318,9 @@ NVIDIA GPUs require "NVIDIA Driver" (418.56 or later) and "CUDA Toolkit" (10.1 o - osCommerce, xt:Commerce - PunBB - MyBB 1.2+, IPB2+ (Invision Power Board) +- Django (PBKDF2-SHA256) +- Django (SHA-1) +- Web2py pbkdf2-sha512 - TOTP (HMAC-SHA1) ## diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index f17019a19..62d51e518 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -17,10 +17,10 @@ _hashcat_backend_devices () if [ ! -x "${executable}" ]; then executable="${HASHCAT_ROOT}"/hashcat.bin fi - + if [ ! -x "${executable}" ]; then local which_hashcat=$(which hashcat 2>/dev/null) - + if [ -n "${which_hashcat}" ]; then executable="${which_hashcat}" fi @@ -37,8 +37,7 @@ _hashcat_backend_devices () # sanity check, all device ids must be numerical if [ -n "${cur_selection}" ]; then - if echo "${cur_selection}" | sed 's/,/\n/g' | grep -q -v '^[0-9]\+$' - then + if echo "${cur_selection}" | sed 's/,/\n/g' | grep -q -v '^[0-9]\+$'; then return fi fi @@ -155,6 +154,7 @@ _hashcat_backend_devices () _hashcat_cpu_devices () { local cur_selection="${1}" + hashcat_device_list="" if [ ! -f "/proc/cpuinfo" ]; then @@ -172,8 +172,7 @@ _hashcat_cpu_devices () # sanity check, all device ids must be numerical if [ -n "${cur_selection}" ]; then - if echo "${cur_selection}" | sed 's/,/\n/g' | grep -q -v '^[0-9]\+$' - then + if echo "${cur_selection}" | sed 's/,/\n/g' | grep -q -v '^[0-9]\+$'; then return fi fi @@ -217,14 +216,191 @@ _hashcat_cpu_devices () done } +_hashcat_files_replace_home () +{ + local cur_select="${1}" + local cur_files="${2}" + + hashcat_select="${cur_select}" + hashcat_file_list="${cur_files}" + + if echo ${cur_select} | grep -q "^~/"; then + home_dir="${HOME}" + + if [ -n "${home_dir}" ]; then + hashcat_file_list=$(echo -n "${cur_files}" | sed "s!^${home_dir}!~\\\\!") + hashcat_select=$(echo -n "${cur_select}" | sed "s!^~/!~\\\\/!") + fi + fi +} + +_hashcat_recursive_file_search () +{ + local allow_dir="${1}" + local is_include="${2}" + local file_list="${3}" + local cur_filter="${4}" + + local grep_flags="-Ei" + + if [ "${is_include}" -eq 0 ]; then + grep_flags="-Eiv" + fi + + hashcat_file_list="" + + local dir_loop="" + + for dir_loop in "${file_list}"; do + if [ -d "${dir_loop}" ]; then + # check subdirs: + + local subdir="${dir_loop}" + local loop_cnt=0 + + for loop_cnt in $(seq 1 35); do # maximum number of recursive (subdir) tests + local subdir_files=$(bash -c "ls -d ${subdir}/*" 2> /dev/null | grep ${grep_flags} '*\.('${cur_filter}')' 2> /dev/null) + + if [ "${allow_dir}" -eq 1 ]; then + if [ -n "${hashcat_file_list}" ]; then + hashcat_file_list="${hashcat_file_list} " + fi + + hashcat_file_list="${hashcat_file_list}${subdir}" + fi + + if [ -z "${subdir_files}" ]; then + break + fi + + local subdir_file="" + + for subdir_file in "${subdir_files}"; do + if [ "${allow_dir}" -eq 1 ]; then + if [ -n "${hashcat_file_list}" ]; then + hashcat_file_list="${hashcat_file_list} " + fi + + hashcat_file_list="${hashcat_file_list}${subdir_file}" + else + if [ ! -d "${subdir_file}" ]; then + if [ -n "${hashcat_file_list}" ]; then + hashcat_file_list="${hashcat_file_list} " + fi + + hashcat_file_list="${hashcat_file_list}${subdir_file}" + fi + fi + done + + local amount=$(echo "${subdir_files}" | wc -l) + + if [ "${amount}" -gt 1 ]; then + break + fi + + subdir="${subdir_files}" + done + else + if [ -n "${hashcat_file_list}" ]; then + hashcat_file_list="${hashcat_file_list} " + fi + + hashcat_file_list="${hashcat_file_list}${dir_loop}" + fi + done +} + +_hashcat_include () +{ + local allow_dir="${1}" + local cur_select="${2}" + local cur_filter="${3}" + + # allow starting/ending quotes (" and '): + + cur_select=$(echo -n "${cur_select}" | sed 's/^["'"'"']//' | sed 's/["'"'"']\$//') + + local file_list=$(bash -c "ls -d ${cur_select}*" 2> /dev/null | grep -Ei "${cur_filter}" 2> /dev/null) + + _hashcat_recursive_file_search "${allow_dir}" 1 "${file_list}" "${cur_filter}" + + if [ "${allow_dir}" -eq 1 ]; then + if [ -d "${cur_select}" ]; then + if [ -n "${hashcat_file_list}" ]; then + hashcat_file_list="${hashcat_file_list} " + fi + + hashcat_file_list="${hashcat_file_list}${cur_select}" + fi + fi + + # handle special case for $HOME directory (~/) + + _hashcat_files_replace_home "${cur_select}" "${hashcat_file_list}" + + # (hashcat_select and hashcat_file_list are modified and "returned") +} + +_hashcat_files_include () +{ + _hashcat_include 0 "${1}" "${2}" +} + +_hashcat_files_folders_include () +{ + _hashcat_include 1 "${1}" "${2}" +} + +_hashcat_exclude () +{ + local allow_dir="${1}" + local cur_select="${2}" + local cur_filter="${3}" + + # allow starting/ending quotes (" and '): + + cur_select=$(echo -n "${cur_select}" | sed 's/^["'"'"']//' | sed 's/["'"'"']\$//') + + local file_list=$(bash -c "ls -d ${cur_select}*" 2> /dev/null | grep -Eiv '*\.('${cur_filter}')' 2> /dev/null) + + _hashcat_recursive_file_search "${allow_dir}" 0 "${file_list}" "${cur_filter}" + + if [ "${allow_dir}" -eq 1 ]; then + if [ -d "${cur_select}" ]; then + if [ -n "${hashcat_file_list}" ]; then + hashcat_file_list="${hashcat_file_list} " + fi + + hashcat_file_list="${hashcat_file_list}${cur_select}" + fi + fi + + # handle special case for $HOME directory (~/) + + _hashcat_files_replace_home "${cur_select}" "${hashcat_file_list}" + + # (hashcat_select and hashcat_file_list are modified and "returned") +} + +_hashcat_files_exclude () +{ + _hashcat_exclude 0 "${1}" "${2}" +} + +_hashcat_files_folders_exclude () +{ + _hashcat_exclude 1 "${1}" "${2}" +} + _hashcat_contains () { local haystack=${1} local needle="${2}" - if echo "${haystack}" | grep -q " ${needle} " 2> /dev/null; then + if echo "${haystack}" | grep -q " ${needle} " 2> /dev/null; then return 0 - elif echo "${haystack}" | grep -q "^${needle} " 2> /dev/null; then + elif echo "${haystack}" | grep -q "^${needle} " 2> /dev/null; then return 0 elif echo "${haystack}" | grep -q " ${needle}\$" 2> /dev/null; then return 0 @@ -239,19 +415,19 @@ _hashcat () local ATTACK_MODES="0 1 3 6 7" local HCCAPX_MESSAGE_PAIRS="0 1 2 3 4 5" - local OUTFILE_FORMATS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" + local OUTFILE_FORMATS="1 2 3 4 5 6" local OPENCL_DEVICE_TYPES="1 2 3" local BACKEND_VECTOR_WIDTH="1 2 4 8 16" local DEBUG_MODE="1 2 3 4" local WORKLOAD_PROFILE="1 2 3 4" local BRAIN_CLIENT_FEATURES="1 2 3" local HIDDEN_FILES="exe|bin|potfile|hcstat2|dictstat2|sh|cmd|bat|restore" - local HIDDEN_FILES_AGGRESIVE="${HIDDEN_FILES}|hcmask|hcchr" + local HIDDEN_FILES_AGGRESSIVE="${HIDDEN_FILES}|hcmask|hcchr" local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' local SHORT_OPTS="-m -a -V -h -b -t -T -o -p -c -d -D -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" - local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --backend-ignore-cuda --backend-ignore-opencl --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" + local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-server-timer --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist" COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" @@ -285,7 +461,29 @@ _hashcat () ;; --outfile-format) - COMPREPLY=($(compgen -W "${OUTFILE_FORMATS}" -- ${cur})) + local outfile_format_list="" + + local filter_list=$(echo -n "${OUTFILE_FORMATS}" | sed 's/ //g') + + if echo "${cur}" | grep -q "^[,${filter_list}]*$"; then + outfile_format_list="${cur}" + + # remove formats already used in the command line: + local formats_used=$(echo -n "${cur}" | sed 's/,/\n/g') + local allowed_formats=$(echo -n "${OUTFILE_FORMATS}" | sed 's/ /\n/g') + + local i + for i in $formats_used; do + allowed_formats=$(echo -n "${allowed_formats}" | grep -v "${formats_used}") + done + + outfile_format_list="${cur}" + for i in $allowed_formats; do + outfile_format_list="${outfile_format_list} ${cur},${i}" + done + fi + + COMPREPLY=($(compgen -W "${outfile_format_list}" -- ${cur})) return 0 ;; @@ -300,14 +498,14 @@ _hashcat () ;; -o|--outfile|-r|--rules-file|--debug-file|--potfile-path| --restore-file-path) - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur}) + _hashcat_files_exclude "${cur}" "${HIDDEN_FILES_AGGRESSIVE}" + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESSIVE}')' -- ${cur}) return 0 ;; --markov-hcstat2) - local files=$(ls -d ${cur}* 2> /dev/null | grep '.*\.hcstat2$' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur}) + _hashcat_files_include "${cur}" '.*\.hcstat2$' + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) return 0 ;; @@ -336,8 +534,8 @@ _hashcat () ;; --keyboard-layout-mapping) - local files=$(ls -d ${cur}* 2> /dev/null | grep '.*\.hckmap$' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur}) + _hashcat_files_include "${cur}" '.*\.hckmap$' + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) return 0 ;; @@ -345,17 +543,14 @@ _hashcat () local mask=${BUILD_IN_CHARSETS} if [ -e "${cur}" ]; then # should be hcchr file (but not enforced) - COMPREPLY=($(compgen -W "${cur}" -- ${cur})) return 0 - fi if [ -n "${cur}" ]; then local cur_var=$(echo "${cur}" | sed 's/\?$//') - mask="${mask} ${cur_var}" local h for h in ${mask}; do @@ -378,17 +573,18 @@ _hashcat () fi mask="${mask} ${cur_var}${h}" - fi done + + mask="${mask} ${cur_var}" fi - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null) + _hashcat_files_exclude "${cur}" "${HIDDEN_FILES}" - mask="${mask} ${files}" + mask="${mask} ${hashcat_file_list}" - COMPREPLY=($(compgen -W "${mask}" -- ${cur})) + COMPREPLY=($(compgen -W "${mask}" -- ${hashcat_select})) return 0 ;; @@ -446,16 +642,26 @@ _hashcat () local cur_part0=$(echo "${cur}" | grep -Eo '^("|'"'"')') - local cur_mod=$(echo "${cur}" | sed 's/^["'"'"']//') - local cur_part1=$(echo "${cur_mod}" | grep ',' 2> /dev/null | sed 's/^\(.*, *\)[^,]*$/\1/') - local cur_part2=$(echo "${cur_mod}" | sed 's/^.*, *\([^,]*\)$/\1/') + local cur_sel=$(echo "${cur}" | sed 's/["'"'"']//g') + + local cur_part1=$(echo "${cur_sel}" | grep ',' 2> /dev/null | sed 's/^\(.*, *\)[^,]*$/\1/') + local cur_part2=$(echo "${cur_sel}" | sed 's/^.*, *\([^,]*\)$/\1/') + + _hashcat_files_exclude "${cur_part2}" "${HIDDEN_FILES_AGGRESSIVE}" + # generate lines with the file name and a duplicate of it with a comma at the end - local files=$(ls -d ${cur_part2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null | sed 's/^\(.*\)$/\1\n\1,\n/' | sed "s/^/${cur_part0}${cur_part1}/" | sed "s/$/${cur_part0}/") - COMPREPLY=($(compgen -W "${files}" -- ${cur})) - return 0 + hashcat_file_list=$(echo "${hashcat_file_list}" | \ + sed "s/^/${cur_part1}/" | \ + sed "s/^/${cur_part0}/" | \ + sed 's/^\(.*\)$/\1\n\1,\n/' | \ + sed 's/,\+$/,/g' | \ + sed 's/^\(.*\)$/\1\n\1"/' | \ + sed 's/,\+"$/"/') + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${cur_sel})) + return 0 esac # allow also the VARIANTS w/o spaces @@ -476,14 +682,14 @@ _hashcat () ;; -o*) - local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) + local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESSIVE}')' 2> /dev/null) outfile_var="$(echo -e "\n${outfile_var}" | sed 's/^/-o/')" COMPREPLY=($(compgen -W "${outfile_var}" -- ${cur})) return 0 ;; -r*) - local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) + local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESSIVE}')' 2> /dev/null) outfile_var="$(echo -e "\n${outfile_var}" | sed 's/^/-r/')" COMPREPLY=($(compgen -W "${outfile_var}" -- ${cur})) return 0 @@ -607,8 +813,8 @@ _hashcat () ;; 1) - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) + _hashcat_files_exclude "${cur}" "${HIDDEN_FILES_AGGRESSIVE}" + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) return 0 ;; @@ -617,8 +823,8 @@ _hashcat () 0) # dict/directory are files here - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) + _hashcat_files_folders_exclude "${cur}" "${HIDDEN_FILES_AGGRESSIVE}" + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) return 0 ;; @@ -627,8 +833,8 @@ _hashcat () return 0 fi - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) + _hashcat_files_folders_exclude "${cur}" "${HIDDEN_FILES_AGGRESSIVE}" + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) return 0 ;; @@ -637,27 +843,19 @@ _hashcat () local mask=${BUILD_IN_CHARSETS} if [ "${has_charset_1}" -eq 1 ]; then - mask="${mask} ?1" - fi if [ "${has_charset_2}" -eq 1 ]; then - mask="${mask} ?2" - fi if [ "${has_charset_3}" -eq 1 ]; then - mask="${mask} ?3" - fi if [ "${has_charset_4}" -eq 1 ]; then - mask="${mask} ?4" - fi if [ -e "${cur}" ]; then # should be hcmask file (but not enforced) @@ -671,21 +869,20 @@ _hashcat () local cur_var=$(echo "${cur}" | sed 's/\?$//') - mask="${mask} ${cur_var}" - local h for h in ${mask}; do - - mask="${mask} ${cur_var}${h}" - + mask="${mask} ${cur_var}${h}" done + + mask="${mask} ${cur_var}" fi - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null) + _hashcat_files_exclude "${cur}" "${HIDDEN_FILES}" - mask="${mask} ${files}" + mask="${mask} ${hashcat_file_list}" + + COMPREPLY=($(compgen -W "${mask}" -- ${hashcat_select})) - COMPREPLY=($(compgen -W "${mask}" -- ${cur})) return 0 fi ;; @@ -693,34 +890,26 @@ _hashcat () 6) if [ "${no_opts}" -eq 2 ]; then - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) + _hashcat_files_folders_exclude "${cur}" "${HIDDEN_FILES_AGGRESSIVE}" + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) elif [ "${no_opts}" -eq 3 ]; then local mask=${BUILD_IN_CHARSETS} if [ "${has_charset_1}" -eq 1 ]; then - mask="${mask} ?1" - fi if [ "${has_charset_2}" -eq 1 ]; then - mask="${mask} ?2" - fi if [ "${has_charset_3}" -eq 1 ]; then - mask="${mask} ?3" - fi if [ "${has_charset_4}" -eq 1 ]; then - mask="${mask} ?4" - fi if [ -e "${cur}" ]; then # should be hcmask file (but not enforced) @@ -734,21 +923,19 @@ _hashcat () local cur_var=$(echo "${cur}" | sed 's/\?$//') - mask="${mask} ${cur_var}" - local h for h in ${mask}; do - - mask="${mask} ${cur_var}${h}" - + mask="${mask} ${cur_var}${h}" done + + mask="${mask} ${cur_var}" fi - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null) + _hashcat_files_folders_exclude "${cur}" "${HIDDEN_FILES}" - mask="${mask} ${files}" + mask="${mask} ${hashcat_file_list}" - COMPREPLY=($(compgen -W "${mask}" -- ${cur})) + COMPREPLY=($(compgen -W "${mask}" -- ${hashcat_select})) return 0 fi @@ -759,27 +946,19 @@ _hashcat () local mask=${BUILD_IN_CHARSETS} if [ "${has_charset_1}" -eq 1 ]; then - mask="${mask} ?1" - fi if [ "${has_charset_2}" -eq 1 ]; then - mask="${mask} ?2" - fi if [ "${has_charset_3}" -eq 1 ]; then - mask="${mask} ?3" - fi if [ "${has_charset_4}" -eq 1 ]; then - mask="${mask} ?4" - fi if [ -e "${cur}" ]; then # should be hcmask file (but not enforced) @@ -793,28 +972,26 @@ _hashcat () local cur_var=$(echo "${cur}" | sed 's/\?$//') - mask="${mask} ${cur_var}" - local h for h in ${mask}; do - - mask="${mask} ${cur_var}${h}" - + mask="${mask} ${cur_var}${h}" done + + mask="${mask} ${cur_var}" fi - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null) + _hashcat_files_folders_exclude "${cur}" "${HIDDEN_FILES}" - mask="${mask} ${files}" + mask="${mask} ${hashcat_file_list}" - COMPREPLY=($(compgen -W "${mask}" -- ${cur})) + COMPREPLY=($(compgen -W "${mask}" -- ${hashcat_select})) return 0 elif [ "${no_opts}" -eq 3 ]; then - local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null) - COMPREPLY=($(compgen -W "${files}" -- ${cur})) - return + _hashcat_files_folders_exclude "${cur}" "${HIDDEN_FILES_AGGRESSIVE}" + COMPREPLY=($(compgen -W "${hashcat_file_list}" -- ${hashcat_select})) + return 0 fi ;; @@ -824,4 +1001,4 @@ _hashcat () esac } -complete -F _hashcat -o filenames "${HASHCAT_ROOT}"/hashcat.bin "${HASHCAT_ROOT}"/hashcat hashcat +complete -F _hashcat "${HASHCAT_ROOT}"/hashcat.bin "${HASHCAT_ROOT}"/hashcat hashcat diff --git a/hashcat.hctune b/hashcat.hctune index 113be9635..49d767bec 100644 --- a/hashcat.hctune +++ b/hashcat.hctune @@ -272,9 +272,13 @@ GeForce_RTX_2080_Ti ALIAS_nv_sm50_or_higher ## ENTRIES ## ############# -DEVICE_TYPE_CPU * * N A A DEVICE_TYPE_CPU * 6100 1 A A -DEVICE_TYPE_CPU * 6900 1 A A +DEVICE_TYPE_CPU * 6231 1 A A +DEVICE_TYPE_CPU * 6232 1 A A +DEVICE_TYPE_CPU * 6233 1 A A +DEVICE_TYPE_CPU * 13731 1 A A +DEVICE_TYPE_CPU * 13732 1 A A +DEVICE_TYPE_CPU * 13733 1 A A #Device Attack Hash Vector Kernel Kernel #Name Mode Type Width Accel Loops @@ -355,21 +359,9 @@ GeForce_GTX_TITAN 3 2410 2 A GeForce_GTX_TITAN 3 5500 1 A A GeForce_GTX_TITAN 3 9900 2 A A -####################### -## EXTREME SLOW ALGOS # -####################### - -#DEVICE_TYPE_GPU * 14600 1 2 M -#DEVICE_TYPE_GPU * 14800 1 2 250 - ########### ## SCRYPT # ########### -DEVICE_TYPE_CPU * 8900 1 16 1 -DEVICE_TYPE_CPU * 9300 1 16 1 DEVICE_TYPE_CPU * 15700 1 1 1 - -DEVICE_TYPE_GPU * 8900 1 16 1 -DEVICE_TYPE_GPU * 9300 1 16 1 DEVICE_TYPE_GPU * 15700 1 1 1 diff --git a/include/backend.h b/include/backend.h index 4d24cf4c0..920f015cf 100644 --- a/include/backend.h +++ b/include/backend.h @@ -68,13 +68,16 @@ int hc_cuMemcpyHtoD (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dstDev int hc_cuMemFree (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dptr); int hc_cuModuleGetFunction (hashcat_ctx_t *hashcat_ctx, CUfunction *hfunc, CUmodule hmod, const char *name); int hc_cuModuleLoadDataEx (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image, unsigned int numOptions, CUjit_option *options, void **optionValues); -int hc_cuModuleLoadDataExLog (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image); int hc_cuModuleUnload (hashcat_ctx_t *hashcat_ctx, CUmodule hmod); int hc_cuStreamCreate (hashcat_ctx_t *hashcat_ctx, CUstream *phStream, unsigned int Flags); int hc_cuStreamDestroy (hashcat_ctx_t *hashcat_ctx, CUstream hStream); int hc_cuStreamSynchronize (hashcat_ctx_t *hashcat_ctx, CUstream hStream); int hc_cuCtxPushCurrent (hashcat_ctx_t *hashcat_ctx, CUcontext ctx); int hc_cuCtxPopCurrent (hashcat_ctx_t *hashcat_ctx, CUcontext *pctx); +int hc_cuLinkCreate (hashcat_ctx_t *hashcat_ctx, unsigned int numOptions, CUjit_option *options, void **optionValues, CUlinkState *stateOut); +int hc_cuLinkAddData (hashcat_ctx_t *hashcat_ctx, CUlinkState state, CUjitInputType type, void *data, size_t size, const char *name, unsigned int numOptions, CUjit_option *options, void **optionValues); +int hc_cuLinkDestroy (hashcat_ctx_t *hashcat_ctx, CUlinkState state); +int hc_cuLinkComplete (hashcat_ctx_t *hashcat_ctx, CUlinkState state, void **cubinOut, size_t *sizeOut); int hc_clBuildProgram (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data); int hc_clCreateBuffer (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem); @@ -131,12 +134,14 @@ int run_kernel_decompress (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *de int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 pws_cnt); int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 pws_cnt); -void generate_source_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file); -void generate_cached_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file); -void generate_source_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *shared_dir, char *source_file); -void generate_cached_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file); -void generate_source_kernel_amp_filename (const u32 attack_kern, char *shared_dir, char *source_file); -void generate_cached_kernel_amp_filename (const u32 attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file); +void generate_source_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file); +void generate_cached_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file); +void generate_source_kernel_shared_filename (char *shared_dir, char *source_file); +void generate_cached_kernel_shared_filename (char *profile_dir, const char *device_name_chksum, char *cached_file); +void generate_source_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *shared_dir, char *source_file); +void generate_cached_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file); +void generate_source_kernel_amp_filename (const u32 attack_kern, char *shared_dir, char *source_file); +void generate_cached_kernel_amp_filename (const u32 attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file); int backend_ctx_init (hashcat_ctx_t *hashcat_ctx); void backend_ctx_destroy (hashcat_ctx_t *hashcat_ctx); @@ -154,4 +159,7 @@ int backend_session_update_combinator (hashcat_ctx_t *hashcat_ctx); int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx); int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l, const u32 css_cnt_r); +void *hook12_thread (void *p); +void *hook23_thread (void *p); + #endif // _BACKEND_H diff --git a/include/brain.h b/include/brain.h index cad19cd45..fcd370772 100644 --- a/include/brain.h +++ b/include/brain.h @@ -41,7 +41,7 @@ #include "xxhash.h" static const int BRAIN_CLIENT_CONNECT_TIMEOUT = 5; -static const int BRAIN_SERVER_DUMP_EVERY = 5 * 60; +static const int BRAIN_SERVER_TIMER = 5 * 60; static const int BRAIN_SERVER_SESSIONS_MAX = 64; static const int BRAIN_SERVER_ATTACKS_MAX = 64 * 1024; static const int BRAIN_SERVER_CLIENTS_MAX = 256; @@ -173,6 +173,8 @@ typedef struct brain_server_dumper_options { brain_server_dbs_t *brain_server_dbs; + u32 brain_server_timer; + } brain_server_dumper_options_t; typedef struct brain_server_client_options @@ -211,7 +213,7 @@ bool brain_client_connect (hc_device_param_t *device_param, const void brain_client_disconnect (hc_device_param_t *device_param); void brain_client_generate_hash (u64 *hash, const char *line_buf, const size_t line_len); -int brain_server (const char *listen_host, const int listen_port, const char *brain_password, const char *brain_session_whitelist); +int brain_server (const char *listen_host, const int listen_port, const char *brain_password, const char *brain_session_whitelist, const u32 brain_server_timer); bool brain_server_read_hash_dumps (brain_server_dbs_t *brain_server_dbs, const char *path); bool brain_server_write_hash_dumps (brain_server_dbs_t *brain_server_dbs, const char *path); bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash, const char *file); diff --git a/include/common.h b/include/common.h index 39ea9016d..3838cd3cb 100644 --- a/include/common.h +++ b/include/common.h @@ -36,6 +36,9 @@ #define _FILE_OFFSET_BITS 64 #endif +// _FORTIFY_SOURCE needs string.h +#include + #ifndef _FORTIFY_SOURCE #define _FORTIFY_SOURCE 2 #endif @@ -92,6 +95,17 @@ but this is nededed for VS compiler which doesn't have inline keyword but has __ #define STAT_NANOSECONDS_ACCESS_TIME st_atimespec.tv_nsec #endif +/** + * Disable this picky gcc-8 compiler warning + * We're in good company: + * https://github.com/curl/curl/blob/fc3743c31bb3c84e31a2eff99e958337571eb5f0/lib/md5.c#L487-L490 + * https://github.com/kivadiu/thread/blob/ee607c86d4acd1d7733304526eb25d742b533071/src/win32/thread_primitives.cpp#L105-L113 + */ + +#if defined (__GNUC__) && (__GNUC__ >= 8) +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif + // config section // do not try to simply change this, it will not work diff --git a/include/convert.h b/include/convert.h index 7a11466ca..968c93e1b 100644 --- a/include/convert.h +++ b/include/convert.h @@ -24,6 +24,8 @@ bool is_valid_hex_string (const u8 *s, const size_t len); bool is_valid_hex_char (const u8 c); bool is_valid_digit_string (const u8 *s, const size_t len); bool is_valid_digit_char (const u8 c); +bool is_valid_float_string (const u8 *s, const size_t len); +bool is_valid_float_char (const u8 c); u8 hex_convert (const u8 c); diff --git a/include/dictstat.h b/include/dictstat.h index 4e79169b1..bfe8fe7b0 100644 --- a/include/dictstat.h +++ b/include/dictstat.h @@ -18,7 +18,7 @@ #define MAX_DICTSTAT 100000 #define DICTSTAT_FILENAME "hashcat.dictstat2" -#define DICTSTAT_VERSION (0x6863646963743200 | 0x01) +#define DICTSTAT_VERSION (0x6863646963743200 | 0x02) int sort_by_dictstat (const void *s1, const void *s2); diff --git a/include/dynloader.h b/include/dynloader.h index 96c498ddc..bc871abd1 100644 --- a/include/dynloader.h +++ b/include/dynloader.h @@ -28,46 +28,52 @@ hc_dynfunc_t hc_dlsym (hc_dynlib_t handle, const char *symbol); #endif #define HC_LOAD_FUNC2(ptr,name,type,var,libname,noerr) \ - ptr->name = (type) hc_dlsym (ptr->var, #name); \ - if (noerr != -1) { \ - if (!ptr->name) { \ - if (noerr == 1) { \ - event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ - return -1; \ - } \ - if (noerr != 1) { \ - event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ - return 0; \ + do { \ + ptr->name = (type) hc_dlsym (ptr->var, #name); \ + if (noerr != -1) { \ + if (!ptr->name) { \ + if (noerr == 1) { \ + event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return -1; \ + } \ + if (noerr != 1) { \ + event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return 0; \ + } \ } \ } \ - } + } while (0) #define HC_LOAD_FUNC(ptr,name,type,libname,noerr) \ - ptr->name = (type) hc_dlsym (ptr->lib, #name); \ - if (noerr != -1) { \ + do { \ + ptr->name = (type) hc_dlsym (ptr->lib, #name); \ + if (noerr != -1) { \ + if (!ptr->name) { \ + if (noerr == 1) { \ + event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return -1; \ + } \ + if (noerr != 1) { \ + event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return 0; \ + } \ + } \ + } \ + } while (0) + +#define HC_LOAD_ADDR(ptr,name,type,func,addr,libname,noerr) \ + do { \ + ptr->name = (type) (*ptr->func) (addr); \ if (!ptr->name) { \ if (noerr == 1) { \ - event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \ return -1; \ } \ if (noerr != 1) { \ - event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \ return 0; \ } \ } \ - } - -#define HC_LOAD_ADDR(ptr,name,type,func,addr,libname,noerr) \ - ptr->name = (type) (*ptr->func) (addr); \ - if (!ptr->name) { \ - if (noerr == 1) { \ - event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \ - return -1; \ - } \ - if (noerr != 1) { \ - event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \ - return 0; \ - } \ - } + } while (0) #endif // _DYNALOADER_H diff --git a/include/emu_inc_ecc_secp256k1.h b/include/emu_inc_ecc_secp256k1.h new file mode 100644 index 000000000..a411dafd1 --- /dev/null +++ b/include/emu_inc_ecc_secp256k1.h @@ -0,0 +1,14 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _EMU_INC_ECC_SECP256K1_H +#define _EMU_INC_ECC_SECP256K1_H + +#include "emu_general.h" + +#include "inc_vendor.h" +#include "inc_ecc_secp256k1.h" + +#endif // _EMU_INC_ECC_SECP256K1_H diff --git a/include/ext_cuda.h b/include/ext_cuda.h index 49257acbb..0e3619fc4 100644 --- a/include/ext_cuda.h +++ b/include/ext_cuda.h @@ -32,6 +32,7 @@ typedef struct CUevent_st *CUevent; /**< CUDA event */ typedef struct CUfunc_st *CUfunction; /**< CUDA function */ typedef struct CUmod_st *CUmodule; /**< CUDA module */ typedef struct CUstream_st *CUstream; /**< CUDA stream */ +typedef struct CUlinkState_st *CUlinkState; typedef enum cudaError_enum { /** @@ -951,6 +952,41 @@ typedef enum CUevent_flags_enum { CU_EVENT_INTERPROCESS = 0x4 /**< Event is suitable for interprocess use. CU_EVENT_DISABLE_TIMING must be set */ } CUevent_flags; +typedef enum CUjitInputType_enum +{ + /** + * Compiled device-class-specific device code\n + * Applicable options: none + */ + CU_JIT_INPUT_CUBIN = 0, + + /** + * PTX source code\n + * Applicable options: PTX compiler options + */ + CU_JIT_INPUT_PTX, + + /** + * Bundle of multiple cubins and/or PTX of some device code\n + * Applicable options: PTX compiler options, ::CU_JIT_FALLBACK_STRATEGY + */ + CU_JIT_INPUT_FATBINARY, + + /** + * Host object with embedded device code\n + * Applicable options: PTX compiler options, ::CU_JIT_FALLBACK_STRATEGY + */ + CU_JIT_INPUT_OBJECT, + + /** + * Archive of host objects with embedded device code\n + * Applicable options: PTX compiler options, ::CU_JIT_FALLBACK_STRATEGY + */ + CU_JIT_INPUT_LIBRARY, + + CU_JIT_NUM_INPUT_TYPES +} CUjitInputType; + #ifdef _WIN32 #define CUDAAPI __stdcall #else @@ -1012,6 +1048,10 @@ typedef CUresult (CUDA_API_CALL *CUDA_CUSTREAMCREATE) (CUstream *, uns typedef CUresult (CUDA_API_CALL *CUDA_CUSTREAMDESTROY) (CUstream); typedef CUresult (CUDA_API_CALL *CUDA_CUSTREAMSYNCHRONIZE) (CUstream); typedef CUresult (CUDA_API_CALL *CUDA_CUSTREAMWAITEVENT) (CUstream, CUevent, unsigned int); +typedef CUresult (CUDA_API_CALL *CUDA_CULINKCREATE) (unsigned int, CUjit_option *, void **, CUlinkState *); +typedef CUresult (CUDA_API_CALL *CUDA_CULINKADDDATA) (CUlinkState, CUjitInputType, void *, size_t, const char *, unsigned int, CUjit_option *, void **); +typedef CUresult (CUDA_API_CALL *CUDA_CULINKDESTROY) (CUlinkState); +typedef CUresult (CUDA_API_CALL *CUDA_CULINKCOMPLETE) (CUlinkState, void **, size_t *); typedef struct hc_cuda_lib { @@ -1070,6 +1110,10 @@ typedef struct hc_cuda_lib CUDA_CUSTREAMDESTROY cuStreamDestroy; CUDA_CUSTREAMSYNCHRONIZE cuStreamSynchronize; CUDA_CUSTREAMWAITEVENT cuStreamWaitEvent; + CUDA_CULINKCREATE cuLinkCreate; + CUDA_CULINKADDDATA cuLinkAddData; + CUDA_CULINKDESTROY cuLinkDestroy; + CUDA_CULINKCOMPLETE cuLinkComplete; } hc_cuda_lib_t; diff --git a/include/filehandling.h b/include/filehandling.h index 8b73699d4..88e9dc9d5 100644 --- a/include/filehandling.h +++ b/include/filehandling.h @@ -29,7 +29,7 @@ void hc_fflush (HCFILE *fp); void hc_fclose (HCFILE *fp); int hc_fputc (int c, HCFILE *fp); char *hc_fgets (char *buf, int len, HCFILE *fp); -size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp); +size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, HCFILE *fp); size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp); size_t fgetl (HCFILE *fp, char *line_buf, const size_t line_sz); diff --git a/include/logfile.h b/include/logfile.h index e2d814644..5d184deba 100644 --- a/include/logfile.h +++ b/include/logfile.h @@ -14,25 +14,25 @@ // logfile_append() checks for logfile_disable internally to make it easier from here -#define logfile_top_msg(msg) logfile_append (hashcat_ctx, "%s\t%s", logfile_ctx->topid, (msg)); -#define logfile_sub_msg(msg) logfile_append (hashcat_ctx, "%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (msg)); -#define logfile_top_var_uint64(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%" PRIu64 "", logfile_ctx->topid, (var), (u64) (val)); -#define logfile_sub_var_uint64(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%" PRIu64 "", logfile_ctx->topid, logfile_ctx->subid, (var), (u64) (val)); -#define logfile_top_var_uint(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%u", logfile_ctx->topid, (var), (u32) (val)); -#define logfile_sub_var_uint(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%u", logfile_ctx->topid, logfile_ctx->subid, (var), (u32) (val)); -#define logfile_top_var_char(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%c", logfile_ctx->topid, (var), (char) (val)); -#define logfile_sub_var_char(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%c", logfile_ctx->topid, logfile_ctx->subid, (var), (char) (val)); -#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (hashcat_ctx, "%s\t%s\t%s", logfile_ctx->topid, (var), (val)); -#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); +#define logfile_top_msg(msg) logfile_append (hashcat_ctx, "%s\t%s", logfile_ctx->topid, (msg)) +#define logfile_sub_msg(msg) logfile_append (hashcat_ctx, "%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (msg)) +#define logfile_top_var_uint64(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%" PRIu64 "", logfile_ctx->topid, (var), (u64) (val)) +#define logfile_sub_var_uint64(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%" PRIu64 "", logfile_ctx->topid, logfile_ctx->subid, (var), (u64) (val)) +#define logfile_top_var_uint(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%u", logfile_ctx->topid, (var), (u32) (val)) +#define logfile_sub_var_uint(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%u", logfile_ctx->topid, logfile_ctx->subid, (var), (u32) (val)) +#define logfile_top_var_char(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%c", logfile_ctx->topid, (var), (char) (val)) +#define logfile_sub_var_char(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%c", logfile_ctx->topid, logfile_ctx->subid, (var), (char) (val)) +#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (hashcat_ctx, "%s\t%s\t%s", logfile_ctx->topid, (var), (val)) +#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (var), (val)) -#define logfile_top_uint(var) logfile_top_var_uint (#var, (var)); -#define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var)); -#define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var)); -#define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var)); -#define logfile_top_char(var) logfile_top_var_char (#var, (var)); -#define logfile_sub_char(var) logfile_sub_var_char (#var, (var)); -#define logfile_top_string(var) logfile_top_var_string (#var, (var)); -#define logfile_sub_string(var) logfile_sub_var_string (#var, (var)); +#define logfile_top_uint(var) logfile_top_var_uint (#var, (var)) +#define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var)) +#define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var)) +#define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var)) +#define logfile_top_char(var) logfile_top_var_char (#var, (var)) +#define logfile_sub_char(var) logfile_sub_var_char (#var, (var)) +#define logfile_top_string(var) logfile_top_var_string (#var, (var)) +#define logfile_sub_string(var) logfile_sub_var_string (#var, (var)) void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx); void logfile_generate_subid (hashcat_ctx_t *hashcat_ctx); diff --git a/include/modules.h b/include/modules.h index 1e90e67dd..4e6fee69c 100644 --- a/include/modules.h +++ b/include/modules.h @@ -71,8 +71,8 @@ bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *ha u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos); int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash); -void module_hook12 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt); -void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt); +void module_hook12 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pw_pos); +void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pw_pos); int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz); diff --git a/include/mpsp.h b/include/mpsp.h index b986d0dc7..da0e6dfc7 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -22,7 +22,7 @@ #define INCR_MASKS 1000 -u32 mp_get_length (const char *mask); +u32 mp_get_length (const char *mask, const u32 opts_type); void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop); diff --git a/include/outfile.h b/include/outfile.h index 79790cf61..e54c09a35 100644 --- a/include/outfile.h +++ b/include/outfile.h @@ -14,6 +14,8 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos); int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len); +u32 outfile_format_parse (const char *format_string); + int outfile_init (hashcat_ctx_t *hashcat_ctx); void outfile_destroy (hashcat_ctx_t *hashcat_ctx); int outfile_write_open (hashcat_ctx_t *hashcat_ctx); diff --git a/include/potfile.h b/include/potfile.h index fcc8407c6..de97a312a 100644 --- a/include/potfile.h +++ b/include/potfile.h @@ -30,5 +30,6 @@ void potfile_update_hashes (hashcat_ctx_t *hashcat_ctx, hash_t *hash_buf, cha void pot_tree_destroy (pot_tree_entry_t *tree); int sort_pot_tree_by_hash (const void *v1, const void *v2); +int sort_pot_orig_line (const void *v1, const void *v2); #endif // _POTFILE_H diff --git a/include/shared.h b/include/shared.h index 787a241c6..96604c730 100644 --- a/include/shared.h +++ b/include/shared.h @@ -64,6 +64,8 @@ bool hc_string_is_digit (const char *s); void hc_string_trim_trailing (char *s); void hc_string_trim_leading (char *s); +int hc_get_processor_count (); + bool hc_same_files (char *file1, char *file2); u32 hc_strtoul (const char *nptr, char **endptr, int base); @@ -77,6 +79,9 @@ u64 round_up_multiple_64 (const u64 v, const u64 m); void hc_strncat (u8 *dst, const u8 *src, const size_t n); +const u8 *hc_strchr_next (const u8 *input_buf, const int input_len, const u8 separator); +const u8 *hc_strchr_last (const u8 *input_buf, const int input_len, const u8 separator); + int count_char (const u8 *buf, const int len, const u8 c); float get_entropy (const u8 *buf, const int len); diff --git a/include/types.h b/include/types.h index 0f754aa71..47eff8f28 100644 --- a/include/types.h +++ b/include/types.h @@ -112,51 +112,53 @@ typedef enum event_identifier EVENT_CRACKER_FINISHED = 0x00000030, EVENT_CRACKER_HASH_CRACKED = 0x00000031, EVENT_CRACKER_STARTING = 0x00000032, - EVENT_HASHLIST_COUNT_LINES_POST = 0x00000040, - EVENT_HASHLIST_COUNT_LINES_PRE = 0x00000041, - EVENT_HASHLIST_PARSE_HASH = 0x00000042, - EVENT_HASHLIST_SORT_HASH_POST = 0x00000043, - EVENT_HASHLIST_SORT_HASH_PRE = 0x00000044, - EVENT_HASHLIST_SORT_SALT_POST = 0x00000045, - EVENT_HASHLIST_SORT_SALT_PRE = 0x00000046, - EVENT_HASHLIST_UNIQUE_HASH_POST = 0x00000047, - EVENT_HASHLIST_UNIQUE_HASH_PRE = 0x00000048, - EVENT_INNERLOOP1_FINISHED = 0x00000050, - EVENT_INNERLOOP1_STARTING = 0x00000051, - EVENT_INNERLOOP2_FINISHED = 0x00000060, - EVENT_INNERLOOP2_STARTING = 0x00000061, - EVENT_LOG_ERROR = 0x00000070, - EVENT_LOG_INFO = 0x00000071, - EVENT_LOG_WARNING = 0x00000072, - EVENT_LOG_ADVICE = 0x00000073, - EVENT_MONITOR_RUNTIME_LIMIT = 0x00000080, - EVENT_MONITOR_STATUS_REFRESH = 0x00000081, - EVENT_MONITOR_TEMP_ABORT = 0x00000082, - EVENT_MONITOR_THROTTLE1 = 0x00000083, - EVENT_MONITOR_THROTTLE2 = 0x00000084, - EVENT_MONITOR_THROTTLE3 = 0x00000085, - EVENT_MONITOR_PERFORMANCE_HINT = 0x00000086, - EVENT_MONITOR_NOINPUT_HINT = 0x00000087, - EVENT_MONITOR_NOINPUT_ABORT = 0x00000088, - EVENT_BACKEND_SESSION_POST = 0x00000090, - EVENT_BACKEND_SESSION_PRE = 0x00000091, - EVENT_BACKEND_SESSION_HOSTMEM = 0x00000092, - EVENT_BACKEND_DEVICE_INIT_POST = 0x00000093, - EVENT_BACKEND_DEVICE_INIT_PRE = 0x00000094, - EVENT_OUTERLOOP_FINISHED = 0x000000a0, - EVENT_OUTERLOOP_MAINSCREEN = 0x000000a1, - EVENT_OUTERLOOP_STARTING = 0x000000a2, - EVENT_POTFILE_ALL_CRACKED = 0x000000b0, - EVENT_POTFILE_HASH_LEFT = 0x000000b1, - EVENT_POTFILE_HASH_SHOW = 0x000000b2, - EVENT_POTFILE_NUM_CRACKED = 0x000000b3, - EVENT_POTFILE_REMOVE_PARSE_POST = 0x000000b4, - EVENT_POTFILE_REMOVE_PARSE_PRE = 0x000000b5, - EVENT_SELFTEST_FINISHED = 0x000000c0, - EVENT_SELFTEST_STARTING = 0x000000c1, - EVENT_SET_KERNEL_POWER_FINAL = 0x000000d0, - EVENT_WORDLIST_CACHE_GENERATE = 0x000000e0, - EVENT_WORDLIST_CACHE_HIT = 0x000000e1, + EVENT_HASHCONFIG_PRE = 0x00000040, + EVENT_HASHCONFIG_POST = 0x00000041, + EVENT_HASHLIST_COUNT_LINES_POST = 0x00000050, + EVENT_HASHLIST_COUNT_LINES_PRE = 0x00000051, + EVENT_HASHLIST_PARSE_HASH = 0x00000052, + EVENT_HASHLIST_SORT_HASH_POST = 0x00000053, + EVENT_HASHLIST_SORT_HASH_PRE = 0x00000054, + EVENT_HASHLIST_SORT_SALT_POST = 0x00000055, + EVENT_HASHLIST_SORT_SALT_PRE = 0x00000056, + EVENT_HASHLIST_UNIQUE_HASH_POST = 0x00000057, + EVENT_HASHLIST_UNIQUE_HASH_PRE = 0x00000058, + EVENT_INNERLOOP1_FINISHED = 0x00000060, + EVENT_INNERLOOP1_STARTING = 0x00000061, + EVENT_INNERLOOP2_FINISHED = 0x00000070, + EVENT_INNERLOOP2_STARTING = 0x00000071, + EVENT_LOG_ERROR = 0x00000080, + EVENT_LOG_INFO = 0x00000081, + EVENT_LOG_WARNING = 0x00000082, + EVENT_LOG_ADVICE = 0x00000083, + EVENT_MONITOR_RUNTIME_LIMIT = 0x00000090, + EVENT_MONITOR_STATUS_REFRESH = 0x00000091, + EVENT_MONITOR_TEMP_ABORT = 0x00000092, + EVENT_MONITOR_THROTTLE1 = 0x00000093, + EVENT_MONITOR_THROTTLE2 = 0x00000094, + EVENT_MONITOR_THROTTLE3 = 0x00000095, + EVENT_MONITOR_PERFORMANCE_HINT = 0x00000096, + EVENT_MONITOR_NOINPUT_HINT = 0x00000097, + EVENT_MONITOR_NOINPUT_ABORT = 0x00000098, + EVENT_BACKEND_SESSION_POST = 0x000000a0, + EVENT_BACKEND_SESSION_PRE = 0x000000a1, + EVENT_BACKEND_SESSION_HOSTMEM = 0x000000a2, + EVENT_BACKEND_DEVICE_INIT_POST = 0x000000a3, + EVENT_BACKEND_DEVICE_INIT_PRE = 0x000000a4, + EVENT_OUTERLOOP_FINISHED = 0x000000b0, + EVENT_OUTERLOOP_MAINSCREEN = 0x000000b1, + EVENT_OUTERLOOP_STARTING = 0x000000b2, + EVENT_POTFILE_ALL_CRACKED = 0x000000c0, + EVENT_POTFILE_HASH_LEFT = 0x000000c1, + EVENT_POTFILE_HASH_SHOW = 0x000000c2, + EVENT_POTFILE_NUM_CRACKED = 0x000000c3, + EVENT_POTFILE_REMOVE_PARSE_POST = 0x000000c4, + EVENT_POTFILE_REMOVE_PARSE_PRE = 0x000000c5, + EVENT_SELFTEST_FINISHED = 0x000000d0, + EVENT_SELFTEST_STARTING = 0x000000d1, + EVENT_SET_KERNEL_POWER_FINAL = 0x000000e0, + EVENT_WORDLIST_CACHE_GENERATE = 0x000000f0, + EVENT_WORDLIST_CACHE_HIT = 0x000000f1, // there will be much more event types soon @@ -255,6 +257,7 @@ typedef enum kern_run KERN_RUN_1 = 1000, KERN_RUN_12 = 1500, KERN_RUN_2 = 2000, + KERN_RUN_2E = 2001, KERN_RUN_23 = 2500, KERN_RUN_3 = 3000, KERN_RUN_4 = 4000, @@ -370,7 +373,8 @@ typedef enum opti_type OPTI_TYPE_USES_BITS_8 = (1 << 16), OPTI_TYPE_USES_BITS_16 = (1 << 17), OPTI_TYPE_USES_BITS_32 = (1 << 18), - OPTI_TYPE_USES_BITS_64 = (1 << 19) + OPTI_TYPE_USES_BITS_64 = (1 << 19), + OPTI_TYPE_REGISTER_LIMIT = (1 << 20), // We'll limit the register count to 128 } opti_type_t; @@ -388,10 +392,10 @@ typedef enum opts_type OPTS_TYPE_PT_GENERATE_LE = (1ULL << 9), OPTS_TYPE_PT_GENERATE_BE = (1ULL << 10), OPTS_TYPE_PT_NEVERCRACK = (1ULL << 11), // if we want all possible results - OPTS_TYPE_PT_BITSLICE = (1ULL << 12), - OPTS_TYPE_PT_ALWAYS_ASCII = (1ULL << 13), - OPTS_TYPE_PT_ALWAYS_HEXIFY = (1ULL << 14), - OPTS_TYPE_PT_LM = (1ULL << 15), // special handling: all lower, 7 max, ... + OPTS_TYPE_PT_ALWAYS_ASCII = (1ULL << 12), + OPTS_TYPE_PT_ALWAYS_HEXIFY = (1ULL << 13), + OPTS_TYPE_PT_LM = (1ULL << 14), // special handling: all lower, 7 max, ... + OPTS_TYPE_PT_HEX = (1ULL << 15), // input wordlist (and masks!) are always in hex OPTS_TYPE_ST_UTF16LE = (1ULL << 16), OPTS_TYPE_ST_UTF16BE = (1ULL << 17), OPTS_TYPE_ST_UPPER = (1ULL << 18), @@ -403,32 +407,34 @@ typedef enum opts_type OPTS_TYPE_ST_ADDBITS15 = (1ULL << 24), OPTS_TYPE_ST_HEX = (1ULL << 25), OPTS_TYPE_ST_BASE64 = (1ULL << 26), - OPTS_TYPE_ST_HASH_MD5 = (1ULL << 27), OPTS_TYPE_HASH_COPY = (1ULL << 28), OPTS_TYPE_HASH_SPLIT = (1ULL << 29), - OPTS_TYPE_HOOK12 = (1ULL << 30), - OPTS_TYPE_HOOK23 = (1ULL << 31), - OPTS_TYPE_INIT2 = (1ULL << 32), - OPTS_TYPE_LOOP2 = (1ULL << 33), - OPTS_TYPE_AUX1 = (1ULL << 34), - OPTS_TYPE_AUX2 = (1ULL << 35), - OPTS_TYPE_AUX3 = (1ULL << 36), - OPTS_TYPE_AUX4 = (1ULL << 37), - OPTS_TYPE_BINARY_HASHFILE = (1ULL << 38), - OPTS_TYPE_PREFERED_THREAD = (1ULL << 39), // some algorithms (complicated ones with many branches) benefit from this - OPTS_TYPE_PT_ADD06 = (1ULL << 40), - OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 41), - OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 42), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately - OPTS_TYPE_SUGGEST_KG = (1ULL << 43), // suggest keep guessing for modules the user maybe wants to use --keep-guessing - OPTS_TYPE_COPY_TMPS = (1ULL << 44), // if we want to use data from tmps buffer (for example get the PMK in WPA) - OPTS_TYPE_POTFILE_NOPASS = (1ULL << 45), // sometimes the password should not be printed to potfile + OPTS_TYPE_LOOP_EXTENDED = (1ULL << 30), // a kernel which is called each time normal _loop kernel finished. + // but unlike a hook kernel this kernel is called for every _loop iteration offset + OPTS_TYPE_HOOK12 = (1ULL << 31), + OPTS_TYPE_HOOK23 = (1ULL << 32), + OPTS_TYPE_INIT2 = (1ULL << 33), + OPTS_TYPE_LOOP2 = (1ULL << 34), + OPTS_TYPE_AUX1 = (1ULL << 35), + OPTS_TYPE_AUX2 = (1ULL << 36), + OPTS_TYPE_AUX3 = (1ULL << 37), + OPTS_TYPE_AUX4 = (1ULL << 38), + OPTS_TYPE_BINARY_HASHFILE = (1ULL << 39), + OPTS_TYPE_PT_ADD06 = (1ULL << 41), + OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 42), + OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 43), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately + OPTS_TYPE_TM_KERNEL = (1ULL << 44), + OPTS_TYPE_SUGGEST_KG = (1ULL << 45), // suggest keep guessing for modules the user maybe wants to use --keep-guessing + OPTS_TYPE_COPY_TMPS = (1ULL << 46), // if we want to use data from tmps buffer (for example get the PMK in WPA) + OPTS_TYPE_POTFILE_NOPASS = (1ULL << 47), // sometimes the password should not be printed to potfile + OPTS_TYPE_DYNAMIC_SHARED = (1ULL << 48), // use dynamic shared memory (note: needs special kernel changes) } opts_type_t; typedef enum dgst_size { DGST_SIZE_4_2 = (2 * sizeof (u32)), // 8 - DGST_SIZE_4_4 = (4 * sizeof (u32)), // 16 + DGST_SIZE_4_4 = (4 * sizeof (u32)), // 16 !!! DGST_SIZE_4_5 = (5 * sizeof (u32)), // 20 DGST_SIZE_4_6 = (6 * sizeof (u32)), // 24 DGST_SIZE_4_7 = (7 * sizeof (u32)), // 28 @@ -436,6 +442,7 @@ typedef enum dgst_size DGST_SIZE_4_16 = (16 * sizeof (u32)), // 64 !!! DGST_SIZE_4_32 = (32 * sizeof (u32)), // 128 !!! DGST_SIZE_4_64 = (64 * sizeof (u32)), // 256 + DGST_SIZE_8_2 = (2 * sizeof (u64)), // 16 !!! DGST_SIZE_8_8 = (8 * sizeof (u64)), // 64 !!! DGST_SIZE_8_16 = (16 * sizeof (u64)), // 128 !!! DGST_SIZE_8_25 = (25 * sizeof (u64)) // 200 @@ -481,7 +488,9 @@ typedef enum outfile_fmt OUTFILE_FMT_HASH = (1 << 0), OUTFILE_FMT_PLAIN = (1 << 1), OUTFILE_FMT_HEXPLAIN = (1 << 2), - OUTFILE_FMT_CRACKPOS = (1 << 3) + OUTFILE_FMT_CRACKPOS = (1 << 3), + OUTFILE_FMT_TIME_ABS = (1 << 4), + OUTFILE_FMT_TIME_REL = (1 << 5) } outfile_fmt_t; @@ -582,6 +591,7 @@ typedef enum user_options_defaults HEX_CHARSET = false, HEX_SALT = false, HEX_WORDLIST = false, + HOOK_THREADS = 0, INCREMENT = false, INCREMENT_MAX = PW_MAX, INCREMENT_MIN = 1, @@ -599,6 +609,8 @@ typedef enum user_options_defaults MARKOV_DISABLE = false, MARKOV_THRESHOLD = 0, NONCE_ERROR_CORRECTIONS = 8, + BACKEND_IGNORE_CUDA = false, + BACKEND_IGNORE_OPENCL = false, BACKEND_INFO = false, BACKEND_VECTOR_WIDTH = 0, OPTIMIZED_KERNEL_ENABLE = false, @@ -626,7 +638,7 @@ typedef enum user_options_defaults SKIP = 0, SLOW_CANDIDATES = false, SPEED_ONLY = false, - SPIN_DAMP = 8, + SPIN_DAMP = 0, STATUS = false, STATUS_JSON = false, STATUS_TIMER = 10, @@ -635,6 +647,8 @@ typedef enum user_options_defaults USAGE = false, USERNAME = false, VERSION = false, + VERACRYPT_PIM_START = 485, + VERACRYPT_PIM_STOP = 485, WORDLIST_AUTOHEX_DISABLE = false, WORKLOAD_PROFILE = 2, @@ -645,123 +659,129 @@ typedef enum user_options_map IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', IDX_BACKEND_DEVICES = 'd', + IDX_BACKEND_IGNORE_CUDA = 0xff01, + IDX_BACKEND_IGNORE_OPENCL = 0xff02, IDX_BACKEND_INFO = 'I', - IDX_BACKEND_VECTOR_WIDTH = 0xff27, - IDX_BENCHMARK_ALL = 0xff01, + IDX_BACKEND_VECTOR_WIDTH = 0xff03, + IDX_BENCHMARK_ALL = 0xff04, IDX_BENCHMARK = 'b', - IDX_BITMAP_MAX = 0xff02, - IDX_BITMAP_MIN = 0xff03, + IDX_BITMAP_MAX = 0xff05, + IDX_BITMAP_MIN = 0xff06, #ifdef WITH_BRAIN IDX_BRAIN_CLIENT = 'z', - IDX_BRAIN_CLIENT_FEATURES = 0xff04, - IDX_BRAIN_HOST = 0xff05, - IDX_BRAIN_PASSWORD = 0xff06, - IDX_BRAIN_PORT = 0xff07, - IDX_BRAIN_SERVER = 0xff08, - IDX_BRAIN_SESSION = 0xff09, - IDX_BRAIN_SESSION_WHITELIST = 0xff0a, + IDX_BRAIN_CLIENT_FEATURES = 0xff07, + IDX_BRAIN_HOST = 0xff08, + IDX_BRAIN_PASSWORD = 0xff09, + IDX_BRAIN_PORT = 0xff0a, + IDX_BRAIN_SERVER = 0xff0b, + IDX_BRAIN_SERVER_TIMER = 0xff0c, + IDX_BRAIN_SESSION = 0xff0d, + IDX_BRAIN_SESSION_WHITELIST = 0xff0e, #endif - IDX_CPU_AFFINITY = 0xff0b, + IDX_CPU_AFFINITY = 0xff0f, IDX_CUSTOM_CHARSET_1 = '1', IDX_CUSTOM_CHARSET_2 = '2', IDX_CUSTOM_CHARSET_3 = '3', IDX_CUSTOM_CHARSET_4 = '4', - IDX_DEBUG_FILE = 0xff0c, - IDX_DEBUG_MODE = 0xff0d, - IDX_ENCODING_FROM = 0xff0e, - IDX_ENCODING_TO = 0xff0f, - IDX_EXAMPLE_HASHES = 0xff10, - IDX_FORCE = 0xff11, - IDX_HWMON_DISABLE = 0xff12, - IDX_HWMON_TEMP_ABORT = 0xff13, + IDX_DEBUG_FILE = 0xff10, + IDX_DEBUG_MODE = 0xff11, + IDX_ENCODING_FROM = 0xff12, + IDX_ENCODING_TO = 0xff13, + IDX_EXAMPLE_HASHES = 0xff14, + IDX_FORCE = 0xff15, + IDX_HWMON_DISABLE = 0xff16, + IDX_HWMON_TEMP_ABORT = 0xff17, IDX_HASH_MODE = 'm', - IDX_HCCAPX_MESSAGE_PAIR = 0xff14, + IDX_HCCAPX_MESSAGE_PAIR = 0xff18, IDX_HELP = 'h', - IDX_HEX_CHARSET = 0xff15, - IDX_HEX_SALT = 0xff16, - IDX_HEX_WORDLIST = 0xff17, + IDX_HEX_CHARSET = 0xff19, + IDX_HEX_SALT = 0xff1a, + IDX_HEX_WORDLIST = 0xff1b, + IDX_HOOK_THREADS = 0xff1c, IDX_INCREMENT = 'i', - IDX_INCREMENT_MAX = 0xff18, - IDX_INCREMENT_MIN = 0xff19, - IDX_INDUCTION_DIR = 0xff1a, - IDX_KEEP_GUESSING = 0xff1b, + IDX_INCREMENT_MAX = 0xff1d, + IDX_INCREMENT_MIN = 0xff1e, + IDX_INDUCTION_DIR = 0xff1f, + IDX_KEEP_GUESSING = 0xff20, IDX_KERNEL_ACCEL = 'n', IDX_KERNEL_LOOPS = 'u', IDX_KERNEL_THREADS = 'T', - IDX_KEYBOARD_LAYOUT_MAPPING = 0xff1c, - IDX_KEYSPACE = 0xff1d, - IDX_LEFT = 0xff1e, + IDX_KEYBOARD_LAYOUT_MAPPING = 0xff21, + IDX_KEYSPACE = 0xff22, + IDX_LEFT = 0xff23, IDX_LIMIT = 'l', - IDX_LOGFILE_DISABLE = 0xff1f, - IDX_LOOPBACK = 0xff20, - IDX_MACHINE_READABLE = 0xff21, - IDX_MARKOV_CLASSIC = 0xff22, - IDX_MARKOV_DISABLE = 0xff23, - IDX_MARKOV_HCSTAT2 = 0xff24, + IDX_LOGFILE_DISABLE = 0xff24, + IDX_LOOPBACK = 0xff25, + IDX_MACHINE_READABLE = 0xff26, + IDX_MARKOV_CLASSIC = 0xff27, + IDX_MARKOV_DISABLE = 0xff28, + IDX_MARKOV_HCSTAT2 = 0xff29, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff25, + IDX_NONCE_ERROR_CORRECTIONS = 0xff2a, IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPTIMIZED_KERNEL_ENABLE = 'O', - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff28, - IDX_OUTFILE_CHECK_DIR = 0xff29, - IDX_OUTFILE_CHECK_TIMER = 0xff2a, - IDX_OUTFILE_FORMAT = 0xff2b, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2b, + IDX_OUTFILE_CHECK_DIR = 0xff2c, + IDX_OUTFILE_CHECK_TIMER = 0xff2d, + IDX_OUTFILE_FORMAT = 0xff2e, IDX_OUTFILE = 'o', - IDX_POTFILE_DISABLE = 0xff2c, - IDX_POTFILE_PATH = 0xff2d, - IDX_PROGRESS_ONLY = 0xff2e, - IDX_QUIET = 0xff2f, - IDX_REMOVE = 0xff30, - IDX_REMOVE_TIMER = 0xff31, - IDX_RESTORE = 0xff32, - IDX_RESTORE_DISABLE = 0xff33, - IDX_RESTORE_FILE_PATH = 0xff34, + IDX_POTFILE_DISABLE = 0xff2f, + IDX_POTFILE_PATH = 0xff30, + IDX_PROGRESS_ONLY = 0xff31, + IDX_QUIET = 0xff32, + IDX_REMOVE = 0xff33, + IDX_REMOVE_TIMER = 0xff34, + IDX_RESTORE = 0xff35, + IDX_RESTORE_DISABLE = 0xff36, + IDX_RESTORE_FILE_PATH = 0xff37, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff35, - IDX_RP_GEN_FUNC_MIN = 0xff36, + IDX_RP_GEN_FUNC_MAX = 0xff38, + IDX_RP_GEN_FUNC_MIN = 0xff39, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff37, + IDX_RP_GEN_SEED = 0xff3a, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff38, - IDX_SCRYPT_TMTO = 0xff39, + IDX_RUNTIME = 0xff3b, + IDX_SCRYPT_TMTO = 0xff3c, IDX_SEGMENT_SIZE = 'c', - IDX_SELF_TEST_DISABLE = 0xff3a, + IDX_SELF_TEST_DISABLE = 0xff3d, IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff3b, - IDX_SHOW = 0xff3c, + IDX_SESSION = 0xff3e, + IDX_SHOW = 0xff3f, IDX_SKIP = 's', IDX_SLOW_CANDIDATES = 'S', - IDX_SPEED_ONLY = 0xff3d, - IDX_SPIN_DAMP = 0xff3e, - IDX_STATUS = 0xff3f, - IDX_STATUS_JSON = 0xff40, - IDX_STATUS_TIMER = 0xff41, - IDX_STDOUT_FLAG = 0xff42, - IDX_STDIN_TIMEOUT_ABORT = 0xff43, - IDX_TRUECRYPT_KEYFILES = 0xff44, - IDX_USERNAME = 0xff45, - IDX_VERACRYPT_KEYFILES = 0xff46, - IDX_VERACRYPT_PIM_START = 0xff47, - IDX_VERACRYPT_PIM_STOP = 0xff48, + IDX_SPEED_ONLY = 0xff40, + IDX_SPIN_DAMP = 0xff41, + IDX_STATUS = 0xff42, + IDX_STATUS_JSON = 0xff43, + IDX_STATUS_TIMER = 0xff44, + IDX_STDOUT_FLAG = 0xff45, + IDX_STDIN_TIMEOUT_ABORT = 0xff46, + IDX_TRUECRYPT_KEYFILES = 0xff47, + IDX_USERNAME = 0xff48, + IDX_VERACRYPT_KEYFILES = 0xff49, + IDX_VERACRYPT_PIM_START = 0xff4a, + IDX_VERACRYPT_PIM_STOP = 0xff4b, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff49, + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4c, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; typedef enum token_attr { - TOKEN_ATTR_FIXED_LENGTH = 1 << 0, - TOKEN_ATTR_OPTIONAL_ROUNDS = 1 << 1, - TOKEN_ATTR_VERIFY_SIGNATURE = 1 << 2, - TOKEN_ATTR_VERIFY_LENGTH = 1 << 3, - TOKEN_ATTR_VERIFY_DIGIT = 1 << 4, - TOKEN_ATTR_VERIFY_HEX = 1 << 5, - TOKEN_ATTR_VERIFY_BASE64A = 1 << 6, - TOKEN_ATTR_VERIFY_BASE64B = 1 << 7, - TOKEN_ATTR_VERIFY_BASE64C = 1 << 8 + TOKEN_ATTR_FIXED_LENGTH = 1 << 0, + TOKEN_ATTR_SEPARATOR_FARTHEST = 1 << 1, + TOKEN_ATTR_OPTIONAL_ROUNDS = 1 << 2, + TOKEN_ATTR_VERIFY_SIGNATURE = 1 << 3, + TOKEN_ATTR_VERIFY_LENGTH = 1 << 4, + TOKEN_ATTR_VERIFY_DIGIT = 1 << 5, + TOKEN_ATTR_VERIFY_FLOAT = 1 << 6, + TOKEN_ATTR_VERIFY_HEX = 1 << 7, + TOKEN_ATTR_VERIFY_BASE64A = 1 << 8, + TOKEN_ATTR_VERIFY_BASE64B = 1 << 9, + TOKEN_ATTR_VERIFY_BASE64C = 1 << 10, } token_attr_t; @@ -830,6 +850,7 @@ typedef struct hash hashinfo_t *hash_info; char *pw_buf; int pw_len; + u64 orig_line_pos; } hash_t; @@ -1057,6 +1078,7 @@ typedef struct hc_device_param u32 kernel_wgs1; u32 kernel_wgs12; u32 kernel_wgs2; + u32 kernel_wgs2e; u32 kernel_wgs23; u32 kernel_wgs3; u32 kernel_wgs4; @@ -1078,6 +1100,7 @@ typedef struct hc_device_param u32 kernel_preferred_wgs_multiple1; u32 kernel_preferred_wgs_multiple12; u32 kernel_preferred_wgs_multiple2; + u32 kernel_preferred_wgs_multiple2e; u32 kernel_preferred_wgs_multiple23; u32 kernel_preferred_wgs_multiple3; u32 kernel_preferred_wgs_multiple4; @@ -1099,6 +1122,7 @@ typedef struct hc_device_param u64 kernel_local_mem_size1; u64 kernel_local_mem_size12; u64 kernel_local_mem_size2; + u64 kernel_local_mem_size2e; u64 kernel_local_mem_size23; u64 kernel_local_mem_size3; u64 kernel_local_mem_size4; @@ -1117,6 +1141,28 @@ typedef struct hc_device_param u64 kernel_local_mem_size_aux3; u64 kernel_local_mem_size_aux4; + u64 kernel_dynamic_local_mem_size1; + u64 kernel_dynamic_local_mem_size12; + u64 kernel_dynamic_local_mem_size2; + u64 kernel_dynamic_local_mem_size2e; + u64 kernel_dynamic_local_mem_size23; + u64 kernel_dynamic_local_mem_size3; + u64 kernel_dynamic_local_mem_size4; + u64 kernel_dynamic_local_mem_size_init2; + u64 kernel_dynamic_local_mem_size_loop2; + u64 kernel_dynamic_local_mem_size_mp; + u64 kernel_dynamic_local_mem_size_mp_l; + u64 kernel_dynamic_local_mem_size_mp_r; + u64 kernel_dynamic_local_mem_size_amp; + u64 kernel_dynamic_local_mem_size_tm; + u64 kernel_dynamic_local_mem_size_memset; + u64 kernel_dynamic_local_mem_size_atinit; + u64 kernel_dynamic_local_mem_size_decompress; + u64 kernel_dynamic_local_mem_size_aux1; + u64 kernel_dynamic_local_mem_size_aux2; + u64 kernel_dynamic_local_mem_size_aux3; + u64 kernel_dynamic_local_mem_size_aux4; + u32 kernel_accel; u32 kernel_accel_prev; u32 kernel_accel_min; @@ -1211,6 +1257,7 @@ typedef struct hc_device_param double exec_us_prev1[EXPECTED_ITERATIONS]; double exec_us_prev2[EXPECTED_ITERATIONS]; + double exec_us_prev2e[EXPECTED_ITERATIONS]; double exec_us_prev3[EXPECTED_ITERATIONS]; double exec_us_prev4[EXPECTED_ITERATIONS]; double exec_us_prev_init2[EXPECTED_ITERATIONS]; @@ -1229,12 +1276,30 @@ typedef struct hc_device_param hc_timer_t timer_speed; + // Some more attributes + + bool use_opencl12; + bool use_opencl20; + bool use_opencl21; + // AMD + bool has_vadd; + bool has_vaddc; + bool has_vadd_co; + bool has_vaddc_co; + bool has_vsub; + bool has_vsubb; + bool has_vsub_co; + bool has_vsubb_co; bool has_vadd3; bool has_vbfe; bool has_vperm; // NV + bool has_add; + bool has_addc; + bool has_sub; + bool has_subc; bool has_bfe; bool has_lop3; bool has_mov64; @@ -1290,12 +1355,14 @@ typedef struct hc_device_param CUevent cuda_event2; CUmodule cuda_module; + CUmodule cuda_module_shared; CUmodule cuda_module_mp; CUmodule cuda_module_amp; CUfunction cuda_function1; CUfunction cuda_function12; CUfunction cuda_function2; + CUfunction cuda_function2e; CUfunction cuda_function23; CUfunction cuda_function3; CUfunction cuda_function4; @@ -1371,12 +1438,14 @@ typedef struct hc_device_param cl_command_queue opencl_command_queue; cl_program opencl_program; + cl_program opencl_program_shared; cl_program opencl_program_mp; cl_program opencl_program_amp; cl_kernel opencl_kernel1; cl_kernel opencl_kernel12; cl_kernel opencl_kernel2; + cl_kernel opencl_kernel2e; cl_kernel opencl_kernel23; cl_kernel opencl_kernel3; cl_kernel opencl_kernel4; @@ -1588,6 +1657,8 @@ typedef struct dictstat char encoding_from[64]; char encoding_to[64]; + u8 hash_filename[16]; + } dictstat_t; typedef struct hashdump @@ -1627,7 +1698,7 @@ typedef struct loopback_ctx typedef struct mf { - char mf_buf[0x100]; + char mf_buf[0x400]; int mf_len; } mf_t; @@ -1691,6 +1762,14 @@ typedef struct pot_tree_entry } pot_tree_entry_t; +typedef struct pot_orig_line_entry +{ + u8 *hash_buf; + int hash_len; + int line_pos; + +} pot_orig_line_entry_t; + typedef struct restore_data { int version; @@ -1809,6 +1888,7 @@ typedef struct user_options bool brain_host_chgd; bool brain_port_chgd; bool brain_password_chgd; + bool brain_server_timer_chgd; #endif bool hash_mode_chgd; bool hccapx_message_pair_chgd; @@ -1851,6 +1931,8 @@ typedef struct user_options bool machine_readable; bool markov_classic; bool markov_disable; + bool backend_ignore_cuda; + bool backend_ignore_opencl; bool backend_info; bool optimized_kernel_enable; bool outfile_autohex; @@ -1870,6 +1952,8 @@ typedef struct user_options bool stdin_timeout_abort_chgd; bool usage; bool username; + bool veracrypt_pim_start_chgd; + bool veracrypt_pim_stop_chgd; bool version; bool wordlist_autohex_disable; #ifdef WITH_BRAIN @@ -1905,6 +1989,7 @@ typedef struct user_options u32 bitmap_max; u32 bitmap_min; #ifdef WITH_BRAIN + u32 brain_server_timer; u32 brain_client_features; u32 brain_port; u32 brain_session; @@ -1914,6 +1999,7 @@ typedef struct user_options u32 hwmon_temp_abort; int hash_mode; u32 hccapx_message_pair; + u32 hook_threads; u32 increment_max; u32 increment_min; u32 kernel_accel; @@ -2456,6 +2542,23 @@ typedef struct thread_param } thread_param_t; +typedef struct hook_thread_param +{ + int tid; + int tsz; + + module_ctx_t *module_ctx; + status_ctx_t *status_ctx; + + hc_device_param_t *device_param; + + void *hook_salts_buf; + + u32 salt_pos; + u64 pws_cnt; + +} hook_thread_param_t; + #define MAX_TOKENS 128 #define MAX_SIGNATURES 16 diff --git a/src/Makefile b/src/Makefile index c61078a4a..ace912d1a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,6 +7,7 @@ SHARED := 0 DEBUG := 0 PRODUCTION := 0 PRODUCTION_VERSION := v5.1.0 +ENABLE_CUBIN := 1 ENABLE_BRAIN := 1 USE_SYSTEM_LZMA := 0 USE_SYSTEM_ZLIB := 0 @@ -111,25 +112,25 @@ LIBRARY_DEV_FOLDER ?= $(LIBRARY_DEV_ROOT_FOLDER)/hashcat ifeq ($(USE_SYSTEM_LZMA),0) DEPS_LZMA_PATH := deps/LZMA-SDK/C else -DEPS_LZMA_PATH := $(LIBRARY_DEV_ROOT_FOLDER)/ +DEPS_LZMA_PATH := $(LIBRARY_DEV_ROOT_FOLDER) endif ifeq ($(USE_SYSTEM_ZLIB),0) -DEPS_ZLIB_PATH := deps/zlib/ +DEPS_ZLIB_PATH := deps/zlib else -DEPS_ZLIB_PATH := $(LIBRARY_DEV_ROOT_FOLDER)/ +DEPS_ZLIB_PATH := $(LIBRARY_DEV_ROOT_FOLDER) endif ifeq ($(USE_SYSTEM_OPENCL),0) DEPS_OPENCL_PATH := deps/OpenCL-Headers else -DEPS_OPENCL_PATH := $(LIBRARY_DEV_ROOT_FOLDER)/ +DEPS_OPENCL_PATH := $(LIBRARY_DEV_ROOT_FOLDER) endif ifeq ($(USE_SYSTEM_XXHASH),0) DEPS_XXHASH_PATH := deps/xxHash else -DEPS_XXHASH_PATH := $(LIBRARY_DEV_ROOT_FOLDER)/ +DEPS_XXHASH_PATH := $(LIBRARY_DEV_ROOT_FOLDER) endif ## @@ -234,6 +235,11 @@ LFLAGS += -lxxhash endif endif +# CUDA binary cache +ifeq ($(ENABLE_CUBIN),1) +CFLAGS += -DWITH_CUBIN +endif + ## ## Native compilation target ## @@ -299,7 +305,7 @@ endif # MSYS2 EMU_OBJS_ALL := emu_general emu_inc_common emu_inc_platform emu_inc_scalar emu_inc_simd EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized EMU_OBJS_ALL += emu_inc_truecrypt_crc32 emu_inc_truecrypt_keyfile emu_inc_truecrypt_xts emu_inc_veracrypt_xts -EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 +EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 emu_inc_ecc_secp256k1 EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish OBJS_ALL := affinity autotune backend benchmark bitmap bitops combinator common convert cpt cpu_crc32 debugfile dictstat dispatch dynloader event ext_ADL ext_cuda ext_nvapi ext_nvml ext_nvrtc ext_OpenCL ext_sysfs ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL) diff --git a/src/autotune.c b/src/autotune.c index 24aa16979..bcf1ac33b 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -199,7 +199,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param u32 kernel_loops_max_reduced = kernel_loops_max; - if (1) + if (true) { double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops_min); diff --git a/src/backend.c b/src/backend.c index 832175b8a..fdc8dba83 100644 --- a/src/backend.c +++ b/src/backend.c @@ -43,6 +43,10 @@ static bool is_same_device (const hc_device_param_t *src, const hc_device_param_ if (src->pcie_device != dst->pcie_device) return false; if (src->pcie_function != dst->pcie_function) return false; + // Intel CPU and embedded GPU would survive up to here! + + if (src->opencl_device_type != dst->opencl_device_type) return false; + return true; } @@ -98,7 +102,9 @@ static bool is_same_device_type (const hc_device_param_t *src, const hc_device_p if (src->is_cuda != dst->is_cuda) return false; if (src->is_opencl != dst->is_opencl) return false; - if (src->is_cuda == true) + if (strcmp (src->device_name, dst->device_name) != 0) return false; + + if (src->is_opencl == true) { if (strcmp (src->opencl_device_vendor, dst->opencl_device_vendor) != 0) return false; if (strcmp (src->opencl_device_version, dst->opencl_device_version) != 0) return false; @@ -278,6 +284,7 @@ static bool setup_opencl_device_types_filter (hashcat_ctx_t *hashcat_ctx, const return true; } +/* static bool cuda_test_instruction (hashcat_ctx_t *hashcat_ctx, const int sm_major, const int sm_minor, const char *kernel_buf) { nvrtcProgram program; @@ -295,7 +302,7 @@ static bool cuda_test_instruction (hashcat_ctx_t *hashcat_ctx, const int sm_majo backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcCompileProgram (program, 3, (const char * const *) nvrtc_options); @@ -333,7 +340,7 @@ static bool cuda_test_instruction (hashcat_ctx_t *hashcat_ctx, const int sm_majo return false; } - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; CUmodule cuda_module; @@ -354,6 +361,7 @@ static bool cuda_test_instruction (hashcat_ctx_t *hashcat_ctx, const int sm_majo return true; } +*/ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_device_id device, const char *kernel_buf) { @@ -363,33 +371,26 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; - // LLVM seems to write an error message (if there's an error) directly to stderr - // and not (as supposted to) into buffer for later request using clGetProgramBuildInfo() + const int fd_stderr = fileno (stderr); #ifndef DEBUG - #ifndef _WIN - fflush (stderr); - int bak = fcntl(2, F_DUPFD_CLOEXEC); - int tmp = open ("/dev/null", O_WRONLY | O_CLOEXEC); - dup2 (tmp, 2); + const int stderr_bak = dup (fd_stderr); + #ifdef _WIN + const int tmp = open ("NUL", O_WRONLY); + #else + const int tmp = open ("/dev/null", O_WRONLY); + #endif + dup2 (tmp, fd_stderr); close (tmp); #endif - #endif - int CL_rc = ocl->clBuildProgram (program, 1, &device, "-Werror", NULL, NULL); // do not use the wrapper to avoid the error message + const int CL_rc = ocl->clBuildProgram (program, 1, &device, NULL, NULL, NULL); #ifndef DEBUG - #ifndef _WIN - fflush (stderr); - #ifndef __APPLE__ - dup3 (bak, 2, O_CLOEXEC); - #else - dup2 (bak, 2); - #endif - close (bak); - #endif + dup2 (stderr_bak, fd_stderr); + close (stderr_bak); #endif if (CL_rc != CL_SUCCESS) @@ -424,7 +425,7 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont return true; } -static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources, const bool force_recompile) +static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources) { HCFILE fp; @@ -439,11 +440,9 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f return false; } - #define EXTRASZ 100 + const size_t klen = st.st_size; - size_t klen = st.st_size; - - char *buf = (char *) hcmalloc (klen + 1 + EXTRASZ); + char *buf = (char *) hcmalloc (klen + 1); size_t num_read = hc_fread (buf, sizeof (char), klen, &fp); @@ -460,19 +459,6 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f buf[klen] = 0; - if (force_recompile == true) - { - // this adds some hopefully unique data to the backend kernel source - // the effect should be that backend kernel compiler caching see this as new "uncached" source - // we have to do this since they do not check for the changes only in the #include source - - time_t tlog = time (NULL); - - const int extra_len = snprintf (buf + klen, EXTRASZ, "\n//%u\n", (u32) tlog); - - klen += extra_len; - } - kernel_lengths[0] = klen; kernel_sources[0] = buf; @@ -487,7 +473,7 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f return true; } -static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, char *binary, size_t binary_size) +static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, char *binary, size_t binary_size) { if (binary_size > 0) { @@ -513,6 +499,15 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, hc_fflush (&fp); + if (hc_unlockfile (&fp) == -1) + { + hc_fclose (&fp); + + event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno)); + + return false; + } + hc_fclose (&fp); } @@ -627,6 +622,16 @@ void generate_cached_kernel_filename (const bool slow_candidates, const u32 atta } } +void generate_source_kernel_shared_filename (char *shared_dir, char *source_file) +{ + snprintf (source_file, 255, "%s/OpenCL/shared.cl", shared_dir); +} + +void generate_cached_kernel_shared_filename (char *profile_dir, const char *device_name_chksum_amp_mp, char *cached_file) +{ + snprintf (cached_file, 255, "%s/kernels/shared.%s.kernel", profile_dir, device_name_chksum_amp_mp); +} + void generate_source_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *shared_dir, char *source_file) { if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE)) @@ -667,7 +672,7 @@ int nvrtc_init (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; memset (nvrtc, 0, sizeof (NVRTC_PTR)); @@ -683,10 +688,10 @@ int nvrtc_init (hashcat_ctx_t *hashcat_ctx) char dllname[100]; - for (int major = 20; major >= 10; major--) // older than 3.x do not ship _v2 functions anyway - // older than 7.x does not support sm 5.x - // older than 8.x does not have documentation archive online, no way to check if nvrtc support whatever we need - // older than 10.x is just a theoretical limit since we define 10.1 as the minimum required version + for (int major = 20; major >= 9; major--) // older than 3.x do not ship _v2 functions anyway + // older than 7.x does not support sm 5.x + // older than 8.x does not have documentation archive online, no way to check if nvrtc support whatever we need + // older than 9.x is just a theoretical limit since we define 9.0 as the minimum required version { for (int minor = 20; minor >= 0; minor--) { @@ -737,7 +742,7 @@ void nvrtc_close (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; if (nvrtc) { @@ -756,7 +761,7 @@ int hc_nvrtcCreateProgram (hashcat_ctx_t *hashcat_ctx, nvrtcProgram *prog, const { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcCreateProgram (prog, src, name, numHeaders, headers, includeNames); @@ -774,7 +779,7 @@ int hc_nvrtcDestroyProgram (hashcat_ctx_t *hashcat_ctx, nvrtcProgram *prog) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcDestroyProgram (prog); @@ -792,7 +797,7 @@ int hc_nvrtcCompileProgram (hashcat_ctx_t *hashcat_ctx, nvrtcProgram prog, int n { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcCompileProgram (prog, numOptions, options); @@ -810,7 +815,7 @@ int hc_nvrtcGetProgramLogSize (hashcat_ctx_t *hashcat_ctx, nvrtcProgram prog, si { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcGetProgramLogSize (prog, logSizeRet); @@ -828,7 +833,7 @@ int hc_nvrtcGetProgramLog (hashcat_ctx_t *hashcat_ctx, nvrtcProgram prog, char * { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcGetProgramLog (prog, log); @@ -846,7 +851,7 @@ int hc_nvrtcGetPTXSize (hashcat_ctx_t *hashcat_ctx, nvrtcProgram prog, size_t *p { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcGetPTXSize (prog, ptxSizeRet); @@ -864,7 +869,7 @@ int hc_nvrtcGetPTX (hashcat_ctx_t *hashcat_ctx, nvrtcProgram prog, char *ptx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcGetPTX (prog, ptx); @@ -882,7 +887,7 @@ int hc_nvrtcVersion (hashcat_ctx_t *hashcat_ctx, int *major, int *minor) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - NVRTC_PTR *nvrtc = backend_ctx->nvrtc; + NVRTC_PTR *nvrtc = (NVRTC_PTR *) backend_ctx->nvrtc; const nvrtcResult NVRTC_err = nvrtc->nvrtcVersion (major, minor); @@ -902,7 +907,7 @@ int cuda_init (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; memset (cuda, 0, sizeof (CUDA_PTR)); @@ -921,19 +926,21 @@ int cuda_init (hashcat_ctx_t *hashcat_ctx) if (cuda->lib == NULL) return -1; #define HC_LOAD_FUNC_CUDA(ptr,name,cudaname,type,libname,noerr) \ - ptr->name = (type) hc_dlsym ((ptr)->lib, #cudaname); \ - if ((noerr) != -1) { \ - if (!(ptr)->name) { \ - if ((noerr) == 1) { \ - event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ - return -1; \ - } \ - if ((noerr) != 1) { \ - event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ - return 0; \ + do { \ + ptr->name = (type) hc_dlsym ((ptr)->lib, #cudaname); \ + if ((noerr) != -1) { \ + if (!(ptr)->name) { \ + if ((noerr) == 1) { \ + event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return -1; \ + } \ + if ((noerr) != 1) { \ + event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return 0; \ + } \ } \ } \ - } + } while (0) // finding the right symbol is a PITA, because of the _v2 suffix // a good reference is cuda.h itself @@ -992,6 +999,12 @@ int cuda_init (hashcat_ctx_t *hashcat_ctx) HC_LOAD_FUNC_CUDA (cuda, cuStreamDestroy, cuStreamDestroy_v2, CUDA_CUSTREAMDESTROY, CUDA, 1); HC_LOAD_FUNC_CUDA (cuda, cuStreamSynchronize, cuStreamSynchronize, CUDA_CUSTREAMSYNCHRONIZE, CUDA, 1); HC_LOAD_FUNC_CUDA (cuda, cuStreamWaitEvent, cuStreamWaitEvent, CUDA_CUSTREAMWAITEVENT, CUDA, 1); + #if defined (WITH_CUBIN) + HC_LOAD_FUNC_CUDA (cuda, cuLinkCreate, cuLinkCreate_v2, CUDA_CULINKCREATE, CUDA, 1); + HC_LOAD_FUNC_CUDA (cuda, cuLinkAddData, cuLinkAddData_v2, CUDA_CULINKADDDATA, CUDA, 1); + HC_LOAD_FUNC_CUDA (cuda, cuLinkDestroy, cuLinkDestroy, CUDA_CULINKDESTROY, CUDA, 1); + HC_LOAD_FUNC_CUDA (cuda, cuLinkComplete, cuLinkComplete, CUDA_CULINKCOMPLETE, CUDA, 1); + #endif return 0; } @@ -1000,7 +1013,7 @@ void cuda_close (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; if (cuda) { @@ -1019,7 +1032,7 @@ int hc_cuInit (hashcat_ctx_t *hashcat_ctx, unsigned int Flags) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuInit (Flags); @@ -1046,7 +1059,7 @@ int hc_cuDeviceGetAttribute (hashcat_ctx_t *hashcat_ctx, int *pi, CUdevice_attri { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuDeviceGetAttribute (pi, attrib, dev); @@ -1073,7 +1086,7 @@ int hc_cuDeviceGetCount (hashcat_ctx_t *hashcat_ctx, int *count) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuDeviceGetCount (count); @@ -1100,7 +1113,7 @@ int hc_cuDeviceGet (hashcat_ctx_t *hashcat_ctx, CUdevice* device, int ordinal) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuDeviceGet (device, ordinal); @@ -1127,7 +1140,7 @@ int hc_cuDeviceGetName (hashcat_ctx_t *hashcat_ctx, char *name, int len, CUdevic { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuDeviceGetName (name, len, dev); @@ -1154,7 +1167,7 @@ int hc_cuDeviceTotalMem (hashcat_ctx_t *hashcat_ctx, size_t *bytes, CUdevice dev { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuDeviceTotalMem (bytes, dev); @@ -1181,7 +1194,7 @@ int hc_cuDriverGetVersion (hashcat_ctx_t *hashcat_ctx, int *driverVersion) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuDriverGetVersion (driverVersion); @@ -1208,7 +1221,7 @@ int hc_cuCtxCreate (hashcat_ctx_t *hashcat_ctx, CUcontext *pctx, unsigned int fl { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxCreate (pctx, flags, dev); @@ -1235,7 +1248,7 @@ int hc_cuCtxDestroy (hashcat_ctx_t *hashcat_ctx, CUcontext ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxDestroy (ctx); @@ -1262,7 +1275,7 @@ int hc_cuModuleLoadDataEx (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const v { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuModuleLoadDataEx (module, image, numOptions, options, optionValues); @@ -1285,58 +1298,11 @@ int hc_cuModuleLoadDataEx (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const v return 0; } -int hc_cuModuleLoadDataExLog (hashcat_ctx_t *hashcat_ctx, CUmodule *module, const void *image) -{ - #define LOG_SIZE 8192 - - char *info_log = hcmalloc (LOG_SIZE); - char *error_log = hcmalloc (LOG_SIZE); - - CUjit_option opts[6]; - void *vals[6]; - - opts[0] = CU_JIT_TARGET_FROM_CUCONTEXT; - vals[0] = (void *) 0; - - opts[1] = CU_JIT_LOG_VERBOSE; - vals[1] = (void *) 1; - - opts[2] = CU_JIT_INFO_LOG_BUFFER; - vals[2] = (void *) info_log; - - opts[3] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; - vals[3] = (void *) LOG_SIZE; - - opts[4] = CU_JIT_ERROR_LOG_BUFFER; - vals[4] = (void *) error_log; - - opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES; - vals[5] = (void *) LOG_SIZE; - - const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataEx (hashcat_ctx, module, image, 6, opts, vals); - - #if defined (DEBUG) - printf ("cuModuleLoadDataEx() Info Log (%d):\n%s\n\n", (int) strlen (info_log), info_log); - printf ("cuModuleLoadDataEx() Error Log (%d):\n%s\n\n", (int) strlen (error_log), error_log); - #else - if (rc_cuModuleLoadDataEx == -1) - { - printf ("cuModuleLoadDataEx() Info Log (%d):\n%s\n\n", (int) strlen (info_log), info_log); - printf ("cuModuleLoadDataEx() Error Log (%d):\n%s\n\n", (int) strlen (error_log), error_log); - } - #endif - - hcfree (info_log); - hcfree (error_log); - - return rc_cuModuleLoadDataEx; -} - int hc_cuModuleUnload (hashcat_ctx_t *hashcat_ctx, CUmodule hmod) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuModuleUnload (hmod); @@ -1363,7 +1329,7 @@ int hc_cuCtxSetCurrent (hashcat_ctx_t *hashcat_ctx, CUcontext ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxSetCurrent (ctx); @@ -1390,7 +1356,7 @@ int hc_cuMemAlloc (hashcat_ctx_t *hashcat_ctx, CUdeviceptr *dptr, size_t bytesiz { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuMemAlloc (dptr, bytesize); @@ -1417,7 +1383,7 @@ int hc_cuMemFree (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dptr) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuMemFree (dptr); @@ -1444,7 +1410,7 @@ int hc_cuMemcpyDtoH (hashcat_ctx_t *hashcat_ctx, void *dstHost, CUdeviceptr srcD { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuMemcpyDtoH (dstHost, srcDevice, ByteCount); @@ -1471,7 +1437,7 @@ int hc_cuMemcpyDtoD (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dstDevice, CUdevice { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuMemcpyDtoD (dstDevice, srcDevice, ByteCount); @@ -1498,7 +1464,7 @@ int hc_cuMemcpyHtoD (hashcat_ctx_t *hashcat_ctx, CUdeviceptr dstDevice, const vo { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuMemcpyHtoD (dstDevice, srcHost, ByteCount); @@ -1525,7 +1491,7 @@ int hc_cuModuleGetFunction (hashcat_ctx_t *hashcat_ctx, CUfunction *hfunc, CUmod { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuModuleGetFunction (hfunc, hmod, name); @@ -1552,7 +1518,7 @@ int hc_cuModuleGetGlobal (hashcat_ctx_t *hashcat_ctx, CUdeviceptr *dptr, size_t { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuModuleGetGlobal (dptr, bytes, hmod, name); @@ -1579,7 +1545,7 @@ int hc_cuMemGetInfo (hashcat_ctx_t *hashcat_ctx, size_t *free, size_t *total) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuMemGetInfo (free, total); @@ -1606,7 +1572,7 @@ int hc_cuFuncGetAttribute (hashcat_ctx_t *hashcat_ctx, int *pi, CUfunction_attri { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuFuncGetAttribute (pi, attrib, hfunc); @@ -1633,7 +1599,7 @@ int hc_cuFuncSetAttribute (hashcat_ctx_t *hashcat_ctx, CUfunction hfunc, CUfunct { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuFuncSetAttribute (hfunc, attrib, value); @@ -1660,7 +1626,7 @@ int hc_cuStreamCreate (hashcat_ctx_t *hashcat_ctx, CUstream *phStream, unsigned { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuStreamCreate (phStream, Flags); @@ -1687,7 +1653,7 @@ int hc_cuStreamDestroy (hashcat_ctx_t *hashcat_ctx, CUstream hStream) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuStreamDestroy (hStream); @@ -1714,7 +1680,7 @@ int hc_cuStreamSynchronize (hashcat_ctx_t *hashcat_ctx, CUstream hStream) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuStreamSynchronize (hStream); @@ -1741,7 +1707,7 @@ int hc_cuLaunchKernel (hashcat_ctx_t *hashcat_ctx, CUfunction f, unsigned int gr { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuLaunchKernel (f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, hStream, kernelParams, extra); @@ -1768,7 +1734,7 @@ int hc_cuCtxSynchronize (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxSynchronize (); @@ -1795,7 +1761,7 @@ int hc_cuEventCreate (hashcat_ctx_t *hashcat_ctx, CUevent *phEvent, unsigned int { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuEventCreate (phEvent, Flags); @@ -1822,7 +1788,7 @@ int hc_cuEventDestroy (hashcat_ctx_t *hashcat_ctx, CUevent hEvent) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuEventDestroy (hEvent); @@ -1849,7 +1815,7 @@ int hc_cuEventElapsedTime (hashcat_ctx_t *hashcat_ctx, float *pMilliseconds, CUe { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuEventElapsedTime (pMilliseconds, hStart, hEnd); @@ -1876,7 +1842,7 @@ int hc_cuEventQuery (hashcat_ctx_t *hashcat_ctx, CUevent hEvent) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuEventQuery (hEvent); @@ -1903,7 +1869,7 @@ int hc_cuEventRecord (hashcat_ctx_t *hashcat_ctx, CUevent hEvent, CUstream hStre { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuEventRecord (hEvent, hStream); @@ -1930,7 +1896,7 @@ int hc_cuEventSynchronize (hashcat_ctx_t *hashcat_ctx, CUevent hEvent) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuEventSynchronize (hEvent); @@ -1957,7 +1923,7 @@ int hc_cuCtxSetCacheConfig (hashcat_ctx_t *hashcat_ctx, CUfunc_cache config) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxSetCacheConfig (config); @@ -1984,7 +1950,7 @@ int hc_cuCtxPushCurrent (hashcat_ctx_t *hashcat_ctx, CUcontext ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxPushCurrent (ctx); @@ -2011,7 +1977,7 @@ int hc_cuCtxPopCurrent (hashcat_ctx_t *hashcat_ctx, CUcontext *pctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - CUDA_PTR *cuda = backend_ctx->cuda; + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; const CUresult CU_err = cuda->cuCtxPopCurrent (pctx); @@ -2034,6 +2000,113 @@ int hc_cuCtxPopCurrent (hashcat_ctx_t *hashcat_ctx, CUcontext *pctx) return 0; } +int hc_cuLinkCreate (hashcat_ctx_t *hashcat_ctx, unsigned int numOptions, CUjit_option *options, void **optionValues, CUlinkState *stateOut) +{ + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; + + const CUresult CU_err = cuda->cuLinkCreate (numOptions, options, optionValues, stateOut); + + if (CU_err != CUDA_SUCCESS) + { + const char *pStr = NULL; + + if (cuda->cuGetErrorString (CU_err, &pStr) == CUDA_SUCCESS) + { + event_log_error (hashcat_ctx, "cuLinkCreate(): %s", pStr); + } + else + { + event_log_error (hashcat_ctx, "cuLinkCreate(): %d", CU_err); + } + + return -1; + } + + return 0; +} + +int hc_cuLinkAddData (hashcat_ctx_t *hashcat_ctx, CUlinkState state, CUjitInputType type, void *data, size_t size, const char *name, unsigned int numOptions, CUjit_option *options, void **optionValues) +{ + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; + + const CUresult CU_err = cuda->cuLinkAddData (state, type, data, size, name, numOptions, options, optionValues); + + if (CU_err != CUDA_SUCCESS) + { + const char *pStr = NULL; + + if (cuda->cuGetErrorString (CU_err, &pStr) == CUDA_SUCCESS) + { + event_log_error (hashcat_ctx, "cuLinkAddData(): %s", pStr); + } + else + { + event_log_error (hashcat_ctx, "cuLinkAddData(): %d", CU_err); + } + + return -1; + } + + return 0; +} + +int hc_cuLinkDestroy (hashcat_ctx_t *hashcat_ctx, CUlinkState state) +{ + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; + + const CUresult CU_err = cuda->cuLinkDestroy (state); + + if (CU_err != CUDA_SUCCESS) + { + const char *pStr = NULL; + + if (cuda->cuGetErrorString (CU_err, &pStr) == CUDA_SUCCESS) + { + event_log_error (hashcat_ctx, "cuLinkDestroy(): %s", pStr); + } + else + { + event_log_error (hashcat_ctx, "cuLinkDestroy(): %d", CU_err); + } + + return -1; + } + + return 0; +} + +int hc_cuLinkComplete (hashcat_ctx_t *hashcat_ctx, CUlinkState state, void **cubinOut, size_t *sizeOut) +{ + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; + + const CUresult CU_err = cuda->cuLinkComplete (state, cubinOut, sizeOut); + + if (CU_err != CUDA_SUCCESS) + { + const char *pStr = NULL; + + if (cuda->cuGetErrorString (CU_err, &pStr) == CUDA_SUCCESS) + { + event_log_error (hashcat_ctx, "cuLinkComplete(): %s", pStr); + } + else + { + event_log_error (hashcat_ctx, "cuLinkComplete(): %d", CU_err); + } + + return -1; + } + + return 0; +} // OpenCL @@ -2041,7 +2114,7 @@ int ocl_init (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; memset (ocl, 0, sizeof (OCL_PTR)); @@ -2101,7 +2174,7 @@ void ocl_close (hashcat_ctx_t *hashcat_ctx) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; if (ocl) { @@ -2120,7 +2193,7 @@ int hc_clEnqueueNDRangeKernel (hashcat_ctx_t *hashcat_ctx, cl_command_queue comm { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clEnqueueNDRangeKernel (command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event); @@ -2138,7 +2211,7 @@ int hc_clGetEventInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_event_info { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetEventInfo (event, param_name, param_value_size, param_value, param_value_size_ret); @@ -2156,7 +2229,7 @@ int hc_clFlush (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clFlush (command_queue); @@ -2174,7 +2247,7 @@ int hc_clFinish (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clFinish (command_queue); @@ -2192,7 +2265,7 @@ int hc_clSetKernelArg (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_uint arg { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value); @@ -2210,7 +2283,7 @@ int hc_clEnqueueWriteBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue comman { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list, event); @@ -2228,7 +2301,7 @@ int hc_clEnqueueCopyBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size, num_events_in_wait_list, event_wait_list, event); @@ -2246,7 +2319,7 @@ int hc_clEnqueueReadBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, size, ptr, num_events_in_wait_list, event_wait_list, event); @@ -2264,7 +2337,7 @@ int hc_clGetPlatformIDs (hashcat_ctx_t *hashcat_ctx, cl_uint num_entries, cl_pla { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetPlatformIDs (num_entries, platforms, num_platforms); @@ -2282,7 +2355,7 @@ int hc_clGetPlatformInfo (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, c { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetPlatformInfo (platform, param_name, param_value_size, param_value, param_value_size_ret); @@ -2300,7 +2373,7 @@ int hc_clGetDeviceIDs (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_d { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices); @@ -2318,7 +2391,7 @@ int hc_clGetDeviceInfo (hashcat_ctx_t *hashcat_ctx, cl_device_id device, cl_devi { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetDeviceInfo (device, param_name, param_value_size, param_value, param_value_size_ret); @@ -2336,7 +2409,7 @@ int hc_clCreateContext (hashcat_ctx_t *hashcat_ctx, const cl_context_properties { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2356,7 +2429,7 @@ int hc_clCreateCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_ { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2376,7 +2449,7 @@ int hc_clCreateBuffer (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_mem_fl { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2396,7 +2469,7 @@ int hc_clCreateProgramWithSource (hashcat_ctx_t *hashcat_ctx, cl_context context { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2416,7 +2489,7 @@ int hc_clCreateProgramWithBinary (hashcat_ctx_t *hashcat_ctx, cl_context context { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2436,7 +2509,7 @@ int hc_clBuildProgram (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_uint n { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data); @@ -2454,7 +2527,7 @@ int hc_clCreateKernel (hashcat_ctx_t *hashcat_ctx, cl_program program, const cha { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2474,7 +2547,7 @@ int hc_clReleaseMemObject (hashcat_ctx_t *hashcat_ctx, cl_mem mem) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clReleaseMemObject (mem); @@ -2492,7 +2565,7 @@ int hc_clReleaseKernel (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clReleaseKernel (kernel); @@ -2510,7 +2583,7 @@ int hc_clReleaseProgram (hashcat_ctx_t *hashcat_ctx, cl_program program) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clReleaseProgram (program); @@ -2528,7 +2601,7 @@ int hc_clReleaseCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_command_queue comma { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clReleaseCommandQueue (command_queue); @@ -2546,7 +2619,7 @@ int hc_clReleaseContext (hashcat_ctx_t *hashcat_ctx, cl_context context) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clReleaseContext (context); @@ -2564,7 +2637,7 @@ int hc_clEnqueueMapBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_ { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; cl_int CL_err; @@ -2584,7 +2657,7 @@ int hc_clEnqueueUnmapMemObject (hashcat_ctx_t *hashcat_ctx, cl_command_queue com { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event); @@ -2602,7 +2675,7 @@ int hc_clGetKernelWorkGroupInfo (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, c { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret); @@ -2620,7 +2693,7 @@ int hc_clGetProgramBuildInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetProgramBuildInfo (program, device, param_name, param_value_size, param_value, param_value_size_ret); @@ -2638,7 +2711,7 @@ int hc_clGetProgramInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_prog { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetProgramInfo (program, param_name, param_value_size, param_value, param_value_size_ret); @@ -2656,7 +2729,7 @@ int hc_clWaitForEvents (hashcat_ctx_t *hashcat_ctx, cl_uint num_events, const cl { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clWaitForEvents (num_events, event_list); @@ -2674,7 +2747,7 @@ int hc_clGetEventProfilingInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_p { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clGetEventProfilingInfo (event, param_name, param_value_size, param_value, param_value_size_ret); @@ -2692,7 +2765,7 @@ int hc_clReleaseEvent (hashcat_ctx_t *hashcat_ctx, cl_event event) { backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; const cl_int CL_err = ocl->clReleaseEvent (event); @@ -2786,7 +2859,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, } else { - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL) { const u32 size_tm = device_param->size_tm; @@ -2869,24 +2942,60 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (device_param->is_cuda == true) { - if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1; + if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, pws_cnt * hashconfig->hook_size) == -1) return -1; } if (device_param->is_opencl == true) { - if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, pws_cnt * hashconfig->hook_size, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; } - module_ctx->module_hook12 (device_param, hashes->hook_salts_buf, salt_pos, pws_cnt); + const int hook_threads = (int) user_options->hook_threads; + + hook_thread_param_t *hook_threads_param = (hook_thread_param_t *) hccalloc (hook_threads, sizeof (hook_thread_param_t)); + + for (int i = 0; i < hook_threads; i++) + { + hook_thread_param_t *hook_thread_param = hook_threads_param + i; + + hook_thread_param->tid = i; + hook_thread_param->tsz = hook_threads; + + hook_thread_param->module_ctx = module_ctx; + hook_thread_param->status_ctx = status_ctx; + + hook_thread_param->device_param = device_param; + + hook_thread_param->hook_salts_buf = hashes->hook_salts_buf; + + hook_thread_param->salt_pos = salt_pos; + + hook_thread_param->pws_cnt = pws_cnt; + } + + hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hook_threads, sizeof (hc_thread_t)); + + for (int i = 0; i < hook_threads; i++) + { + hook_thread_param_t *hook_thread_param = hook_threads_param + i; + + hc_thread_create (c_threads[i], hook12_thread, hook_thread_param); + } + + hc_thread_wait (hook_threads, c_threads); + + hcfree (c_threads); + + hcfree (hook_threads_param); if (device_param->is_cuda == true) { - if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks) == -1) return -1; + if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, pws_cnt * hashconfig->hook_size) == -1) return -1; } if (device_param->is_opencl == true) { - if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, pws_cnt * hashconfig->hook_size, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; } } } @@ -2908,6 +3017,11 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, pws_cnt, true, slow_iteration) == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED) + { + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, pws_cnt, true, slow_iteration) == -1) return -1; + } + //bug? //while (status_ctx->run_thread_level2 == false) break; if (status_ctx->run_thread_level2 == false) break; @@ -2949,24 +3063,60 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (device_param->is_cuda == true) { - if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1; + if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, pws_cnt * hashconfig->hook_size) == -1) return -1; } if (device_param->is_opencl == true) { - if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, pws_cnt * hashconfig->hook_size, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; } - module_ctx->module_hook23 (device_param, hashes->hook_salts_buf, salt_pos, pws_cnt); + const int hook_threads = (int) user_options->hook_threads; + + hook_thread_param_t *hook_threads_param = (hook_thread_param_t *) hccalloc (hook_threads, sizeof (hook_thread_param_t)); + + for (int i = 0; i < hook_threads; i++) + { + hook_thread_param_t *hook_thread_param = hook_threads_param + i; + + hook_thread_param->tid = i; + hook_thread_param->tsz = hook_threads; + + hook_thread_param->module_ctx = module_ctx; + hook_thread_param->status_ctx = status_ctx; + + hook_thread_param->device_param = device_param; + + hook_thread_param->hook_salts_buf = hashes->hook_salts_buf; + + hook_thread_param->salt_pos = salt_pos; + + hook_thread_param->pws_cnt = pws_cnt; + } + + hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hook_threads, sizeof (hc_thread_t)); + + for (int i = 0; i < hook_threads; i++) + { + hook_thread_param_t *hook_thread_param = hook_threads_param + i; + + hc_thread_create (c_threads[i], hook23_thread, hook_thread_param); + } + + hc_thread_wait (hook_threads, c_threads); + + hcfree (c_threads); + + hcfree (hook_threads_param); if (device_param->is_cuda == true) { - if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks) == -1) return -1; + if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, pws_cnt * hashconfig->hook_size) == -1) return -1; } if (device_param->is_opencl == true) { - if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, pws_cnt * hashconfig->hook_size, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; } } } @@ -3030,6 +3180,34 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_cnt, false, 0) == -1) return -1; } } + + /* + * maybe we should add this zero of temporary buffers + * however it drops the performance from 7055338 to 7010621 + + if (device_param->is_cuda == true) + { + if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_tmps, device_param->size_tmps) == -1) return -1; + } + + if (device_param->is_opencl == true) + { + if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_tmps, device_param->size_tmps) == -1) return -1; + } + */ + + if ((hashconfig->opts_type & OPTS_TYPE_HOOK12) || (hashconfig->opts_type & OPTS_TYPE_HOOK23)) + { + if (device_param->is_cuda == true) + { + if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_hooks, pws_cnt * hashconfig->hook_size) == -1) return -1; + } + + if (device_param->is_opencl == true) + { + if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_hooks, pws_cnt * hashconfig->hook_size) == -1) return -1; + } + } } return 0; @@ -3243,24 +3421,81 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - const user_options_t *user_options = hashcat_ctx->user_options; u64 kernel_threads = 0; + u64 dynamic_shared_mem = 0; switch (kern_run) { - case KERN_RUN_1: kernel_threads = device_param->kernel_wgs1; break; - case KERN_RUN_12: kernel_threads = device_param->kernel_wgs12; break; - case KERN_RUN_2: kernel_threads = device_param->kernel_wgs2; break; - case KERN_RUN_23: kernel_threads = device_param->kernel_wgs23; break; - case KERN_RUN_3: kernel_threads = device_param->kernel_wgs3; break; - case KERN_RUN_4: kernel_threads = device_param->kernel_wgs4; break; - case KERN_RUN_INIT2: kernel_threads = device_param->kernel_wgs_init2; break; - case KERN_RUN_LOOP2: kernel_threads = device_param->kernel_wgs_loop2; break; - case KERN_RUN_AUX1: kernel_threads = device_param->kernel_wgs_aux1; break; - case KERN_RUN_AUX2: kernel_threads = device_param->kernel_wgs_aux2; break; - case KERN_RUN_AUX3: kernel_threads = device_param->kernel_wgs_aux3; break; - case KERN_RUN_AUX4: kernel_threads = device_param->kernel_wgs_aux4; break; + case KERN_RUN_1: + kernel_threads = device_param->kernel_wgs1; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size1; + break; + case KERN_RUN_12: + kernel_threads = device_param->kernel_wgs12; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size12; + break; + case KERN_RUN_2: + kernel_threads = device_param->kernel_wgs2; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size2; + break; + case KERN_RUN_2E: + kernel_threads = device_param->kernel_wgs2e; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size2e; + break; + case KERN_RUN_23: + kernel_threads = device_param->kernel_wgs23; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size23; + break; + case KERN_RUN_3: + kernel_threads = device_param->kernel_wgs3; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size3; + break; + case KERN_RUN_4: + kernel_threads = device_param->kernel_wgs4; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size4; + break; + case KERN_RUN_INIT2: + kernel_threads = device_param->kernel_wgs_init2; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size_init2; + break; + case KERN_RUN_LOOP2: + kernel_threads = device_param->kernel_wgs_loop2; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size_loop2; + break; + case KERN_RUN_AUX1: + kernel_threads = device_param->kernel_wgs_aux1; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size_aux1; + break; + case KERN_RUN_AUX2: + kernel_threads = device_param->kernel_wgs_aux2; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size_aux2; + break; + case KERN_RUN_AUX3: + kernel_threads = device_param->kernel_wgs_aux3; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size_aux3; + break; + case KERN_RUN_AUX4: + kernel_threads = device_param->kernel_wgs_aux4; + dynamic_shared_mem = device_param->kernel_dynamic_local_mem_size_aux4; + break; + } + + if ((hashconfig->opts_type & OPTS_TYPE_DYNAMIC_SHARED) == 0) + { + dynamic_shared_mem = 0; + } + + if (device_param->is_cuda == true) + { + if ((device_param->kernel_dynamic_local_mem_size_memset % device_param->device_local_mem_size) == 0) + { + // this is the case Compute Capability 7.5 + // there is also Compute Capability 7.0 which offers a larger dynamic local size access + // however, if it's an exact multiple the driver can optimize this for us more efficient + + dynamic_shared_mem = 0; + } } kernel_threads = MIN (kernel_threads, device_param->kernel_threads); @@ -3280,6 +3515,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con case KERN_RUN_1: cuda_function = device_param->cuda_function1; break; case KERN_RUN_12: cuda_function = device_param->cuda_function12; break; case KERN_RUN_2: cuda_function = device_param->cuda_function2; break; + case KERN_RUN_2E: cuda_function = device_param->cuda_function2e; break; case KERN_RUN_23: cuda_function = device_param->cuda_function23; break; case KERN_RUN_3: cuda_function = device_param->cuda_function3; break; case KERN_RUN_4: cuda_function = device_param->cuda_function4; break; @@ -3290,48 +3526,41 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con case KERN_RUN_AUX3: cuda_function = device_param->cuda_function_aux3; break; case KERN_RUN_AUX4: cuda_function = device_param->cuda_function_aux4; break; } + + if (hc_cuFuncSetAttribute (hashcat_ctx, cuda_function, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, dynamic_shared_mem) == -1) return -1; } + if (kernel_threads == 0) kernel_threads = 1; + num_elements = CEILDIV (num_elements, kernel_threads); - if ((hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) && (user_options->attack_mode == ATTACK_MODE_BF)) + if (kern_run == KERN_RUN_1) { - if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event1, device_param->cuda_stream) == -1) return -1; - - if (hc_cuLaunchKernel (hashcat_ctx, cuda_function, num_elements, 32, 1, kernel_threads, 1, 1, 0, device_param->cuda_stream, device_param->kernel_params, NULL) == -1) return -1; - - if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event2, device_param->cuda_stream) == -1) return -1; + if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_INIT) + { + num_elements = CEILDIV (num_elements, device_param->vector_width); + } } - else + else if (kern_run == KERN_RUN_2) { - if (kern_run == KERN_RUN_1) + if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_LOOP) { - if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_INIT) - { - num_elements = CEILDIV (num_elements, device_param->vector_width); - } + num_elements = CEILDIV (num_elements, device_param->vector_width); } - else if (kern_run == KERN_RUN_2) - { - if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_LOOP) - { - num_elements = CEILDIV (num_elements, device_param->vector_width); - } - } - else if (kern_run == KERN_RUN_3) - { - if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_COMP) - { - num_elements = CEILDIV (num_elements, device_param->vector_width); - } - } - - if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event1, device_param->cuda_stream) == -1) return -1; - - if (hc_cuLaunchKernel (hashcat_ctx, cuda_function, num_elements, 1, 1, kernel_threads, 1, 1, 0, device_param->cuda_stream, device_param->kernel_params, NULL) == -1) return -1; - - if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event2, device_param->cuda_stream) == -1) return -1; } + else if (kern_run == KERN_RUN_3) + { + if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_COMP) + { + num_elements = CEILDIV (num_elements, device_param->vector_width); + } + } + + if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event1, device_param->cuda_stream) == -1) return -1; + + if (hc_cuLaunchKernel (hashcat_ctx, cuda_function, num_elements, 1, 1, kernel_threads, 1, 1, dynamic_shared_mem, device_param->cuda_stream, device_param->kernel_params, NULL) == -1) return -1; + + if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event2, device_param->cuda_stream) == -1) return -1; if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1; @@ -3369,6 +3598,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con case KERN_RUN_1: opencl_kernel = device_param->opencl_kernel1; break; case KERN_RUN_12: opencl_kernel = device_param->opencl_kernel12; break; case KERN_RUN_2: opencl_kernel = device_param->opencl_kernel2; break; + case KERN_RUN_2E: opencl_kernel = device_param->opencl_kernel2e; break; case KERN_RUN_23: opencl_kernel = device_param->opencl_kernel23; break; case KERN_RUN_3: opencl_kernel = device_param->opencl_kernel3; break; case KERN_RUN_4: opencl_kernel = device_param->opencl_kernel4; break; @@ -3400,44 +3630,34 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con cl_event opencl_event; - if ((hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) && (user_options->attack_mode == ATTACK_MODE_BF)) + if (kern_run == KERN_RUN_1) { - const size_t global_work_size[3] = { num_elements, 32, 1 }; - const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - - if (hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->opencl_command_queue, opencl_kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, &opencl_event) == -1) return -1; + if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_INIT) + { + num_elements = CEILDIV (num_elements, device_param->vector_width); + } } - else + else if (kern_run == KERN_RUN_2) { - if (kern_run == KERN_RUN_1) + if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_LOOP) { - if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_INIT) - { - num_elements = CEILDIV (num_elements, device_param->vector_width); - } + num_elements = CEILDIV (num_elements, device_param->vector_width); } - else if (kern_run == KERN_RUN_2) - { - if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_LOOP) - { - num_elements = CEILDIV (num_elements, device_param->vector_width); - } - } - else if (kern_run == KERN_RUN_3) - { - if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_COMP) - { - num_elements = CEILDIV (num_elements, device_param->vector_width); - } - } - - num_elements = round_up_multiple_64 (num_elements, kernel_threads); - - const size_t global_work_size[3] = { num_elements, 1, 1 }; - const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - - if (hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->opencl_command_queue, opencl_kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, &opencl_event) == -1) return -1; } + else if (kern_run == KERN_RUN_3) + { + if (hashconfig->opti_type & OPTI_TYPE_SLOW_HASH_SIMD_COMP) + { + num_elements = CEILDIV (num_elements, device_param->vector_width); + } + } + + num_elements = round_up_multiple_64 (num_elements, kernel_threads); + + const size_t global_work_size[3] = { num_elements, 1, 1 }; + const size_t local_work_size[3] = { kernel_threads, 1, 1 }; + + if (hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->opencl_command_queue, opencl_kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, &opencl_event) == -1) return -1; if (hc_clFlush (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1; @@ -3445,14 +3665,14 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con const u32 iterationm = iteration % EXPECTED_ITERATIONS; - cl_int opencl_event_status; - - size_t param_value_size_ret; - - if (hc_clGetEventInfo (hashcat_ctx, opencl_event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof (opencl_event_status), &opencl_event_status, ¶m_value_size_ret) == -1) return -1; - if (device_param->spin_damp > 0) { + cl_int opencl_event_status; + + size_t param_value_size_ret; + + if (hc_clGetEventInfo (hashcat_ctx, opencl_event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof (opencl_event_status), &opencl_event_status, ¶m_value_size_ret) == -1) return -1; + double spin_total = device_param->spin_damp; while (opencl_event_status != CL_COMPLETE) @@ -3463,6 +3683,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con { case KERN_RUN_1: if (device_param->exec_us_prev1[iterationm] > 0) usleep ((useconds_t) (device_param->exec_us_prev1[iterationm] * device_param->spin_damp)); break; case KERN_RUN_2: if (device_param->exec_us_prev2[iterationm] > 0) usleep ((useconds_t) (device_param->exec_us_prev2[iterationm] * device_param->spin_damp)); break; + case KERN_RUN_2E: if (device_param->exec_us_prev2e[iterationm] > 0) usleep ((useconds_t) (device_param->exec_us_prev2e[iterationm] * device_param->spin_damp)); break; case KERN_RUN_3: if (device_param->exec_us_prev3[iterationm] > 0) usleep ((useconds_t) (device_param->exec_us_prev3[iterationm] * device_param->spin_damp)); break; case KERN_RUN_4: if (device_param->exec_us_prev4[iterationm] > 0) usleep ((useconds_t) (device_param->exec_us_prev4[iterationm] * device_param->spin_damp)); break; case KERN_RUN_INIT2: if (device_param->exec_us_prev_init2[iterationm] > 0) usleep ((useconds_t) (device_param->exec_us_prev_init2[iterationm] * device_param->spin_damp)); break; @@ -3506,6 +3727,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con { case KERN_RUN_1: device_param->exec_us_prev1[iterationm] = exec_us; break; case KERN_RUN_2: device_param->exec_us_prev2[iterationm] = exec_us; break; + case KERN_RUN_2E: device_param->exec_us_prev2e[iterationm] = exec_us; break; case KERN_RUN_3: device_param->exec_us_prev3[iterationm] = exec_us; break; case KERN_RUN_4: device_param->exec_us_prev4[iterationm] = exec_us; break; case KERN_RUN_INIT2: device_param->exec_us_prev_init2[iterationm] = exec_us; break; @@ -4637,137 +4859,155 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) * Load and map CUDA library calls, then init CUDA */ - CUDA_PTR *cuda = (CUDA_PTR *) hcmalloc (sizeof (CUDA_PTR)); + int rc_cuda_init = -1; - backend_ctx->cuda = cuda; - - int rc_cuda_init = cuda_init (hashcat_ctx); - - if (rc_cuda_init == -1) + if (user_options->backend_ignore_cuda == false) { - cuda_close (hashcat_ctx); - } + CUDA_PTR *cuda = (CUDA_PTR *) hcmalloc (sizeof (CUDA_PTR)); - /** - * Load and map NVRTC library calls - */ + backend_ctx->cuda = cuda; - NVRTC_PTR *nvrtc = (NVRTC_PTR *) hcmalloc (sizeof (NVRTC_PTR)); + rc_cuda_init = cuda_init (hashcat_ctx); - backend_ctx->nvrtc = nvrtc; - - int rc_nvrtc_init = nvrtc_init (hashcat_ctx); - - if (rc_nvrtc_init == -1) - { - nvrtc_close (hashcat_ctx); - } - - /** - * Check if both CUDA and NVRTC were load successful - */ - - if ((rc_cuda_init == 0) && (rc_nvrtc_init == 0)) - { - // nvrtc version - - int nvrtc_major = 0; - int nvrtc_minor = 0; - - if (hc_nvrtcVersion (hashcat_ctx, &nvrtc_major, &nvrtc_minor) == -1) return -1; - - int nvrtc_driver_version = (nvrtc_major * 1000) + (nvrtc_minor * 10); - - backend_ctx->nvrtc_driver_version = nvrtc_driver_version; - - // cuda version - - int cuda_driver_version = 0; - - if (hc_cuDriverGetVersion (hashcat_ctx, &cuda_driver_version) == -1) return -1; - - backend_ctx->cuda_driver_version = cuda_driver_version; - - // some pre-check - - if ((nvrtc_driver_version < 10010) || (cuda_driver_version < 10010)) + if (rc_cuda_init == -1) { - event_log_error (hashcat_ctx, "Outdated NVIDIA CUDA Toolkit version '%d' detected!", cuda_driver_version); - - event_log_warning (hashcat_ctx, "See hashcat.net for officially supported NVIDIA CUDA Toolkit versions."); - event_log_warning (hashcat_ctx, NULL); - - return -1; + cuda_close (hashcat_ctx); } - } - else - { - rc_cuda_init = -1; - rc_nvrtc_init = -1; - cuda_close (hashcat_ctx); - nvrtc_close (hashcat_ctx); + /** + * Load and map NVRTC library calls + */ + + NVRTC_PTR *nvrtc = (NVRTC_PTR *) hcmalloc (sizeof (NVRTC_PTR)); + + backend_ctx->nvrtc = nvrtc; + + int rc_nvrtc_init = nvrtc_init (hashcat_ctx); + + if (rc_nvrtc_init == -1) + { + nvrtc_close (hashcat_ctx); + } + + /** + * Check if both CUDA and NVRTC were load successful + */ + + if ((rc_cuda_init == 0) && (rc_nvrtc_init == 0)) + { + // nvrtc version + + int nvrtc_major = 0; + int nvrtc_minor = 0; + + if (hc_nvrtcVersion (hashcat_ctx, &nvrtc_major, &nvrtc_minor) == -1) return -1; + + int nvrtc_driver_version = (nvrtc_major * 1000) + (nvrtc_minor * 10); + + backend_ctx->nvrtc_driver_version = nvrtc_driver_version; + + if (nvrtc_driver_version < 9000) + { + event_log_error (hashcat_ctx, "Outdated NVIDIA NVRTC driver version '%d' detected!", nvrtc_driver_version); + + event_log_warning (hashcat_ctx, "See hashcat.net for officially supported NVIDIA CUDA Toolkit versions."); + event_log_warning (hashcat_ctx, NULL); + + return -1; + } + + // cuda version + + int cuda_driver_version = 0; + + if (hc_cuDriverGetVersion (hashcat_ctx, &cuda_driver_version) == -1) return -1; + + backend_ctx->cuda_driver_version = cuda_driver_version; + + if (cuda_driver_version < 9000) + { + event_log_error (hashcat_ctx, "Outdated NVIDIA CUDA driver version '%d' detected!", cuda_driver_version); + + event_log_warning (hashcat_ctx, "See hashcat.net for officially supported NVIDIA CUDA Toolkit versions."); + event_log_warning (hashcat_ctx, NULL); + + return -1; + } + } + else + { + rc_cuda_init = -1; + rc_nvrtc_init = -1; + + cuda_close (hashcat_ctx); + nvrtc_close (hashcat_ctx); + } } /** * Load and map OpenCL library calls */ - OCL_PTR *ocl = (OCL_PTR *) hcmalloc (sizeof (OCL_PTR)); + int rc_ocl_init = -1; - backend_ctx->ocl = ocl; - - const int rc_ocl_init = ocl_init (hashcat_ctx); - - if (rc_ocl_init == -1) + if (user_options->backend_ignore_opencl == false) { - ocl_close (hashcat_ctx); + OCL_PTR *ocl = (OCL_PTR *) hcmalloc (sizeof (OCL_PTR)); + + backend_ctx->ocl = ocl; + + rc_ocl_init = ocl_init (hashcat_ctx); + + if (rc_ocl_init == -1) + { + ocl_close (hashcat_ctx); + } + + /** + * return if both CUDA and OpenCL initialization failed + */ + + if ((rc_cuda_init == -1) && (rc_ocl_init == -1)) + { + event_log_error (hashcat_ctx, "ATTENTION! No OpenCL or CUDA installation found."); + + event_log_warning (hashcat_ctx, "You are probably missing the CUDA or OpenCL runtime installation."); + event_log_warning (hashcat_ctx, NULL); + + #if defined (__linux__) + event_log_warning (hashcat_ctx, "* AMD GPUs on Linux require this driver:"); + event_log_warning (hashcat_ctx, " \"RadeonOpenCompute (ROCm)\" Software Platform (1.6.180 or later)"); + #elif defined (_WIN) + event_log_warning (hashcat_ctx, "* AMD GPUs on Windows require this driver:"); + event_log_warning (hashcat_ctx, " \"AMD Radeon Software Crimson Edition\" (15.12 or later)"); + #endif + + event_log_warning (hashcat_ctx, "* Intel CPUs require this runtime:"); + event_log_warning (hashcat_ctx, " \"OpenCL Runtime for Intel Core and Intel Xeon Processors\" (16.1.1 or later)"); + + #if defined (__linux__) + event_log_warning (hashcat_ctx, "* Intel GPUs on Linux require this driver:"); + event_log_warning (hashcat_ctx, " \"OpenCL 2.0 GPU Driver Package for Linux\" (2.0 or later)"); + #elif defined (_WIN) + event_log_warning (hashcat_ctx, "* Intel GPUs on Windows require this driver:"); + event_log_warning (hashcat_ctx, " \"OpenCL Driver for Intel Iris and Intel HD Graphics\""); + #endif + + event_log_warning (hashcat_ctx, "* NVIDIA GPUs require this runtime and/or driver (both):"); + event_log_warning (hashcat_ctx, " \"NVIDIA Driver\" (418.56 or later)"); + event_log_warning (hashcat_ctx, " \"CUDA Toolkit\" (9.0 or later)"); + event_log_warning (hashcat_ctx, NULL); + + return -1; + } + + /** + * Some permission pre-check, because AMDGPU-PRO Driver crashes if the user has no permission to do this + */ + + if (ocl_check_dri (hashcat_ctx) == -1) return -1; } - /** - * return if both CUDA and OpenCL initialization failed - */ - - if ((rc_cuda_init == -1) && (rc_ocl_init == -1)) - { - event_log_error (hashcat_ctx, "ATTENTION! No OpenCL or CUDA installation found."); - - event_log_warning (hashcat_ctx, "You are probably missing the CUDA or OpenCL runtime installation."); - event_log_warning (hashcat_ctx, NULL); - - #if defined (__linux__) - event_log_warning (hashcat_ctx, "* AMD GPUs on Linux require this driver:"); - event_log_warning (hashcat_ctx, " \"RadeonOpenCompute (ROCm)\" Software Platform (1.6.180 or later)"); - #elif defined (_WIN) - event_log_warning (hashcat_ctx, "* AMD GPUs on Windows require this driver:"); - event_log_warning (hashcat_ctx, " \"AMD Radeon Software Crimson Edition\" (15.12 or later)"); - #endif - - event_log_warning (hashcat_ctx, "* Intel CPUs require this runtime:"); - event_log_warning (hashcat_ctx, " \"OpenCL Runtime for Intel Core and Intel Xeon Processors\" (16.1.1 or later)"); - - #if defined (__linux__) - event_log_warning (hashcat_ctx, "* Intel GPUs on Linux require this driver:"); - event_log_warning (hashcat_ctx, " \"OpenCL 2.0 GPU Driver Package for Linux\" (2.0 or later)"); - #elif defined (_WIN) - event_log_warning (hashcat_ctx, "* Intel GPUs on Windows require this driver:"); - event_log_warning (hashcat_ctx, " \"OpenCL Driver for Intel Iris and Intel HD Graphics\""); - #endif - - event_log_warning (hashcat_ctx, "* NVIDIA GPUs require this runtime and/or driver (both):"); - event_log_warning (hashcat_ctx, " \"NVIDIA Driver\" (418.56 or later)"); - event_log_warning (hashcat_ctx, " \"CUDA Toolkit\" (10.1 or later)"); - event_log_warning (hashcat_ctx, NULL); - - return -1; - } - - /** - * Some permission pre-check, because AMDGPU-PRO Driver crashes if the user has no permission to do this - */ - - if (ocl_check_dri (hashcat_ctx) == -1) return -1; - /** * Backend device selection */ @@ -4807,7 +5047,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) if (backend_ctx->ocl) { #define FREE_OPENCL_CTX_ON_ERROR \ - { \ + do { \ hcfree (opencl_platforms); \ hcfree (opencl_platforms_devices); \ hcfree (opencl_platforms_devices_cnt); \ @@ -4815,7 +5055,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) hcfree (opencl_platforms_vendor); \ hcfree (opencl_platforms_vendor_id); \ hcfree (opencl_platforms_version); \ - } + } while(0) cl_platform_id *opencl_platforms = (cl_platform_id *) hccalloc (CL_PLATFORMS_MAX, sizeof (cl_platform_id)); cl_uint opencl_platforms_cnt = 0; @@ -5037,7 +5277,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_warning (hashcat_ctx, "* NVIDIA GPUs require this runtime and/or driver (both):"); event_log_warning (hashcat_ctx, " \"NVIDIA Driver\" (418.56 or later)"); - event_log_warning (hashcat_ctx, " \"CUDA Toolkit\" (10.1 or later)"); + event_log_warning (hashcat_ctx, " \"CUDA Toolkit\" (9.0 or later)"); event_log_warning (hashcat_ctx, NULL); return -1; @@ -5124,6 +5364,12 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->is_cuda = true; + device_param->is_opencl = false; + + device_param->use_opencl12 = false; + device_param->use_opencl20 = false; + device_param->use_opencl21 = false; + // device_name char *device_name = (char *) hcmalloc (HCBUFSIZ_TINY); @@ -5328,10 +5574,55 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // //if (rc_cuCtxSetCacheConfig == -1) return -1; - device_param->has_bfe = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"bfe.u32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); - device_param->has_lop3 = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"lop3.b32 %0, 0, 0, 0, 0;\" : \"=r\"(r)); }"); - device_param->has_mov64 = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned long long r; unsigned int a; unsigned int b; asm volatile (\"mov.b64 %0, {%1, %2};\" : \"=l\"(r) : \"r\"(a), \"r\"(b)); }"); - device_param->has_prmt = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"prmt.b32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); + const int sm = (device_param->sm_major * 10) + device_param->sm_minor; + + device_param->has_add = (sm >= 12) ? true : false; + device_param->has_addc = (sm >= 12) ? true : false; + device_param->has_sub = (sm >= 12) ? true : false; + device_param->has_subc = (sm >= 12) ? true : false; + device_param->has_bfe = (sm >= 20) ? true : false; + device_param->has_lop3 = (sm >= 50) ? true : false; + device_param->has_mov64 = (sm >= 10) ? true : false; + device_param->has_prmt = (sm >= 20) ? true : false; + + /* + #define RUN_INSTRUCTION_CHECKS() \ + device_param->has_add = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"add.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_addc = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"addc.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_sub = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"sub.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_subc = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"subc.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_bfe = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"bfe.u32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_lop3 = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"lop3.b32 %0, 0, 0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_mov64 = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned long long r; unsigned int a; unsigned int b; asm volatile (\"mov.b64 %0, {%1, %2};\" : \"=l\"(r) : \"r\"(a), \"r\"(b)); }"); \ + device_param->has_prmt = cuda_test_instruction (hashcat_ctx, sm_major, sm_minor, "__global__ void test () { unsigned int r; asm volatile (\"prmt.b32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); \ + + if (backend_devices_idx > 0) + { + hc_device_param_t *device_param_prev = &devices_param[backend_devices_idx - 1]; + + if (is_same_device_type (device_param, device_param_prev) == true) + { + device_param->has_add = device_param_prev->has_add; + device_param->has_addc = device_param_prev->has_addc; + device_param->has_sub = device_param_prev->has_sub; + device_param->has_subc = device_param_prev->has_subc; + device_param->has_bfe = device_param_prev->has_bfe; + device_param->has_lop3 = device_param_prev->has_lop3; + device_param->has_mov64 = device_param_prev->has_mov64; + device_param->has_prmt = device_param_prev->has_prmt; + } + else + { + RUN_INSTRUCTION_CHECKS(); + } + } + else + { + RUN_INSTRUCTION_CHECKS(); + } + + #undef RUN_INSTRUCTION_CHECKS + */ // device_available_mem @@ -5362,12 +5653,14 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_device_id **opencl_platforms_devices = backend_ctx->opencl_platforms_devices; cl_uint *opencl_platforms_devices_cnt = backend_ctx->opencl_platforms_devices_cnt; cl_uint *opencl_platforms_vendor_id = backend_ctx->opencl_platforms_vendor_id; + char **opencl_platforms_version = backend_ctx->opencl_platforms_version; for (u32 opencl_platforms_idx = 0; opencl_platforms_idx < opencl_platforms_cnt; opencl_platforms_idx++) { cl_device_id *opencl_platform_devices = opencl_platforms_devices[opencl_platforms_idx]; cl_uint opencl_platform_devices_cnt = opencl_platforms_devices_cnt[opencl_platforms_idx]; cl_uint opencl_platform_vendor_id = opencl_platforms_vendor_id[opencl_platforms_idx]; + char *opencl_platform_version = opencl_platforms_version[opencl_platforms_idx]; for (u32 opencl_platform_devices_idx = 0; opencl_platform_devices_idx < opencl_platform_devices_cnt; opencl_platform_devices_idx++, backend_devices_idx++, opencl_devices_cnt++) { @@ -5387,8 +5680,35 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) //device_param->opencl_platform = opencl_platform; + device_param->is_cuda = false; + device_param->is_opencl = true; + // check OpenCL version + + device_param->use_opencl12 = false; + device_param->use_opencl20 = false; + device_param->use_opencl21 = false; + + int opencl_version_min = 0; + int opencl_version_maj = 0; + + if (sscanf (opencl_platform_version, "OpenCL %d.%d", &opencl_version_min, &opencl_version_maj) == 2) + { + if ((opencl_version_min == 1) && (opencl_version_maj == 2)) + { + device_param->use_opencl12 = true; + } + else if ((opencl_version_min == 2) && (opencl_version_maj == 0)) + { + device_param->use_opencl20 = true; + } + else if ((opencl_version_min == 2) && (opencl_version_maj == 1)) + { + device_param->use_opencl21 = true; + } + } + size_t param_value_size = 0; // opencl_device_type @@ -5606,7 +5926,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_EXTENSIONS, 0, NULL, &device_extensions_size) == -1) return -1; - char *device_extensions = hcmalloc (device_extensions_size + 1); + char *device_extensions = (char *) hcmalloc (device_extensions_size + 1); if (hc_clGetDeviceInfo (hashcat_ctx, device_param->opencl_device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL) == -1) return -1; @@ -5692,7 +6012,12 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // CL_INVALID_COMMAND_QUEUE and CL_OUT_OF_RESOURCES // Turns out that this is caused by Intel OpenCL runtime handling their GPU devices // Disable such devices unless the user forces to use it + // This is successfully workaround with new threading model and new memory management + // Tested on Windows 10 + // OpenCL.Version.: OpenCL C 2.1 + // Driver.Version.: 23.20.16.4973 + /* #if !defined (__APPLE__) if (opencl_device_type & CL_DEVICE_TYPE_GPU) { @@ -5709,6 +6034,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } } #endif // __APPLE__ + */ // skipped @@ -5973,17 +6299,6 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (user_options->quiet == false) event_log_warning (hashcat_ctx, " To disable the timeout, see: https://hashcat.net/q/timeoutpatch"); } } - - if ((strstr (device_param->opencl_device_c_version, "beignet")) || (strstr (device_param->opencl_device_version, "beignet"))) - { - event_log_error (hashcat_ctx, "* Device #%u: Intel beignet driver detected!", device_id + 1); - - event_log_warning (hashcat_ctx, "The beignet driver has been marked as likely to fail kernel compilation."); - event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors."); - event_log_warning (hashcat_ctx, NULL); - - return -1; - } } } @@ -6022,17 +6337,101 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) && (device_param->opencl_platform_vendor_id == VENDOR_ID_AMD)) { - device_param->has_vadd3 = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; __asm__ __volatile__ (\"V_ADD3_U32 %0, 0, 0, 0;\" : \"=v\"(r)); }"); - device_param->has_vbfe = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; __asm__ __volatile__ (\"V_BFE_U32 %0, 0, 0, 0;\" : \"=v\"(r)); }"); - device_param->has_vperm = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; __asm__ __volatile__ (\"V_PERM_B32 %0, 0, 0, 0;\" : \"=v\"(r)); }"); + #define RUN_INSTRUCTION_CHECKS() + device_param->has_vadd = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_ADD_U32 %0, vcc, 0, 0;\" : \"=v\"(r1)); }"); \ + device_param->has_vaddc = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_ADDC_U32 %0, vcc, 0, 0, vcc;\" : \"=v\"(r1)); }"); \ + device_param->has_vadd_co = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_ADD_CO_U32 %0, vcc, 0, 0;\" : \"=v\"(r1)); }"); \ + device_param->has_vaddc_co = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_ADDC_CO_U32 %0, vcc, 0, 0, vcc;\" : \"=v\"(r1)); }"); \ + device_param->has_vsub = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_SUB_U32 %0, vcc, 0, 0;\" : \"=v\"(r1)); }"); \ + device_param->has_vsubb = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_SUBB_U32 %0, vcc, 0, 0, vcc;\" : \"=v\"(r1)); }"); \ + device_param->has_vsub_co = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_SUB_CO_U32 %0, vcc, 0, 0;\" : \"=v\"(r1)); }"); \ + device_param->has_vsubb_co = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_SUBB_CO_U32 %0, vcc, 0, 0, vcc;\" : \"=v\"(r1)); }"); \ + device_param->has_vadd3 = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_ADD3_U32 %0, 0, 0, 0;\" : \"=v\"(r1)); }"); \ + device_param->has_vbfe = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_BFE_U32 %0, 0, 0, 0;\" : \"=v\"(r1)); }"); \ + device_param->has_vperm = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r1; __asm__ __volatile__ (\"V_PERM_B32 %0, 0, 0, 0;\" : \"=v\"(r1)); }"); \ + + if (backend_devices_idx > 0) + { + hc_device_param_t *device_param_prev = &devices_param[backend_devices_idx - 1]; + + if (is_same_device_type (device_param, device_param_prev) == true) + { + device_param->has_vadd = device_param_prev->has_vadd; + device_param->has_vaddc = device_param_prev->has_vaddc; + device_param->has_vadd_co = device_param_prev->has_vadd_co; + device_param->has_vaddc_co = device_param_prev->has_vaddc_co; + device_param->has_vsub = device_param_prev->has_vsub; + device_param->has_vsubb = device_param_prev->has_vsubb; + device_param->has_vsub_co = device_param_prev->has_vsub_co; + device_param->has_vsubb_co = device_param_prev->has_vsubb_co; + device_param->has_vadd3 = device_param_prev->has_vadd3; + device_param->has_vbfe = device_param_prev->has_vbfe; + device_param->has_vperm = device_param_prev->has_vperm; + } + else + { + RUN_INSTRUCTION_CHECKS(); + } + } + else + { + RUN_INSTRUCTION_CHECKS(); + } + + #undef RUN_INSTRUCTION_CHECKS } if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) && (device_param->opencl_platform_vendor_id == VENDOR_ID_NV)) { - device_param->has_bfe = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"bfe.u32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); - device_param->has_lop3 = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"lop3.b32 %0, 0, 0, 0, 0;\" : \"=r\"(r)); }"); - device_param->has_mov64 = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { ulong r; uint a; uint b; asm volatile (\"mov.b64 %0, {%1, %2};\" : \"=l\"(r) : \"r\"(a), \"r\"(b)); }"); - device_param->has_prmt = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"prmt.b32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); + const int sm = (device_param->sm_major * 10) + device_param->sm_minor; + + device_param->has_add = (sm >= 12) ? true : false; + device_param->has_addc = (sm >= 12) ? true : false; + device_param->has_sub = (sm >= 12) ? true : false; + device_param->has_subc = (sm >= 12) ? true : false; + device_param->has_bfe = (sm >= 20) ? true : false; + device_param->has_lop3 = (sm >= 50) ? true : false; + device_param->has_mov64 = (sm >= 10) ? true : false; + device_param->has_prmt = (sm >= 20) ? true : false; + + /* + #define RUN_INSTRUCTION_CHECKS() \ + device_param->has_add = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"add.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_addc = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"addc.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_sub = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"sub.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_subc = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"subc.cc.u32 %0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_bfe = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"bfe.u32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_lop3 = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"lop3.b32 %0, 0, 0, 0, 0;\" : \"=r\"(r)); }"); \ + device_param->has_mov64 = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { ulong r; uint a; uint b; asm volatile (\"mov.b64 %0, {%1, %2};\" : \"=l\"(r) : \"r\"(a), \"r\"(b)); }"); \ + device_param->has_prmt = opencl_test_instruction (hashcat_ctx, context, device_param->opencl_device, "__kernel void test () { uint r; asm volatile (\"prmt.b32 %0, 0, 0, 0;\" : \"=r\"(r)); }"); \ + + if (backend_devices_idx > 0) + { + hc_device_param_t *device_param_prev = &devices_param[backend_devices_idx - 1]; + + if (is_same_device_type (device_param, device_param_prev) == true) + { + device_param->has_add = device_param_prev->has_add; + device_param->has_addc = device_param_prev->has_addc; + device_param->has_sub = device_param_prev->has_sub; + device_param->has_subc = device_param_prev->has_subc; + device_param->has_bfe = device_param_prev->has_bfe; + device_param->has_lop3 = device_param_prev->has_lop3; + device_param->has_mov64 = device_param_prev->has_mov64; + device_param->has_prmt = device_param_prev->has_prmt; + } + else + { + RUN_INSTRUCTION_CHECKS(); + } + } + else + { + RUN_INSTRUCTION_CHECKS(); + } + + #undef RUN_INSTRUCTION_CHECKS + */ } // device_available_mem @@ -6070,7 +6469,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_int CL_err; - OCL_PTR *ocl = backend_ctx->ocl; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; tmp_device[c] = ocl->clCreateBuffer (context, CL_MEM_READ_WRITE, MAX_ALLOC_CHECKS_SIZE, NULL, &CL_err); @@ -6150,6 +6549,19 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) return -1; } + // now we can calculate the number of parallel running hook threads based on + // the number cpu cores and the number of active compute devices + // unless overwritten by the user + + if (user_options->hook_threads == HOOK_THREADS) + { + const u32 processor_count = hc_get_processor_count (); + + const u32 processor_count_cu = CEILDIV (processor_count, backend_ctx->backend_devices_active); // should never reach 0 + + user_options->hook_threads = processor_count_cu; + } + // additional check to see if the user has chosen a device that is not within the range of available devices (i.e. larger than devices_cnt) if (backend_ctx->backend_devices_filter != (u64) -1) @@ -6381,6 +6793,40 @@ static int get_cuda_kernel_local_mem_size (hashcat_ctx_t *hashcat_ctx, CUfunctio return 0; } +static int get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx_t *hashcat_ctx, CUfunction function, u64 *result) +{ + // AFAIK there's no way to query the maximum value for dynamic shared memory available (because it depends on kernel code). + // let's brute force it, therefore workaround the hashcat wrapper of cuFuncSetAttribute() + + #define MAX_ASSUMED_SHARED (1024 * 1024) + + u64 dynamic_shared_size_bytes = 0; + + for (int i = 1; i <= MAX_ASSUMED_SHARED; i++) + { + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + + CUDA_PTR *cuda = (CUDA_PTR *) backend_ctx->cuda; + + const CUresult CU_err = cuda->cuFuncSetAttribute (function, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, i); + + if (CU_err == CUDA_SUCCESS) + { + dynamic_shared_size_bytes = i; + + continue; + } + + break; + } + + *result = dynamic_shared_size_bytes; + + if (hc_cuFuncSetAttribute (hashcat_ctx, function, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, 0) == -1) return -1; + + return 0; +} + static int get_opencl_kernel_wgs (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_kernel kernel, u32 *result) { size_t work_group_size = 0; @@ -6427,6 +6873,23 @@ static int get_opencl_kernel_local_mem_size (hashcat_ctx_t *hashcat_ctx, hc_devi return 0; } +static int get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_kernel kernel, u64 *result) +{ + cl_ulong dynamic_local_mem_size = 0; + + if (hc_clGetKernelWorkGroupInfo (hashcat_ctx, kernel, device_param->opencl_device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof (dynamic_local_mem_size), &dynamic_local_mem_size, NULL) == -1) return -1; + + // unknown how to query this information in OpenCL + // we therefore reset to zero + // the above call to hc_clGetKernelWorkGroupInfo() is just to avoid compiler warnings + + dynamic_local_mem_size = 0; + + *result = dynamic_local_mem_size; + + return 0; +} + static u32 get_kernel_threads (const hc_device_param_t *device_param) { // this is an upper limit, a good start, since our strategy is to reduce thread counts only. @@ -6440,14 +6903,31 @@ static u32 get_kernel_threads (const hc_device_param_t *device_param) kernel_threads_max = MIN (kernel_threads_max, device_maxworkgroup_size); - // for CPU we just do 1 ... - if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU) { + // for all CPU we just do 1 ... + const u32 cpu_prefered_thread_count = 1; kernel_threads_max = MIN (kernel_threads_max, cpu_prefered_thread_count); } + else if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) + { + // for GPU we need to distinguish by vendor + + if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) + { + const u32 gpu_prefered_thread_count = 8; + + kernel_threads_max = MIN (kernel_threads_max, gpu_prefered_thread_count); + } + else if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + { + const u32 gpu_prefered_thread_count = 64; + + kernel_threads_max = MIN (kernel_threads_max, gpu_prefered_thread_count); + } + } // this is intenionally! at this point, kernel_threads_min can be higher than kernel_threads_max. // in this case we actually want kernel_threads_min selected. @@ -6457,6 +6937,397 @@ static u32 get_kernel_threads (const hc_device_param_t *device_param) return kernel_threads; } +static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const char *kernel_name, char *source_file, char *cached_file, const char *build_options_buf, const bool cache_disable, cl_program *opencl_program, CUmodule *cuda_module) +{ + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + + bool cached = true; + + if (cache_disable == true) + { + cached = false; + } + + if (hc_path_read (cached_file) == false) + { + cached = false; + } + + if (hc_path_is_empty (cached_file) == true) + { + cached = false; + } + + /** + * kernel compile or load + */ + + size_t kernel_lengths_buf = 0; + + size_t *kernel_lengths = &kernel_lengths_buf; + + char *kernel_sources_buf = NULL; + + char **kernel_sources = &kernel_sources_buf; + + if (cached == false) + { + #if defined (DEBUG) + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_param->device_id + 1, filename_from_filepath (cached_file)); + #endif + + if (read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources) == false) return false; + + if (device_param->is_cuda == true) + { + nvrtcProgram program; + + if (hc_nvrtcCreateProgram (hashcat_ctx, &program, kernel_sources[0], kernel_name, 0, NULL, NULL) == -1) return false; + + char **nvrtc_options = (char **) hccalloc (4 + strlen (build_options_buf) + 1, sizeof (char *)); // ... + + nvrtc_options[0] = "--restrict"; + nvrtc_options[1] = "--device-as-default-execution-space"; + nvrtc_options[2] = "--gpu-architecture"; + + hc_asprintf (&nvrtc_options[3], "compute_%d%d", device_param->sm_major, device_param->sm_minor); + + char *nvrtc_options_string = hcstrdup (build_options_buf); + + const int num_options = 4 + nvrtc_make_options_array_from_string (nvrtc_options_string, nvrtc_options + 4); + + const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options); + + size_t build_log_size = 0; + + hc_nvrtcGetProgramLogSize (hashcat_ctx, program, &build_log_size); + + #if defined (DEBUG) + if ((build_log_size > 1) || (rc_nvrtcCompileProgram == -1)) + #else + if (rc_nvrtcCompileProgram == -1) + #endif + { + char *build_log = (char *) hcmalloc (build_log_size + 1); + + if (hc_nvrtcGetProgramLog (hashcat_ctx, program, build_log) == -1) return false; + + puts (build_log); + + hcfree (build_log); + } + + if (rc_nvrtcCompileProgram == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed.", device_param->device_id + 1, source_file); + + return false; + } + + hcfree (nvrtc_options); + hcfree (nvrtc_options_string); + + size_t binary_size = 0; + + if (hc_nvrtcGetPTXSize (hashcat_ctx, program, &binary_size) == -1) return false; + + char *binary = (char *) hcmalloc (binary_size); + + if (hc_nvrtcGetPTX (hashcat_ctx, program, binary) == -1) return false; + + if (hc_nvrtcDestroyProgram (hashcat_ctx, &program) == -1) return false; + + #define LOG_SIZE 8192 + + char *mod_info_log = (char *) hcmalloc (LOG_SIZE + 1); + char *mod_error_log = (char *) hcmalloc (LOG_SIZE + 1); + + int mod_cnt = 6; + + CUjit_option mod_opts[7]; + void *mod_vals[7]; + + mod_opts[0] = CU_JIT_TARGET_FROM_CUCONTEXT; + mod_vals[0] = (void *) 0; + + mod_opts[1] = CU_JIT_LOG_VERBOSE; + mod_vals[1] = (void *) 1; + + mod_opts[2] = CU_JIT_INFO_LOG_BUFFER; + mod_vals[2] = (void *) mod_info_log; + + mod_opts[3] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; + mod_vals[3] = (void *) LOG_SIZE; + + mod_opts[4] = CU_JIT_ERROR_LOG_BUFFER; + mod_vals[4] = (void *) mod_error_log; + + mod_opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES; + mod_vals[5] = (void *) LOG_SIZE; + + if (hashconfig->opti_type & OPTI_TYPE_REGISTER_LIMIT) + { + mod_opts[6] = CU_JIT_MAX_REGISTERS; + mod_vals[6] = (void *) 128; + + mod_cnt++; + } + + #if defined (WITH_CUBIN) + + char *jit_info_log = (char *) hcmalloc (LOG_SIZE + 1); + char *jit_error_log = (char *) hcmalloc (LOG_SIZE + 1); + + int jit_cnt = 6; + + CUjit_option jit_opts[7]; + void *jit_vals[7]; + + jit_opts[0] = CU_JIT_TARGET_FROM_CUCONTEXT; + jit_vals[0] = (void *) 0; + + jit_opts[1] = CU_JIT_LOG_VERBOSE; + jit_vals[1] = (void *) 1; + + jit_opts[2] = CU_JIT_INFO_LOG_BUFFER; + jit_vals[2] = (void *) jit_info_log; + + jit_opts[3] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; + jit_vals[3] = (void *) LOG_SIZE; + + jit_opts[4] = CU_JIT_ERROR_LOG_BUFFER; + jit_vals[4] = (void *) jit_error_log; + + jit_opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES; + jit_vals[5] = (void *) LOG_SIZE; + + if (hashconfig->opti_type & OPTI_TYPE_REGISTER_LIMIT) + { + jit_opts[6] = CU_JIT_MAX_REGISTERS; + jit_vals[6] = (void *) 128; + + jit_cnt++; + } + + CUlinkState state; + + if (hc_cuLinkCreate (hashcat_ctx, jit_cnt, jit_opts, jit_vals, &state) == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s link failed. Error Log:", device_param->device_id + 1, source_file); + event_log_error (hashcat_ctx, "%s", jit_error_log); + event_log_error (hashcat_ctx, NULL); + + return false; + } + + if (hc_cuLinkAddData (hashcat_ctx, state, CU_JIT_INPUT_PTX, binary, binary_size, kernel_name, 0, NULL, NULL) == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s link failed. Error Log:", device_param->device_id + 1, source_file); + event_log_error (hashcat_ctx, "%s", jit_error_log); + event_log_error (hashcat_ctx, NULL); + + return false; + } + + void *cubin = NULL; + + size_t cubin_size = 0; + + if (hc_cuLinkComplete (hashcat_ctx, state, &cubin, &cubin_size) == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s link failed. Error Log:", device_param->device_id + 1, source_file); + event_log_error (hashcat_ctx, "%s", jit_error_log); + event_log_error (hashcat_ctx, NULL); + + return false; + } + + #if defined (DEBUG) + event_log_info (hashcat_ctx, "* Device #%u: Kernel %s link successful. Info Log:", device_param->device_id + 1, source_file); + event_log_info (hashcat_ctx, "%s", jit_info_log); + event_log_info (hashcat_ctx, NULL); + #endif + + if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, cubin, mod_cnt, mod_opts, mod_vals) == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s load failed. Error Log:", device_param->device_id + 1, source_file); + event_log_error (hashcat_ctx, "%s", mod_error_log); + event_log_error (hashcat_ctx, NULL); + + return false; + } + + #if defined (DEBUG) + event_log_info (hashcat_ctx, "* Device #%u: Kernel %s load successful. Info Log:", device_param->device_id + 1, source_file); + event_log_info (hashcat_ctx, "%s", mod_info_log); + event_log_info (hashcat_ctx, NULL); + #endif + + if (cache_disable == false) + { + if (write_kernel_binary (hashcat_ctx, cached_file, cubin, cubin_size) == false) return false; + } + + if (hc_cuLinkDestroy (hashcat_ctx, state) == -1) return false; + + hcfree (jit_info_log); + hcfree (jit_error_log); + + #else + + if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, binary, mod_cnt, mod_opts, mod_vals) == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s load failed. Error Log:", device_param->device_id + 1, source_file); + event_log_error (hashcat_ctx, "%s", mod_error_log); + event_log_error (hashcat_ctx, NULL); + + return false; + } + + #if defined (DEBUG) + event_log_info (hashcat_ctx, "* Device #%u: Kernel %s load successful. Info Log:", device_param->device_id + 1, source_file); + event_log_info (hashcat_ctx, "%s", mod_info_log); + event_log_info (hashcat_ctx, NULL); + #endif + + if (cache_disable == false) + { + if (write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size) == false) return false; + } + + #endif + + hcfree (mod_info_log); + hcfree (mod_error_log); + + hcfree (binary); + } + + if (device_param->is_opencl == true) + { + if (hc_clCreateProgramWithSource (hashcat_ctx, device_param->opencl_context, 1, (const char **) kernel_sources, NULL, opencl_program) == -1) return false; + + const int CL_rc = hc_clBuildProgram (hashcat_ctx, *opencl_program, 1, &device_param->opencl_device, build_options_buf, NULL, NULL); + + //if (CL_rc == -1) return -1; + + size_t build_log_size = 0; + + hc_clGetProgramBuildInfo (hashcat_ctx, *opencl_program, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + + //if (CL_rc == -1) return -1; + + #if defined (DEBUG) + if ((build_log_size > 1) || (CL_rc == -1)) + #else + if (CL_rc == -1) + #endif + { + char *build_log = (char *) hcmalloc (build_log_size + 1); + + const int rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, *opencl_program, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + + if (rc_clGetProgramBuildInfo == -1) return false; + + puts (build_log); + + hcfree (build_log); + } + + if (CL_rc == -1) return false; + + if (cache_disable == false) + { + size_t binary_size; + + if (hc_clGetProgramInfo (hashcat_ctx, *opencl_program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL) == -1) return false; + + char *binary = (char *) hcmalloc (binary_size); + + if (hc_clGetProgramInfo (hashcat_ctx, *opencl_program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL) == -1) return false; + + if (write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size) == false) return false; + + hcfree (binary); + } + } + } + else + { + if (read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources) == false) return false; + + if (device_param->is_cuda == true) + { + #define LOG_SIZE 8192 + + char *mod_info_log = (char *) hcmalloc (LOG_SIZE + 1); + char *mod_error_log = (char *) hcmalloc (LOG_SIZE + 1); + + int mod_cnt = 6; + + CUjit_option mod_opts[7]; + void *mod_vals[7]; + + mod_opts[0] = CU_JIT_TARGET_FROM_CUCONTEXT; + mod_vals[0] = (void *) 0; + + mod_opts[1] = CU_JIT_LOG_VERBOSE; + mod_vals[1] = (void *) 1; + + mod_opts[2] = CU_JIT_INFO_LOG_BUFFER; + mod_vals[2] = (void *) mod_info_log; + + mod_opts[3] = CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; + mod_vals[3] = (void *) LOG_SIZE; + + mod_opts[4] = CU_JIT_ERROR_LOG_BUFFER; + mod_vals[4] = (void *) mod_error_log; + + mod_opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES; + mod_vals[5] = (void *) LOG_SIZE; + + if (hashconfig->opti_type & OPTI_TYPE_REGISTER_LIMIT) + { + mod_opts[6] = CU_JIT_MAX_REGISTERS; + mod_vals[6] = (void *) 128; + + mod_cnt++; + } + + if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, kernel_sources[0], mod_cnt, mod_opts, mod_vals) == -1) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s load failed. Error Log:", device_param->device_id + 1, source_file); + event_log_error (hashcat_ctx, "%s", mod_error_log); + event_log_error (hashcat_ctx, NULL); + + return false; + } + + #if defined (DEBUG) + event_log_info (hashcat_ctx, "* Device #%u: Kernel %s load successful. Info Log:", device_param->device_id + 1, source_file); + event_log_info (hashcat_ctx, "%s", mod_info_log); + event_log_info (hashcat_ctx, NULL); + #endif + + hcfree (mod_info_log); + hcfree (mod_error_log); + } + + if (device_param->is_opencl == true) + { + if (hc_clCreateProgramWithBinary (hashcat_ctx, device_param->opencl_context, 1, &device_param->opencl_device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, opencl_program) == -1) return false; + + if (hc_clBuildProgram (hashcat_ctx, *opencl_program, 1, &device_param->opencl_device, build_options_buf, NULL, NULL) == -1) return false; + } + } + + hcfree (kernel_sources[0]); + + return true; +} + int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; @@ -6881,12 +7752,33 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -I OpenCL -I %s ", folder_config->cpath_real); #endif + /* currently disabled, hangs NEO drivers since 20.09. + was required for NEO driver 20.08 to workaround the same issue! + we go with the latest version + + if (device_param->is_opencl == true) + { + if (device_param->use_opencl12 == true) + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-cl-std=CL1.2 "); + } + else if (device_param->use_opencl20 == true) + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-cl-std=CL2.0 "); + } + else if (device_param->use_opencl21 == true) + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-cl-std=CL2.1 "); + } + } + */ + // we don't have sm_* on vendors not NV but it doesn't matter #if defined (DEBUG) - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D LOCAL_MEM_TYPE=%d -D VENDOR_ID=%u -D CUDA_ARCH=%u -D HAS_VPERM=%u -D HAS_VADD3=%u -D HAS_VBFE=%u -D HAS_BFE=%u -D HAS_LOP3=%u -D HAS_MOV64=%u -D HAS_PRMT=%u -D VECT_SIZE=%d -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D ATTACK_EXEC=%u -D ATTACK_KERN=%u -D _unroll ", device_param->device_local_mem_type, device_param->opencl_platform_vendor_id, (device_param->sm_major * 100) + (device_param->sm_minor * 10), device_param->has_vperm, device_param->has_vadd3, device_param->has_vbfe, device_param->has_bfe, device_param->has_lop3, device_param->has_mov64, device_param->has_prmt, device_param->vector_width, (u32) device_param->opencl_device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, kern_type, hashconfig->attack_exec, user_options_extra->attack_kern); + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D LOCAL_MEM_TYPE=%d -D VENDOR_ID=%u -D CUDA_ARCH=%u -D HAS_ADD=%u -D HAS_ADDC=%u -D HAS_SUB=%u -D HAS_SUBC=%u -D HAS_VADD=%u -D HAS_VADDC=%u -D HAS_VADD_CO=%u -D HAS_VADDC_CO=%u -D HAS_VSUB=%u -D HAS_VSUBB=%u -D HAS_VSUB_CO=%u -D HAS_VSUBB_CO=%u -D HAS_VPERM=%u -D HAS_VADD3=%u -D HAS_VBFE=%u -D HAS_BFE=%u -D HAS_LOP3=%u -D HAS_MOV64=%u -D HAS_PRMT=%u -D VECT_SIZE=%d -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D ATTACK_EXEC=%u -D ATTACK_KERN=%u ", device_param->device_local_mem_type, device_param->opencl_platform_vendor_id, (device_param->sm_major * 100) + (device_param->sm_minor * 10), device_param->has_add, device_param->has_addc, device_param->has_sub, device_param->has_subc, device_param->has_vadd, device_param->has_vaddc, device_param->has_vadd_co, device_param->has_vaddc_co, device_param->has_vsub, device_param->has_vsubb, device_param->has_vsub_co, device_param->has_vsubb_co, device_param->has_vperm, device_param->has_vadd3, device_param->has_vbfe, device_param->has_bfe, device_param->has_lop3, device_param->has_mov64, device_param->has_prmt, device_param->vector_width, (u32) device_param->opencl_device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, kern_type, hashconfig->attack_exec, user_options_extra->attack_kern); #else - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D LOCAL_MEM_TYPE=%d -D VENDOR_ID=%u -D CUDA_ARCH=%u -D HAS_VPERM=%u -D HAS_VADD3=%u -D HAS_VBFE=%u -D HAS_BFE=%u -D HAS_LOP3=%u -D HAS_MOV64=%u -D HAS_PRMT=%u -D VECT_SIZE=%d -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D ATTACK_EXEC=%u -D ATTACK_KERN=%u -D _unroll -w ", device_param->device_local_mem_type, device_param->opencl_platform_vendor_id, (device_param->sm_major * 100) + (device_param->sm_minor * 10), device_param->has_vperm, device_param->has_vadd3, device_param->has_vbfe, device_param->has_bfe, device_param->has_lop3, device_param->has_mov64, device_param->has_prmt, device_param->vector_width, (u32) device_param->opencl_device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, kern_type, hashconfig->attack_exec, user_options_extra->attack_kern); + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D LOCAL_MEM_TYPE=%d -D VENDOR_ID=%u -D CUDA_ARCH=%u -D HAS_ADD=%u -D HAS_ADDC=%u -D HAS_SUB=%u -D HAS_SUBC=%u -D HAS_VADD=%u -D HAS_VADDC=%u -D HAS_VADD_CO=%u -D HAS_VADDC_CO=%u -D HAS_VSUB=%u -D HAS_VSUBB=%u -D HAS_VSUB_CO=%u -D HAS_VSUBB_CO=%u -D HAS_VPERM=%u -D HAS_VADD3=%u -D HAS_VBFE=%u -D HAS_BFE=%u -D HAS_LOP3=%u -D HAS_MOV64=%u -D HAS_PRMT=%u -D VECT_SIZE=%d -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D ATTACK_EXEC=%u -D ATTACK_KERN=%u -w ", device_param->device_local_mem_type, device_param->opencl_platform_vendor_id, (device_param->sm_major * 100) + (device_param->sm_minor * 10), device_param->has_add, device_param->has_addc, device_param->has_sub, device_param->has_subc, device_param->has_vadd, device_param->has_vaddc, device_param->has_vadd_co, device_param->has_vaddc_co, device_param->has_vsub, device_param->has_vsubb, device_param->has_vsub_co, device_param->has_vsubb_co, device_param->has_vperm, device_param->has_vadd3, device_param->has_vbfe, device_param->has_bfe, device_param->has_lop3, device_param->has_mov64, device_param->has_prmt, device_param->vector_width, (u32) device_param->opencl_device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, kern_type, hashconfig->attack_exec, user_options_extra->attack_kern); #endif build_options_buf[build_options_len] = 0; @@ -6901,38 +7793,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } */ - char *build_options_module_buf = (char *) hcmalloc (build_options_sz); - - int build_options_module_len = 0; - - build_options_module_len += snprintf (build_options_module_buf + build_options_module_len, build_options_sz - build_options_module_len, "%s ", build_options_buf); - - if (module_ctx->module_jit_build_options != MODULE_DEFAULT) - { - char *jit_build_options = module_ctx->module_jit_build_options (hashconfig, user_options, user_options_extra, hashes, device_param); - - if (jit_build_options != NULL) - { - build_options_module_len += snprintf (build_options_module_buf + build_options_module_len, build_options_sz - build_options_module_len, "%s", jit_build_options); - - // this is a bit ugly - // would be better to have the module return the value as value - - u32 fixed_local_size = 0; - - if (sscanf (jit_build_options, "-D FIXED_LOCAL_SIZE=%u", &fixed_local_size) == 1) - { - device_param->kernel_threads_min = fixed_local_size; - device_param->kernel_threads_max = fixed_local_size; - } - } - } - - build_options_module_buf[build_options_module_len] = 0; - #if defined (DEBUG) if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_options '%s'", device_id + 1, build_options_buf); - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_options_module '%s'", device_id + 1, build_options_module_buf); #endif /** @@ -6998,11 +7860,167 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) cache_disable = module_ctx->module_jit_cache_disable (hashconfig, user_options, user_options_extra, hashes, device_param); } + /** + * shared kernel with no hashconfig dependencies + */ + + { + /** + * kernel shared source filename + */ + + char source_file[256] = { 0 }; + + generate_source_kernel_shared_filename (folder_config->shared_dir, source_file); + + if (hc_path_read (source_file) == false) + { + event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); + + return -1; + } + + /** + * kernel shared cached filename + */ + + char cached_file[256] = { 0 }; + + generate_cached_kernel_shared_filename (folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); + + const bool rc_load_kernel = load_kernel (hashcat_ctx, device_param, "shared_kernel", source_file, cached_file, build_options_buf, cache_disable, &device_param->opencl_program_shared, &device_param->cuda_module_shared); + + if (rc_load_kernel == false) + { + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed.", device_param->device_id + 1, source_file); + + return -1; + } + + if (device_param->is_cuda == true) + { + // GPU memset + + if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function_memset, device_param->cuda_module_shared, "gpu_memset") == -1) return -1; + + if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function_memset, &device_param->kernel_wgs_memset) == -1) return -1; + + if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_memset, &device_param->kernel_local_mem_size_memset) == -1) return -1; + + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_memset, &device_param->kernel_dynamic_local_mem_size_memset) == -1) return -1; + + device_param->kernel_preferred_wgs_multiple_memset = device_param->cuda_warp_size; + + //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); if (CL_rc == -1) return -1; + //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); if (CL_rc == -1) return -1; + //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 2, sizeof (cl_ulong), device_param->kernel_params_memset[2]); if (CL_rc == -1) return -1; + + // GPU autotune init + + if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function_atinit, device_param->cuda_module_shared, "gpu_atinit") == -1) return -1; + + if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function_atinit, &device_param->kernel_wgs_atinit) == -1) return -1; + + if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_atinit, &device_param->kernel_local_mem_size_atinit) == -1) return -1; + + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_atinit, &device_param->kernel_dynamic_local_mem_size_atinit) == -1) return -1; + + device_param->kernel_preferred_wgs_multiple_atinit = device_param->cuda_warp_size; + + // CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 0, sizeof (cl_mem), device_param->kernel_params_atinit[0]); if (CL_rc == -1) return -1; + // CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 1, sizeof (cl_ulong), device_param->kernel_params_atinit[1]); if (CL_rc == -1) return -1; + + // GPU decompress + + if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function_decompress, device_param->cuda_module_shared, "gpu_decompress") == -1) return -1; + + if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function_decompress, &device_param->kernel_wgs_decompress) == -1) return -1; + + if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_decompress, &device_param->kernel_local_mem_size_decompress) == -1) return -1; + + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_decompress, &device_param->kernel_dynamic_local_mem_size_decompress) == -1) return -1; + + device_param->kernel_preferred_wgs_multiple_decompress = device_param->cuda_warp_size; + } + + if (device_param->is_opencl == true) + { + // GPU memset + + if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program_shared, "gpu_memset", &device_param->opencl_kernel_memset) == -1) return -1; + + if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_wgs_memset) == -1) return -1; + + if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_local_mem_size_memset) == -1) return -1; + + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_dynamic_local_mem_size_memset) == -1) return -1; + + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_preferred_wgs_multiple_memset) == -1) return -1; + + // GPU autotune init + + if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program_shared, "gpu_atinit", &device_param->opencl_kernel_atinit) == -1) return -1; + + if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_wgs_atinit) == -1) return -1; + + if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_local_mem_size_atinit) == -1) return -1; + + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_dynamic_local_mem_size_atinit) == -1) return -1; + + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_preferred_wgs_multiple_atinit) == -1) return -1; + + // GPU decompress + + if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program_shared, "gpu_decompress", &device_param->opencl_kernel_decompress) == -1) return -1; + + if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_wgs_decompress) == -1) return -1; + + if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_local_mem_size_decompress) == -1) return -1; + + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_dynamic_local_mem_size_decompress) == -1) return -1; + + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_preferred_wgs_multiple_decompress) == -1) return -1; + } + } + /** * main kernel */ { + char *build_options_module_buf = (char *) hcmalloc (build_options_sz); + + int build_options_module_len = 0; + + build_options_module_len += snprintf (build_options_module_buf + build_options_module_len, build_options_sz - build_options_module_len, "%s ", build_options_buf); + + if (module_ctx->module_jit_build_options != MODULE_DEFAULT) + { + char *jit_build_options = module_ctx->module_jit_build_options (hashconfig, user_options, user_options_extra, hashes, device_param); + + if (jit_build_options != NULL) + { + build_options_module_len += snprintf (build_options_module_buf + build_options_module_len, build_options_sz - build_options_module_len, "%s", jit_build_options); + + // this is a bit ugly + // would be better to have the module return the value as value + + u32 fixed_local_size = 0; + + if (sscanf (jit_build_options, "-D FIXED_LOCAL_SIZE=%u", &fixed_local_size) == 1) + { + device_param->kernel_threads_min = fixed_local_size; + device_param->kernel_threads_max = fixed_local_size; + } + } + } + + build_options_module_buf[build_options_module_len] = 0; + + #if defined (DEBUG) + if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_options_module '%s'", device_id + 1, build_options_module_buf); + #endif + /** * kernel source filename */ @@ -7026,196 +8044,22 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) generate_cached_kernel_filename (user_options->slow_candidates, hashconfig->attack_exec, user_options_extra->attack_kern, kern_type, hashconfig->opti_type, folder_config->profile_dir, device_name_chksum, cached_file); - bool cached = true; - - if (cache_disable == true) - { - cached = false; - } - - if (hc_path_read (cached_file) == false) - { - cached = false; - } - - if (hc_path_is_empty (cached_file) == true) - { - cached = false; - } - /** - * kernel compile or load + * load kernel */ - size_t kernel_lengths_buf = 0; + const bool rc_load_kernel = load_kernel (hashcat_ctx, device_param, "main_kernel", source_file, cached_file, build_options_module_buf, cache_disable, &device_param->opencl_program, &device_param->cuda_module); - size_t *kernel_lengths = &kernel_lengths_buf; - - char *kernel_sources_buf = NULL; - - char **kernel_sources = &kernel_sources_buf; - - if (cached == false) + if (rc_load_kernel == false) { - #if defined (DEBUG) - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - #endif + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed.", device_param->device_id + 1, source_file); - if (read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true) == false) return -1; - - if (device_param->is_cuda == true) - { - nvrtcProgram program; - - if (hc_nvrtcCreateProgram (hashcat_ctx, &program, kernel_sources[0], "main_kernel", 0, NULL, NULL) == -1) return -1; - - char **nvrtc_options = (char **) hccalloc (4 + strlen (build_options_module_buf) + 1, sizeof (char *)); // ... - - nvrtc_options[0] = "--restrict"; - nvrtc_options[1] = "--device-as-default-execution-space"; - nvrtc_options[2] = "--gpu-architecture"; - - hc_asprintf (&nvrtc_options[3], "compute_%d%d", device_param->sm_major, device_param->sm_minor); - - char *nvrtc_options_string = hcstrdup (build_options_module_buf); - - const int num_options = 4 + nvrtc_make_options_array_from_string (nvrtc_options_string, nvrtc_options + 4); - - const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options); - - size_t build_log_size = 0; - - hc_nvrtcGetProgramLogSize (hashcat_ctx, program, &build_log_size); - - #if defined (DEBUG) - if ((build_log_size > 1) || (rc_nvrtcCompileProgram == -1)) - #else - if (rc_nvrtcCompileProgram == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - if (hc_nvrtcGetProgramLog (hashcat_ctx, program, build_log) == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (rc_nvrtcCompileProgram == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - hcfree (nvrtc_options); - hcfree (nvrtc_options_string); - - size_t binary_size; - - if (hc_nvrtcGetPTXSize (hashcat_ctx, program, &binary_size) == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - if (hc_nvrtcGetPTX (hashcat_ctx, program, binary) == -1) return -1; - - if (hc_nvrtcDestroyProgram (hashcat_ctx, &program) == -1) return -1; - - const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module, binary); - - if (rc_cuModuleLoadDataEx == -1) return -1; - - if (cache_disable == false) - { - const bool rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - - if (rc_write == false) return -1; - } - - hcfree (binary); - } - - if (device_param->is_opencl == true) - { - if (hc_clCreateProgramWithSource (hashcat_ctx, device_param->opencl_context, 1, (const char **) kernel_sources, NULL, &device_param->opencl_program) == -1) return -1; - - const int CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->opencl_program, 1, &device_param->opencl_device, build_options_module_buf, NULL, NULL); - - //if (CL_rc == -1) return -1; - - size_t build_log_size = 0; - - hc_clGetProgramBuildInfo (hashcat_ctx, device_param->opencl_program, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - - //if (CL_rc == -1) return -1; - - #if defined (DEBUG) - if ((build_log_size > 1) || (CL_rc == -1)) - #else - if (CL_rc == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - const int rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->opencl_program, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - - if (rc_clGetProgramBuildInfo == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (CL_rc == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - if (cache_disable == false) - { - size_t binary_size; - - if (hc_clGetProgramInfo (hashcat_ctx, device_param->opencl_program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL) == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - if (hc_clGetProgramInfo (hashcat_ctx, device_param->opencl_program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL) == -1) return -1; - - if (write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size) == false) return -1; - - hcfree (binary); - } - } - } - else - { - if (read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false) == false) return -1; - - if (device_param->is_cuda == true) - { - if (hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module, kernel_sources[0]) == -1) return -1; - } - - if (device_param->is_opencl == true) - { - if (hc_clCreateProgramWithBinary (hashcat_ctx, device_param->opencl_context, 1, &device_param->opencl_device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->opencl_program) == -1) return -1; - - if (hc_clBuildProgram (hashcat_ctx, device_param->opencl_program, 1, &device_param->opencl_device, build_options_module_buf, NULL, NULL) == -1) return -1; - } + return -1; } - hcfree (kernel_sources[0]); + hcfree (build_options_module_buf); } - hcfree (build_options_module_buf); - /** * word generator kernel */ @@ -7250,194 +8094,14 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); - bool cached = true; + const bool rc_load_kernel = load_kernel (hashcat_ctx, device_param, "mp_kernel", source_file, cached_file, build_options_buf, cache_disable, &device_param->opencl_program_mp, &device_param->cuda_module_mp); - if (cache_disable == true) + if (rc_load_kernel == false) { - cached = false; + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed.", device_param->device_id + 1, source_file); + + return -1; } - - if (hc_path_read (cached_file) == false) - { - cached = false; - } - - if (hc_path_is_empty (cached_file) == true) - { - cached = false; - } - - /** - * kernel compile or load - */ - - size_t kernel_lengths_buf = 0; - - size_t *kernel_lengths = &kernel_lengths_buf; - - char *kernel_sources_buf = NULL; - - char **kernel_sources = &kernel_sources_buf; - - if (cached == false) - { - #if defined (DEBUG) - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - #endif - - if (read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true) == false) return -1; - - if (device_param->is_cuda == true) - { - nvrtcProgram program; - - if (hc_nvrtcCreateProgram (hashcat_ctx, &program, kernel_sources[0], "mp_kernel", 0, NULL, NULL) == -1) return -1; - - char **nvrtc_options = (char **) hccalloc (4 + strlen (build_options_buf) + 1, sizeof (char *)); // ... - - nvrtc_options[0] = "--restrict"; - nvrtc_options[1] = "--device-as-default-execution-space"; - nvrtc_options[2] = "--gpu-architecture"; - - hc_asprintf (&nvrtc_options[3], "compute_%d%d", device_param->sm_major, device_param->sm_minor); - - char *nvrtc_options_string = hcstrdup (build_options_buf); - - const int num_options = 4 + nvrtc_make_options_array_from_string (nvrtc_options_string, nvrtc_options + 4); - - const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options); - - size_t build_log_size = 0; - - hc_nvrtcGetProgramLogSize (hashcat_ctx, program, &build_log_size); - - #if defined (DEBUG) - if ((build_log_size > 1) || (rc_nvrtcCompileProgram == -1)) - #else - if (rc_nvrtcCompileProgram == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - if (hc_nvrtcGetProgramLog (hashcat_ctx, program, build_log) == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (rc_nvrtcCompileProgram == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - hcfree (nvrtc_options); - hcfree (nvrtc_options_string); - - size_t binary_size = 0; - - if (hc_nvrtcGetPTXSize (hashcat_ctx, program, &binary_size) == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - if (hc_nvrtcGetPTX (hashcat_ctx, program, binary) == -1) return -1; - - if (hc_nvrtcDestroyProgram (hashcat_ctx, &program) == -1) return -1; - - // tbd: check for some useful options - - const int rc_cuModuleLoadDataEx = hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_mp, binary); - - if (rc_cuModuleLoadDataEx == -1) return -1; - - if (cache_disable == false) - { - const bool rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - - if (rc_write == false) return -1; - } - - hcfree (binary); - } - - if (device_param->is_opencl == true) - { - if (hc_clCreateProgramWithSource (hashcat_ctx, device_param->opencl_context, 1, (const char **) kernel_sources, NULL, &device_param->opencl_program_mp) == -1) return -1; - - const int CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->opencl_program_mp, 1, &device_param->opencl_device, build_options_buf, NULL, NULL); - - //if (CL_rc == -1) return -1; - - size_t build_log_size = 0; - - hc_clGetProgramBuildInfo (hashcat_ctx, device_param->opencl_program_mp, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - - //if (CL_rc == -1) return -1; - - #if defined (DEBUG) - if ((build_log_size > 1) || (CL_rc == -1)) - #else - if (CL_rc == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - const int rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->opencl_program_mp, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - - if (rc_clGetProgramBuildInfo == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (CL_rc == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - if (cache_disable == false) - { - size_t binary_size = 0; - - if (hc_clGetProgramInfo (hashcat_ctx, device_param->opencl_program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL) == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - if (hc_clGetProgramInfo (hashcat_ctx, device_param->opencl_program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL) == -1) return -1; - - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - - hcfree (binary); - } - } - } - else - { - if (read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false) == false) return -1; - - if (device_param->is_cuda == true) - { - if (hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_mp, kernel_sources[0]) == -1) return -1; - } - - if (device_param->is_opencl == true) - { - if (hc_clCreateProgramWithBinary (hashcat_ctx, device_param->opencl_context, 1, &device_param->opencl_device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->opencl_program_mp) == -1) return -1; - - if (hc_clBuildProgram (hashcat_ctx, device_param->opencl_program_mp, 1, &device_param->opencl_device, build_options_buf, NULL, NULL) == -1) return -1; - } - } - - hcfree (kernel_sources[0]); } } @@ -7479,193 +8143,15 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) generate_cached_kernel_amp_filename (user_options_extra->attack_kern, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); - bool cached = true; + const bool rc_load_kernel = load_kernel (hashcat_ctx, device_param, "amp_kernel", source_file, cached_file, build_options_buf, cache_disable, &device_param->opencl_program_amp, &device_param->cuda_module_amp); - if (cache_disable == true) + if (rc_load_kernel == false) { - cached = false; + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed.", device_param->device_id + 1, source_file); + + return -1; } - if (hc_path_read (cached_file) == false) - { - cached = false; - } - - if (hc_path_is_empty (cached_file) == true) - { - cached = false; - } - - /** - * kernel compile or load - */ - - size_t kernel_lengths_buf = 0; - - size_t *kernel_lengths = &kernel_lengths_buf; - - char *kernel_sources_buf = NULL; - - char **kernel_sources = &kernel_sources_buf; - - if (cached == false) - { - #if defined (DEBUG) - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - #endif - - const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); - - if (rc_read_kernel == false) return -1; - - if (device_param->is_cuda == true) - { - nvrtcProgram program; - - if (hc_nvrtcCreateProgram (hashcat_ctx, &program, kernel_sources[0], "mp_kernel", 0, NULL, NULL) == -1) return -1; - - char **nvrtc_options = (char **) hccalloc (4 + strlen (build_options_buf) + 1, sizeof (char *)); // ... - - nvrtc_options[0] = "--restrict"; - nvrtc_options[1] = "--device-as-default-execution-space"; - nvrtc_options[2] = "--gpu-architecture"; - - hc_asprintf (&nvrtc_options[3], "compute_%d%d", device_param->sm_major, device_param->sm_minor); - - char *nvrtc_options_string = hcstrdup (build_options_buf); - - const int num_options = 4 + nvrtc_make_options_array_from_string (nvrtc_options_string, nvrtc_options + 4); - - const int rc_nvrtcCompileProgram = hc_nvrtcCompileProgram (hashcat_ctx, program, num_options, (const char * const *) nvrtc_options); - - size_t build_log_size = 0; - - hc_nvrtcGetProgramLogSize (hashcat_ctx, program, &build_log_size); - - #if defined (DEBUG) - if ((build_log_size > 1) || (rc_nvrtcCompileProgram == -1)) - #else - if (rc_nvrtcCompileProgram == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - if (hc_nvrtcGetProgramLog (hashcat_ctx, program, build_log) == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (rc_nvrtcCompileProgram == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - hcfree (nvrtc_options); - hcfree (nvrtc_options_string); - - size_t binary_size = 0; - - if (hc_nvrtcGetPTXSize (hashcat_ctx, program, &binary_size) == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - if (hc_nvrtcGetPTX (hashcat_ctx, program, binary) == -1) return -1; - - if (hc_nvrtcDestroyProgram (hashcat_ctx, &program) == -1) return -1; - - // tbd: check for some useful options - - if (hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_amp, binary) == -1) return -1; - - if (cache_disable == false) - { - if (write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size) == false) return -1; - } - - hcfree (binary); - } - - if (device_param->is_opencl == true) - { - if (hc_clCreateProgramWithSource (hashcat_ctx, device_param->opencl_context, 1, (const char **) kernel_sources, NULL, &device_param->opencl_program_amp) == -1) return -1; - - const int CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->opencl_program_amp, 1, &device_param->opencl_device, build_options_buf, NULL, NULL); - - //if (CL_rc == -1) return -1; - - size_t build_log_size = 0; - - hc_clGetProgramBuildInfo (hashcat_ctx, device_param->opencl_program_amp, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - - //if (CL_rc == -1) return -1; - - #if defined (DEBUG) - if ((build_log_size > 1) || (CL_rc == -1)) - #else - if (CL_rc == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); - - const int rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->opencl_program_amp, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - - if (rc_clGetProgramBuildInfo == -1) return -1; - - puts (build_log); - - hcfree (build_log); - } - - if (CL_rc == -1) - { - device_param->skipped_warning = true; - - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - - continue; - } - - if (cache_disable == false) - { - size_t binary_size; - - if (hc_clGetProgramInfo (hashcat_ctx, device_param->opencl_program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL) == -1) return -1; - - char *binary = (char *) hcmalloc (binary_size); - - if (hc_clGetProgramInfo (hashcat_ctx, device_param->opencl_program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL) == -1) return -1; - - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - - hcfree (binary); - } - } - } - else - { - if (read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false) == false) return -1; - - if (device_param->is_cuda == true) - { - if (hc_cuModuleLoadDataExLog (hashcat_ctx, &device_param->cuda_module_amp, kernel_sources[0]) == -1) return -1; - } - - if (device_param->is_opencl == true) - { - if (hc_clCreateProgramWithBinary (hashcat_ctx, device_param->opencl_context, 1, &device_param->opencl_device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->opencl_program_amp) == -1) return -1; - - if (hc_clBuildProgram (hashcat_ctx, device_param->opencl_program_amp, 1, &device_param->opencl_device, build_options_buf, NULL, NULL) == -1) return -1; - } - } - - hcfree (kernel_sources[0]); - hcfree (build_options_buf); } } @@ -7687,6 +8173,38 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) * global buffers */ + const u64 size_total_fixed + = bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + bitmap_ctx->bitmap_size + + size_plains + + size_digests + + size_shown + + size_salts + + size_results + + size_extra_buffer + + size_st_digests + + size_st_salts + + size_st_esalts + + size_esalts + + size_markov_css + + size_root_css + + size_rules + + size_rules_c + + size_tm; + + if (size_total_fixed > device_param->device_available_mem) + { + event_log_error (hashcat_ctx, "* Device #%u: Not enough allocatable device memory for this hashlist and/or ruleset.", device_id + 1); + + return -1; + } + if (device_param->is_cuda == true) { if (hc_cuMemAlloc (hashcat_ctx, &device_param->cuda_d_bitmap_s1_a, bitmap_ctx->bitmap_size) == -1) return -1; @@ -8188,6 +8706,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function1, &device_param->kernel_local_mem_size1) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function1, &device_param->kernel_dynamic_local_mem_size1) == -1) return -1; + device_param->kernel_preferred_wgs_multiple1 = device_param->cuda_warp_size; // kernel2 @@ -8200,6 +8720,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function2, &device_param->kernel_local_mem_size2) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function2, &device_param->kernel_dynamic_local_mem_size2) == -1) return -1; + device_param->kernel_preferred_wgs_multiple2 = device_param->cuda_warp_size; // kernel3 @@ -8212,6 +8734,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function3, &device_param->kernel_local_mem_size3) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function3, &device_param->kernel_dynamic_local_mem_size3) == -1) return -1; + device_param->kernel_preferred_wgs_multiple3 = device_param->cuda_warp_size; } else @@ -8224,6 +8748,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function4, &device_param->kernel_local_mem_size4) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function4, &device_param->kernel_dynamic_local_mem_size4) == -1) return -1; + device_param->kernel_preferred_wgs_multiple4 = device_param->cuda_warp_size; } } @@ -8241,6 +8767,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function1, &device_param->kernel_local_mem_size1) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function1, &device_param->kernel_dynamic_local_mem_size1) == -1) return -1; + device_param->kernel_preferred_wgs_multiple1 = device_param->cuda_warp_size; // kernel2 @@ -8253,6 +8781,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function2, &device_param->kernel_local_mem_size2) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function2, &device_param->kernel_dynamic_local_mem_size2) == -1) return -1; + device_param->kernel_preferred_wgs_multiple2 = device_param->cuda_warp_size; // kernel3 @@ -8265,6 +8795,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function3, &device_param->kernel_local_mem_size3) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function3, &device_param->kernel_dynamic_local_mem_size3) == -1) return -1; + device_param->kernel_preferred_wgs_multiple3 = device_param->cuda_warp_size; } else @@ -8277,6 +8809,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function4, &device_param->kernel_local_mem_size4) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function4, &device_param->kernel_dynamic_local_mem_size4) == -1) return -1; + device_param->kernel_preferred_wgs_multiple4 = device_param->cuda_warp_size; } } @@ -8288,7 +8822,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode == ATTACK_MODE_BF) { - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL) { snprintf (kernel_name, sizeof (kernel_name), "m%05u_tm", kern_type); @@ -8298,6 +8832,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_tm, &device_param->kernel_local_mem_size_tm) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_tm, &device_param->kernel_dynamic_local_mem_size_tm) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_tm = device_param->cuda_warp_size; } } @@ -8315,6 +8851,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function1, &device_param->kernel_local_mem_size1) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function1, &device_param->kernel_dynamic_local_mem_size1) == -1) return -1; + device_param->kernel_preferred_wgs_multiple1 = device_param->cuda_warp_size; // kernel2 @@ -8327,6 +8865,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function2, &device_param->kernel_local_mem_size2) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function2, &device_param->kernel_dynamic_local_mem_size2) == -1) return -1; + device_param->kernel_preferred_wgs_multiple2 = device_param->cuda_warp_size; // kernel3 @@ -8339,8 +8879,27 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function3, &device_param->kernel_local_mem_size3) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function3, &device_param->kernel_dynamic_local_mem_size3) == -1) return -1; + device_param->kernel_preferred_wgs_multiple3 = device_param->cuda_warp_size; + if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED) + { + // kernel2e + + snprintf (kernel_name, sizeof (kernel_name), "m%05u_loop_extended", kern_type); + + if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function2e, device_param->cuda_module, kernel_name) == -1) return -1; + + if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function2e, &device_param->kernel_wgs2e) == -1) return -1; + + if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function2e, &device_param->kernel_local_mem_size2e) == -1) return -1; + + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function2e, &device_param->kernel_dynamic_local_mem_size2e) == -1) return -1; + + device_param->kernel_preferred_wgs_multiple2e = device_param->cuda_warp_size; + } + // kernel12 if (hashconfig->opts_type & OPTS_TYPE_HOOK12) @@ -8353,6 +8912,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function12, &device_param->kernel_local_mem_size12) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function12, &device_param->kernel_dynamic_local_mem_size12) == -1) return -1; + device_param->kernel_preferred_wgs_multiple12 = device_param->cuda_warp_size; } @@ -8368,6 +8929,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function23, &device_param->kernel_local_mem_size23) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function23, &device_param->kernel_dynamic_local_mem_size23) == -1) return -1; + device_param->kernel_preferred_wgs_multiple23 = device_param->cuda_warp_size; } @@ -8383,6 +8946,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_init2, &device_param->kernel_local_mem_size_init2) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_init2, &device_param->kernel_dynamic_local_mem_size_init2) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_init2 = device_param->cuda_warp_size; } @@ -8398,6 +8963,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_loop2, &device_param->kernel_local_mem_size_loop2) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_loop2, &device_param->kernel_dynamic_local_mem_size_loop2) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_loop2 = device_param->cuda_warp_size; } @@ -8413,6 +8980,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_aux1, &device_param->kernel_local_mem_size_aux1) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_aux1, &device_param->kernel_dynamic_local_mem_size_aux1) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_aux1 = device_param->cuda_warp_size; } @@ -8428,6 +8997,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_aux2, &device_param->kernel_local_mem_size_aux2) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_aux2, &device_param->kernel_dynamic_local_mem_size_aux2) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_aux2 = device_param->cuda_warp_size; } @@ -8443,6 +9014,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_aux3, &device_param->kernel_local_mem_size_aux3) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_aux3, &device_param->kernel_dynamic_local_mem_size_aux3) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_aux3 = device_param->cuda_warp_size; } @@ -8458,47 +9031,12 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_aux4, &device_param->kernel_local_mem_size_aux4) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_aux4, &device_param->kernel_dynamic_local_mem_size_aux4) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_aux4 = device_param->cuda_warp_size; } } - // GPU memset - - if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function_memset, device_param->cuda_module, "gpu_memset") == -1) return -1; - - if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function_memset, &device_param->kernel_wgs_memset) == -1) return -1; - - if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_memset, &device_param->kernel_local_mem_size_memset) == -1) return -1; - - device_param->kernel_preferred_wgs_multiple_memset = device_param->cuda_warp_size; - - //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); if (CL_rc == -1) return -1; - //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); if (CL_rc == -1) return -1; - //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 2, sizeof (cl_ulong), device_param->kernel_params_memset[2]); if (CL_rc == -1) return -1; - - // GPU autotune init - - if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function_atinit, device_param->cuda_module, "gpu_atinit") == -1) return -1; - - if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function_atinit, &device_param->kernel_wgs_atinit) == -1) return -1; - - if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_atinit, &device_param->kernel_local_mem_size_atinit) == -1) return -1; - - device_param->kernel_preferred_wgs_multiple_atinit = device_param->cuda_warp_size; - - // CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 0, sizeof (cl_mem), device_param->kernel_params_atinit[0]); if (CL_rc == -1) return -1; - // CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 1, sizeof (cl_ulong), device_param->kernel_params_atinit[1]); if (CL_rc == -1) return -1; - - // GPU decompress - - if (hc_cuModuleGetFunction (hashcat_ctx, &device_param->cuda_function_decompress, device_param->cuda_module, "gpu_decompress") == -1) return -1; - - if (get_cuda_kernel_wgs (hashcat_ctx, device_param->cuda_function_decompress, &device_param->kernel_wgs_decompress) == -1) return -1; - - if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_decompress, &device_param->kernel_local_mem_size_decompress) == -1) return -1; - - device_param->kernel_preferred_wgs_multiple_decompress = device_param->cuda_warp_size; - //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 0, sizeof (cl_mem), device_param->kernel_params_decompress[0]); if (CL_rc == -1) return -1; //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 1, sizeof (cl_mem), device_param->kernel_params_decompress[1]); if (CL_rc == -1) return -1; //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 2, sizeof (cl_mem), device_param->kernel_params_decompress[2]); if (CL_rc == -1) return -1; @@ -8521,6 +9059,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_mp_l, &device_param->kernel_local_mem_size_mp_l) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_mp_l, &device_param->kernel_dynamic_local_mem_size_mp_l) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_mp_l = device_param->cuda_warp_size; // mp_r @@ -8531,12 +9071,17 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_mp_r, &device_param->kernel_local_mem_size_mp_r) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_mp_r, &device_param->kernel_dynamic_local_mem_size_mp_r) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_mp_r = device_param->cuda_warp_size; - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (user_options->attack_mode == ATTACK_MODE_BF) { - //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); if (CL_rc == -1) return -1; - //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); if (CL_rc == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL) + { + //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); if (CL_rc == -1) return -1; + //CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); if (CL_rc == -1) return -1; + } } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) @@ -8547,6 +9092,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_mp, &device_param->kernel_local_mem_size_mp) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_mp, &device_param->kernel_dynamic_local_mem_size_mp) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_mp = device_param->cuda_warp_size; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) @@ -8557,6 +9104,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_mp, &device_param->kernel_local_mem_size_mp) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_mp, &device_param->kernel_dynamic_local_mem_size_mp) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_mp = device_param->cuda_warp_size; } } @@ -8578,10 +9127,12 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_cuda_kernel_local_mem_size (hashcat_ctx, device_param->cuda_function_amp, &device_param->kernel_local_mem_size_amp) == -1) return -1; + if (get_cuda_kernel_dynamic_local_mem_size (hashcat_ctx, device_param->cuda_function_amp, &device_param->kernel_dynamic_local_mem_size_amp) == -1) return -1; + device_param->kernel_preferred_wgs_multiple_amp = device_param->cuda_warp_size; } -/* + /* if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { // nothing to do @@ -8609,7 +9160,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) //if (CL_rc == -1) return -1; } } -*/ + */ } // zero some data buffers @@ -8705,6 +9256,24 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (device_param->is_opencl == true) { + // GPU memset + + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 2, sizeof (cl_ulong), device_param->kernel_params_memset[2]) == -1) return -1; + + // GPU autotune init + + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 0, sizeof (cl_mem), device_param->kernel_params_atinit[0]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 1, sizeof (cl_ulong), device_param->kernel_params_atinit[1]) == -1) return -1; + + // GPU decompress + + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 0, sizeof (cl_mem), device_param->kernel_params_decompress[0]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 1, sizeof (cl_mem), device_param->kernel_params_decompress[1]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 2, sizeof (cl_mem), device_param->kernel_params_decompress[2]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 3, sizeof (cl_ulong), device_param->kernel_params_decompress[3]) == -1) return -1; + char kernel_name[64] = { 0 }; if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -8723,6 +9292,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_local_mem_size1) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_dynamic_local_mem_size1) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_preferred_wgs_multiple1) == -1) return -1; // kernel2 @@ -8735,6 +9306,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_local_mem_size2) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_dynamic_local_mem_size2) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_preferred_wgs_multiple2) == -1) return -1; // kernel3 @@ -8747,6 +9320,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_local_mem_size3) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_dynamic_local_mem_size3) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_preferred_wgs_multiple3) == -1) return -1; } else @@ -8759,6 +9334,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel4, &device_param->kernel_local_mem_size4) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel4, &device_param->kernel_dynamic_local_mem_size4) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel4, &device_param->kernel_preferred_wgs_multiple4) == -1) return -1; } } @@ -8776,6 +9353,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_local_mem_size1) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_dynamic_local_mem_size1) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_preferred_wgs_multiple1) == -1) return -1; // kernel2 @@ -8788,6 +9367,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_local_mem_size2) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_dynamic_local_mem_size2) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_preferred_wgs_multiple2) == -1) return -1; // kernel3 @@ -8800,6 +9381,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_local_mem_size3) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_dynamic_local_mem_size3) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_preferred_wgs_multiple3) == -1) return -1; } else @@ -8812,6 +9395,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel4, &device_param->kernel_local_mem_size4) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel4, &device_param->kernel_dynamic_local_mem_size4) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel4, &device_param->kernel_preferred_wgs_multiple4) == -1) return -1; } } @@ -8823,7 +9408,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode == ATTACK_MODE_BF) { - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL) { snprintf (kernel_name, sizeof (kernel_name), "m%05u_tm", kern_type); @@ -8833,6 +9418,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_tm, &device_param->kernel_local_mem_size_tm) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_tm, &device_param->kernel_dynamic_local_mem_size_tm) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_tm, &device_param->kernel_preferred_wgs_multiple_tm) == -1) return -1; } } @@ -8850,6 +9437,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_local_mem_size1) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_dynamic_local_mem_size1) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel1, &device_param->kernel_preferred_wgs_multiple1) == -1) return -1; // kernel2 @@ -8862,6 +9451,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_local_mem_size2) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_dynamic_local_mem_size2) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel2, &device_param->kernel_preferred_wgs_multiple2) == -1) return -1; // kernel3 @@ -8874,8 +9465,27 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_local_mem_size3) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_dynamic_local_mem_size3) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel3, &device_param->kernel_preferred_wgs_multiple3) == -1) return -1; + // aux1 + + if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED) + { + snprintf (kernel_name, sizeof (kernel_name), "m%05u_loop_extended", kern_type); + + if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program, kernel_name, &device_param->opencl_kernel2e) == -1) return -1; + + if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel2e, &device_param->kernel_wgs2e) == -1) return -1; + + if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2e, &device_param->kernel_local_mem_size2e) == -1) return -1; + + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel2e, &device_param->kernel_dynamic_local_mem_size2e) == -1) return -1; + + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel2e, &device_param->kernel_preferred_wgs_multiple2e) == -1) return -1; + } + // kernel12 if (hashconfig->opts_type & OPTS_TYPE_HOOK12) @@ -8888,6 +9498,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel12, &device_param->kernel_local_mem_size12) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel12, &device_param->kernel_dynamic_local_mem_size12) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel12, &device_param->kernel_preferred_wgs_multiple12) == -1) return -1; } @@ -8903,6 +9515,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel23, &device_param->kernel_local_mem_size23) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel23, &device_param->kernel_dynamic_local_mem_size23) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel23, &device_param->kernel_preferred_wgs_multiple23) == -1) return -1; } @@ -8918,6 +9532,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_init2, &device_param->kernel_local_mem_size_init2) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_init2, &device_param->kernel_dynamic_local_mem_size_init2) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_init2, &device_param->kernel_preferred_wgs_multiple_init2) == -1) return -1; } @@ -8933,6 +9549,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_loop2, &device_param->kernel_local_mem_size_loop2) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_loop2, &device_param->kernel_dynamic_local_mem_size_loop2) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_loop2, &device_param->kernel_preferred_wgs_multiple_loop2) == -1) return -1; } @@ -8948,6 +9566,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux1, &device_param->kernel_local_mem_size_aux1) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux1, &device_param->kernel_dynamic_local_mem_size_aux1) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_aux1, &device_param->kernel_preferred_wgs_multiple_aux1) == -1) return -1; } @@ -8963,6 +9583,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux2, &device_param->kernel_local_mem_size_aux2) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux2, &device_param->kernel_dynamic_local_mem_size_aux2) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_aux2, &device_param->kernel_preferred_wgs_multiple_aux2) == -1) return -1; } @@ -8978,6 +9600,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux3, &device_param->kernel_local_mem_size_aux3) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux3, &device_param->kernel_dynamic_local_mem_size_aux3) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_aux3, &device_param->kernel_preferred_wgs_multiple_aux3) == -1) return -1; } @@ -8993,52 +9617,12 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux4, &device_param->kernel_local_mem_size_aux4) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_aux4, &device_param->kernel_dynamic_local_mem_size_aux4) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_aux4, &device_param->kernel_preferred_wgs_multiple_aux4) == -1) return -1; } } - // GPU memset - - if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program, "gpu_memset", &device_param->opencl_kernel_memset) == -1) return -1; - - if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_wgs_memset) == -1) return -1; - - if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_local_mem_size_memset) == -1) return -1; - - if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_memset, &device_param->kernel_preferred_wgs_multiple_memset) == -1) return -1; - - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_memset, 2, sizeof (cl_ulong), device_param->kernel_params_memset[2]) == -1) return -1; - - // GPU autotune init - - if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program, "gpu_atinit", &device_param->opencl_kernel_atinit) == -1) return -1; - - if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_wgs_atinit) == -1) return -1; - - if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_local_mem_size_atinit) == -1) return -1; - - if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_atinit, &device_param->kernel_preferred_wgs_multiple_atinit) == -1) return -1; - - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 0, sizeof (cl_mem), device_param->kernel_params_atinit[0]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_atinit, 1, sizeof (cl_ulong), device_param->kernel_params_atinit[1]) == -1) return -1; - - // GPU decompress - - if (hc_clCreateKernel (hashcat_ctx, device_param->opencl_program, "gpu_decompress", &device_param->opencl_kernel_decompress) == -1) return -1; - - if (get_opencl_kernel_wgs (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_wgs_decompress) == -1) return -1; - - if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_local_mem_size_decompress) == -1) return -1; - - if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_decompress, &device_param->kernel_preferred_wgs_multiple_decompress) == -1) return -1; - - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 0, sizeof (cl_mem), device_param->kernel_params_decompress[0]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 1, sizeof (cl_mem), device_param->kernel_params_decompress[1]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 2, sizeof (cl_mem), device_param->kernel_params_decompress[2]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_decompress, 3, sizeof (cl_ulong), device_param->kernel_params_decompress[3]) == -1) return -1; - // MP start if (user_options->slow_candidates == true) @@ -9056,6 +9640,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp_l, &device_param->kernel_local_mem_size_mp_l) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp_l, &device_param->kernel_dynamic_local_mem_size_mp_l) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_mp_l, &device_param->kernel_preferred_wgs_multiple_mp_l) == -1) return -1; // mp_r @@ -9066,12 +9652,17 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp_r, &device_param->kernel_local_mem_size_mp_r) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp_r, &device_param->kernel_dynamic_local_mem_size_mp_r) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_mp_r, &device_param->kernel_preferred_wgs_multiple_mp_r) == -1) return -1; - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (user_options->attack_mode == ATTACK_MODE_BF) { - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]) == -1) return -1; - if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]) == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL) + { + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]) == -1) return -1; + if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]) == -1) return -1; + } } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) @@ -9082,6 +9673,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp, &device_param->kernel_local_mem_size_mp) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp, &device_param->kernel_dynamic_local_mem_size_mp) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_mp, &device_param->kernel_preferred_wgs_multiple_mp) == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) @@ -9092,6 +9685,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp, &device_param->kernel_local_mem_size_mp) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_mp, &device_param->kernel_dynamic_local_mem_size_mp) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_mp, &device_param->kernel_preferred_wgs_multiple_mp) == -1) return -1; } } @@ -9113,6 +9708,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (get_opencl_kernel_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_amp, &device_param->kernel_local_mem_size_amp) == -1) return -1; + if (get_opencl_kernel_dynamic_local_mem_size (hashcat_ctx, device_param, device_param->opencl_kernel_amp, &device_param->kernel_dynamic_local_mem_size_amp) == -1) return -1; + if (get_opencl_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->opencl_kernel_amp, &device_param->kernel_preferred_wgs_multiple_amp) == -1) return -1; } @@ -9235,13 +9832,16 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - // not required - } - else - { - device_param->kernel_threads_max = MIN (device_param->kernel_threads_max, 64); + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + // not required + } + else + { + device_param->kernel_threads_max = MIN (device_param->kernel_threads_max, 64); + } } } @@ -9258,6 +9858,22 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) u32 kernel_accel_min = device_param->kernel_accel_min; u32 kernel_accel_max = device_param->kernel_accel_max; + /** + * We need a kernel accel limiter otherwise we will allocate too much memory (Example 4* GTX1080): + * 4 (gpus) * 260 (sizeof pw_t) * 3 (pws, pws_comp, pw_pre) * 20 (MCU) * 1024 (threads) * 1024 (accel) = 65,431,142,400 bytes RAM!! + */ + + const u32 accel_limit = CEILDIV ((64 * 1024), kernel_threads); // this should result in less than 4GB per GPU, but allow higher accel in case user reduces the threads manually using -T + + kernel_accel_max = MIN (kernel_accel_max, accel_limit); + + if (kernel_accel_min > kernel_accel_max) + { + event_log_error (hashcat_ctx, "* Device #%u: Too many compute units to keep minimum kernel accel limit. Retry with lower --backend-kernel-threads value.", device_id + 1); + + return -1; + } + // find out if we would request too much memory on memory blocks which are based on kernel_accel u64 size_pws = 4; @@ -9752,6 +10368,7 @@ void backend_session_destroy (hashcat_ctx_t *hashcat_ctx) device_param->cuda_function1 = NULL; device_param->cuda_function12 = NULL; device_param->cuda_function2 = NULL; + device_param->cuda_function2e = NULL; device_param->cuda_function23 = NULL; device_param->cuda_function3 = NULL; device_param->cuda_function4 = NULL; @@ -9819,6 +10436,7 @@ void backend_session_destroy (hashcat_ctx_t *hashcat_ctx) if (device_param->opencl_kernel1) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel1); if (device_param->opencl_kernel12) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel12); if (device_param->opencl_kernel2) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel2); + if (device_param->opencl_kernel2e) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel2e); if (device_param->opencl_kernel23) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel23); if (device_param->opencl_kernel3) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel3); if (device_param->opencl_kernel4) hc_clReleaseKernel (hashcat_ctx, device_param->opencl_kernel4); @@ -9884,6 +10502,7 @@ void backend_session_destroy (hashcat_ctx_t *hashcat_ctx) device_param->opencl_kernel1 = NULL; device_param->opencl_kernel12 = NULL; device_param->opencl_kernel2 = NULL; + device_param->opencl_kernel2e = NULL; device_param->opencl_kernel23 = NULL; device_param->opencl_kernel3 = NULL; device_param->opencl_kernel4 = NULL; @@ -10131,3 +10750,51 @@ int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_ return 0; } + +void *hook12_thread (void *p) +{ + hook_thread_param_t *hook_thread_param = (hook_thread_param_t *) p; + + module_ctx_t *module_ctx = hook_thread_param->module_ctx; + status_ctx_t *status_ctx = hook_thread_param->status_ctx; + + const u64 tid = hook_thread_param->tid; + const u64 tsz = hook_thread_param->tsz; + const u64 pws_cnt = hook_thread_param->pws_cnt; + + for (u64 pw_pos = tid; pw_pos < pws_cnt; pw_pos += tsz) + { + while (status_ctx->devices_status == STATUS_PAUSED) sleep (1); + + if (status_ctx->devices_status == STATUS_RUNNING) + { + module_ctx->module_hook12 (hook_thread_param->device_param, hook_thread_param->hook_salts_buf, hook_thread_param->salt_pos, pw_pos); + } + } + + return NULL; +} + +void *hook23_thread (void *p) +{ + hook_thread_param_t *hook_thread_param = (hook_thread_param_t *) p; + + module_ctx_t *module_ctx = hook_thread_param->module_ctx; + status_ctx_t *status_ctx = hook_thread_param->status_ctx; + + const u64 tid = hook_thread_param->tid; + const u64 tsz = hook_thread_param->tsz; + const u64 pws_cnt = hook_thread_param->pws_cnt; + + for (u64 pw_pos = tid; pw_pos < pws_cnt; pw_pos += tsz) + { + while (status_ctx->devices_status == STATUS_PAUSED) sleep (1); + + if (status_ctx->devices_status == STATUS_RUNNING) + { + module_ctx->module_hook23 (hook_thread_param->device_param, hook_thread_param->hook_salts_buf, hook_thread_param->salt_pos, pw_pos); + } + } + + return NULL; +} diff --git a/src/benchmark.c b/src/benchmark.c index 05f0c35a6..3653b4fd1 100644 --- a/src/benchmark.c +++ b/src/benchmark.c @@ -16,7 +16,7 @@ static const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[] = 100, 1400, 1700, - 2500, + 22000, 1000, 3000, 5500, diff --git a/src/brain.c b/src/brain.c index d67170cd4..e91347c8b 100644 --- a/src/brain.c +++ b/src/brain.c @@ -66,7 +66,7 @@ u32 brain_compute_session (hashcat_ctx_t *hashcat_ctx) // digest u32 digests_cnt = hashes->digests_cnt; - u32 *digests_buf = hashes->digests_buf; + u32 *digests_buf = (u32 *) hashes->digests_buf; XXH64_update (state, digests_buf, digests_cnt * hashconfig->dgst_size); @@ -1950,11 +1950,15 @@ void *brain_server_handle_dumps (void *p) brain_server_dbs_t *brain_server_dbs = brain_server_dumper_options->brain_server_dbs; - int i = 0; + u32 brain_server_timer = brain_server_dumper_options->brain_server_timer; + + if (brain_server_timer == 0) return NULL; + + u32 i = 0; while (keep_running == true) { - if (i == BRAIN_SERVER_DUMP_EVERY) + if (i == brain_server_timer) { brain_server_write_hash_dumps (brain_server_dbs, "."); brain_server_write_attack_dumps (brain_server_dbs, "."); @@ -2306,7 +2310,7 @@ void *brain_server_handle_client (void *p) // short global alloc - brain_server_db_short_t *brain_server_db_short = hcmalloc (sizeof (brain_server_db_short_t)); + brain_server_db_short_t *brain_server_db_short = (brain_server_db_short_t *) hcmalloc (sizeof (brain_server_db_short_t)); brain_server_db_short->short_cnt = 0; brain_server_db_short->short_buf = (brain_server_hash_short_t *) hccalloc (passwords_max, sizeof (brain_server_hash_short_t)); @@ -2923,7 +2927,7 @@ void *brain_server_handle_client (void *p) return NULL; } -int brain_server (const char *listen_host, const int listen_port, const char *brain_password, const char *brain_session_whitelist) +int brain_server (const char *listen_host, const int listen_port, const char *brain_password, const char *brain_session_whitelist, const u32 brain_server_timer) { #if defined (_WIN) WSADATA wsaData; @@ -3193,7 +3197,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br brain_server_dumper_options_t brain_server_dumper_options; - brain_server_dumper_options.brain_server_dbs = brain_server_dbs; + brain_server_dumper_options.brain_server_dbs = brain_server_dbs; + brain_server_dumper_options.brain_server_timer = brain_server_timer; hc_thread_t dump_thr; diff --git a/src/convert.c b/src/convert.c index befca7fb9..3a26d6a28 100644 --- a/src/convert.c +++ b/src/convert.c @@ -311,6 +311,27 @@ bool is_valid_hex_char (const u8 c) return false; } +bool is_valid_float_string (const u8 *s, const size_t len) +{ + for (size_t i = 0; i < len; i++) + { + const u8 c = s[i]; + + if (is_valid_float_char (c) == false) return false; + } + + return true; +} + +bool is_valid_float_char (const u8 c) +{ + if ((c >= '0') && (c <= '9')) return true; + + if (c == '.') return true; + + return false; +} + bool is_valid_digit_string (const u8 *s, const size_t len) { for (size_t i = 0; i < len; i++) diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index f7e9accff..1da9094bc 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -85,7 +85,7 @@ u32 cpu_crc32_buffer (const u8 *buf, const size_t length) crc = crc32tab[(crc ^ buf[pos]) & 0xff] ^ (crc >> 8); } - return crc ^ 0xffffffff;; + return crc ^ 0xffffffff; } int cpu_crc32 (const char *filename, u8 keytab[64]) diff --git a/src/debugfile.c b/src/debugfile.c index 839dcba35..a6ffd3826 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -141,6 +141,8 @@ void debugfile_destroy (hashcat_ctx_t *hashcat_ctx) if (debugfile_ctx->filename) { + hc_unlockfile (&debugfile_ctx->fp); + hc_fclose (&debugfile_ctx->fp); } diff --git a/src/dictstat.c b/src/dictstat.c index caab3deea..03736e74b 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -17,6 +17,10 @@ int sort_by_dictstat (const void *s1, const void *s2) const dictstat_t *d1 = (const dictstat_t *) s1; const dictstat_t *d2 = (const dictstat_t *) s2; + const int rc_hash = memcmp (d1->hash_filename, d2->hash_filename, 16); + + if (rc_hash != 0) return rc_hash; + const int rc_from = strcmp (d1->encoding_from, d2->encoding_from); if (rc_from != 0) return rc_from; @@ -217,6 +221,15 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx) hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, &fp); + if (hc_unlockfile (&fp) == -1) + { + hc_fclose (&fp); + + event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno)); + + return -1; + } + hc_fclose (&fp); return 0; diff --git a/src/dispatch.c b/src/dispatch.c index b2e936235..428be4371 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -1390,8 +1390,6 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { get_next_word (hashcat_ctx_tmp, &fp, &line_buf, &line_len); - line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); - // post-process rule engine if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) diff --git a/src/emu_inc_ecc_secp256k1.c b/src/emu_inc_ecc_secp256k1.c new file mode 100644 index 000000000..934824312 --- /dev/null +++ b/src/emu_inc_ecc_secp256k1.c @@ -0,0 +1,13 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "types.h" +#include "common.h" +#include "emu_general.h" + +#include "inc_vendor.h" +#include "inc_platform.h" +#include "inc_ecc_secp256k1.cl" + diff --git a/src/filehandling.c b/src/filehandling.c index 9ea564f2a..22a9e2aa6 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -137,7 +137,7 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp) return n; } -size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp) +size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, HCFILE *fp) { size_t n = -1; @@ -443,8 +443,6 @@ void hc_fclose (HCFILE *fp) fclose (fp->pfp); } - close (fp->fd); - fp->fd = -1; fp->pfp = NULL; fp->is_gzip = false; @@ -482,7 +480,7 @@ size_t fgetl (HCFILE *fp, char *line_buf, const size_t line_sz) if (line_truncated > 0) { - fprintf (stderr, "\nOversized line detected! Truncated %" PRIu64 " bytes\n", line_truncated); + fprintf (stderr, "\nOversized line detected! Truncated %" PRIu64 " bytes\n", (u64) line_truncated); } if (line_len == 0) return 0; diff --git a/src/folder.c b/src/folder.c index 27b4837cb..0c313f31c 100644 --- a/src/folder.c +++ b/src/folder.c @@ -340,7 +340,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - char *install_dir = hcmalloc (HCBUFSIZ_TINY); + char *install_dir = (char *) hcmalloc (HCBUFSIZ_TINY); get_install_dir (install_dir, resolved_exec_path); @@ -359,8 +359,8 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins const char *home_dir = pwp->pw_dir; - profile_dir = hcmalloc (HCBUFSIZ_TINY); - session_dir = hcmalloc (HCBUFSIZ_TINY); + profile_dir = (char *) hcmalloc (HCBUFSIZ_TINY); + session_dir = (char *) hcmalloc (HCBUFSIZ_TINY); get_profile_dir (profile_dir, home_dir); get_session_dir (session_dir, profile_dir); @@ -458,7 +458,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins hcfree (cpath); //if (getenv ("TMP") == NULL) - if (1) + if (true) { char *tmp; diff --git a/src/hashcat.c b/src/hashcat.c index 01a069ab7..fb7006d91 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -444,6 +444,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * setup variables and buffers depending on hash_mode */ + EVENT (EVENT_HASHCONFIG_PRE); + if (hashconfig_init (hashcat_ctx) == -1) { event_log_error (hashcat_ctx, "Invalid hash-mode '%u' selected.", user_options->hash_mode); @@ -451,6 +453,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) return -1; } + EVENT (EVENT_HASHCONFIG_POST); + /** * generate hashlist filename for later use */ diff --git a/src/hashes.c b/src/hashes.c index a92af200e..c5d1df4f3 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -258,6 +258,18 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) hc_fflush (&fp); + if (hc_unlockfile (&fp) == -1) + { + hc_fclose (&fp); + + event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno)); + + free (new_hashfile); + free (old_hashfile); + + return -1; + } + hc_fclose (&fp); unlink (old_hashfile); @@ -330,22 +342,23 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl // plain - u8 plain_buf[256+1]; + u8 plain_buf[0x1000]; // while the password itself can have only length 256, the module could encode it with something like base64 which inflates the requires buffer size memset (plain_buf, 0, sizeof (plain_buf)); u8 *plain_ptr = plain_buf; + int plain_len = 0; - build_plain (hashcat_ctx, device_param, plain, (u32 *)plain_buf, &plain_len); + build_plain (hashcat_ctx, device_param, plain, (u32 *) plain_buf, &plain_len); if (module_ctx->module_build_plain_postprocess != MODULE_DEFAULT) { - u8 temp_buf[256+1] = { 0 }; + u8 temp_buf[0x1000]; memset (temp_buf, 0, sizeof (temp_buf)); - const int temp_len = module_ctx->module_build_plain_postprocess (hashcat_ctx->hashconfig, hashcat_ctx->hashes, tmps, (u32 *)plain_buf, sizeof (plain_buf), plain_len, (u32 *)temp_buf, sizeof (temp_buf)); + const int temp_len = module_ctx->module_build_plain_postprocess (hashcat_ctx->hashconfig, hashcat_ctx->hashes, tmps, (u32 *) plain_buf, sizeof (plain_buf), plain_len, (u32 *)temp_buf, sizeof (temp_buf)); if (temp_len < (int) sizeof (plain_buf)) { @@ -470,7 +483,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, salt_t *salt_buf = &hashes->salts_buf[salt_pos]; - u32 num_cracked; + u32 num_cracked = 0; int CU_rc; int CL_rc; @@ -822,6 +835,12 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) for (u64 hash_pos = 0; hash_pos < hashes_avail; hash_pos++) { + /** + * Initialize some values for later use + */ + + hashes_buf[hash_pos].orig_line_pos = hash_pos; + hashes_buf[hash_pos].digest = ((char *) digests_buf) + (hash_pos * hashconfig->dgst_size); if (hashconfig->is_salted == true) @@ -887,10 +906,10 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) hlfmt_hash (hashcat_ctx, hashlist_format, input_buf, input_len, &hash_buf, &hash_len); - bool hash_fmt_error = 0; + bool hash_fmt_error = false; - if (hash_len < 1) hash_fmt_error = 1; - if (hash_buf == NULL) hash_fmt_error = 1; + if (hash_len < 1) hash_fmt_error = true; + if (hash_buf == NULL) hash_fmt_error = true; if (hash_fmt_error) { @@ -1034,10 +1053,10 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) hlfmt_hash (hashcat_ctx, hashlist_format, line_buf, line_len, &hash_buf, &hash_len); - bool hash_fmt_error = 0; + bool hash_fmt_error = false; - if (hash_len < 1) hash_fmt_error = 1; - if (hash_buf == NULL) hash_fmt_error = 1; + if (hash_len < 1) hash_fmt_error = true; + if (hash_buf == NULL) hash_fmt_error = true; if (hash_fmt_error) { diff --git a/src/hwmon.c b/src/hwmon.c index 905ce6e61..a709b3b72 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -18,7 +18,7 @@ static bool sysfs_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - SYSFS_PTR *sysfs = hwmon_ctx->hm_sysfs; + SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; memset (sysfs, 0, sizeof (SYSFS_PTR)); @@ -37,7 +37,7 @@ static void sysfs_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - SYSFS_PTR *sysfs = hwmon_ctx->hm_sysfs; + SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; if (sysfs) { @@ -69,7 +69,7 @@ static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int b return NULL; } - char *hwmon = hcmalloc (HCBUFSIZ_TINY); + char *hwmon = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon", syspath); @@ -405,7 +405,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; memset (nvml, 0, sizeof (NVML_PTR)); @@ -518,22 +518,22 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) return -1; } - HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCount, NVML_DEVICE_GET_COUNT, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetPciInfo, NVML_DEVICE_GET_PCIINFO, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCount, NVML_DEVICE_GET_COUNT, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetPciInfo, NVML_DEVICE_GET_PCIINFO, NVML, 0); return 0; } @@ -542,7 +542,7 @@ static void nvml_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; if (nvml) { @@ -562,9 +562,9 @@ static int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - const nvmlReturn_t nvml_rc = nvml->nvmlInit (); + const nvmlReturn_t nvml_rc = (nvmlReturn_t) nvml->nvmlInit (); if (nvml_rc != NVML_SUCCESS) { @@ -582,9 +582,9 @@ static int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - const nvmlReturn_t nvml_rc = nvml->nvmlShutdown (); + const nvmlReturn_t nvml_rc = (nvmlReturn_t) nvml->nvmlShutdown (); if (nvml_rc != NVML_SUCCESS) { @@ -602,7 +602,7 @@ static int hm_NVML_nvmlDeviceGetCount (hashcat_ctx_t *hashcat_ctx, unsigned int { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCount (deviceCount); @@ -622,7 +622,7 @@ static int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsig { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (device_index, device); @@ -642,7 +642,7 @@ static int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDev { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp); @@ -662,7 +662,7 @@ static int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed); @@ -682,7 +682,7 @@ static int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nv { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization); @@ -702,7 +702,7 @@ static int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevic { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clockfreq); @@ -722,7 +722,7 @@ static int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp); @@ -742,7 +742,7 @@ static int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, n { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth); @@ -762,7 +762,7 @@ static int hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_ { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVML_PTR *nvml = hwmon_ctx->hm_nvml; + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPciInfo (device, pci); @@ -784,7 +784,7 @@ static int nvapi_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; memset (nvapi, 0, sizeof (NVAPI_PTR)); @@ -820,15 +820,15 @@ static int nvapi_init (hashcat_ctx_t *hashcat_ctx) return -1; } - HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828U, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7EU, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048CU, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921FU, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841U, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0CU, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusId, NVAPI_GPU_GETBUSID, nvapi_QueryInterface, 0x1BE0B8E5U, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusSlotId, NVAPI_GPU_GETBUSSLOTID, nvapi_QueryInterface, 0x2A0A350FU, NVAPI, 0) + HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828U, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7EU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048CU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921FU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841U, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0CU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusId, NVAPI_GPU_GETBUSID, nvapi_QueryInterface, 0x1BE0B8E5U, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusSlotId, NVAPI_GPU_GETBUSSLOTID, nvapi_QueryInterface, 0x2A0A350FU, NVAPI, 0); return 0; } @@ -837,7 +837,7 @@ static void nvapi_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; if (nvapi) { @@ -857,9 +857,9 @@ static int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_Initialize (); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_Initialize (); if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) return -1; @@ -881,9 +881,9 @@ static int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_Unload (); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_Unload (); if (NvAPI_rc != NVAPI_OK) { @@ -903,9 +903,9 @@ static int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuH { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); if (NvAPI_rc != NVAPI_OK) { @@ -925,9 +925,9 @@ static int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysi { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); if (NvAPI_rc != NVAPI_OK) { @@ -947,9 +947,9 @@ static int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhy { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); if (NvAPI_rc != NVAPI_OK) { @@ -969,9 +969,9 @@ static int hm_NvAPI_GPU_GetBusId (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandl { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetBusId (hPhysicalGpu, pBusId); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetBusId (hPhysicalGpu, pBusId); if (NvAPI_rc != NVAPI_OK) { @@ -991,9 +991,9 @@ static int hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuH { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetBusSlotId (hPhysicalGpu, pBusSlotId); + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetBusSlotId (hPhysicalGpu, pBusSlotId); if (NvAPI_rc != NVAPI_OK) { @@ -1015,7 +1015,7 @@ static int adl_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; memset (adl, 0, sizeof (ADL_PTR)); @@ -1045,27 +1045,27 @@ static int adl_init (hashcat_ctx_t *hashcat_ctx) return -1; } - HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0); return 0; } @@ -1074,7 +1074,7 @@ static void adl_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; if (adl) { @@ -1089,7 +1089,7 @@ static int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Main_Control_Destroy (); @@ -1107,7 +1107,7 @@ static int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALL { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Main_Control_Create (callback, iEnumConnectedAdapters); @@ -1125,7 +1125,7 @@ static int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Adapter_NumberOfAdapters_Get (lpNumAdapters); @@ -1143,7 +1143,7 @@ static int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapter { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Adapter_AdapterInfo_Get (lpInfo, iInputSize); @@ -1161,7 +1161,7 @@ static int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iA { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive5_Temperature_Get (iAdapterIndex, iThermalControllerIndex, lpTemperature); @@ -1179,7 +1179,7 @@ static int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iA { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive6_Temperature_Get (iAdapterIndex, iTemperature); @@ -1197,7 +1197,7 @@ static int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive5_CurrentActivity_Get (iAdapterIndex, lpActivity); @@ -1215,7 +1215,7 @@ static int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdap { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); @@ -1233,7 +1233,7 @@ static int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdap { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Get (iAdapterIndex, lpFanSpeedInfo); @@ -1251,7 +1251,7 @@ static int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive_Caps (iAdapterIndex, od_supported, od_enabled, od_version); @@ -1269,7 +1269,7 @@ static int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_c { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - ADL_PTR *adl = hwmon_ctx->hm_adl; + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; const int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureData_Get (iAdapterIndex, cur_temp, default_temp); @@ -2247,12 +2247,12 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_attrs_t *hm_adapters_sysfs = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); #define FREE_ADAPTERS \ - { \ + do { \ hcfree (hm_adapters_adl); \ hcfree (hm_adapters_nvapi); \ hcfree (hm_adapters_nvml); \ hcfree (hm_adapters_sysfs); \ - } + } while(0) if (backend_ctx->need_nvml == true) { @@ -2557,7 +2557,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (hwmon_ctx->hm_sysfs) { - if (1) + if (true) { int hm_adapters_id = 0; diff --git a/src/interface.c b/src/interface.c index 60ce5e5ec..e514a1ca8 100644 --- a/src/interface.c +++ b/src/interface.c @@ -92,12 +92,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->hlfmt_disable = default_hlfmt_disable (hashconfig, user_options, user_options_extra); hashconfig->hook_salt_size = default_hook_salt_size (hashconfig, user_options, user_options_extra); hashconfig->hook_size = default_hook_size (hashconfig, user_options, user_options_extra); - hashconfig->kernel_accel_min = default_kernel_accel_min (hashconfig, user_options, user_options_extra); - hashconfig->kernel_accel_max = default_kernel_accel_max (hashconfig, user_options, user_options_extra); - hashconfig->kernel_loops_min = default_kernel_loops_min (hashconfig, user_options, user_options_extra); - hashconfig->kernel_loops_max = default_kernel_loops_max (hashconfig, user_options, user_options_extra); - hashconfig->kernel_threads_min = default_kernel_threads_min (hashconfig, user_options, user_options_extra); - hashconfig->kernel_threads_max = default_kernel_threads_max (hashconfig, user_options, user_options_extra); hashconfig->outfile_check_disable = default_outfile_check_disable (hashconfig, user_options, user_options_extra); hashconfig->outfile_check_nocomp = default_outfile_check_nocomp (hashconfig, user_options, user_options_extra); hashconfig->potfile_disable = default_potfile_disable (hashconfig, user_options, user_options_extra); @@ -132,7 +126,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) // check for missing pointer assignements #define CHECK_DEFINED(func) \ - if ((func) == NULL) \ + if ((func) == NULL) \ { \ event_log_error (hashcat_ctx, "Missing symbol definitions. Old template?"); \ \ @@ -211,7 +205,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) // mandatory functions check #define CHECK_MANDATORY(func) \ - if ((func) == MODULE_DEFAULT) \ + if ((func) == MODULE_DEFAULT) \ { \ event_log_error (hashcat_ctx, "Missing mandatory symbol definitions"); \ \ @@ -267,12 +261,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if (module_ctx->module_hlfmt_disable != MODULE_DEFAULT) hashconfig->hlfmt_disable = module_ctx->module_hlfmt_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_hook_salt_size != MODULE_DEFAULT) hashconfig->hook_salt_size = module_ctx->module_hook_salt_size (hashconfig, user_options, user_options_extra); if (module_ctx->module_hook_size != MODULE_DEFAULT) hashconfig->hook_size = module_ctx->module_hook_size (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kernel_accel_min != MODULE_DEFAULT) hashconfig->kernel_accel_min = module_ctx->module_kernel_accel_min (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kernel_accel_max != MODULE_DEFAULT) hashconfig->kernel_accel_max = module_ctx->module_kernel_accel_max (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kernel_loops_min != MODULE_DEFAULT) hashconfig->kernel_loops_min = module_ctx->module_kernel_loops_min (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kernel_loops_max != MODULE_DEFAULT) hashconfig->kernel_loops_max = module_ctx->module_kernel_loops_max (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kernel_threads_min != MODULE_DEFAULT) hashconfig->kernel_threads_min = module_ctx->module_kernel_threads_min (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kernel_threads_max != MODULE_DEFAULT) hashconfig->kernel_threads_max = module_ctx->module_kernel_threads_max (hashconfig, user_options, user_options_extra); if (module_ctx->module_outfile_check_disable != MODULE_DEFAULT) hashconfig->outfile_check_disable = module_ctx->module_outfile_check_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_outfile_check_nocomp != MODULE_DEFAULT) hashconfig->outfile_check_nocomp = module_ctx->module_outfile_check_nocomp (hashconfig, user_options, user_options_extra); if (module_ctx->module_potfile_disable != MODULE_DEFAULT) hashconfig->potfile_disable = module_ctx->module_potfile_disable (hashconfig, user_options, user_options_extra); @@ -292,6 +280,16 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) } } + if (user_options->hex_charset) + { + hashconfig->opts_type |= OPTS_TYPE_PT_HEX; + } + + if (user_options->hex_wordlist) + { + hashconfig->opts_type |= OPTS_TYPE_PT_HEX; + } + if (user_options->hex_salt) { if (hashconfig->salt_type == SALT_TYPE_GENERIC) @@ -406,15 +404,27 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) // those depend on some previously defined values - hashconfig->pw_max = default_pw_max (hashconfig, user_options, user_options_extra); - hashconfig->pw_min = default_pw_min (hashconfig, user_options, user_options_extra); - hashconfig->salt_max = default_salt_max (hashconfig, user_options, user_options_extra); - hashconfig->salt_min = default_salt_min (hashconfig, user_options, user_options_extra); + hashconfig->pw_max = default_pw_max (hashconfig, user_options, user_options_extra); + hashconfig->pw_min = default_pw_min (hashconfig, user_options, user_options_extra); + hashconfig->salt_max = default_salt_max (hashconfig, user_options, user_options_extra); + hashconfig->salt_min = default_salt_min (hashconfig, user_options, user_options_extra); + hashconfig->kernel_accel_min = default_kernel_accel_min (hashconfig, user_options, user_options_extra); + hashconfig->kernel_accel_max = default_kernel_accel_max (hashconfig, user_options, user_options_extra); + hashconfig->kernel_loops_min = default_kernel_loops_min (hashconfig, user_options, user_options_extra); + hashconfig->kernel_loops_max = default_kernel_loops_max (hashconfig, user_options, user_options_extra); + hashconfig->kernel_threads_min = default_kernel_threads_min (hashconfig, user_options, user_options_extra); + hashconfig->kernel_threads_max = default_kernel_threads_max (hashconfig, user_options, user_options_extra); - if (module_ctx->module_pw_max != MODULE_DEFAULT) hashconfig->pw_max = module_ctx->module_pw_max (hashconfig, user_options, user_options_extra); - if (module_ctx->module_pw_min != MODULE_DEFAULT) hashconfig->pw_min = module_ctx->module_pw_min (hashconfig, user_options, user_options_extra); - if (module_ctx->module_salt_max != MODULE_DEFAULT) hashconfig->salt_max = module_ctx->module_salt_max (hashconfig, user_options, user_options_extra); - if (module_ctx->module_salt_min != MODULE_DEFAULT) hashconfig->salt_min = module_ctx->module_salt_min (hashconfig, user_options, user_options_extra); + if (module_ctx->module_pw_max != MODULE_DEFAULT) hashconfig->pw_max = module_ctx->module_pw_max (hashconfig, user_options, user_options_extra); + if (module_ctx->module_pw_min != MODULE_DEFAULT) hashconfig->pw_min = module_ctx->module_pw_min (hashconfig, user_options, user_options_extra); + if (module_ctx->module_salt_max != MODULE_DEFAULT) hashconfig->salt_max = module_ctx->module_salt_max (hashconfig, user_options, user_options_extra); + if (module_ctx->module_salt_min != MODULE_DEFAULT) hashconfig->salt_min = module_ctx->module_salt_min (hashconfig, user_options, user_options_extra); + if (module_ctx->module_kernel_accel_min != MODULE_DEFAULT) hashconfig->kernel_accel_min = module_ctx->module_kernel_accel_min (hashconfig, user_options, user_options_extra); + if (module_ctx->module_kernel_accel_max != MODULE_DEFAULT) hashconfig->kernel_accel_max = module_ctx->module_kernel_accel_max (hashconfig, user_options, user_options_extra); + if (module_ctx->module_kernel_loops_min != MODULE_DEFAULT) hashconfig->kernel_loops_min = module_ctx->module_kernel_loops_min (hashconfig, user_options, user_options_extra); + if (module_ctx->module_kernel_loops_max != MODULE_DEFAULT) hashconfig->kernel_loops_max = module_ctx->module_kernel_loops_max (hashconfig, user_options, user_options_extra); + if (module_ctx->module_kernel_threads_min != MODULE_DEFAULT) hashconfig->kernel_threads_min = module_ctx->module_kernel_threads_min (hashconfig, user_options, user_options_extra); + if (module_ctx->module_kernel_threads_max != MODULE_DEFAULT) hashconfig->kernel_threads_max = module_ctx->module_kernel_threads_max (hashconfig, user_options, user_options_extra); return 0; } diff --git a/src/logfile.c b/src/logfile.c index 29f342a4b..d69e15d75 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -66,6 +66,8 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) hc_fflush (&fp); + hc_unlockfile (&fp); + hc_fclose (&fp); } diff --git a/src/loopback.c b/src/loopback.c index d289a70c1..2568971d7 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -158,10 +158,7 @@ void loopback_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, con hc_fflush (&loopback_ctx->fp); - if (hc_unlockfile (&loopback_ctx->fp)) - { - event_log_error (hashcat_ctx, "%s: Failed to unlock file", loopback_ctx->filename); - } + hc_unlockfile (&loopback_ctx->fp); loopback_ctx->unused = false; } diff --git a/src/main.c b/src/main.c index d7d1f14bf..d235db109 100644 --- a/src/main.c +++ b/src/main.c @@ -484,24 +484,6 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, event_log_info (hashcat_ctx, NULL); - /** - * Optimizer constraints - */ - - event_log_info (hashcat_ctx, "Minimum password length supported by kernel: %u", hashconfig->pw_min); - event_log_info (hashcat_ctx, "Maximum password length supported by kernel: %u", hashconfig->pw_max); - - if (hashconfig->is_salted == true) - { - if (hashconfig->opti_type & OPTI_TYPE_RAW_HASH) - { - event_log_info (hashcat_ctx, "Minimim salt length supported by kernel: %u", hashconfig->salt_min); - event_log_info (hashcat_ctx, "Maximum salt length supported by kernel: %u", hashconfig->salt_max); - } - } - - event_log_info (hashcat_ctx, NULL); - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) { if (hashconfig->has_optimized_kernel == true) @@ -898,6 +880,36 @@ static void main_wordlist_cache_generate (MAYBE_UNUSED hashcat_ctx_t *hashcat_ct } } +static void main_hashconfig_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ +} + +static void main_hashconfig_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return; + + /** + * Optimizer constraints + */ + + event_log_info (hashcat_ctx, "Minimum password length supported by kernel: %u", hashconfig->pw_min); + event_log_info (hashcat_ctx, "Maximum password length supported by kernel: %u", hashconfig->pw_max); + + if (hashconfig->is_salted == true) + { + if (hashconfig->opti_type & OPTI_TYPE_RAW_HASH) + { + event_log_info (hashcat_ctx, "Minimim salt length supported by kernel: %u", hashconfig->salt_min); + event_log_info (hashcat_ctx, "Maximum salt length supported by kernel: %u", hashconfig->salt_max); + } + } + + event_log_info (hashcat_ctx, NULL); +} + static void main_hashlist_count_lines_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -1006,6 +1018,8 @@ static void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, co case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break; case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break; case EVENT_CRACKER_STARTING: main_cracker_starting (hashcat_ctx, buf, len); break; + case EVENT_HASHCONFIG_PRE: main_hashconfig_pre (hashcat_ctx, buf, len); break; + case EVENT_HASHCONFIG_POST: main_hashconfig_post (hashcat_ctx, buf, len); break; case EVENT_HASHLIST_COUNT_LINES_POST: main_hashlist_count_lines_post (hashcat_ctx, buf, len); break; case EVENT_HASHLIST_COUNT_LINES_PRE: main_hashlist_count_lines_pre (hashcat_ctx, buf, len); break; case EVENT_HASHLIST_PARSE_HASH: main_hashlist_parse_hash (hashcat_ctx, buf, len); break; @@ -1111,7 +1125,7 @@ int main (int argc, char **argv) #ifdef WITH_BRAIN if (user_options->brain_server == true) { - const int rc = brain_server (user_options->brain_host, user_options->brain_port, user_options->brain_password, user_options->brain_session_whitelist); + const int rc = brain_server (user_options->brain_host, user_options->brain_port, user_options->brain_password, user_options->brain_session_whitelist, user_options->brain_server_timer); hcfree (hashcat_ctx); diff --git a/src/modules/module_00040.c b/src/modules/module_00040.c index 198427067..2d4dc98cf 100644 --- a/src/modules/module_00040.c +++ b/src/modules/module_00040.c @@ -29,7 +29,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_ADDBITS14 | OPTS_TYPE_PT_UTF16LE; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "23a8a90599fc5d0d15265d4d3b565f6e:58802707"; diff --git a/src/modules/module_00124.c b/src/modules/module_00124.c index aadcd4d27..8587d8ca8 100644 --- a/src/modules/module_00124.c +++ b/src/modules/module_00124.c @@ -16,7 +16,7 @@ static const u32 DGST_POS1 = 4; static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; -static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; static const char *HASH_NAME = "Django (SHA-1)"; static const u64 KERN_TYPE = 120; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE diff --git a/src/modules/module_00300.c b/src/modules/module_00300.c index 3764d565b..00fccfe0a 100644 --- a/src/modules/module_00300.c +++ b/src/modules/module_00300.c @@ -121,11 +121,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u8 *out_buf = (u8 *) line_buf; - u32_to_hex (tmp[0], out_buf + 0); - u32_to_hex (tmp[1], out_buf + 8); - u32_to_hex (tmp[2], out_buf + 16); - u32_to_hex (tmp[3], out_buf + 24); - u32_to_hex (tmp[4], out_buf + 32); + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + u32_to_hex (tmp[4], out_buf + 32); const int out_len = 40; diff --git a/src/modules/module_00600.c b/src/modules/module_00600.c index 6fd67c51f..3a2b13610 100644 --- a/src/modules/module_00600.c +++ b/src/modules/module_00600.c @@ -54,13 +54,6 @@ typedef struct blake2 static const char *SIGNATURE_BLAKE2B = "$BLAKE2$"; -u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u32 kernel_threads_max = 64; // performance only optimization - - return kernel_threads_max; -} - u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (blake2_t); @@ -198,7 +191,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = MODULE_DEFAULT; module_ctx->module_kernel_loops_min = MODULE_DEFAULT; - module_ctx->module_kernel_threads_max = module_kernel_threads_max; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; diff --git a/src/modules/module_01300.c b/src/modules/module_01300.c index 3d0172a4a..7811626e7 100644 --- a/src/modules/module_01300.c +++ b/src/modules/module_01300.c @@ -134,13 +134,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u8 *out_buf = (u8 *) line_buf; - u32_to_hex (tmp[ 0], out_buf + 0); - u32_to_hex (tmp[ 1], out_buf + 8); - u32_to_hex (tmp[ 2], out_buf + 16); - u32_to_hex (tmp[ 3], out_buf + 24); - u32_to_hex (tmp[ 4], out_buf + 32); - u32_to_hex (tmp[ 5], out_buf + 40); - u32_to_hex (tmp[ 6], out_buf + 48); + u32_to_hex (tmp[ 0], out_buf + 0); + u32_to_hex (tmp[ 1], out_buf + 8); + u32_to_hex (tmp[ 2], out_buf + 16); + u32_to_hex (tmp[ 3], out_buf + 24); + u32_to_hex (tmp[ 4], out_buf + 32); + u32_to_hex (tmp[ 5], out_buf + 40); + u32_to_hex (tmp[ 6], out_buf + 48); const int out_len = 56; diff --git a/src/modules/module_01450.c b/src/modules/module_01450.c index f986b4e7d..06c85549c 100644 --- a/src/modules/module_01450.c +++ b/src/modules/module_01450.c @@ -42,28 +42,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -215,7 +193,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01460.c b/src/modules/module_01460.c index 309338d1b..9bf1562ab 100644 --- a/src/modules/module_01460.c +++ b/src/modules/module_01460.c @@ -16,7 +16,6 @@ static const u32 DGST_POS1 = 7; static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 6; static const u32 DGST_SIZE = DGST_SIZE_4_8; -static const u32 DGST_BLK_SIZE = 64; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_AUTHENTICATED; static const char *HASH_NAME = "HMAC-SHA256 (key = $salt)"; static const u64 KERN_TYPE = 1460; @@ -41,10 +40,34 @@ u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } -u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_BLK_SIZE; } const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -196,7 +219,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -216,7 +239,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_pwdump_column = MODULE_DEFAULT; module_ctx->module_pw_max = MODULE_DEFAULT; module_ctx->module_pw_min = MODULE_DEFAULT; - module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_max = MODULE_DEFAULT; module_ctx->module_salt_min = MODULE_DEFAULT; module_ctx->module_salt_type = module_salt_type; module_ctx->module_separator = MODULE_DEFAULT; diff --git a/src/modules/module_01500.c b/src/modules/module_01500.c index 563d9bfac..77ab912d2 100644 --- a/src/modules/module_01500.c +++ b/src/modules/module_01500.c @@ -22,10 +22,10 @@ static const char *HASH_NAME = "descrypt, DES (Unix), Traditional DES"; static const u64 KERN_TYPE = 1500; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_BITSLICE; + | OPTS_TYPE_TM_KERNEL; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = NULL; // the self-test can't work because the salt is not part of the code at compile-time -static const char *ST_HASH = "8133vc.5rieNk"; +static const char *ST_HASH = "24leDr0hHfb3A"; u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } @@ -73,6 +73,13 @@ int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, return src_len; } +u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_threads_max = 64; // performance only optimization + + return kernel_threads_max; +} + u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { u32 kernel_loops_max = KERNEL_LOOPS_MAX; @@ -124,9 +131,38 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if ((user_options->attack_mode == ATTACK_MODE_BF) && (hashes->salts_cnt == 1) && (user_options->slow_candidates == false)) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-DDESCRYPT_SALT=%u", hashes->salts_buf[0].salt_buf[0] & 0xfff); + if ((user_options->attack_mode == ATTACK_MODE_BF) && (hashes->salts_cnt == 1) && (user_options->slow_candidates == false)) + { + hc_asprintf (&jit_build_options, "-DDESCRYPT_SALT=%u", hashes->salts_buf[0].salt_buf[0] & 0xfff); + } + + return jit_build_options; + } + + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + if ((user_options->attack_mode == ATTACK_MODE_BF) && (hashes->salts_cnt == 1) && (user_options->slow_candidates == false)) + { + hc_asprintf (&jit_build_options, "-DDESCRYPT_SALT=%u -D _unroll", hashes->salts_buf[0].salt_buf[0] & 0xfff); + } + } + // ROCM + else if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + if ((user_options->attack_mode == ATTACK_MODE_BF) && (hashes->salts_cnt == 1) && (user_options->slow_candidates == false)) + { + hc_asprintf (&jit_build_options, "-DDESCRYPT_SALT=%u -D _unroll", hashes->salts_buf[0].salt_buf[0] & 0xfff); + } + } + else + { + if ((user_options->attack_mode == ATTACK_MODE_BF) && (hashes->salts_cnt == 1) && (user_options->slow_candidates == false)) + { + hc_asprintf (&jit_build_options, "-DDESCRYPT_SALT=%u", hashes->salts_buf[0].salt_buf[0] & 0xfff); + } } return jit_build_options; @@ -272,7 +308,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = module_kernel_loops_max; module_ctx->module_kernel_loops_min = module_kernel_loops_min; - module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = module_kernel_threads_max; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; diff --git a/src/modules/module_01700.c b/src/modules/module_01700.c index fda53c0e0..4adc47171 100644 --- a/src/modules/module_01700.c +++ b/src/modules/module_01700.c @@ -48,6 +48,25 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -142,14 +161,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u8 *out_buf = (u8 *) line_buf; - u64_to_hex (tmp[0], out_buf + 0); - u64_to_hex (tmp[1], out_buf + 16); - u64_to_hex (tmp[2], out_buf + 32); - u64_to_hex (tmp[3], out_buf + 48); - u64_to_hex (tmp[4], out_buf + 64); - u64_to_hex (tmp[5], out_buf + 80); - u64_to_hex (tmp[6], out_buf + 96); - u64_to_hex (tmp[7], out_buf + 112); + u64_to_hex (tmp[0], out_buf + 0); + u64_to_hex (tmp[1], out_buf + 16); + u64_to_hex (tmp[2], out_buf + 32); + u64_to_hex (tmp[3], out_buf + 48); + u64_to_hex (tmp[4], out_buf + 64); + u64_to_hex (tmp[5], out_buf + 80); + u64_to_hex (tmp[6], out_buf + 96); + u64_to_hex (tmp[7], out_buf + 112); const int out_len = 128; @@ -198,7 +217,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01720.c b/src/modules/module_01720.c index 7bb4f2e51..3e771610f 100644 --- a/src/modules/module_01720.c +++ b/src/modules/module_01720.c @@ -52,19 +52,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->is_cuda == true) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; } - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_01722.c b/src/modules/module_01722.c index 4a575d258..3a1f57cb4 100644 --- a/src/modules/module_01722.c +++ b/src/modules/module_01722.c @@ -53,19 +53,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->is_cuda == true) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; } - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_01740.c b/src/modules/module_01740.c index 083c274f9..9f4656673 100644 --- a/src/modules/module_01740.c +++ b/src/modules/module_01740.c @@ -49,28 +49,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -246,7 +224,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01750.c b/src/modules/module_01750.c index ed0e6e54d..c4a8c458e 100644 --- a/src/modules/module_01750.c +++ b/src/modules/module_01750.c @@ -43,28 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -216,7 +194,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01760.c b/src/modules/module_01760.c index 0d862910f..2fb10e83b 100644 --- a/src/modules/module_01760.c +++ b/src/modules/module_01760.c @@ -44,28 +44,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -217,7 +195,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_01800.c b/src/modules/module_01800.c index 9b6d0c196..5d997f5d8 100644 --- a/src/modules/module_01800.c +++ b/src/modules/module_01800.c @@ -414,6 +414,25 @@ static void sha512crypt_encode (const u8 digest[64], u8 buf[86]) buf[85] = int_to_itoa64 (l & 0x3f); //l >>= 6; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (sha512crypt_tmp_t); @@ -430,15 +449,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; diff --git a/src/modules/module_02000.c b/src/modules/module_02000.c index 0c8df2610..be40fcb4f 100644 --- a/src/modules/module_02000.c +++ b/src/modules/module_02000.c @@ -18,7 +18,7 @@ static const u32 DGST_POS3 = 0; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_PLAIN; static const char *HASH_NAME = "STDOUT"; -static const u64 KERN_TYPE = 0; +static const u64 KERN_TYPE = 2000; static const u32 OPTI_TYPE = 0; static const u64 OPTS_TYPE = 0; static const u32 SALT_TYPE = SALT_TYPE_NONE; diff --git a/src/modules/module_02100.c b/src/modules/module_02100.c index a7ef91744..f2735b482 100644 --- a/src/modules/module_02100.c +++ b/src/modules/module_02100.c @@ -95,7 +95,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_min[2] = SALT_MIN; token.len_max[2] = SALT_MAX; token.sep[2] = '#'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_SEPARATOR_FARTHEST; token.len_min[3] = 32; token.len_max[3] = 32; diff --git a/src/modules/module_02500.c b/src/modules/module_02500.c index 8907f8677..753636dc1 100644 --- a/src/modules/module_02500.c +++ b/src/modules/module_02500.c @@ -261,7 +261,7 @@ int module_hash_decode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY // essid - char *sep_pos = strrchr (line_buf, ':'); + char *sep_pos = strrchr (line_buf, '*'); if (sep_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); @@ -292,7 +292,7 @@ int module_hash_encode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY tmp_buf[tmp_len] = 0; - const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", + const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x*%s", wpa_pbkdf2_tmp->out[0], wpa_pbkdf2_tmp->out[1], wpa_pbkdf2_tmp->out[2], diff --git a/src/modules/module_02501.c b/src/modules/module_02501.c index a7ce17b04..41aa86acd 100644 --- a/src/modules/module_02501.c +++ b/src/modules/module_02501.c @@ -258,7 +258,7 @@ int module_hash_decode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY // essid - char *sep_pos = strrchr (line_buf, ':'); + char *sep_pos = strrchr (line_buf, '*'); if (sep_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); @@ -289,7 +289,7 @@ int module_hash_encode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY tmp_buf[tmp_len] = 0; - const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", + const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x*%s", wpa_pmk_tmp->out[0], wpa_pmk_tmp->out[1], wpa_pmk_tmp->out[2], diff --git a/src/modules/module_03000.c b/src/modules/module_03000.c index e5c819941..8d5e8c7a8 100644 --- a/src/modules/module_03000.c +++ b/src/modules/module_03000.c @@ -23,10 +23,11 @@ static const u64 KERN_TYPE = 3000; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_PT_UPPER - | OPTS_TYPE_PT_BITSLICE + | OPTS_TYPE_TM_KERNEL | OPTS_TYPE_PT_ALWAYS_ASCII | OPTS_TYPE_PT_LM | OPTS_TYPE_HASH_SPLIT; +static const u32 PWDUMP_COLUMN = PWDUMP_COLUMN_LM_HASH; static const u32 SALT_TYPE = SALT_TYPE_NONE; static const char *ST_PASS = "hashcat1"; static const char *ST_HASH = "299bd128c1101fd6"; @@ -42,10 +43,42 @@ const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_pwdump_column (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return PWDUMP_COLUMN; } u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 kernel_threads_max = 64; // performance only optimization @@ -210,7 +243,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; @@ -227,7 +260,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_potfile_custom_check = MODULE_DEFAULT; module_ctx->module_potfile_disable = MODULE_DEFAULT; module_ctx->module_potfile_keep_all_hashes = module_potfile_keep_all_hashes; - module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pwdump_column = module_pwdump_column; module_ctx->module_pw_max = module_pw_max; module_ctx->module_pw_min = MODULE_DEFAULT; module_ctx->module_salt_max = MODULE_DEFAULT; diff --git a/src/modules/module_03100.c b/src/modules/module_03100.c index 7b6c8f845..d05fa2e42 100644 --- a/src/modules/module_03100.c +++ b/src/modules/module_03100.c @@ -42,6 +42,25 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 pw_max = 30; // http://www.red-database-security.de/whitepaper/oracle_passwords.html @@ -145,7 +164,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_03200.c b/src/modules/module_03200.c index 81c5203de..17521e5e9 100644 --- a/src/modules/module_03200.c +++ b/src/modules/module_03200.c @@ -20,7 +20,8 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "bcrypt $2*$, Blowfish (Unix)"; static const u64 KERN_TYPE = 3200; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; -static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_DYNAMIC_SHARED; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$2a$05$MBCzKhG1KhezLh.0LRa0Kuw12nLJtpHy6DIaU.JAnqJUDYspHC.Ou"; @@ -81,16 +82,32 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; + // this mode heavily depends on the available shared memory size + // note the kernel need to have some special code changes in order to make use to use post-48k memory region + // we need to set some macros + + bool use_dynamic = false; + + if (device_param->is_cuda == true) + { + if (device_param->kernel_dynamic_local_mem_size_memset % device_param->device_local_mem_size) + { + // this is the case Compute Capability 7.5 + // there is also Compute Capability 7.0 which offers a larger dynamic local size access + // however, if it's an exact multiple the driver can optimize this for us more efficient + + use_dynamic = true; + } + } + // this uses some nice feedback effect. // based on the device_local_mem_size the reqd_work_group_size in the kernel is set to some value // which is then is read from the opencl host in the kernel_preferred_wgs_multiple1/2/3 result. // therefore we do not need to set module_kernel_threads_min/max except for CPU, where the threads are set to fixed 1. - u32 fixed_local_size = 0; - if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU) { - fixed_local_size = 1; + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u", 1); } else { @@ -106,29 +123,58 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY if (device_param->is_opencl == true) { - overhead = 4; + overhead = 1; } } if (user_options->kernel_threads_chgd == true) { - fixed_local_size = user_options->kernel_threads; + u32 fixed_local_size = user_options->kernel_threads; - // otherwise out-of-bound reads - - if ((fixed_local_size * 4096) > (device_param->device_local_mem_size - overhead)) + if (use_dynamic == true) { - fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096; + if ((fixed_local_size * 4096) > device_param->kernel_dynamic_local_mem_size_memset) + { + // otherwise out-of-bound reads + + fixed_local_size = device_param->kernel_dynamic_local_mem_size_memset / 4096; + } + + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u -D DYNAMIC_LOCAL", fixed_local_size); + } + else + { + if ((fixed_local_size * 4096) > (device_param->device_local_mem_size - overhead)) + { + // otherwise out-of-bound reads + + fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096; + } + + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u", fixed_local_size); } } else { - fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096; + if (use_dynamic == true) + { + // using kernel_dynamic_local_mem_size_memset is a bit hackish. + // we had to brute-force this value out of an already loaded CUDA function. + // there's no official way to query for this value. + + const u32 fixed_local_size = device_param->kernel_dynamic_local_mem_size_memset / 4096; + + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u -D DYNAMIC_LOCAL", fixed_local_size); + } + else + { + const u32 fixed_local_size = (device_param->device_local_mem_size - overhead) / 4096; + + hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u", fixed_local_size); + } } } - hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u", fixed_local_size); - return jit_build_options; } diff --git a/src/modules/module_04010.c b/src/modules/module_04010.c index 052b0a889..875f0c4e8 100644 --- a/src/modules/module_04010.c +++ b/src/modules/module_04010.c @@ -44,6 +44,20 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // amdgpu-pro-19.30-934563-ubuntu-18.04: self-test failure. + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) + { + return true; + } + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -208,6 +222,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_04710.c b/src/modules/module_04710.c index 0921abcbe..b16fb9e65 100644 --- a/src/modules/module_04710.c +++ b/src/modules/module_04710.c @@ -27,7 +27,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_ADDBITS14; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "53c724b7f34f09787ed3f1b316215fc35c789504:hashcat1"; diff --git a/src/modules/module_05200.c b/src/modules/module_05200.c index 7c50b5d47..9cd198e98 100644 --- a/src/modules/module_05200.c +++ b/src/modules/module_05200.c @@ -59,6 +59,37 @@ typedef struct pwsafe3_tmp static const char *SIGNATURE_PSAFE3 = "PWS3"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 pw_max = PW_MAX; @@ -185,7 +216,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_05500.c b/src/modules/module_05500.c index 6a57ee25b..1ebabe097 100644 --- a/src/modules/module_05500.c +++ b/src/modules/module_05500.c @@ -79,6 +79,25 @@ static void transform_netntlmv1_key (const u8 *nthash, u8 *key) key[7] |= 0x01; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (netntlm_t); @@ -424,7 +443,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06100.c b/src/modules/module_06100.c index dd1c9f75d..d50c226fb 100644 --- a/src/modules/module_06100.c +++ b/src/modules/module_06100.c @@ -41,15 +41,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -215,7 +206,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06211.c b/src/modules/module_06211.c index 8f2be8897..ef63c4be4 100644 --- a/src/modules/module_06211.c +++ b/src/modules/module_06211.c @@ -74,9 +74,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_06212.c b/src/modules/module_06212.c index bfc9d05d8..a2f6fc4bf 100644 --- a/src/modules/module_06212.c +++ b/src/modules/module_06212.c @@ -74,9 +74,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_06213.c b/src/modules/module_06213.c index 1b09d8607..0cdbd43c5 100644 --- a/src/modules/module_06213.c +++ b/src/modules/module_06213.c @@ -74,9 +74,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_06221.c b/src/modules/module_06221.c index 6d43ffe3c..2744b6b37 100644 --- a/src/modules/module_06221.c +++ b/src/modules/module_06221.c @@ -109,15 +109,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -275,7 +266,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06222.c b/src/modules/module_06222.c index b0ae40989..d4314e47f 100644 --- a/src/modules/module_06222.c +++ b/src/modules/module_06222.c @@ -109,15 +109,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -275,7 +266,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06223.c b/src/modules/module_06223.c index ee3c1f5ed..ec19b3c56 100644 --- a/src/modules/module_06223.c +++ b/src/modules/module_06223.c @@ -109,15 +109,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -133,8 +124,6 @@ int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); return parser_status; @@ -275,7 +264,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06231.c b/src/modules/module_06231.c index e01fd7300..e86e09b69 100644 --- a/src/modules/module_06231.c +++ b/src/modules/module_06231.c @@ -70,18 +70,6 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -277,7 +265,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06232.c b/src/modules/module_06232.c index b8a404670..847c2c3e9 100644 --- a/src/modules/module_06232.c +++ b/src/modules/module_06232.c @@ -70,18 +70,6 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -277,7 +265,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06233.c b/src/modules/module_06233.c index 499f0714a..080976adf 100644 --- a/src/modules/module_06233.c +++ b/src/modules/module_06233.c @@ -70,18 +70,6 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const bool potfile_disable = true; @@ -277,7 +265,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06241.c b/src/modules/module_06241.c index 09c3e8ec7..4ff957c71 100644 --- a/src/modules/module_06241.c +++ b/src/modules/module_06241.c @@ -25,7 +25,8 @@ static const u64 KERN_TYPE = 6211; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_BINARY_HASHFILE; + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_KEYBOARD_MAPPING; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "2b5da9924119fde5270f712ba3c3e4974460416e8465f222149499908c2fca0a4753b581f26625d11c4d3f49bdeb1c95bc3e17629d7e19ffb66175e5feab90a4fd670194f95d578266f3f54e61b82dc00efc2bb4438e19c3f6d7a92825a7625d88ec6286ab4e1761749edc83dad4340fd167544f09913fd6b03775013ff232fc4dad6f726ef82ad4bd1c5227a7796d7db35a912beeda5b0cdd798bc34d3ac24403c87dc672a983687dd64f920c991840a56105a6311797eed9976014909700366420673f6455242c71151ac75903a353538ec24b4feb967e2b46886395cf3e934e83a6a58ef2c0180273a0c33ba2bd870b1d84afb03d5558dc17bc7fb586404ad9a7e506ed859540110c6ad73f0f1d2be47829bc666e1838ec3f1dc1f610206241ce07fbf2542ecef9348b37aa460815794ca582709697cbf0c90c3dae4cb9dd97b29d3c7d82bd8d0c81d708e74c7007468c6c55a40fd4f803a4f5a75818d7da0d1ef333b8622e7de516fa62a6fa2b8d6d5d23653dfcedffec771456ee204e5c85ee88defbe195462fbe8ce0e2a5a455dab66478b877ec37dfa66f19ab5201c56cd707ba7bee1b10360965d3868c1fdf91dda124b1b0994fee75848083d19369735905bd2864b496c6e35ecf96f6dd4728570a45746bcf8d7d0ec0b9b0b112b28fdc53efcfa7d0558c132cd683a742d62b34304d9f991029c8aedc3d8767da8c"; @@ -70,18 +71,6 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const tc_t *tc = (const tc_t *) hashes->esalts_buf; @@ -289,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06242.c b/src/modules/module_06242.c index 20a239fd0..048df78b1 100644 --- a/src/modules/module_06242.c +++ b/src/modules/module_06242.c @@ -25,7 +25,8 @@ static const u64 KERN_TYPE = 6212; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_BINARY_HASHFILE; + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_KEYBOARD_MAPPING; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "debcc3e74a7b2acb4c7eaa4ac86fd6431da1d9579f4f76f0b31f07b3d36e65099daca9e4ae569114b3cb6e64d707b6206a2ab6b31ab0c17b356da3719d0e2fa4058f0349763970855d4c83b02a967bb2969f1b6f3e4fdbce37c6df203efbe87bfdb5ffd8fe376e9ad61862a8f659ef0db39e06ed34c4f80aa856df2219ac6a37ebb0244445db7e412b773f4e28846c5e65129cd4f4ce76979c083f08a7c4e2be30469b8363eaf8579baa870cdcb2bdca6b60e64559cb0def242576b80722bf36eb6d94640d2937b49edf9c9af67f0172f27319448425f86831c35ae35e764b9e69fcc47a42ba7a565d682366023291b1b4cbcd1b7ba6fba75c214e5849a9ba26197f7f010f01301dcbffaa7311f2ab32c2810470d3fe873334ca578adbfd04c5a39cbd53b09755e4d868dbf8a44d76cc91031f4710b8a985c70738b443572b4745ed10e6120852870b0fdb258f0a804d679eec85b5290235c9c526165b961f17ff0fe32d9f597c8f2ab9b84f3d22fef71fec67987e687590de6ab11b33f1b06f23c38ead94c3de419061b6568612c27517b0a3395e401a2c6058fc5f41f0e084e8f2157b6486624314b1f341f74cfdec9deaed7abf89ccf97b47441493e5086f1351f42a5c0929f6431753baadcd2fb347b8835d08250743bb45aaf1c6bb30eed98e911a273074b7e8ebad2174b527b1b84e1961967bf358711346482d9db1c7"; @@ -70,18 +71,6 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const tc_t *tc = (const tc_t *) hashes->esalts_buf; @@ -289,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06243.c b/src/modules/module_06243.c index baa540b0c..2ee532815 100644 --- a/src/modules/module_06243.c +++ b/src/modules/module_06243.c @@ -25,7 +25,8 @@ static const u64 KERN_TYPE = 6213; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_BINARY_HASHFILE; + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_KEYBOARD_MAPPING; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "5e6628907291b0b74a4f43a23fb0693acb71c4379c3a3cc0eafbab40036bbdadfede179e04484aca0f5b6ecf7c7e8abe61d6836be6590838b8f9027da93ba77d076b9a557c958159c5dcddfb70823b7e324bd99b40a8f39410f6afd279df3493b58b9ffce41b65f3afd2fc467f4553a946b85e6ffc74b91c9c38c689d98419339a84d3c6d116274e34482d546407006ee04af03b594998127b2a9716ca4278b1f3050d015af10a9bb11db0465373f3a786c148bb20473377d8e97264b1c4d7ec4179829ce929573b26e5987b59da8591e2dc8e3934830dd0b5ac521c8637e9bb31e4bc084d53bc6a8dc6875e857a4c8c32a577eed3c6cea5beef514160982be2c7d7e2f4d65efa3f4a0e11ac1860ff3160e7cd968e18019abfd0395080a9f8e860c627fc32c63c8b7ef46b203c63cf0f12c05ea65b1f83a5f1fc6ad6cc200a9527151c2b8016a38f1e87be9c960088eaaa98a01d9db8cdacaae26c446a846042a6c0248b666eea7a1be44dc3fc35ce100c3a3eb377e898deb097cfba9246685d7ec8527cdc5e1983c154169178e3d86cd4017606ccc42d25cbdea0aca2b1ac422372cfbb1ad2b7d465449a2c1fbbae35c8e7fdaadd683a7dc991b76aaba08b8706916924407392a2aef458c2e833290dc1ff116f3f49f918e6a133b60728ac7c464e4f3521784cf32866be32877534bb014312c4301d1740781221a5e8758ea4"; @@ -70,18 +71,6 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const tc_t *tc = (const tc_t *) hashes->esalts_buf; @@ -289,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06400.c b/src/modules/module_06400.c index ad4e7273a..82010ed67 100644 --- a/src/modules/module_06400.c +++ b/src/modules/module_06400.c @@ -254,28 +254,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -311,7 +289,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *iter_pos = token.buf[1]; - char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; + u8 salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; salt->salt_sign[0] = hc_strtoul ((const char *) salt_iter, NULL, 10); @@ -421,7 +399,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06500.c b/src/modules/module_06500.c index 011a3f5bf..63607b2ba 100644 --- a/src/modules/module_06500.c +++ b/src/modules/module_06500.c @@ -462,7 +462,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *iter_pos = token.buf[1]; - char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; + u8 salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; salt->salt_sign[0] = hc_strtoul ((const char *) salt_iter, NULL, 10); @@ -530,15 +530,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return line_len; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - void module_init (module_ctx_t *module_ctx) { module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; @@ -581,7 +572,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_06700.c b/src/modules/module_06700.c index 25cf31f8c..2fc10a247 100644 --- a/src/modules/module_06700.c +++ b/src/modules/module_06700.c @@ -224,7 +224,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *iter_pos = token.buf[1]; - char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; + u8 salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; salt->salt_sign[0] = hc_strtoul ((const char *) salt_iter, NULL, 10); diff --git a/src/modules/module_06800.c b/src/modules/module_06800.c index f90796038..cc10b9e7e 100644 --- a/src/modules/module_06800.c +++ b/src/modules/module_06800.c @@ -51,6 +51,31 @@ typedef struct lastpass_tmp } lastpass_tmp_t; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (lastpass_tmp_t); @@ -68,28 +93,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_07000.c b/src/modules/module_07000.c index 6cdbe3b84..398191d92 100644 --- a/src/modules/module_07000.c +++ b/src/modules/module_07000.c @@ -22,7 +22,7 @@ static const u64 KERN_TYPE = 7000; static const u32 OPTI_TYPE = OPTI_TYPE_PRECOMPUTE_INIT | OPTI_TYPE_EARLY_SKIP | OPTI_TYPE_NOT_ITERATED; -static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "AK1FCIhM0IUIQVFJgcDFwLCMi7GppdwtRzMyDpFOFxdpH8="; @@ -44,18 +44,6 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, static const char *SIGNATURE_FORTIGATE = "AK1"; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { u32 pw_max = PW_MAX; @@ -234,7 +222,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_07100.c b/src/modules/module_07100.c index 36214e2b5..a4d868565 100644 --- a/src/modules/module_07100.c +++ b/src/modules/module_07100.c @@ -22,7 +22,8 @@ static const u64 KERN_TYPE = 7100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_USES_BITS_64 | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; -static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_HASH_COPY; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$ml$1024$2484380731132131624506271467162123576077004878124365203837706482$89a3a979ee186c0c837ca4551f32e951e6564c7ac6798aa35baf4427fbf6bd1d630642c12cfd5c236c7b0104782237db95e895f7c0e372cd81d58f0448daf958"; @@ -120,7 +121,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.len_min[3] = 128; - token.len_max[3] = 128; + token.len_max[3] = 256; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -128,6 +129,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + const int hash_len = token.len[3]; + + if ((hash_len != 128) && (hash_len != 256)) return (PARSER_HASH_LENGTH); + const u8 *hash_pos = token.buf[3]; digest[0] = hex_to_u64 (hash_pos + 0); @@ -177,6 +182,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return (PARSER_OK); } +/* replaced with OPTS_TYPE_HASH_COPY version + int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) { const u32 *digest = (const u32 *) digest_buf; @@ -215,6 +222,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return line_len; } +*/ + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const int line_len = snprintf (line_buf, line_size, "%s", hash_info->orighash); + + return line_len; +} void module_init (module_ctx_t *module_ctx) { diff --git a/src/modules/module_07200.c b/src/modules/module_07200.c index 074043ef5..03cff75f2 100644 --- a/src/modules/module_07200.c +++ b/src/modules/module_07200.c @@ -84,15 +84,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -253,7 +244,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_07400.c b/src/modules/module_07400.c index b9bde6fc2..425811a6e 100644 --- a/src/modules/module_07400.c +++ b/src/modules/module_07400.c @@ -234,6 +234,25 @@ static void sha256crypt_encode (const u8 digest[32], u8 buf[43]) buf[42] = int_to_itoa64 (l & 0x3f); //l >>= 6; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (sha256crypt_tmp_t); @@ -255,15 +274,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -280,7 +290,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.len_min[1] = 0; - token.len_max[1] = 16; + token.len_max[1] = 20; token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_OPTIONAL_ROUNDS; diff --git a/src/modules/module_07401.c b/src/modules/module_07401.c new file mode 100644 index 000000000..71ffae0cc --- /dev/null +++ b/src/modules/module_07401.c @@ -0,0 +1,469 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_DATABASE_SERVER; +static const char *HASH_NAME = "MySQL $A$ (sha256crypt)"; +static const u64 KERN_TYPE = 7400; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_ST_HEX; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$mysql$A$005*F9CC98CE08892924F50A213B6BC571A2C11778C5*625479393559393965414D45316477456B484F41316E64484742577A2E3162785353526B7554584647562F"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct sha256crypt_tmp +{ + u32 alt_result[8]; + u32 p_bytes[64]; + u32 s_bytes[64]; + +} sha256crypt_tmp_t; + +static const u32 MULTIPLIER_MYSQL = 1000; +static const char *SIGNATURE_MYSQL = "$mysql$"; + +static void sha256crypt_decode (u8 digest[32], const u8 buf[43]) +{ + int l; + + l = itoa64_to_int (buf[ 0]) << 0; + l |= itoa64_to_int (buf[ 1]) << 6; + l |= itoa64_to_int (buf[ 2]) << 12; + l |= itoa64_to_int (buf[ 3]) << 18; + + digest[ 0] = (l >> 16) & 0xff; + digest[10] = (l >> 8) & 0xff; + digest[20] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[ 4]) << 0; + l |= itoa64_to_int (buf[ 5]) << 6; + l |= itoa64_to_int (buf[ 6]) << 12; + l |= itoa64_to_int (buf[ 7]) << 18; + + digest[21] = (l >> 16) & 0xff; + digest[ 1] = (l >> 8) & 0xff; + digest[11] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[ 8]) << 0; + l |= itoa64_to_int (buf[ 9]) << 6; + l |= itoa64_to_int (buf[10]) << 12; + l |= itoa64_to_int (buf[11]) << 18; + + digest[12] = (l >> 16) & 0xff; + digest[22] = (l >> 8) & 0xff; + digest[ 2] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[12]) << 0; + l |= itoa64_to_int (buf[13]) << 6; + l |= itoa64_to_int (buf[14]) << 12; + l |= itoa64_to_int (buf[15]) << 18; + + digest[ 3] = (l >> 16) & 0xff; + digest[13] = (l >> 8) & 0xff; + digest[23] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[16]) << 0; + l |= itoa64_to_int (buf[17]) << 6; + l |= itoa64_to_int (buf[18]) << 12; + l |= itoa64_to_int (buf[19]) << 18; + + digest[24] = (l >> 16) & 0xff; + digest[ 4] = (l >> 8) & 0xff; + digest[14] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[20]) << 0; + l |= itoa64_to_int (buf[21]) << 6; + l |= itoa64_to_int (buf[22]) << 12; + l |= itoa64_to_int (buf[23]) << 18; + + digest[15] = (l >> 16) & 0xff; + digest[25] = (l >> 8) & 0xff; + digest[ 5] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[24]) << 0; + l |= itoa64_to_int (buf[25]) << 6; + l |= itoa64_to_int (buf[26]) << 12; + l |= itoa64_to_int (buf[27]) << 18; + + digest[ 6] = (l >> 16) & 0xff; + digest[16] = (l >> 8) & 0xff; + digest[26] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[28]) << 0; + l |= itoa64_to_int (buf[29]) << 6; + l |= itoa64_to_int (buf[30]) << 12; + l |= itoa64_to_int (buf[31]) << 18; + + digest[27] = (l >> 16) & 0xff; + digest[ 7] = (l >> 8) & 0xff; + digest[17] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[32]) << 0; + l |= itoa64_to_int (buf[33]) << 6; + l |= itoa64_to_int (buf[34]) << 12; + l |= itoa64_to_int (buf[35]) << 18; + + digest[18] = (l >> 16) & 0xff; + digest[28] = (l >> 8) & 0xff; + digest[ 8] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[36]) << 0; + l |= itoa64_to_int (buf[37]) << 6; + l |= itoa64_to_int (buf[38]) << 12; + l |= itoa64_to_int (buf[39]) << 18; + + digest[ 9] = (l >> 16) & 0xff; + digest[19] = (l >> 8) & 0xff; + digest[29] = (l >> 0) & 0xff; + + l = itoa64_to_int (buf[40]) << 0; + l |= itoa64_to_int (buf[41]) << 6; + l |= itoa64_to_int (buf[42]) << 12; + + digest[31] = (l >> 8) & 0xff; + digest[30] = (l >> 0) & 0xff; +} + +static void sha256crypt_encode (const u8 digest[32], u8 buf[43]) +{ + int l; + + l = (digest[ 0] << 16) | (digest[10] << 8) | (digest[20] << 0); + + buf[ 0] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 1] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 2] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 3] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[21] << 16) | (digest[ 1] << 8) | (digest[11] << 0); + + buf[ 4] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 5] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 6] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 7] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[12] << 16) | (digest[22] << 8) | (digest[ 2] << 0); + + buf[ 8] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[ 9] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[10] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[11] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[ 3] << 16) | (digest[13] << 8) | (digest[23] << 0); + + buf[12] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[13] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[14] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[15] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[24] << 16) | (digest[ 4] << 8) | (digest[14] << 0); + + buf[16] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[17] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[18] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[19] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[15] << 16) | (digest[25] << 8) | (digest[ 5] << 0); + + buf[20] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[21] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[22] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[23] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[ 6] << 16) | (digest[16] << 8) | (digest[26] << 0); + + buf[24] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[25] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[26] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[27] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[27] << 16) | (digest[ 7] << 8) | (digest[17] << 0); + + buf[28] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[29] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[30] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[31] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[18] << 16) | (digest[28] << 8) | (digest[ 8] << 0); + + buf[32] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[33] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[34] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[35] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = (digest[ 9] << 16) | (digest[19] << 8) | (digest[29] << 0); + + buf[36] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[37] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[38] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[39] = int_to_itoa64 (l & 0x3f); //l >>= 6; + + l = 0 | (digest[31] << 8) | (digest[30] << 0); + + buf[40] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[41] = int_to_itoa64 (l & 0x3f); l >>= 6; + buf[42] = int_to_itoa64 (l & 0x3f); //l >>= 6; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (sha256crypt_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + u32 pw_max = PW_MAX; + + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + if (optimized_kernel == true) + { + pw_max = 15; + } + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + token_t token; + + token.token_cnt = 5; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_MYSQL; + + token.len[0] = 7; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.len_min[1] = 1; + token.len_max[1] = 1; + token.sep[1] = '$'; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.len_min[2] = 3; + token.len_max[2] = 3; + token.sep[2] = '*'; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.len_min[3] = 40; + token.len_max[3] = 40; + token.sep[3] = '*'; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[4] = 86; + token.len_max[4] = 86; + token.sep[4] = '*'; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // version: + + const u8 *version_pos = token.buf[1]; + + if (version_pos[0] != 'A') return (PARSER_SIGNATURE_UNMATCHED); // $A$ + + // cost factor: + + const u8 *cost_pos = token.buf[2]; + + u32 cost_factor = hc_strtoul ((const char *) cost_pos, NULL, 10); + + u32 salt_iter = cost_factor * MULTIPLIER_MYSQL; + + // from: https://github.com/mysql/mysql-server/blob/4869291f7ee258e136ef03f5a50135fe7329ffb9/include/crypt_genhash_impl.h#L30-L31 + + if (salt_iter < 1000) return (PARSER_SALT_ITERATION); + + // this check would probably be unsafe because it might change in the future: + // if (salt_iter > 5000) return (PARSER_SALT_ITERATION); + + salt->salt_iter = salt_iter; + + const u8 *salt_pos = token.buf[3]; + const int salt_len = token.len[3]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + const u8 *hash_pos = token.buf[4]; + const int hash_len = token.len[4]; + + u8 tmp_dgst[100] = { 0 }; + + const int dgst_len = hex_decode ((const u8 *) hash_pos, hash_len, (u8 *) tmp_dgst); + + if (dgst_len != 43) return (PARSER_HASH_ENCODING); + + sha256crypt_decode ((u8 *) digest, tmp_dgst); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + // digest: + + u8 dgst[100] = { 0 }; + + sha256crypt_encode ((u8 *) digest_buf, dgst); + + // yeah, this is weird: we use hex-encoding for base64-encoded salt + // this has to do with missing MySQL function to decode/encode this variant of base64 + + u8 hex_dgst[100] = { 0 }; + + hex_encode (dgst, 43, hex_dgst); + + uppercase (hex_dgst, 86); // cosmetic + + // salt: + + u8 hex_salt[SALT_MAX * 2] = { 0 }; + + const int salt_len = generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, hex_salt); + + hex_salt[salt_len] = 0; + + uppercase (hex_salt, 40); // cosmetic + + const int cost = salt->salt_iter / MULTIPLIER_MYSQL; + + int line_len = snprintf (line_buf, line_size, "$mysql$A$%03i*%s*%s", cost, hex_salt, hex_dgst); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_07500.c b/src/modules/module_07500.c index cae72985d..468380134 100644 --- a/src/modules/module_07500.c +++ b/src/modules/module_07500.c @@ -78,6 +78,15 @@ u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { diff --git a/src/modules/module_07800.c b/src/modules/module_07800.c index c47ad7e0c..0d79c1256 100644 --- a/src/modules/module_07800.c +++ b/src/modules/module_07800.c @@ -51,17 +51,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: password not found - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -221,6 +210,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_07801.c b/src/modules/module_07801.c index 71d4928e8..03afc6595 100644 --- a/src/modules/module_07801.c +++ b/src/modules/module_07801.c @@ -51,17 +51,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: password not found - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -221,6 +210,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_07900.c b/src/modules/module_07900.c index 781ffd524..7e8821016 100644 --- a/src/modules/module_07900.c +++ b/src/modules/module_07900.c @@ -20,6 +20,7 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; static const char *HASH_NAME = "Drupal7"; static const u64 KERN_TYPE = 7900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_REGISTER_LIMIT | OPTI_TYPE_USES_BITS_64; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -49,6 +50,31 @@ typedef struct drupal7_tmp static const char *SIGNATURE_DRUPAL7 = "$S$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (drupal7_tmp_t); @@ -284,29 +310,6 @@ static void drupal7_encode (const u8 digest[64], u8 buf[43]) //buf[43] = int_to_itoa64 (l & 0x3f); } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - // trap 6 - if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) - { - return true; - } - } - - return false; -} - -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -487,6 +490,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_08000.c b/src/modules/module_08000.c index b32d0da9f..e5b33b331 100644 --- a/src/modules/module_08000.c +++ b/src/modules/module_08000.c @@ -60,14 +60,32 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + + return false; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -223,6 +241,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_08100.c b/src/modules/module_08100.c index c84e4f38b..23211af1d 100644 --- a/src/modules/module_08100.c +++ b/src/modules/module_08100.c @@ -17,7 +17,7 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; -static const char *HASH_NAME = "Citrix NetScaler"; +static const char *HASH_NAME = "Citrix NetScaler (SHA1)"; static const u64 KERN_TYPE = 8100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT diff --git a/src/modules/module_08200.c b/src/modules/module_08200.c index 4d44eb5a7..fffa11d5c 100644 --- a/src/modules/module_08200.c +++ b/src/modules/module_08200.c @@ -62,9 +62,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_08500.c b/src/modules/module_08500.c index b39cd7c14..974cd8e0b 100644 --- a/src/modules/module_08500.c +++ b/src/modules/module_08500.c @@ -44,6 +44,31 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, static const char *SIGNATURE_RACF = "$racf$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 pw_max = 8; // Underlaying DES max @@ -213,7 +238,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_08600.c b/src/modules/module_08600.c index 422df3893..8cb8ee957 100644 --- a/src/modules/module_08600.c +++ b/src/modules/module_08600.c @@ -50,17 +50,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -173,6 +162,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_09200.c b/src/modules/module_09200.c index bf26e3ed8..13d63eead 100644 --- a/src/modules/module_09200.c +++ b/src/modules/module_09200.c @@ -84,22 +84,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { @@ -257,7 +242,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_09500.c b/src/modules/module_09500.c index 328bdeea4..ee2a7ac9a 100644 --- a/src/modules/module_09500.c +++ b/src/modules/module_09500.c @@ -21,7 +21,8 @@ static const char *HASH_NAME = "MS Office 2010"; static const u64 KERN_TYPE = 9500; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; -static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_DEEP_COMP_KERNEL; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$office$*2010*100000*128*16*34170046140146368675746031258762*de5bc114991bb3a5679a6e24320bdb09*1b72a4ddffba3dcd5395f6a5ff75b126cb832b733c298e86162028ca47a235a9"; @@ -56,6 +57,11 @@ typedef struct office2010_tmp static const char *SIGNATURE_OFFICE2010 = "$office$"; +u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) +{ + return KERN_RUN_3; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (office2010_t); @@ -265,7 +271,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; - module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; module_ctx->module_dgst_pos2 = module_dgst_pos2; diff --git a/src/modules/module_09600.c b/src/modules/module_09600.c index f9adb9e7f..948fddf33 100644 --- a/src/modules/module_09600.c +++ b/src/modules/module_09600.c @@ -9,7 +9,6 @@ #include "bitops.h" #include "convert.h" #include "shared.h" -#include "memory.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -58,6 +57,32 @@ typedef struct office2013_tmp static const char *SIGNATURE_OFFICE2013 = "$office$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + + u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) { return KERN_RUN_3; @@ -87,13 +112,15 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - char *jit_build_options = NULL; + // amdgpu-pro-19.30-934563-ubuntu-18.04: self-test failure. + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + return true; + } - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; + return false; } int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) @@ -339,6 +366,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_09710.c b/src/modules/module_09710.c index f2f8b662a..2f7a5957a 100644 --- a/src/modules/module_09710.c +++ b/src/modules/module_09710.c @@ -99,7 +99,7 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u32 forced_outfile_format = 5; + const u32 forced_outfile_format = OUTFILE_FMT_HASH | OUTFILE_FMT_HEXPLAIN; return forced_outfile_format; } diff --git a/src/modules/module_09800.c b/src/modules/module_09800.c index b191924dc..61ab1471a 100644 --- a/src/modules/module_09800.c +++ b/src/modules/module_09800.c @@ -49,6 +49,8 @@ typedef struct oldoffice34 u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; @@ -137,7 +139,22 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + // alternative format (with second block data): + + if (rc_tokenizer == PARSER_TOKEN_LENGTH) // or just rc_tokenizer != PARSER_OK + { + token.token_cnt = 6; + + token.len_min[5] = 64; + token.len_max[5] = 64; + token.sep[5] = '*'; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + } if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); @@ -165,6 +182,24 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE oldoffice34->encryptedVerifierHash[3] = hex_to_u32 (encryptedVerifierHash_pos + 24); oldoffice34->encryptedVerifierHash[4] = hex_to_u32 (encryptedVerifierHash_pos + 32); + // second block (if needed) + + oldoffice34->secondBlockLen = 0; + + if (token.token_cnt == 6) + { + oldoffice34->secondBlockData[0] = 0; + + const u8 *second_block_data = token.buf[5]; + + for (int i = 0, j = 0; i < 8; i += 1, j += 8) + { + oldoffice34->secondBlockData[i] = hex_to_u32 (second_block_data + j); + } + + oldoffice34->secondBlockLen = 64; + } + // salt salt->salt_len = 16; @@ -208,7 +243,23 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const oldoffice34_t *oldoffice34 = (const oldoffice34_t *) esalt_buf; - const int line_len = snprintf (line_buf, line_size, "%s%u*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", + u8 secondBlockData[64 + 1 + 1]; + + memset (secondBlockData, 0, sizeof (secondBlockData)); + + if (oldoffice34->secondBlockLen != 0) + { + secondBlockData[0] = '*'; + + u8 *ptr = (u8 *) oldoffice34->secondBlockData; + + for (int i = 0, j = 1; i < 32; i += 1, j += 2) + { + u8_to_hex (ptr[i], secondBlockData + j); + } + } + + const int line_len = snprintf (line_buf, line_size, "%s%u*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%s", SIGNATURE_OLDOFFICE, oldoffice34->version, salt->salt_buf[0], @@ -223,7 +274,8 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE byte_swap_32 (oldoffice34->encryptedVerifierHash[1]), byte_swap_32 (oldoffice34->encryptedVerifierHash[2]), byte_swap_32 (oldoffice34->encryptedVerifierHash[3]), - byte_swap_32 (oldoffice34->encryptedVerifierHash[4])); + byte_swap_32 (oldoffice34->encryptedVerifierHash[4]), + secondBlockData); return line_len; } diff --git a/src/modules/module_09810.c b/src/modules/module_09810.c index ecbba7c64..ff9ccd2a5 100644 --- a/src/modules/module_09810.c +++ b/src/modules/module_09810.c @@ -48,6 +48,8 @@ typedef struct oldoffice34 u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; @@ -98,7 +100,7 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u32 forced_outfile_format = 5; + const u32 forced_outfile_format = OUTFILE_FMT_HASH | OUTFILE_FMT_HEXPLAIN; return forced_outfile_format; } @@ -144,7 +146,22 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + // alternative format (with second block data): + + if (rc_tokenizer == PARSER_TOKEN_LENGTH) // or just rc_tokenizer != PARSER_OK + { + token.token_cnt = 6; + + token.len_min[5] = 64; + token.len_max[5] = 64; + token.sep[5] = '*'; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + } if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); @@ -172,6 +189,24 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE oldoffice34->encryptedVerifierHash[3] = hex_to_u32 (encryptedVerifierHash_pos + 24); oldoffice34->encryptedVerifierHash[4] = hex_to_u32 (encryptedVerifierHash_pos + 32); + // second block (if needed) + + oldoffice34->secondBlockLen = 0; + + if (token.token_cnt == 6) + { + oldoffice34->secondBlockData[0] = 0; + + const u8 *second_block_data = token.buf[5]; + + for (int i = 0, j = 0; i < 8; i += 1, j += 8) + { + oldoffice34->secondBlockData[i] = hex_to_u32 (second_block_data + j); + } + + oldoffice34->secondBlockLen = 64; + } + // salt salt->salt_len = 16; @@ -215,7 +250,23 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const oldoffice34_t *oldoffice34 = (const oldoffice34_t *) esalt_buf; - const int line_len = snprintf (line_buf, line_size, "%s%u*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", + u8 secondBlockData[64 + 1 + 1]; + + memset (secondBlockData, 0, sizeof (secondBlockData)); + + if (oldoffice34->secondBlockLen != 0) + { + secondBlockData[0] = '*'; + + u8 *ptr = (u8 *) oldoffice34->secondBlockData; + + for (int i = 0, j = 1; i < 32; i += 1, j += 2) + { + u8_to_hex (ptr[i], secondBlockData + j); + } + } + + const int line_len = snprintf (line_buf, line_size, "%s%u*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%s", SIGNATURE_OLDOFFICE, oldoffice34->version, salt->salt_buf[0], @@ -230,7 +281,8 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE byte_swap_32 (oldoffice34->encryptedVerifierHash[1]), byte_swap_32 (oldoffice34->encryptedVerifierHash[2]), byte_swap_32 (oldoffice34->encryptedVerifierHash[3]), - byte_swap_32 (oldoffice34->encryptedVerifierHash[4])); + byte_swap_32 (oldoffice34->encryptedVerifierHash[4]), + secondBlockData); return line_len; } diff --git a/src/modules/module_09820.c b/src/modules/module_09820.c index fd1aeabc1..7a6b2869c 100644 --- a/src/modules/module_09820.c +++ b/src/modules/module_09820.c @@ -50,6 +50,8 @@ typedef struct oldoffice34 u32 version; u32 encryptedVerifier[4]; u32 encryptedVerifierHash[5]; + u32 secondBlockData[8]; + u32 secondBlockLen; u32 rc4key[2]; } oldoffice34_t; @@ -117,7 +119,29 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + // alternative format (with second block data): + + if (rc_tokenizer == PARSER_TOKEN_LENGTH) // or just rc_tokenizer != PARSER_OK + { + token.token_cnt = 7; + + token.sep[4] = '*'; + + token.len_min[5] = 64; + token.len_max[5] = 64; + token.sep[5] = ':'; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[6] = 10; + token.len_max[6] = 10; + token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + } if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); @@ -125,7 +149,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *osalt_pos = token.buf[2]; const u8 *encryptedVerifier_pos = token.buf[3]; const u8 *encryptedVerifierHash_pos = token.buf[4]; - const u8 *rc4key_pos = token.buf[5]; + + const u8 rc4_idx = token.token_cnt - 1; + + const u8 *rc4key_pos = token.buf[rc4_idx]; // esalt @@ -163,6 +190,24 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE oldoffice34->rc4key[0] = byte_swap_32 (oldoffice34->rc4key[0]); oldoffice34->rc4key[1] = byte_swap_32 (oldoffice34->rc4key[1]); + // second block (if needed) + + oldoffice34->secondBlockLen = 0; + + if (token.token_cnt == 7) + { + oldoffice34->secondBlockData[0] = 0; + + const u8 *second_block_data = token.buf[5]; + + for (int i = 0, j = 0; i < 8; i += 1, j += 8) + { + oldoffice34->secondBlockData[i] = hex_to_u32 (second_block_data + j); + } + + oldoffice34->secondBlockLen = 64; + } + // salt salt->salt_len = 16; @@ -208,7 +253,23 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *rc4key = (const u8 *) oldoffice34->rc4key; - const int line_len = snprintf (line_buf, line_size, "%s%u*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", + u8 secondBlockData[64 + 1 + 1]; + + memset (secondBlockData, 0, sizeof (secondBlockData)); + + if (oldoffice34->secondBlockLen != 0) + { + secondBlockData[0] = '*'; + + u8 *ptr = (u8 *) oldoffice34->secondBlockData; + + for (int i = 0, j = 1; i < 32; i += 1, j += 2) + { + u8_to_hex (ptr[i], secondBlockData + j); + } + } + + const int line_len = snprintf (line_buf, line_size, "%s%u*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%s:%02x%02x%02x%02x%02x", SIGNATURE_OLDOFFICE, oldoffice34->version, salt->salt_buf[0], @@ -224,6 +285,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE byte_swap_32 (oldoffice34->encryptedVerifierHash[2]), byte_swap_32 (oldoffice34->encryptedVerifierHash[3]), byte_swap_32 (oldoffice34->encryptedVerifierHash[4]), + secondBlockData, rc4key[0], rc4key[1], rc4key[2], diff --git a/src/modules/module_10000.c b/src/modules/module_10000.c index 8878b3ffe..dff0015e2 100644 --- a/src/modules/module_10000.c +++ b/src/modules/module_10000.c @@ -16,7 +16,7 @@ static const u32 DGST_POS1 = 1; static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_32; -static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; static const char *HASH_NAME = "Django (PBKDF2-SHA256)"; static const u64 KERN_TYPE = 10900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE diff --git a/src/modules/module_10400.c b/src/modules/module_10400.c index 0d683dc1d..60f3f28d8 100644 --- a/src/modules/module_10400.c +++ b/src/modules/module_10400.c @@ -64,6 +64,37 @@ typedef struct pdf static const char *SIGNATURE_PDF = "$pdf$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pdf_t); @@ -345,7 +376,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_10410.c b/src/modules/module_10410.c index 96624d904..998a79b4a 100644 --- a/src/modules/module_10410.c +++ b/src/modules/module_10410.c @@ -65,6 +65,37 @@ typedef struct pdf static const char *SIGNATURE_PDF = "$pdf$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pdf_t); @@ -107,7 +138,7 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u32 forced_outfile_format = 5; + const u32 forced_outfile_format = OUTFILE_FMT_HASH | OUTFILE_FMT_HEXPLAIN; return forced_outfile_format; } @@ -365,7 +396,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_10500.c b/src/modules/module_10500.c index 68975507a..54b1a770e 100644 --- a/src/modules/module_10500.c +++ b/src/modules/module_10500.c @@ -88,6 +88,31 @@ static void md5_complete_no_limit (u32 digest[4], const u32 *plain, const u32 pl digest[3] = md5_ctx.h[3]; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pdf_t); @@ -471,7 +496,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_10700.c b/src/modules/module_10700.c index 3e669131e..fe006580c 100644 --- a/src/modules/module_10700.c +++ b/src/modules/module_10700.c @@ -19,7 +19,8 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_DOCUMENTS; static const char *HASH_NAME = "PDF 1.7 Level 8 (Acrobat 10 - 11)"; static const u64 KERN_TYPE = 10700; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_REGISTER_LIMIT; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_HASH_COPY; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; @@ -106,49 +107,26 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake: Segmentation fault - if (device_param->opencl_platform_vendor_id == VENDOR_ID_POCL) - { - return true; - } - - // l_opencl_p_18.1.0.013: password not found - if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) - { - return true; - } - } - - // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed. - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) - { - return true; - } - } - - return false; -} - char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { char *jit_build_options = NULL; - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + // this is a workaround to avoid a Segmentation fault and self-test fails on AMD GPU PRO + + hc_asprintf (&jit_build_options, "-cl-opt-disable"); + } + + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + // this is a workaround to avoid a compile time of over an hour (and then to not work) on ROCM in pure kernel mode + + hc_asprintf (&jit_build_options, "-cl-opt-disable"); + } + } return jit_build_options; } @@ -396,7 +374,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_separator = MODULE_DEFAULT; module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; - module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_10800.c b/src/modules/module_10800.c index 83f7c04c7..b10c09996 100644 --- a/src/modules/module_10800.c +++ b/src/modules/module_10800.c @@ -52,19 +52,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->is_cuda == true) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; } - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; diff --git a/src/modules/module_10900.c b/src/modules/module_10900.c index e09a65e84..9e629949b 100644 --- a/src/modules/module_10900.c +++ b/src/modules/module_10900.c @@ -61,6 +61,31 @@ typedef struct pbkdf2_sha256_tmp static const char *SIGNATURE_PBKDF2_SHA256 = "sha256"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_t); @@ -85,28 +110,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_10901.c b/src/modules/module_10901.c new file mode 100644 index 000000000..0ecf50529 --- /dev/null +++ b/src/modules/module_10901.c @@ -0,0 +1,265 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; + +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_64; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_SERVER; +static const char *HASH_NAME = "RedHat 389-DS LDAP (PBKDF2-HMAC-SHA256)"; +static const u64 KERN_TYPE = 10900; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "{PBKDF2_SHA256}AAAgADkxMjM2NTIzMzgzMjQ3MjI4MDAwNTk5OTAyOTk4NDI2MjkyMzAzNjg0NjQwOTMxNjI3OTMzNjg0MDI0OTY5NTe5ULagRTYpLaUoeqJMg8x9W/DXu+9VTFaVhaYvebYrY+sOqn1ZMRnws22C1uAkiE2tFM8qN+xw5xe7OmCPZ203NuruK4oB33QlsKIEz4ppm0TR94JB9PJx7lIQwFHD3FUNUNryj4jk6UYyJ4+V1Z9Ug/Iy/ylQBJgfs5ihzgxHYZrfp1wUCXFzlZG9mxmziPm8VFnAhaX4+FBAZvLAx33jpbKOwEg7TmwP2VJ8BNFLQRqwYdlqIjQlAhncXH+dqIF9VdM4MonAA0hx76bMvFTP7LF5VO1IqVmcuYz7YG9v4KKRjnvoUUqOj6okUBQTay3EzsdFVnUW1FemYOccJd5q"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct pbkdf2_sha256 +{ + u32 salt_buf[64]; + +} pbkdf2_sha256_t; + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +static const char *SIGNATURE_REDHAT_PBKDF2_SHA256 = "{PBKDF2_SHA256}"; + +static const int HASH_LEN_RAW = 256; +static const int SALT_LEN_RAW = 64; +static const int ITER_LEN_RAW = 4; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha256_t *pbkdf2_sha256 = (pbkdf2_sha256_t *) esalt_buf; + + token_t token; + + token.token_cnt = 2; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_REDHAT_PBKDF2_SHA256; + + //length of signature + token.len[0] = 15; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + //length of base64 encoded hash + token.len_min[1] = 432; + token.len_max[1] = 432; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + //read hash into tmp_buf + + const u8 *tmp_pos = token.buf[1]; + const int tmp_len = token.len[1]; + + u8 tmp_buf[512]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + const int base64_decode_len = base64_decode (base64_to_int, tmp_pos, tmp_len, tmp_buf); + + if (base64_decode_len != (ITER_LEN_RAW + SALT_LEN_RAW + HASH_LEN_RAW)) return (PARSER_HASH_LENGTH); + + // iter + + u8 *iter_pos = tmp_buf; + + u32 salt_iter; + + memcpy (&salt_iter, iter_pos, ITER_LEN_RAW); + + salt_iter = byte_swap_32 (salt_iter); // implementation does a ntohl() + + salt->salt_iter = salt_iter - 1; + + // salt + + u8 *salt_pos = tmp_buf + ITER_LEN_RAW; + + salt->salt_len = SALT_LEN_RAW; + + memcpy (pbkdf2_sha256->salt_buf, salt_pos, SALT_LEN_RAW); + + for (int i = 0; i < SALT_LEN_RAW / 4; i++) salt->salt_buf[i] = pbkdf2_sha256->salt_buf[i]; + + // hash + + u8 *hash_pos = tmp_buf + ITER_LEN_RAW + SALT_LEN_RAW; + + memcpy (digest, hash_pos, HASH_LEN_RAW); + + for (int i = 0; i < HASH_LEN_RAW / 4; i++) digest[i] = byte_swap_32 (digest[i]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const pbkdf2_sha256_t *pbkdf2_sha256 = (pbkdf2_sha256_t *) esalt_buf; + + u32 tmp_digest[64]; + + for (int i = 0; i < HASH_LEN_RAW / 4; i++) tmp_digest[i] = byte_swap_32 (digest[i]); + + char tmp_buf[512]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + const u32 salt_iters = byte_swap_32 (salt->salt_iter + 1); //htonl (salt->salt_iter); + + memcpy (tmp_buf, &salt_iters, ITER_LEN_RAW); + memcpy (tmp_buf + ITER_LEN_RAW, pbkdf2_sha256->salt_buf, salt->salt_len); + memcpy (tmp_buf + ITER_LEN_RAW + SALT_LEN_RAW, tmp_digest, HASH_LEN_RAW); + + char ptr_plain[512]; + + memset (ptr_plain, 0, sizeof (ptr_plain)); + + base64_encode (int_to_base64, (const u8 *) tmp_buf, (ITER_LEN_RAW + SALT_LEN_RAW + HASH_LEN_RAW), (u8 *) ptr_plain); + + const int line_len = snprintf (line_buf, line_size, "%s%s", SIGNATURE_REDHAT_PBKDF2_SHA256, ptr_plain); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} + diff --git a/src/modules/module_11000.c b/src/modules/module_11000.c index 138f23ce5..c79414903 100644 --- a/src/modules/module_11000.c +++ b/src/modules/module_11000.c @@ -58,23 +58,6 @@ u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return salt_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -188,7 +171,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_11300.c b/src/modules/module_11300.c index 32a164d91..5d3a31c88 100644 --- a/src/modules/module_11300.c +++ b/src/modules/module_11300.c @@ -51,6 +51,9 @@ typedef struct bitcoin_wallet u32 cry_master_buf[64]; u32 cry_master_len; + u32 cry_salt_buf[16]; + u32 cry_salt_len; + } bitcoin_wallet_t; typedef struct bitcoin_wallet_tmp @@ -61,6 +64,31 @@ typedef struct bitcoin_wallet_tmp static const char *SIGNATURE_BITCOIN_WALLET = "$bitcoin$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (bitcoin_wallet_t); @@ -85,29 +113,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - // trap 6 - if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) - { - return true; - } - } - - return false; -} - -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -127,12 +132,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[1] = '$'; token.len_min[1] = 2; - token.len_max[1] = 2; + token.len_max[1] = 3; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 16; + token.len_min[2] = 64; token.len_max[2] = 256; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -145,7 +150,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[4] = '$'; token.len_min[4] = 16; - token.len_max[4] = 16; + token.len_max[4] = 36; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -208,7 +213,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (ckey_buf_len != ckey_len) return (PARSER_SALT_VALUE); if (public_key_buf_len != public_key_len) return (PARSER_SALT_VALUE); - if (cry_master_len % 16) return (PARSER_SALT_VALUE); + if (cry_master_len < 64) return (PARSER_SALT_VALUE); + if (cry_master_len % 32) return (PARSER_SALT_VALUE); + + if (cry_salt_len != 16 && cry_salt_len != 36) return (PARSER_SALT_VALUE); // esalt @@ -232,12 +240,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE salt->salt_iter = cry_rounds - 1; - // salt + // esalt - const bool parse_rc = generic_salt_decode (hashconfig, cry_salt_buf_pos, cry_salt_buf_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + const bool parse_rc = generic_salt_decode (hashconfig, cry_salt_buf_pos, cry_salt_buf_len, (u8 *) bitcoin_wallet->cry_salt_buf, (int *) &bitcoin_wallet->cry_salt_len); if (parse_rc == false) return (PARSER_SALT_LENGTH); + // salt + + salt->salt_buf[0] = bitcoin_wallet->cry_salt_buf[0]; + salt->salt_buf[1] = bitcoin_wallet->cry_salt_buf[1]; + + salt->salt_len = 8; + return (PARSER_OK); } @@ -315,6 +330,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_11600.c b/src/modules/module_11600.c index c05058ab9..edb374ffd 100644 --- a/src/modules/module_11600.c +++ b/src/modules/module_11600.c @@ -94,7 +94,27 @@ typedef struct seven_zip_hook_salt static const char *SIGNATURE_SEVEN_ZIP = "$7z$"; -void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt) +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + + +void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pw_pos) { seven_zip_hook_t *hook_items = (seven_zip_hook_t *) device_param->hooks_buf; @@ -105,67 +125,40 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, u32 *data_buf = seven_zip->data_buf; u32 unpack_size = seven_zip->unpack_size; - for (u64 pw_pos = 0; pw_pos < pws_cnt; pw_pos++) + // this hook data needs to be updated (the "hook_success" variable): + + seven_zip_hook_t *hook_item = &hook_items[pw_pos]; + + const u32 *ukey = (const u32 *) hook_item->ukey; + + // init AES + + AES_KEY aes_key; + + memset (&aes_key, 0, sizeof (aes_key)); + + aes256_set_decrypt_key (aes_key.rdk, ukey, (u32 *) te0, (u32 *) te1, (u32 *) te2, (u32 *) te3, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3); + + int aes_len = seven_zip->aes_len; + + u32 data[4]; + u32 out[4]; + u32 iv[4]; + + iv[0] = seven_zip->iv_buf[0]; + iv[1] = seven_zip->iv_buf[1]; + iv[2] = seven_zip->iv_buf[2]; + iv[3] = seven_zip->iv_buf[3]; + + u32 out_full[81882]; + + // if aes_len > 16 we need to loop + + int i = 0; + int j = 0; + + for (i = 0, j = 0; i < aes_len - 16; i += 16, j += 4) { - // this hook data needs to be updated (the "hook_success" variable): - - seven_zip_hook_t *hook_item = &hook_items[pw_pos]; - - const u32 *ukey = (const u32 *) hook_item->ukey; - - // init AES - - AES_KEY aes_key; - - memset (&aes_key, 0, sizeof (aes_key)); - - aes256_set_decrypt_key (aes_key.rdk, ukey, (u32 *) te0, (u32 *) te1, (u32 *) te2, (u32 *) te3, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3); - - int aes_len = seven_zip->aes_len; - - u32 data[4]; - u32 out[4]; - u32 iv[4]; - - iv[0] = seven_zip->iv_buf[0]; - iv[1] = seven_zip->iv_buf[1]; - iv[2] = seven_zip->iv_buf[2]; - iv[3] = seven_zip->iv_buf[3]; - - u32 out_full[81882]; - - // if aes_len > 16 we need to loop - - int i = 0; - int j = 0; - - for (i = 0, j = 0; i < aes_len - 16; i += 16, j += 4) - { - data[0] = data_buf[j + 0]; - data[1] = data_buf[j + 1]; - data[2] = data_buf[j + 2]; - data[3] = data_buf[j + 3]; - - aes256_decrypt (aes_key.rdk, data, out, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4); - - out[0] ^= iv[0]; - out[1] ^= iv[1]; - out[2] ^= iv[2]; - out[3] ^= iv[3]; - - iv[0] = data[0]; - iv[1] = data[1]; - iv[2] = data[2]; - iv[3] = data[3]; - - out_full[j + 0] = out[0]; - out_full[j + 1] = out[1]; - out_full[j + 2] = out[2]; - out_full[j + 3] = out[3]; - } - - // we need to run it at least once: - data[0] = data_buf[j + 0]; data[1] = data_buf[j + 1]; data[2] = data_buf[j + 2]; @@ -178,105 +171,129 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, out[2] ^= iv[2]; out[3] ^= iv[3]; + iv[0] = data[0]; + iv[1] = data[1]; + iv[2] = data[2]; + iv[3] = data[3]; + out_full[j + 0] = out[0]; out_full[j + 1] = out[1]; out_full[j + 2] = out[2]; out_full[j + 3] = out[3]; + } - /* - * check the CRC32 "hash" - */ + // we need to run it at least once: - u32 seven_zip_crc = seven_zip->crc; + data[0] = data_buf[j + 0]; + data[1] = data_buf[j + 1]; + data[2] = data_buf[j + 2]; + data[3] = data_buf[j + 3]; - u32 crc; + aes256_decrypt (aes_key.rdk, data, out, (u32 *) td0, (u32 *) td1, (u32 *) td2, (u32 *) td3, (u32 *) td4); - if (data_type == 0) // uncompressed + out[0] ^= iv[0]; + out[1] ^= iv[1]; + out[2] ^= iv[2]; + out[3] ^= iv[3]; + + out_full[j + 0] = out[0]; + out_full[j + 1] = out[1]; + out_full[j + 2] = out[2]; + out_full[j + 3] = out[3]; + + /* + * check the CRC32 "hash" + */ + + u32 seven_zip_crc = seven_zip->crc; + + u32 crc; + + if (data_type == 0) // uncompressed + { + crc = cpu_crc32_buffer ((u8 *) out_full, unpack_size); + } + else + { + u32 crc_len = seven_zip->crc_len; + + char *coder_attributes = seven_zip->coder_attributes; + + // input buffers and length + + u8 *compressed_data = (u8 *) out_full; + + SizeT compressed_data_len = aes_len; + + // output buffers and length + + unsigned char *decompressed_data; + + decompressed_data = (unsigned char *) hcmalloc (crc_len); + + SizeT decompressed_data_len = crc_len; + + int ret; + + if (data_type == 1) // LZMA1 { - crc = cpu_crc32_buffer ((u8 *) out_full, unpack_size); + ret = hc_lzma1_decompress (compressed_data, &compressed_data_len, decompressed_data, &decompressed_data_len, coder_attributes); } - else + else if (data_type == 7) // inflate using zlib (DEFLATE compression) { - u32 crc_len = seven_zip->crc_len; + ret = SZ_ERROR_DATA; - char *coder_attributes = seven_zip->coder_attributes; + z_stream inf; - // input buffers and length + inf.zalloc = Z_NULL; + inf.zfree = Z_NULL; + inf.opaque = Z_NULL; - u8 *compressed_data = (u8 *) out_full; + inf.avail_in = compressed_data_len; + inf.next_in = compressed_data; - SizeT compressed_data_len = aes_len; + inf.avail_out = decompressed_data_len; + inf.next_out = decompressed_data; - // output buffers and length + // inflate: - unsigned char *decompressed_data; + inflateInit2 (&inf, -MAX_WBITS); - decompressed_data = (unsigned char *) hcmalloc (crc_len); + int zlib_ret = inflate (&inf, Z_NO_FLUSH); - SizeT decompressed_data_len = crc_len; + inflateEnd (&inf); - int ret; - - if (data_type == 1) // LZMA1 + if ((zlib_ret == Z_OK) || (zlib_ret == Z_STREAM_END)) { - ret = hc_lzma1_decompress (compressed_data, &compressed_data_len, decompressed_data, &decompressed_data_len, coder_attributes); + ret = SZ_OK; } - else if (data_type == 7) // inflate using zlib (DEFLATE compression) - { - ret = SZ_ERROR_DATA; - - z_stream inf; - - inf.zalloc = Z_NULL; - inf.zfree = Z_NULL; - inf.opaque = Z_NULL; - - inf.avail_in = compressed_data_len; - inf.next_in = compressed_data; - - inf.avail_out = decompressed_data_len; - inf.next_out = decompressed_data; - - // inflate: - - inflateInit2 (&inf, -MAX_WBITS); - - int zlib_ret = inflate (&inf, Z_NO_FLUSH); - - inflateEnd (&inf); - - if ((zlib_ret == Z_OK) || (zlib_ret == Z_STREAM_END)) - { - ret = SZ_OK; - } - } - else // we only support LZMA2 in addition to LZMA1 - { - ret = hc_lzma2_decompress (compressed_data, &compressed_data_len, decompressed_data, &decompressed_data_len, coder_attributes); - } - - if (ret != SZ_OK) - { - hook_item->hook_success = 0; - - hcfree (decompressed_data); - - continue; - } - - crc = cpu_crc32_buffer (decompressed_data, crc_len); - - hcfree (decompressed_data); + } + else // we only support LZMA2 in addition to LZMA1 + { + ret = hc_lzma2_decompress (compressed_data, &compressed_data_len, decompressed_data, &decompressed_data_len, coder_attributes); } - if (crc == seven_zip_crc) - { - hook_item->hook_success = 1; - } - else + if (ret != SZ_OK) { hook_item->hook_success = 0; + + hcfree (decompressed_data); + + return; } + + crc = cpu_crc32_buffer (decompressed_data, crc_len); + + hcfree (decompressed_data); + } + + if (crc == seven_zip_crc) + { + hook_item->hook_success = 1; + } + else + { + hook_item->hook_success = 0; } } @@ -301,49 +318,46 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -u32 module_kernel_accel_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u32 kernel_accel_max = 128; // password length affects total performance, this limits the wait times for threads with short password lengths if there's at least one thread with long password length - - return kernel_accel_max; -} - u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - // this overrides the reductions of PW_MAX in case optimized kernel is selected - // IOW, even in optimized kernel mode it support length 256 + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - const u32 pw_max = PW_MAX; + u32 pw_max = PW_MAX; + + if (optimized_kernel == true) + { + pw_max = 20; + } return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +u32 module_kernel_loops_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - char *jit_build_options = NULL; + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - if (device_param->is_cuda == true) + u32 kernel_loops_min = KERNEL_LOOPS_MIN; + + if (optimized_kernel == true) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + kernel_loops_min = 4096; } - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; + return kernel_loops_min; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + u32 kernel_loops_max = KERNEL_LOOPS_MAX; + + if (optimized_kernel == true) { - return true; + kernel_loops_max = 4096; } - return false; + return kernel_loops_max; } int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) @@ -741,10 +755,10 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_size = module_hook_size; module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; - module_ctx->module_kernel_accel_max = module_kernel_accel_max; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; - module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; @@ -766,6 +780,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_11700.c b/src/modules/module_11700.c index 760f7396f..b7a5cb3cd 100644 --- a/src/modules/module_11700.c +++ b/src/modules/module_11700.c @@ -43,7 +43,7 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES + // amdgpu-pro-19.30-934563-ubuntu-18.04: CL_OUT_OF_RESOURCES if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) diff --git a/src/modules/module_11750.c b/src/modules/module_11750.c index 180c9134f..8be5c4dbd 100644 --- a/src/modules/module_11750.c +++ b/src/modules/module_11750.c @@ -41,17 +41,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -212,6 +201,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_11760.c b/src/modules/module_11760.c index a8239650a..6af85b12e 100644 --- a/src/modules/module_11760.c +++ b/src/modules/module_11760.c @@ -41,17 +41,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -212,6 +201,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_11800.c b/src/modules/module_11800.c index 834a9824d..485cc066b 100644 --- a/src/modules/module_11800.c +++ b/src/modules/module_11800.c @@ -43,7 +43,7 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES + // amdgpu-pro-19.30-934563-ubuntu-18.04: CL_OUT_OF_RESOURCES if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) diff --git a/src/modules/module_11850.c b/src/modules/module_11850.c index 427c4c58c..5832b0bce 100644 --- a/src/modules/module_11850.c +++ b/src/modules/module_11850.c @@ -41,17 +41,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -236,6 +225,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_11860.c b/src/modules/module_11860.c index a14e200f2..e906b095d 100644 --- a/src/modules/module_11860.c +++ b/src/modules/module_11860.c @@ -41,17 +41,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -236,6 +225,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_12100.c b/src/modules/module_12100.c index abd252672..546191755 100644 --- a/src/modules/module_12100.c +++ b/src/modules/module_12100.c @@ -86,18 +86,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -243,7 +231,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_12200.c b/src/modules/module_12200.c index d857b7e49..1bc010075 100644 --- a/src/modules/module_12200.c +++ b/src/modules/module_12200.c @@ -51,6 +51,31 @@ typedef struct ecryptfs_tmp static const char *SIGNATURE_ECRYPTFS = "$ecryptfs$"; static const int ROUNDS_ECRYPTFS = 65536; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (ecryptfs_tmp_t); @@ -68,28 +93,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_12300.c b/src/modules/module_12300.c index dee15c73d..e91d361f3 100644 --- a/src/modules/module_12300.c +++ b/src/modules/module_12300.c @@ -71,15 +71,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -217,7 +208,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_12400.c b/src/modules/module_12400.c index 91ba35598..9280a2f3f 100644 --- a/src/modules/module_12400.c +++ b/src/modules/module_12400.c @@ -20,7 +20,8 @@ static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "BSDi Crypt, Extended DES"; static const u64 KERN_TYPE = 12400; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_REGISTER_LIMIT; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -52,6 +53,25 @@ typedef struct bsdicrypt_tmp static const char *SIGNATURE_BSDICRYPT = "_"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 pw_max = (const u64) sizeof (bsdicrypt_tmp_t); @@ -230,7 +250,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_12500.c b/src/modules/module_12500.c index c95b57400..6e5c46635 100644 --- a/src/modules/module_12500.c +++ b/src/modules/module_12500.c @@ -91,17 +91,6 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, return mask; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -258,6 +247,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_12700.c b/src/modules/module_12700.c index d6fa81dc0..a88e1d03b 100644 --- a/src/modules/module_12700.c +++ b/src/modules/module_12700.c @@ -93,7 +93,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 64; + token.len_min[2] = 144; token.len_max[2] = 65536; token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH @@ -109,29 +109,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[2]; - salt->salt_buf[0] = hex_to_u32 (salt_pos + 0); - salt->salt_buf[1] = hex_to_u32 (salt_pos + 8); - salt->salt_buf[2] = hex_to_u32 (salt_pos + 16); - salt->salt_buf[3] = hex_to_u32 (salt_pos + 24); + // first 16 byte are IV - salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); - salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); - salt->salt_buf[2] = byte_swap_32 (salt->salt_buf[2]); - salt->salt_buf[3] = byte_swap_32 (salt->salt_buf[3]); + for (int i = 0, j = 0; i < 16; i += 1, j += 8) + { + salt->salt_buf[i] = hex_to_u32 (salt_pos + j); - // this is actually the CT, which is also the hash later (if matched) + salt->salt_buf[i] = byte_swap_32 (salt->salt_buf[i]); + } - salt->salt_buf[4] = hex_to_u32 (salt_pos + 32); - salt->salt_buf[5] = hex_to_u32 (salt_pos + 40); - salt->salt_buf[6] = hex_to_u32 (salt_pos + 48); - salt->salt_buf[7] = hex_to_u32 (salt_pos + 56); - - salt->salt_buf[4] = byte_swap_32 (salt->salt_buf[4]); - salt->salt_buf[5] = byte_swap_32 (salt->salt_buf[5]); - salt->salt_buf[6] = byte_swap_32 (salt->salt_buf[6]); - salt->salt_buf[7] = byte_swap_32 (salt->salt_buf[7]); - - salt->salt_len = 32; // note we need to fix this to 16 in kernel + salt->salt_len = 64; salt->salt_iter = ROUNDS_MYWALLET - 1; diff --git a/src/modules/module_12800.c b/src/modules/module_12800.c index 8d54446f2..2e69cd7fb 100644 --- a/src/modules/module_12800.c +++ b/src/modules/module_12800.c @@ -53,6 +53,31 @@ typedef struct pbkdf2_sha256_tmp static const char *SIGNATURE_MS_DRSR = "v1;PPH1_MD4"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); @@ -70,28 +95,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_12900.c b/src/modules/module_12900.c index 061515591..a9275ac0f 100644 --- a/src/modules/module_12900.c +++ b/src/modules/module_12900.c @@ -53,6 +53,31 @@ typedef struct pbkdf2_sha256_tmp static const int ROUNDS_ANDROIDFDE_SAMSUNG = 4096; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); @@ -70,28 +95,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_13000.c b/src/modules/module_13000.c index 431233d2d..da0e1880c 100644 --- a/src/modules/module_13000.c +++ b/src/modules/module_13000.c @@ -59,6 +59,31 @@ typedef struct rar5 static const char *SIGNATURE_RAR5 = "$rar5$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (rar5_t); @@ -83,28 +108,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_13100.c b/src/modules/module_13100.c index d425ad799..1203e34aa 100644 --- a/src/modules/module_13100.c +++ b/src/modules/module_13100.c @@ -75,7 +75,16 @@ u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + // amdgpu-pro-19.30-934563-ubuntu-18.04: CL_OUT_OF_RESOURCES if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) diff --git a/src/modules/module_13600.c b/src/modules/module_13600.c index 562841524..891c8518a 100644 --- a/src/modules/module_13600.c +++ b/src/modules/module_13600.c @@ -19,7 +19,8 @@ static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_ARCHIVE; static const char *HASH_NAME = "WinZip"; static const u64 KERN_TYPE = 13600; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -156,13 +157,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_max[5] = 6; token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + | TOKEN_ATTR_VERIFY_HEX; token.len_min[6] = 1; token.len_max[6] = 6; token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + | TOKEN_ATTR_VERIFY_HEX; token.len_min[7] = 0; token.len_max[7] = 16384; @@ -233,7 +234,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *compress_length_pos = token.buf[6]; - const u32 compress_length = hc_strtoul ((const char *) compress_length_pos, NULL, 10); + const u32 compress_length = hc_strtoul ((const char *) compress_length_pos, NULL, 16); zip2->compress_length = compress_length; @@ -364,7 +365,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 data_len = zip2->data_len; - char data_tmp[8192 + 1] = { 0 }; + char data_tmp[16384 + 1] = { 0 }; for (u32 i = 0, j = 0; i < data_len; i += 1, j += 2) { @@ -384,7 +385,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE sprintf (auth_tmp + j, "%02x", ptr[i]); } - const int line_len = snprintf (line_buf, line_size, "%s*%u*%u*%u*%s*%x*%u*%s*%s*%s", + const int line_len = snprintf (line_buf, line_size, "%s*%u*%u*%u*%s*%x*%x*%s*%s*%s", SIGNATURE_ZIP2_START, zip2->type, zip2->mode, diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index 87852ec44..2096bd458 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 512 bit"; static const u64 KERN_TYPE = 13711; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +80,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_655331 = 655331; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_tmp_t *vc_tmp = (const vc_tmp_t *) tmps; @@ -235,7 +226,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -321,7 +312,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index c8179fb71..8a5f1cf13 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1024 bit"; static const u64 KERN_TYPE = 13712; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +80,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_655331 = 655331; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_tmp_t *vc_tmp = (const vc_tmp_t *) tmps; @@ -235,7 +226,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -321,7 +312,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index 062378441..7a5360837 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1536 bit"; static const u64 KERN_TYPE = 13713; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +80,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_655331 = 655331; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_tmp_t *vc_tmp = (const vc_tmp_t *) tmps; @@ -235,7 +226,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -321,7 +312,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index fba2cc96d..9680018f1 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -23,9 +23,11 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA512 + XTS 512 bit"; static const u64 KERN_TYPE = 13721; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_USES_BITS_64; + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -56,6 +58,7 @@ typedef struct tc64_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_tmp_t; @@ -137,15 +140,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -233,7 +227,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -319,7 +313,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index 7e8257b77..88b7c0862 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -23,9 +23,11 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA512 + XTS 1024 bit"; static const u64 KERN_TYPE = 13722; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_USES_BITS_64; + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -56,6 +58,7 @@ typedef struct tc64_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_tmp_t; @@ -137,15 +140,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -233,7 +227,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -319,7 +313,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index 5b9c5cb94..bf90814ed 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -23,9 +23,11 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA512 + XTS 1536 bit"; static const u64 KERN_TYPE = 13723; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_USES_BITS_64; + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -56,6 +58,7 @@ typedef struct tc64_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_tmp_t; @@ -137,15 +140,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) { const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -233,7 +227,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -319,7 +313,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index 3afff8644..ab2885331 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Whirlpool + XTS 512 bit"; static const u64 KERN_TYPE = 13731; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +80,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_tmp_t *vc_tmp = (const vc_tmp_t *) tmps; @@ -235,7 +226,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -321,7 +312,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index 965776e9e..7ba12cfca 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Whirlpool + XTS 1024 bit"; static const u64 KERN_TYPE = 13732; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +80,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_tmp_t *vc_tmp = (const vc_tmp_t *) tmps; @@ -235,7 +226,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -321,7 +312,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index 3a7d0bbbb..2dfac5939 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Whirlpool + XTS 1536 bit"; static const u64 KERN_TYPE = 13733; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +80,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_tmp_t *vc_tmp = (const vc_tmp_t *) tmps; @@ -235,7 +226,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -321,7 +312,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index 45fa7d48c..e819dc268 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -22,10 +22,13 @@ static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 512 bit + boot-mode"; static const u64 KERN_TYPE = 13711; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE - | OPTS_TYPE_KEYBOARD_MAPPING; + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "528c2997054ce1d22cbc5233463df8119a0318ab94aa715e6e686c898f36690b443221a18f578fb893e0db1e4b875cc711eab542e70e13b55d6aa26134e1a8d34f5ae6caaea7390a5e2f50130e85f9e551216dd0895f4fb0bcdec219246c249236771e1f2a1f447054d363c398ab367ed7f9574eb0611211e742f429cd53b56fcdb42d2eb183c134847dc6efc7c8293d6481aa53406f0446398591956f79ca3ce76e80208fd409d0f6f14c68312fc119ab4292972338b1457c73585ae2fc863bf202f141495de50253799cbc27010fba6de6b0a36888d12f4e3964aaaf43a830097aee7d40c5e79e5e80e7b0228a67a95bb4969dd8afa0d51d6fff340f82e824547c708b5aa59274009d7d847c53a8019e73c068c6e96a4c3c6c27d0e9f4a8c3a9c52c964eebc00128e9a539f4f569606c92bfc2d4662494a1a6aca239d73399645c86bd66b8985b5bf217b29eeba0507a388aeec85fe94f6b42a1b805ecb90a08b2c8081fe51e76bc1d97f73ae10c72a9b2db694304e04807820c088f91bb97d4585493f3e6cc392a7e56a64a66b8e11b51898b4f956d1b5fe8cf55772fd6f8c0f2a2bb2d9fef05ab2bb90f251ff2e6aa0dfffeac9e045be2ec44ebc8dd4d260748e308205475dcc2cef369e869bfc1e6d7335620c694f524260770838c768346d83af7b467cdc80814d8f55a535dbac35fc278d0d1f6101db95019cee097bb"; @@ -55,6 +58,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +81,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_327661 = 327661; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_t *vc = (const vc_t *) hashes->esalts_buf; @@ -236,7 +228,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; @@ -322,7 +314,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index eda71240c..42f09c216 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -22,10 +22,13 @@ static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1024 bit + boot-mode"; static const u64 KERN_TYPE = 13712; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE - | OPTS_TYPE_KEYBOARD_MAPPING; + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "a3c0fa44ec59bf7a3eed64bf70b8a60623664503eeb972eb51fa25ee921d813f8e45d3e1ab1c0088a62482bb78c6e07308d2308d3d66831505b0cb02fe214fbac8a51cf9be2ada3c46045afa7df810f2e7b57792150de63b111a9aa78d70e25d832b3d6901aa455b32da240ff68380d66da27f4f7ccc5fadc6b3ff68e27b6d5c48e6512865e3b9fbe2a64a55454cfc333d7850603ecf8e1cf19abaaf8c1581a6fa14c5091ebe70e6338081d72d6a95b542764f3865946edc8e626e166cc2e0f6260032f8decdd98f9a82aa2b065a41e9b42ce8c33d3f935706431d19888bd5b2bd4d34d9bceb8596b15994f247169ee7f8cd34b6955362b60f37a4167c7b63bab8af65e7c592e9ba4535c255b4b3d93b302aa017ea335af20f9d9696f1eb37770ca87b0245d29887cc4611a3a43d11170219c509814eb1fc122a189c08394f22309dd48a996cbfc70cf67f76b6b19e46407a12ef001b2c360501dbd63d1c9f85132204709204992078318920b32aac917bb98d8eeefb60abef47571404d069a6df7881f8e7815c18789f23561d7d33f47e1aa97fb4a60bac0332b0e742a9b0498e5641401567615fd6dbd0fcfff07aebce0d543f2c498486f15f38dcf1dd55d7144d3fc51bf1f491798b183a84f3f49a72944c8054cdab915e19dc376ae3fa681d4afcd7b13f425e96340a696a4f11929b2e769ba207c5bf2c2976a3834c499d"; @@ -55,6 +58,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +81,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_327661 = 327661; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_t *vc = (const vc_t *) hashes->esalts_buf; @@ -236,7 +228,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; @@ -322,7 +314,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index fb3b75f0f..0c3e07a8b 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -22,10 +22,13 @@ static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt RIPEMD160 + XTS 1536 bit + boot-mode"; static const u64 KERN_TYPE = 13713; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE - | OPTS_TYPE_KEYBOARD_MAPPING; + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "1a8c0135fa94567aa866740cb27c5b9763c95be3ac0b7b5c744a36e48c08ae38d6d06ae5db926c64d05295cef134fb4d8eaa96a7b5673a1439f55c8ab829390ea945babc464e63f3aa33dcfed72c1bcf4051af13da96a2601a060d8c8be0343a7a4f0394b2bdd419b019bd10c3d39f0b6d9afd833816ee9ee5a8afada52db174a85ee029c46b706f8f96e937bb71569b65c2339a3ac8d831733888717fe08029013931ebed1fe932ceb16e52a5d54204e181057584d06991b8e9b16ba557d38f00e7c2be5ea864473e5e35d00a58b7ef8888c78d52ac1933011ca6c447bd16751024186657d1e314540e2c847115b70a51a23e61426ae09e646d715f807eed85e5c14ab2130da0ba86ddc40d3cdce035b454fceb969094d8d1b66e69f34e24d642dc244a81d163c395837d4cd9e2d581f4bb470ad4e5a2037068947f14676796f4adf208621c3db4629b3fec9a24edebfc37f97ea657295a2efbdd18fc44a0cc04f429d4da374db3ba2f3fc7dece70b64ac2c2a94ce5334b20b4251534f9ff3f60b1b252019d2617379bba68a4bc621cbd070881301beb0300bee243d113347d2f0a52fa79fb9fb349eba0056678618c006287e9730a0af32daa17841d88b99e25a9afcedd292a0592565f0ba533f1022ed4d6e51e64b98bab390fee3646133a0e02a5724bb14203fd50006e4be86544b62a9cb64188fbbf4ccd90a32022aa7c"; @@ -55,6 +58,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -77,18 +81,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_327661 = 327661; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc_t *vc = (const vc_t *) hashes->esalts_buf; @@ -236,7 +228,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; @@ -322,7 +314,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index dae3c2d94..df3dab805 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 512 bit"; static const u64 KERN_TYPE = 13751; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -81,9 +84,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; @@ -235,7 +245,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index 9f847766b..c2675a0e1 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1024 bit"; static const u64 KERN_TYPE = 13752; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -81,9 +84,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; @@ -235,7 +245,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index 8113f044c..df061adce 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -22,9 +22,11 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1536 bit"; static const u64 KERN_TYPE = 13753; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -55,6 +57,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -81,9 +84,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; @@ -235,7 +245,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index 5fc1a1376..d121c9928 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -22,10 +22,13 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 512 bit + boot-mode"; static const u64 KERN_TYPE = 13751; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE - | OPTS_TYPE_KEYBOARD_MAPPING; + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "c8a5f07efc320ecd797ac2c5b911b0f7ee688f859890dd3fa39b4808eb3113219e2bf1517f46a20feba286a3f3e997c80361132262bc0dacb6e9f7088bec9f5689a0b989ad9d4cc847170422ecd3384c9ee5ccf813fa8fe8ba4d2e6a993c99032337032b83471e9e0aa2531d85481c6d66f3a0d24688e1a17b5e81b3f68736ed05279ac05bcb83bea0c813d807e8c5547f11774c93a0e9de280c1ac5b5f170c0a4b5234f7d0d35a8ec7ec69454607cd35be24428a7be1799beed0ccd6a2af49b920446ebb0cb0bebda4a86c386fcffbb61cb93894ad74819a288c6e5b2e12111011e9f149d165b91f79897f71a96bc17c2b7a5e184147a90e9289d143b597ea98797c560e91b454461d03182f1a6c0bfd2b332829f30f0f18c8253d3194aac7996d4c401a3c1de7b266962a7dd8bc0b071a357121f00bafda835584a119f8fa23306545c413856ad3b2784b8de8ce9377f180baeb0f41590eb603110ff0a82f67349711d6f1b5d707f9c655318af88530962b9127fcf3c73b4d26319a9760cd795cd5ecba203dade9e1c79af14a9e06b9b56ce0af024e6ac582bd3ced1051fb865b55b4b6eaa65789a0c31c04cc4f2fc7b458fda188907f16810f4ce6e12a264cdcb264f1c26533758b92f585a3bbc2cac84731d74e9603d1c43b321ca36b01e5724e0e5558bcba56b57c8d59ded93c12d2664350cf6a048bcfc5d62aa85c590"; @@ -55,6 +58,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -81,9 +85,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; @@ -236,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index b0da01aa7..a772f9180 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -22,10 +22,13 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1024 bit + boot-mode"; static const u64 KERN_TYPE = 13752; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE - | OPTS_TYPE_KEYBOARD_MAPPING; + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "6bb6eef1af55eb2b2849e1fc9c90c08f705010efa6443581111216b3e145201374bb8e626e4d94a4ce7ecabb11aa57610063fceed38ca9873b0e1194bd12121d2f6b8a71994c5982049c4517ca7178a55b68cee773e06532b46d68810ede1b18783d7bca98bebf1778d14ecc18e0791190402c6a82bf3ec93e715e65997812363cc6e6bcad4f751fce16f37bbc1d6ac1d0a24c5685e85501a7c46d1cd5b04c55c605357906e5957b99230e2e9834a206e6ff48270ddf3c08c39e5c8390b2a7b7e6064719dbac29ef7513ea78c0edf420eb7ac6db684e890c5fcacfb230996f335f48f4472eaa33f3abe59943a8e3bc27ff4c24fd42015fdacd5e2eaf448049b4aa5ef1c038ca853871fc7f2573aace0874cdd1f3e01140803c1ad036b801cc1a54d619064b9b31e70e7e2601fd7b40f67814320c56721e86ddb3c62ec8cb9680ca7d2504b9decf360e32497ace8171dd9602f01db3be1541f659643e1bdc5139815acdf4debf0186707569c9b57c0fd0031ce03a5091d7937bca8f37015fa35af5f44968176164c0b9194f895a2346dacc51f5e3e7be5682ea7860c4b4302a0f22edecc7ccaebb1c824c5ca4ed4c5e674e742a1d55a7d3e732e40f0107ffad1e3876ec909fac58f1ee21ac99de2c8c29272b1df9dd7f724ff497925898506c4f6e2ae81e285239e5260b119af959338340876b5b8fdd6fede67ae37d3c750265"; @@ -55,6 +58,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -81,9 +85,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; @@ -236,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index 09fb93505..885e9c1c6 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -22,10 +22,13 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt SHA256 + XTS 1536 bit + boot-mode"; static const u64 KERN_TYPE = 13753; -static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE - | OPTS_TYPE_KEYBOARD_MAPPING; + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "f95b222552195378a228d932f7df38ca459b6d812899be43944ba2e9bf47967ba35da17bf69cc3f424521983989a66fd3c7865af6dd8ac2aeb82e10c92cae66f62c89b7053d2ba18ee5adcebcf426cc7720f029f7ea5409b3b7182593afbee99f6a3828887d9da6438fafd766589c35c210de60b013d9f816f9a1c8e7e76159347611c3dba00f433aa419dcb9eaf59af6886fccd7d12ae09c2b3d7a8a6102c511e8a34b4c39df8b1938dd5fe037d7087cf2a33b5410df9a6d83d218819b32bc13999c2dd7e96eb740902699ffe5fbaa47270cf1a7e3488198495059e1520ad4ad8beec0c63827286c300555a30febfe29a359d7e364c0b52613d9cff9348152f6871b6210681ab8cfdf24b96c4793c546083197d6e5377a59d7fcab9aa679fddf550ac1ab04249d0d679e8a39ddcca26f9b8b21f7f8b71d64a0ad3d9e3ed9e2e41abd6a9b4ff4d4a7ab29c27882487909fb1118a91de8e2e2d0dea7501a63b7553fd4ff26a5f64964031c9aa3fabbc09e3f58b09ce42bbf3f05afe0f9ea18331c7ba1a887afe307fedc2be93568fe80def12e97d5e129c373814a560573ee6350f59b329352e28137aa31688c499ae1c20b25c91506c520cae56c969790204de1ba46773197fb6a72fd4742712375e89cb5ee41f3ec8b64f3322ba389c947e671b0414e981fe582898af8a5bab09e094f03cb4cab047e7547313a7d1ddba7b70"; @@ -55,6 +58,7 @@ typedef struct vc_tmp u32 pim_key[64]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc_tmp_t; @@ -81,9 +85,16 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); } return jit_build_options; @@ -236,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index f788981ef..21ab8fc58 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -23,9 +23,11 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 512 bit"; static const u64 KERN_TYPE = 13771; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_USES_BITS_64; + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -59,6 +61,7 @@ typedef struct vc64_sbog_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_sbog_tmp_t; @@ -81,18 +84,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc64_sbog_tmp_t *vc64_sbog_tmp = (const vc64_sbog_tmp_t *) tmps; @@ -239,7 +230,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -325,7 +316,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index e52ee2725..ce9a1edd8 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -23,9 +23,11 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 1024 bit"; static const u64 KERN_TYPE = 13772; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_USES_BITS_64; + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -59,6 +61,7 @@ typedef struct vc64_sbog_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_sbog_tmp_t; @@ -81,18 +84,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc64_sbog_tmp_t *vc64_sbog_tmp = (const vc64_sbog_tmp_t *) tmps; @@ -239,7 +230,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -325,7 +316,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index 20634ebe4..ed658c123 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -23,9 +23,11 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 1536 bit"; static const u64 KERN_TYPE = 13773; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_USES_BITS_64; + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; @@ -59,6 +61,7 @@ typedef struct vc64_sbog_tmp u64 pim_key[32]; int pim; // marker for cracked + int pim_check; // marker for _extended kernel } vc64_sbog_tmp_t; @@ -81,18 +84,6 @@ typedef struct vc static const int ROUNDS_VERACRYPT_500000 = 500000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { const vc64_sbog_tmp_t *vc64_sbog_tmp = (const vc64_sbog_tmp_t *) tmps; @@ -239,7 +230,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; @@ -325,7 +316,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_13800.c b/src/modules/module_13800.c index 5f75c5384..824072b74 100644 --- a/src/modules/module_13800.c +++ b/src/modules/module_13800.c @@ -51,6 +51,25 @@ typedef struct win8phone } win8phone_t; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (win8phone_t); @@ -202,7 +221,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_14000.c b/src/modules/module_14000.c index bb55b36ec..e2dabbed1 100644 --- a/src/modules/module_14000.c +++ b/src/modules/module_14000.c @@ -22,7 +22,7 @@ static const char *HASH_NAME = "DES (PT = $salt, key = $pass)"; static const u64 KERN_TYPE = 14000; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_BITSLICE + | OPTS_TYPE_TM_KERNEL | OPTS_TYPE_ST_HEX; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat1"; @@ -43,6 +43,37 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 kernel_threads_max = 64; // performance only optimization @@ -241,7 +272,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_14100.c b/src/modules/module_14100.c index 3d2e730c0..3449b6844 100644 --- a/src/modules/module_14100.c +++ b/src/modules/module_14100.c @@ -107,18 +107,6 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, return mask; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -245,7 +233,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_14400.c b/src/modules/module_14400.c index d08c521eb..d34342ece 100644 --- a/src/modules/module_14400.c +++ b/src/modules/module_14400.c @@ -56,20 +56,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 1) - { - return true; - } - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -220,6 +206,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_14600.c b/src/modules/module_14600.c index 74c962be4..46d30eb20 100644 --- a/src/modules/module_14600.c +++ b/src/modules/module_14600.c @@ -61,7 +61,7 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, #define LUKS_KEY_ENABLED 0x00AC71F3 #define LUKS_STRIPES 4000 // partition header starts with magic -#define LUKS_MAGIC {'L','U','K','S', 0xba, 0xbe}; +#define LUKS_MAGIC {'L','U','K','S', (char) 0xba, (char) 0xbe}; #define LUKS_MAGIC_L 6 /* Actually we need only 37, but we don't want struct autoaligning to kick in */ #define UUID_STRING_L 40 diff --git a/src/modules/module_15000.c b/src/modules/module_15000.c index ea57ea224..ca167be63 100644 --- a/src/modules/module_15000.c +++ b/src/modules/module_15000.c @@ -45,6 +45,25 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 salt_min = 64; @@ -59,28 +78,6 @@ u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return salt_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -188,14 +185,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE int out_len = 0; - u64_to_hex (tmp[0], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[1], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[2], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[3], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[4], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[5], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[6], out_buf + out_len); out_len += 16; - u64_to_hex (tmp[7], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[0], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[1], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[2], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[3], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[4], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[5], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[6], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[7], out_buf + out_len); out_len += 16; out_buf[out_len] = hashconfig->separator; diff --git a/src/modules/module_15200.c b/src/modules/module_15200.c index 2139e5cf7..440a270a7 100644 --- a/src/modules/module_15200.c +++ b/src/modules/module_15200.c @@ -93,13 +93,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[2] = '$'; token.len_min[2] = 1; - token.len_max[2] = 5; + token.len_max[2] = 6; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 64; - token.len_max[3] = 20000; + token.len_min[3] = 144; + token.len_max[3] = 999999; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -119,29 +119,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *data_pos = token.buf[3]; - salt->salt_buf[0] = hex_to_u32 ((const u8 *) &data_pos[ 0]); - salt->salt_buf[1] = hex_to_u32 ((const u8 *) &data_pos[ 8]); - salt->salt_buf[2] = hex_to_u32 ((const u8 *) &data_pos[16]); - salt->salt_buf[3] = hex_to_u32 ((const u8 *) &data_pos[24]); + // first 16 byte are IV - salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); - salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); - salt->salt_buf[2] = byte_swap_32 (salt->salt_buf[2]); - salt->salt_buf[3] = byte_swap_32 (salt->salt_buf[3]); + for (int i = 0, j = 0; i < 16; i += 1, j += 8) + { + salt->salt_buf[i] = hex_to_u32 (data_pos + j); - // this is actually the CT, which is also the hash later (if matched) + salt->salt_buf[i] = byte_swap_32 (salt->salt_buf[i]); + } - salt->salt_buf[4] = hex_to_u32 ((const u8 *) &data_pos[32]); - salt->salt_buf[5] = hex_to_u32 ((const u8 *) &data_pos[40]); - salt->salt_buf[6] = hex_to_u32 ((const u8 *) &data_pos[48]); - salt->salt_buf[7] = hex_to_u32 ((const u8 *) &data_pos[56]); - - salt->salt_buf[4] = byte_swap_32 (salt->salt_buf[4]); - salt->salt_buf[5] = byte_swap_32 (salt->salt_buf[5]); - salt->salt_buf[6] = byte_swap_32 (salt->salt_buf[6]); - salt->salt_buf[7] = byte_swap_32 (salt->salt_buf[7]); - - salt->salt_len = 32; // note we need to fix this to 16 in kernel + salt->salt_len = 64; // hash diff --git a/src/modules/module_15300.c b/src/modules/module_15300.c index da8ae9c42..3fd578bed 100644 --- a/src/modules/module_15300.c +++ b/src/modules/module_15300.c @@ -96,26 +96,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - // trap 6 - if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) - { - return true; - } - } - - // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -459,6 +439,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_15400.c b/src/modules/module_15400.c index 0660d13b6..505530ff6 100644 --- a/src/modules/module_15400.c +++ b/src/modules/module_15400.c @@ -24,8 +24,8 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_RAW_HASH; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; -static const char *ST_PASS = "hashcat"; -static const char *ST_HASH = "$chacha20$*0400000000000003*35*0200000000000001*3961626364656667*8a152c57a7a856a8"; +static const char *ST_PASS = "hashcat_hashcat_hashcat_hashcat_"; +static const char *ST_HASH = "$chacha20$*0400000000000003*16*0200000000000001*5152535455565758*6b05fe554b0bc3b3"; u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } @@ -55,7 +55,7 @@ static const char *SIGNATURE_CHACHA20 = "$chacha20$"; const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const char *mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxxx"; + const char *mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxx"; return mask; } diff --git a/src/modules/module_15500.c b/src/modules/module_15500.c index 3c76749ec..6e714bce3 100644 --- a/src/modules/module_15500.c +++ b/src/modules/module_15500.c @@ -121,7 +121,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_min[4] = 2; token.len_max[4] = 2; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; token.len_min[5] = 28; diff --git a/src/modules/module_15600.c b/src/modules/module_15600.c index 34c185fbf..8f5d65224 100644 --- a/src/modules/module_15600.c +++ b/src/modules/module_15600.c @@ -62,6 +62,31 @@ typedef struct ethereum_pbkdf2 static const char *SIGNATURE_ETHEREUM_PBKDF2 = "$ethereum$p"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (ethereum_pbkdf2_t); @@ -86,28 +111,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_15700.c b/src/modules/module_15700.c index 2b814cc05..ac04271df 100644 --- a/src/modules/module_15700.c +++ b/src/modules/module_15700.c @@ -247,6 +247,15 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // Invalid extra buffer size. + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + // amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { @@ -519,6 +528,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_15900.c b/src/modules/module_15900.c index f53679d02..984e66c85 100644 --- a/src/modules/module_15900.c +++ b/src/modules/module_15900.c @@ -97,26 +97,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - // trap 6 - if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) - { - return true; - } - } - - // amdgpu-pro-18.50-708488-ubuntu-18.04: self-test failed - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - return true; - } - - return false; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -458,6 +438,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_16000.c b/src/modules/module_16000.c index 9f763f309..793157c3b 100644 --- a/src/modules/module_16000.c +++ b/src/modules/module_16000.c @@ -41,6 +41,17 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // amdgpu-pro-19.30-934563-ubuntu-18.04: self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + return true; + } + + return false; +} + u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u32 pw_max = 8; // Underlaying DES max @@ -181,6 +192,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_16200.c b/src/modules/module_16200.c index 7a3f9aae0..82645d06d 100644 --- a/src/modules/module_16200.c +++ b/src/modules/module_16200.c @@ -62,6 +62,31 @@ typedef struct apple_secure_notes_tmp static const char *SIGNATURE_APPLE_SECURE_NOTES = "$ASN$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (apple_secure_notes_t); @@ -76,28 +101,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_16300.c b/src/modules/module_16300.c index ad6e9b970..03b47be5e 100644 --- a/src/modules/module_16300.c +++ b/src/modules/module_16300.c @@ -63,6 +63,31 @@ typedef struct pbkdf2_sha256_tmp static const char *SIGNATURE_ETHEREUM_PRESALE = "$ethereum$w"; static const int ROUNDS_ETHEREUM_PRESALE = 2000; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (ethereum_presale_t); @@ -77,28 +102,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_16600.c b/src/modules/module_16600.c index 633901cca..2ad9fe201 100644 --- a/src/modules/module_16600.c +++ b/src/modules/module_16600.c @@ -20,6 +20,7 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER; static const char *HASH_NAME = "Electrum Wallet (Salt-Type 1-3)"; static const u64 KERN_TYPE = 16600; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_REGISTER_LIMIT | OPTI_TYPE_PRECOMPUTE_INIT; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE | OPTS_TYPE_PT_ADD80 diff --git a/src/modules/module_16700.c b/src/modules/module_16700.c index db3f2ee43..39a348c1e 100644 --- a/src/modules/module_16700.c +++ b/src/modules/module_16700.c @@ -76,28 +76,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -284,7 +262,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_16800.c b/src/modules/module_16800.c index d77ddd8ed..b236b0cea 100644 --- a/src/modules/module_16800.c +++ b/src/modules/module_16800.c @@ -132,7 +132,7 @@ int module_hash_decode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY // essid - char *sep_pos = strrchr (line_buf, ':'); + char *sep_pos = strrchr (line_buf, '*'); if (sep_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); @@ -163,7 +163,7 @@ int module_hash_encode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY tmp_buf[tmp_len] = 0; - const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", + const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x*%s", wpa_pbkdf2_tmp->out[0], wpa_pbkdf2_tmp->out[1], wpa_pbkdf2_tmp->out[2], diff --git a/src/modules/module_16801.c b/src/modules/module_16801.c index f34c449d0..2e8ef9987 100644 --- a/src/modules/module_16801.c +++ b/src/modules/module_16801.c @@ -129,7 +129,7 @@ int module_hash_decode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY // essid - char *sep_pos = strrchr (line_buf, ':'); + char *sep_pos = strrchr (line_buf, '*'); if (sep_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); @@ -160,7 +160,7 @@ int module_hash_encode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY tmp_buf[tmp_len] = 0; - const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", + const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x*%s", wpa_pmk_tmp->out[0], wpa_pmk_tmp->out[1], wpa_pmk_tmp->out[2], diff --git a/src/modules/module_16900.c b/src/modules/module_16900.c index 1b520901d..301f2032f 100644 --- a/src/modules/module_16900.c +++ b/src/modules/module_16900.c @@ -63,6 +63,31 @@ typedef struct ansible_vault static const char *SIGNATURE_ANSIBLE_VAULT = "$ansible$"; static const int ROUNDS_ANSIBLE_VAULT = 10000; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (ansible_vault_t); @@ -87,28 +112,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_17200.c b/src/modules/module_17200.c index a94a30ec7..015c30865 100644 --- a/src/modules/module_17200.c +++ b/src/modules/module_17200.c @@ -163,6 +163,17 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // hangs somewhere in zlib inflate + if (device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pkzip_t); @@ -419,6 +430,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_17210.c b/src/modules/module_17210.c index c1f405f2e..834de1ccd 100644 --- a/src/modules/module_17210.c +++ b/src/modules/module_17210.c @@ -102,7 +102,7 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_ARCHIVE; static const char *HASH_NAME = "PKZIP (Uncompressed)"; static const u64 KERN_TYPE = 17210; static const u32 OPTI_TYPE = 0; -static const u64 OPTS_TYPE = OPTS_TYPE_PT_NEVERCRACK; // nevercrack is required because it's quite likely that a collision is found which will not necessarily work as password for the archive +static const u64 OPTS_TYPE = 0; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "$pkzip2$1*1*2*0*1d1*1c5*eda7a8de*0*28*0*1d1*eda7*5096*1dea673da43d9fc7e2be1a1f4f664269fceb6cb88723a97408ae1fe07f774d31d1442ea8485081e63f919851ca0b7588d5e3442317fff19fe547a4ef97492ed75417c427eea3c4e146e16c100a2f8b6abd7e5988dc967e5a0e51f641401605d673630ea52ebb04da4b388489901656532c9aa474ca090dbac7cf8a21428d57b42a71da5f3d83fed927361e5d385ca8e480a6d42dea5b4bf497d3a24e79fc7be37c8d1721238cbe9e1ea3ae1eb91fc02aabdf33070d718d5105b70b3d7f3d2c28b3edd822e89a5abc0c8fee117c7fbfbfd4b4c8e130977b75cb0b1da080bfe1c0859e6483c42f459c8069d45a76220e046e6c2a2417392fd87e4aa4a2559eaab3baf78a77a1b94d8c8af16a977b4bb45e3da211838ad044f209428dba82666bf3d54d4eed82c64a9b3444a44746b9e398d0516a2596d84243b4a1d7e87d9843f38e45b6be67fd980107f3ad7b8453d87300e6c51ac9f5e3f6c3b702654440c543b1d808b62f7a313a83b31a6faaeedc2620de7057cd0df80f70346fe2d4dccc318f0b5ed128bcf0643e63d754bb05f53afb2b0fa90b34b538b2ad3648209dff587df4fa18698e4fa6d858ad44aa55d2bba3b08dfdedd3e28b8b7caf394d5d9d95e452c2ab1c836b9d74538c2f0d24b9b577*$/pkzip2$"; diff --git a/src/modules/module_17220.c b/src/modules/module_17220.c index 403640d94..8b17b39d9 100644 --- a/src/modules/module_17220.c +++ b/src/modules/module_17220.c @@ -163,6 +163,17 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // hangs somewhere in zlib inflate + if (device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pkzip_t); @@ -422,6 +433,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_17225.c b/src/modules/module_17225.c index 66907159f..4fecbf47a 100644 --- a/src/modules/module_17225.c +++ b/src/modules/module_17225.c @@ -163,6 +163,17 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // hangs somewhere in zlib inflate + if (device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (pkzip_t); @@ -422,6 +433,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_17300.c b/src/modules/module_17300.c index 06e2b7fe4..4b4869d7f 100644 --- a/src/modules/module_17300.c +++ b/src/modules/module_17300.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -159,7 +146,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_17400.c b/src/modules/module_17400.c index 31657b2bb..bb769e386 100644 --- a/src/modules/module_17400.c +++ b/src/modules/module_17400.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -150,7 +137,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_17500.c b/src/modules/module_17500.c index 25f8768e1..b177872e6 100644 --- a/src/modules/module_17500.c +++ b/src/modules/module_17500.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -156,7 +143,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_17600.c b/src/modules/module_17600.c index 7b4e506fa..478ccccf8 100644 --- a/src/modules/module_17600.c +++ b/src/modules/module_17600.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -162,7 +149,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_17700.c b/src/modules/module_17700.c index f8cd6aa4b..8d4003e0a 100644 --- a/src/modules/module_17700.c +++ b/src/modules/module_17700.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -159,7 +146,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_17800.c b/src/modules/module_17800.c index 01322071f..704d37190 100644 --- a/src/modules/module_17800.c +++ b/src/modules/module_17800.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -150,7 +137,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_17900.c b/src/modules/module_17900.c index 2441bd555..d4947e418 100644 --- a/src/modules/module_17900.c +++ b/src/modules/module_17900.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -156,7 +143,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_18000.c b/src/modules/module_18000.c index f2860130d..ad03e89af 100644 --- a/src/modules/module_18000.c +++ b/src/modules/module_18000.c @@ -43,19 +43,6 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - // -Wpass-failed=transform-warning - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -162,7 +149,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_18200.c b/src/modules/module_18200.c index c6df66777..005a435c1 100644 --- a/src/modules/module_18200.c +++ b/src/modules/module_18200.c @@ -54,6 +54,25 @@ typedef struct krb5asrep static const char *SIGNATURE_KRB5ASREP = "$krb5asrep$23$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (krb5asrep_t); @@ -77,7 +96,16 @@ u32 module_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // amdgpu-pro-18.50-708488-ubuntu-18.04: CL_OUT_OF_RESOURCES + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + // amdgpu-pro-19.30-934563-ubuntu-18.04: CL_OUT_OF_RESOURCES if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) @@ -250,7 +278,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_18300.c b/src/modules/module_18300.c index 0ddd0cf91..aea70f144 100644 --- a/src/modules/module_18300.c +++ b/src/modules/module_18300.c @@ -62,6 +62,31 @@ typedef struct apple_secure_notes_tmp static const char *SIGNATURE_APFS = "$fvde$"; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (apple_secure_notes_tmp_t); @@ -76,28 +101,6 @@ u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED return esalt_size; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; diff --git a/src/modules/module_18800.c b/src/modules/module_18800.c index 9394bd875..81533c4d4 100644 --- a/src/modules/module_18800.c +++ b/src/modules/module_18800.c @@ -58,6 +58,37 @@ typedef struct bsp } bsp_t; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (bsp_tmp_t); @@ -226,7 +257,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_19100.c b/src/modules/module_19100.c index c8ef5add7..520858229 100644 --- a/src/modules/module_19100.c +++ b/src/modules/module_19100.c @@ -57,28 +57,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -247,7 +225,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_19200.c b/src/modules/module_19200.c index affe045ca..2464f396a 100644 --- a/src/modules/module_19200.c +++ b/src/modules/module_19200.c @@ -59,28 +59,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->is_cuda == true) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -249,7 +227,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_19500.c b/src/modules/module_19500.c index 9969ff202..042440d0a 100644 --- a/src/modules/module_19500.c +++ b/src/modules/module_19500.c @@ -52,6 +52,17 @@ typedef struct devise_hash } devise_hash_t; +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // amdgpu-pro-19.30-934563-ubuntu-18.04: self-test failure. + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (devise_hash_t); @@ -260,6 +271,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = MODULE_DEFAULT; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_20200.c b/src/modules/module_20200.c index 74d5e1379..514dd7511 100644 --- a/src/modules/module_20200.c +++ b/src/modules/module_20200.c @@ -84,14 +84,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -270,7 +262,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_20300.c b/src/modules/module_20300.c index d8e024b88..57dca6697 100644 --- a/src/modules/module_20300.c +++ b/src/modules/module_20300.c @@ -83,14 +83,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -269,7 +261,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_20400.c b/src/modules/module_20400.c index 4b1dd0ac8..b7f6a8200 100644 --- a/src/modules/module_20400.c +++ b/src/modules/module_20400.c @@ -83,14 +83,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; @@ -262,7 +254,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_20600.c b/src/modules/module_20600.c index 0a9bc07b9..8189cb6fb 100644 --- a/src/modules/module_20600.c +++ b/src/modules/module_20600.c @@ -49,6 +49,38 @@ typedef struct omt_sha256_tmp } omt_sha256_tmp_t; +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // Intel CPU + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (omt_sha256_tmp_t); @@ -184,7 +216,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_20710.c b/src/modules/module_20710.c index 6d867729b..a401ce919 100644 --- a/src/modules/module_20710.c +++ b/src/modules/module_20710.c @@ -28,7 +28,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_ADDBITS15; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "bfede293ecf6539211a7305ea218b9f3f608953130405cda9eaba6fb6250f824:7218532375810603"; @@ -59,7 +59,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_min[0] = 64; token.len_max[0] = 64; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; token.len_max[1] = SALT_MAX; diff --git a/src/modules/module_20711.c b/src/modules/module_20711.c index 2cf90e042..51308e59d 100644 --- a/src/modules/module_20711.c +++ b/src/modules/module_20711.c @@ -82,7 +82,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_min[1] = 16; token.len_max[1] = 16; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; token.len_min[2] = 64; diff --git a/src/modules/module_21000.c b/src/modules/module_21000.c index 41e32c006..1b0b1b71b 100644 --- a/src/modules/module_21000.c +++ b/src/modules/module_21000.c @@ -48,6 +48,25 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -142,14 +161,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u8 *out_buf = (u8 *) line_buf; - u64_to_hex (tmp[0], out_buf + 0); - u64_to_hex (tmp[1], out_buf + 16); - u64_to_hex (tmp[2], out_buf + 32); - u64_to_hex (tmp[3], out_buf + 48); - u64_to_hex (tmp[4], out_buf + 64); - u64_to_hex (tmp[5], out_buf + 80); - u64_to_hex (tmp[6], out_buf + 96); - u64_to_hex (tmp[7], out_buf + 112); + u64_to_hex (tmp[0], out_buf + 0); + u64_to_hex (tmp[1], out_buf + 16); + u64_to_hex (tmp[2], out_buf + 32); + u64_to_hex (tmp[3], out_buf + 48); + u64_to_hex (tmp[4], out_buf + 64); + u64_to_hex (tmp[5], out_buf + 80); + u64_to_hex (tmp[6], out_buf + 96); + u64_to_hex (tmp[7], out_buf + 112); const int out_len = 128; @@ -198,7 +217,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_21200.c b/src/modules/module_21200.c index 6c9ea1daf..00d1f58cb 100644 --- a/src/modules/module_21200.c +++ b/src/modules/module_21200.c @@ -27,7 +27,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_ADDBITS14; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "e69b7a7fe1bf2ad9ef116f79551ee919:baa038987e582431a6d"; @@ -60,8 +60,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 19; - token.len_max[1] = 19; + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) diff --git a/src/modules/module_21300.c b/src/modules/module_21300.c index 6c4522dc2..c687160a6 100644 --- a/src/modules/module_21300.c +++ b/src/modules/module_21300.c @@ -27,7 +27,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_PT_ADD80 | OPTS_TYPE_PT_ADDBITS14; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "799dc7d9aa4d3f404cc21a4936dbdcde:68617368636174"; //6d455b6e8945bebfd0a5878eaa201523:hashcat"; //c8f4f1202e7aaebb14e49903ca973d39:943038186"; diff --git a/src/modules/module_21400.c b/src/modules/module_21400.c index dc92ef5c8..daaa73b0a 100644 --- a/src/modules/module_21400.c +++ b/src/modules/module_21400.c @@ -17,7 +17,7 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 6; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; -static const char *HASH_NAME = "sha256(sha256_bin(pass))"; +static const char *HASH_NAME = "sha256(sha256_bin($pass))"; static const u64 KERN_TYPE = 21400; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT diff --git a/src/modules/module_21500.c b/src/modules/module_21500.c index 7a774dcd8..c2298bcbc 100644 --- a/src/modules/module_21500.c +++ b/src/modules/module_21500.c @@ -86,18 +86,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con return pw_max; } -char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - char *jit_build_options = NULL; - - if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) - { - hc_asprintf (&jit_build_options, "-D NO_UNROLL"); - } - - return jit_build_options; -} - int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u64 *digest = (u64 *) digest_buf; @@ -262,7 +250,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook23 = MODULE_DEFAULT; module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; - module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_build_options = MODULE_DEFAULT; module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; diff --git a/src/modules/module_21600.c b/src/modules/module_21600.c new file mode 100644 index 000000000..0596f6b51 --- /dev/null +++ b/src/modules/module_21600.c @@ -0,0 +1,227 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; +static const char *HASH_NAME = "Web2py pbkdf2-sha512"; +static const u64 KERN_TYPE = 21600; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "pbkdf2(1000,20,sha512)$744943$c5f8cdef76e3327c908d8d96d4abdb3d8caba14c"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const char *SIGNATURE_WEB2PY_START = "pbkdf2"; +static const char *SIGNATURE_WEB2PY_STOP = "20,sha512)"; + +typedef struct web2py_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[16]; + u64 out[16]; + +} web2py_sha512_tmp_t; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (web2py_sha512_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + token_t token; + + token.token_cnt = 5; + + token.signatures_cnt = 2; + token.signatures_buf[0] = SIGNATURE_WEB2PY_START; + token.signatures_buf[1] = SIGNATURE_WEB2PY_STOP; + + token.sep[0] = '('; + token.len_min[0] = 6; + token.len_max[0] = 6; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = ','; + token.len_min[1] = 1; + token.len_max[1] = 8; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '$'; + token.len_min[2] = 10; + token.len_max[2] = 10; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[3] = '$'; + token.len_min[3] = SALT_MIN; + token.len_max[3] = SALT_MAX; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; + + token.len_min[4] = 40; + token.len_max[4] = 40; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // salt + + const u8 *salt_pos = token.buf[3]; + const int salt_len = token.len[3]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + salt->salt_iter = hc_strtoul ((const char *) token.buf[1], NULL, 10) - 1; + + // hash + + hex_decode ((const u8 *) token.buf[4], 40, (u8 *) digest); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u64 *digest = (const u64 *) digest_buf; + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s(%d,%s$", SIGNATURE_WEB2PY_START, salt->salt_iter + 1, SIGNATURE_WEB2PY_STOP); + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + out_buf[out_len] = '$'; + + out_len += 1; + + out_len += hex_encode ((const u8 *) digest, 20, (u8 *) out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_21700.c b/src/modules/module_21700.c new file mode 100644 index 000000000..92ee6a3b0 --- /dev/null +++ b/src/modules/module_21700.c @@ -0,0 +1,334 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" +#include "emu_inc_ecc_secp256k1.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER; +static const char *HASH_NAME = "Electrum Wallet (Salt-Type 4)"; +static const u64 KERN_TYPE = 21700; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$electrum$4*03eae309d8bda5dcbddaae8145469193152763894b7260a6c4ba181b3ac2ed5653*8c594086a64dc87a9c1f8a69f646e31e8d3182c3c722def4427aa20684776ac26092c6f60bf2762e27adfa93fe1e952dcb8d6362224b9a371953aa3a2edb596ce5eb4c0879c4353f2cc515ec6c9e7a6defa26c5df346d18a62e9d40fcc606bc8c34322bf2212f77770a683788db0baf4cb43595c2a27fe5ff8bdcb1fd915bcd725149d8ee8f14c71635fecb04da5dde97584f4581ceb7d907dceed80ae5daa8352dda20b25fd6001e99a96b7cf839a36cd3f5656304e6998c18e03dd2fb720cb41386c52910c9cb83272c3d50f3a6ff362ab8389b0c21c75133c971df0a75b331796371b060b32fe1673f4a041d7ae08bbdeffb45d706eaf65f99573c07972701c97766b4d7a8a03bba0f885eb3845dfd9152286e1de1f93e25ce04c54712509166dda80a84c2d34652f68e6c01e662f8b1cc7c15103a4502c29332a4fdbdda470c875809e15aab3f2fcb061ee96992ad7e8ab9da88203e35f47d6e88b07a13b0e70ef76de3be20dc06facbddc1e47206b16b44573f57396265116b4d243e77d1c98bc2b28aa3ec0f8d959764a54ecdd03d8360ff2823577fe2183e618aac15b30c1d20986841e3d83c0bfabcedb7c27ddc436eb7113db927e0beae7522b04566631a090b214660152a4f4a90e19356e66ee7309a0671b2e7bfde82667538d193fc7e397442052c6c611b6bf0a04f629a1dc7fa9eb44bfad1bfc6a0bce9f0564c3b483737e447720b7fd038c9a961a25e9594b76bf8c8071c83fcacd689c7469f698ee4aee4d4f626a73e21ce4967e705e4d83e1145b4260330367d8341c84723a1b02567ffbab26aac3afd1079887b4391f05d09780fc65f8b4f68cd51391c06593919d7eafd0775f83045b8f5c2e59cef902ff500654ea29b7623c7594ab2cc0e05ffe3f10abc46c9c5dac824673c307dcbff5bc5f3774141ff99f6a34ec4dd8a58d154a1c72636a2422b8fafdef399dec350d2b91947448582d52291f2261d264d29399ae3c92dc61769a49224af9e7c98d74190f93eb49a44db7587c1a2afb5e1a4bec5cdeb8ad2aac9728d5ae95600c52e9f063c11cdb32b7c1d8435ce76fcf1fa562bd38f14bf6c303c70fb373d951b8a691ab793f12c0f3336d6191378bccaed32923bba81868148f029e3d5712a2fb9f610997549710716db37f7400690c8dfbed12ff0a683d8e4d0079b380e2fd856eeafb8c6eedfac8fb54dacd6bd8a96e9f8d23ea87252c1a7c2b53efc6e6aa1f0cc30fbaaf68ee7d46666afc15856669cd9baebf9397ff9f322cce5285e68a985f3b6aadce5e8f14e9f9dd16764bc4e9f62168aa265d8634ab706ed40b0809023f141c36717bd6ccef9ec6aa6bfd2d00bda9375c2fee9ebba49590a166*1b0997cf64bb2c2ff88cb87bcacd9729d404bd46db18117c20d94e67c946fedc"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct electrum +{ + secp256k1_t coords; + + u32 data_buf[4096]; + u32 data_len; + +} electrum_t; + +typedef struct electrum_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[8]; + u64 out[8]; + +} electrum_tmp_t; + +static const char *SIGNATURE_ELECTRUM = "$electrum$4*"; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (electrum_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (electrum_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = PW_MAX; + + return pw_max; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + electrum_t *esalt = (electrum_t *) esalt_buf; + + token_t token; + + token.token_cnt = 4; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_ELECTRUM; + + token.len[0] = 12; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 66; + token.len_max[1] = 66; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[2] = '*'; + token.len_min[2] = 128; + token.len_max[2] = 32768; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len_min[3] = 64; + token.len_max[3] = 64; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *ephemeral_pos = token.buf[1]; + const u8 *data_buf_pos = token.buf[2]; + const u8 *mac_pos = token.buf[3]; + + const u32 data_len = token.len[2] / 2; + + /** + * store data + */ + + // data_len: + + esalt->data_len = data_len; + + // ephemeral pubkey: + + u32 ephemeral_pubkey[9] = { 0 }; + + u8 *ephemeral_pubkey_ptr = (u8 *) ephemeral_pubkey; + + for (u32 i = 0, j = 0; j < 66; i += 1, j += 2) + { + ephemeral_pubkey_ptr[i] = hex_to_u8 (ephemeral_pos + j); + } + + secp256k1_t *coords = &esalt->coords; + + u32 parse_success = parse_public (coords, ephemeral_pubkey); + + if (parse_success != 0) return (PARSER_SALT_VALUE); + + // data buf: + + u8* data_buf_ptr = (u8 *) esalt->data_buf; + + memset (data_buf_ptr, 0, sizeof (esalt->data_buf)); + + for (u32 i = 0, j = 0; j < data_len * 2; i += 1, j += 2) + { + data_buf_ptr[i] = hex_to_u8 (data_buf_pos + j); + } + + // digest / mac: + + for (u32 i = 0, j = 0; j < 64; i += 1, j += 8) + { + digest[i] = hex_to_u32 (mac_pos + j); + + digest[i] = byte_swap_32 (digest[i]); + } + + // fake salt + + salt->salt_buf[0] = esalt->data_buf[0]; + salt->salt_buf[1] = esalt->data_buf[1]; + salt->salt_buf[2] = esalt->data_buf[2]; + salt->salt_buf[3] = esalt->data_buf[3]; + + salt->salt_len = 16; + + salt->salt_iter = 1024 - 1; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + u32 *digest = (u32 *) digest_buf; + + electrum_t *esalt = (electrum_t *) esalt_buf; + + // ephemeral pubkey: + + char ephemeral[66 + 1]; + + memset (ephemeral, 0, sizeof (ephemeral)); + + u8 type = 0x02 | (esalt->coords.xy[8] & 1); // odd or even y coordinate + + snprintf (ephemeral, 66 + 1, "%02x", type); + + for (int i = 31, j = 2; i >= 0; i -= 1, j += 2) + { + const u8 *ptr = (const u8 *) esalt->coords.xy; + + snprintf (ephemeral + j, 66 + 1 - j, "%02x", ptr[i]); + } + + // data buf: + + char data_buf[32768 + 1]; + + memset (data_buf, 0, sizeof (data_buf)); + + for (u32 i = 0, j = 0; i < esalt->data_len; i += 1, j += 2) + { + const u8 *ptr = (const u8 *) esalt->data_buf; + + snprintf (data_buf + j, 32768 + 1 - j, "%02x", ptr[i]); + } + + // digest / mac: + + char mac[64 + 1]; + + memset (mac, 0, sizeof (mac)); + + for (u32 i = 0, j = 0; i < 8; i += 1, j += 8) + { + snprintf (mac + j, 64 + 1 - j, "%08x", digest[i]); + } + + int bytes_written = snprintf (line_buf, line_size, "%s%s*%s*%s", + SIGNATURE_ELECTRUM, + ephemeral, + data_buf, + mac); + + return bytes_written; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_21800.c b/src/modules/module_21800.c new file mode 100644 index 000000000..e148a3f3d --- /dev/null +++ b/src/modules/module_21800.c @@ -0,0 +1,328 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" +#include "emu_inc_ecc_secp256k1.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER; +static const char *HASH_NAME = "Electrum Wallet (Salt-Type 5)"; +static const u64 KERN_TYPE = 21800; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$electrum$5*02170fee7c35f1ef3b229edc90fbd0793b688a0d6f41137a97aab2343d315cce16*94cf72d8f5d774932b414a3344984859e43721268d2eb35fa531de5a2fc7024b463c730a54f4f46229dd9fede5034b19ac415c2916e9c16b02094f845795df0c397ff76d597886b1f9e014ad1a8f64a3f617d9900aa645b3ba86f16ce542251fc22c41d93fa6bc118be96d9582917e19d2a299743331804cfc7ce2c035367b4cbcfb70adfb1e10a0f2795769f2165d8fd13daa8b45eeac495b5b63e91a87f63b42e483f84a881e49adecacf6519cb564694b42dd9fe80fcbc6cdb63cf5ae33f35255266f5c2524dd93d3cc15eba0f2ccdc3c109cc2d7e8f711b8b440f168caf8b005e8bcdfe694148e94a04d2a738f09349a96600bd8e8edae793b26ebae231022f24e96cb158db141ac40400a9e9ef099e673cfe017281537c57f82fb45c62bdb64462235a6eefb594961d5eb2c46537958e4d04250804c6e9f343ab7a0db07af6b8a9d1a6c5cfcd311b8fb8383ac9ed9d98d427d526c2f517fc97473bd87cb59899bd0e8fb8c57fa0f7e0d53daa57c972cf92764af4b1725a5fb8f504b663ec519731929b3caaa793d8ee74293eee27d0e208a60e26290bc546e6fa9ed865076e13febfea249729218c1b5752e912055fbf993fbac5df2cca2b37c5e0f9c30789858ceeb3c482a8db123966775aeed2eee2fc34efb160d164929f51589bff748ca773f38978bff3508d5a7591fb2d2795df983504a788071f469d78c88fd7899cabbc5804f458653d0206b82771a59522e1fa794d7de1536c51a437f5d6df5efd6654678e5794ca429b5752e1103340ed80786f1e9da7f5b39af628b2212e4d88cd36b8a7136d50a6b6e275ab406ba7c57cc70d77d01c4c16e9363901164fa92dc9e9b99219d5376f24862e775968605001e71b000e2c7123b4b43f3ca40db17efd729388782e46e64d43ccb947db4eb1473ff1a3836b74fe312cd1a33b73b8b8d80c087088932277773c329f2f66a01d6b3fc1e651c56959ebbed7b14a21b977f3acdedf1a0d98d519a74b50c39b3052d840106da4145345d86ec0461cddafacc2a4f0dd646457ad05bf04dcbcc80516a5c5ed14d2d639a70e77b686f19cbfb63f546d81ae19cc8ba35cce3f3b5b9602df25b678e14411fecec87b8347f5047513df415c6b1a3d39871a6bcb0f67d9cf8311596deae45fd1d84a04fd58f1fd55c5156b7309af09094c99a53674809cb87a45f95a2d69f9997a38085519cb4e056f9efd56672a2c1fe927d5ea8eec25b8aff6e56f9a2310f1a481daf407b8adf16201da267c59973920fd21bb087b88123ef98709839d6a3ee34efb8ccd5c15ed0e46cff3172682769531164b66c8689c35a26299dd26d09233d1f64f9667474141cf9c6a6de7f2bc52c3bb44cfe679ff4b912c06df406283836b3581773cb76d375304f46239da5996594a8d03b14c02f1b35a432dc44a96331242ae31174*33a7ee59d6d17ed1ee99dc0a71771227e6f3734b17ba36eb589bdced56244135"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct electrum +{ + secp256k1_t coords; + + u32 data_buf[256]; + +} electrum_t; + +typedef struct electrum_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[8]; + u64 out[8]; + +} electrum_tmp_t; + +static const char *SIGNATURE_ELECTRUM = "$electrum$5*"; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (electrum_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (electrum_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = PW_MAX; + + return pw_max; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + + // hangs somewhere in zlib inflate + if (device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) + { + return true; + } + + return false; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + electrum_t *esalt = (electrum_t *) esalt_buf; + + token_t token; + + token.token_cnt = 4; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_ELECTRUM; + + token.len[0] = 12; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 66; + token.len_max[1] = 66; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[2] = '*'; + token.len_min[2] = 2048; + token.len_max[2] = 2048; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len_min[3] = 64; + token.len_max[3] = 64; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *ephemeral_pos = token.buf[1]; + const u8 *data_buf_pos = token.buf[2]; + const u8 *mac_pos = token.buf[3]; + + /** + * store data + */ + + // ephemeral pubkey: + + u32 ephemeral_pubkey[9] = { 0 }; + + u8 *ephemeral_pubkey_ptr = (u8 *) ephemeral_pubkey; + + for (u32 i = 0, j = 0; j < 66; i += 1, j += 2) + { + ephemeral_pubkey_ptr[i] = hex_to_u8 (ephemeral_pos + j); + } + + secp256k1_t *coords = &esalt->coords; + + u32 parse_success = parse_public (coords, ephemeral_pubkey); + + if (parse_success != 0) return (PARSER_SALT_VALUE); + + // data buf: + + u8* data_buf_ptr = (u8 *) esalt->data_buf; + + for (u32 i = 0, j = 0; j < 2048; i += 1, j += 2) + { + data_buf_ptr[i] = hex_to_u8 (data_buf_pos + j); + } + + // digest / mac: + + for (u32 i = 0, j = 0; j < 64; i += 1, j += 8) + { + digest[i] = hex_to_u32 (mac_pos + j); + + digest[i] = byte_swap_32 (digest[i]); + } + + // fake salt + + salt->salt_buf[0] = esalt->data_buf[0]; + salt->salt_buf[1] = esalt->data_buf[1]; + salt->salt_buf[2] = esalt->data_buf[2]; + salt->salt_buf[3] = esalt->data_buf[3]; + + salt->salt_len = 16; + + salt->salt_iter = 1024 - 1; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + u32 *digest = (u32 *) digest_buf; + + electrum_t *esalt = (electrum_t *) esalt_buf; + + // ephemeral pubkey: + + char ephemeral[66 + 1]; + + memset (ephemeral, 0, sizeof (ephemeral)); + + u8 type = 0x02 | (esalt->coords.xy[8] & 1); // odd or even y coordinate + + snprintf (ephemeral, 66 + 1, "%02x", type); + + for (int i = 31, j = 2; i >= 0; i -= 1, j += 2) + { + const u8 *ptr = (const u8 *) esalt->coords.xy; + + snprintf (ephemeral + j, 66 + 1 - j, "%02x", ptr[i]); + } + + // data buf: + + char data_buf[2048 + 1]; + + memset (data_buf, 0, sizeof (data_buf)); + + for (u32 i = 0, j = 0; i < 1024; i += 1, j += 2) + { + const u8 *ptr = (const u8 *) esalt->data_buf; + + snprintf (data_buf + j, 2048 + 1 - j, "%02x", ptr[i]); + } + + // mac: + + char mac[64 + 1]; + + memset (mac, 0, sizeof (mac)); + + for (u32 i = 0, j = 0; i < 8; i += 1, j += 8) + { + snprintf (mac + j, 64 + 1 - j, "%08x", digest[i]); + } + + int bytes_written = snprintf (line_buf, line_size, "%s%s*%s*%s", + SIGNATURE_ELECTRUM, + ephemeral, + data_buf, + mac); + + return bytes_written; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22000.c b/src/modules/module_22000.c new file mode 100644 index 000000000..b914157e4 --- /dev/null +++ b/src/modules/module_22000.c @@ -0,0 +1,1342 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +#define DGST_ELEM 4 + +#include "emu_general.h" +#include "emu_inc_cipher_aes.h" +#include "emu_inc_hash_md5.h" +#include "m22000-pure.cl" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; +static const char *HASH_NAME = "WPA-PBKDF2-PMKID+EAPOL"; +static const u64 KERN_TYPE = 22000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_AUX1 + | OPTS_TYPE_AUX2 + | OPTS_TYPE_AUX3 + | OPTS_TYPE_AUX4 + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_DEEP_COMP_KERNEL + | OPTS_TYPE_COPY_TMPS; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat!"; +static const char *ST_HASH = "WPA*01*4d4fe7aac3a2cecab195321ceb99a7d0*fc690c158264*f4747f87f9f4*686173686361742d6573736964***"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const u32 ROUNDS_WPA_PBKDF2 = 4096; + +// this is required to force mingw to accept the packed attribute +#pragma pack(push,1) + +struct auth_packet +{ + u8 version; + u8 type; + u16 length; + u8 key_descriptor; + u16 key_information; + u16 key_length; + u64 replay_counter; + u8 wpa_key_nonce[32]; + u8 wpa_key_iv[16]; + u8 wpa_key_rsc[8]; + u8 wpa_key_id[8]; + u8 wpa_key_mic[16]; + u16 wpa_key_data_length; + +} __attribute__((packed)); + +#pragma pack(pop) + +typedef struct auth_packet auth_packet_t; + +#define HCCAPX_VERSION 4 +#define HCCAPX_SIGNATURE 0x58504348 // HCPX + +// this is required to force mingw to accept the packed attribute +#pragma pack(push,1) + +struct hccapx +{ + u32 signature; + u32 version; + u8 message_pair; + u8 essid_len; + u8 essid[32]; + u8 keyver; + u8 keymic[16]; + u8 mac_ap[6]; + u8 nonce_ap[32]; + u8 mac_sta[6]; + u8 nonce_sta[32]; + u16 eapol_len; + u8 eapol[256]; + +} __attribute__((packed)); + +typedef struct hccapx hccapx_t; + +#pragma pack(pop) + +const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const char *mask = "?a?a?a?a?a?a?a?a"; + + return mask; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (wpa_pbkdf2_tmp_t); + + return tmp_size; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (wpa_t); + + return esalt_size; +} + +static bool is_hccapx (HCFILE *fp) +{ + hccapx_t hccapx; + + const size_t nread = hc_fread (&hccapx, sizeof (hccapx_t), 1, fp); + + if (nread == 1) + { + if (hccapx.signature == HCCAPX_SIGNATURE) + { + return true; + } + } + + return false; +} + +int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) +{ + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, hashconfig->st_hash, strlen (hashconfig->st_hash)); + + wpa_t *wpa = (wpa_t *) hash->esalt; + + wpa->detected_le = 1; + wpa->detected_be = 0; + + wpa->nonce_error_corrections = 3; + + return parser_status; +} + +int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, hashes_t *hashes) +{ + hash_t *hashes_buf = hashes->hashes_buf; + + int hashes_cnt = 0; + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1; + + const bool r = is_hccapx (&fp); + + hc_rewind (&fp); + + if (r == true) + { + char *in = (char *) hcmalloc (sizeof (hccapx_t)); + + while (!hc_feof (&fp)) + { + const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, &fp); + + if (nread == 0) break; + + memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t)); + + memset (hashes_buf[hashes_cnt].esalt, 0, sizeof (wpa_t)); + + wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt; + + wpa->message_pair_chgd = user_options->hccapx_message_pair_chgd; + wpa->message_pair = user_options->hccapx_message_pair; + + wpa->nonce_error_corrections_chgd = user_options->nonce_error_corrections_chgd; + wpa->nonce_error_corrections = user_options->nonce_error_corrections; + + hash_t *hash = &hashes_buf[hashes_cnt]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, in, sizeof (hccapx_t)); + + if (parser_status != PARSER_OK) continue; + + hashes_cnt++; + } + + hcfree (in); + } + else + { + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); + + while (!hc_feof (&fp)) + { + const size_t line_len = fgetl (&fp, line_buf, HCBUFSIZ_LARGE); + + if (line_len == 0) continue; + + memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t)); + + memset (hashes_buf[hashes_cnt].esalt, 0, sizeof (wpa_t)); + + wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt; + + wpa->message_pair_chgd = user_options->hccapx_message_pair_chgd; + wpa->message_pair = user_options->hccapx_message_pair; + + wpa->nonce_error_corrections_chgd = user_options->nonce_error_corrections_chgd; + wpa->nonce_error_corrections = user_options->nonce_error_corrections; + + hash_t *hash = &hashes_buf[hashes_cnt]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, line_buf, line_len); + + if (parser_status != PARSER_OK) continue; + + hashes_cnt++; + } + + hcfree (line_buf); + } + + hc_fclose (&fp); + + return hashes_cnt; +} + +int module_hash_binary_count (MAYBE_UNUSED const hashes_t *hashes) +{ + // this mode actually works on a plaintext file + // but to stay in a .hccapx backward compatibility mode we have to tell the module + // the file is in binary. + // we then have to iterated through the file ourself + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1; + + const bool r = is_hccapx (&fp); + + hc_rewind (&fp); + + int count = 0; + + if (r == true) + { + struct stat st; + + stat (hashes->hashfile, &st); + + count = st.st_size / sizeof (hccapx_t); + } + else + { + count = count_lines (&fp); + } + + hc_fclose (&fp); + + return count; +} + +bool module_hlfmt_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool hlfmt_disable = true; + + return hlfmt_disable; +} + +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_min = 8; + + return pw_min; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = 63; + + return pw_max; +} + +int module_hash_decode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len, MAYBE_UNUSED void *tmps) +{ + wpa_t *wpa = (wpa_t *) esalt_buf; + + wpa_pbkdf2_tmp_t *wpa_pbkdf2_tmp = (wpa_pbkdf2_tmp_t *) tmps; + + // here we have in line_hash_buf: PMK*essid:password + // but we don't care about the password + + // PMK + + wpa_pbkdf2_tmp->out[0] = hex_to_u32 ((const u8 *) line_buf + 0); + wpa_pbkdf2_tmp->out[1] = hex_to_u32 ((const u8 *) line_buf + 8); + wpa_pbkdf2_tmp->out[2] = hex_to_u32 ((const u8 *) line_buf + 16); + wpa_pbkdf2_tmp->out[3] = hex_to_u32 ((const u8 *) line_buf + 24); + wpa_pbkdf2_tmp->out[4] = hex_to_u32 ((const u8 *) line_buf + 32); + wpa_pbkdf2_tmp->out[5] = hex_to_u32 ((const u8 *) line_buf + 40); + wpa_pbkdf2_tmp->out[6] = hex_to_u32 ((const u8 *) line_buf + 48); + wpa_pbkdf2_tmp->out[7] = hex_to_u32 ((const u8 *) line_buf + 56); + + // essid + + char *sep_pos = strrchr (line_buf, '*'); + + if (sep_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); + + if ((line_buf + 64) != sep_pos) return (PARSER_HASH_LENGTH); + + char *essid_pos = sep_pos + 1; + + const int essid_len = strlen (essid_pos); + + if (essid_len & 1) return (PARSER_SALT_VALUE); + + if (essid_len > 64) return (PARSER_SALT_VALUE); + + wpa->essid_len = hex_decode ((const u8 *) essid_pos, essid_len, (u8 *) wpa->essid_buf); + + return PARSER_OK; +} + +int module_hash_encode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size, MAYBE_UNUSED const void *tmps) +{ + const wpa_t *wpa = (const wpa_t *) esalt_buf; + + const wpa_pbkdf2_tmp_t *wpa_pbkdf2_tmp = (const wpa_pbkdf2_tmp_t *) tmps; + + char tmp_buf[128]; + + const int tmp_len = hex_encode ((const u8 *) wpa->essid_buf, wpa->essid_len, (u8 *) tmp_buf); + + tmp_buf[tmp_len] = 0; + + const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x*%s", + wpa_pbkdf2_tmp->out[0], + wpa_pbkdf2_tmp->out[1], + wpa_pbkdf2_tmp->out[2], + wpa_pbkdf2_tmp->out[3], + wpa_pbkdf2_tmp->out[4], + wpa_pbkdf2_tmp->out[5], + wpa_pbkdf2_tmp->out[6], + wpa_pbkdf2_tmp->out[7], + tmp_buf); + + return line_len; +} + +int module_hash_binary_save (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos, char **buf) +{ + const salt_t *salts_buf = hashes->salts_buf; + const void *esalts_buf = hashes->esalts_buf; + + const salt_t *salt = &salts_buf[salt_pos]; + + const u32 digest_cur = salt->digests_offset + digest_pos; + + const wpa_t *wpas = (const wpa_t *) esalts_buf; + const wpa_t *wpa = &wpas[digest_cur]; + + char tmp_buf[128]; + + const int tmp_len = hex_encode ((const u8 *) wpa->essid_buf, wpa->essid_len, (u8 *) tmp_buf); + + tmp_buf[tmp_len] = 0; + + const u8 *mac_ap = (const u8 *) wpa->mac_ap; + const u8 *mac_sta = (const u8 *) wpa->mac_sta; + + if (wpa->type == 1) + { + const int len = hc_asprintf (buf, "WPA*01*%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s***" EOL, + byte_swap_32 (wpa->pmkid[0]), + byte_swap_32 (wpa->pmkid[1]), + byte_swap_32 (wpa->pmkid[2]), + byte_swap_32 (wpa->pmkid[3]), + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + tmp_buf); + + return len; + } + else if (wpa->type == 2) + { + u32 eapol_swapped[64 + 2]; + + for (int i = 0; i < 64; i++) + { + eapol_swapped[i] = wpa->eapol[i]; + + if (wpa->keyver == 2) + { + eapol_swapped[i] = byte_swap_32 (eapol_swapped[i]); + } + } + + eapol_swapped[64] = 0; + eapol_swapped[65] = 0; + + char tmp2_buf[1024]; + + const int tmp2_len = hex_encode ((const u8 *) eapol_swapped, wpa->eapol_len, (u8 *) tmp2_buf); + + tmp2_buf[tmp2_len] = 0; + + const int len = hc_asprintf (buf, "WPA*02*%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s*%08x%08x%08x%08x%08x%08x%08x%08x*%s*%02x" EOL, + wpa->keymic[0], + wpa->keymic[1], + wpa->keymic[2], + wpa->keymic[3], + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + tmp_buf, + byte_swap_32 (wpa->anonce[0]), + byte_swap_32 (wpa->anonce[1]), + byte_swap_32 (wpa->anonce[2]), + byte_swap_32 (wpa->anonce[3]), + byte_swap_32 (wpa->anonce[4]), + byte_swap_32 (wpa->anonce[5]), + byte_swap_32 (wpa->anonce[6]), + byte_swap_32 (wpa->anonce[7]), + tmp2_buf, + wpa->message_pair); + + return len; + } + + return 0; +} + +u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) +{ + const u32 digests_offset = hashes->salts_buf[salt_pos].digests_offset; + + wpa_t *wpas = (wpa_t *) hashes->esalts_buf; + + wpa_t *wpa = &wpas[digests_offset + digest_pos]; + + if (wpa->type == 1) + { + return KERN_RUN_AUX4; + } + else if (wpa->type == 2) + { + if (wpa->keyver == 1) + { + return KERN_RUN_AUX1; + } + else if (wpa->keyver == 2) + { + return KERN_RUN_AUX2; + } + else if (wpa->keyver == 3) + { + return KERN_RUN_AUX3; + } + } + + return 0; +} + +bool module_potfile_custom_check (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hash_t *db, MAYBE_UNUSED const hash_t *entry_hash, MAYBE_UNUSED const void *entry_tmps) +{ + const wpa_t *wpa_entry = (const wpa_t *) entry_hash->esalt; + const wpa_t *wpa_db = (const wpa_t *) db->esalt; + + if (wpa_db->essid_len != wpa_entry->essid_len) return false; + + if (strcmp ((const char *) wpa_db->essid_buf, (const char *) wpa_entry->essid_buf)) return false; + + const wpa_pbkdf2_tmp_t *wpa_pbkdf2_tmp = (const wpa_pbkdf2_tmp_t *) entry_tmps; + + wpa_pbkdf2_tmp_t tmps; + + tmps.out[0] = byte_swap_32 (wpa_pbkdf2_tmp->out[0]); + tmps.out[1] = byte_swap_32 (wpa_pbkdf2_tmp->out[1]); + tmps.out[2] = byte_swap_32 (wpa_pbkdf2_tmp->out[2]); + tmps.out[3] = byte_swap_32 (wpa_pbkdf2_tmp->out[3]); + tmps.out[4] = byte_swap_32 (wpa_pbkdf2_tmp->out[4]); + tmps.out[5] = byte_swap_32 (wpa_pbkdf2_tmp->out[5]); + tmps.out[6] = byte_swap_32 (wpa_pbkdf2_tmp->out[6]); + tmps.out[7] = byte_swap_32 (wpa_pbkdf2_tmp->out[7]); + + plain_t plains_buf; + + u32 hashes_shown = 0; + + u32 d_return_buf = 0; + + void (*m22000_aux) (KERN_ATTR_TMPS_ESALT (wpa_pbkdf2_tmp_t, wpa_t)); + + if (wpa_db->type == 1) + { + m22000_aux = m22000_aux4; + } + else if (wpa_db->type == 2) + { + if (wpa_db->keyver == 1) + { + m22000_aux = m22000_aux1; + } + else if (wpa_db->keyver == 2) + { + m22000_aux = m22000_aux2; + } + else if (wpa_db->keyver == 3) + { + m22000_aux = m22000_aux3; + } + else + { + return false; + } + } + else + { + return false; + } + + m22000_aux + ( + NULL, // pws + NULL, // rules_buf + NULL, // combs_buf + NULL, // bfs_buf + &tmps, // tmps + NULL, // hooks + NULL, // bitmaps_buf_s1_a + NULL, // bitmaps_buf_s1_b + NULL, // bitmaps_buf_s1_c + NULL, // bitmaps_buf_s1_d + NULL, // bitmaps_buf_s2_a + NULL, // bitmaps_buf_s2_b + NULL, // bitmaps_buf_s2_c + NULL, // bitmaps_buf_s2_d + &plains_buf, // plains_buf + db->digest, // digests_buf + &hashes_shown, // hashes_shown + db->salt, // salt_bufs + db->esalt, // esalt_bufs + &d_return_buf, // d_return_buf + NULL, // d_extra0_buf + NULL, // d_extra1_buf + NULL, // d_extra2_buf + NULL, // d_extra3_buf + 0, // bitmap_mask + 0, // bitmap_shift1 + 0, // bitmap_shift2 + 0, // salt_pos + 0, // loop_pos + 0, // loop_cnt + 0, // il_cnt + 1, // digests_cnt + 0, // digests_offset + 0, // combs_mode + 1 // gid_max + ); + + const bool r = (d_return_buf == 0) ? false : true; + + return r; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + wpa_t *wpa = (wpa_t *) esalt_buf; + + char *input_buf = (char *) line_buf; + int input_len = line_len; + + // start old pmkid/hccapx compatibility parsing + // idea is to find out if parsing succeeds and in this case to build a + // valid 22000 hash line and replace line_buf pointer + + char tmp_buf[1024]; + int tmp_len; + + // hccapx parser + + if (line_len == sizeof (hccapx_t)) + { + hccapx_t *hccapx = (hccapx_t *) line_buf; + + if ((hccapx->signature == HCCAPX_SIGNATURE) && (hccapx->version == HCCAPX_VERSION)) + { + tmp_len = 0; + + tmp_len += snprintf (tmp_buf, sizeof (tmp_buf) - tmp_len, "WPA*02*"); + + tmp_len += hex_encode ((const u8 *) hccapx->keymic, 16, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->mac_ap, 6, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->mac_sta, 6, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->essid, hccapx->essid_len, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->nonce_ap, 32, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->eapol, hccapx->eapol_len, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) &hccapx->message_pair, 1, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = 0; + + input_buf = tmp_buf; + input_len = tmp_len; + } + } + + // pmkid parser + + if (1) + { + // detect super-old/old format + + int old_sep = 0; + int new_sep = 0; + + for (int i = 0; i < line_len; i++) + { + const char c = line_buf[i]; + + if (c == '*') old_sep++; + if (c == ':') new_sep++; + } + + const u8 sep = (new_sep > old_sep) ? ':' : '*'; + + // start normal parsing + + token_t token; + + token.token_cnt = 4; + + token.sep[0] = sep; + token.len_min[0] = 32; + token.len_max[0] = 32; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[1] = sep; + token.len_min[1] = 12; + token.len_max[1] = 12; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[2] = sep; + token.len_min[2] = 12; + token.len_max[2] = 12; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = sep; + token.len_min[3] = 0; + token.len_max[3] = 64; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer == PARSER_OK) + { + tmp_len = snprintf (tmp_buf, sizeof (tmp_buf), "WPA*01*%s***", line_buf); + + input_buf = tmp_buf; + input_len = tmp_len; + } + } + + // start normal parsing + + token_t token; + + token.token_cnt = 9; + + token.signatures_cnt = 1; + token.signatures_buf[0] = "WPA"; + + token.sep[0] = '*'; + token.len_min[0] = 3; + token.len_max[0] = 3; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 2; + token.len_max[1] = 2; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[2] = '*'; + token.len_min[2] = 32; + token.len_max[2] = 32; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len_min[3] = 12; + token.len_max[3] = 12; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '*'; + token.len_min[4] = 12; + token.len_max[4] = 12; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[5] = '*'; + token.len_min[5] = 0; + token.len_max[5] = 64; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[6] = '*'; + token.len_min[6] = 0; + token.len_max[6] = 64; + token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[7] = '*'; + token.len_min[7] = 0; + token.len_max[7] = 512; + token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[8] = '*'; + token.len_min[8] = 0; + token.len_max[8] = 2; + token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) input_buf, input_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // mac_ap + + u8 *mac_ap = (u8 *) wpa->mac_ap; + u8 *mac_sta = (u8 *) wpa->mac_sta; + + const u8 *macap_buf = token.buf[3]; + + mac_ap[0] = hex_to_u8 (macap_buf + 0); + mac_ap[1] = hex_to_u8 (macap_buf + 2); + mac_ap[2] = hex_to_u8 (macap_buf + 4); + mac_ap[3] = hex_to_u8 (macap_buf + 6); + mac_ap[4] = hex_to_u8 (macap_buf + 8); + mac_ap[5] = hex_to_u8 (macap_buf + 10); + + // mac_sta + + const u8 *macsta_buf = token.buf[4]; + + mac_sta[0] = hex_to_u8 (macsta_buf + 0); + mac_sta[1] = hex_to_u8 (macsta_buf + 2); + mac_sta[2] = hex_to_u8 (macsta_buf + 4); + mac_sta[3] = hex_to_u8 (macsta_buf + 6); + mac_sta[4] = hex_to_u8 (macsta_buf + 8); + mac_sta[5] = hex_to_u8 (macsta_buf + 10); + + // essid + + const u8 *essid_buf = token.buf[5]; + const int essid_len = token.len[5]; + + if (essid_len & 1) return (PARSER_SALT_VALUE); + + wpa->essid_len = hex_decode (essid_buf, essid_len, (u8 *) wpa->essid_buf); + + // salt + + memcpy (salt->salt_buf, wpa->essid_buf, wpa->essid_len); + + salt->salt_len = wpa->essid_len; + + salt->salt_iter = ROUNDS_WPA_PBKDF2 - 1; + + // type + + const u8 *type_buf = token.buf[1]; + + const u8 type = hex_to_u8 (type_buf); + + if ((type != 1) && (type != 2)) return (PARSER_SALT_VALUE); + + wpa->type = type; + + // PMKID specific code + + if (type == 1) + { + // pmkid + + const u8 *pmkid_buf = token.buf[2]; + + wpa->pmkid[0] = hex_to_u32 (pmkid_buf + 0); + wpa->pmkid[1] = hex_to_u32 (pmkid_buf + 8); + wpa->pmkid[2] = hex_to_u32 (pmkid_buf + 16); + wpa->pmkid[3] = hex_to_u32 (pmkid_buf + 24); + + // pmkid_data + + wpa->pmkid_data[0] = 0x204b4d50; // "PMK " + wpa->pmkid_data[1] = 0x656d614e; // "Name" + wpa->pmkid_data[2] = (mac_ap[0] << 0) + | (mac_ap[1] << 8) + | (mac_ap[2] << 16) + | (mac_ap[3] << 24); + wpa->pmkid_data[3] = (mac_ap[4] << 0) + | (mac_ap[5] << 8) + | (mac_sta[0] << 16) + | (mac_sta[1] << 24); + wpa->pmkid_data[4] = (mac_sta[2] << 0) + | (mac_sta[3] << 8) + | (mac_sta[4] << 16) + | (mac_sta[5] << 24); + + // hash + + digest[0] = wpa->pmkid[0]; + digest[1] = wpa->pmkid[1]; + digest[2] = wpa->pmkid[2]; + digest[3] = wpa->pmkid[3]; + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + } + + // EAPOL specific code + + if (type == 2) + { + // checks + + if (token.len[6] != 64) return (PARSER_SALT_LENGTH); + + if (token.len[7] < (int) sizeof (auth_packet_t) * 2) return (PARSER_SALT_LENGTH); + + if (token.len[8] != 2) return (PARSER_SALT_LENGTH); + + // anonce + + const u8 *anonce_pos = token.buf[6]; + + wpa->anonce[0] = hex_to_u32 (anonce_pos + 0); + wpa->anonce[1] = hex_to_u32 (anonce_pos + 8); + wpa->anonce[2] = hex_to_u32 (anonce_pos + 16); + wpa->anonce[3] = hex_to_u32 (anonce_pos + 24); + wpa->anonce[4] = hex_to_u32 (anonce_pos + 32); + wpa->anonce[5] = hex_to_u32 (anonce_pos + 40); + wpa->anonce[6] = hex_to_u32 (anonce_pos + 48); + wpa->anonce[7] = hex_to_u32 (anonce_pos + 56); + + // eapol + + const u8 *eapol_pos = token.buf[7]; + + u8 *eapol_ptr = (u8 *) wpa->eapol; + + wpa->eapol_len = hex_decode ((const u8 *) eapol_pos, token.len[7], eapol_ptr); + + memset (eapol_ptr + wpa->eapol_len, 0, (256 + 64) - wpa->eapol_len); + + auth_packet_t *auth_packet = (auth_packet_t *) wpa->eapol; + + // keyver + + const u16 key_information = byte_swap_16 (auth_packet->key_information); + + wpa->keyver = key_information & 3; + + if ((wpa->keyver != 1) && (wpa->keyver != 2) && (wpa->keyver != 3)) return (PARSER_SALT_VALUE); + + // pke + + u8 *pke_ptr = (u8 *) wpa->pke; + + memset (pke_ptr, 0, 128); + + if ((wpa->keyver == 1) || (wpa->keyver == 2)) + { + memcpy (pke_ptr, "Pairwise key expansion\x00", 23); + + if (memcmp (mac_ap, mac_sta, 6) < 0) + { + memcpy (pke_ptr + 23, mac_ap, 6); + memcpy (pke_ptr + 29, mac_sta, 6); + } + else + { + memcpy (pke_ptr + 23, mac_sta, 6); + memcpy (pke_ptr + 29, mac_ap, 6); + } + + wpa->nonce_compare = memcmp (wpa->anonce, auth_packet->wpa_key_nonce, 32); + + if (wpa->nonce_compare < 0) + { + memcpy (pke_ptr + 35, wpa->anonce, 32); + memcpy (pke_ptr + 67, auth_packet->wpa_key_nonce, 32); + } + else + { + memcpy (pke_ptr + 35, auth_packet->wpa_key_nonce, 32); + memcpy (pke_ptr + 67, wpa->anonce, 32); + } + } + else if (wpa->keyver == 3) + { + pke_ptr[0] = 1; + pke_ptr[1] = 0; + + memcpy (pke_ptr + 2, "Pairwise key expansion", 22); + + if (memcmp (mac_ap, mac_sta, 6) < 0) + { + memcpy (pke_ptr + 24, mac_ap, 6); + memcpy (pke_ptr + 30, mac_sta, 6); + } + else + { + memcpy (pke_ptr + 24, mac_sta, 6); + memcpy (pke_ptr + 30, mac_ap, 6); + } + + wpa->nonce_compare = memcmp (wpa->anonce, auth_packet->wpa_key_nonce, 32); + + if (wpa->nonce_compare < 0) + { + memcpy (pke_ptr + 36, wpa->anonce, 32); + memcpy (pke_ptr + 68, auth_packet->wpa_key_nonce, 32); + } + else + { + memcpy (pke_ptr + 36, auth_packet->wpa_key_nonce, 32); + memcpy (pke_ptr + 68, wpa->anonce, 32); + } + + pke_ptr[100] = 0x80; + pke_ptr[101] = 1; + } + + for (int i = 0; i < 32; i++) + { + wpa->pke[i] = byte_swap_32 (wpa->pke[i]); + } + + if (wpa->keyver == 2) + { + for (int i = 0; i < 64; i++) + { + wpa->eapol[i] = byte_swap_32 (wpa->eapol[i]); + } + } + + if (wpa->keyver == 3) + { + eapol_ptr[wpa->eapol_len] = 0x80; + } + + // message_pair + + const u8 *message_pair_pos = token.buf[8]; + + const u8 message_pair = hex_to_u8 (message_pair_pos); + + if (wpa->message_pair_chgd == true) + { + // we can filter some message types here + + if (wpa->message_pair != (message_pair & 0x7f)) return (PARSER_HCCAPX_MESSAGE_PAIR); + } + else + { + wpa->message_pair = message_pair; + } + + if (wpa->nonce_error_corrections_chgd == true) + { + // value was set in module_hash_binary_parse() + } + else + { + if (wpa->message_pair & (1 << 4)) + { + // ap-less attack detected, nc not needed + + wpa->nonce_error_corrections = 0; + } + else + { + if (wpa->message_pair & (1 << 7)) + { + // replaycount not checked, nc needed + } + else + { + wpa->nonce_error_corrections = 0; + } + } + } + + // now some optimization related to replay counter endianess + // hcxtools has techniques to detect them + // since we can not guarantee to get our handshakes from hcxtools we enable both by default + // this means that we check both even if both are not set! + // however if one of them is set, we can assume that the endianess has been checked and the other one is not needed + + wpa->detected_le = 1; + wpa->detected_be = 1; + + if (wpa->message_pair & (1 << 5)) + { + wpa->detected_le = 1; + wpa->detected_be = 0; + } + else if (wpa->message_pair & (1 << 6)) + { + wpa->detected_le = 0; + wpa->detected_be = 1; + } + + // mic + + const u8 *mic_pos = token.buf[2]; + + wpa->keymic[0] = hex_to_u32 (mic_pos + 0); + wpa->keymic[1] = hex_to_u32 (mic_pos + 8); + wpa->keymic[2] = hex_to_u32 (mic_pos + 16); + wpa->keymic[3] = hex_to_u32 (mic_pos + 24); + + wpa->keymic[0] = byte_swap_32 (wpa->keymic[0]); + wpa->keymic[1] = byte_swap_32 (wpa->keymic[1]); + wpa->keymic[2] = byte_swap_32 (wpa->keymic[2]); + wpa->keymic[3] = byte_swap_32 (wpa->keymic[3]); + + // Create a hash of the nonce as ESSID is not unique enough + // Not a regular MD5 but good enough + // We can also ignore cases where we should bzero the work buffer + + u32 hash[4]; + + hash[0] = 0; + hash[1] = 1; + hash[2] = 2; + hash[3] = 3; + + u32 block[16]; + + memset (block, 0, sizeof (block)); + + u8 *block_ptr = (u8 *) block; + + for (int i = 0; i < 16; i++) block[i] = salt->salt_buf[i]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->pke[i + 0]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->pke[i + 16]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 0]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 16]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 32]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 48]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 2; i++) block[0 + i] = wpa->mac_ap[i]; + for (int i = 0; i < 2; i++) block[2 + i] = wpa->mac_ap[i]; + for (int i = 0; i < 12; i++) block[4 + i] = 0; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + memcpy (block_ptr + 0, wpa->anonce, 32); + memcpy (block_ptr + 32, auth_packet->wpa_key_nonce, 32); + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + block[0] = wpa->keymic[0]; + block[1] = wpa->keymic[1]; + block[2] = wpa->keymic[2]; + block[3] = wpa->keymic[3]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + // make all this stuff unique + + digest[0] = hash[0]; + digest[1] = hash[1]; + digest[2] = hash[2]; + digest[3] = hash[3]; + } + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const wpa_t *wpa = (const wpa_t *) esalt_buf; + + int line_len = 0; + + const u8 *mac_ap = (const u8 *) wpa->mac_ap; + const u8 *mac_sta = (const u8 *) wpa->mac_sta; + + if (wpa->type == 1) + { + u32_to_hex (wpa->pmkid[0], (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (wpa->pmkid[1], (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (wpa->pmkid[2], (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (wpa->pmkid[3], (u8 *) line_buf + line_len); line_len += 8; + } + else if (wpa->type == 2) + { + u32_to_hex (byte_swap_32 (wpa->keymic[0]), (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (byte_swap_32 (wpa->keymic[1]), (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (byte_swap_32 (wpa->keymic[2]), (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (byte_swap_32 (wpa->keymic[3]), (u8 *) line_buf + line_len); line_len += 8; + } + + line_buf[line_len] = ':'; + + line_len++; + + if (need_hexify ((const u8 *) wpa->essid_buf, wpa->essid_len, ':', 0) == true) + { + char tmp_buf[128]; + + int tmp_len = 0; + + tmp_buf[tmp_len++] = '$'; + tmp_buf[tmp_len++] = 'H'; + tmp_buf[tmp_len++] = 'E'; + tmp_buf[tmp_len++] = 'X'; + tmp_buf[tmp_len++] = '['; + + exec_hexify ((const u8 *) wpa->essid_buf, wpa->essid_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += wpa->essid_len * 2; + + tmp_buf[tmp_len++] = ']'; + + tmp_buf[tmp_len++] = 0; + + line_len += snprintf (line_buf + line_len, line_size - line_len, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + tmp_buf); + } + else + { + line_len += snprintf (line_buf + line_len, line_size - line_len, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + (const char *) wpa->essid_buf); + } + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = module_benchmark_mask; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = module_hash_binary_count; + module_ctx->module_hash_binary_parse = module_hash_binary_parse; + module_ctx->module_hash_binary_save = module_hash_binary_save; + module_ctx->module_hash_decode_potfile = module_hash_decode_potfile; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = module_hash_encode_potfile; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = module_hash_init_selftest; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = module_hlfmt_disable; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = module_potfile_custom_check; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22001.c b/src/modules/module_22001.c new file mode 100644 index 000000000..9a3465266 --- /dev/null +++ b/src/modules/module_22001.c @@ -0,0 +1,1343 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +#define DGST_ELEM 4 + +#include "emu_general.h" +#include "emu_inc_cipher_aes.h" +#include "emu_inc_hash_md5.h" +#include "m22001-pure.cl" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; +static const char *HASH_NAME = "WPA-PMK-PMKID+EAPOL"; +static const u64 KERN_TYPE = 22001; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_AUX1 + | OPTS_TYPE_AUX2 + | OPTS_TYPE_AUX3 + | OPTS_TYPE_AUX4 + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_DEEP_COMP_KERNEL + | OPTS_TYPE_COPY_TMPS + | OPTS_TYPE_POTFILE_NOPASS; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "88f43854ae7b1624fc2ab7724859e795130f4843c7535729e819cf92f39535dc"; +static const char *ST_HASH = "WPA*01*5ce7ebe97a1bbfeb2822ae627b726d5b*27462da350ac*accd10fb464e*686173686361742d6573736964***"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const u32 ROUNDS_WPA_PMK = 0; + +// this is required to force mingw to accept the packed attribute +#pragma pack(push,1) + +struct auth_packet +{ + u8 version; + u8 type; + u16 length; + u8 key_descriptor; + u16 key_information; + u16 key_length; + u64 replay_counter; + u8 wpa_key_nonce[32]; + u8 wpa_key_iv[16]; + u8 wpa_key_rsc[8]; + u8 wpa_key_id[8]; + u8 wpa_key_mic[16]; + u16 wpa_key_data_length; + +} __attribute__((packed)); + +#pragma pack(pop) + +typedef struct auth_packet auth_packet_t; + +#define HCCAPX_VERSION 4 +#define HCCAPX_SIGNATURE 0x58504348 // HCPX + +// this is required to force mingw to accept the packed attribute +#pragma pack(push,1) + +struct hccapx +{ + u32 signature; + u32 version; + u8 message_pair; + u8 essid_len; + u8 essid[32]; + u8 keyver; + u8 keymic[16]; + u8 mac_ap[6]; + u8 nonce_ap[32]; + u8 mac_sta[6]; + u8 nonce_sta[32]; + u16 eapol_len; + u8 eapol[256]; + +} __attribute__((packed)); + +typedef struct hccapx hccapx_t; + +#pragma pack(pop) + +const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const char *mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + + return mask; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (wpa_pmk_tmp_t); + + return tmp_size; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (wpa_t); + + return esalt_size; +} + +static bool is_hccapx (HCFILE *fp) +{ + hccapx_t hccapx; + + const size_t nread = hc_fread (&hccapx, sizeof (hccapx_t), 1, fp); + + if (nread == 1) + { + if (hccapx.signature == HCCAPX_SIGNATURE) + { + return true; + } + } + + return false; +} + +int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) +{ + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, hashconfig->st_hash, strlen (hashconfig->st_hash)); + + wpa_t *wpa = (wpa_t *) hash->esalt; + + wpa->detected_le = 1; + wpa->detected_be = 0; + + wpa->nonce_error_corrections = 3; + + return parser_status; +} + +int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, hashes_t *hashes) +{ + hash_t *hashes_buf = hashes->hashes_buf; + + int hashes_cnt = 0; + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1; + + const bool r = is_hccapx (&fp); + + hc_rewind (&fp); + + if (r == true) + { + char *in = (char *) hcmalloc (sizeof (hccapx_t)); + + while (!hc_feof (&fp)) + { + const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, &fp); + + if (nread == 0) break; + + memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t)); + + memset (hashes_buf[hashes_cnt].esalt, 0, sizeof (wpa_t)); + + wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt; + + wpa->message_pair_chgd = user_options->hccapx_message_pair_chgd; + wpa->message_pair = user_options->hccapx_message_pair; + + wpa->nonce_error_corrections_chgd = user_options->nonce_error_corrections_chgd; + wpa->nonce_error_corrections = user_options->nonce_error_corrections; + + hash_t *hash = &hashes_buf[hashes_cnt]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, in, sizeof (hccapx_t)); + + if (parser_status != PARSER_OK) continue; + + hashes_cnt++; + } + + hcfree (in); + } + else + { + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); + + while (!hc_feof (&fp)) + { + const size_t line_len = fgetl (&fp, line_buf, HCBUFSIZ_LARGE); + + if (line_len == 0) continue; + + memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t)); + + memset (hashes_buf[hashes_cnt].esalt, 0, sizeof (wpa_t)); + + wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt; + + wpa->message_pair_chgd = user_options->hccapx_message_pair_chgd; + wpa->message_pair = user_options->hccapx_message_pair; + + wpa->nonce_error_corrections_chgd = user_options->nonce_error_corrections_chgd; + wpa->nonce_error_corrections = user_options->nonce_error_corrections; + + hash_t *hash = &hashes_buf[hashes_cnt]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, line_buf, line_len); + + if (parser_status != PARSER_OK) continue; + + hashes_cnt++; + } + + hcfree (line_buf); + } + + hc_fclose (&fp); + + return hashes_cnt; +} + +int module_hash_binary_count (MAYBE_UNUSED const hashes_t *hashes) +{ + // this mode actually works on a plaintext file + // but to stay in a .hccapx backward compatibility mode we have to tell the module + // the file is in binary. + // we then have to iterated through the file ourself + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1; + + const bool r = is_hccapx (&fp); + + hc_rewind (&fp); + + int count = 0; + + if (r == true) + { + struct stat st; + + stat (hashes->hashfile, &st); + + count = st.st_size / sizeof (hccapx_t); + } + else + { + count = count_lines (&fp); + } + + hc_fclose (&fp); + + return count; +} + +bool module_hlfmt_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool hlfmt_disable = true; + + return hlfmt_disable; +} + +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_min = 64; + + return pw_min; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_max = 64; + + return pw_max; +} + +int module_hash_decode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len, MAYBE_UNUSED void *tmps) +{ + wpa_t *wpa = (wpa_t *) esalt_buf; + + wpa_pmk_tmp_t *wpa_pmk_tmp = (wpa_pmk_tmp_t *) tmps; + + // here we have in line_hash_buf: PMK*essid:password + // but we don't care about the password + + // PMK + + wpa_pmk_tmp->out[0] = hex_to_u32 ((const u8 *) line_buf + 0); + wpa_pmk_tmp->out[1] = hex_to_u32 ((const u8 *) line_buf + 8); + wpa_pmk_tmp->out[2] = hex_to_u32 ((const u8 *) line_buf + 16); + wpa_pmk_tmp->out[3] = hex_to_u32 ((const u8 *) line_buf + 24); + wpa_pmk_tmp->out[4] = hex_to_u32 ((const u8 *) line_buf + 32); + wpa_pmk_tmp->out[5] = hex_to_u32 ((const u8 *) line_buf + 40); + wpa_pmk_tmp->out[6] = hex_to_u32 ((const u8 *) line_buf + 48); + wpa_pmk_tmp->out[7] = hex_to_u32 ((const u8 *) line_buf + 56); + + // essid + + char *sep_pos = strrchr (line_buf, '*'); + + if (sep_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); + + if ((line_buf + 64) != sep_pos) return (PARSER_HASH_LENGTH); + + char *essid_pos = sep_pos + 1; + + const int essid_len = strlen (essid_pos); + + if (essid_len & 1) return (PARSER_SALT_VALUE); + + if (essid_len > 64) return (PARSER_SALT_VALUE); + + wpa->essid_len = hex_decode ((const u8 *) essid_pos, essid_len, (u8 *) wpa->essid_buf); + + return PARSER_OK; +} + +int module_hash_encode_potfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size, MAYBE_UNUSED const void *tmps) +{ + const wpa_t *wpa = (const wpa_t *) esalt_buf; + + const wpa_pmk_tmp_t *wpa_pmk_tmp = (const wpa_pmk_tmp_t *) tmps; + + char tmp_buf[128]; + + const int tmp_len = hex_encode ((const u8 *) wpa->essid_buf, wpa->essid_len, (u8 *) tmp_buf); + + tmp_buf[tmp_len] = 0; + + const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", + wpa_pmk_tmp->out[0], + wpa_pmk_tmp->out[1], + wpa_pmk_tmp->out[2], + wpa_pmk_tmp->out[3], + wpa_pmk_tmp->out[4], + wpa_pmk_tmp->out[5], + wpa_pmk_tmp->out[6], + wpa_pmk_tmp->out[7], + tmp_buf); + + return line_len; +} + +int module_hash_binary_save (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos, char **buf) +{ + const salt_t *salts_buf = hashes->salts_buf; + const void *esalts_buf = hashes->esalts_buf; + + const salt_t *salt = &salts_buf[salt_pos]; + + const u32 digest_cur = salt->digests_offset + digest_pos; + + const wpa_t *wpas = (const wpa_t *) esalts_buf; + const wpa_t *wpa = &wpas[digest_cur]; + + char tmp_buf[128]; + + const int tmp_len = hex_encode ((const u8 *) wpa->essid_buf, wpa->essid_len, (u8 *) tmp_buf); + + tmp_buf[tmp_len] = 0; + + const u8 *mac_ap = (const u8 *) wpa->mac_ap; + const u8 *mac_sta = (const u8 *) wpa->mac_sta; + + if (wpa->type == 1) + { + const int len = hc_asprintf (buf, "WPA*01*%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s***" EOL, + byte_swap_32 (wpa->pmkid[0]), + byte_swap_32 (wpa->pmkid[1]), + byte_swap_32 (wpa->pmkid[2]), + byte_swap_32 (wpa->pmkid[3]), + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + tmp_buf); + + return len; + } + else if (wpa->type == 2) + { + u32 eapol_swapped[64 + 2]; + + for (int i = 0; i < 64; i++) + { + eapol_swapped[i] = wpa->eapol[i]; + + if (wpa->keyver == 2) + { + eapol_swapped[i] = byte_swap_32 (eapol_swapped[i]); + } + } + + eapol_swapped[64] = 0; + eapol_swapped[65] = 0; + + char tmp2_buf[1024]; + + const int tmp2_len = hex_encode ((const u8 *) eapol_swapped, wpa->eapol_len, (u8 *) tmp2_buf); + + tmp2_buf[tmp2_len] = 0; + + const int len = hc_asprintf (buf, "WPA*02*%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s*%08x%08x%08x%08x%08x%08x%08x%08x*%s*%02x" EOL, + wpa->keymic[0], + wpa->keymic[1], + wpa->keymic[2], + wpa->keymic[3], + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + tmp_buf, + byte_swap_32 (wpa->anonce[0]), + byte_swap_32 (wpa->anonce[1]), + byte_swap_32 (wpa->anonce[2]), + byte_swap_32 (wpa->anonce[3]), + byte_swap_32 (wpa->anonce[4]), + byte_swap_32 (wpa->anonce[5]), + byte_swap_32 (wpa->anonce[6]), + byte_swap_32 (wpa->anonce[7]), + tmp2_buf, + wpa->message_pair); + + return len; + } + + return 0; +} + +u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) +{ + const u32 digests_offset = hashes->salts_buf[salt_pos].digests_offset; + + wpa_t *wpas = (wpa_t *) hashes->esalts_buf; + + wpa_t *wpa = &wpas[digests_offset + digest_pos]; + + if (wpa->type == 1) + { + return KERN_RUN_AUX4; + } + else if (wpa->type == 2) + { + if (wpa->keyver == 1) + { + return KERN_RUN_AUX1; + } + else if (wpa->keyver == 2) + { + return KERN_RUN_AUX2; + } + else if (wpa->keyver == 3) + { + return KERN_RUN_AUX3; + } + } + + return 0; +} + +bool module_potfile_custom_check (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hash_t *db, MAYBE_UNUSED const hash_t *entry_hash, MAYBE_UNUSED const void *entry_tmps) +{ + const wpa_t *wpa_entry = (const wpa_t *) entry_hash->esalt; + const wpa_t *wpa_db = (const wpa_t *) db->esalt; + + if (wpa_db->essid_len != wpa_entry->essid_len) return false; + + if (strcmp ((const char *) wpa_db->essid_buf, (const char *) wpa_entry->essid_buf)) return false; + + const wpa_pmk_tmp_t *wpa_pmk_tmp = (const wpa_pmk_tmp_t *) entry_tmps; + + wpa_pmk_tmp_t tmps; + + tmps.out[0] = byte_swap_32 (wpa_pmk_tmp->out[0]); + tmps.out[1] = byte_swap_32 (wpa_pmk_tmp->out[1]); + tmps.out[2] = byte_swap_32 (wpa_pmk_tmp->out[2]); + tmps.out[3] = byte_swap_32 (wpa_pmk_tmp->out[3]); + tmps.out[4] = byte_swap_32 (wpa_pmk_tmp->out[4]); + tmps.out[5] = byte_swap_32 (wpa_pmk_tmp->out[5]); + tmps.out[6] = byte_swap_32 (wpa_pmk_tmp->out[6]); + tmps.out[7] = byte_swap_32 (wpa_pmk_tmp->out[7]); + + plain_t plains_buf; + + u32 hashes_shown = 0; + + u32 d_return_buf = 0; + + void (*m22001_aux) (KERN_ATTR_TMPS_ESALT (wpa_pmk_tmp_t, wpa_t)); + + if (wpa_db->type == 1) + { + m22001_aux = m22001_aux4; + } + else if (wpa_db->type == 2) + { + if (wpa_db->keyver == 1) + { + m22001_aux = m22001_aux1; + } + else if (wpa_db->keyver == 2) + { + m22001_aux = m22001_aux2; + } + else if (wpa_db->keyver == 3) + { + m22001_aux = m22001_aux3; + } + else + { + return false; + } + } + else + { + return false; + } + + m22001_aux + ( + NULL, // pws + NULL, // rules_buf + NULL, // combs_buf + NULL, // bfs_buf + &tmps, // tmps + NULL, // hooks + NULL, // bitmaps_buf_s1_a + NULL, // bitmaps_buf_s1_b + NULL, // bitmaps_buf_s1_c + NULL, // bitmaps_buf_s1_d + NULL, // bitmaps_buf_s2_a + NULL, // bitmaps_buf_s2_b + NULL, // bitmaps_buf_s2_c + NULL, // bitmaps_buf_s2_d + &plains_buf, // plains_buf + db->digest, // digests_buf + &hashes_shown, // hashes_shown + db->salt, // salt_bufs + db->esalt, // esalt_bufs + &d_return_buf, // d_return_buf + NULL, // d_extra0_buf + NULL, // d_extra1_buf + NULL, // d_extra2_buf + NULL, // d_extra3_buf + 0, // bitmap_mask + 0, // bitmap_shift1 + 0, // bitmap_shift2 + 0, // salt_pos + 0, // loop_pos + 0, // loop_cnt + 0, // il_cnt + 1, // digests_cnt + 0, // digests_offset + 0, // combs_mode + 1 // gid_max + ); + + const bool r = (d_return_buf == 0) ? false : true; + + return r; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + wpa_t *wpa = (wpa_t *) esalt_buf; + + char *input_buf = (char *) line_buf; + int input_len = line_len; + + // start old pmkid/hccapx compatibility parsing + // idea is to find out if parsing succeeds and in this case to build a + // valid 22001 hash line and replace line_buf pointer + + char tmp_buf[1024]; + int tmp_len; + + // hccapx parser + + if (line_len == sizeof (hccapx_t)) + { + hccapx_t *hccapx = (hccapx_t *) line_buf; + + if ((hccapx->signature == HCCAPX_SIGNATURE) && (hccapx->version == HCCAPX_VERSION)) + { + tmp_len = 0; + + tmp_len += snprintf (tmp_buf, sizeof (tmp_buf) - tmp_len, "WPA*02*"); + + tmp_len += hex_encode ((const u8 *) hccapx->keymic, 16, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->mac_ap, 6, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->mac_sta, 6, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->essid, hccapx->essid_len, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->nonce_ap, 32, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) hccapx->eapol, hccapx->eapol_len, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = '*'; + + tmp_len++; + + tmp_len += hex_encode ((const u8 *) &hccapx->message_pair, 1, (u8 *) tmp_buf + tmp_len); + + tmp_buf[tmp_len] = 0; + + input_buf = tmp_buf; + input_len = tmp_len; + } + } + + // pmkid parser + + if (1) + { + // detect super-old/old format + + int old_sep = 0; + int new_sep = 0; + + for (int i = 0; i < line_len; i++) + { + const char c = line_buf[i]; + + if (c == '*') old_sep++; + if (c == ':') new_sep++; + } + + const u8 sep = (new_sep > old_sep) ? ':' : '*'; + + // start normal parsing + + token_t token; + + token.token_cnt = 4; + + token.sep[0] = sep; + token.len_min[0] = 32; + token.len_max[0] = 32; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[1] = sep; + token.len_min[1] = 12; + token.len_max[1] = 12; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[2] = sep; + token.len_min[2] = 12; + token.len_max[2] = 12; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = sep; + token.len_min[3] = 0; + token.len_max[3] = 64; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer == PARSER_OK) + { + tmp_len = snprintf (tmp_buf, sizeof (tmp_buf), "WPA*01*%s***", line_buf); + + input_buf = tmp_buf; + input_len = tmp_len; + } + } + + // start normal parsing + + token_t token; + + token.token_cnt = 9; + + token.signatures_cnt = 1; + token.signatures_buf[0] = "WPA"; + + token.sep[0] = '*'; + token.len_min[0] = 3; + token.len_max[0] = 3; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 2; + token.len_max[1] = 2; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[2] = '*'; + token.len_min[2] = 32; + token.len_max[2] = 32; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len_min[3] = 12; + token.len_max[3] = 12; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '*'; + token.len_min[4] = 12; + token.len_max[4] = 12; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[5] = '*'; + token.len_min[5] = 0; + token.len_max[5] = 64; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[6] = '*'; + token.len_min[6] = 0; + token.len_max[6] = 64; + token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[7] = '*'; + token.len_min[7] = 0; + token.len_max[7] = 512; + token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[8] = '*'; + token.len_min[8] = 0; + token.len_max[8] = 2; + token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) input_buf, input_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // mac_ap + + u8 *mac_ap = (u8 *) wpa->mac_ap; + u8 *mac_sta = (u8 *) wpa->mac_sta; + + const u8 *macap_buf = token.buf[3]; + + mac_ap[0] = hex_to_u8 (macap_buf + 0); + mac_ap[1] = hex_to_u8 (macap_buf + 2); + mac_ap[2] = hex_to_u8 (macap_buf + 4); + mac_ap[3] = hex_to_u8 (macap_buf + 6); + mac_ap[4] = hex_to_u8 (macap_buf + 8); + mac_ap[5] = hex_to_u8 (macap_buf + 10); + + // mac_sta + + const u8 *macsta_buf = token.buf[4]; + + mac_sta[0] = hex_to_u8 (macsta_buf + 0); + mac_sta[1] = hex_to_u8 (macsta_buf + 2); + mac_sta[2] = hex_to_u8 (macsta_buf + 4); + mac_sta[3] = hex_to_u8 (macsta_buf + 6); + mac_sta[4] = hex_to_u8 (macsta_buf + 8); + mac_sta[5] = hex_to_u8 (macsta_buf + 10); + + // essid + + const u8 *essid_buf = token.buf[5]; + const int essid_len = token.len[5]; + + if (essid_len & 1) return (PARSER_SALT_VALUE); + + wpa->essid_len = hex_decode (essid_buf, essid_len, (u8 *) wpa->essid_buf); + + // salt + + memcpy (salt->salt_buf, wpa->essid_buf, wpa->essid_len); + + salt->salt_len = wpa->essid_len; + + salt->salt_iter = ROUNDS_WPA_PMK; + + // type + + const u8 *type_buf = token.buf[1]; + + const u8 type = hex_to_u8 (type_buf); + + if ((type != 1) && (type != 2)) return (PARSER_SALT_VALUE); + + wpa->type = type; + + // PMKID specific code + + if (type == 1) + { + // pmkid + + const u8 *pmkid_buf = token.buf[2]; + + wpa->pmkid[0] = hex_to_u32 (pmkid_buf + 0); + wpa->pmkid[1] = hex_to_u32 (pmkid_buf + 8); + wpa->pmkid[2] = hex_to_u32 (pmkid_buf + 16); + wpa->pmkid[3] = hex_to_u32 (pmkid_buf + 24); + + // pmkid_data + + wpa->pmkid_data[0] = 0x204b4d50; // "PMK " + wpa->pmkid_data[1] = 0x656d614e; // "Name" + wpa->pmkid_data[2] = (mac_ap[0] << 0) + | (mac_ap[1] << 8) + | (mac_ap[2] << 16) + | (mac_ap[3] << 24); + wpa->pmkid_data[3] = (mac_ap[4] << 0) + | (mac_ap[5] << 8) + | (mac_sta[0] << 16) + | (mac_sta[1] << 24); + wpa->pmkid_data[4] = (mac_sta[2] << 0) + | (mac_sta[3] << 8) + | (mac_sta[4] << 16) + | (mac_sta[5] << 24); + + // hash + + digest[0] = wpa->pmkid[0]; + digest[1] = wpa->pmkid[1]; + digest[2] = wpa->pmkid[2]; + digest[3] = wpa->pmkid[3]; + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + } + + // EAPOL specific code + + if (type == 2) + { + // checks + + if (token.len[6] != 64) return (PARSER_SALT_LENGTH); + + if (token.len[7] < (int) sizeof (auth_packet_t) * 2) return (PARSER_SALT_LENGTH); + + if (token.len[8] != 2) return (PARSER_SALT_LENGTH); + + // anonce + + const u8 *anonce_pos = token.buf[6]; + + wpa->anonce[0] = hex_to_u32 (anonce_pos + 0); + wpa->anonce[1] = hex_to_u32 (anonce_pos + 8); + wpa->anonce[2] = hex_to_u32 (anonce_pos + 16); + wpa->anonce[3] = hex_to_u32 (anonce_pos + 24); + wpa->anonce[4] = hex_to_u32 (anonce_pos + 32); + wpa->anonce[5] = hex_to_u32 (anonce_pos + 40); + wpa->anonce[6] = hex_to_u32 (anonce_pos + 48); + wpa->anonce[7] = hex_to_u32 (anonce_pos + 56); + + // eapol + + const u8 *eapol_pos = token.buf[7]; + + u8 *eapol_ptr = (u8 *) wpa->eapol; + + wpa->eapol_len = hex_decode ((const u8 *) eapol_pos, token.len[7], eapol_ptr); + + memset (eapol_ptr + wpa->eapol_len, 0, (256 + 64) - wpa->eapol_len); + + auth_packet_t *auth_packet = (auth_packet_t *) wpa->eapol; + + // keyver + + const u16 key_information = byte_swap_16 (auth_packet->key_information); + + wpa->keyver = key_information & 3; + + if ((wpa->keyver != 1) && (wpa->keyver != 2) && (wpa->keyver != 3)) return (PARSER_SALT_VALUE); + + // pke + + u8 *pke_ptr = (u8 *) wpa->pke; + + memset (pke_ptr, 0, 128); + + if ((wpa->keyver == 1) || (wpa->keyver == 2)) + { + memcpy (pke_ptr, "Pairwise key expansion\x00", 23); + + if (memcmp (mac_ap, mac_sta, 6) < 0) + { + memcpy (pke_ptr + 23, mac_ap, 6); + memcpy (pke_ptr + 29, mac_sta, 6); + } + else + { + memcpy (pke_ptr + 23, mac_sta, 6); + memcpy (pke_ptr + 29, mac_ap, 6); + } + + wpa->nonce_compare = memcmp (wpa->anonce, auth_packet->wpa_key_nonce, 32); + + if (wpa->nonce_compare < 0) + { + memcpy (pke_ptr + 35, wpa->anonce, 32); + memcpy (pke_ptr + 67, auth_packet->wpa_key_nonce, 32); + } + else + { + memcpy (pke_ptr + 35, auth_packet->wpa_key_nonce, 32); + memcpy (pke_ptr + 67, wpa->anonce, 32); + } + } + else if (wpa->keyver == 3) + { + pke_ptr[0] = 1; + pke_ptr[1] = 0; + + memcpy (pke_ptr + 2, "Pairwise key expansion", 22); + + if (memcmp (mac_ap, mac_sta, 6) < 0) + { + memcpy (pke_ptr + 24, mac_ap, 6); + memcpy (pke_ptr + 30, mac_sta, 6); + } + else + { + memcpy (pke_ptr + 24, mac_sta, 6); + memcpy (pke_ptr + 30, mac_ap, 6); + } + + wpa->nonce_compare = memcmp (wpa->anonce, auth_packet->wpa_key_nonce, 32); + + if (wpa->nonce_compare < 0) + { + memcpy (pke_ptr + 36, wpa->anonce, 32); + memcpy (pke_ptr + 68, auth_packet->wpa_key_nonce, 32); + } + else + { + memcpy (pke_ptr + 36, auth_packet->wpa_key_nonce, 32); + memcpy (pke_ptr + 68, wpa->anonce, 32); + } + + pke_ptr[100] = 0x80; + pke_ptr[101] = 1; + } + + for (int i = 0; i < 32; i++) + { + wpa->pke[i] = byte_swap_32 (wpa->pke[i]); + } + + if (wpa->keyver == 2) + { + for (int i = 0; i < 64; i++) + { + wpa->eapol[i] = byte_swap_32 (wpa->eapol[i]); + } + } + + if (wpa->keyver == 3) + { + eapol_ptr[wpa->eapol_len] = 0x80; + } + + // message_pair + + const u8 *message_pair_pos = token.buf[8]; + + const u8 message_pair = hex_to_u8 (message_pair_pos); + + if (wpa->message_pair_chgd == true) + { + // we can filter some message types here + + if (wpa->message_pair != (message_pair & 0x7f)) return (PARSER_HCCAPX_MESSAGE_PAIR); + } + else + { + wpa->message_pair = message_pair; + } + + if (wpa->nonce_error_corrections_chgd == true) + { + // value was set in module_hash_binary_parse() + } + else + { + if (wpa->message_pair & (1 << 4)) + { + // ap-less attack detected, nc not needed + + wpa->nonce_error_corrections = 0; + } + else + { + if (wpa->message_pair & (1 << 7)) + { + // replaycount not checked, nc needed + } + else + { + wpa->nonce_error_corrections = 0; + } + } + } + + // now some optimization related to replay counter endianess + // hcxtools has techniques to detect them + // since we can not guarantee to get our handshakes from hcxtools we enable both by default + // this means that we check both even if both are not set! + // however if one of them is set, we can assume that the endianess has been checked and the other one is not needed + + wpa->detected_le = 1; + wpa->detected_be = 1; + + if (wpa->message_pair & (1 << 5)) + { + wpa->detected_le = 1; + wpa->detected_be = 0; + } + else if (wpa->message_pair & (1 << 6)) + { + wpa->detected_le = 0; + wpa->detected_be = 1; + } + + // mic + + const u8 *mic_pos = token.buf[2]; + + wpa->keymic[0] = hex_to_u32 (mic_pos + 0); + wpa->keymic[1] = hex_to_u32 (mic_pos + 8); + wpa->keymic[2] = hex_to_u32 (mic_pos + 16); + wpa->keymic[3] = hex_to_u32 (mic_pos + 24); + + wpa->keymic[0] = byte_swap_32 (wpa->keymic[0]); + wpa->keymic[1] = byte_swap_32 (wpa->keymic[1]); + wpa->keymic[2] = byte_swap_32 (wpa->keymic[2]); + wpa->keymic[3] = byte_swap_32 (wpa->keymic[3]); + + // Create a hash of the nonce as ESSID is not unique enough + // Not a regular MD5 but good enough + // We can also ignore cases where we should bzero the work buffer + + u32 hash[4]; + + hash[0] = 0; + hash[1] = 1; + hash[2] = 2; + hash[3] = 3; + + u32 block[16]; + + memset (block, 0, sizeof (block)); + + u8 *block_ptr = (u8 *) block; + + for (int i = 0; i < 16; i++) block[i] = salt->salt_buf[i]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->pke[i + 0]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->pke[i + 16]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 0]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 16]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 32]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 16; i++) block[i] = wpa->eapol[i + 48]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + for (int i = 0; i < 2; i++) block[0 + i] = wpa->mac_ap[i]; + for (int i = 0; i < 2; i++) block[2 + i] = wpa->mac_ap[i]; + for (int i = 0; i < 12; i++) block[4 + i] = 0; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + memcpy (block_ptr + 0, wpa->anonce, 32); + memcpy (block_ptr + 32, auth_packet->wpa_key_nonce, 32); + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + block[0] = wpa->keymic[0]; + block[1] = wpa->keymic[1]; + block[2] = wpa->keymic[2]; + block[3] = wpa->keymic[3]; + + md5_transform (block + 0, block + 4, block + 8, block + 12, hash); + + // make all this stuff unique + + digest[0] = hash[0]; + digest[1] = hash[1]; + digest[2] = hash[2]; + digest[3] = hash[3]; + } + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const wpa_t *wpa = (const wpa_t *) esalt_buf; + + int line_len = 0; + + const u8 *mac_ap = (const u8 *) wpa->mac_ap; + const u8 *mac_sta = (const u8 *) wpa->mac_sta; + + if (wpa->type == 1) + { + u32_to_hex (wpa->pmkid[0], (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (wpa->pmkid[1], (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (wpa->pmkid[2], (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (wpa->pmkid[3], (u8 *) line_buf + line_len); line_len += 8; + } + else if (wpa->type == 2) + { + u32_to_hex (byte_swap_32 (wpa->keymic[0]), (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (byte_swap_32 (wpa->keymic[1]), (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (byte_swap_32 (wpa->keymic[2]), (u8 *) line_buf + line_len); line_len += 8; + u32_to_hex (byte_swap_32 (wpa->keymic[3]), (u8 *) line_buf + line_len); line_len += 8; + } + + line_buf[line_len] = ':'; + + line_len++; + + if (need_hexify ((const u8 *) wpa->essid_buf, wpa->essid_len, ':', 0) == true) + { + char tmp_buf[128]; + + int tmp_len = 0; + + tmp_buf[tmp_len++] = '$'; + tmp_buf[tmp_len++] = 'H'; + tmp_buf[tmp_len++] = 'E'; + tmp_buf[tmp_len++] = 'X'; + tmp_buf[tmp_len++] = '['; + + exec_hexify ((const u8 *) wpa->essid_buf, wpa->essid_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += wpa->essid_len * 2; + + tmp_buf[tmp_len++] = ']'; + + tmp_buf[tmp_len++] = 0; + + line_len += snprintf (line_buf + line_len, line_size - line_len, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + tmp_buf); + } + else + { + line_len += snprintf (line_buf + line_len, line_size - line_len, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + mac_ap[0], + mac_ap[1], + mac_ap[2], + mac_ap[3], + mac_ap[4], + mac_ap[5], + mac_sta[0], + mac_sta[1], + mac_sta[2], + mac_sta[3], + mac_sta[4], + mac_sta[5], + (const char *) wpa->essid_buf); + } + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = module_benchmark_mask; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = module_hash_binary_count; + module_ctx->module_hash_binary_parse = module_hash_binary_parse; + module_ctx->module_hash_binary_save = module_hash_binary_save; + module_ctx->module_hash_decode_potfile = module_hash_decode_potfile; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = module_hash_encode_potfile; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = module_hash_init_selftest; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = module_hlfmt_disable; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = module_potfile_custom_check; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22100.c b/src/modules/module_22100.c new file mode 100644 index 000000000..afbc29550 --- /dev/null +++ b/src/modules/module_22100.c @@ -0,0 +1,490 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_sha256.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; +static const char *HASH_NAME = "BitLocker"; +static const u64 KERN_TYPE = 22100; +static const u32 OPTI_TYPE = OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$bitlocker$1$16$6f972989ddc209f1eccf07313a7266a2$1048576$12$3a33a8eaff5e6f81d907b591$60$316b0f6d4cb445fb056f0e3e0633c413526ff4481bbf588917b70a4e8f8075f5ceb45958a800b42cb7ff9b7f5e17c6145bf8561ea86f52d3592059fb"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +#define ITERATION_BITLOCKER 0x100000 +#define SALT_LEN_BITLOCKER 16 +#define IV_LEN_BITLOCKER 12 +#define DATA_LEN_BITLOCKER 60 + +typedef struct bitlocker +{ + u32 type; + u32 iv[4]; + u32 data[15]; + u32 wb_ke_pc[ITERATION_BITLOCKER][48]; + +} bitlocker_t; + +typedef struct bitlocker_tmp +{ + u32 last_hash[8]; + u32 init_hash[8]; + +} bitlocker_tmp_t; + +static const char *SIGNATURE_BITLOCKER = "$bitlocker$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll -D FORCE_DISABLE_SHM"); + } + + // AMD-GPU-PRO + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (bitlocker_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (bitlocker_tmp_t); + + return tmp_size; +} + +u32 module_kernel_loops_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_min = 4096; + + return kernel_loops_min; +} + +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 4096; + + return kernel_loops_max; +} + +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // https://docs.microsoft.com/en-us/windows/security/information-protection/bitlocker/bitlocker-group-policy-settings + // The startup PIN must have a minimum length of 4 digits, and it can have a maximum length of 20 digits. By default, the minimum PIN length is 6. + + const u32 pw_min = 4; + + return pw_min; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + bitlocker_t *bitlocker = (bitlocker_t *) esalt_buf; + + token_t token; + + token.token_cnt = 9; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_BITLOCKER; + + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 1; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '$'; + token.len_min[2] = 2; + token.len_max[2] = 2; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[3] = '$'; + token.len_min[3] = 32; + token.len_max[3] = 32; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '$'; + token.len_min[4] = 7; + token.len_max[4] = 7; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[5] = '$'; + token.len_min[5] = 2; + token.len_max[5] = 2; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[6] = '$'; + token.len_min[6] = 24; + token.len_max[6] = 24; + token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[7] = '$'; + token.len_min[7] = 2; + token.len_max[7] = 2; + token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[8] = '$'; + token.len_min[8] = 120; + token.len_max[8] = 120; + token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // type + + const u8 *type_pos = token.buf[1]; + + const u32 type = hc_strtoul ((const char *) type_pos, NULL, 10); + + if ((type != 0) && (type != 1)) return PARSER_SALT_VALUE; + + bitlocker->type = type; + + // salt + + const u8 *salt_len_pos = token.buf[2]; + + const u32 salt_len = hc_strtoul ((const char *) salt_len_pos, NULL, 10); + + if (salt_len != SALT_LEN_BITLOCKER) return PARSER_SALT_LENGTH; + + const u8 *salt_pos = token.buf[3]; + + salt->salt_buf[0] = hex_to_u32 (salt_pos + 0); + salt->salt_buf[1] = hex_to_u32 (salt_pos + 8); + salt->salt_buf[2] = hex_to_u32 (salt_pos + 16); + salt->salt_buf[3] = hex_to_u32 (salt_pos + 24); + + salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); + salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); + salt->salt_buf[2] = byte_swap_32 (salt->salt_buf[2]); + salt->salt_buf[3] = byte_swap_32 (salt->salt_buf[3]); + + salt->salt_len = SALT_LEN_BITLOCKER; + + // wb_ke_pc + + for (int i = 0; i < ITERATION_BITLOCKER; i++) + { + u32 tmp[64]; + + tmp[ 0] = salt->salt_buf[0]; + tmp[ 1] = salt->salt_buf[1]; + tmp[ 2] = salt->salt_buf[2]; + tmp[ 3] = salt->salt_buf[3]; + tmp[ 4] = byte_swap_32 (i); + tmp[ 5] = 0; + tmp[ 6] = 0x80000000; + tmp[ 7] = 0; + tmp[ 8] = 0; + tmp[ 9] = 0; + tmp[10] = 0; + tmp[11] = 0; + tmp[12] = 0; + tmp[13] = 0; + tmp[14] = 0; + tmp[15] = 88 * 8; + + #define hc_rotl32_S rotl32 + + for (int j = 16; j < 64; j++) + { + tmp[j] = SHA256_EXPAND_S (tmp[j - 2], tmp[j - 7], tmp[j - 15], tmp[j - 16]); + } + + for (int j = 0; j < 48; j++) + { + bitlocker->wb_ke_pc[i][j] = tmp[16 + j]; + } + } + + // iter + + const u8 *iter_pos = token.buf[4]; + + const u32 iter = hc_strtoul ((const char *) iter_pos, NULL, 10); + + if (iter != ITERATION_BITLOCKER) return PARSER_SALT_VALUE; + + salt->salt_iter = ITERATION_BITLOCKER; + + // IV (nonce) + + const u8 *iv_len_pos = token.buf[5]; // aka nonce_len + + const u32 iv_len = hc_strtoul ((const char *) iv_len_pos, NULL, 10); + + if (iv_len != IV_LEN_BITLOCKER) return PARSER_SALT_LENGTH; + + const u8 *iv_pos = token.buf[6]; + + u32 iv[4] = { 0 }; + + iv[0] = hex_to_u32 (iv_pos + 0); + iv[1] = hex_to_u32 (iv_pos + 8); + iv[2] = hex_to_u32 (iv_pos + 16); + + iv[0] = byte_swap_32 (iv[0]); + iv[1] = byte_swap_32 (iv[1]); + iv[2] = byte_swap_32 (iv[2]); + + // prefix 0x02 and shift-right by 1 byte: + + iv[3] = (iv[2] << 24) | 0x01; // 0x01 because we start with the VMK (skip MAC) + iv[2] = (iv[1] << 24) | (iv[2] >> 8); + iv[1] = (iv[0] << 24) | (iv[1] >> 8); + iv[0] = (0x02 << 24) | (iv[0] >> 8); // 15 - strlen (iv) - 1 = 14 - 12 = 0x02 + + bitlocker->iv[0] = iv[0]; + bitlocker->iv[1] = iv[1]; + bitlocker->iv[2] = iv[2]; + bitlocker->iv[3] = iv[3]; + + // data and digest: + + const u8 *data_len_pos = token.buf[7]; + + const u32 data_len = hc_strtoul ((const char *) data_len_pos, NULL, 10); + + if (data_len != DATA_LEN_BITLOCKER) return PARSER_SALT_LENGTH; + + const u8 *data_pos = token.buf[8]; + + for (u32 i = 0, j = 0; i < DATA_LEN_BITLOCKER / 4; i += 1, j += 8) + { + bitlocker->data[i] = hex_to_u32 (data_pos + j); + + bitlocker->data[i] = byte_swap_32 (bitlocker->data[i]); + } + + // fake digest: + + memcpy (digest, bitlocker->data, 16); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + bitlocker_t *bitlocker = (bitlocker_t *) esalt_buf; + + // type + + u32 type = bitlocker->type; + + // salt + + #define SALT_HEX_LEN SALT_LEN_BITLOCKER * 2 + 1 + + char salt_buf[SALT_HEX_LEN] = { 0 }; + + for (u32 i = 0, j = 0; i < SALT_LEN_BITLOCKER / 4; i += 1, j += 8) + { + snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", salt->salt_buf[i]); + } + + // iv + + u32 iv[4] = { 0 }; + + iv[0] = bitlocker->iv[0]; + iv[1] = bitlocker->iv[1]; + iv[2] = bitlocker->iv[2]; + iv[3] = bitlocker->iv[3]; + + // remove 0x02 from start (left-shift by 1 byte): + + iv[0] = (iv[0] << 8) | (iv[1] >> 24); + iv[1] = (iv[1] << 8) | (iv[2] >> 24); + iv[2] = (iv[2] << 8) | (iv[3] >> 24); + iv[3] = 0; + + #define IV_HEX_LEN IV_LEN_BITLOCKER * 2 + 1 + + char iv_buf[IV_HEX_LEN] = { 0 }; + + for (u32 i = 0, j = 0; i < IV_LEN_BITLOCKER / 4; i += 1, j += 8) + { + snprintf (iv_buf + j, IV_HEX_LEN - j, "%08x", iv[i]); + } + + // data + + #define DATA_HEX_LEN DATA_LEN_BITLOCKER * 2 + 1 + + char data_buf[DATA_HEX_LEN] = { 0 }; + + for (u32 i = 0, j = 0; i < DATA_LEN_BITLOCKER / 4; i += 1, j += 8) + { + snprintf (data_buf + j, DATA_HEX_LEN - j, "%08x", bitlocker->data[i]); + } + + // output + + int line_len = snprintf (line_buf, line_size, "$bitlocker$%i$%i$%s$%i$%i$%s$%i$%s", + type, + SALT_LEN_BITLOCKER, + salt_buf, + ITERATION_BITLOCKER, + IV_LEN_BITLOCKER, + iv_buf, + DATA_LEN_BITLOCKER, + data_buf); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22200.c b/src/modules/module_22200.c new file mode 100644 index 000000000..060cdea68 --- /dev/null +++ b/src/modules/module_22200.c @@ -0,0 +1,280 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 14; +static const u32 DGST_POS1 = 15; +static const u32 DGST_POS2 = 6; +static const u32 DGST_POS3 = 7; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; +static const char *HASH_NAME = "Citrix NetScaler (SHA512)"; +static const u64 KERN_TYPE = 22200; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_PREPENDED_SALT + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "2f9282ade42ce148175dc3b4d8b5916dae5211eee49886c3f7cc768f6b9f2eb982a5ac2f2672a0223999bfd15349093278adf12f6276e8b61dacf5572b3f93d0b4fa886ce"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const char *SIGNATURE_NETSCALER = "2"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + token_t token; + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETSCALER; + + token.len[0] = 1; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + + token.len[2] = 128; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + memcpy (salt->salt_buf, salt_pos, salt_len); + + salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); + salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); + + salt->salt_len = salt_len; + + // hash + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u64 (hash_pos + 0); + digest[1] = hex_to_u64 (hash_pos + 16); + digest[2] = hex_to_u64 (hash_pos + 32); + digest[3] = hex_to_u64 (hash_pos + 48); + digest[4] = hex_to_u64 (hash_pos + 64); + digest[5] = hex_to_u64 (hash_pos + 80); + digest[6] = hex_to_u64 (hash_pos + 96); + digest[7] = hex_to_u64 (hash_pos + 112); + + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= SHA512M_A; + digest[1] -= SHA512M_B; + digest[2] -= SHA512M_C; + digest[3] -= SHA512M_D; + digest[4] -= SHA512M_E; + digest[5] -= SHA512M_F; + digest[6] -= SHA512M_G; + digest[7] -= SHA512M_H; + } + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u64 *digest = (const u64 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u64 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += SHA512M_A; + tmp[1] += SHA512M_B; + tmp[2] += SHA512M_C; + tmp[3] += SHA512M_D; + tmp[4] += SHA512M_E; + tmp[5] += SHA512M_F; + tmp[6] += SHA512M_G; + tmp[7] += SHA512M_H; + } + + tmp[0] = byte_swap_64 (tmp[0]); + tmp[1] = byte_swap_64 (tmp[1]); + tmp[2] = byte_swap_64 (tmp[2]); + tmp[3] = byte_swap_64 (tmp[3]); + tmp[4] = byte_swap_64 (tmp[4]); + tmp[5] = byte_swap_64 (tmp[5]); + tmp[6] = byte_swap_64 (tmp[6]); + tmp[7] = byte_swap_64 (tmp[7]); + + u32 tmp_salt[2]; + + tmp_salt[0] = byte_swap_32 (salt->salt_buf[0]); + tmp_salt[1] = byte_swap_32 (salt->salt_buf[1]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + out_buf[0] = '2'; out_len += 1; + + memcpy (out_buf + out_len, tmp_salt, 8); out_len += 8; + + u64_to_hex (tmp[0], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[1], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[2], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[3], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[4], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[5], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[6], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[7], out_buf + out_len); out_len += 16; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22300.c b/src/modules/module_22300.c new file mode 100644 index 000000000..9432c3a27 --- /dev/null +++ b/src/modules/module_22300.c @@ -0,0 +1,251 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "sha256($salt.$pass.$salt)"; +static const u64 KERN_TYPE = 22300; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "755a8ce4e0cf0baee41d714aa35c9fca803106608f718f973eab006578285007:11265"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + token_t token; + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len_min[0] = 64; + token.len_max[0] = 64; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= SHA256M_A; + digest[1] -= SHA256M_B; + digest[2] -= SHA256M_C; + digest[3] -= SHA256M_D; + digest[4] -= SHA256M_E; + digest[5] -= SHA256M_F; + digest[6] -= SHA256M_G; + digest[7] -= SHA256M_H; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += SHA256M_A; + tmp[1] += SHA256M_B; + tmp[2] += SHA256M_C; + tmp[3] += SHA256M_D; + tmp[4] += SHA256M_E; + tmp[5] += SHA256M_F; + tmp[6] += SHA256M_G; + tmp[7] += SHA256M_H; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); + tmp[5] = byte_swap_32 (tmp[5]); + tmp[6] = byte_swap_32 (tmp[6]); + tmp[7] = byte_swap_32 (tmp[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[4], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[5], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[6], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[7], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22301.c b/src/modules/module_22301.c new file mode 100644 index 000000000..cda57a6e7 --- /dev/null +++ b/src/modules/module_22301.c @@ -0,0 +1,253 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "Telegram client app passcode (SHA256)"; +static const u64 KERN_TYPE = 22300; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$telegram$0*518c001aeb3b4ae96c6173be4cebe60a85f67b1e087b045935849e2f815b5e41*25184098058621950709328221838128"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const char *SIGNATURE_TELEGRAM = "$telegram$"; + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + token_t token; + + token.token_cnt = 4; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_TELEGRAM; + + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.len_min[1] = 1; + token.len_max[1] = 1; + token.sep[1] = '*'; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.len_min[2] = 64; + token.len_max[2] = 64; + token.sep[2] = '*'; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[3] = 32; + token.len_max[3] = 32; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *version_pos = token.buf[1]; + + if (version_pos[0] != '0') return (PARSER_SALT_VALUE); + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= SHA256M_A; + digest[1] -= SHA256M_B; + digest[2] -= SHA256M_C; + digest[3] -= SHA256M_D; + digest[4] -= SHA256M_E; + digest[5] -= SHA256M_F; + digest[6] -= SHA256M_G; + digest[7] -= SHA256M_H; + } + + const u8 *salt_pos = token.buf[3]; + + salt->salt_buf[0] = hex_to_u32 (salt_pos + 0); + salt->salt_buf[1] = hex_to_u32 (salt_pos + 8); + salt->salt_buf[2] = hex_to_u32 (salt_pos + 16); + salt->salt_buf[3] = hex_to_u32 (salt_pos + 24); + + salt->salt_len = 16; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += SHA256M_A; + tmp[1] += SHA256M_B; + tmp[2] += SHA256M_C; + tmp[3] += SHA256M_D; + tmp[4] += SHA256M_E; + tmp[5] += SHA256M_F; + tmp[6] += SHA256M_G; + tmp[7] += SHA256M_H; + } + + const int line_len = snprintf (line_buf, line_size, "%s%i*%08x%08x%08x%08x%08x%08x%08x%08x*%08x%08x%08x%08x", + SIGNATURE_TELEGRAM, + 0, + tmp[0], + tmp[1], + tmp[2], + tmp[3], + tmp[4], + tmp[5], + tmp[6], + tmp[7], + byte_swap_32 (salt->salt_buf[0]), + byte_swap_32 (salt->salt_buf[1]), + byte_swap_32 (salt->salt_buf[2]), + byte_swap_32 (salt->salt_buf[3])); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22400.c b/src/modules/module_22400.c new file mode 100644 index 000000000..024e9a8cd --- /dev/null +++ b/src/modules/module_22400.c @@ -0,0 +1,349 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE; +static const char *HASH_NAME = "AES Crypt (SHA256)"; +static const u64 KERN_TYPE = 22400; +static const u32 OPTI_TYPE = 0; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$aescrypt$1*efc648908ca7ec727f37f3316dfd885c*eff5c87a35545406a57b56de57bd0554*3a66401271aec08cbd10cf2070332214093a33f36bd0dced4a4bb09fab817184*6a3c49fea0cafb19190dc4bdadb787e73b1df244c51780beef912598bd3bdf7e"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +#define ITERATION_AESCRYPT 0x2000 +#define SALT_LEN_AESCRYPT 16 +#define IV_LEN_AESCRYPT 16 +#define KEY_LEN_AESCRYPT 32 + +typedef struct aescrypt +{ + u32 iv[4]; + u32 key[8]; + +} aescrypt_t; + +typedef struct aescrypt_tmp +{ + u32 pass[144]; + int len; + +} aescrypt_tmp_t; + +static const char *SIGNATURE_AESCRYPT = "$aescrypt$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (aescrypt_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (aescrypt_tmp_t); + + return tmp_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + aescrypt_t *aescrypt = (aescrypt_t *) esalt_buf; + + token_t token; + + token.token_cnt = 6; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_AESCRYPT; + + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 1; + token.len_max[1] = 1; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '*'; + token.len_min[2] = 32; + token.len_max[2] = 32; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len_min[3] = 32; + token.len_max[3] = 32; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '*'; + token.len_min[4] = 64; + token.len_max[4] = 64; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[5] = '*'; + token.len_min[5] = 64; + token.len_max[5] = 64; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // version + + const u8 *version_pos = token.buf[1]; + + const u32 version = hc_strtoul ((const char *) version_pos, NULL, 10); + + if (version != 1) return PARSER_SALT_VALUE; + + // salt + + const u8 *salt_pos = token.buf[2]; + + salt->salt_buf[0] = hex_to_u32 (salt_pos + 0); + salt->salt_buf[1] = hex_to_u32 (salt_pos + 8); + salt->salt_buf[2] = hex_to_u32 (salt_pos + 16); + salt->salt_buf[3] = hex_to_u32 (salt_pos + 24); + + salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); + salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); + salt->salt_buf[2] = byte_swap_32 (salt->salt_buf[2]); + salt->salt_buf[3] = byte_swap_32 (salt->salt_buf[3]); + + salt->salt_len = SALT_LEN_AESCRYPT; + + salt->salt_iter = ITERATION_AESCRYPT - 1; + + // IV + + const u8 *iv_pos = token.buf[3]; + + aescrypt->iv[0] = hex_to_u32 (iv_pos + 0); + aescrypt->iv[1] = hex_to_u32 (iv_pos + 8); + aescrypt->iv[2] = hex_to_u32 (iv_pos + 16); + aescrypt->iv[3] = hex_to_u32 (iv_pos + 24); + + aescrypt->iv[0] = byte_swap_32 (aescrypt->iv[0]); + aescrypt->iv[1] = byte_swap_32 (aescrypt->iv[1]); + aescrypt->iv[2] = byte_swap_32 (aescrypt->iv[2]); + aescrypt->iv[3] = byte_swap_32 (aescrypt->iv[3]); + + // key + + const u8 *key_pos = token.buf[4]; + + for (u32 i = 0, j = 0; i < 8; i += 1, j += 8) + { + aescrypt->key[i] = hex_to_u32 (key_pos + j); + + aescrypt->key[i] = byte_swap_32 (aescrypt->key[i]); + } + + // digest + + const u8 *hmac_pos = token.buf[5]; + + for (u32 i = 0, j = 0; i < 8; i += 1, j += 8) + { + digest[i] = hex_to_u32 (hmac_pos + j); + + digest[i] = byte_swap_32 (digest[i]); + } + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + aescrypt_t *aescrypt = (aescrypt_t *) esalt_buf; + + // salt + + #define SALT_HEX_LEN SALT_LEN_AESCRYPT * 2 + 1 + + char salt_buf[SALT_HEX_LEN] = { 0 }; + + for (u32 i = 0, j = 0; i < SALT_LEN_AESCRYPT / 4; i += 1, j += 8) + { + snprintf (salt_buf + j, SALT_HEX_LEN - j, "%08x", salt->salt_buf[i]); + } + + // iv + + #define IV_HEX_LEN IV_LEN_AESCRYPT * 2 + 1 + + char iv_buf[IV_HEX_LEN] = { 0 }; + + for (u32 i = 0, j = 0; i < IV_LEN_AESCRYPT / 4; i += 1, j += 8) + { + snprintf (iv_buf + j, IV_HEX_LEN - j, "%08x", aescrypt->iv[i]); + } + + // key + + #define KEY_HEX_LEN KEY_LEN_AESCRYPT * 2 + 1 + + char key_buf[KEY_HEX_LEN] = { 0 }; + + for (u32 i = 0, j = 0; i < KEY_LEN_AESCRYPT / 4; i += 1, j += 8) + { + snprintf (key_buf + j, KEY_HEX_LEN - j, "%08x", aescrypt->key[i]); + } + + // output + + int line_len = snprintf (line_buf, line_size, "%s%i*%s*%s*%s*%08x%08x%08x%08x%08x%08x%08x%08x", + SIGNATURE_AESCRYPT, + 1, + salt_buf, + iv_buf, + key_buf, + digest[0], + digest[1], + digest[2], + digest[3], + digest[4], + digest[5], + digest[6], + digest[7]); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_22500.c b/src/modules/module_22500.c new file mode 100644 index 000000000..2a8405de0 --- /dev/null +++ b/src/modules/module_22500.c @@ -0,0 +1,226 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER; +static const char *HASH_NAME = "MultiBit Classic .key (MD5)"; +static const u64 KERN_TYPE = 22500; +static const u32 OPTI_TYPE = OPTI_TYPE_EARLY_SKIP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$multibit$1*e5912fe5c84af3d5*5f0391c219e8ef62c06505b1f6232858f5bcaa739c2b471d45dd0bd8345334de"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const char *SIGNATURE_MULTIBIT = "$multibit$"; + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + u32 pw_max = PW_MAX; + + if (optimized_kernel == true) + { + pw_max = 31; // 55 - 8 (salt) - 16 (key1/key2) + } + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + token_t token; + + token.token_cnt = 4; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_MULTIBIT; + + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len_min[1] = 1; + token.len_max[1] = 1; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '*'; + token.len_min[2] = 16; + token.len_max[2] = 16; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '*'; + token.len_min[3] = 64; + token.len_max[3] = 64; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // version + + const u8 *version_pos = token.buf[1]; + + const u32 version = hc_strtoul ((const char *) version_pos, NULL, 10); + + if (version != 1) return PARSER_SALT_VALUE; + + // salt + + const u8 *salt_pos = token.buf[2]; + + salt->salt_buf[0] = hex_to_u32 (salt_pos + 0); + salt->salt_buf[1] = hex_to_u32 (salt_pos + 8); + + // data + + const u8 *data_pos = token.buf[3]; + + salt->salt_buf[2] = hex_to_u32 (data_pos + 0); + salt->salt_buf[3] = hex_to_u32 (data_pos + 8); + salt->salt_buf[4] = hex_to_u32 (data_pos + 16); + salt->salt_buf[5] = hex_to_u32 (data_pos + 24); + salt->salt_buf[6] = hex_to_u32 (data_pos + 32); + salt->salt_buf[7] = hex_to_u32 (data_pos + 40); + salt->salt_buf[8] = hex_to_u32 (data_pos + 48); + salt->salt_buf[9] = hex_to_u32 (data_pos + 56); + + salt->salt_len = 40; // 8 + 32; + + // fake hash + + digest[0] = salt->salt_buf[2]; + digest[1] = salt->salt_buf[3]; + digest[2] = salt->salt_buf[4]; + digest[3] = salt->salt_buf[5]; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + int line_len = snprintf (line_buf, line_size, "%s%i*%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", + SIGNATURE_MULTIBIT, + 1, + byte_swap_32 (salt->salt_buf[0]), + byte_swap_32 (salt->salt_buf[1]), + byte_swap_32 (salt->salt_buf[2]), + byte_swap_32 (salt->salt_buf[3]), + byte_swap_32 (salt->salt_buf[4]), + byte_swap_32 (salt->salt_buf[5]), + byte_swap_32 (salt->salt_buf[6]), + byte_swap_32 (salt->salt_buf[7]), + byte_swap_32 (salt->salt_buf[8]), + byte_swap_32 (salt->salt_buf[9])); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/mpsp.c b/src/mpsp.c index f69f14fba..2ab211833 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -217,6 +217,13 @@ static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, const u32 *in_buf, size_t { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + if (css_cnt == 256) + { + event_log_error (hashcat_ctx, "Invalid mask length."); + + return -1; + } + cs_t *cs = &css[css_cnt]; size_t css_uniq_sz = CHARSIZ * sizeof (u32); @@ -254,7 +261,7 @@ static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, const u32 *in_buf, size_t static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret) { - const user_options_t *user_options = hashcat_ctx->user_options; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; size_t in_pos; @@ -317,7 +324,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_ } else { - if (user_options->hex_charset == true) + if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) { in_pos++; @@ -362,7 +369,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, cs_t *css_buf, u32 *css_cnt) { - const user_options_t *user_options = hashcat_ctx->user_options; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; memset (css_buf, 0, 256 * sizeof (cs_t)); @@ -430,7 +437,7 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l } else { - if (user_options->hex_charset == true) + if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) { mask_pos++; @@ -488,7 +495,7 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len, char *new_mask_buf) { - const user_options_t *user_options = hashcat_ctx->user_options; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; u32 mask_pos; @@ -512,7 +519,7 @@ static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_b } else { - if (user_options->hex_charset == true) + if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) { mask_pos++; @@ -1061,7 +1068,7 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask, const char if (user_options->increment == true) { - const u32 mask_length = mp_get_length (mask); + const u32 mask_length = mp_get_length (mask, hashconfig->opts_type); u32 increment_min = user_options->increment_min; u32 increment_max = user_options->increment_max; @@ -1129,17 +1136,34 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask, const char return 0; } -u32 mp_get_length (const char *mask) +u32 mp_get_length (const char *mask, const u32 opts_type) { + bool ignore_next = false; + u32 len = 0; const size_t mask_len = strlen (mask); for (size_t i = 0; i < mask_len; i++) { - if (mask[i] == '?') i++; + if (ignore_next == true) + { + ignore_next = false; + } + else + { + if (mask[i] == '?') + { + ignore_next = true; + } - len++; + if (opts_type & OPTS_TYPE_PT_HEX) + { + ignore_next = true; + } + + len++; + } } return len; @@ -1260,7 +1284,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (user_options->benchmark == true) { - pw_min = mp_get_length (mask_ctx->mask); + pw_min = mp_get_length (mask_ctx->mask, hashconfig->opts_type); pw_max = pw_min; } diff --git a/src/outfile.c b/src/outfile.c index 8dc949b50..a0498b902 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -5,6 +5,7 @@ #include "common.h" #include "types.h" +#include "memory.h" #include "event.h" #include "convert.h" #include "mpsp.h" @@ -16,6 +17,101 @@ #include "locking.h" #include "outfile.h" +u32 outfile_format_parse (const char *format_string) +{ + if (format_string == NULL) return 0; + + char *format = hcstrdup (format_string); + + if (format == NULL) return 0; + + char *saveptr = NULL; + + char *next = strtok_r (format, ",", &saveptr); + + if (next == NULL) + { + hcfree (format); + + return 0; + } + + u32 outfile_format = 0; + + do + { + const int tok_len = strlen (next); + + // reject non-numbers: + + if (is_valid_digit_string ((const u8 *) next, tok_len) == false) + { + outfile_format = 0; + break; + } + + // string to number conversion: + + const u32 num = hc_strtoul (next, NULL, 10); + + if (num == 0) + { + outfile_format = 0; + break; + } + + if (num > 31) + { + outfile_format = 0; + break; + } + + // to bitmask: + + const u32 bit = 1 << (num - 1); + + bool accepted = false; + + switch (bit) + { + // allowed formats: + case OUTFILE_FMT_HASH: + case OUTFILE_FMT_PLAIN: + case OUTFILE_FMT_HEXPLAIN: + case OUTFILE_FMT_CRACKPOS: + case OUTFILE_FMT_TIME_ABS: + case OUTFILE_FMT_TIME_REL: + accepted = true; + break; + // NOT acceptable formats: + default: + accepted = false; + break; + } + + if (accepted == false) + { + outfile_format = 0; + break; + } + + // the user should specify any format at most once: + + if (outfile_format & bit) + { + outfile_format = 0; + break; + } + + outfile_format |= bit; + + } while ((next = strtok_r ((char *) NULL, ",", &saveptr)) != NULL); + + hcfree (format); + + return outfile_format; +} + int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len) { const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; @@ -391,10 +487,10 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx) outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; user_options_t *user_options = hashcat_ctx->user_options; - outfile_ctx->fp.pfp = NULL; - outfile_ctx->filename = user_options->outfile; - outfile_ctx->outfile_format = user_options->outfile_format; - outfile_ctx->outfile_autohex = user_options->outfile_autohex; + outfile_ctx->fp.pfp = NULL; + outfile_ctx->filename = user_options->outfile; + outfile_ctx->outfile_format = user_options->outfile_format; + outfile_ctx->outfile_autohex = user_options->outfile_autohex; return 0; } @@ -437,6 +533,8 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx) if (outfile_ctx->fp.pfp == NULL) return; + hc_unlockfile (&outfile_ctx->fp); + hc_fclose (&outfile_ctx->fp); } @@ -445,6 +543,7 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const user_options_t *user_options = hashcat_ctx->user_options; outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; const u32 outfile_format = (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_HEXIFY) ? 5 : outfile_ctx->outfile_format; @@ -458,7 +557,7 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou tmp_len += user_len; - if (outfile_format & (OUTFILE_FMT_HASH | OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) + if (outfile_format & (OUTFILE_FMT_TIME_ABS | OUTFILE_FMT_TIME_REL | OUTFILE_FMT_HASH | OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) { tmp_buf[tmp_len] = hashconfig->separator; @@ -467,6 +566,47 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou } } + if (outfile_format & OUTFILE_FMT_TIME_ABS) + { + time_t now; + + time (&now); + + tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_LARGE - tmp_len, "%" PRIu64, (u64) now); + + if (outfile_format & (OUTFILE_FMT_TIME_REL | OUTFILE_FMT_HASH | OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) + { + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; + } + } + + if (outfile_format & OUTFILE_FMT_TIME_REL) + { + time_t time_now; + + time (&time_now); + + time_t time_started = status_ctx->runtime_start; + + u64 diff = 0; + + if (time_now > time_started) // should always be true, but you never know + { + diff = (u64) time_now - (u64) time_started; + } + + tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_LARGE - tmp_len, "%" PRIu64, diff); + + if (outfile_format & (OUTFILE_FMT_HASH | OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) + { + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; + } + } + if (outfile_format & OUTFILE_FMT_HASH) { memcpy (tmp_buf + tmp_len, out_buf, out_len); diff --git a/src/outfile_check.c b/src/outfile_check.c index 84d47b1e9..02e3cb4fa 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -37,7 +37,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) salt_t *salts_buf = hashes->salts_buf; const u32 salts_cnt = hashes->salts_cnt; - char *digests_buf = hashes->digests_buf; + char *digests_buf = (char *) hashes->digests_buf; char *root_directory = outcheck_ctx->root_directory; u32 outfile_check_timer = user_options->outfile_check_timer; diff --git a/src/potfile.c b/src/potfile.c index 58a247406..784df9373 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -74,6 +74,16 @@ int sort_pot_tree_by_hash (const void *v1, const void *v2) return sort_by_hash (h1, h2, hc); } +// this function is used to reproduce the hash ordering based on the original input hash file + +int sort_pot_orig_line (const void *v1, const void *v2) +{ + const pot_orig_line_entry_t *t1 = (const pot_orig_line_entry_t *) v1; + const pot_orig_line_entry_t *t2 = (const pot_orig_line_entry_t *) v2; + + return t1->line_pos > t2->line_pos; +} + // the problem with the GNU tdestroy () function is that it doesn't work with mingw etc // there are 2 alternatives: // 1. recursively delete the entries with entry->left and entry->right @@ -247,7 +257,7 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, cons int tmp_len = 0; - if (1) + if (true) { memcpy (tmp_buf + tmp_len, out_buf, out_len); @@ -347,7 +357,7 @@ void potfile_update_hashes (hashcat_ctx_t *hashcat_ctx, hash_t *hash_buf, char * // the main search function is this: - void **found = tfind (&search_entry, (void **) &tree, sort_pot_tree_by_hash); + void **found = (void **) tfind (&search_entry, (void **) &tree, sort_pot_tree_by_hash); if (found) { @@ -451,7 +461,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) // the following function searches if the "key" is already present and if not inserts the new entry: - void **found = tsearch (new_entry, (void **) &all_hashes_tree, sort_pot_tree_by_hash); + void **found = (void **) tsearch (new_entry, (void **) &all_hashes_tree, sort_pot_tree_by_hash); pot_tree_entry_t *found_entry = (pot_tree_entry_t *) *found; @@ -648,6 +658,9 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) u32 salts_cnt = hashes->salts_cnt; salt_t *salts_buf = hashes->salts_buf; + pot_orig_line_entry_t *final_buf = (pot_orig_line_entry_t *) hccalloc (hashes->hashes_cnt, sizeof (pot_orig_line_entry_t)); + u32 final_cnt = 0; + if (hashconfig->opts_type & OPTS_TYPE_HASH_SPLIT) { // this implementation will work for LM only @@ -757,7 +770,17 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, (u8 *) mixed_buf, mixed_len, 0, username, user_len, (char *) tmp_buf); - EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); + //EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_buf = (u8 *) hcmalloc (tmp_len); + + memcpy (final_buf[final_cnt].hash_buf, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_len = tmp_len; + + final_buf[final_cnt].line_pos = hash1->orig_line_pos; + + final_cnt++; } } } @@ -808,7 +831,6 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) tmp_buf[0] = 0; - // special case for collider modes: we do not use the $HEX[] format within the hash itself // therefore we need to convert the $HEX[] password into hexadecimal (without "$HEX[" and "]") @@ -837,11 +859,32 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, (u8 *) hash->pw_buf, hash->pw_len, 0, username, user_len, (char *) tmp_buf); } - EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); + //EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_buf = (u8 *) hcmalloc (tmp_len); + + memcpy (final_buf[final_cnt].hash_buf, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_len = tmp_len; + + final_buf[final_cnt].line_pos = hash->orig_line_pos; + + final_cnt++; } } } + qsort (final_buf, final_cnt, sizeof (pot_orig_line_entry_t), sort_pot_orig_line); + + for (u32 final_pos = 0; final_pos < final_cnt; final_pos++) + { + EVENT_DATA (EVENT_POTFILE_HASH_SHOW, final_buf[final_pos].hash_buf, final_buf[final_pos].hash_len); + + hcfree (final_buf[final_pos].hash_buf); + } + + hcfree (final_buf); + return 0; } @@ -857,6 +900,9 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) u32 salts_cnt = hashes->salts_cnt; salt_t *salts_buf = hashes->salts_buf; + pot_orig_line_entry_t *final_buf = (pot_orig_line_entry_t *) hccalloc (hashes->hashes_cnt, sizeof (pot_orig_line_entry_t)); + u32 final_cnt = 0; + if (hashconfig->opts_type & OPTS_TYPE_HASH_SPLIT) { // this implementation will work for LM only @@ -933,7 +979,17 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, NULL, 0, 0, username, user_len, (char *) tmp_buf); - EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len); + //EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_buf = (u8 *) hcmalloc (tmp_len); + + memcpy (final_buf[final_cnt].hash_buf, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_len = tmp_len; + + final_buf[final_cnt].line_pos = hash1->orig_line_pos; + + final_cnt++; } } } @@ -1008,10 +1064,31 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, NULL, 0, 0, username, user_len, (char *) tmp_buf); - EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len); + //EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_buf = (u8 *) hcmalloc (tmp_len); + + memcpy (final_buf[final_cnt].hash_buf, tmp_buf, tmp_len); + + final_buf[final_cnt].hash_len = tmp_len; + + final_buf[final_cnt].line_pos = hash->orig_line_pos; + + final_cnt++; } } } + qsort (final_buf, final_cnt, sizeof (pot_orig_line_entry_t), sort_pot_orig_line); + + for (u32 final_pos = 0; final_pos < final_cnt; final_pos++) + { + EVENT_DATA (EVENT_POTFILE_HASH_LEFT, final_buf[final_pos].hash_buf, final_buf[final_pos].hash_len); + + hcfree (final_buf[final_pos].hash_buf); + } + + hcfree (final_buf); + return 0; } diff --git a/src/rp.c b/src/rp.c index 2fdce44ca..63c0f5ba9 100644 --- a/src/rp.c +++ b/src/rp.c @@ -218,8 +218,8 @@ int generate_random_rule (char rule_buf[RP_RULE_SIZE], const u32 rp_gen_func_min #define INCR_POS if (++rule_pos == rule_len) return (-1) #define SET_NAME(rule,val) (rule)->cmds[rule_cnt] = ((val) & 0xff) << 0 -#define SET_P0(rule,val) INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 8) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 12); rule_pos += 3; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 8; } -#define SET_P1(rule,val) INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 16) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 20); rule_pos += 3; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 16; } +#define SET_P0(rule,val) do { INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 8) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 12); rule_pos += 3; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 8; } } while(0) +#define SET_P1(rule,val) do { INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 16) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 20); rule_pos += 3; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 16; } } while(0) #define GET_NAME(rule) rule_cmd = (((rule)->cmds[rule_cnt] >> 0) & 0xff) #define GET_P0(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 8) & 0xff) #define GET_P1(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 16) & 0xff) @@ -872,7 +872,7 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, const user_options_t *user_options = hashcat_ctx->user_options; u32 kernel_rules_cnt = 0; - kernel_rule_t *kernel_rules_buf = hccalloc (user_options->rp_gen, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (user_options->rp_gen, sizeof (kernel_rule_t)); char *rule_buf = (char *) hcmalloc (RP_RULE_SIZE); diff --git a/src/rp_cpu.c b/src/rp_cpu.c index 3070516ae..b9dc23e69 100644 --- a/src/rp_cpu.c +++ b/src/rp_cpu.c @@ -807,14 +807,16 @@ int _old_apply_rule (const char *rule, int rule_len, char in[RP_PASSWORD_SIZE], case RULE_OP_REJECT_NOT_CONTAIN: NEXT_RULEPOS (rule_pos); - char *match = strchr (out, rule_new[rule_pos]); - if (match != NULL) { - pos_mem = (int)(match - out); - } - else - { - return (RULE_RC_REJECT_ERROR); + const char *match = strchr (out, rule_new[rule_pos]); + if (match != NULL) + { + pos_mem = (int)(match - out); + } + else + { + return (RULE_RC_REJECT_ERROR); + } } break; diff --git a/src/selftest.c b/src/selftest.c index b299cb3eb..829f40f69 100644 --- a/src/selftest.c +++ b/src/selftest.c @@ -44,6 +44,27 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param // password : move the known password into a fake buffer + const u32 module_opts_type = module_ctx->module_opts_type (hashconfig, user_options, user_options_extra); + + pw_t tmp; + + memset (&tmp, 0, sizeof (tmp)); + + char *tmp_ptr = (char *) &tmp.i; + + const size_t tmp_len = strlen (hashconfig->st_pass); + + if (module_opts_type & OPTS_TYPE_PT_HEX) + { + tmp.pw_len = hex_decode ((const u8 *) hashconfig->st_pass, (const int) tmp_len, (u8 *) tmp_ptr); + } + else + { + memcpy (tmp_ptr, hashconfig->st_pass, tmp_len); + + tmp.pw_len = (u32) tmp_len; + } + u32 highest_pw_len = 0; if (user_options->slow_candidates == true) @@ -53,13 +74,15 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param device_param->kernel_params_buf32[30] = 1; } - pw_t pw; memset (&pw, 0, sizeof (pw)); + pw_t pw; + + memset (&pw, 0, sizeof (pw)); char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = tmp.pw_len; - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + memcpy (pw_ptr, tmp_ptr, pw_len); pw.pw_len = (u32) pw_len; @@ -87,9 +110,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = tmp.pw_len; - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + memcpy (pw_ptr, tmp_ptr, pw_len); pw.pw_len = (u32) pw_len; @@ -119,9 +142,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = tmp.pw_len; - memcpy (pw_ptr, hashconfig->st_pass, pw_len - 1); + memcpy (pw_ptr, tmp_ptr, pw_len - 1); pw.pw_len = (u32) pw_len - 1; @@ -136,7 +159,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *comb_ptr = (char *) &comb.i; - memcpy (comb_ptr, hashconfig->st_pass + pw_len - 1, 1); + memcpy (comb_ptr, tmp_ptr + pw_len - 1, 1); comb.pw_len = 1; @@ -178,7 +201,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { device_param->kernel_params_buf32[30] = 1; - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL) { pw_t pw; @@ -186,9 +209,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = tmp.pw_len; - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + memcpy (pw_ptr, tmp_ptr, pw_len); if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) { @@ -215,7 +238,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *bf_ptr = (char *) &bf.i; - memcpy (bf_ptr, hashconfig->st_pass, 1); + memcpy (bf_ptr, tmp_ptr, 1); if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) { @@ -223,7 +246,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param for (int i = 0, j = 0; i < 1; i += 1, j += 2) { - bf_ptr[j + 0] = hashconfig->st_pass[i]; + bf_ptr[j + 0] = tmp_ptr[i]; bf_ptr[j + 1] = 0; } } @@ -234,7 +257,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param for (int i = 0, j = 0; i < 1; i += 1, j += 2) { bf_ptr[j + 0] = 0; - bf_ptr[j + 1] = hashconfig->st_pass[i]; + bf_ptr[j + 1] = tmp_ptr[i]; } } @@ -264,9 +287,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = tmp.pw_len; - memcpy (pw_ptr + 1, hashconfig->st_pass + 1, pw_len - 1); + memcpy (pw_ptr + 1, tmp_ptr + 1, pw_len - 1); size_t new_pass_len = pw_len; @@ -276,7 +299,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2) { - pw_ptr[j + 0] = hashconfig->st_pass[i]; + pw_ptr[j + 0] = tmp_ptr[i]; pw_ptr[j + 1] = 0; } @@ -289,7 +312,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2) { pw_ptr[j + 0] = 0; - pw_ptr[j + 1] = hashconfig->st_pass[i]; + pw_ptr[j + 1] = tmp_ptr[i]; } new_pass_len *= 2; @@ -366,9 +389,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = tmp.pw_len; - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + memcpy (pw_ptr, tmp_ptr, pw_len); pw.pw_len = (u32) pw_len; @@ -432,7 +455,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; } - module_ctx->module_hook12 (device_param, hashes->st_hook_salts_buf, 0, 1); + module_ctx->module_hook12 (device_param, hashes->st_hook_salts_buf, 0, 0); if (device_param->is_cuda == true) { @@ -463,6 +486,11 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param device_param->kernel_params_buf32[29] = loop_left; if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 1, false, 0) == -1) return -1; + + if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED) + { + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, 1, false, 0) == -1) return -1; + } } if (hashconfig->opts_type & OPTS_TYPE_HOOK23) @@ -479,7 +507,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; } - module_ctx->module_hook23 (device_param, hashes->st_hook_salts_buf, 0, 1); + module_ctx->module_hook23 (device_param, hashes->st_hook_salts_buf, 0, 0); if (device_param->is_cuda == true) { @@ -523,30 +551,31 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX1, 1, false, 0) == -1) return -1; } - else if (hashconfig->opts_type & OPTS_TYPE_AUX2) + + if (hashconfig->opts_type & OPTS_TYPE_AUX2) { if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX2, 1, false, 0) == -1) return -1; } - else if (hashconfig->opts_type & OPTS_TYPE_AUX3) + + if (hashconfig->opts_type & OPTS_TYPE_AUX3) { if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX3, 1, false, 0) == -1) return -1; } - else + + if (hashconfig->opts_type & OPTS_TYPE_AUX4) { - if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0) == -1) return -1; + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX4, 1, false, 0) == -1) return -1; } } - else - { - if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0) == -1) return -1; - } + + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0) == -1) return -1; } device_param->spin_damp = spin_damp_sav; // check : check if cracked - u32 num_cracked; + u32 num_cracked = 0; if (device_param->is_cuda == true) { @@ -654,6 +683,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (num_cracked == 0) { hc_thread_mutex_lock (status_ctx->mux_display); + if (device_param->is_opencl == true) { event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! OpenCL kernel self-test failed.", device_param->device_id + 1); diff --git a/src/shared.c b/src/shared.c index 009322c48..05387f5e6 100644 --- a/src/shared.c +++ b/src/shared.c @@ -83,7 +83,7 @@ static const char *HASH_CATEGORY_RAW_HASH_AUTHENTICATED_STR = "Raw Hash, Authent static const char *HASH_CATEGORY_RAW_CIPHER_KPA_STR = "Raw Cipher, Known-Plaintext attack"; static const char *HASH_CATEGORY_GENERIC_KDF_STR = "Generic KDF"; static const char *HASH_CATEGORY_NETWORK_PROTOCOL_STR = "Network Protocols"; -static const char *HASH_CATEGORY_FORUM_SOFTWARE_STR = "Forums, CMS, E-Commerce, Frameworks"; +static const char *HASH_CATEGORY_FORUM_SOFTWARE_STR = "Forums, CMS, E-Commerce"; static const char *HASH_CATEGORY_DATABASE_SERVER_STR = "Database Server"; static const char *HASH_CATEGORY_NETWORK_SERVER_STR = "FTP, HTTP, SMTP, LDAP Server"; static const char *HASH_CATEGORY_RAW_CHECKSUM_STR = "Raw Checksum"; @@ -609,6 +609,27 @@ void hc_string_trim_trailing (char *s) s[new_len] = 0; } +int hc_get_processor_count () +{ + int cnt = 0; + + #if defined (_WIN) + + SYSTEM_INFO info; + + GetSystemInfo (&info); + + cnt = (int) info.dwNumberOfProcessors; + + #else + + cnt = (int) sysconf (_SC_NPROCESSORS_ONLN); + + #endif + + return cnt; +} + bool hc_same_files (char *file1, char *file2) { if ((file1 != NULL) && (file2 != NULL)) @@ -994,7 +1015,7 @@ static int rounds_count_length (const char *input_buf, const int input_len) if (memcmp (input_buf, rounds, 7) == 0) { - char *next_pos = strchr (input_buf + 8, '$'); + const char *next_pos = strchr (input_buf + 8, '$'); if (next_pos == NULL) return -1; @@ -1007,6 +1028,26 @@ static int rounds_count_length (const char *input_buf, const int input_len) return -1; } +const u8 *hc_strchr_next (const u8 *input_buf, const int input_len, const u8 separator) +{ + for (int i = 0; i < input_len; i++) + { + if (input_buf[i] == separator) return &input_buf[i]; + } + + return NULL; +} + +const u8 *hc_strchr_last (const u8 *input_buf, const int input_len, const u8 separator) +{ + for (int i = input_len - 1; i >= 0; i--) + { + if (input_buf[i] == separator) return &input_buf[i]; + } + + return NULL; +} + int input_tokenizer (const u8 *input_buf, const int input_len, token_t *token) { int len_left = input_len; @@ -1045,7 +1086,16 @@ int input_tokenizer (const u8 *input_buf, const int input_len, token_t *token) } } - const u8 *next_pos = (const u8 *) strchr ((const char *) token->buf[token_idx], token->sep[token_idx]); + const u8 *next_pos = NULL; + + if (token->attr[token_idx] & TOKEN_ATTR_SEPARATOR_FARTHEST) + { + next_pos = hc_strchr_last (token->buf[token_idx], len_left, token->sep[token_idx]); + } + else + { + next_pos = hc_strchr_next (token->buf[token_idx], len_left, token->sep[token_idx]); + } if (next_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); @@ -1092,6 +1142,16 @@ int input_tokenizer (const u8 *input_buf, const int input_len, token_t *token) if (token->len[token_idx] > token->len_max[token_idx]) return (PARSER_TOKEN_LENGTH); } + if (token->attr[token_idx] & TOKEN_ATTR_VERIFY_DIGIT) + { + if (is_valid_digit_string (token->buf[token_idx], token->len[token_idx]) == false) return (PARSER_TOKEN_ENCODING); + } + + if (token->attr[token_idx] & TOKEN_ATTR_VERIFY_FLOAT) + { + if (is_valid_float_string (token->buf[token_idx], token->len[token_idx]) == false) return (PARSER_TOKEN_ENCODING); + } + if (token->attr[token_idx] & TOKEN_ATTR_VERIFY_HEX) { if (is_valid_hex_string (token->buf[token_idx], token->len[token_idx]) == false) return (PARSER_TOKEN_ENCODING); diff --git a/src/slow_candidates.c b/src/slow_candidates.c index 222cc4a92..45af658e8 100644 --- a/src/slow_candidates.c +++ b/src/slow_candidates.c @@ -35,7 +35,7 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u char *line_buf = NULL; u32 line_len = 0; - while (1) + while (true) { HCFILE *fp = &extra_info_straight->fp; @@ -86,7 +86,7 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u char *line_buf = NULL; u32 line_len = 0; - while (1) + while (true) { get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len); @@ -121,10 +121,12 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u char *line_buf = extra_info_combi->scratch_buf; u32 line_len = 0; - while (1) + while (true) { line_len = (u32) fgetl (combs_fp, line_buf, HCBUFSIZ_LARGE); + line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); + // post-process rule engine if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) @@ -174,14 +176,12 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) char *line_buf = NULL; u32 line_len = 0; - while (1) + while (true) { HCFILE *fp = &extra_info_straight->fp; get_next_word (hashcat_ctx, fp, &line_buf, &line_len); - line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); - // post-process rule engine char rule_buf_out[RP_PASSWORD_SIZE]; @@ -218,10 +218,14 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) { + extra_info_straight->out_len = MIN (extra_info_straight->out_len, 31); // max length supported by apply_rules_optimized() + extra_info_straight->out_len = apply_rules_optimized (straight_ctx->kernel_rules_buf[extra_info_straight->rule_pos].cmds, &out_ptr[0], &out_ptr[4], extra_info_straight->out_len); } else { + extra_info_straight->out_len = MIN (extra_info_straight->out_len, 256); // max length supported by apply_rules() + extra_info_straight->out_len = apply_rules (straight_ctx->kernel_rules_buf[extra_info_straight->rule_pos].cmds, out_ptr, extra_info_straight->out_len); } @@ -246,25 +250,26 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) char *line_buf = NULL; u32 line_len = 0; - while (1) + while (true) { get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len); - line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); - // post-process rule engine + char rule_buf_out[RP_PASSWORD_SIZE]; + if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) { if (line_len >= RP_PASSWORD_SIZE) continue; - char rule_buf_out[RP_PASSWORD_SIZE]; - memset (rule_buf_out, 0, sizeof (rule_buf_out)); const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); if (rule_len_out < 0) continue; + + line_buf = rule_buf_out; + line_len = (u32) rule_len_out; } break; @@ -284,10 +289,12 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) char *line_buf = extra_info_combi->scratch_buf; u32 line_len = 0; - while (1) + while (true) { line_len = (u32) fgetl (combs_fp, line_buf, HCBUFSIZ_LARGE); + line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); + // post-process rule engine if (run_rule_engine ((int) user_options_extra->rule_len_r, user_options->rule_buf_r)) diff --git a/src/status.c b/src/status.c index 718336f43..26407519e 100644 --- a/src/status.c +++ b/src/status.c @@ -778,13 +778,14 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx) int status_get_guess_mask_length (const hashcat_ctx_t *hashcat_ctx) { - const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; if (mask_ctx == NULL) return -1; if (mask_ctx->mask == NULL) return -1; - return mp_get_length (mask_ctx->mask); + return mp_get_length (mask_ctx->mask, hashconfig->opts_type); } char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx) diff --git a/src/stdout.c b/src/stdout.c index f7a4585f1..102b22d79 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -291,7 +291,12 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, out_flush (&out); - if (filename) hc_fclose (&out.fp); + if (filename) + { + hc_unlockfile (&out.fp); + + hc_fclose (&out.fp); + } return 0; } diff --git a/src/terminal.c b/src/terminal.c index e0ae0137f..d1e8834e8 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -555,7 +555,7 @@ void example_hashes (hashcat_ctx_t *hashcat_ctx) { event_log_info (hashcat_ctx, "HASH: %s", hashconfig->st_hash); - if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options->separator, 0)) + if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options->separator, false)) { char tmp_buf[HCBUFSIZ_LARGE] = { 0 }; @@ -615,7 +615,7 @@ void example_hashes (hashcat_ctx_t *hashcat_ctx) { event_log_info (hashcat_ctx, "HASH: %s", hashconfig->st_hash); - if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options->separator, 0)) + if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options->separator, false)) { char tmp_buf[HCBUFSIZ_LARGE] = { 0 }; @@ -683,6 +683,7 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) char *device_name = device_param->device_name; u32 device_processors = device_param->device_processors; u32 device_maxclock_frequency = device_param->device_maxclock_frequency; + u64 device_available_mem = device_param->device_available_mem; u64 device_global_mem = device_param->device_global_mem; if (device_param->device_id_alias_cnt) @@ -697,7 +698,8 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, " Name...........: %s", device_name); event_log_info (hashcat_ctx, " Processor(s)...: %u", device_processors); event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency); - event_log_info (hashcat_ctx, " Memory.........: %" PRIu64 " MB", device_global_mem / 1024 / 1024); + event_log_info (hashcat_ctx, " Memory.Total...: %" PRIu64 " MB", device_global_mem / 1024 / 1024); + event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024); event_log_info (hashcat_ctx, NULL); } } @@ -738,6 +740,7 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) u32 device_processors = device_param->device_processors; u32 device_maxclock_frequency = device_param->device_maxclock_frequency; u64 device_maxmem_alloc = device_param->device_maxmem_alloc; + u64 device_available_mem = device_param->device_available_mem; u64 device_global_mem = device_param->device_global_mem; cl_device_type opencl_device_type = device_param->opencl_device_type; cl_uint opencl_device_vendor_id = device_param->opencl_device_vendor_id; @@ -762,7 +765,8 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, " Version........: %s", opencl_device_version); event_log_info (hashcat_ctx, " Processor(s)...: %u", device_processors); event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency); - event_log_info (hashcat_ctx, " Memory.........: %" PRIu64 "/%" PRIu64 " MB allocatable", device_maxmem_alloc / 1024 / 1024, device_global_mem / 1024 / 1024); + event_log_info (hashcat_ctx, " Memory.Total...: %" PRIu64 " MB (limited to %" PRIu64 " MB allocatable in one block)", device_global_mem / 1024 / 1024, device_maxmem_alloc / 1024 / 1024); + event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024); event_log_info (hashcat_ctx, " OpenCL.Version.: %s", opencl_device_c_version); event_log_info (hashcat_ctx, " Driver.Version.: %s", opencl_driver_version); event_log_info (hashcat_ctx, NULL); @@ -801,17 +805,19 @@ void backend_info_compact (hashcat_ctx_t *hashcat_ctx) const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx; - int device_id = device_param->device_id; - char *device_name = device_param->device_name; - u32 device_processors = device_param->device_processors; - u64 device_global_mem = device_param->device_global_mem; + int device_id = device_param->device_id; + char *device_name = device_param->device_name; + u32 device_processors = device_param->device_processors; + u64 device_global_mem = device_param->device_global_mem; + u64 device_available_mem = device_param->device_available_mem; if ((device_param->skipped == false) && (device_param->skipped_warning == false)) { - event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 " MB, %uMCU", + event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB, %uMCU", device_id + 1, device_name, - device_global_mem / 1024 / 1024, + device_available_mem / 1024 / 1024, + device_global_mem / 1024 / 1024, device_processors); } else @@ -854,19 +860,21 @@ void backend_info_compact (hashcat_ctx_t *hashcat_ctx) const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx; - int device_id = device_param->device_id; - char *device_name = device_param->device_name; - u32 device_processors = device_param->device_processors; - u64 device_maxmem_alloc = device_param->device_maxmem_alloc; - u64 device_global_mem = device_param->device_global_mem; + int device_id = device_param->device_id; + char *device_name = device_param->device_name; + u32 device_processors = device_param->device_processors; + u64 device_maxmem_alloc = device_param->device_maxmem_alloc; + u64 device_global_mem = device_param->device_global_mem; + u64 device_available_mem = device_param->device_available_mem; if ((device_param->skipped == false) && (device_param->skipped_warning == false)) { - event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB allocatable, %uMCU", + event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB (%" PRIu64 " MB allocatable), %uMCU", device_id + 1, device_name, - device_maxmem_alloc / 1024 / 1024, - device_global_mem / 1024 / 1024, + device_available_mem / 1024 / 1024, + device_global_mem / 1024 / 1024, + device_maxmem_alloc / 1024 / 1024, device_processors); } else @@ -1131,15 +1139,35 @@ void status_display (hashcat_ctx_t *hashcat_ctx) "Hash.Target......: %s", hashcat_status->hash_target); - event_log_info (hashcat_ctx, + if (user_options->force == true) + { + event_log_info (hashcat_ctx, + "Time.Started.....: %s, (%s)", + hashcat_status->time_started_absolute, + hashcat_status->time_started_relative); + } + else + { + event_log_info (hashcat_ctx, "Time.Started.....: %s (%s)", hashcat_status->time_started_absolute, hashcat_status->time_started_relative); + } - event_log_info (hashcat_ctx, + if (user_options->force == true) + { + event_log_info (hashcat_ctx, + "Time.Estimated...: %s, (%s)", + hashcat_status->time_estimated_absolute, + hashcat_status->time_estimated_relative); + } + else + { + event_log_info (hashcat_ctx, "Time.Estimated...: %s (%s)", hashcat_status->time_estimated_absolute, hashcat_status->time_estimated_relative); + } switch (hashcat_status->guess_mode) { diff --git a/src/timer.c b/src/timer.c index 415514456..ba9df1889 100644 --- a/src/timer.c +++ b/src/timer.c @@ -9,12 +9,12 @@ #if defined (_WIN) -inline void hc_timer_set (hc_timer_t *a) +void hc_timer_set (hc_timer_t *a) { QueryPerformanceCounter (a); } -inline double hc_timer_get (hc_timer_t a) +double hc_timer_get (hc_timer_t a) { hc_timer_t hr_freq; @@ -31,7 +31,7 @@ inline double hc_timer_get (hc_timer_t a) #else -inline void hc_timer_set (hc_timer_t* a) +void hc_timer_set (hc_timer_t* a) { #if defined(__APPLE__) && defined(MISSING_CLOCK_GETTIME) gettimeofday (a, NULL); @@ -40,7 +40,7 @@ inline void hc_timer_set (hc_timer_t* a) #endif } -inline double hc_timer_get (hc_timer_t a) +double hc_timer_get (hc_timer_t a) { hc_timer_t hr_tmp; diff --git a/src/tuningdb.c b/src/tuningdb.c index 248f8d30a..f2a7f9ac5 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -342,7 +342,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev { device_name_nospace[i] = 0; - tuning_db_alias_t *alias = bsearch (&a, tuning_db->alias_buf, tuning_db->alias_cnt, sizeof (tuning_db_alias_t), sort_by_tuning_db_alias); + tuning_db_alias_t *alias = (tuning_db_alias_t *) bsearch (&a, tuning_db->alias_buf, tuning_db->alias_cnt, sizeof (tuning_db_alias_t), sort_by_tuning_db_alias); if (alias == NULL) continue; @@ -372,7 +372,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev s.attack_mode = (i & 2) ? -1 : attack_mode; s.hash_mode = (i & 4) ? -1 : hash_mode; - entry = bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry); + entry = (tuning_db_entry_t *) bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry); if (entry != NULL) break; @@ -386,7 +386,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev { s.device_name = alias_name; - entry = bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry); + entry = (tuning_db_entry_t *) bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry); if (entry != NULL) break; } @@ -406,7 +406,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev s.device_name = "DEVICE_TYPE_ACCELERATOR"; } - entry = bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry); + entry = (tuning_db_entry_t *) bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry); if (entry != NULL) break; } diff --git a/src/usage.c b/src/usage.c index 57b14bab1..0f30e2109 100644 --- a/src/usage.c +++ b/src/usage.c @@ -53,7 +53,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --restore-disable | | Do not write restore file |", " --restore-file-path | File | Specific path to restore file | --restore-file-path=x.restore", " -o, --outfile | File | Define outfile for recovered hash | -o outfile.txt", - " --outfile-format | Num | Define outfile-format X for recovered hash | --outfile-format=7", + " --outfile-format | Str | Outfile format to use, separated with commas | --outfile-format=1,3", " --outfile-autohex-disable | | Disable the use of $HEX[] in output plains |", " --outfile-check-timer | Num | Sets seconds between outfile checks to X | --outfile-check=30", " --wordlist-autohex-disable | | Disable the conversion of $HEX[] from the wordlist |", @@ -88,7 +88,10 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --bitmap-min | Num | Sets minimum bits allowed for bitmaps to X | --bitmap-min=24", " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24", " --cpu-affinity | Str | Locks to CPU devices, separated with commas | --cpu-affinity=1,2,3", + " --hook-threads | Num | Sets number of threads for a hook (per compute unit) | --hook-threads=8", " --example-hashes | | Show an example hash for each hash-mode |", + " --backend-ignore-cuda | | Do not try to open CUDA interface on startup |", + " --backend-ignore-opencl | | Do not try to open OpenCL interface on startup |", " -I, --backend-info | | Show info about detected backend API devices | -I", " -d, --backend-devices | Str | Backend devices to use, separated with commas | -d 1", " -D, --opencl-device-types | Str | OpenCL device-types to use, separated with commas | -D 1", @@ -98,7 +101,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -u, --kernel-loops | Num | Manual workload tuning, set innerloop step size to X | -u 256", " -T, --kernel-threads | Num | Manual workload tuning, set thread count to X | -T 64", " --backend-vector-width | Num | Manually override backend vector-width to X | --backend-vector=4", - " --spin-damp | Num | Use CPU for device synchronization, in percent | --spin-damp=50", + " --spin-damp | Num | Use CPU for device synchronization, in percent | --spin-damp=10", " --hwmon-disable | | Disable temperature and fanspeed reads and triggers |", " --hwmon-temp-abort | Num | Abort if temperature reaches X degrees Celsius | --hwmon-temp-abort=100", " --scrypt-tmto | Num | Manually override TMTO value for scrypt to X | --scrypt-tmto=3", @@ -122,6 +125,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -S, --slow-candidates | | Enable slower (but advanced) candidate generators |", #ifdef WITH_BRAIN " --brain-server | | Enable brain server |", + " --brain-server-timer | Num | Update the brain server dump each X seconds (min:60) | --brain-server-timer=300", " -z, --brain-client | | Enable brain client, activates -S |", " --brain-client-features | Num | Define brain client features, see below | --brain-client-features=3", " --brain-host | Str | Brain server host (IP or domain) | --brain-host=127.0.0.1", @@ -156,19 +160,10 @@ static const char *const USAGE_BIG_POST_HASHMODES[] = " ===+========", " 1 | hash[:salt]", " 2 | plain", - " 3 | hash[:salt]:plain", - " 4 | hex_plain", - " 5 | hash[:salt]:hex_plain", - " 6 | plain:hex_plain", - " 7 | hash[:salt]:plain:hex_plain", - " 8 | crackpos", - " 9 | hash[:salt]:crack_pos", - " 10 | plain:crack_pos", - " 11 | hash[:salt]:plain:crack_pos", - " 12 | hex_plain:crack_pos", - " 13 | hash[:salt]:hex_plain:crack_pos", - " 14 | plain:hex_plain:crack_pos", - " 15 | hash[:salt]:plain:hex_plain:crack_pos", + " 3 | hex_plain", + " 4 | crack_pos", + " 5 | timestamp absolute", + " 6 | timestamp relative", "", "- [ Rule Debugging Modes ] -", "", diff --git a/src/user_options.c b/src/user_options.c index 81078d074..ec19a0354 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -13,6 +13,7 @@ #include "usage.h" #include "backend.h" #include "user_options.h" +#include "outfile.h" #ifdef WITH_BRAIN #include "brain.h" @@ -29,6 +30,8 @@ static const struct option long_options[] = {"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE}, {"attack-mode", required_argument, NULL, IDX_ATTACK_MODE}, {"backend-devices", required_argument, NULL, IDX_BACKEND_DEVICES}, + {"backend-ignore-cuda", no_argument, NULL, IDX_BACKEND_IGNORE_CUDA}, + {"backend-ignore-opencl", no_argument, NULL, IDX_BACKEND_IGNORE_OPENCL}, {"backend-info", no_argument, NULL, IDX_BACKEND_INFO}, {"backend-vector-width", required_argument, NULL, IDX_BACKEND_VECTOR_WIDTH}, {"benchmark-all", no_argument, NULL, IDX_BENCHMARK_ALL}, @@ -58,6 +61,7 @@ static const struct option long_options[] = {"hex-charset", no_argument, NULL, IDX_HEX_CHARSET}, {"hex-salt", no_argument, NULL, IDX_HEX_SALT}, {"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST}, + {"hook-threads", required_argument, NULL, IDX_HOOK_THREADS}, {"increment-max", required_argument, NULL, IDX_INCREMENT_MAX}, {"increment-min", required_argument, NULL, IDX_INCREMENT_MIN}, {"increment", no_argument, NULL, IDX_INCREMENT}, @@ -126,6 +130,7 @@ static const struct option long_options[] = {"brain-client", no_argument, NULL, IDX_BRAIN_CLIENT}, {"brain-client-features", required_argument, NULL, IDX_BRAIN_CLIENT_FEATURES}, {"brain-server", no_argument, NULL, IDX_BRAIN_SERVER}, + {"brain-server-timer", required_argument, NULL, IDX_BRAIN_SERVER_TIMER}, {"brain-host", required_argument, NULL, IDX_BRAIN_HOST}, {"brain-port", required_argument, NULL, IDX_BRAIN_PORT}, {"brain-password", required_argument, NULL, IDX_BRAIN_PASSWORD}, @@ -152,6 +157,8 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->advice_disable = ADVICE_DISABLE; user_options->attack_mode = ATTACK_MODE; user_options->backend_devices = NULL; + user_options->backend_ignore_cuda = BACKEND_IGNORE_CUDA; + user_options->backend_ignore_opencl = BACKEND_IGNORE_OPENCL; user_options->backend_info = BACKEND_INFO; user_options->backend_vector_width = BACKEND_VECTOR_WIDTH; user_options->benchmark_all = BENCHMARK_ALL; @@ -164,6 +171,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->brain_host = NULL; user_options->brain_port = BRAIN_PORT; user_options->brain_server = BRAIN_SERVER; + user_options->brain_server_timer = BRAIN_SERVER_TIMER; user_options->brain_session = BRAIN_SESSION; user_options->brain_session_whitelist = NULL; #endif @@ -185,6 +193,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->hex_charset = HEX_CHARSET; user_options->hex_salt = HEX_SALT; user_options->hex_wordlist = HEX_WORDLIST; + user_options->hook_threads = HOOK_THREADS; user_options->increment = INCREMENT; user_options->increment_max = INCREMENT_MAX; user_options->increment_min = INCREMENT_MIN; @@ -248,8 +257,8 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->usage = USAGE; user_options->username = USERNAME; user_options->veracrypt_keyfiles = NULL; - user_options->veracrypt_pim_start = 0; - user_options->veracrypt_pim_stop = 0; + user_options->veracrypt_pim_start = VERACRYPT_PIM_START; + user_options->veracrypt_pim_stop = VERACRYPT_PIM_STOP; user_options->version = VERSION; user_options->wordlist_autohex_disable = WORDLIST_AUTOHEX_DISABLE; user_options->workload_profile = WORKLOAD_PROFILE; @@ -302,7 +311,6 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_RP_GEN_FUNC_MAX: case IDX_RP_GEN_SEED: case IDX_MARKOV_THRESHOLD: - case IDX_OUTFILE_FORMAT: case IDX_OUTFILE_CHECK_TIMER: case IDX_BACKEND_VECTOR_WIDTH: case IDX_WORKLOAD_PROFILE: @@ -321,6 +329,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_BITMAP_MAX: case IDX_INCREMENT_MIN: case IDX_INCREMENT_MAX: + case IDX_HOOK_THREADS: #ifdef WITH_BRAIN case IDX_BRAIN_PORT: #endif @@ -390,7 +399,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break; case IDX_RESTORE_FILE_PATH: user_options->restore_file_path = optarg; break; case IDX_STATUS: user_options->status = true; break; - case IDX_STATUS_JSON: user_options->status_json = true; break; + case IDX_STATUS_JSON: user_options->status_json = true; break; case IDX_STATUS_TIMER: user_options->status_timer = hc_strtoul (optarg, NULL, 10); break; case IDX_MACHINE_READABLE: user_options->machine_readable = true; break; case IDX_LOOPBACK: user_options->loopback = true; break; @@ -414,7 +423,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_MARKOV_THRESHOLD: user_options->markov_threshold = hc_strtoul (optarg, NULL, 10); break; case IDX_MARKOV_HCSTAT2: user_options->markov_hcstat2 = optarg; break; case IDX_OUTFILE: user_options->outfile = optarg; break; - case IDX_OUTFILE_FORMAT: user_options->outfile_format = hc_strtoul (optarg, NULL, 10); + case IDX_OUTFILE_FORMAT: user_options->outfile_format = outfile_format_parse (optarg); user_options->outfile_format_chgd = true; break; case IDX_OUTFILE_AUTOHEX_DISABLE: user_options->outfile_autohex = false; break; case IDX_OUTFILE_CHECK_TIMER: user_options->outfile_check_timer = hc_strtoul (optarg, NULL, 10); break; @@ -423,6 +432,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_HEX_SALT: user_options->hex_salt = true; break; case IDX_HEX_WORDLIST: user_options->hex_wordlist = true; break; case IDX_CPU_AFFINITY: user_options->cpu_affinity = optarg; break; + case IDX_BACKEND_IGNORE_CUDA: user_options->backend_ignore_cuda = true; break; + case IDX_BACKEND_IGNORE_OPENCL: user_options->backend_ignore_opencl = true; break; case IDX_BACKEND_INFO: user_options->backend_info = true; break; case IDX_BACKEND_DEVICES: user_options->backend_devices = optarg; break; case IDX_BACKEND_VECTOR_WIDTH: user_options->backend_vector_width = hc_strtoul (optarg, NULL, 10); @@ -449,14 +460,17 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_KEYBOARD_LAYOUT_MAPPING: user_options->keyboard_layout_mapping = optarg; break; case IDX_TRUECRYPT_KEYFILES: user_options->truecrypt_keyfiles = optarg; break; case IDX_VERACRYPT_KEYFILES: user_options->veracrypt_keyfiles = optarg; break; - case IDX_VERACRYPT_PIM_START: user_options->veracrypt_pim_start = hc_strtoul (optarg, NULL, 10); break; - case IDX_VERACRYPT_PIM_STOP: user_options->veracrypt_pim_stop = hc_strtoul (optarg, NULL, 10); break; + case IDX_VERACRYPT_PIM_START: user_options->veracrypt_pim_start = hc_strtoul (optarg, NULL, 10); + user_options->veracrypt_pim_start_chgd = true; break; + case IDX_VERACRYPT_PIM_STOP: user_options->veracrypt_pim_stop = hc_strtoul (optarg, NULL, 10); + user_options->veracrypt_pim_stop_chgd = true; break; case IDX_SEGMENT_SIZE: user_options->segment_size = hc_strtoul (optarg, NULL, 10); user_options->segment_size_chgd = true; break; case IDX_SCRYPT_TMTO: user_options->scrypt_tmto = hc_strtoul (optarg, NULL, 10); break; case IDX_SEPARATOR: user_options->separator = optarg[0]; break; case IDX_BITMAP_MIN: user_options->bitmap_min = hc_strtoul (optarg, NULL, 10); break; case IDX_BITMAP_MAX: user_options->bitmap_max = hc_strtoul (optarg, NULL, 10); break; + case IDX_HOOK_THREADS: user_options->hook_threads = hc_strtoul (optarg, NULL, 10); break; case IDX_INCREMENT: user_options->increment = true; break; case IDX_INCREMENT_MIN: user_options->increment_min = hc_strtoul (optarg, NULL, 10); user_options->increment_min_chgd = true; break; @@ -471,6 +485,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_BRAIN_CLIENT: user_options->brain_client = true; break; case IDX_BRAIN_CLIENT_FEATURES: user_options->brain_client_features = hc_strtoul (optarg, NULL, 10); break; case IDX_BRAIN_SERVER: user_options->brain_server = true; break; + case IDX_BRAIN_SERVER_TIMER: user_options->brain_server_timer = hc_strtoul (optarg, NULL, 10); + user_options->brain_server_timer_chgd = true; break; case IDX_BRAIN_PASSWORD: user_options->brain_password = optarg; user_options->brain_password_chgd = true; break; case IDX_BRAIN_HOST: user_options->brain_host = optarg; @@ -530,6 +546,26 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + + if (user_options->brain_server_timer_chgd) + { + if (user_options->brain_server == false) + { + event_log_error (hashcat_ctx, "The --brain-server-timer flag requires --brain-server."); + + return -1; + } + + if (user_options->brain_server_timer != 0) // special case (no intermediate dumps) + { + if (user_options->brain_server_timer < 60) + { + event_log_error (hashcat_ctx, "Brain server backup timer must be at least 60 seconds."); + + return -1; + } + } + } #endif if (user_options->slow_candidates == true) @@ -625,7 +661,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if (user_options->outfile_format > 16) + if (user_options->outfile_format == 0) { event_log_error (hashcat_ctx, "Invalid --outfile-format value specified."); @@ -649,9 +685,23 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_format_chgd == true) { - if (user_options->outfile_format > 7) + if (user_options->outfile_format & OUTFILE_FMT_CRACKPOS) { - event_log_error (hashcat_ctx, "Combining --outfile-format > 7 with --show is not allowed."); + event_log_error (hashcat_ctx, "Using crack_pos in --outfile-format for --show is not allowed."); + + return -1; + } + + if (user_options->outfile_format & OUTFILE_FMT_TIME_ABS) + { + event_log_error (hashcat_ctx, "Using the absolute timestamp in --outfile-format for --show is not allowed."); + + return -1; + } + + if (user_options->outfile_format & OUTFILE_FMT_TIME_REL) + { + event_log_error (hashcat_ctx, "Using the relative timestamp in --outfile-format for --show is not allowed."); return -1; } @@ -672,14 +722,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if ((user_options->veracrypt_pim_start != 0) && (user_options->veracrypt_pim_stop == 0)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == false)) { event_log_error (hashcat_ctx, "If --veracrypt-pim-start is specified then --veracrypt-pim-stop needs to be specified, too."); return -1; } - if ((user_options->veracrypt_pim_start == 0) && (user_options->veracrypt_pim_stop != 0)) + if ((user_options->veracrypt_pim_start_chgd == false) && (user_options->veracrypt_pim_stop_chgd == true)) { event_log_error (hashcat_ctx, "If --veracrypt-pim-stop is specified then --veracrypt-pim-start needs to be specified, too."); @@ -1007,20 +1057,119 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if ((user_options->spin_damp_chgd == true) && (user_options->benchmark == true)) - { - event_log_error (hashcat_ctx, "Values of --spin-damp cannot be used in combination with --benchmark."); - - return -1; - } - if (user_options->benchmark == true) { + // sanity checks based on automatically overwritten configuration variables by + // benchmark mode section in user_options_preprocess() + + #ifdef WITH_BRAIN + if (user_options->brain_client == true) + { + event_log_error (hashcat_ctx, "Brain client (-z) is not allowed in benchmark mode."); + + return -1; + } + + if (user_options->brain_server == true) + { + event_log_error (hashcat_ctx, "Brain server is not allowed in benchmark mode."); + + return -1; + } + #endif + if (user_options->attack_mode_chgd == true) { - if (user_options->attack_mode != ATTACK_MODE_BF) + event_log_error (hashcat_ctx, "Can't change --attack-mode (-a) in benchmark mode."); + + return -1; + } + + if (user_options->bitmap_min != BITMAP_MIN) + { + event_log_error (hashcat_ctx, "Can't change --bitmap-min in benchmark mode."); + + return -1; + } + + if (user_options->bitmap_max != BITMAP_MAX) + { + event_log_error (hashcat_ctx, "Can't change --bitmap-max in benchmark mode."); + + return -1; + } + + if (user_options->hwmon_temp_abort != HWMON_TEMP_ABORT) + { + event_log_error (hashcat_ctx, "Can't change --hwmon-temp-abort in benchmark mode."); + + return -1; + } + + if (user_options->left == true) + { + event_log_error (hashcat_ctx, "Can't change --left in benchmark mode."); + + return -1; + } + + if (user_options->show == true) + { + event_log_error (hashcat_ctx, "Can't change --show in benchmark mode."); + + return -1; + } + + if (user_options->speed_only == true) + { + event_log_error (hashcat_ctx, "Can't change --speed-only in benchmark mode."); + + return -1; + } + + if (user_options->progress_only == true) + { + event_log_error (hashcat_ctx, "Can't change --progress-only in benchmark mode."); + + return -1; + } + + if (user_options->increment == true) + { + event_log_error (hashcat_ctx, "Can't change --increment (-i) in benchmark mode."); + + return -1; + } + + if (user_options->restore == true) + { + event_log_error (hashcat_ctx, "Can't change --restore in benchmark mode."); + + return -1; + } + + if (user_options->status == true) + { + event_log_error (hashcat_ctx, "Can't change --status in benchmark mode."); + + return -1; + } + + if (user_options->spin_damp_chgd == true) + { + event_log_error (hashcat_ctx, "Can't change --spin-damp in benchmark mode."); + + return -1; + } + + if ((user_options->custom_charset_1 != NULL) + || (user_options->custom_charset_2 != NULL) + || (user_options->custom_charset_3 != NULL) + || (user_options->custom_charset_4 != NULL)) + { + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - event_log_error (hashcat_ctx, "Benchmark mode is only allowed in attack mode 3 (brute-force)."); + event_log_error (hashcat_ctx, "Custom charsets are not supported in benchmark mode."); return -1; } @@ -2723,6 +2872,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->hex_charset); logfile_top_uint (user_options->hex_salt); logfile_top_uint (user_options->hex_wordlist); + logfile_top_uint (user_options->hook_threads); logfile_top_uint (user_options->increment); logfile_top_uint (user_options->increment_max); logfile_top_uint (user_options->increment_min); @@ -2780,6 +2930,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->brain_client); logfile_top_uint (user_options->brain_client_features); logfile_top_uint (user_options->brain_server); + logfile_top_uint (user_options->brain_server_timer); logfile_top_uint (user_options->brain_port); logfile_top_uint (user_options->brain_session); #endif diff --git a/src/wordlist.c b/src/wordlist.c index 57bd36346..deda8afd2 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -13,14 +13,16 @@ #include "rp_cpu.h" #include "shared.h" #include "wordlist.h" +#include "emu_inc_hash_sha1.h" size_t convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const size_t line_len) { + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const user_options_t *user_options = hashcat_ctx->user_options; if (line_len & 1) return (line_len); // not in hex - if (user_options->hex_wordlist == true) + if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) { size_t i, j; @@ -187,7 +189,13 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, char **out_buf, u32 wl_data->pos += off; + // do the on-the-fly hex decode using original buffer + // this is safe as length only decreases in size + + len = (u32) convert_from_hex (hashcat_ctx, ptr, len); + // do the on-the-fly encoding + // needs to write into new buffer because size case both decrease and increase if (wl_data->iconv_enabled == true) { @@ -204,6 +212,8 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, char **out_buf, u32 len = HCBUFSIZ_TINY - iconv_sz; } + // this is only a test for length, not writing into output buffer + if (run_rule_engine (user_options_extra->rule_len_l, user_options->rule_buf_l)) { if (len >= RP_PASSWORD_SIZE) continue; @@ -331,7 +341,7 @@ int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const char *dictfile, u dictstat_t d; - d.cnt = 0; + memset (&d, 0, sizeof (d)); if (fstat (hc_fileno (fp), &d.stat)) { @@ -369,6 +379,21 @@ int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const char *dictfile, u return 0; } + const size_t dictfile_len = strlen (dictfile); + + u32 *dictfile_padded = (u32 *) hcmalloc (dictfile_len + 64); // padding required for sha1_update() + + memcpy (dictfile_padded, dictfile, dictfile_len); + + sha1_ctx_t sha1_ctx; + sha1_init (&sha1_ctx); + sha1_update (&sha1_ctx, dictfile_padded, dictfile_len); + sha1_final (&sha1_ctx); + + hcfree (dictfile_padded); + + memcpy (d.hash_filename, sha1_ctx.h, 16); + const u64 cached_cnt = dictstat_find (hashcat_ctx, &d); if (run_rule_engine (user_options_extra->rule_len_l, user_options->rule_buf_l) == 0) @@ -444,6 +469,11 @@ int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const char *dictfile, u i += off; + // do the on-the-fly hex decode using original buffer + // this is safe as length only decreases in size + + len = (u32) convert_from_hex (hashcat_ctx, ptr, len); + // do the on-the-fly encoding if (wl_data->iconv_enabled == true) diff --git a/tools/aescrypt2hashcat.pl b/tools/aescrypt2hashcat.pl new file mode 100755 index 000000000..8cb2c6efa --- /dev/null +++ b/tools/aescrypt2hashcat.pl @@ -0,0 +1,131 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +# +# Helper functions +# + +sub read_bytes +{ + my $handle = shift; + my $size = shift; + + my $data = ""; + + read ($handle, $data, $size); + + # this function is very strict: + # it only returns something if all the bytes can be read + + if (length ($data) != $size) + { + die "ERROR: Couldn't read data from the file. Maybe incorrect file format?\n"; + } + + return $data; +} + +# +# Start +# + +if (scalar (@ARGV) != 1) +{ + die "usage: $0 file.txt.aes\n"; +} + +my $file_name = $ARGV[0]; + +my $file_handle; + +if (! open ($file_handle, "<", $file_name)) +{ + die "ERROR: Couldn't open file '$file_name'\n"; +} + +binmode ($file_handle); + + +# Signature: + +my $signature = read_bytes ($file_handle, 3); + +if ($signature ne "AES") +{ + die "ERROR: The file doesn't seem to be a correct aescrypt file (signature mismatch)\n"; +} + +# Version + +my $version = read_bytes ($file_handle, 1); + +if ($version ne "\x02") +{ + die "ERROR: Currently only aescrypt file version 2 is supported by this script\n"; +} + + +read_bytes ($file_handle, 1); # reservered/skip (normally should be just \x00) + + +# Loop over the extensions until we got extension size 0 + +my $extension_size = read_bytes ($file_handle, 2); + +while ($extension_size ne "\x00\x00") +{ + my $skip_size = unpack ("S>", $extension_size); # 16-bit lengths + + read_bytes ($file_handle, $skip_size); # skip the extension + + $extension_size = read_bytes ($file_handle, 2); +} + +# IV (for KDF) + +my $iv = read_bytes ($file_handle, 16); + + +# IV (encrypted IV for AES decryption) + +my $iv_enc = read_bytes ($file_handle, 16); + + +# key_enc + +my $key_enc = read_bytes ($file_handle, 32); + + +# HMAC + +my $hmac = read_bytes ($file_handle, 32); + +# +# Hex conversion +# + +$iv = unpack ("H*", $iv); +$iv_enc = unpack ("H*", $iv_enc); +$key_enc = unpack ("H*", $key_enc); +$hmac = unpack ("H*", $hmac); + +# +# Final output +# + +print sprintf ("\$aescrypt\$1*%s*%s*%s*%s\n", $iv, $iv_enc, $key_enc, $hmac); + +# +# Cleanup +# + +close ($file_handle); + +exit (0); diff --git a/tools/benchmark_deep.pl b/tools/benchmark_deep.pl new file mode 100755 index 000000000..4b6f629fe --- /dev/null +++ b/tools/benchmark_deep.pl @@ -0,0 +1,514 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my $nvidia_cache = "~/.nv"; +my $amd_cache = "~/.AMD"; +my $hashcat_path = "."; +my $kernels_cache = "$hashcat_path/kernels"; +my $hashcat_bin = "$hashcat_path/hashcat"; +my $device = 3; +my $workload_profile = 3; +my $runtime = 24; +my $sleep_sec = 12; +my $default_mask = "?b?b?b?b?b?b?b"; +my $result = "result.txt"; +my $old_hashcat = 0; # requires to have ran with new hashcat before to create the hashfiles +my $repeats = 1; +my $cpu_benchmark = 0; + +print "\nHardware preparations... You may need to adjust some settings and probably can ignore some of the error\n\n"; + +system ("echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor"); + +if ($cpu_benchmark == 1) +{ + system ("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo"); ## for CPU benchmark Intel + system ("echo 0 > /sys/devices/system/cpu/cpufreq/boost"); ## for CPU benchmark AMD +} +else +{ + system ("rocm-smi --resetprofile --resetclocks --resetfans"); + system ("rocm-smi --setfan 100% --setperflevel high"); + + system ("nvidia-smi -rac"); + system ("nvidia-smi -pm ENABLED"); + system ("nvidia-smi -acp UNRESTRICTED"); + system ("nvidia-smi -pl 225"); ## needs per-gpu adjust + system ("nvidia-settings -a GPUPowerMizerMode=1 -a GPUFanControlState=1 -a GPUTargetFanSpeed=100"); +} + +print "\n\nStarting...\n\n"; + +system ("rm -rf $nvidia_cache"); +system ("rm -rf $amd_cache"); +system ("rm -rf $kernels_cache"); + +my @hash_types_selection = +( + 0, + 100, + 1400, + 1700, + 16800, + 1000, + 3000, + 5500, + 5600, + 1500, + 500, + 3200, + 1800, + 7500, + 13100, + 15300, + 15900, + 7100, + 11600, + 12500, + 13000, + 6241, + 13400, + 6800, + 11300, +); + +my @hash_types = +( + 0, + 20, + 50, + 60, + 100, + 120, + 150, + 160, + 200, + 300, + 400, + 500, + 600, + 900, + 1000, + 1100, + 1300, + 1400, + 1420, + 1450, + 1460, + 1500, + 1600, + 1700, + 1720, + 1750, + 1760, + 1800, + 2100, + 2400, + 2410, + 2500, + 2501, + 2611, + 2711, + 2811, + 3000, + 3100, + 3200, + 3710, + 3800, + 3910, + 4010, + 4110, + 4300, + 4400, + 4500, + 4520, + 4700, + 4800, + 4900, + 5100, + 5200, + 5300, + 5400, + 5500, + 5600, + 5800, + 6000, + 6100, + 6211, + 6221, + 6231, + 6241, + 6300, + 6400, + 6500, + 6600, + 6700, + 6800, + 6900, + 7000, + 7100, + 7300, + 7400, + 7500, + 7700, + 7701, + 7800, + 7801, + 7900, + 8000, + 8100, + 8200, + 8300, + 8400, + 8500, + 8600, + 8700, + 8800, + 8900, + 9000, + 9100, + 9400, + 9500, + 9600, + 9700, + 9710, + 9720, + 9800, + 9810, + 9820, + 9900, + 10100, + 10300, + 10400, + 10410, + 10420, + 10500, + 10700, + 10800, + 10900, + 11000, + 11100, + 11200, + 11300, + 11400, + 11500, + 11600, + 11700, + 11750, + 11760, + 11800, + 11850, + 11860, + 11900, + 12000, + 12200, + 12300, + 12400, + 12500, + 12600, + 12700, + 12800, + 12900, + 13000, + 13100, + 13200, + 13300, + 13400, + 13500, + 13600, + 13711, + 13721, + 13731, + 13741, + 13751, + 13761, + 13771, + 13800, + 13900, + 14000, + 14100, + 14400, + 14700, + 14800, + 14900, + 15000, + 15100, + 15300, + 15400, + 15500, + 15600, + 15900, + 16000, + 16100, + 16200, + 16300, + 16400, + 16600, + 16800, + 16801, + 16900, + 17300, + 17400, + 17500, + 17600, + 17700, + 17800, + 17900, + 18000, + 18100, + 18200, + 18300, + 18400, + 18500, + 18600, + 18700, + 18800, + 18900, + 19000, + 19100, + 19200, + 19300, + 19500, + 19600, + 19700, + 19800, + 19900, + 20011, + 20012, + 20013, + 20500, + 20510, + 20600, + 20710, + 20800, + 20900, + 21000, + 21100, + 21200, + 21300, + 21400, + 21500, + 21600, + 21700, + 21800, + 22000, + 22100, + 22200, + 22300, + 22400, + 22500, +); + +if (scalar @ARGV) +{ + @hash_types = @ARGV; +} + +unlink ($result); + +chdir ($hashcat_path); + +for my $hash_type (@hash_types) +{ + # banchmark always in optimized mode with single hash and mask! + + my $mask = $default_mask; + + if ($old_hashcat == 0) + { + my $module = get_module ($hash_type); + + my $st_hash = $module->{"st_hash"}; + my $is_binary = $module->{"is_binary"}; + + open (OUT, ">", "tmp.hash.$hash_type") or die; + + if ($is_binary) + { + print OUT pack ("H*", $st_hash), "\n"; + } + else + { + print OUT "$st_hash\n"; + } + + close (OUT); + + $mask = $module->{"mask"}; + } + + my @command = + ( + $hashcat_bin, + "--quiet", + "tmp.hash.$hash_type", + "--keep-guessing", + "--self-test-disable", + "--markov-disable", + "--restore-disable", + "--outfile-autohex-disable", + "--wordlist-autohex-disable", + "--potfile-disable", + "--logfile-disable", + "--hwmon-disable", + "--status", + "--status-timer", 1, + "--runtime", $runtime, + "--machine-readable", + "--optimized-kernel-enable", + "--workload-profile", $workload_profile, + "--hash-type", $hash_type, + "--attack-mode", 3, + $mask + ); + + if ($cpu_benchmark == 1) + { + push (@command, "--opencl-device-types", 1); + } + else + { + push (@command, "--backend-devices", $device); + } + + print "Executing command: ", join (" ", @command), "\n"; + + my $final_speed = 0; + + for (my $i = 0; $i <= $repeats; $i++) + { + printf ("Run #%d\n", $i); + + open (IN, "-|", @command, "--runtime", 1); + close (IN); + + my $was_slower = 0; + + my $speed = 0; + + my $sample = 0; + + open (IN, "-|", @command); + + while (my $line = ) + { + chomp $line; + + print "$line\n"; + + my @data = split "\t", $line; + + next unless defined $data[1]; + + next if ($data[1] != '3'); + + $sample++; + + if ($sample > 5) + { + if ($data[3] > $speed) + { + $speed = $data[3]; + } + else + { + $was_slower++; + + last if ($was_slower == 3); + } + } + } + + close (IN); + + sleep ($sleep_sec); + + $final_speed = $speed if ($speed > $final_speed); + } + + open (OUT, ">>", $result) or die; + print OUT $final_speed, "\n"; + close (OUT); +} + +sub get_module +{ + my $hash_type = shift; + + my $st_hash = undef; + my $is_binary = 0; + my $pw_min = -1; + my $pw_max = -1; + + my $path = sprintf ("src/modules/module_%05d.c", $hash_type); + + open (IN, $path) or die; + + while (my $line = ) + { + chomp $line; + + if ($line =~ /OPTS_TYPE_BINARY_HASHFILE/) + { + if (($hash_type == 22000) || ($hash_type == 22001)) + { + ## problem while in -m 2500 backward compatiblity mode + } + else + { + $is_binary = 1; + } + } + + if ($line =~ /ST_HASH *= \"(.*)\"/) + { + $st_hash = $1; + } + + if ($line =~ /const u32 pw_min = (\d+);/) + { + $pw_min = $1; + } + + if ($line =~ /const u32 pw_max = (\d+);/) + { + $pw_max = $1; + } + } + + close (IN); + + my $mask = $default_mask; + + if ($pw_min != -1) + { + if ($pw_min < 7) + { + $mask = substr ($mask, 0, $pw_min * 2); + } + else + { + my $left = $pw_min - 7; + + $mask .= "x" x $left; + } + } + elsif ($pw_max != -1) + { + if ($pw_max < 7) + { + $mask = substr ($mask, 0, $pw_min * 2); + } + } + + my $module = + { + "is_binary" => $is_binary, + "st_hash" => $st_hash, + "mask" => $mask, + }; + + return $module; +} diff --git a/tools/install_modules.sh b/tools/install_modules.sh index 268e09b9f..804960f82 100755 --- a/tools/install_modules.sh +++ b/tools/install_modules.sh @@ -14,6 +14,7 @@ cpan install Authen::Passphrase::LANManager \ Authen::Passphrase::MySQL323 \ Authen::Passphrase::NTHash \ Authen::Passphrase::PHPass \ + Compress::Zlib \ Convert::EBCDIC \ Crypt::CBC \ Crypt::DES \ @@ -25,6 +26,8 @@ cpan install Authen::Passphrase::LANManager \ Crypt::Mode::ECB \ Crypt::MySQL \ Crypt::OpenSSH::ChachaPoly \ + Crypt::OpenSSL::EC \ + Crypt::OpenSSL::Bignum::CTX \ Crypt::PBKDF2 \ Crypt::RC4 \ Crypt::Rijndael \ @@ -59,7 +62,7 @@ ERRORS=$((ERRORS+$?)) pip2 install pygost pycryptoplus -pip2 -y uninstall pycryptodome +pip2 uninstall -y pycryptodome ERRORS=$((ERRORS+$?)) diff --git a/tools/test.sh b/tools/test.sh index 0adb8e174..e64e6685c 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -19,7 +19,7 @@ VC_MODES="13711 13712 13713 13721 13722 13723 13731 13732 13733 13741 13742 1374 NEVER_CRACK="9720 9820 14900 18100" # List of modes which return a different output hash format than the input hash format -NOCHECK_ENCODING="16800" +NOCHECK_ENCODING="16800 22000" # LUKS mode has test containers LUKS_MODE="14600" @@ -273,6 +273,8 @@ function init() min_offset=3 elif [ "${hash_type}" -eq 16800 ]; then min_offset=7 # means length 8, since we start with 0 + elif [ "${hash_type}" -eq 22000 ]; then + min_offset=7 # means length 8, since we start with 0 fi # foreach password entry split password in 2 (skip first entry, is len 1) @@ -334,6 +336,8 @@ function init() min_len=31 elif [ "${hash_type}" -eq 16800 ]; then min_len=7 # means length 8, since we start with 0 + elif [ "${hash_type}" -eq 22000 ]; then + min_len=7 # means length 8, since we start with 0 fi # generate multiple pass/hash foreach len (2 to 8) @@ -402,6 +406,10 @@ function status() ;; 10) + if is_in_array "${hash_type}" ${NEVER_CRACK_ALGOS}; then + return + fi + if [ "${pass_only}" -eq 1 ]; then echo "plains not found in output, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" else @@ -469,7 +477,13 @@ function attack_0() if [ "${file_only}" -eq 1 ]; then temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt" - echo "${hash}" | base64 -d > "${temp_file}" + + if [ "${hash_type}" -ne 22000 ]; then + echo "${hash}" | base64 -d > "${temp_file}" + else + echo "${hash}" > "${temp_file}" + fi + hash="${temp_file}" fi @@ -486,10 +500,10 @@ function attack_0() output=$(echo "${pass}" | ./${BIN} ${OPTS} -a 0 -m ${hash_type} "${hash}" 2>&1) - pass=${pass_old} - ret=${?} + pass=${pass_old} + echo "${output}" >> "${OUTD}/logfull.txt" if [ "${ret}" -eq 0 ]; then @@ -553,9 +567,13 @@ function attack_0() hash_file=${temp_file} - while read -r base64_hash; do + while read -r file_only_hash; do - echo -n "${base64_hash}" | base64 -d >> "${temp_file}" + if [ "${hash_type}" -ne 22000 ]; then + echo -n "${file_only_hash}" | base64 -d >> "${temp_file}" + else + echo "${file_only_hash}" >> "${temp_file}" + fi done < "${OUTD}/${hash_type}_hashes.txt" @@ -657,7 +675,13 @@ function attack_1() if [ "${file_only}" -eq 1 ]; then temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt" - echo "${hash}" | base64 -d > "${temp_file}" + + if [ "${hash_type}" -ne 22000 ]; then + echo "${hash}" | base64 -d > "${temp_file}" + else + echo "${hash}" > "${temp_file}" + fi + hash="${temp_file}" fi @@ -815,9 +839,13 @@ function attack_1() hash_file=${temp_file} - while read -r base64_hash; do + while read -r file_only_hash; do - echo -n "${base64_hash}" | base64 -d >> "${temp_file}" + if [ "${hash_type}" -ne 22000 ]; then + echo -n "${file_only_hash}" | base64 -d >> "${temp_file}" + else + echo "${file_only_hash}" >> "${temp_file}" + fi done < "${OUTD}/${hash_type}_multihash_combi.txt" @@ -925,6 +953,8 @@ function attack_3() max=1 elif [ "${hash_type}" -eq 16800 ]; then max=7 + elif [ "${hash_type}" -eq 22000 ]; then + max=7 fi i=1 @@ -944,7 +974,13 @@ function attack_3() if [ "${file_only}" -eq 1 ]; then temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt" - echo "${hash}" | base64 -d > "${temp_file}" + + if [ "${hash_type}" -ne 22000 ]; then + echo "${hash}" | base64 -d > "${temp_file}" + else + echo "${hash}" > "${temp_file}" + fi + hash="${temp_file}" fi @@ -1094,6 +1130,11 @@ function attack_3() increment_max=9 fi + if [ "${hash_type}" -eq 22000 ]; then + increment_min=8 + increment_max=9 + fi + # if file_only -> decode all base64 "hashes" and put them in the temporary file if [ "${file_only}" -eq 1 ]; then @@ -1103,9 +1144,13 @@ function attack_3() hash_file=${temp_file} - while read -r base64_hash; do + while read -r file_only_hash; do - echo -n "${base64_hash}" | base64 -d >> "${temp_file}" + if [ "${hash_type}" -ne 22000 ]; then + echo -n "${file_only_hash}" | base64 -d >> "${temp_file}" + else + echo "${file_only_hash}" >> "${temp_file}" + fi done < "${OUTD}/${hash_type}_multihash_bruteforce.txt" @@ -1335,6 +1380,91 @@ function attack_3() custom_charsets="-1 ${charset_1} -2 ${charset_2} -3 ${charset_3} -4 ${charset_4}" fi + if [ "${hash_type}" -eq 22000 ]; then + + mask="?d?d?d?d?d?1?2?3?4" + + charset_1="" + charset_2="" + charset_3="" + charset_4="" + + # check positions (here we assume that mask is always composed of non literal chars + # i.e. something like ?d?l?u?s?1 is possible, but ?d?dsuffix not + charset_1_pos=$(expr index "${mask}" 1) + charset_2_pos=$(expr index "${mask}" 2) + charset_3_pos=$(expr index "${mask}" 3) + charset_4_pos=$(expr index "${mask}" 4) + + # divide each charset position by 2 since each of them occupies 2 positions in the mask + + charset_1_pos=$((charset_1_pos / 2)) + charset_2_pos=$((charset_2_pos / 2)) + charset_3_pos=$((charset_3_pos / 2)) + charset_4_pos=$((charset_4_pos / 2)) + + i=1 + + while read -r -u 9 hash; do + + pass=$(sed -n ${i}p "${OUTD}/${hash_type}_passwords.txt") + + # charset 1 + char=$(echo "${pass}" | cut -b ${charset_1_pos}) + charset_1=$(printf "%s\n%s\n" "${charset_1}" "${char}") + + # charset 2 + char=$(echo "${pass}" | cut -b ${charset_2_pos}) + charset_2=$(printf "%s\n%s\n" "${charset_2}" "${char}") + + # charset 3 + char=$(echo "${pass}" | cut -b ${charset_3_pos}) + charset_3=$(printf "%s\n%s\n" "${charset_3}" "${char}") + + # charset 4 + char=$(echo "${pass}" | cut -b ${charset_4_pos}) + charset_4=$(printf "%s\n%s\n" "${charset_4}" "${char}") + + i=$((i + 1)) + + done 9< "${OUTD}/${hash_type}_multihash_bruteforce.txt" + + # just make sure that all custom charset fields are initialized + + if [ -z "${charset_1}" ]; then + + charset_1="1" + + fi + + if [ -z "${charset_2}" ]; then + + charset_2="2" + + fi + + if [ -z "${charset_3}" ]; then + + charset_3="3" + + fi + + if [ -z "${charset_4}" ]; then + + charset_4="4" + + fi + + # unique and remove new lines + + charset_1=$(echo "${charset_1}" | sort -u | tr -d '\n') + charset_2=$(echo "${charset_2}" | sort -u | tr -d '\n') + charset_3=$(echo "${charset_3}" | sort -u | tr -d '\n') + charset_4=$(echo "${charset_4}" | sort -u | tr -d '\n') + + custom_charsets="-1 ${charset_1} -2 ${charset_2} -3 ${charset_3} -4 ${charset_4}" + fi + increment_charset_opts="" if [ ${need_hcmask} -eq 0 ]; then # the "normal" case without .hcmask file @@ -1449,6 +1579,8 @@ function attack_6() mask_offset=29 elif [ "${hash_type}" -eq 16800 ]; then max=6 + elif [ "${hash_type}" -eq 22000 ]; then + max=6 fi # special case: we need to split the first line @@ -1507,7 +1639,13 @@ function attack_6() if [ "${file_only}" -eq 1 ]; then temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt" - echo "${hash}" | base64 -d > "${temp_file}" + + if [ "${hash_type}" -ne 22000 ]; then + echo "${hash}" | base64 -d > "${temp_file}" + else + echo "${hash}" > "${temp_file}" + fi + hash="${temp_file}" fi @@ -1667,6 +1805,8 @@ function attack_6() max=8 elif [ "${hash_type}" -eq 16800 ]; then max=5 + elif [ "${hash_type}" -eq 22000 ]; then + max=5 fi if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then @@ -1695,9 +1835,13 @@ function attack_6() hash_file=${temp_file} - while read -r base64_hash; do + while read -r file_only_hash; do - echo -n "${base64_hash}" | base64 -d >> "${temp_file}" + if [ "${hash_type}" -ne 22000 ]; then + echo -n "${file_only_hash}" | base64 -d >> "${temp_file}" + else + echo "${file_only_hash}" >> "${temp_file}" + fi done < "${OUTD}/${hash_type}_hashes_multi_${i}.txt" @@ -1813,6 +1957,8 @@ function attack_7() max=1 elif [ "${hash_type}" -eq 16800 ]; then max=5 + elif [ "${hash_type}" -eq 22000 ]; then + max=5 fi # special case: we need to split the first line @@ -1860,7 +2006,13 @@ function attack_7() if [ "${file_only}" -eq 1 ]; then temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt" - echo "${hash}" | base64 -d > "${temp_file}" + + if [ "${hash_type}" -ne 22000 ]; then + echo "${hash}" | base64 -d > "${temp_file}" + else + echo "${hash}" > "${temp_file}" + fi + hash="${temp_file}" fi @@ -1916,6 +2068,26 @@ function attack_7() fi + if [ "${hash_type}" -eq 22000 ]; then + + pass_part_1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1") + pass_part_2=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict2") + + pass_part_2_len=${#pass_part_2} + + pass=${pass_part_1}${pass_part_2} + pass_len=${#pass} + + # add first x chars of password to mask and append the (old) mask + + mask_len=${#mask} + mask_len=$((mask_len / 2)) + + mask_prefix=$(echo "${pass}" | cut -b -$((pass_len - mask_len - pass_part_2_len))) + mask=${mask_prefix}${mask} + + fi + if [ "${hash_type}" -eq 20510 ]; then pass_part_1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1") @@ -2060,6 +2232,8 @@ function attack_7() max=5 elif [ "${hash_type}" -eq 16800 ]; then max=5 + elif [ "${hash_type}" -eq 22000 ]; then + max=5 fi if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then @@ -2091,9 +2265,13 @@ function attack_7() hash_file=${temp_file} - while read -r base64_hash; do + while read -r file_only_hash; do - echo -n "${base64_hash}" | base64 -d >> "${temp_file}" + if [ "${hash_type}" -ne 22000 ]; then + echo -n "${file_only_hash}" | base64 -d >> "${temp_file}" + else + echo "${file_only_hash}" >> "${temp_file}" + fi done < "${OUTD}/${hash_type}_hashes_multi_${i}.txt" @@ -2805,13 +2983,6 @@ if [ "${TYPE}" = "null" ]; then TYPE="Gpu" fi -if [ "${HT}" -eq 20510 ]; then # special case for PKZIP Master Key - if [ "${MODE}" -eq 1 ]; then # if "multi" was forced we need to exit - echo "ERROR: -m 20510 = PKZIP Master Key can only be run with a single hash" - exit 1 - fi -fi - if [ -n "${ARCHITECTURE}" ]; then BIN="${BIN}${ARCHITECTURE}" @@ -2943,6 +3114,18 @@ if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then fi fi + if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key + if [ "${MODE}" -eq 1 ]; then # if "multi" was forced we need to skip it + if [ "${HT_MIN}" -eq 20510 ]; then + if [ "${HT_MAX}" -eq 20510 ]; then + echo "ERROR: -m 20510 = PKZIP Master Key can only be run with a single hash" + fi + fi + + continue + fi + fi + if [ -z "${PACKAGE_FOLDER}" ]; then # init test data diff --git a/tools/test_modules/README.md b/tools/test_modules/README.md index a8b4e5f2b..8f91e1828 100644 --- a/tools/test_modules/README.md +++ b/tools/test_modules/README.md @@ -3,7 +3,7 @@ Each module provides the functions `module_constraints`, `module_generate_hash` and `module_verify_hash`. * The `module_constraints` function should return the minimum and maximum length of the password, salt and the combination of password and salt in following order: password (pure), salt (pure), password (optimized), salt (optimized) and combination (optimized). -Each pair should be set to -1 if the hash mode is not supporting the appropriate field. For example, if a hash-mode does not support a salt, it should be set to -1. The last field (combination) is important if the the password and the salt is stored in the same buffer in the kernel (typically raw hashes only). +Each pair should be set to -1 if the hash mode is not supporting the appropriate field. For example, if a hash-mode does not support a salt, it should be set to -1. The last field (combination) is important if the password and the salt is stored in the same buffer in the kernel (typically raw hashes only). * The first parameter to `module_generate_hash` is the password, which can be either in ASCII or binary (packed) form. The second parameter is the salt *which can be undefined for unsalted hash modes). * The `module_verify_hash` function accepts a line from the cracks file, without the newline characters. diff --git a/tools/test_modules/m07400.pm b/tools/test_modules/m07400.pm index a3eb9a241..0a21cb527 100644 --- a/tools/test_modules/m07400.pm +++ b/tools/test_modules/m07400.pm @@ -7,8 +7,9 @@ use strict; use warnings; +use Digest::SHA qw (sha256); -sub module_constraints { [[0, 256], [0, 16], [0, 15], [0, 16], [-1, -1]] } +sub module_constraints { [[0, 256], [0, 20], [0, 15], [0, 20], [-1, -1]] } sub module_generate_hash { @@ -20,11 +21,11 @@ sub module_generate_hash if (defined $iter) { - $hash_buf = crypt ($word, "\$5\$rounds=$iter\$$salt\$"); + $hash_buf = sha256crypt ($word, $salt, $iter, 1); } else { - $hash_buf = crypt ($word, "\$5\$$salt\$"); + $hash_buf = sha256crypt ($word, $salt, 5000, 0); } my $hash = sprintf ("%s", $hash_buf); @@ -93,5 +94,189 @@ sub module_verify_hash return ($new_hash, $word); } -1; +# This is a modified sha_crypts () function of pass_gen.pl from +# https://github.com/magnumripper/JohnTheRipper/blob/bleeding-jumbo/run/pass_gen.pl +# Copyright: https://github.com/magnumripper/JohnTheRipper/blob/bleeding-jumbo/doc/pass_gen.Manifest +# public domain +# written by Jim Fougeron + +# updated for new MySQL hashes by philsmd +# modified date: February 2020 +# license: public domain + +my @i64 = ('.', '/', '0'..'9', 'A'..'Z', 'a'..'z'); + +sub to64 +{ + my $v = shift; + my $n = shift; + + my $str; + + while (--$n >= 0) + { + $str .= $i64[$v & 0x3F]; + + $v >>= 6; + } + + return $str; +} + +sub sha_crypts +{ + my ($func, $bits, $key, $salt, $loops) = @_; + + my $bytes = $bits / 8; + + my $b = $func->($key . $salt . $key); + + # Add for any character in the key one byte of the alternate sum. + + my $tmp = $key . $salt; + + for (my $i = length ($key); $i > 0; $i -= $bytes) + { + if ($i > $bytes) + { + $tmp .= $b; + } + else + { + $tmp .= substr ($b, 0, $i); + } + } + + # Take the binary representation of the length of the key and for every 1 add the alternate sum, for every 0 the key. + + for (my $i = length ($key); $i > 0; $i >>= 1) + { + if (($i & 1) != 0) + { + $tmp .= $b; + } + else + { + $tmp .= $key; + } + } + + my $a = $func->($tmp); + + # NOTE, this will be the 'initial' $c value in the inner loop. + + # For every character in the password add the entire password. produces DP + + $tmp = ""; + + for (my $i = 0; $i < length ($key); $i++) + { + $tmp .= $key; + } + + my $dp = $func->($tmp); + + # Create byte sequence P + + my $p = ""; + + for (my $i = length ($key); $i > 0; $i -= $bytes) + { + if ($i > $bytes) + { + $p .= $dp; + } + else + { + $p .= substr ($dp, 0, $i); + } + } + + # produce ds + + $tmp = ""; + + my $til = 16 + ord (substr ($a, 0, 1)); + + for (my $i = 0; $i < $til; $i++) + { + $tmp .= $salt; + } + + my $ds = $func->($tmp); + + # Create byte sequence S + + my $s = ""; + + for (my $i = length ($salt); $i > 0; $i -= $bytes) + { + if ($i > $bytes) + { + $s .= $ds; + } + else + { + $s .= substr ($ds, 0, $i); + } + } + + my $c = $a; # Ok, we saved this, which will 'seed' our crypt value here in the loop. + + # now we do 5000 iterations of SHA2 (256 or 512) + + for (my $i = 0; $i < $loops; $i++) + { + if ($i & 1) { $tmp = $p; } + else { $tmp = $c; } + + if ($i % 3) { $tmp .= $s; } + if ($i % 7) { $tmp .= $p; } + + if ($i & 1) { $tmp .= $c; } + else { $tmp .= $p; } + + $c = $func->($tmp); + } + + my $inc1; my $inc2; my $mod; my $end; + + if ($bits == 256) { $inc1 = 10; $inc2 = 21; $mod = 30; $end = 0; } + else { $inc1 = 21; $inc2 = 22; $mod = 63; $end = 21; } + + my $i = 0; + $tmp = ""; + + do + { + $tmp .= to64 ((ord (substr ($c, $i, 1)) << 16) | (ord (substr ($c, ($i + $inc1) % $mod, 1)) << 8) | ord (substr ($c, ($i + $inc1 * 2) % $mod, 1)), 4); + $i = ($i + $inc2) % $mod; + } while ($i != $end); + + if ($bits == 256) { $tmp .= to64 ((ord (substr ($c, 31, 1)) << 8) | ord (substr ($c, 30, 1)), 3); } + else { $tmp .= to64 (ord (substr ($c, 63, 1)), 2); } + + return $tmp; +} + +sub sha256crypt +{ + my $pass = shift; + my $salt = shift; + my $iter = shift; + my $rounds = shift; + + my $bin = sha_crypts (\&sha256, 256, $pass, $salt, $iter); + + if ($rounds == 1) + { + return "\$5\$rounds=$iter\$" . $salt . "\$$bin"; + } + else + { + return "\$5\$" . $salt . "\$$bin"; + } +} + +1; diff --git a/tools/test_modules/m07401.pm b/tools/test_modules/m07401.pm new file mode 100644 index 000000000..2c3f5e87c --- /dev/null +++ b/tools/test_modules/m07401.pm @@ -0,0 +1,266 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256); + +sub module_constraints { [[0, 256], [20, 20], [0, 15], [20, 20], [-1, -1]] } + +my $ITERATION_MULTIPLIER = 1000; + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $cost = shift // 5; # => cost * $ITERATION_MULTIPLIER + my $lower = shift // 0; + + my $dgst = sha_crypts (\&sha256, 256, $word, $salt, $cost * $ITERATION_MULTIPLIER); + + my $salt_hex = unpack ("H*", $salt); + my $dgst_hex = unpack ("H*", $dgst); + + # default for MySQL is upper-case hexadecimals: + + if ($lower == 0) + { + $salt_hex = uc ($salt_hex); + $dgst_hex = uc ($dgst_hex); + } + + my $hash = sprintf ("\$mysql\$A\$%03i*%s*%s", + $cost, + $salt_hex, + $dgst_hex); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless ($idx >= 0); + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless defined $hash; + return unless defined $word; + + return unless (substr ($hash, 0, 9) eq '$mysql$A$'); + + $idx = index ($hash, '*'); + + return unless ($idx == 12); + + # iter: + + my $cost_factor = substr ($hash, 9, 3); + + $cost_factor = int ($cost_factor); + + return unless ($cost_factor > 0); + + # salt: + + $idx = index ($hash, '*', 13); + + return unless ($idx == 53); + + my $salt = substr ($hash, 13, 40); + + $salt = pack ("H*", $salt); + + # check for lower/upper case: + + my $digest = substr ($hash, 54); + + my $is_lower = 0; + + $is_lower = 1 if (uc ($digest) ne $digest); + + # verify: + + $word = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word, $salt, $cost_factor, $is_lower); + + return ($new_hash, $word); +} + +# This is a modified sha_crypts () function of pass_gen.pl from +# https://github.com/magnumripper/JohnTheRipper/blob/bleeding-jumbo/run/pass_gen.pl + +# Copyright: https://github.com/magnumripper/JohnTheRipper/blob/bleeding-jumbo/doc/pass_gen.Manifest +# public domain +# written by Jim Fougeron + +# updated for new MySQL hashes by philsmd +# modified date: February 2020 +# license: public domain + +my @i64 = ('.', '/', '0'..'9', 'A'..'Z', 'a'..'z'); + +sub to64 +{ + my $v = shift; + my $n = shift; + + my $str; + + while (--$n >= 0) + { + $str .= $i64[$v & 0x3F]; + + $v >>= 6; + } + + return $str; +} + +sub sha_crypts +{ + my ($func, $bits, $key, $salt, $loops) = @_; + + my $bytes = $bits / 8; + + my $b = $func->($key . $salt . $key); + + # Add for any character in the key one byte of the alternate sum. + + my $tmp = $key . $salt; + + for (my $i = length ($key); $i > 0; $i -= $bytes) + { + if ($i > $bytes) + { + $tmp .= $b; + } + else + { + $tmp .= substr ($b, 0, $i); + } + } + + # Take the binary representation of the length of the key and for every 1 add the alternate sum, for every 0 the key. + + for (my $i = length ($key); $i > 0; $i >>= 1) + { + if (($i & 1) != 0) + { + $tmp .= $b; + } + else + { + $tmp .= $key; + } + } + + my $a = $func->($tmp); + + # NOTE, this will be the 'initial' $c value in the inner loop. + + # For every character in the password add the entire password. produces DP + + $tmp = ""; + + for (my $i = 0; $i < length ($key); $i++) + { + $tmp .= $key; + } + + my $dp = $func->($tmp); + + # Create byte sequence P + + my $p = ""; + + for (my $i = length ($key); $i > 0; $i -= $bytes) + { + if ($i > $bytes) + { + $p .= $dp; + } + else + { + $p .= substr ($dp, 0, $i); + } + } + + # produce ds + + $tmp = ""; + + my $til = 16 + ord (substr ($a, 0, 1)); + + for (my $i = 0; $i < $til; $i++) + { + $tmp .= $salt; + } + + my $ds = $func->($tmp); + + # Create byte sequence S + + my $s = ""; + + for (my $i = length ($salt); $i > 0; $i -= $bytes) + { + if ($i > $bytes) + { + $s .= $ds; + } + else + { + $s .= substr ($ds, 0, $i); + } + } + + my $c = $a; # Ok, we saved this, which will 'seed' our crypt value here in the loop. + + # now we do 5000 iterations of SHA2 (256 or 512) + + for (my $i = 0; $i < $loops; $i++) + { + if ($i & 1) { $tmp = $p; } + else { $tmp = $c; } + + if ($i % 3) { $tmp .= $s; } + if ($i % 7) { $tmp .= $p; } + + if ($i & 1) { $tmp .= $c; } + else { $tmp .= $p; } + + $c = $func->($tmp); + } + + my $inc1; my $inc2; my $mod; my $end; + + if ($bits == 256) { $inc1 = 10; $inc2 = 21; $mod = 30; $end = 0; } + else { $inc1 = 21; $inc2 = 22; $mod = 63; $end = 21; } + + my $i = 0; + $tmp = ""; + + do + { + $tmp .= to64 ((ord (substr ($c, $i, 1)) << 16) | (ord (substr ($c, ($i + $inc1) % $mod, 1)) << 8) | ord (substr ($c, ($i + $inc1 * 2) % $mod, 1)), 4); + $i = ($i + $inc2) % $mod; + } while ($i != $end); + + if ($bits == 256) { $tmp .= to64 ((ord (substr ($c, 31, 1)) << 8) | ord (substr ($c, 30, 1)), 3); } + else { $tmp .= to64 (ord (substr ($c, 63, 1)), 2); } + + return $tmp; +} + +1; diff --git a/tools/test_modules/m09800.pm b/tools/test_modules/m09800.pm index 5e4c7a39d..995a92a07 100644 --- a/tools/test_modules/m09800.pm +++ b/tools/test_modules/m09800.pm @@ -20,6 +20,7 @@ sub module_generate_hash my $salt = shift; my $param = shift; my $param2 = shift; + my $param3 = shift; my $salt_bin = pack ("H*", $salt); @@ -64,7 +65,67 @@ sub module_generate_hash my $encrypted1 = $m->RC4 ($data1_buf); my $encrypted2 = $m->RC4 ($data2_buf); - my $hash = sprintf ("\$oldoffice\$%d*%s*%s*%s", $version, $salt, unpack ("H*", $encrypted1), unpack ("H*", $encrypted2)); + + my $secblock = ""; + + if ($version == 3) + { + my $key2 = substr (sha1 ($tmp . "\x01\x00\x00\x00"), 0, 5) . "\x00" x 11; + + my $rc4 = Crypt::RC4->new ($key2); + + if (defined $param3) # verify/decrypt: + { + if (length ($param3) > 0) + { + my $decrypted = $rc4->RC4 (pack ("H*", $param3)); + + # count the number of NUL (\x00) bytes: + + my $num_nul_bytes = 0; + + for (my $i = 0; $i < 32; $i++) + { + $num_nul_bytes++ if (substr ($decrypted, $i, 1) eq "\x00"); + } + + if ($num_nul_bytes < 10) + { + $secblock = "*"; # incorrect/fake/empty result + } + else + { + $secblock = "*$param3"; + } + } + } + else + { + if (random_number (0, 1) == 1) # the second block data is optional + { + my $num_zeros = random_number (10, 32); # at least 10 NUL bytes + + $secblock = "\x00" x $num_zeros; + + # fill the buffer with some random bytes (up to 32 bytes total): + + for (my $i = 0; $i < 32 - $num_zeros; $i++) + { + my $idx = random_number (0, $num_zeros + $i); # insert at random position + + my $c = random_bytes (1); # 0x00-0xff + + $secblock = substr ($secblock, 0, $idx) . $c . substr ($secblock, $idx); + } + + $secblock = $rc4->RC4 ($secblock); + + $secblock = "*" . unpack ("H*", $secblock); + } + } + } + + my $hash = sprintf ("\$oldoffice\$%d*%s*%s*%s%s", $version, $salt, unpack ("H*", $encrypted1), unpack ("H*", $encrypted2), $secblock); return $hash; } @@ -81,7 +142,9 @@ sub module_verify_hash my @data = split /\*/, $hash_in; - return unless scalar @data == 4; + my $num_fields = scalar @data; + + return unless (($num_fields == 4) || ($num_fields == 5)); my $signature = shift @data; @@ -95,6 +158,15 @@ sub module_verify_hash my $param = shift @data; my $param2 = substr ($signature, 11, 1); + my $param3 = ""; + + if ($num_fields == 5) + { + shift @data; # ignore the "digest" + + $param3 = shift @data; + } + return unless defined $salt; return unless defined $word; return unless defined $param; @@ -102,7 +174,7 @@ sub module_verify_hash $word = pack_if_HEX_notation ($word); - my $new_hash = module_generate_hash ($word, $salt, $param, $param2); + my $new_hash = module_generate_hash ($word, $salt, $param, $param2, $param3); return ($new_hash, $word); } diff --git a/tools/test_modules/m10901.pm b/tools/test_modules/m10901.pm new file mode 100644 index 000000000..d74ee2c29 --- /dev/null +++ b/tools/test_modules/m10901.pm @@ -0,0 +1,78 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; +use Crypt::PBKDF2; +use MIME::Base64; + +sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iter = shift // 8192; ## https://pagure.io/389-ds-base/blob/master/f/ldap/servers/plugins/pwdstorage/pbkdf2_pwd.c + + if (length $salt == 0) + { + $salt = random_bytes (16); + } + + my $pbkdf2 = Crypt::PBKDF2->new( + hash_class => 'HMACSHA2', + iterations => $iter, + output_len => 256, + salt_len => 64, + ); + + my $p = $pbkdf2->generate($word, $salt); + + my $decoded_hash = $pbkdf2->decode_string($p); + + my $diter = $decoded_hash->{"iterations"}; + + my $iterbytes = pack('I', unpack('N*', pack('L*', $diter))); + + my $dsalt = $decoded_hash->{"salt"}; + + my $dhash = $decoded_hash->{"hash"}; + + my $tmp = $iterbytes . $dsalt . $dhash; + + my $hash = "{PBKDF2_SHA256}" . encode_base64($tmp, ''); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless (substr ($hash, 0, 15) eq '{PBKDF2_SHA256}'); + + my $hashbytes = decode_base64(substr ($hash, 15, length $hash)); + + my $iterbytes = substr $hashbytes, 0, 4; + + my $iter = unpack('N*', pack('L*', unpack("I",$iterbytes))); + + my $salt = substr $hashbytes, 4, 64; + + return unless defined $salt; + return unless defined $iter; + return unless defined $word; + + my $new_hash = module_generate_hash ($word, $salt, $iter); + + return ($new_hash, $word); +} + +1; + diff --git a/tools/test_modules/m11600.pm b/tools/test_modules/m11600.pm index 1bdf02efe..195a04e88 100644 --- a/tools/test_modules/m11600.pm +++ b/tools/test_modules/m11600.pm @@ -13,7 +13,7 @@ use Digest::CRC qw (crc32); use Digest::SHA qw (sha256); use Encode; -sub module_constraints { [[0, 256], [0, 16], [-1, -1], [-1, -1], [-1, -1]] } +sub module_constraints { [[0, 256], [0, 16], [0, 20], [0, 16], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m13400.pm b/tools/test_modules/m13400.pm index 51dd1c326..f4a641df5 100644 --- a/tools/test_modules/m13400.pm +++ b/tools/test_modules/m13400.pm @@ -299,6 +299,8 @@ sub module_generate_hash $expected_bytes = $cipher->decrypt ($contents_hash); + $expected_bytes = substr ($expected_bytes . "\x00" x 32, 0, 32); # padding + $hash = sprintf ('$keepass$*%d*%d*%d*%s*%s*%s*%s*%s%s', $version, $iteration, diff --git a/tools/test_modules/m13600.pm b/tools/test_modules/m13600.pm index 86c5667bc..ca04a7516 100644 --- a/tools/test_modules/m13600.pm +++ b/tools/test_modules/m13600.pm @@ -94,7 +94,7 @@ sub module_generate_hash my $auth = hmac_hex ($data, $key_bin, \&sha1, 64); - my $hash = sprintf ('$zip2$*%u*%u*%u*%s*%s*%u*%s*%s*$/zip2$', $type, $mode, $magic, $salt, $verify_bytes, $compress_length, $data, substr ($auth, 0, 20)); + my $hash = sprintf ('$zip2$*%u*%u*%u*%s*%s*%x*%s*%s*$/zip2$', $type, $mode, $magic, $salt, $verify_bytes, $compress_length, $data, substr ($auth, 0, 20)); return $hash; } diff --git a/tools/test_modules/m15400.pm b/tools/test_modules/m15400.pm index eb8395170..67c6d4641 100644 --- a/tools/test_modules/m15400.pm +++ b/tools/test_modules/m15400.pm @@ -10,7 +10,7 @@ use warnings; use Crypt::OpenSSH::ChachaPoly; -sub module_constraints { [[-1, -1], [-1, -1], [32, 32], [-1, -1], [-1, -1]] } +sub module_constraints { [[32, 32], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { @@ -40,8 +40,9 @@ sub module_generate_hash my $plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0a2b4c6d8e"; my $eight_byte_iv = pack ("H*", $iv); my $eight_byte_counter = pack ("H*", $counter); - my $pad_len = 32 - length ($word); - my $key = $word . "\0" x $pad_len; + #my $pad_len = 32 - length ($word); + #my $key = $word . "\0" x $pad_len; + my $key = $word; my $cipher = Crypt::OpenSSH::ChachaPoly->new ($key); diff --git a/tools/test_modules/m21200.pm b/tools/test_modules/m21200.pm index 400afd6cb..3386d285d 100644 --- a/tools/test_modules/m21200.pm +++ b/tools/test_modules/m21200.pm @@ -11,12 +11,12 @@ use warnings; use Digest::MD5 qw (md5_hex); use Digest::SHA qw (sha1_hex); -sub module_constraints { [[0, 256], [19, 19], [0, 55], [-1, -1], [-1, -1]] } +sub module_constraints { [[0, 256], [0, 256], [0, 55], [-1, -1], [-1, -1]] } sub module_generate_hash { my $word = shift; - my $salt = random_hex_string (19, 19); + my $salt = shift; my $digest = md5_hex (sha1_hex ($salt) . md5_hex ($word)); diff --git a/tools/test_modules/m21300.pm b/tools/test_modules/m21300.pm index 6973f8946..fe5e2be44 100644 --- a/tools/test_modules/m21300.pm +++ b/tools/test_modules/m21300.pm @@ -11,18 +11,13 @@ use warnings; use Digest::MD5 qw (md5_hex); use Digest::SHA qw (sha1_hex); -sub module_constraints { [[0, 256], [1, 256], [0, 55], [-1, -1], [-1, -1]] } +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } sub module_generate_hash { my $word = shift; my $salt = shift; - if (length $salt == 0) - { - $salt = random_hex_string (1, 256); - } - my $digest = md5_hex ($salt . sha1_hex ($salt . $word)); my $hash = sprintf ("%s:%s", $digest, $salt); diff --git a/tools/test_modules/m21600.pm b/tools/test_modules/m21600.pm new file mode 100644 index 000000000..03f480059 --- /dev/null +++ b/tools/test_modules/m21600.pm @@ -0,0 +1,70 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use MIME::Base64 qw (encode_base64 decode_base64); +use Crypt::PBKDF2; + +sub module_constraints { [[0, 256], [1, 15], [-1, -1], [-1, -1], [-1, -1]] } + +#pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff"; + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iterations = shift // 1000; + my $out_len = shift // 20; + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 512), + iterations => $iterations, + output_len => $out_len + ); + + my $digest = $pbkdf2->PBKDF2 ($salt, $word); + my $digest_hex = unpack "H*", $digest; + + my $hash = sprintf ('pbkdf2(%i,20,sha512)$%s$%s', $iterations, $salt, $digest_hex); + + return $hash; +} + +#pbkdf2(1000,20,sha512)$a2a2ca127df6bc19$77bb5a3d129e2ce710daaefeefef8356c4c827ff"; + +sub module_verify_hash +{ + my $line = shift; + + my ($digest, $word) = split (/:([^:]+)$/, $line); + + return unless defined $digest; + return unless defined $word; + + my ($intro, $salt, $hash_encoded) = split ('$', $digest); + my ($signature, $iterations, $len, $prf) = split (m/[\(\),]/, $digest); + + return unless ($signature eq 'pbkdf2'); + return unless ($prf eq 'sha512'); + return unless defined $iterations; + return unless defined $hash_encoded; + + my $hash = pack 'H*',$hash_encoded; + + my $out_len = length ($hash); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt, $iterations, $out_len); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m21700.pm b/tools/test_modules/m21700.pm new file mode 100644 index 000000000..fc0f8a617 --- /dev/null +++ b/tools/test_modules/m21700.pm @@ -0,0 +1,284 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use Crypt::OpenSSL::EC; +use Crypt::OpenSSL::Bignum::CTX; + +use Digest::SHA qw (sha256 sha512); +use Digest::HMAC qw (hmac_hex); + +use Crypt::CBC; +use Compress::Zlib; + +sub module_constraints { [[0, 256], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } + +my $MAX_DATA_LEN = 16384; + +# helper function: key derivation from password and one point on the curve (public key) + +sub generate_key +{ + my $word = shift; + my $ephemeral_pubkey = shift; + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 512), + iterations => 1024, + output_len => 64 + ); + + my $private_key = $pbkdf2->PBKDF2 ("", $word); + + my $method = Crypt::OpenSSL::EC::EC_GFp_simple_method (); # or Crypt::OpenSSL::EC::EC_GFp_mont_method () + + my $group = Crypt::OpenSSL::EC::EC_GROUP::new ($method); + + # secp256k1 elliptic curve parameters + + my $p = Crypt::OpenSSL::Bignum->new_from_hex ("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); + my $a = Crypt::OpenSSL::Bignum->new_from_hex ("0000000000000000000000000000000000000000000000000000000000000000"); + my $b = Crypt::OpenSSL::Bignum->new_from_hex ("0000000000000000000000000000000000000000000000000000000000000007"); + + my $ctx = Crypt::OpenSSL::Bignum::CTX->new (); + + Crypt::OpenSSL::EC::EC_GROUP::set_curve_GFp ($group, $p, $a, $b, $ctx); + + my $Gx = Crypt::OpenSSL::Bignum->new_from_hex ("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"); + my $Gy = Crypt::OpenSSL::Bignum->new_from_hex ("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"); + + my $G = Crypt::OpenSSL::EC::EC_POINT::new ($group); + + Crypt::OpenSSL::EC::EC_POINT::set_affine_coordinates_GFp ($group, $G, $Gx, $Gy, $ctx); + + my $order = Crypt::OpenSSL::Bignum->new_from_hex ("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); + my $cofactor = Crypt::OpenSSL::Bignum->new_from_hex ("0000000000000000000000000000000000000000000000000000000000000001"); + + Crypt::OpenSSL::EC::EC_GROUP::set_generator ($group, $G, $order, $cofactor); # or cofactor = Crypt::OpenSSL::Bignum->one () + + + # scalar + + # hash mod GROUP_ORDER + + my $m = Crypt::OpenSSL::Bignum->new_from_hex (unpack ("H*", $private_key)); + + + # point (public key, ephemeral_pubkey) + + my $Q = Crypt::OpenSSL::EC::EC_POINT::new ($group); + + my $ret = Crypt::OpenSSL::EC::EC_POINT::oct2point ($group, $Q, $ephemeral_pubkey, $ctx); + + if ($ret == 0) + { + return; + } + + # multiply + + my $result = Crypt::OpenSSL::EC::EC_POINT::new ($group); + + my $n = Crypt::OpenSSL::Bignum->zero (); + + Crypt::OpenSSL::EC::EC_POINT::mul ($group, $result, $n, $Q, $m, $ctx); + + # get compressed public/shared key format + + my $public_key = Crypt::OpenSSL::EC::EC_POINT::point2oct ($group, $result, &Crypt::OpenSSL::EC::POINT_CONVERSION_COMPRESSED, $ctx); + + + # hash the compressed public key with sha512 () + + return sha512 ($public_key); +} + +sub module_generate_hash +{ + my $word = shift; + + my $ephemeral_pubkey = ""; + my $key = ""; + + my $valid_point = 0; + + while ($valid_point == 0) + { + my $sign_of_curve_point = int (rand (2)); # 2 possibilities: 02... or 03... ephemeral public keys + + $ephemeral_pubkey = pack ("H*", "0" . ($sign_of_curve_point + 2) . random_hex_string (64)); + + $key = generate_key ($word, $ephemeral_pubkey); + + if (defined ($key)) + { + $valid_point = 1; + } + } + + my $valid_compression_rate = 0; + + my $compressed_data = ""; + + while ($valid_compression_rate == 0) + { + my $data_buf = "{\r\n \""; + + if (int (rand (2)) == 1) # alternative with different line break + { + $data_buf = "{\n \""; + } + + # we assume a compression rate of 30% (smaller if compressed) + + my $data_length = 64 + int (rand (int ($MAX_DATA_LEN * 1.30 + 1))); + + my $random_length = $data_length - length ($data_buf); + + if ($random_length > 0) + { + $data_buf .= random_string ($random_length); # or random_bytes ($random_length); + } + + # compress/deflate the data: + + my $deflator = deflateInit (-WindowBits => MAX_WBITS); + + my $header = $deflator->deflate ($data_buf); + + $compressed_data = $deflator->flush (); + + $compressed_data = $header . $compressed_data; + + # check if data is valid: + + my $compressed_data_len = length ($compressed_data); + + if ($compressed_data_len < 64) # minimum length required by hashcat's tokenizer + { + next; + } + + if (($compressed_data_len + 15) > $MAX_DATA_LEN) # version 5 is not supported in -m 21700 + { + next; + } + + $valid_compression_rate = 1; + } + + + # encrypt the data with AES128: + + my $iv = substr ($key, 0, 16); + my $aes_key = substr ($key, 16, 16); + + my $aes = Crypt::CBC->new ({ + cipher => "Crypt::Rijndael", + keysize => 16, + literal_key => 1, + header => "none", + iv => $iv, + key => $aes_key + }); + + my $encrypted_data = $aes->encrypt ($compressed_data); + + + # MAC: + + my $hmac_key = substr ($key, 32, 32); + + my $mac = hmac_hex ($encrypted_data, $hmac_key, \&sha256); + + # format the hash: + + my $hash = sprintf ("\$electrum\$4*%s*%s*%s", + unpack ("H*", $ephemeral_pubkey), + unpack ("H*", $encrypted_data), + $mac + ); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my $hash_in = substr ($line, 0, $index1); + + my $word = substr ($line, $index1 + 1); + + return if (substr ($hash_in, 0, 10) ne "\$electrum\$"); + + + # version: + + my $index2 = index ($hash_in, "*"); + + return if $index2 < 1; + + my $version = substr ($hash_in, 10, $index2 - 10); + + return if ($version ne "4"); + + + # public key: + + $index1 = index ($line, "*", $index2 + 1); + + return if $index1 < 1; + + my $ephemeral_pubkey = substr ($hash_in, $index2 + 1, $index1 - $index2 - 1); + + $ephemeral_pubkey = pack ("H*", $ephemeral_pubkey); + + + # data: + + $index2 = index ($hash_in, "*", $index1 + 1); + + return if $index2 < 1; + + my $data_buf = substr ($hash_in, $index1 + 1, $index2 - $index1 - 1); + + $data_buf = pack ("H*", $data_buf); + + + # MAC: + + my $mac = substr ($hash_in, $index2 + 1); + + + # Start: + + my $new_hash = ""; + + my $key = generate_key ($word, $ephemeral_pubkey); + + my $hmac_key = substr ($key, 32, 32); + + my $mac_gen = hmac_hex ($data_buf, $hmac_key, \&sha256); + + if ($mac_gen eq $mac) + { + $new_hash = $hash_in; + } + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m21800.pm b/tools/test_modules/m21800.pm new file mode 100644 index 000000000..705f066dd --- /dev/null +++ b/tools/test_modules/m21800.pm @@ -0,0 +1,338 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use Crypt::OpenSSL::EC; +use Crypt::OpenSSL::Bignum::CTX; + +use Digest::SHA qw (sha256 sha512); +use Digest::HMAC qw (hmac_hex); + +use Crypt::CBC; +use Compress::Zlib; + +sub module_constraints { [[0, 256], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } + +my $MAX_DATA_LEN = 16384; +my $TRUNCATE_DATA_LEN = 1024; + +# helper function: key derivation from password and one point on the curve (public key) + +sub generate_key +{ + my $word = shift; + my $ephemeral_pubkey = shift; + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 512), + iterations => 1024, + output_len => 64 + ); + + my $private_key = $pbkdf2->PBKDF2 ("", $word); + + my $method = Crypt::OpenSSL::EC::EC_GFp_simple_method (); # or Crypt::OpenSSL::EC::EC_GFp_mont_method () + + my $group = Crypt::OpenSSL::EC::EC_GROUP::new ($method); + + # secp256k1 elliptic curve parameters + + my $p = Crypt::OpenSSL::Bignum->new_from_hex ("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); + my $a = Crypt::OpenSSL::Bignum->new_from_hex ("0000000000000000000000000000000000000000000000000000000000000000"); + my $b = Crypt::OpenSSL::Bignum->new_from_hex ("0000000000000000000000000000000000000000000000000000000000000007"); + + my $ctx = Crypt::OpenSSL::Bignum::CTX->new (); + + Crypt::OpenSSL::EC::EC_GROUP::set_curve_GFp ($group, $p, $a, $b, $ctx); + + my $Gx = Crypt::OpenSSL::Bignum->new_from_hex ("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"); + my $Gy = Crypt::OpenSSL::Bignum->new_from_hex ("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"); + + my $G = Crypt::OpenSSL::EC::EC_POINT::new ($group); + + Crypt::OpenSSL::EC::EC_POINT::set_affine_coordinates_GFp ($group, $G, $Gx, $Gy, $ctx); + + my $order = Crypt::OpenSSL::Bignum->new_from_hex ("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); + my $cofactor = Crypt::OpenSSL::Bignum->new_from_hex ("0000000000000000000000000000000000000000000000000000000000000001"); + + Crypt::OpenSSL::EC::EC_GROUP::set_generator ($group, $G, $order, $cofactor); # or cofactor = Crypt::OpenSSL::Bignum->one () + + + # scalar + + # hash mod GROUP_ORDER + + my $m = Crypt::OpenSSL::Bignum->new_from_hex (unpack ("H*", $private_key)); + + + # point (public key, ephemeral_pubkey) + + my $Q = Crypt::OpenSSL::EC::EC_POINT::new ($group); + + my $ret = Crypt::OpenSSL::EC::EC_POINT::oct2point ($group, $Q, $ephemeral_pubkey, $ctx); + + if ($ret == 0) + { + return; + } + + # multiply + + my $result = Crypt::OpenSSL::EC::EC_POINT::new ($group); + + my $n = Crypt::OpenSSL::Bignum->zero (); + + Crypt::OpenSSL::EC::EC_POINT::mul ($group, $result, $n, $Q, $m, $ctx); + + # get compressed public/shared key format + + my $public_key = Crypt::OpenSSL::EC::EC_POINT::point2oct ($group, $result, &Crypt::OpenSSL::EC::POINT_CONVERSION_COMPRESSED, $ctx); + + + # hash the compressed public key with sha512 () + + return sha512 ($public_key); +} + +sub module_generate_hash +{ + my $word = shift; + + my $ephemeral_pubkey = ""; + my $key = ""; + + my $valid_point = 0; + + while ($valid_point == 0) + { + my $sign_of_curve_point = int (rand (2)); # 2 possibilities: 02... or 03... ephemeral public keys + + $ephemeral_pubkey = pack ("H*", "0" . ($sign_of_curve_point + 2) . random_hex_string (64)); + + $key = generate_key ($word, $ephemeral_pubkey); + + if (defined ($key)) + { + $valid_point = 1; + } + } + + my $valid_compression_rate = 0; + + my $compressed_data = ""; + + while ($valid_compression_rate == 0) + { + my $data_buf = "{\r\n \""; + + if (int (rand (2)) == 1) # alternative with different line break + { + $data_buf = "{\n \""; + } + + # we assume a compression rate of 30% (smaller if compressed) + + my $data_length = $MAX_DATA_LEN + int (rand (int ($MAX_DATA_LEN * 1.30 + 1))); + + my $random_length = $data_length - length ($data_buf); + + if ($random_length > 0) + { + $data_buf .= random_string ($random_length); # or random_bytes ($random_length); + } + + # compress/deflate the data: + + my $deflator = deflateInit (-WindowBits => MAX_WBITS); + + my $header = $deflator->deflate ($data_buf); + + $compressed_data = $deflator->flush (); + + $compressed_data = $header . $compressed_data; + + # check if data is valid: + + if ((length ($compressed_data) + 15) <= $MAX_DATA_LEN) + { + next; + } + + my $zlib_rate = ord (substr ($compressed_data, 2, 1)) & 0x07; + + if (($zlib_rate != 0x04) && ($zlib_rate != 0x05)) + { + next; + } + + $valid_compression_rate = 1; + } + + + # encrypt the data with AES128: + + my $iv = substr ($key, 0, 16); + my $aes_key = substr ($key, 16, 16); + + my $aes = Crypt::CBC->new ({ + cipher => "Crypt::Rijndael", + keysize => 16, + literal_key => 1, + header => "none", + iv => $iv, + key => $aes_key + }); + + my $encrypted_data = $aes->encrypt ($compressed_data); + + + # MAC: + + my $hmac_key = substr ($key, 32, 32); + + my $mac = hmac_hex ($encrypted_data, $hmac_key, \&sha256); + + # truncate for version 5: + + $encrypted_data = substr ($encrypted_data, 0, $TRUNCATE_DATA_LEN); + + # format the hash: + + my $hash = sprintf ("\$electrum\$5*%s*%s*%s", + unpack ("H*", $ephemeral_pubkey), + unpack ("H*", $encrypted_data), + $mac + ); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my $hash_in = substr ($line, 0, $index1); + + my $word = substr ($line, $index1 + 1); + + return if (substr ($hash_in, 0, 10) ne "\$electrum\$"); + + + # version: + + my $index2 = index ($hash_in, "*"); + + return if $index2 < 1; + + my $version = substr ($hash_in, 10, $index2 - 10); + + return if ($version ne "5"); + + + # public key: + + $index1 = index ($line, "*", $index2 + 1); + + return if $index1 < 1; + + my $ephemeral_pubkey = substr ($hash_in, $index2 + 1, $index1 - $index2 - 1); + + $ephemeral_pubkey = pack ("H*", $ephemeral_pubkey); + + + # data: + + $index2 = index ($hash_in, "*", $index1 + 1); + + return if $index2 < 1; + + my $data_buf = substr ($hash_in, $index1 + 1, $index2 - $index1 - 1); + + $data_buf = pack ("H*", $data_buf); + + + # MAC: + + my $mac = substr ($hash_in, $index2 + 1); + + + # Start: + + my $new_hash = ""; + + my $key = generate_key ($word, $ephemeral_pubkey); + + + # decrypt the data with AES128 + + my $iv = substr ($key, 0, 16); + my $aes_key = substr ($key, 16, 16); + + my $aes = Crypt::CBC->new ({ + cipher => "Crypt::Rijndael", + keysize => 16, + literal_key => 1, + header => "none", + iv => $iv, + key => $aes_key + }); + + my $decrypted_data = $aes->decrypt ($data_buf); + + + # some early reject/validation steps: + + # first test: + + if (substr ($decrypted_data, 0, 2) ne "\x78\x9c") + { + return ($new_hash, $word); + } + + # second test: + + if ((ord (substr ($decrypted_data, 2, 1)) & 0x07) != 0x05) + { + return ($new_hash, $word); + } + + + # decompress/inflate: + + my $inflator = inflateInit (-WindowBits => MAX_WBITS); + + my ($decompressed_data, $status) = $inflator->inflate ($decrypted_data); + + + # final validation of data: + + if (length ($status) > 0) + { + return ($new_hash, $word); + } + + if ((substr ($decompressed_data, 0, 7) ne "{\n \"") && + (substr ($decompressed_data, 0, 8) ne "{\r\n \"")) + { + return ($new_hash, $word); + } + + $new_hash = $hash_in; + + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m22000.pm b/tools/test_modules/m22000.pm new file mode 100644 index 000000000..210eaaa75 --- /dev/null +++ b/tools/test_modules/m22000.pm @@ -0,0 +1,569 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use Digest::MD5 qw (md5); +use Digest::SHA qw (sha1 sha256); +use Digest::HMAC qw (hmac hmac_hex); +use Digest::CMAC; + +sub module_constraints { [[8, 63], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $type = shift // random_number (1, 2); + my $macap = shift; + my $macsta = shift; + my $essid = shift; + my $anonce = shift; + my $eapol = shift; + my $mp = shift; + + my $hash; + + if ($type == 1) + { + if (!defined ($macap)) + { + $macap = unpack ("H*", random_bytes (6)); + } + + if (!defined ($macsta)) + { + $macsta = unpack ("H*", random_bytes (6)); + } + + if (!defined ($essid)) + { + $essid = unpack ("H*", random_bytes (random_number (0, 32) & 0x1e)); + } + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => 4096, + output_len => 32, + ); + + my $essid_bin = pack ("H*", $essid); + + my $pmk = $pbkdf2->PBKDF2 ($essid_bin, $word); + + my $macap_bin = pack ("H*", $macap); + my $macsta_bin = pack ("H*", $macsta); + + my $data = "PMK Name" . $macap_bin . $macsta_bin; + + my $pmkid = hmac_hex ($data, $pmk, \&sha1); + + $hash = sprintf ("WPA*%02x*%s*%s*%s*%s***", $type, substr ($pmkid, 0, 32), $macap, $macsta, $essid); + } + elsif ($type == 2) + { + if (!defined ($macap)) + { + $macap = random_bytes (6); + } + else + { + $macap = pack ("H*", $macap); + } + + if (!defined ($macsta)) + { + $macsta = random_bytes (6); + } + else + { + $macsta = pack ("H*", $macsta); + } + + if (!defined ($mp)) + { + $mp = "\x00"; + } + else + { + $mp = pack ("H*", $mp); + } + + my $keyver; + + my $snonce; + + if (!defined ($eapol)) + { + $keyver = random_number (1, 3); # 1, 2 or 3 + + $snonce = random_bytes (32); + + $eapol = gen_random_wpa_eapol ($keyver, $snonce); + } + else + { + $eapol = pack ("H*", $eapol); + + my $key_info = unpack ("n*", substr ($eapol, 5, 2)); + + $keyver = $key_info & 3; + + $snonce = substr ($eapol, 17, 32); + } + + if (!defined ($anonce)) + { + $anonce = random_bytes (32); + } + else + { + $anonce = pack ("H*", $anonce); + } + + if (!defined ($essid)) + { + $essid = unpack ("H*", random_bytes (random_number (0, 32) & 0x1e)); + } + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => 4096, + output_len => 32, + ); + + my $essid_bin = pack ("H*", $essid); + + my $pmk = $pbkdf2->PBKDF2 ($essid_bin, $word); + + # Pairwise Transient Key (PTK) transformation + + my $ptk = wpa_prf_512 ($keyver, $pmk, $macsta, $macap, $snonce, $anonce); + + # generate the Message Integrity Code (MIC) + + my $mic = ""; + + if ($keyver == 1) # WPA1 => MD5 + { + $mic = hmac ($eapol, $ptk, \&md5); + } + elsif ($keyver == 2) # WPA2 => SHA1 + { + $mic = hmac ($eapol, $ptk, \&sha1); + } + elsif ($keyver == 3) # WPA2 => SHA256 + AES-CMAC + { + my $omac1 = Digest::CMAC->new ($ptk, 'Crypt::Rijndael'); + + $omac1->add ($eapol); + + $mic = $omac1->digest; + } + + $mic = substr ($mic, 0, 16); + + $hash = sprintf ("WPA*%02x*%s*%s*%s*%s*%s*%s*%s", $type, unpack ("H*", $mic), unpack ("H*", $macap), unpack ("H*", $macsta), $essid, unpack ("H*", $anonce), unpack ("H*", $eapol), unpack ("H*", $mp)); + } + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my $word = substr ($line, $index1 + 1); + + my $hash_in = substr ($line, 0, $index1); + + my @data = split ('\*', $hash_in); + + my ($signature, $type, $pmkidmic, $macap, $macsta, $essid, $anonce, $eapol, $mp) = @data; + + return unless defined $signature; + return unless defined $type; + return unless defined $pmkidmic; + return unless defined $macap; + return unless defined $macsta; + return unless defined $essid; + + return unless ($signature eq "WPA"); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, undef, $type, $macap, $macsta, $essid, $anonce, $eapol, $mp); + + return ($new_hash, $word); +} + +sub gen_random_wpa_eapol +{ + my $keyver = shift; + my $snonce = shift; + + my $ret = ""; + + # version + + my $version = 1; # 802.1X-2001 + + $ret .= pack ("C*", $version); + + my $type = 3; # means that this EAPOL frame is used to transfer key information + + $ret .= pack ("C*", $type); + + my $length; # length of remaining data + + if ($keyver == 1) + { + $length = 119; + } + else + { + $length = 117; + } + + $ret .= pack ("n*", $length); + + my $descriptor_type; + + if ($keyver == 1) + { + $descriptor_type = 254; # EAPOL WPA key + } + else + { + $descriptor_type = 1; # EAPOL RSN key + } + + $ret .= pack ("C*", $descriptor_type); + + # key_info is a bit vector: + # generated from these 13 bits: encrypted key data, request, error, secure, key mic, key ack, install, key index (2), key type, key descriptor (3) + + my $key_info = 0; + + $key_info |= 1 << 8; # set key MIC + $key_info |= 1 << 3; # set if it is a pairwise key + + if ($keyver == 1) + { + $key_info |= 1; # RC4 Cipher, HMAC-MD5 MIC + } + elsif ($keyver == 2) + { + $key_info |= 2; # AES Cipher, HMAC-SHA1 MIC + } + elsif ($keyver == 3) + { + $key_info |= 3; # AES-CMAC + } + + $ret .= pack ("n*", $key_info); + + my $key_length; + + if ($keyver == 1) + { + $key_length = 32; + } + else + { + $key_length = 0; + } + + $ret .= pack ("n*", $key_length); + + my $replay_counter = 1; + + $ret .= pack ("Q>*", $replay_counter); + + $ret .= $snonce; + + my $key_iv = "\x00" x 16; + + $ret .= $key_iv; + + my $key_rsc = "\x00" x 8; + + $ret .= $key_rsc; + + my $key_id = "\x00" x 8; + + $ret .= $key_id; + + my $key_mic = "\x00" x 16; + + $ret .= $key_mic; + + my $key_data_len; + + if ($keyver == 1) + { + $key_data_len = 24; # length of the key_data (== WPA info) + } + else + { + $key_data_len = 22; # length of the key_data (== RSN info) + } + + $ret .= pack ("n*", $key_data_len); + + my $key_data = ""; + + if ($keyver == 1) + { + # wpa info + + my $wpa_info = ""; + + my $vendor_specific_data = ""; + + my $tag_number = 221; # means it is a vendor specific tag + + $vendor_specific_data .= pack ("C*", $tag_number); + + my $tag_len = 22; # length of the remaining "tag data" + + $vendor_specific_data .= pack ("C*", $tag_len); + + my $vendor_specific_oui = pack ("H*", "0050f2"); # microsoft + + $vendor_specific_data .= $vendor_specific_oui; + + my $vendor_specific_oui_type = 1; # WPA Information Element + + $vendor_specific_data .= pack ("C*", $vendor_specific_oui_type); + + my $vendor_specific_wpa_version = 1; + + $vendor_specific_data .= pack ("v*", $vendor_specific_wpa_version); + + # multicast + + my $vendor_specific_multicast_oui = pack ("H*", "0050f2"); + + $vendor_specific_data .= $vendor_specific_multicast_oui; + + my $vendor_specific_multicast_type = 2; # TKIP + + $vendor_specific_data .= pack ("C*", $vendor_specific_multicast_type); + + # unicast + + my $vendor_specific_unicast_count = 1; + + $vendor_specific_data .= pack ("v*", $vendor_specific_unicast_count); + + my $vendor_specific_unicast_oui = pack ("H*", "0050f2"); + + $vendor_specific_data .= $vendor_specific_unicast_oui; + + my $vendor_specific_unicast_type = 2; # TKIP + + $vendor_specific_data .= pack ("C*", $vendor_specific_unicast_type); + + # Auth Key Management (AKM) + + my $auth_key_management_count = 1; + + $vendor_specific_data .= pack ("v*", $auth_key_management_count); + + my $auth_key_management_oui = pack ("H*", "0050f2"); + + $vendor_specific_data .= $auth_key_management_oui; + + my $auth_key_management_type = 2; # Pre-Shared Key (PSK) + + $vendor_specific_data .= pack ("C*", $auth_key_management_type); + + $wpa_info = $vendor_specific_data; + + $key_data = $wpa_info; + } + else + { + # rsn info + + my $rsn_info = ""; + + my $tag_number = 48; # RSN info + + $rsn_info .= pack ("C*", $tag_number); + + my $tag_len = 20; # length of the remaining "tag_data" + + $rsn_info .= pack ("C*", $tag_len); + + my $rsn_version = 1; + + $rsn_info .= pack ("v*", $rsn_version); + + # group cipher suite + + my $group_cipher_suite_oui = pack ("H*", "000fac"); # Ieee8021 + + $rsn_info .= $group_cipher_suite_oui; + + my $group_cipher_suite_type = 4; # AES (CCM) + + $rsn_info .= pack ("C*", $group_cipher_suite_type); + + # pairwise cipher suite + + my $pairwise_cipher_suite_count = 1; + + $rsn_info .= pack ("v*", $pairwise_cipher_suite_count); + + my $pairwise_cipher_suite_oui = pack ("H*", "000fac"); # Ieee8021 + + $rsn_info .= $pairwise_cipher_suite_oui; + + my $pairwise_cipher_suite_type = 4; # AES (CCM) + + $rsn_info .= pack ("C*", $pairwise_cipher_suite_type); + + # Auth Key Management (AKM) + + my $auth_key_management_count = 1; + + $rsn_info .= pack ("v*", $auth_key_management_count); + + my $auth_key_management_oui = pack ("H*", "000fac"); # Ieee8021 + + $rsn_info .= $auth_key_management_oui; + + my $auth_key_management_type = 2; # Pre-Shared Key (PSK) + + $rsn_info .= pack ("C*", $auth_key_management_type); + + # RSN Capabilities + + # bit vector of these 9 bits: peerkey enabled, management frame protection (MFP) capable, MFP required, + # RSN GTKSA Capabilities (2), RSN PTKSA Capabilities (2), no pairwise Capabilities, Pre-Auth Capabilities + + my $rsn_capabilities = pack ("H*", "0000"); + + $rsn_info .= $rsn_capabilities; + + $key_data = $rsn_info; + } + + $ret .= $key_data; + + return $ret; +} + +sub wpa_prf_512 +{ + my $keyver = shift; + my $pmk = shift; + my $macsta = shift; + my $macap = shift; + my $snonce = shift; + my $anonce = shift; + + my $data = "Pairwise key expansion"; + + if (($keyver == 1) || ($keyver == 2)) + { + $data .= "\x00"; + } + + # + # Min(AA, SPA) || Max(AA, SPA) + # + + # compare if greater: Min()/Max() on the MACs (6 bytes) + + if (memcmp ($macsta, $macap, 6) < 0) + { + $data .= $macsta; + $data .= $macap; + } + else + { + $data .= $macap; + $data .= $macsta; + } + + # + # Min(ANonce,SNonce) || Max(ANonce,SNonce) + # + + # compare if greater: Min()/Max() on the nonces (32 bytes) + + if (memcmp ($snonce, $anonce, 32) < 0) + { + $data .= $snonce; + $data .= $anonce; + } + else + { + $data .= $anonce; + $data .= $snonce; + } + + my $prf_buf; + + if (($keyver == 1) || ($keyver == 2)) + { + $data .= "\x00"; + + $prf_buf = hmac ($data, $pmk, \&sha1); + } + else + { + my $data3 = "\x01\x00" . $data . "\x80\x01"; + + $prf_buf = hmac ($data3, $pmk, \&sha256); + } + + $prf_buf = substr ($prf_buf, 0, 16); + + return $prf_buf; +} + +sub memcmp +{ + my $str1 = shift; + my $str2 = shift; + my $len = shift; + + my $len_str1 = length ($str1); + my $len_str2 = length ($str2); + + if (($len > $len_str1) || ($len > $len_str2)) + { + print "ERROR: memcmp () lengths wrong"; + + exit (1); + } + + for (my $i = 0; $i < $len; $i++) + { + my $c_1 = ord (substr ($str1, $i, 1)); + my $c_2 = ord (substr ($str2, $i, 1)); + + return -1 if ($c_1 < $c_2); + return 1 if ($c_1 > $c_2); + } + + return 0; +} + +1; diff --git a/tools/test_modules/m22100.pm b/tools/test_modules/m22100.pm new file mode 100644 index 000000000..c839c45b4 --- /dev/null +++ b/tools/test_modules/m22100.pm @@ -0,0 +1,302 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256); +use Crypt::Mode::ECB; +use Encode; + +sub module_constraints { [[4, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +my $ITER = 1048576; # 0x100000 +my $SALT_LEN = 16; +my $IV_LEN = 12; +my $MAC_LEN = 16; +my $VMK_LEN = 44; # note: MAC_LEN + VMK_LEN = 60 + +sub bitlocker_kdf +{ + my $initial_hash = shift; + my $salt = shift; + + # password_key_data (88 bytes): + # 0-31 (32): last_hash + # 32-63 (32): init_hash + # 64-79 (16): salt + # 80-87 ( 8): iter + + my $password_key_data = "\x00" x (32 + 32 + 16 + 8); + + substr ($password_key_data, 32, 32) = $initial_hash; + substr ($password_key_data, 64, 16) = $salt; + + for (my $iter = 0; $iter < 0x100000; $iter++) + { + substr ($password_key_data, 80, 8) = pack ("Q", $iter); + + substr ($password_key_data, 0, 32) = sha256 ($password_key_data); + } + + return substr ($password_key_data, 0, 32); # AES-CCM key +} + +# non-standard/variant of AES-CCM (encrypt or decrypt, both => crypt): + +sub bitlocker_crypt_data +{ + my $key = shift; + my $data = shift; + my $iv = shift; + + my $ret = ""; # return value (output buffer) + + my $iiv = "\x02"; # 15 - length ($iv) - 1 = 14 - length ($iv) + + $iiv = $iiv . $iv . "\x00\x00\x00"; # add "\x00" x (16 - length ($iv)) + + # we could do this in a loop (but let's unroll it to make it clear what is going on): + # (first and last are special) + + # 0 + + # substr ($iiv, 15, 1) = "\x00"; + + my $aes = Crypt::Mode::ECB->new ('AES', 0); + + my $block = $aes->encrypt ($iiv, $key); + + for (my $i = 0; $i < 16; $i++) + { + $ret .= chr (ord (substr ($data, $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + # 1 + + substr ($iiv, 15, 1) = "\x01"; + + $block = $aes->encrypt ($iiv, $key); + + for (my $i = 0; $i < 16; $i++) + { + $ret .= chr (ord (substr ($data, 16 + $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + # 2 + + substr ($iiv, 15, 1) = "\x02"; + + $block = $aes->encrypt ($iiv, $key); + + for (my $i = 0; $i < 16; $i++) + { + $ret .= chr (ord (substr ($data, 32 + $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + # 3 (final/remaining data: 12 bytes): + + substr ($iiv, 15, 1) = "\x03"; + + $block = $aes->encrypt ($iiv, $key); + + for (my $i = 0; $i < 12; $i++) + { + $ret .= chr (ord (substr ($data, 48 + $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + return $ret; +} + +sub bitlocker_generate_mac +{ + my $key = shift; + my $data = shift; + my $iv = shift; + + my $iiv = "\x3a" . $iv . "\x00\x00" . "\x2c"; + + # we could do this in a loop (but let's unroll it to make it clear what is going on): + # (first and last are special) + + # 0 + + my $aes = Crypt::Mode::ECB->new ('AES', 0); + + my $block = $aes->encrypt ($iiv, $key); + + my $res = ""; + + for (my $i = 0; $i < 16; $i++) + { + $res .= chr (ord (substr ($data, $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + # 1 + + $block = $aes->encrypt ($res, $key); + + $res = ""; + + for (my $i = 0; $i < 16; $i++) + { + $res .= chr (ord (substr ($data, 16 + $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + # 2 + + $block = $aes->encrypt ($res, $key); + + $res = ""; + + for (my $i = 0; $i < 12; $i++) + { + $res .= chr (ord (substr ($data, 32 + $i, 1)) ^ ord (substr ($block, $i, 1))); + } + + # 3 + + $block = $aes->encrypt ($res . substr ($block, 12, 4), $key); + + return $block; +} + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iv = shift // random_bytes (12); + my $data = shift; # if not set, we're going to "generate"/fake it below + my $type = shift // random_number (0, 1); # if set to 1: check also the MAC in hashcat + + + # key generation (KDF): + + my $word_utf16le = encode ("UTF-16LE", $word); + + my $pass_hash = sha256 (sha256 ($word_utf16le)); + + my $key = bitlocker_kdf ($pass_hash, $salt); + + + if (! $data) + { + $data = pack ("H*", "2c000000"); # actually, only 0x2c00 can be expected for sure + $data .= pack ("H*", "01000000"); # actually, only 0x0100 can be expected for sure + $data .= chr (random_number (0, 5)); + $data .= pack ("H*", "200000"); # actually, only 0x20 can be expected for sure + + $data .= random_bytes (44 - 12); # 44 - bytes that we set above + } + else + { + # verification: + + my $dec_data = bitlocker_crypt_data ($key, $data, $iv); # decryption + + my $data_size = ord (substr ($dec_data, 16, 1)) | (ord (substr ($dec_data, 17, 1)) << 8); + my $version = ord (substr ($dec_data, 20, 1)) | (ord (substr ($dec_data, 21, 1)) << 8); + + my $v1 = ord (substr ($dec_data, 16 + 8, 1)); # Volume Master Key (VMK) + 8 + my $v2 = ord (substr ($dec_data, 16 + 9, 1)); # Volume Master Key (VMK) + 9 + + # early ejects / failed: + + return unless ($data_size == 0x2c); + return unless ($version == 0x01); + return unless ($v2 == 0x20); + return unless ($v1 <= 0x05); + + $data = substr ($dec_data, 16); # skip the MAC such that we get only the raw data (VMK etc) + + # note: we do NOT check the $type value ... we do the MAC verification anyway to be safe + # (for "verify" and $type set to 0 - no MAC verification -, we could early exit here already) + } + + + # MAC (authenticate-then-encrypt, MAC first!): + + my $mac = bitlocker_generate_mac ($key, $data, $iv); + + + # encrypt (both, MAC + VMK): + + my $mac_vmk = $mac . $data; + + my $enc_data = bitlocker_crypt_data ($key, $mac_vmk, $iv); # encryption + + + # output: + + my $hash = sprintf ("\$bitlocker\$%i\$%i\$%s\$%i\$%i\$%s\$%i\$%s", + $type, + $SALT_LEN, + unpack ("H*", $salt), + $ITER, + $IV_LEN, + unpack ("H*", $iv), + $MAC_LEN + $VMK_LEN, + unpack ("H*", $enc_data)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return if ($idx < 0); + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless defined $hash; + return unless defined $word; + + my @data = split ('\$', $hash); + + return unless (scalar (@data) == 10); + + my $signature = $data[1]; + my $type = $data[2]; + my $salt_len = $data[3]; + my $salt = $data[4]; + my $iter = $data[5]; + my $iv_len = $data[6]; + my $iv = $data[7]; + my $data_len = $data[8]; + my $data = $data[9]; + + # sanity checks: + + return unless ($signature eq "bitlocker"); + + return unless ($salt_len == $SALT_LEN); + return unless ($iv_len == $IV_LEN); + return unless ($data_len == $MAC_LEN + $VMK_LEN); + + # hex to binary conversion: + + $salt = pack ("H*", $salt); + $iv = pack ("H*", $iv); + $data = pack ("H*", $data); + + return unless (length ($salt) == $SALT_LEN); + return unless (length ($iv) == $IV_LEN); + return unless (length ($data) == $MAC_LEN + $VMK_LEN); + + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt, $iv, $data, $type); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m22200.pm b/tools/test_modules/m22200.pm new file mode 100644 index 000000000..e8876c224 --- /dev/null +++ b/tools/test_modules/m22200.pm @@ -0,0 +1,51 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex); + +sub module_constraints { [[0, 256], [8, 8], [0, 54], [8, 8], [8, 54]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $hash_buf = sha512_hex ($salt . $word . "\x00"); + + my $hash = sprintf ("2%s%s", $salt, $hash_buf); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $salt = substr ($line, 1, 8); + + my $rest = substr ($line, 1 + 8); + + my $index2 = index ($rest, ":"); + + return if $index2 < 1; + + my $word = substr ($rest, $index2 + 1); + + return unless defined $salt; + return unless defined $word; + + $word = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m22300.pm b/tools/test_modules/m22300.pm new file mode 100644 index 000000000..e6cda0756 --- /dev/null +++ b/tools/test_modules/m22300.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); + +sub module_constraints { [[0, 256], [0, 127], [0, 27], [0, 27], [0, 27]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_hex ($salt . $word . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m22301.pm b/tools/test_modules/m22301.pm new file mode 100644 index 000000000..6c708d513 --- /dev/null +++ b/tools/test_modules/m22301.pm @@ -0,0 +1,58 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); + +sub module_constraints { [[0, 256], [32, 32], [0, 55], [32, 32], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $salt_bin = pack ("H*", $salt); + + my $digest = sha256_hex ($salt_bin . $word . $salt_bin); + + my $hash = sprintf ("\$telegram\$0*%s*%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + my @data = split ('\*', $hash); + + return unless (scalar (@data) == 3); + + return unless (substr ($data[0], 0, 10) eq '$telegram$'); + + my $version = substr ($data[0], 10); + + return unless ($version eq "0"); + + my $digest = $data[1]; + my $salt = $data[2]; + + return unless (length ($digest) eq 64); + return unless (length ($salt) eq 32); # hex length + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m22400.pm b/tools/test_modules/m22400.pm new file mode 100644 index 000000000..e9aa0318e --- /dev/null +++ b/tools/test_modules/m22400.pm @@ -0,0 +1,89 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256); +use Digest::HMAC qw (hmac_hex); +use Encode; + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $iv_aes = shift // random_bytes (16); + my $key_aes = shift // random_bytes (32); + + my $word_utf16le = encode ('UTF-16le', $word); + + my $key = $salt . "\x00" x 16; + + for (my $i = 0; $i < 8192; $i++) + { + $key = sha256 ($key . $word_utf16le); + } + + my $digest = hmac_hex ($iv_aes . $key_aes, $key, \&sha256, 64); + + # hex conversion: + + my $salt_hex = unpack ("H*", $salt); + my $iv_hex = unpack ("H*", $iv_aes); + my $key_hex = unpack ("H*", $key_aes); + + my $hash = sprintf ("\$aescrypt\$1*%s*%s*%s*%s", $salt_hex, $iv_hex, $key_hex, $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my @data = split ('\*', $hash); + + return unless (scalar (@data) == 5); + + my $signature = substr ($data[0], 0, 10); + + return unless ($signature eq "\$aescrypt\$"); + + my $version = substr ($data[0], 10); + + return unless ($version eq "1"); + + my $salt = $data[1]; + my $iv = $data[2]; + my $key = $data[3]; + + return unless (length ($salt) == 32); # hex lengths + return unless (length ($iv) == 32); + return unless (length ($key) == 64); + + # binary conversion: + + $salt = pack ("H*", $salt); + $iv = pack ("H*", $iv); + $key = pack ("H*", $key); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt, $iv, $key); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m22500.pm b/tools/test_modules/m22500.pm new file mode 100644 index 000000000..5a7b956a7 --- /dev/null +++ b/tools/test_modules/m22500.pm @@ -0,0 +1,192 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5); +use Crypt::CBC; + +sub module_constraints { [[0, 256], [8, 8], [0, 31], [8, 8], [-1, -1]] } + +my $BASE58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; +my $BITCOINJ_CHARS = ".abcdefghijklmnopqrstuvwxyz"; + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $data = shift; + + my $word_salt = $word . $salt; + + my $key1 = md5 ( $word_salt); + my $key2 = md5 ($key1 . $word_salt); + my $iv = md5 ($key2 . $word_salt); + + my $aes_cbc = Crypt::CBC->new ({ + cipher => "Crypt::Rijndael", + iv => $iv, + key => $key1 . $key2, + keysize => 32, + literal_key => 1, + header => "none", + padding => "none" + }); + + my $type = 0; # 0: MultiBit Classic MD5, 1: KnCGroup Bitcoin Wallet, 2: bitcoinj + my $key = ""; + + if (! defined ($data)) + { + $type = random_number (0, 2); + + if ($type == 0) + { + my @chars_at_start = ('K', 'L', 'Q', '5'); + + $data = $chars_at_start[random_number (0, scalar (@chars_at_start) - 1)]; + + for (my $i = 1; $i < 32; $i++) + { + $data .= substr ($BASE58_CHARS, random_number (0, length ($BASE58_CHARS) - 1), 1); + } + } + elsif ($type == 1) + { + $data = "\n"; + $data .= chr (random_number (0, 127)); + $data .= "org."; + + for (my $i = 6; $i < 32; $i++) + { + $data .= substr ($BITCOINJ_CHARS, random_number (0, length ($BITCOINJ_CHARS) - 1), 1); + } + } + elsif ($type == 2) + { + # Full string would be: + # "# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins." + + $data = '# KEEP YOUR PRIVATE KEYS SAFE! A'; + } + + $key = $aes_cbc->encrypt ($data); + } + else + { + $key = $aes_cbc->decrypt ($data); + + # verification step: + + # first char of $key must be K, L, Q, 5, # or \n + + my $char_at_start = substr ($key, 0, 1); + + if (($char_at_start eq 'K') || + ($char_at_start eq 'L') || + ($char_at_start eq 'Q') || + ($char_at_start eq '5')) + { + my $error = 0; + + for (my $i = 1; $i < 32; $i++) # start with 1 (we already checked first char) + { + my $c = substr ($key, $i, 1); + + my $idx = index ($BASE58_CHARS, $c); + + next if ($idx >= 0); + + $error = 1; + + last; + } + + if ($error == 0) + { + $key = $data; + } + } + elsif ($char_at_start eq "\n") # bitcoinj + { + my $second_char = substr ($key, 1, 1); + + if (ord ($second_char) < 128) + { + if (substr ($key, 2, 4) eq "org.") + { + my $error = 0; + + for (my $i = 6; $i < 14; $i++) # start with 6 (we already checked first chars) + { + my $c = substr ($key, $i, 1); + + my $idx = index ($BITCOINJ_CHARS, $c); + + next if ($idx >= 0); + + $error = 1; + + last; + } + + if ($error == 0) + { + $key = $data; + } + } + } + } + elsif ($char_at_start eq '#') # KnCGroup Bitcoin Wallet + { + if (substr ($key, 0, 16) eq '# KEEP YOUR PRIV') + { + $key = $data; + } + } + } + + my $hash = sprintf ("\$multibit\$1*%s*%s", unpack ("H*", $salt), unpack ("H*", $key)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 12) eq '$multibit$1*'; + + $idx = index ($hash, '*', 12); + + return unless $idx == 28; + + my $salt_hex = substr ($hash, 12, 16); # 28 - 12 = 16 + my $data_hex = substr ($hash, 29); + + return unless length ($salt_hex) == 16; + return unless length ($data_hex) == 64; + + my $salt = pack ("H*", $salt_hex); + my $data = pack ("H*", $data_hex); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt, $data); + + return ($new_hash, $word); +} + +1;