Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m06900_a3.cl
index 34d362d..21f8e46 100644 (file)
@@ -1,24 +1,21 @@
 /**
- * Author......: Jens Steube <jens.steube@gmail.com>
+ * Authors.....: Jens Steube <jens.steube@gmail.com>
+ *               Gabriele Gristina <matrix@hashcat.net>
+ *               magnum <john.magnum@hushmail.com>
+ *
  * License.....: MIT
  */
 
 #define _GOST_
 
-#include "include/constants.h"
-#include "include/kernel_vendor.h"
+#define NEW_SIMD_CODE
 
-#define DGST_R0 0
-#define DGST_R1 1
-#define DGST_R2 2
-#define DGST_R3 3
-
-#include "include/kernel_functions.c"
-#include "OpenCL/types_ocl.c"
-#include "OpenCL/common.c"
-
-#define COMPARE_S "OpenCL/check_single_comp4.c"
-#define COMPARE_M "OpenCL/check_multi_comp4.c"
+#include "inc_vendor.cl"
+#include "inc_hash_constants.h"
+#include "inc_hash_functions.cl"
+#include "inc_types.cl"
+#include "inc_common.cl"
+#include "inc_simd.cl"
 
 __constant u32 c_tables[4][256] =
 {
@@ -288,11 +285,21 @@ __constant u32 c_tables[4][256] =
   }
 };
 
+#if   VECT_SIZE == 1
 #define BOX(i,n,S) (S)[(n)][(i)]
-
-#define round(k1,k2,tbl)                  \
+#elif VECT_SIZE == 2
+#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1])
+#elif VECT_SIZE == 4
+#define BOX(i,n,S) (u32x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3])
+#elif VECT_SIZE == 8
+#define BOX(i,n,S) (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])
+#elif VECT_SIZE == 16
+#define BOX(i,n,S) (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
+
+#define _round(k1,k2,tbl)                 \
 {                                         \
-  u32 t;                                  \
+  u32x t;                                 \
   t = (k1) + r;                           \
   l ^= BOX (((t >>  0) & 0xff), 0, tbl) ^ \
        BOX (((t >>  8) & 0xff), 1, tbl) ^ \
@@ -307,26 +314,26 @@ __constant u32 c_tables[4][256] =
 
 #define R(k,h,s,i,t)      \
 {                         \
-  u32 r;                  \
-  u32 l;                  \
+  u32x r;                 \
+  u32x l;                 \
   r = h[i + 0];           \
   l = h[i + 1];           \
-  round (k[0], k[1], t);  \
-  round (k[2], k[3], t);  \
-  round (k[4], k[5], t);  \
-  round (k[6], k[7], t);  \
-  round (k[0], k[1], t);  \
-  round (k[2], k[3], t);  \
-  round (k[4], k[5], t);  \
-  round (k[6], k[7], t);  \
-  round (k[0], k[1], t);  \
-  round (k[2], k[3], t);  \
-  round (k[4], k[5], t);  \
-  round (k[6], k[7], t);  \
-  round (k[7], k[6], t);  \
-  round (k[5], k[4], t);  \
-  round (k[3], k[2], t);  \
-  round (k[1], k[0], t);  \
+  _round (k[0], k[1], t);  \
+  _round (k[2], k[3], t);  \
+  _round (k[4], k[5], t);  \
+  _round (k[6], k[7], t);  \
+  _round (k[0], k[1], t);  \
+  _round (k[2], k[3], t);  \
+  _round (k[4], k[5], t);  \
+  _round (k[6], k[7], t);  \
+  _round (k[0], k[1], t);  \
+  _round (k[2], k[3], t);  \
+  _round (k[4], k[5], t);  \
+  _round (k[6], k[7], t);  \
+  _round (k[7], k[6], t);  \
+  _round (k[5], k[4], t);  \
+  _round (k[3], k[2], t);  \
+  _round (k[1], k[0], t);  \
   s[i + 0] = l;           \
   s[i + 1] = r;           \
 }
@@ -377,8 +384,8 @@ __constant u32 c_tables[4][256] =
 
 #define A(x)        \
 {                   \
-  u32 l;          \
-  u32 r;          \
+  u32x l;           \
+  u32x r;           \
   l = x[0] ^ x[2];  \
   r = x[1] ^ x[3];  \
   x[0] = x[2];      \
@@ -393,8 +400,8 @@ __constant u32 c_tables[4][256] =
 
 #define AA(x)       \
 {                   \
-  u32 l;          \
-  u32 r;          \
+  u32x l;           \
+  u32x r;           \
   l    = x[0];      \
   r    = x[2];      \
   x[0] = x[4];      \
@@ -652,8 +659,8 @@ __constant u32 c_tables[4][256] =
 
 #define PASS0(h,s,u,v,t)  \
 {                         \
-  u32 k[8];             \
-  u32 w[8];             \
+  u32x k[8];              \
+  u32x w[8];              \
   X (w, u, v);            \
   P (k, w);               \
   R (k, h, s, 0, t);      \
@@ -663,8 +670,8 @@ __constant u32 c_tables[4][256] =
 
 #define PASS2(h,s,u,v,t)  \
 {                         \
-  u32 k[8];             \
-  u32 w[8];             \
+  u32x k[8];              \
+  u32x w[8];              \
   X (w, u, v);            \
   P (k, w);               \
   R (k, h, s, 2, t);      \
@@ -675,8 +682,8 @@ __constant u32 c_tables[4][256] =
 
 #define PASS4(h,s,u,v,t)  \
 {                         \
-  u32 k[8];             \
-  u32 w[8];             \
+  u32x k[8];              \
+  u32x w[8];              \
   X (w, u, v);            \
   P (k, w);               \
   R (k, h, s, 4, t);      \
@@ -686,14 +693,14 @@ __constant u32 c_tables[4][256] =
 
 #define PASS6(h,s,u,v,t)  \
 {                         \
-  u32 k[8];             \
-  u32 w[8];             \
+  u32x k[8];              \
+  u32x w[8];              \
   X (w, u, v);            \
   P (k, w);               \
   R (k, h, s, 6, t);      \
 }
 
-static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, __local u32 s_tables[4][256])
+void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, __local u32 (*s_tables)[256])
 {
   /**
    * modifier
@@ -702,27 +709,25 @@ static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
   const u32 gid = get_global_id (0);
   const u32 lid = get_local_id (0);
 
-  /**
-   * base
-   */
-
-  const u32 w14 = pw_len * 8;
-
   /**
    * loop
    */
 
   u32 w0l = w0[0];
 
-  for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
+  for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
   {
-    const u32 w0r = bfs_buf[il_pos].i;
+    const u32x w0r = ix_create_bft (bfs_buf, il_pos);
+
+    const u32x w0lr = w0l | w0r;
 
-    w0[0] = w0l | w0r;
+    /**
+     * GOST
+     */
 
-    u32 data[8];
+    u32x data[8];
 
-    data[0] = w0[0];
+    data[0] = w0lr;
     data[1] = w0[1];
     data[2] = w0[2];
     data[3] = w0[3];
@@ -731,7 +736,7 @@ static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     data[6] = w1[2];
     data[7] = w1[3];
 
-    u32 state[16];
+    u32x state[16];
 
     state[ 0] = 0;
     state[ 1] = 0;
@@ -750,8 +755,8 @@ static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     state[14] = data[6];
     state[15] = data[7];
 
-    u32 state_m[8];
-    u32 data_m[8];
+    u32x state_m[8];
+    u32x data_m[8];
 
     /* gost1 */
 
@@ -773,9 +778,9 @@ static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     data_m[6] = data[6];
     data_m[7] = data[7];
 
-    u32 tmp[8];
+    u32x tmp[8];
 
-    if (pw_len > 0)
+    //if (pw_len > 0) // not really SIMD compatible
     {
       PASS0 (state, tmp, state_m, data_m, s_tables);
       PASS2 (state, tmp, state_m, data_m, s_tables);
@@ -787,7 +792,7 @@ static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
       SHIFT61 (state, data_m);
     }
 
-    data[0] = w14;
+    data[0] = pw_len * 8;
     data[1] = 0;
     data[2] = 0;
     data[3] = 0;
@@ -865,15 +870,11 @@ static void m06900m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
     /* store */
 
-    const u32 r0 = state[0];
-    const u32 r1 = state[1];
-    const u32 r2 = state[2];
-    const u32 r3 = state[3];
-
-    #include COMPARE_M
+    COMPARE_M_SIMD (state[0], state[1], state[2], state[3]);
   }
 }
-static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, __local u32 s_tables[4][256])
+
+void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, __local u32 (*s_tables)[256])
 {
   /**
    * modifier
@@ -882,12 +883,6 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
   const u32 gid = get_global_id (0);
   const u32 lid = get_local_id (0);
 
-  /**
-   * base
-   */
-
-  const u32 w14 = pw_len * 8;
-
   /**
    * digest
    */
@@ -906,15 +901,19 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   u32 w0l = w0[0];
 
-  for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
+  for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
   {
-    const u32 w0r = bfs_buf[il_pos].i;
+    const u32x w0r = ix_create_bft (bfs_buf, il_pos);
 
-    w0[0] = w0l | w0r;
+    const u32x w0lr = w0l | w0r;
 
-    u32 data[8];
+    /**
+     * GOST
+     */
 
-    data[0] = w0[0];
+    u32x data[8];
+
+    data[0] = w0lr;
     data[1] = w0[1];
     data[2] = w0[2];
     data[3] = w0[3];
@@ -923,7 +922,7 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     data[6] = w1[2];
     data[7] = w1[3];
 
-    u32 state[16];
+    u32x state[16];
 
     state[ 0] = 0;
     state[ 1] = 0;
@@ -942,8 +941,8 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     state[14] = data[6];
     state[15] = data[7];
 
-    u32 state_m[8];
-    u32 data_m[8];
+    u32x state_m[8];
+    u32x data_m[8];
 
     /* gost1 */
 
@@ -965,9 +964,9 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     data_m[6] = data[6];
     data_m[7] = data[7];
 
-    u32 tmp[8];
+    u32x tmp[8];
 
-    if (pw_len > 0)
+    //if (pw_len > 0) // not really SIMD compatible
     {
       PASS0 (state, tmp, state_m, data_m, s_tables);
       PASS2 (state, tmp, state_m, data_m, s_tables);
@@ -979,7 +978,7 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
       SHIFT61 (state, data_m);
     }
 
-    data[0] = w14;
+    data[0] = pw_len * 8;
     data[1] = 0;
     data[2] = 0;
     data[3] = 0;
@@ -1057,28 +1056,41 @@ static void m06900s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
     /* store */
 
-    const u32 r0 = state[0];
-    const u32 r1 = state[1];
-    const u32 r2 = state[2];
-    const u32 r3 = state[3];
-
-    #include COMPARE_S
+    COMPARE_M_SIMD (state[0], state[1], state[2], state[3]);
   }
 }
 
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_m04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m06900_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
 {
   /**
    * base
    */
 
   const u32 gid = get_global_id (0);
+  const u32 lid = get_local_id (0);
+  const u32 lsz = get_local_size (0);
 
   /**
-   * modifier
+   * sbox
    */
 
-  const u32 lid = get_local_id (0);
+  __local u32 s_tables[4][256];
+
+  for (u32 i = lid; i < 256; i += lsz)
+  {
+    s_tables[0][i] = c_tables[0][i];
+    s_tables[1][i] = c_tables[1][i];
+    s_tables[2][i] = c_tables[2][i];
+    s_tables[3][i] = c_tables[3][i];
+  }
+
+  barrier (CLK_LOCAL_MEM_FENCE);
+
+  if (gid >= gid_max) return;
+
+  /**
+   * modifier
+   */
 
   u32 w0[4];
 
@@ -1110,58 +1122,44 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_m04 (__glo
 
   const u32 pw_len = pws[gid].pw_len;
 
-  /**
-   * sbox
-   */
-
-  __local u32 s_tables[4][256];
-
-  const u32 lid4 = lid * 4;
-
-  s_tables[0][lid4 + 0] = c_tables[0][lid4 + 0];
-  s_tables[0][lid4 + 1] = c_tables[0][lid4 + 1];
-  s_tables[0][lid4 + 2] = c_tables[0][lid4 + 2];
-  s_tables[0][lid4 + 3] = c_tables[0][lid4 + 3];
-
-  s_tables[1][lid4 + 0] = c_tables[1][lid4 + 0];
-  s_tables[1][lid4 + 1] = c_tables[1][lid4 + 1];
-  s_tables[1][lid4 + 2] = c_tables[1][lid4 + 2];
-  s_tables[1][lid4 + 3] = c_tables[1][lid4 + 3];
-
-  s_tables[2][lid4 + 0] = c_tables[2][lid4 + 0];
-  s_tables[2][lid4 + 1] = c_tables[2][lid4 + 1];
-  s_tables[2][lid4 + 2] = c_tables[2][lid4 + 2];
-  s_tables[2][lid4 + 3] = c_tables[2][lid4 + 3];
-
-  s_tables[3][lid4 + 0] = c_tables[3][lid4 + 0];
-  s_tables[3][lid4 + 1] = c_tables[3][lid4 + 1];
-  s_tables[3][lid4 + 2] = c_tables[3][lid4 + 2];
-  s_tables[3][lid4 + 3] = c_tables[3][lid4 + 3];
-
-  barrier (CLK_LOCAL_MEM_FENCE);
-
-  if (gid >= gid_max) return;
-
   /**
    * main
    */
 
-  m06900m (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, s_tables);
+  m06900m (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, s_tables);
 }
 
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_m08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m06900_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
 {
   /**
    * base
    */
 
   const u32 gid = get_global_id (0);
+  const u32 lid = get_local_id (0);
+  const u32 lsz = get_local_size (0);
 
   /**
-   * modifier
+   * sbox
    */
 
-  const u32 lid = get_local_id (0);
+  __local u32 s_tables[4][256];
+
+  for (u32 i = lid; i < 256; i += lsz)
+  {
+    s_tables[0][i] = c_tables[0][i];
+    s_tables[1][i] = c_tables[1][i];
+    s_tables[2][i] = c_tables[2][i];
+    s_tables[3][i] = c_tables[3][i];
+  }
+
+  barrier (CLK_LOCAL_MEM_FENCE);
+
+  if (gid >= gid_max) return;
+
+  /**
+   * modifier
+   */
 
   u32 w0[4];
 
@@ -1193,62 +1191,48 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_m08 (__glo
 
   const u32 pw_len = pws[gid].pw_len;
 
-  /**
-   * sbox
-   */
-
-  __local u32 s_tables[4][256];
-
-  const u32 lid4 = lid * 4;
-
-  s_tables[0][lid4 + 0] = c_tables[0][lid4 + 0];
-  s_tables[0][lid4 + 1] = c_tables[0][lid4 + 1];
-  s_tables[0][lid4 + 2] = c_tables[0][lid4 + 2];
-  s_tables[0][lid4 + 3] = c_tables[0][lid4 + 3];
-
-  s_tables[1][lid4 + 0] = c_tables[1][lid4 + 0];
-  s_tables[1][lid4 + 1] = c_tables[1][lid4 + 1];
-  s_tables[1][lid4 + 2] = c_tables[1][lid4 + 2];
-  s_tables[1][lid4 + 3] = c_tables[1][lid4 + 3];
-
-  s_tables[2][lid4 + 0] = c_tables[2][lid4 + 0];
-  s_tables[2][lid4 + 1] = c_tables[2][lid4 + 1];
-  s_tables[2][lid4 + 2] = c_tables[2][lid4 + 2];
-  s_tables[2][lid4 + 3] = c_tables[2][lid4 + 3];
-
-  s_tables[3][lid4 + 0] = c_tables[3][lid4 + 0];
-  s_tables[3][lid4 + 1] = c_tables[3][lid4 + 1];
-  s_tables[3][lid4 + 2] = c_tables[3][lid4 + 2];
-  s_tables[3][lid4 + 3] = c_tables[3][lid4 + 3];
-
-  barrier (CLK_LOCAL_MEM_FENCE);
-
-  if (gid >= gid_max) return;
-
   /**
    * main
    */
 
-  m06900m (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, s_tables);
+  m06900m (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, s_tables);
 }
 
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_m16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m06900_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
 {
 }
 
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_s04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m06900_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
 {
   /**
    * base
    */
 
   const u32 gid = get_global_id (0);
+  const u32 lid = get_local_id (0);
+  const u32 lsz = get_local_size (0);
 
   /**
-   * modifier
+   * sbox
    */
 
-  const u32 lid = get_local_id (0);
+  __local u32 s_tables[4][256];
+
+  for (u32 i = lid; i < 256; i += lsz)
+  {
+    s_tables[0][i] = c_tables[0][i];
+    s_tables[1][i] = c_tables[1][i];
+    s_tables[2][i] = c_tables[2][i];
+    s_tables[3][i] = c_tables[3][i];
+  }
+
+  barrier (CLK_LOCAL_MEM_FENCE);
+
+  if (gid >= gid_max) return;
+
+  /**
+   * modifier
+   */
 
   u32 w0[4];
 
@@ -1280,58 +1264,44 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_s04 (__glo
 
   const u32 pw_len = pws[gid].pw_len;
 
-  /**
-   * sbox
-   */
-
-  __local u32 s_tables[4][256];
-
-  const u32 lid4 = lid * 4;
-
-  s_tables[0][lid4 + 0] = c_tables[0][lid4 + 0];
-  s_tables[0][lid4 + 1] = c_tables[0][lid4 + 1];
-  s_tables[0][lid4 + 2] = c_tables[0][lid4 + 2];
-  s_tables[0][lid4 + 3] = c_tables[0][lid4 + 3];
-
-  s_tables[1][lid4 + 0] = c_tables[1][lid4 + 0];
-  s_tables[1][lid4 + 1] = c_tables[1][lid4 + 1];
-  s_tables[1][lid4 + 2] = c_tables[1][lid4 + 2];
-  s_tables[1][lid4 + 3] = c_tables[1][lid4 + 3];
-
-  s_tables[2][lid4 + 0] = c_tables[2][lid4 + 0];
-  s_tables[2][lid4 + 1] = c_tables[2][lid4 + 1];
-  s_tables[2][lid4 + 2] = c_tables[2][lid4 + 2];
-  s_tables[2][lid4 + 3] = c_tables[2][lid4 + 3];
-
-  s_tables[3][lid4 + 0] = c_tables[3][lid4 + 0];
-  s_tables[3][lid4 + 1] = c_tables[3][lid4 + 1];
-  s_tables[3][lid4 + 2] = c_tables[3][lid4 + 2];
-  s_tables[3][lid4 + 3] = c_tables[3][lid4 + 3];
-
-  barrier (CLK_LOCAL_MEM_FENCE);
-
-  if (gid >= gid_max) return;
-
   /**
    * main
    */
 
-  m06900s (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, s_tables);
+  m06900s (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, s_tables);
 }
 
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_s08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m06900_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
 {
   /**
    * base
    */
 
   const u32 gid = get_global_id (0);
+  const u32 lid = get_local_id (0);
+  const u32 lsz = get_local_size (0);
 
   /**
-   * modifier
+   * sbox
    */
 
-  const u32 lid = get_local_id (0);
+  __local u32 s_tables[4][256];
+
+  for (u32 i = lid; i < 256; i += lsz)
+  {
+    s_tables[0][i] = c_tables[0][i];
+    s_tables[1][i] = c_tables[1][i];
+    s_tables[2][i] = c_tables[2][i];
+    s_tables[3][i] = c_tables[3][i];
+  }
+
+  barrier (CLK_LOCAL_MEM_FENCE);
+
+  if (gid >= gid_max) return;
+
+  /**
+   * modifier
+   */
 
   u32 w0[4];
 
@@ -1363,45 +1333,13 @@ __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_s08 (__glo
 
   const u32 pw_len = pws[gid].pw_len;
 
-  /**
-   * sbox
-   */
-
-  __local u32 s_tables[4][256];
-
-  const u32 lid4 = lid * 4;
-
-  s_tables[0][lid4 + 0] = c_tables[0][lid4 + 0];
-  s_tables[0][lid4 + 1] = c_tables[0][lid4 + 1];
-  s_tables[0][lid4 + 2] = c_tables[0][lid4 + 2];
-  s_tables[0][lid4 + 3] = c_tables[0][lid4 + 3];
-
-  s_tables[1][lid4 + 0] = c_tables[1][lid4 + 0];
-  s_tables[1][lid4 + 1] = c_tables[1][lid4 + 1];
-  s_tables[1][lid4 + 2] = c_tables[1][lid4 + 2];
-  s_tables[1][lid4 + 3] = c_tables[1][lid4 + 3];
-
-  s_tables[2][lid4 + 0] = c_tables[2][lid4 + 0];
-  s_tables[2][lid4 + 1] = c_tables[2][lid4 + 1];
-  s_tables[2][lid4 + 2] = c_tables[2][lid4 + 2];
-  s_tables[2][lid4 + 3] = c_tables[2][lid4 + 3];
-
-  s_tables[3][lid4 + 0] = c_tables[3][lid4 + 0];
-  s_tables[3][lid4 + 1] = c_tables[3][lid4 + 1];
-  s_tables[3][lid4 + 2] = c_tables[3][lid4 + 2];
-  s_tables[3][lid4 + 3] = c_tables[3][lid4 + 3];
-
-  barrier (CLK_LOCAL_MEM_FENCE);
-
-  if (gid >= gid_max) return;
-
   /**
    * main
    */
 
-  m06900s (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, s_tables);
+  m06900s (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, s_tables);
 }
 
-__kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m06900_s16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m06900_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
 {
 }