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