Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m07100.cl
index 6f64405..aaafd49 100644 (file)
@@ -7,14 +7,8 @@
 
 #define NEW_SIMD_CODE
 
-#include "inc_hash_constants.h"
 #include "inc_vendor.cl"
-
-#define DGST_R0 0
-#define DGST_R1 1
-#define DGST_R2 2
-#define DGST_R3 3
-
+#include "inc_hash_constants.h"
 #include "inc_hash_functions.cl"
 #include "inc_types.cl"
 #include "inc_common.cl"
@@ -370,6 +364,59 @@ void hmac_sha512_run_V (const u64x w1[16], const u64x ipad[8], const u64x opad[8
   sha512_transform_V (w, dgst);
 }
 
+void hmac_sha512_run_V_x (const u64x ipad[8], const u64x opad[8], u64x dgst[8])
+{
+  u64x w[16];
+
+  w[ 0] = dgst[0];
+  w[ 1] = dgst[1];
+  w[ 2] = dgst[2];
+  w[ 3] = dgst[3];
+  w[ 4] = dgst[4];
+  w[ 5] = dgst[5];
+  w[ 6] = dgst[6];
+  w[ 7] = dgst[7];
+  w[ 8] = 0x8000000000000000;
+  w[ 9] = 0;
+  w[10] = 0;
+  w[11] = 0;
+  w[12] = 0;
+  w[13] = 0;
+  w[14] = 0;
+  w[15] = (128 + 64) * 8;
+
+  dgst[0] = ipad[0];
+  dgst[1] = ipad[1];
+  dgst[2] = ipad[2];
+  dgst[3] = ipad[3];
+  dgst[4] = ipad[4];
+  dgst[5] = ipad[5];
+  dgst[6] = ipad[6];
+  dgst[7] = ipad[7];
+
+  sha512_transform_V (w, dgst);
+
+  w[ 0] = dgst[0];
+  w[ 1] = dgst[1];
+  w[ 2] = dgst[2];
+  w[ 3] = dgst[3];
+  w[ 4] = dgst[4];
+  w[ 5] = dgst[5];
+  w[ 6] = dgst[6];
+  w[ 7] = dgst[7];
+
+  dgst[0] = opad[0];
+  dgst[1] = opad[1];
+  dgst[2] = opad[2];
+  dgst[3] = opad[3];
+  dgst[4] = opad[4];
+  dgst[5] = opad[5];
+  dgst[6] = opad[6];
+  dgst[7] = opad[7];
+
+  sha512_transform_V (w, dgst);
+}
+
 void hmac_sha512_init_V (u64x w[16], u64x ipad[8], u64x opad[8])
 {
   w[ 0] ^= 0x3636363636363636;
@@ -429,7 +476,7 @@ void hmac_sha512_init_V (u64x w[16], u64x ipad[8], u64x opad[8])
   sha512_transform_V (w, opad);
 }
 
-__kernel void m07100_init (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pbkdf2_sha512_tmp_t *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 pbkdf2_sha512_t *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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m07100_init (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pbkdf2_sha512_tmp_t *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 pbkdf2_sha512_t *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
@@ -560,7 +607,7 @@ __kernel void m07100_init (__global pw_t *pws, __global kernel_rule_t *rules_buf
   }
 }
 
-__kernel void m07100_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pbkdf2_sha512_tmp_t *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 pbkdf2_sha512_t *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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m07100_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pbkdf2_sha512_tmp_t *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 pbkdf2_sha512_t *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)
 {
   const u32 gid = get_global_id (0);
 
@@ -590,7 +637,6 @@ __kernel void m07100_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf
   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);
@@ -601,46 +647,18 @@ __kernel void m07100_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf
     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 w[16];
-
-      w[ 0] = dgst[0];
-      w[ 1] = dgst[1];
-      w[ 2] = dgst[2];
-      w[ 3] = dgst[3];
-      w[ 4] = dgst[4];
-      w[ 5] = dgst[5];
-      w[ 6] = dgst[6];
-      w[ 7] = dgst[7];
-      w[ 8] = 0x8000000000000000;
-      w[ 9] = 0;
-      w[10] = 0;
-      w[11] = 0;
-      w[12] = 0;
-      w[13] = 0;
-      w[14] = 0;
-      w[15] = (128 + 64) * 8;
-
-      hmac_sha512_run_V (w, 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];
+      hmac_sha512_run_V_x (ipad, opad, dgst);
+
+      unpackv_xor (tmps, out, gid, 0, dgst[0]);
+      unpackv_xor (tmps, out, gid, 1, dgst[1]);
+      unpackv_xor (tmps, out, gid, 2, dgst[2]);
+      unpackv_xor (tmps, out, gid, 3, dgst[3]);
+      unpackv_xor (tmps, out, gid, 4, dgst[4]);
+      unpackv_xor (tmps, out, gid, 5, dgst[5]);
+      unpackv_xor (tmps, out, gid, 6, dgst[6]);
+      unpackv_xor (tmps, out, gid, 7, dgst[7]);
     }
 
     unpackv (tmps, dgst, gid, 0, dgst[0]);
@@ -651,19 +669,10 @@ __kernel void m07100_loop (__global pw_t *pws, __global kernel_rule_t *rules_buf
     unpackv (tmps, dgst, gid, 5, dgst[5]);
     unpackv (tmps, dgst, gid, 6, dgst[6]);
     unpackv (tmps, dgst, gid, 7, dgst[7]);
-
-    unpackv (tmps, out, gid, 0, out[0]);
-    unpackv (tmps, out, gid, 1, out[1]);
-    unpackv (tmps, out, gid, 2, out[2]);
-    unpackv (tmps, out, gid, 3, out[3]);
-    unpackv (tmps, out, gid, 4, out[4]);
-    unpackv (tmps, out, gid, 5, out[5]);
-    unpackv (tmps, out, gid, 6, out[6]);
-    unpackv (tmps, out, gid, 7, out[7]);
   }
 }
 
-__kernel void m07100_comp (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pbkdf2_sha512_tmp_t *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 pbkdf2_sha512_t *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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
+__kernel void m07100_comp (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global pbkdf2_sha512_tmp_t *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 pbkdf2_sha512_t *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