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