- Dropped all vector code since new GPU's are all scalar, makes the code much easier
[hashcat.git] / OpenCL / m01100_a3.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 "types_ocl.c"
18 #include "common.c"
19
20 #define COMPARE_S "check_single_comp4.c"
21 #define COMPARE_M "check_multi_comp4.c"
22
23 static void m01100m (u32 w[16], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
24 {
25   /**
26    * modifier
27    */
28
29   const u32 gid = get_global_id (0);
30   const u32 lid = get_local_id (0);
31
32   /**
33    * salt
34    */
35
36   u32 salt_buf0[4];
37
38   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
39   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
40   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
41   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
42
43   u32 salt_buf1[4];
44
45   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
46   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
47   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
48   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
49
50   u32 salt_buf2[4];
51
52   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
53   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
54   salt_buf2[2] = 0;
55   salt_buf2[3] = 0;
56
57   const u32 salt_len = salt_bufs[salt_pos].salt_len;
58
59   /**
60    * base
61    */
62
63   const u32 F_w0c00 =     0 + MD4C00;
64   const u32 F_w1c00 = w[ 1] + MD4C00;
65   const u32 F_w2c00 = w[ 2] + MD4C00;
66   const u32 F_w3c00 = w[ 3] + MD4C00;
67   const u32 F_w4c00 = w[ 4] + MD4C00;
68   const u32 F_w5c00 = w[ 5] + MD4C00;
69   const u32 F_w6c00 = w[ 6] + MD4C00;
70   const u32 F_w7c00 = w[ 7] + MD4C00;
71   const u32 F_w8c00 = w[ 8] + MD4C00;
72   const u32 F_w9c00 = w[ 9] + MD4C00;
73   const u32 F_wac00 = w[10] + MD4C00;
74   const u32 F_wbc00 = w[11] + MD4C00;
75   const u32 F_wcc00 = w[12] + MD4C00;
76   const u32 F_wdc00 = w[13] + MD4C00;
77   const u32 F_wec00 = w[14] + MD4C00;
78   const u32 F_wfc00 = w[15] + MD4C00;
79
80   const u32 G_w0c01 =     0 + MD4C01;
81   const u32 G_w4c01 = w[ 4] + MD4C01;
82   const u32 G_w8c01 = w[ 8] + MD4C01;
83   const u32 G_wcc01 = w[12] + MD4C01;
84   const u32 G_w1c01 = w[ 1] + MD4C01;
85   const u32 G_w5c01 = w[ 5] + MD4C01;
86   const u32 G_w9c01 = w[ 9] + MD4C01;
87   const u32 G_wdc01 = w[13] + MD4C01;
88   const u32 G_w2c01 = w[ 2] + MD4C01;
89   const u32 G_w6c01 = w[ 6] + MD4C01;
90   const u32 G_wac01 = w[10] + MD4C01;
91   const u32 G_wec01 = w[14] + MD4C01;
92   const u32 G_w3c01 = w[ 3] + MD4C01;
93   const u32 G_w7c01 = w[ 7] + MD4C01;
94   const u32 G_wbc01 = w[11] + MD4C01;
95   const u32 G_wfc01 = w[15] + MD4C01;
96
97   const u32 H_w0c02 =     0 + MD4C02;
98   const u32 H_w8c02 = w[ 8] + MD4C02;
99   const u32 H_w4c02 = w[ 4] + MD4C02;
100   const u32 H_wcc02 = w[12] + MD4C02;
101   const u32 H_w2c02 = w[ 2] + MD4C02;
102   const u32 H_wac02 = w[10] + MD4C02;
103   const u32 H_w6c02 = w[ 6] + MD4C02;
104   const u32 H_wec02 = w[14] + MD4C02;
105   const u32 H_w1c02 = w[ 1] + MD4C02;
106   const u32 H_w9c02 = w[ 9] + MD4C02;
107   const u32 H_w5c02 = w[ 5] + MD4C02;
108   const u32 H_wdc02 = w[13] + MD4C02;
109   const u32 H_w3c02 = w[ 3] + MD4C02;
110   const u32 H_wbc02 = w[11] + MD4C02;
111   const u32 H_w7c02 = w[ 7] + MD4C02;
112   const u32 H_wfc02 = w[15] + MD4C02;
113
114   /**
115    * loop
116    */
117
118   u32 w0l = w[0];
119
120   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
121   {
122     const u32 w0r = words_buf_r[il_pos];
123
124     const u32 w0 = w0l | w0r;
125
126     u32 a = MD4M_A;
127     u32 b = MD4M_B;
128     u32 c = MD4M_C;
129     u32 d = MD4M_D;
130
131     MD4_STEP (MD4_Fo, a, b, c, d, w0, F_w0c00, MD4S00);
132     MD4_STEP0(MD4_Fo, d, a, b, c,     F_w1c00, MD4S01);
133     MD4_STEP0(MD4_Fo, c, d, a, b,     F_w2c00, MD4S02);
134     MD4_STEP0(MD4_Fo, b, c, d, a,     F_w3c00, MD4S03);
135     MD4_STEP0(MD4_Fo, a, b, c, d,     F_w4c00, MD4S00);
136     MD4_STEP0(MD4_Fo, d, a, b, c,     F_w5c00, MD4S01);
137     MD4_STEP0(MD4_Fo, c, d, a, b,     F_w6c00, MD4S02);
138     MD4_STEP0(MD4_Fo, b, c, d, a,     F_w7c00, MD4S03);
139     MD4_STEP0(MD4_Fo, a, b, c, d,     F_w8c00, MD4S00);
140     MD4_STEP0(MD4_Fo, d, a, b, c,     F_w9c00, MD4S01);
141     MD4_STEP0(MD4_Fo, c, d, a, b,     F_wac00, MD4S02);
142     MD4_STEP0(MD4_Fo, b, c, d, a,     F_wbc00, MD4S03);
143     MD4_STEP0(MD4_Fo, a, b, c, d,     F_wcc00, MD4S00);
144     MD4_STEP0(MD4_Fo, d, a, b, c,     F_wdc00, MD4S01);
145     MD4_STEP0(MD4_Fo, c, d, a, b,     F_wec00, MD4S02);
146     MD4_STEP0(MD4_Fo, b, c, d, a,     F_wfc00, MD4S03);
147
148     MD4_STEP (MD4_Go, a, b, c, d, w0, G_w0c01, MD4S10);
149     MD4_STEP0(MD4_Go, d, a, b, c,     G_w4c01, MD4S11);
150     MD4_STEP0(MD4_Go, c, d, a, b,     G_w8c01, MD4S12);
151     MD4_STEP0(MD4_Go, b, c, d, a,     G_wcc01, MD4S13);
152     MD4_STEP0(MD4_Go, a, b, c, d,     G_w1c01, MD4S10);
153     MD4_STEP0(MD4_Go, d, a, b, c,     G_w5c01, MD4S11);
154     MD4_STEP0(MD4_Go, c, d, a, b,     G_w9c01, MD4S12);
155     MD4_STEP0(MD4_Go, b, c, d, a,     G_wdc01, MD4S13);
156     MD4_STEP0(MD4_Go, a, b, c, d,     G_w2c01, MD4S10);
157     MD4_STEP0(MD4_Go, d, a, b, c,     G_w6c01, MD4S11);
158     MD4_STEP0(MD4_Go, c, d, a, b,     G_wac01, MD4S12);
159     MD4_STEP0(MD4_Go, b, c, d, a,     G_wec01, MD4S13);
160     MD4_STEP0(MD4_Go, a, b, c, d,     G_w3c01, MD4S10);
161     MD4_STEP0(MD4_Go, d, a, b, c,     G_w7c01, MD4S11);
162     MD4_STEP0(MD4_Go, c, d, a, b,     G_wbc01, MD4S12);
163     MD4_STEP0(MD4_Go, b, c, d, a,     G_wfc01, MD4S13);
164
165     MD4_STEP (MD4_H , a, b, c, d, w0, H_w0c02, MD4S20);
166     MD4_STEP0(MD4_H , d, a, b, c,     H_w8c02, MD4S21);
167     MD4_STEP0(MD4_H , c, d, a, b,     H_w4c02, MD4S22);
168     MD4_STEP0(MD4_H , b, c, d, a,     H_wcc02, MD4S23);
169     MD4_STEP0(MD4_H , a, b, c, d,     H_w2c02, MD4S20);
170     MD4_STEP0(MD4_H , d, a, b, c,     H_wac02, MD4S21);
171     MD4_STEP0(MD4_H , c, d, a, b,     H_w6c02, MD4S22);
172     MD4_STEP0(MD4_H , b, c, d, a,     H_wec02, MD4S23);
173     MD4_STEP0(MD4_H , a, b, c, d,     H_w1c02, MD4S20);
174     MD4_STEP0(MD4_H , d, a, b, c,     H_w9c02, MD4S21);
175     MD4_STEP0(MD4_H , c, d, a, b,     H_w5c02, MD4S22);
176     MD4_STEP0(MD4_H , b, c, d, a,     H_wdc02, MD4S23);
177     MD4_STEP0(MD4_H , a, b, c, d,     H_w3c02, MD4S20);
178     MD4_STEP0(MD4_H , d, a, b, c,     H_wbc02, MD4S21);
179     MD4_STEP0(MD4_H , c, d, a, b,     H_w7c02, MD4S22);
180     MD4_STEP0(MD4_H , b, c, d, a,     H_wfc02, MD4S23);
181
182     a += MD4M_A;
183     b += MD4M_B;
184     c += MD4M_C;
185     d += MD4M_D;
186
187     u32 w0_t[4];
188     u32 w1_t[4];
189     u32 w2_t[4];
190     u32 w3_t[4];
191
192     w0_t[0] = a;
193     w0_t[1] = b;
194     w0_t[2] = c;
195     w0_t[3] = d;
196     w1_t[0] = salt_buf0[0];
197     w1_t[1] = salt_buf0[1];
198     w1_t[2] = salt_buf0[2];
199     w1_t[3] = salt_buf0[3];
200     w2_t[0] = salt_buf1[0];
201     w2_t[1] = salt_buf1[1];
202     w2_t[2] = salt_buf1[2];
203     w2_t[3] = salt_buf1[3];
204     w3_t[0] = salt_buf2[0];
205     w3_t[1] = salt_buf2[1];
206     w3_t[2] = (16 + salt_len) * 8;
207     w3_t[3] = 0;
208
209     a = MD4M_A;
210     b = MD4M_B;
211     c = MD4M_C;
212     d = MD4M_D;
213
214     MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
215     MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
216     MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
217     MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
218     MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
219     MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
220     MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
221     MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
222     MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
223     MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
224     MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
225     MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
226     MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
227     MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
228     MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
229     MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
230
231     MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
232     MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
233     MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
234     MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
235     MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
236     MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
237     MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
238     MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
239     MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
240     MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
241     MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
242     MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
243     MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
244     MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
245     MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
246     MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
247
248     MD4_STEP (MD4_H , a, b, c, d, w0_t[0], MD4C02, MD4S20);
249     MD4_STEP (MD4_H , d, a, b, c, w2_t[0], MD4C02, MD4S21);
250     MD4_STEP (MD4_H , c, d, a, b, w1_t[0], MD4C02, MD4S22);
251     MD4_STEP (MD4_H , b, c, d, a, w3_t[0], MD4C02, MD4S23);
252     MD4_STEP (MD4_H , a, b, c, d, w0_t[2], MD4C02, MD4S20);
253     MD4_STEP (MD4_H , d, a, b, c, w2_t[2], MD4C02, MD4S21);
254     MD4_STEP (MD4_H , c, d, a, b, w1_t[2], MD4C02, MD4S22);
255     MD4_STEP (MD4_H , b, c, d, a, w3_t[2], MD4C02, MD4S23);
256     MD4_STEP (MD4_H , a, b, c, d, w0_t[1], MD4C02, MD4S20);
257     MD4_STEP (MD4_H , d, a, b, c, w2_t[1], MD4C02, MD4S21);
258     MD4_STEP (MD4_H , c, d, a, b, w1_t[1], MD4C02, MD4S22);
259     MD4_STEP (MD4_H , b, c, d, a, w3_t[1], MD4C02, MD4S23);
260     MD4_STEP (MD4_H , a, b, c, d, w0_t[3], MD4C02, MD4S20);
261     MD4_STEP (MD4_H , d, a, b, c, w2_t[3], MD4C02, MD4S21);
262     MD4_STEP (MD4_H , c, d, a, b, w1_t[3], MD4C02, MD4S22);
263     MD4_STEP (MD4_H , b, c, d, a, w3_t[3], MD4C02, MD4S23);
264
265     const u32 r0 = a;
266     const u32 r1 = d;
267     const u32 r2 = c;
268     const u32 r3 = b;
269
270     #include COMPARE_M
271   }
272 }
273
274 static void m01100s (u32 w[16], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
275 {
276   /**
277    * modifier
278    */
279
280   const u32 gid = get_global_id (0);
281   const u32 lid = get_local_id (0);
282
283   /**
284    * salt
285    */
286
287   u32 salt_buf0[4];
288
289   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
290   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
291   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
292   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
293
294   u32 salt_buf1[4];
295
296   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
297   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
298   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
299   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
300
301   u32 salt_buf2[4];
302
303   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
304   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
305   salt_buf2[2] = 0;
306   salt_buf2[3] = 0;
307
308   const u32 salt_len = salt_bufs[salt_pos].salt_len;
309
310   /**
311    * base
312    */
313
314   const u32 F_w0c00 =     0 + MD4C00;
315   const u32 F_w1c00 = w[ 1] + MD4C00;
316   const u32 F_w2c00 = w[ 2] + MD4C00;
317   const u32 F_w3c00 = w[ 3] + MD4C00;
318   const u32 F_w4c00 = w[ 4] + MD4C00;
319   const u32 F_w5c00 = w[ 5] + MD4C00;
320   const u32 F_w6c00 = w[ 6] + MD4C00;
321   const u32 F_w7c00 = w[ 7] + MD4C00;
322   const u32 F_w8c00 = w[ 8] + MD4C00;
323   const u32 F_w9c00 = w[ 9] + MD4C00;
324   const u32 F_wac00 = w[10] + MD4C00;
325   const u32 F_wbc00 = w[11] + MD4C00;
326   const u32 F_wcc00 = w[12] + MD4C00;
327   const u32 F_wdc00 = w[13] + MD4C00;
328   const u32 F_wec00 = w[14] + MD4C00;
329   const u32 F_wfc00 = w[15] + MD4C00;
330
331   const u32 G_w0c01 =     0 + MD4C01;
332   const u32 G_w4c01 = w[ 4] + MD4C01;
333   const u32 G_w8c01 = w[ 8] + MD4C01;
334   const u32 G_wcc01 = w[12] + MD4C01;
335   const u32 G_w1c01 = w[ 1] + MD4C01;
336   const u32 G_w5c01 = w[ 5] + MD4C01;
337   const u32 G_w9c01 = w[ 9] + MD4C01;
338   const u32 G_wdc01 = w[13] + MD4C01;
339   const u32 G_w2c01 = w[ 2] + MD4C01;
340   const u32 G_w6c01 = w[ 6] + MD4C01;
341   const u32 G_wac01 = w[10] + MD4C01;
342   const u32 G_wec01 = w[14] + MD4C01;
343   const u32 G_w3c01 = w[ 3] + MD4C01;
344   const u32 G_w7c01 = w[ 7] + MD4C01;
345   const u32 G_wbc01 = w[11] + MD4C01;
346   const u32 G_wfc01 = w[15] + MD4C01;
347
348   const u32 H_w0c02 =     0 + MD4C02;
349   const u32 H_w8c02 = w[ 8] + MD4C02;
350   const u32 H_w4c02 = w[ 4] + MD4C02;
351   const u32 H_wcc02 = w[12] + MD4C02;
352   const u32 H_w2c02 = w[ 2] + MD4C02;
353   const u32 H_wac02 = w[10] + MD4C02;
354   const u32 H_w6c02 = w[ 6] + MD4C02;
355   const u32 H_wec02 = w[14] + MD4C02;
356   const u32 H_w1c02 = w[ 1] + MD4C02;
357   const u32 H_w9c02 = w[ 9] + MD4C02;
358   const u32 H_w5c02 = w[ 5] + MD4C02;
359   const u32 H_wdc02 = w[13] + MD4C02;
360   const u32 H_w3c02 = w[ 3] + MD4C02;
361   const u32 H_wbc02 = w[11] + MD4C02;
362   const u32 H_w7c02 = w[ 7] + MD4C02;
363   const u32 H_wfc02 = w[15] + MD4C02;
364
365   /**
366    * digest
367    */
368
369   const u32 search[4] =
370   {
371     digests_buf[digests_offset].digest_buf[DGST_R0],
372     digests_buf[digests_offset].digest_buf[DGST_R1],
373     digests_buf[digests_offset].digest_buf[DGST_R2],
374     digests_buf[digests_offset].digest_buf[DGST_R3]
375   };
376
377   /**
378    * loop
379    */
380
381   u32 w0l = w[0];
382
383   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
384   {
385     const u32 w0r = words_buf_r[il_pos];
386
387     const u32 w0 = w0l | w0r;
388
389     u32 a = MD4M_A;
390     u32 b = MD4M_B;
391     u32 c = MD4M_C;
392     u32 d = MD4M_D;
393
394     MD4_STEP (MD4_Fo, a, b, c, d, w0, F_w0c00, MD4S00);
395     MD4_STEP0(MD4_Fo, d, a, b, c,     F_w1c00, MD4S01);
396     MD4_STEP0(MD4_Fo, c, d, a, b,     F_w2c00, MD4S02);
397     MD4_STEP0(MD4_Fo, b, c, d, a,     F_w3c00, MD4S03);
398     MD4_STEP0(MD4_Fo, a, b, c, d,     F_w4c00, MD4S00);
399     MD4_STEP0(MD4_Fo, d, a, b, c,     F_w5c00, MD4S01);
400     MD4_STEP0(MD4_Fo, c, d, a, b,     F_w6c00, MD4S02);
401     MD4_STEP0(MD4_Fo, b, c, d, a,     F_w7c00, MD4S03);
402     MD4_STEP0(MD4_Fo, a, b, c, d,     F_w8c00, MD4S00);
403     MD4_STEP0(MD4_Fo, d, a, b, c,     F_w9c00, MD4S01);
404     MD4_STEP0(MD4_Fo, c, d, a, b,     F_wac00, MD4S02);
405     MD4_STEP0(MD4_Fo, b, c, d, a,     F_wbc00, MD4S03);
406     MD4_STEP0(MD4_Fo, a, b, c, d,     F_wcc00, MD4S00);
407     MD4_STEP0(MD4_Fo, d, a, b, c,     F_wdc00, MD4S01);
408     MD4_STEP0(MD4_Fo, c, d, a, b,     F_wec00, MD4S02);
409     MD4_STEP0(MD4_Fo, b, c, d, a,     F_wfc00, MD4S03);
410
411     MD4_STEP (MD4_Go, a, b, c, d, w0, G_w0c01, MD4S10);
412     MD4_STEP0(MD4_Go, d, a, b, c,     G_w4c01, MD4S11);
413     MD4_STEP0(MD4_Go, c, d, a, b,     G_w8c01, MD4S12);
414     MD4_STEP0(MD4_Go, b, c, d, a,     G_wcc01, MD4S13);
415     MD4_STEP0(MD4_Go, a, b, c, d,     G_w1c01, MD4S10);
416     MD4_STEP0(MD4_Go, d, a, b, c,     G_w5c01, MD4S11);
417     MD4_STEP0(MD4_Go, c, d, a, b,     G_w9c01, MD4S12);
418     MD4_STEP0(MD4_Go, b, c, d, a,     G_wdc01, MD4S13);
419     MD4_STEP0(MD4_Go, a, b, c, d,     G_w2c01, MD4S10);
420     MD4_STEP0(MD4_Go, d, a, b, c,     G_w6c01, MD4S11);
421     MD4_STEP0(MD4_Go, c, d, a, b,     G_wac01, MD4S12);
422     MD4_STEP0(MD4_Go, b, c, d, a,     G_wec01, MD4S13);
423     MD4_STEP0(MD4_Go, a, b, c, d,     G_w3c01, MD4S10);
424     MD4_STEP0(MD4_Go, d, a, b, c,     G_w7c01, MD4S11);
425     MD4_STEP0(MD4_Go, c, d, a, b,     G_wbc01, MD4S12);
426     MD4_STEP0(MD4_Go, b, c, d, a,     G_wfc01, MD4S13);
427
428     MD4_STEP (MD4_H , a, b, c, d, w0, H_w0c02, MD4S20);
429     MD4_STEP0(MD4_H , d, a, b, c,     H_w8c02, MD4S21);
430     MD4_STEP0(MD4_H , c, d, a, b,     H_w4c02, MD4S22);
431     MD4_STEP0(MD4_H , b, c, d, a,     H_wcc02, MD4S23);
432     MD4_STEP0(MD4_H , a, b, c, d,     H_w2c02, MD4S20);
433     MD4_STEP0(MD4_H , d, a, b, c,     H_wac02, MD4S21);
434     MD4_STEP0(MD4_H , c, d, a, b,     H_w6c02, MD4S22);
435     MD4_STEP0(MD4_H , b, c, d, a,     H_wec02, MD4S23);
436     MD4_STEP0(MD4_H , a, b, c, d,     H_w1c02, MD4S20);
437     MD4_STEP0(MD4_H , d, a, b, c,     H_w9c02, MD4S21);
438     MD4_STEP0(MD4_H , c, d, a, b,     H_w5c02, MD4S22);
439     MD4_STEP0(MD4_H , b, c, d, a,     H_wdc02, MD4S23);
440     MD4_STEP0(MD4_H , a, b, c, d,     H_w3c02, MD4S20);
441     MD4_STEP0(MD4_H , d, a, b, c,     H_wbc02, MD4S21);
442     MD4_STEP0(MD4_H , c, d, a, b,     H_w7c02, MD4S22);
443     MD4_STEP0(MD4_H , b, c, d, a,     H_wfc02, MD4S23);
444
445     a += MD4M_A;
446     b += MD4M_B;
447     c += MD4M_C;
448     d += MD4M_D;
449
450     u32 w0_t[4];
451     u32 w1_t[4];
452     u32 w2_t[4];
453     u32 w3_t[4];
454
455     w0_t[0] = a;
456     w0_t[1] = b;
457     w0_t[2] = c;
458     w0_t[3] = d;
459     w1_t[0] = salt_buf0[0];
460     w1_t[1] = salt_buf0[1];
461     w1_t[2] = salt_buf0[2];
462     w1_t[3] = salt_buf0[3];
463     w2_t[0] = salt_buf1[0];
464     w2_t[1] = salt_buf1[1];
465     w2_t[2] = salt_buf1[2];
466     w2_t[3] = salt_buf1[3];
467     w3_t[0] = salt_buf2[0];
468     w3_t[1] = salt_buf2[1];
469     w3_t[2] = (16 + salt_len) * 8;
470     w3_t[3] = 0;
471
472     a = MD4M_A;
473     b = MD4M_B;
474     c = MD4M_C;
475     d = MD4M_D;
476
477     MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
478     MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
479     MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
480     MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
481     MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
482     MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
483     MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
484     MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
485     MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
486     MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
487     MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
488     MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
489     MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
490     MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
491     MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
492     MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
493
494     MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
495     MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
496     MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
497     MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
498     MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
499     MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
500     MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
501     MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
502     MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
503     MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
504     MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
505     MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
506     MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
507     MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
508     MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
509     MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
510
511     MD4_STEP (MD4_H , a, b, c, d, w0_t[0], MD4C02, MD4S20);
512     MD4_STEP (MD4_H , d, a, b, c, w2_t[0], MD4C02, MD4S21);
513     MD4_STEP (MD4_H , c, d, a, b, w1_t[0], MD4C02, MD4S22);
514     MD4_STEP (MD4_H , b, c, d, a, w3_t[0], MD4C02, MD4S23);
515     MD4_STEP (MD4_H , a, b, c, d, w0_t[2], MD4C02, MD4S20);
516     MD4_STEP (MD4_H , d, a, b, c, w2_t[2], MD4C02, MD4S21);
517     MD4_STEP (MD4_H , c, d, a, b, w1_t[2], MD4C02, MD4S22);
518     MD4_STEP (MD4_H , b, c, d, a, w3_t[2], MD4C02, MD4S23);
519     MD4_STEP (MD4_H , a, b, c, d, w0_t[1], MD4C02, MD4S20);
520     MD4_STEP (MD4_H , d, a, b, c, w2_t[1], MD4C02, MD4S21);
521     MD4_STEP (MD4_H , c, d, a, b, w1_t[1], MD4C02, MD4S22);
522     MD4_STEP (MD4_H , b, c, d, a, w3_t[1], MD4C02, MD4S23);
523     MD4_STEP (MD4_H , a, b, c, d, w0_t[3], MD4C02, MD4S20);
524
525     bool q_cond = allx (search[0] != a);
526
527     if (q_cond) continue;
528
529     MD4_STEP (MD4_H , d, a, b, c, w2_t[3], MD4C02, MD4S21);
530     MD4_STEP (MD4_H , c, d, a, b, w1_t[3], MD4C02, MD4S22);
531     MD4_STEP (MD4_H , b, c, d, a, w3_t[3], MD4C02, MD4S23);
532
533     const u32 r0 = a;
534     const u32 r1 = d;
535     const u32 r2 = c;
536     const u32 r3 = b;
537
538     #include COMPARE_S
539   }
540 }
541
542 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01100_m04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
543 {
544   /**
545    * base
546    */
547
548   const u32 gid = get_global_id (0);
549
550   if (gid >= gid_max) return;
551
552   u32 w[16];
553
554   w[ 0] = pws[gid].i[ 0];
555   w[ 1] = pws[gid].i[ 1];
556   w[ 2] = pws[gid].i[ 2];
557   w[ 3] = pws[gid].i[ 3];
558   w[ 4] = 0;
559   w[ 5] = 0;
560   w[ 6] = 0;
561   w[ 7] = 0;
562   w[ 8] = 0;
563   w[ 9] = 0;
564   w[10] = 0;
565   w[11] = 0;
566   w[12] = 0;
567   w[13] = 0;
568   w[14] = pws[gid].i[14];
569   w[15] = 0;
570
571   const u32 pw_len = pws[gid].pw_len;
572
573   /**
574    * main
575    */
576
577   m01100m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, 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);
578 }
579
580 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01100_m08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
581 {
582   /**
583    * base
584    */
585
586   const u32 gid = get_global_id (0);
587
588   if (gid >= gid_max) return;
589
590   u32 w[16];
591
592   w[ 0] = pws[gid].i[ 0];
593   w[ 1] = pws[gid].i[ 1];
594   w[ 2] = pws[gid].i[ 2];
595   w[ 3] = pws[gid].i[ 3];
596   w[ 4] = pws[gid].i[ 4];
597   w[ 5] = pws[gid].i[ 5];
598   w[ 6] = pws[gid].i[ 6];
599   w[ 7] = pws[gid].i[ 7];
600   w[ 8] = 0;
601   w[ 9] = 0;
602   w[10] = 0;
603   w[11] = 0;
604   w[12] = 0;
605   w[13] = 0;
606   w[14] = pws[gid].i[14];
607   w[15] = 0;
608
609   const u32 pw_len = pws[gid].pw_len;
610
611   /**
612    * main
613    */
614
615   m01100m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, 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);
616 }
617
618 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01100_m16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
619 {
620 }
621
622 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01100_s04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
623 {
624   /**
625    * base
626    */
627
628   const u32 gid = get_global_id (0);
629
630   if (gid >= gid_max) return;
631
632   u32 w[16];
633
634   w[ 0] = pws[gid].i[ 0];
635   w[ 1] = pws[gid].i[ 1];
636   w[ 2] = pws[gid].i[ 2];
637   w[ 3] = pws[gid].i[ 3];
638   w[ 4] = 0;
639   w[ 5] = 0;
640   w[ 6] = 0;
641   w[ 7] = 0;
642   w[ 8] = 0;
643   w[ 9] = 0;
644   w[10] = 0;
645   w[11] = 0;
646   w[12] = 0;
647   w[13] = 0;
648   w[14] = pws[gid].i[14];
649   w[15] = 0;
650
651   const u32 pw_len = pws[gid].pw_len;
652
653   /**
654    * main
655    */
656
657   m01100s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, 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);
658 }
659
660 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01100_s08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
661 {
662   /**
663    * base
664    */
665
666   const u32 gid = get_global_id (0);
667
668   if (gid >= gid_max) return;
669
670   u32 w[16];
671
672   w[ 0] = pws[gid].i[ 0];
673   w[ 1] = pws[gid].i[ 1];
674   w[ 2] = pws[gid].i[ 2];
675   w[ 3] = pws[gid].i[ 3];
676   w[ 4] = pws[gid].i[ 4];
677   w[ 5] = pws[gid].i[ 5];
678   w[ 6] = pws[gid].i[ 6];
679   w[ 7] = pws[gid].i[ 7];
680   w[ 8] = 0;
681   w[ 9] = 0;
682   w[10] = 0;
683   w[11] = 0;
684   w[12] = 0;
685   w[13] = 0;
686   w[14] = pws[gid].i[14];
687   w[15] = 0;
688
689   const u32 pw_len = pws[gid].pw_len;
690
691   /**
692    * main
693    */
694
695   m01100s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, 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);
696 }
697
698 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01100_s16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global u32 * words_buf_r, __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)
699 {
700 }