Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m00200_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MYSQL323_
7
8 //incompatible
9 //#define NEW_SIMD_CODE
10
11 #include "inc_vendor.cl"
12 #include "inc_hash_constants.h"
13 #include "inc_hash_functions.cl"
14 #include "inc_types.cl"
15 #include "inc_common.cl"
16 #include "inc_rp.h"
17 #include "inc_rp.cl"
18 #include "inc_simd.cl"
19
20 __kernel void m00200_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)
21 {
22   /**
23    * modifier
24    */
25
26   const u32 lid = get_local_id (0);
27
28   /**
29    * base
30    */
31
32   const u32 gid = get_global_id (0);
33
34   if (gid >= gid_max) return;
35
36   u32 pw_buf0[4];
37   u32 pw_buf1[4];
38
39   pw_buf0[0] = pws[gid].i[0];
40   pw_buf0[1] = pws[gid].i[1];
41   pw_buf0[2] = pws[gid].i[2];
42   pw_buf0[3] = pws[gid].i[3];
43   pw_buf1[0] = pws[gid].i[4];
44   pw_buf1[1] = pws[gid].i[5];
45   pw_buf1[2] = pws[gid].i[6];
46   pw_buf1[3] = pws[gid].i[7];
47
48   const u32 pw_len = pws[gid].pw_len;
49
50   /**
51    * loop
52    */
53
54   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
55   {
56     u32x w0[4] = { 0 };
57     u32x w1[4] = { 0 };
58     u32x w2[4] = { 0 };
59     u32x w3[4] = { 0 };
60
61     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
62
63     u32x w_t[16];
64
65     w_t[ 0] = w0[0];
66     w_t[ 1] = w0[1];
67     w_t[ 2] = w0[2];
68     w_t[ 3] = w0[3];
69     w_t[ 4] = w1[0];
70     w_t[ 5] = w1[1];
71     w_t[ 6] = w1[2];
72     w_t[ 7] = w1[3];
73     w_t[ 8] = 0;
74     w_t[ 9] = 0;
75     w_t[10] = 0;
76     w_t[11] = 0;
77     w_t[12] = 0;
78     w_t[13] = 0;
79     w_t[14] = 0;
80     w_t[15] = 0;
81
82     u32x a = MYSQL323_A;
83     u32x b = MYSQL323_B;
84     u32x c = 0;
85     u32x d = 0;
86
87     u32x add = 7;
88
89     #define ROUND(v)                              \
90     {                                             \
91       a ^= (((a & 0x3f) + add) * (v)) + (a << 8); \
92       b += (b << 8) ^ a;                          \
93       add += v;                                   \
94     }
95
96     int i;
97     int j;
98
99     for (i = 0, j = 0; i <= (int) out_len - 4; i += 4, j += 1)
100     {
101       const u32x wj = w_t[j];
102
103       ROUND ((wj >>  0) & 0xff);
104       ROUND ((wj >>  8) & 0xff);
105       ROUND ((wj >> 16) & 0xff);
106       ROUND ((wj >> 24) & 0xff);
107     }
108
109     const u32x wj = w_t[j];
110
111     const u32 left = out_len - i;
112
113     if (left == 3)
114     {
115       ROUND ((wj >>  0) & 0xff);
116       ROUND ((wj >>  8) & 0xff);
117       ROUND ((wj >> 16) & 0xff);
118     }
119     else if (left == 2)
120     {
121       ROUND ((wj >>  0) & 0xff);
122       ROUND ((wj >>  8) & 0xff);
123     }
124     else if (left == 1)
125     {
126       ROUND ((wj >>  0) & 0xff);
127     }
128
129     a &= 0x7fffffff;
130     b &= 0x7fffffff;
131
132     u32x z = 0;
133
134     COMPARE_M_SIMD (a, b, z, z);
135   }
136 }
137
138 __kernel void m00200_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)
139 {
140 }
141
142 __kernel void m00200_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)
143 {
144 }
145
146 __kernel void m00200_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)
147 {
148   /**
149    * modifier
150    */
151
152   const u32 lid = get_local_id (0);
153
154   /**
155    * base
156    */
157
158   const u32 gid = get_global_id (0);
159
160   if (gid >= gid_max) return;
161
162   u32 pw_buf0[4];
163   u32 pw_buf1[4];
164
165   pw_buf0[0] = pws[gid].i[0];
166   pw_buf0[1] = pws[gid].i[1];
167   pw_buf0[2] = pws[gid].i[2];
168   pw_buf0[3] = pws[gid].i[3];
169   pw_buf1[0] = pws[gid].i[4];
170   pw_buf1[1] = pws[gid].i[5];
171   pw_buf1[2] = pws[gid].i[6];
172   pw_buf1[3] = pws[gid].i[7];
173
174   const u32 pw_len = pws[gid].pw_len;
175
176   /**
177    * digest
178    */
179
180   const u32 search[4] =
181   {
182     digests_buf[digests_offset].digest_buf[DGST_R0],
183     digests_buf[digests_offset].digest_buf[DGST_R1],
184     0,
185     0
186   };
187
188   /**
189    * loop
190    */
191
192   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
193   {
194     u32x w0[4] = { 0 };
195     u32x w1[4] = { 0 };
196     u32x w2[4] = { 0 };
197     u32x w3[4] = { 0 };
198
199     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
200
201     u32x w_t[16];
202
203     w_t[ 0] = w0[0];
204     w_t[ 1] = w0[1];
205     w_t[ 2] = w0[2];
206     w_t[ 3] = w0[3];
207     w_t[ 4] = w1[0];
208     w_t[ 5] = w1[1];
209     w_t[ 6] = w1[2];
210     w_t[ 7] = w1[3];
211     w_t[ 8] = 0;
212     w_t[ 9] = 0;
213     w_t[10] = 0;
214     w_t[11] = 0;
215     w_t[12] = 0;
216     w_t[13] = 0;
217     w_t[14] = 0;
218     w_t[15] = 0;
219
220     u32x a = MYSQL323_A;
221     u32x b = MYSQL323_B;
222     u32x c = 0;
223     u32x d = 0;
224
225     u32x add = 7;
226
227     #define ROUND(v)                              \
228     {                                             \
229       a ^= (((a & 0x3f) + add) * (v)) + (a << 8); \
230       b += (b << 8) ^ a;                          \
231       add += v;                                   \
232     }
233
234     int i;
235     int j;
236
237     for (i = 0, j = 0; i <= (int) out_len - 4; i += 4, j += 1)
238     {
239       const u32x wj = w_t[j];
240
241       ROUND ((wj >>  0) & 0xff);
242       ROUND ((wj >>  8) & 0xff);
243       ROUND ((wj >> 16) & 0xff);
244       ROUND ((wj >> 24) & 0xff);
245     }
246
247     const u32x wj = w_t[j];
248
249     const u32 left = out_len - i;
250
251     if (left == 3)
252     {
253       ROUND ((wj >>  0) & 0xff);
254       ROUND ((wj >>  8) & 0xff);
255       ROUND ((wj >> 16) & 0xff);
256     }
257     else if (left == 2)
258     {
259       ROUND ((wj >>  0) & 0xff);
260       ROUND ((wj >>  8) & 0xff);
261     }
262     else if (left == 1)
263     {
264       ROUND ((wj >>  0) & 0xff);
265     }
266
267     a &= 0x7fffffff;
268     b &= 0x7fffffff;
269
270     u32x z = 0;
271
272     COMPARE_S_SIMD (a, b, z, z);
273   }
274 }
275
276 __kernel void m00200_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)
277 {
278 }
279
280 __kernel void m00200_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)
281 {
282 }