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