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