From f4e43da4562940a008a271846b88a47aea6c0028 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sun, 17 Feb 2019 08:57:51 +0100 Subject: [PATCH] Fix whirlpool final() handling --- OpenCL/inc_hash_whirlpool.cl | 4 +- OpenCL/m06100_a1-optimized.cl | 24 ++--- OpenCL/m06100_a3-optimized.cl | 182 +++------------------------------- tools/test_modules/m06100.pm | 2 +- 4 files changed, 27 insertions(+), 185 deletions(-) diff --git a/OpenCL/inc_hash_whirlpool.cl b/OpenCL/inc_hash_whirlpool.cl index 9c1d7c294..7611742f8 100644 --- a/OpenCL/inc_hash_whirlpool.cl +++ b/OpenCL/inc_hash_whirlpool.cl @@ -1934,7 +1934,7 @@ DECLSPEC void whirlpool_final (whirlpool_ctx_t *ctx) append_0x80_4x4_S (ctx->w0, ctx->w1, ctx->w2, ctx->w3, pos ^ 3); - if (pos >= 56) + if (pos >= 32) { whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); @@ -2937,7 +2937,7 @@ DECLSPEC void whirlpool_final_vector (whirlpool_ctx_vector_t *ctx) append_0x80_4x4 (ctx->w0, ctx->w1, ctx->w2, ctx->w3, pos ^ 3); - if (pos >= 56) + if (pos >= 32) { whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl); diff --git a/OpenCL/m06100_a1-optimized.cl b/OpenCL/m06100_a1-optimized.cl index abaa6b039..74a58864b 100644 --- a/OpenCL/m06100_a1-optimized.cl +++ b/OpenCL/m06100_a1-optimized.cl @@ -161,12 +161,12 @@ __kernel void m06100_m04 (KERN_ATTR_ESALT (netntlm_t)) w[ 5] = swap32 (w1[1]); w[ 6] = swap32 (w1[2]); w[ 7] = swap32 (w1[3]); - w[ 8] = swap32 (w2[0]); - w[ 9] = swap32 (w2[1]); - w[10] = swap32 (w2[2]); - w[11] = swap32 (w2[3]); - w[12] = swap32 (w3[0]); - w[13] = swap32 (w3[1]); + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; w[14] = 0; w[15] = pw_len * 8; @@ -362,12 +362,12 @@ __kernel void m06100_s04 (KERN_ATTR_ESALT (netntlm_t)) w[ 5] = swap32 (w1[1]); w[ 6] = swap32 (w1[2]); w[ 7] = swap32 (w1[3]); - w[ 8] = swap32 (w2[0]); - w[ 9] = swap32 (w2[1]); - w[10] = swap32 (w2[2]); - w[11] = swap32 (w2[3]); - w[12] = swap32 (w3[0]); - w[13] = swap32 (w3[1]); + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; w[14] = 0; w[15] = pw_len * 8; diff --git a/OpenCL/m06100_a3-optimized.cl b/OpenCL/m06100_a3-optimized.cl index e0d760cbb..add7a05c7 100644 --- a/OpenCL/m06100_a3-optimized.cl +++ b/OpenCL/m06100_a3-optimized.cl @@ -49,12 +49,12 @@ DECLSPEC void m06100m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER w[ 5] = w1[1]; w[ 6] = w1[2]; w[ 7] = w1[3]; - w[ 8] = w2[0]; - w[ 9] = w2[1]; - w[10] = w2[2]; - w[11] = w2[3]; - w[12] = w3[0]; - w[13] = w3[1]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; w[14] = 0; w[15] = pw_len * 8; @@ -130,12 +130,12 @@ DECLSPEC void m06100s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER w[ 5] = w1[1]; w[ 6] = w1[2]; w[ 7] = w1[3]; - w[ 8] = w2[0]; - w[ 9] = w2[1]; - w[10] = w2[2]; - w[11] = w2[3]; - w[12] = w3[0]; - w[13] = w3[1]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; w[14] = 0; w[15] = pw_len * 8; @@ -336,85 +336,6 @@ __kernel void m06100_m08 (KERN_ATTR_BASIC ()) __kernel void m06100_m16 (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); - - /** - * shared - */ - - __local u32 s_Ch[8][256]; - __local u32 s_Cl[8][256]; - - for (MAYBE_VOLATILE 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]; - } - - barrier (CLK_LOCAL_MEM_FENCE); - - if (gid >= gid_max) return; - - /** - * base - */ - - 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 - */ - - 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); } __kernel void m06100_s04 (KERN_ATTR_BASIC ()) @@ -585,83 +506,4 @@ __kernel void m06100_s08 (KERN_ATTR_BASIC ()) __kernel void m06100_s16 (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); - - /** - * shared - */ - - __local u32 s_Ch[8][256]; - __local u32 s_Cl[8][256]; - - for (MAYBE_VOLATILE 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]; - } - - barrier (CLK_LOCAL_MEM_FENCE); - - if (gid >= gid_max) return; - - /** - * base - */ - - 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 - */ - - 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); } diff --git a/tools/test_modules/m06100.pm b/tools/test_modules/m06100.pm index 36780f55c..6d000473a 100644 --- a/tools/test_modules/m06100.pm +++ b/tools/test_modules/m06100.pm @@ -10,7 +10,7 @@ use warnings; use Crypt::Digest::Whirlpool qw (whirlpool_hex); -sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } +sub module_constraints { [[0, 255], [-1, -1], [0, 31], [-1, -1], [-1, -1]] } sub module_generate_hash {