Zero pws_buf before reuse
[hashcat.git] / OpenCL / m00900_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD4_
7
8 #define NEW_SIMD_CODE
9
10 #include "include/constants.h"
11 #include "include/kernel_vendor.h"
12
13 #define DGST_R0 0
14 #define DGST_R1 3
15 #define DGST_R2 2
16 #define DGST_R3 1
17
18 #include "include/kernel_functions.c"
19 #include "OpenCL/types_ocl.c"
20 #include "OpenCL/common.c"
21 #include "OpenCL/simd.c"
22
23 __kernel void m00900_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_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
24 {
25   /**
26    * modifier
27    */
28
29   const u32 lid = get_local_id (0);
30
31   /**
32    * base
33    */
34
35   const u32 gid = get_global_id (0);
36
37   if (gid >= gid_max) return;
38
39   u32 pws0[4] = { 0 };
40   u32 pws1[4] = { 0 };
41
42   pws0[0] = pws[gid].i[0];
43   pws0[1] = pws[gid].i[1];
44   pws0[2] = pws[gid].i[2];
45   pws0[3] = pws[gid].i[3];
46   pws1[0] = pws[gid].i[4];
47   pws1[1] = pws[gid].i[5];
48   pws1[2] = pws[gid].i[6];
49   pws1[3] = pws[gid].i[7];
50
51   const u32 pw_l_len = pws[gid].pw_len;
52
53   /**
54    * loop
55    */
56
57   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
58   {
59     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
60
61     const u32x pw_len = pw_l_len + pw_r_len;
62
63     u32x wordr0[4] = { 0 };
64     u32x wordr1[4] = { 0 };
65     u32x wordr2[4] = { 0 };
66     u32x wordr3[4] = { 0 };
67
68     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
69     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
70     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
71     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
72     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
73     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
74     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
75     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
76
77     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
78     {
79       switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
80     }
81
82     u32x w0[4];
83
84     w0[0] = wordl0[0] | wordr0[0];
85     w0[1] = wordl0[1] | wordr0[1];
86     w0[2] = wordl0[2] | wordr0[2];
87     w0[3] = wordl0[3] | wordr0[3];
88
89     u32x w1[4];
90
91     w1[0] = wordl1[0] | wordr1[0];
92     w1[1] = wordl1[1] | wordr1[1];
93     w1[2] = wordl1[2] | wordr1[2];
94     w1[3] = wordl1[3] | wordr1[3];
95
96     u32x w2[4];
97
98     w2[0] = wordl2[0] | wordr2[0];
99     w2[1] = wordl2[1] | wordr2[1];
100     w2[2] = wordl2[2] | wordr2[2];
101     w2[3] = wordl2[3] | wordr2[3];
102
103     u32x w3[4];
104
105     w3[0] = wordl3[0] | wordr3[0];
106     w3[1] = wordl3[1] | wordr3[1];
107     w3[2] = pw_len * 8;
108     w3[3] = 0;
109
110     u32x a = MD4M_A;
111     u32x b = MD4M_B;
112     u32x c = MD4M_C;
113     u32x d = MD4M_D;
114
115     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
116     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
117     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
118     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
119     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
120     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
121     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
122     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
123     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
124     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
125     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
126     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
127     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
128     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
129     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
130     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
131
132     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
133     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
134     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
135     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
136     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
137     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
138     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
139     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
140     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
141     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
142     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
143     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
144     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
145     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
146     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
147     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
148
149     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
150     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
151     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
152     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
153     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
154     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
155     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
156     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
157     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
158     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
159     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
160     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
161     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
162     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
163     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
164     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
165     COMPARE_M_SIMD (a, d, c, b);
166   }
167 }
168
169 __kernel void m00900_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_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
170 {
171 }
172
173 __kernel void m00900_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_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
174 {
175 }
176
177 __kernel void m00900_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_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
178 {
179   /**
180    * modifier
181    */
182
183   const u32 lid = get_local_id (0);
184
185   /**
186    * base
187    */
188
189   const u32 gid = get_global_id (0);
190
191   if (gid >= gid_max) return;
192
193   u32 pws0[4] = { 0 };
194   u32 pws1[4] = { 0 };
195
196   pws0[0] = pws[gid].i[0];
197   pws0[1] = pws[gid].i[1];
198   pws0[2] = pws[gid].i[2];
199   pws0[3] = pws[gid].i[3];
200   pws1[0] = pws[gid].i[4];
201   pws1[1] = pws[gid].i[5];
202   pws1[2] = pws[gid].i[6];
203   pws1[3] = pws[gid].i[7];
204
205   const u32 pw_l_len = pws[gid].pw_len;
206   /**
207    * digest
208    */
209
210   const u32 search[4] =
211   {
212     digests_buf[digests_offset].digest_buf[DGST_R0],
213     digests_buf[digests_offset].digest_buf[DGST_R1],
214     digests_buf[digests_offset].digest_buf[DGST_R2],
215     digests_buf[digests_offset].digest_buf[DGST_R3]
216   };
217
218   /**
219    * loop
220    */
221
222   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
223   {
224     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
225
226     const u32x pw_len = pw_l_len + pw_r_len;
227
228     u32x wordr0[4] = { 0 };
229     u32x wordr1[4] = { 0 };
230     u32x wordr2[4] = { 0 };
231     u32x wordr3[4] = { 0 };
232
233     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
234     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
235     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
236     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
237     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
238     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
239     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
240     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
241
242     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
243     {
244       switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
245     }
246
247     u32x w0[4];
248
249     w0[0] = wordl0[0] | wordr0[0];
250     w0[1] = wordl0[1] | wordr0[1];
251     w0[2] = wordl0[2] | wordr0[2];
252     w0[3] = wordl0[3] | wordr0[3];
253
254     u32x w1[4];
255
256     w1[0] = wordl1[0] | wordr1[0];
257     w1[1] = wordl1[1] | wordr1[1];
258     w1[2] = wordl1[2] | wordr1[2];
259     w1[3] = wordl1[3] | wordr1[3];
260
261     u32x w2[4];
262
263     w2[0] = wordl2[0] | wordr2[0];
264     w2[1] = wordl2[1] | wordr2[1];
265     w2[2] = wordl2[2] | wordr2[2];
266     w2[3] = wordl2[3] | wordr2[3];
267
268     u32x w3[4];
269
270     w3[0] = wordl3[0] | wordr3[0];
271     w3[1] = wordl3[1] | wordr3[1];
272     w3[2] = pw_len * 8;
273     w3[3] = 0;
274
275     u32x a = MD4M_A;
276     u32x b = MD4M_B;
277     u32x c = MD4M_C;
278     u32x d = MD4M_D;
279
280     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
281     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
282     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
283     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
284     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
285     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
286     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
287     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
288     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
289     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
290     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
291     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
292     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
293     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
294     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
295     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
296
297     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
298     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
299     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
300     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
301     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
302     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
303     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
304     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
305     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
306     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
307     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
308     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
309     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
310     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
311     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
312     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
313
314     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
315     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
316     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
317     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
318     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
319     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
320     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
321     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
322     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
323     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
324     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
325     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
326     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
327     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
328     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
329     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
330     COMPARE_S_SIMD (a, d, c, b);
331   }
332 }
333
334 __kernel void m00900_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_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
335 {
336 }
337
338 __kernel void m00900_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_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
339 {
340 }