79af82be7f18e81dbf15e6107b3105b8dc6e1f32
[hashcat.git] / OpenCL / m03800_a3.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
7
8 #define NEW_SIMD_CODE
9
10 #include "inc_hash_constants.h"
11 #include "inc_vendor.cl"
12
13 #define DGST_R0 0
14 #define DGST_R1 3
15 #define DGST_R2 2
16 #define DGST_R3 1
17
18 #include "inc_hash_functions.cl"
19 #include "inc_types.cl"
20 #include "inc_common.cl"
21 #include "inc_simd.cl"
22
23 void m03800m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 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   u32 salt_buf0[4];
37   u32 salt_buf1[4];
38   u32 salt_buf2[4];
39   u32 salt_buf3[4];
40
41   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
42   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
43   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
44   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
45   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
46   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
47   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
48   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
49   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
50   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
51   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
52   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
53   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
54   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
55   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
56   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
57
58   u32 salt_buf0_t[4];
59   u32 salt_buf1_t[4];
60   u32 salt_buf2_t[4];
61   u32 salt_buf3_t[4];
62
63   salt_buf0_t[0] = salt_bufs[salt_pos].salt_buf[ 0];
64   salt_buf0_t[1] = salt_bufs[salt_pos].salt_buf[ 1];
65   salt_buf0_t[2] = salt_bufs[salt_pos].salt_buf[ 2];
66   salt_buf0_t[3] = salt_bufs[salt_pos].salt_buf[ 3];
67   salt_buf1_t[0] = salt_bufs[salt_pos].salt_buf[ 4];
68   salt_buf1_t[1] = salt_bufs[salt_pos].salt_buf[ 5];
69   salt_buf1_t[2] = salt_bufs[salt_pos].salt_buf[ 6];
70   salt_buf1_t[3] = salt_bufs[salt_pos].salt_buf[ 7];
71   salt_buf2_t[0] = salt_bufs[salt_pos].salt_buf[ 8];
72   salt_buf2_t[1] = salt_bufs[salt_pos].salt_buf[ 9];
73   salt_buf2_t[2] = salt_bufs[salt_pos].salt_buf[10];
74   salt_buf2_t[3] = salt_bufs[salt_pos].salt_buf[11];
75   salt_buf3_t[0] = salt_bufs[salt_pos].salt_buf[12];
76   salt_buf3_t[1] = salt_bufs[salt_pos].salt_buf[13];
77   salt_buf3_t[2] = salt_bufs[salt_pos].salt_buf[14];
78   salt_buf3_t[3] = salt_bufs[salt_pos].salt_buf[15];
79
80   const u32 salt_len = salt_bufs[salt_pos].salt_len;
81
82   const u32 pw_salt_len = pw_len + salt_len;
83
84   const u32 salt_pw_salt_len = salt_len + pw_len + salt_len;
85
86   switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_salt_len);
87
88   salt_buf0[0] |= salt_buf0_t[0];
89   salt_buf0[1] |= salt_buf0_t[1];
90   salt_buf0[2] |= salt_buf0_t[2];
91   salt_buf0[3] |= salt_buf0_t[3];
92   salt_buf1[0] |= salt_buf1_t[0];
93   salt_buf1[1] |= salt_buf1_t[1];
94   salt_buf1[2] |= salt_buf1_t[2];
95   salt_buf1[3] |= salt_buf1_t[3];
96   salt_buf2[0] |= salt_buf2_t[0];
97   salt_buf2[1] |= salt_buf2_t[1];
98   salt_buf2[2] |= salt_buf2_t[2];
99   salt_buf2[3] |= salt_buf2_t[3];
100   salt_buf3[0] |= salt_buf3_t[0];
101   salt_buf3[1] |= salt_buf3_t[1];
102   salt_buf3[2] |= salt_buf3_t[2];
103   salt_buf3[3] |= salt_buf3_t[3];
104
105   append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_pw_salt_len);
106
107   /**
108    * loop
109    */
110
111   u32 w0l = w0[0];
112
113   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
114   {
115     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
116
117     const u32x w0lr = w0l | w0r;
118
119     u32x t0[4];
120     u32x t1[4];
121     u32x t2[4];
122     u32x t3[4];
123
124     t0[0] = w0lr;
125     t0[1] = w0[1];
126     t0[2] = w0[2];
127     t0[3] = w0[3];
128     t1[0] = w1[0];
129     t1[1] = w1[1];
130     t1[2] = w1[2];
131     t1[3] = w1[3];
132     t2[0] = w2[0];
133     t2[1] = w2[1];
134     t2[2] = w2[2];
135     t2[3] = w2[3];
136     t3[0] = w3[0];
137     t3[1] = w3[1];
138     t3[2] = w3[2];
139     t3[3] = w3[3];
140
141     /**
142      * put the password after the first salt but before the second salt
143      */
144
145     switch_buffer_by_offset_le (t0, t1, t2, t3, salt_len);
146
147     t0[0] |= salt_buf0[0];
148     t0[1] |= salt_buf0[1];
149     t0[2] |= salt_buf0[2];
150     t0[3] |= salt_buf0[3];
151     t1[0] |= salt_buf1[0];
152     t1[1] |= salt_buf1[1];
153     t1[2] |= salt_buf1[2];
154     t1[3] |= salt_buf1[3];
155     t2[0] |= salt_buf2[0];
156     t2[1] |= salt_buf2[1];
157     t2[2] |= salt_buf2[2];
158     t2[3] |= salt_buf2[3];
159     t3[0] |= salt_buf3[0];
160     t3[1] |= salt_buf3[1];
161     t3[2]  = salt_pw_salt_len * 8;
162     t3[3]  = 0;
163
164     /**
165      * md5
166      */
167
168     u32x a = MD5M_A;
169     u32x b = MD5M_B;
170     u32x c = MD5M_C;
171     u32x d = MD5M_D;
172
173     MD5_STEP (MD5_Fo, a, b, c, d, t0[0], MD5C00, MD5S00);
174     MD5_STEP (MD5_Fo, d, a, b, c, t0[1], MD5C01, MD5S01);
175     MD5_STEP (MD5_Fo, c, d, a, b, t0[2], MD5C02, MD5S02);
176     MD5_STEP (MD5_Fo, b, c, d, a, t0[3], MD5C03, MD5S03);
177     MD5_STEP (MD5_Fo, a, b, c, d, t1[0], MD5C04, MD5S00);
178     MD5_STEP (MD5_Fo, d, a, b, c, t1[1], MD5C05, MD5S01);
179     MD5_STEP (MD5_Fo, c, d, a, b, t1[2], MD5C06, MD5S02);
180     MD5_STEP (MD5_Fo, b, c, d, a, t1[3], MD5C07, MD5S03);
181     MD5_STEP (MD5_Fo, a, b, c, d, t2[0], MD5C08, MD5S00);
182     MD5_STEP (MD5_Fo, d, a, b, c, t2[1], MD5C09, MD5S01);
183     MD5_STEP (MD5_Fo, c, d, a, b, t2[2], MD5C0a, MD5S02);
184     MD5_STEP (MD5_Fo, b, c, d, a, t2[3], MD5C0b, MD5S03);
185     MD5_STEP (MD5_Fo, a, b, c, d, t3[0], MD5C0c, MD5S00);
186     MD5_STEP (MD5_Fo, d, a, b, c, t3[1], MD5C0d, MD5S01);
187     MD5_STEP (MD5_Fo, c, d, a, b, t3[2], MD5C0e, MD5S02);
188     MD5_STEP (MD5_Fo, b, c, d, a, t3[3], MD5C0f, MD5S03);
189
190     MD5_STEP (MD5_Go, a, b, c, d, t0[1], MD5C10, MD5S10);
191     MD5_STEP (MD5_Go, d, a, b, c, t1[2], MD5C11, MD5S11);
192     MD5_STEP (MD5_Go, c, d, a, b, t2[3], MD5C12, MD5S12);
193     MD5_STEP (MD5_Go, b, c, d, a, t0[0], MD5C13, MD5S13);
194     MD5_STEP (MD5_Go, a, b, c, d, t1[1], MD5C14, MD5S10);
195     MD5_STEP (MD5_Go, d, a, b, c, t2[2], MD5C15, MD5S11);
196     MD5_STEP (MD5_Go, c, d, a, b, t3[3], MD5C16, MD5S12);
197     MD5_STEP (MD5_Go, b, c, d, a, t1[0], MD5C17, MD5S13);
198     MD5_STEP (MD5_Go, a, b, c, d, t2[1], MD5C18, MD5S10);
199     MD5_STEP (MD5_Go, d, a, b, c, t3[2], MD5C19, MD5S11);
200     MD5_STEP (MD5_Go, c, d, a, b, t0[3], MD5C1a, MD5S12);
201     MD5_STEP (MD5_Go, b, c, d, a, t2[0], MD5C1b, MD5S13);
202     MD5_STEP (MD5_Go, a, b, c, d, t3[1], MD5C1c, MD5S10);
203     MD5_STEP (MD5_Go, d, a, b, c, t0[2], MD5C1d, MD5S11);
204     MD5_STEP (MD5_Go, c, d, a, b, t1[3], MD5C1e, MD5S12);
205     MD5_STEP (MD5_Go, b, c, d, a, t3[0], MD5C1f, MD5S13);
206
207     MD5_STEP (MD5_H , a, b, c, d, t1[1], MD5C20, MD5S20);
208     MD5_STEP (MD5_H , d, a, b, c, t2[0], MD5C21, MD5S21);
209     MD5_STEP (MD5_H , c, d, a, b, t2[3], MD5C22, MD5S22);
210     MD5_STEP (MD5_H , b, c, d, a, t3[2], MD5C23, MD5S23);
211     MD5_STEP (MD5_H , a, b, c, d, t0[1], MD5C24, MD5S20);
212     MD5_STEP (MD5_H , d, a, b, c, t1[0], MD5C25, MD5S21);
213     MD5_STEP (MD5_H , c, d, a, b, t1[3], MD5C26, MD5S22);
214     MD5_STEP (MD5_H , b, c, d, a, t2[2], MD5C27, MD5S23);
215     MD5_STEP (MD5_H , a, b, c, d, t3[1], MD5C28, MD5S20);
216     MD5_STEP (MD5_H , d, a, b, c, t0[0], MD5C29, MD5S21);
217     MD5_STEP (MD5_H , c, d, a, b, t0[3], MD5C2a, MD5S22);
218     MD5_STEP (MD5_H , b, c, d, a, t1[2], MD5C2b, MD5S23);
219     MD5_STEP (MD5_H , a, b, c, d, t2[1], MD5C2c, MD5S20);
220     MD5_STEP (MD5_H , d, a, b, c, t3[0], MD5C2d, MD5S21);
221     MD5_STEP (MD5_H , c, d, a, b, t3[3], MD5C2e, MD5S22);
222     MD5_STEP (MD5_H , b, c, d, a, t0[2], MD5C2f, MD5S23);
223
224     MD5_STEP (MD5_I , a, b, c, d, t0[0], MD5C30, MD5S30);
225     MD5_STEP (MD5_I , d, a, b, c, t1[3], MD5C31, MD5S31);
226     MD5_STEP (MD5_I , c, d, a, b, t3[2], MD5C32, MD5S32);
227     MD5_STEP (MD5_I , b, c, d, a, t1[1], MD5C33, MD5S33);
228     MD5_STEP (MD5_I , a, b, c, d, t3[0], MD5C34, MD5S30);
229     MD5_STEP (MD5_I , d, a, b, c, t0[3], MD5C35, MD5S31);
230     MD5_STEP (MD5_I , c, d, a, b, t2[2], MD5C36, MD5S32);
231     MD5_STEP (MD5_I , b, c, d, a, t0[1], MD5C37, MD5S33);
232     MD5_STEP (MD5_I , a, b, c, d, t2[0], MD5C38, MD5S30);
233     MD5_STEP (MD5_I , d, a, b, c, t3[3], MD5C39, MD5S31);
234     MD5_STEP (MD5_I , c, d, a, b, t1[2], MD5C3a, MD5S32);
235     MD5_STEP (MD5_I , b, c, d, a, t3[1], MD5C3b, MD5S33);
236     MD5_STEP (MD5_I , a, b, c, d, t1[0], MD5C3c, MD5S30);
237     MD5_STEP (MD5_I , d, a, b, c, t2[3], MD5C3d, MD5S31);
238     MD5_STEP (MD5_I , c, d, a, b, t0[2], MD5C3e, MD5S32);
239     MD5_STEP (MD5_I , b, c, d, a, t2[1], MD5C3f, MD5S33);
240
241     COMPARE_M_SIMD (a, d, c, b);
242   }
243 }
244
245 void m03800s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset)
246 {
247   /**
248    * modifier
249    */
250
251   const u32 gid = get_global_id (0);
252   const u32 lid = get_local_id (0);
253
254   /**
255    * salt
256    */
257
258   u32 salt_buf0[4];
259   u32 salt_buf1[4];
260   u32 salt_buf2[4];
261   u32 salt_buf3[4];
262
263   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
264   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
265   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
266   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
267   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
268   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
269   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
270   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
271   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
272   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
273   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
274   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
275   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
276   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
277   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
278   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
279
280   u32 salt_buf0_t[4];
281   u32 salt_buf1_t[4];
282   u32 salt_buf2_t[4];
283   u32 salt_buf3_t[4];
284
285   salt_buf0_t[0] = salt_bufs[salt_pos].salt_buf[ 0];
286   salt_buf0_t[1] = salt_bufs[salt_pos].salt_buf[ 1];
287   salt_buf0_t[2] = salt_bufs[salt_pos].salt_buf[ 2];
288   salt_buf0_t[3] = salt_bufs[salt_pos].salt_buf[ 3];
289   salt_buf1_t[0] = salt_bufs[salt_pos].salt_buf[ 4];
290   salt_buf1_t[1] = salt_bufs[salt_pos].salt_buf[ 5];
291   salt_buf1_t[2] = salt_bufs[salt_pos].salt_buf[ 6];
292   salt_buf1_t[3] = salt_bufs[salt_pos].salt_buf[ 7];
293   salt_buf2_t[0] = salt_bufs[salt_pos].salt_buf[ 8];
294   salt_buf2_t[1] = salt_bufs[salt_pos].salt_buf[ 9];
295   salt_buf2_t[2] = salt_bufs[salt_pos].salt_buf[10];
296   salt_buf2_t[3] = salt_bufs[salt_pos].salt_buf[11];
297   salt_buf3_t[0] = salt_bufs[salt_pos].salt_buf[12];
298   salt_buf3_t[1] = salt_bufs[salt_pos].salt_buf[13];
299   salt_buf3_t[2] = salt_bufs[salt_pos].salt_buf[14];
300   salt_buf3_t[3] = salt_bufs[salt_pos].salt_buf[15];
301
302   const u32 salt_len = salt_bufs[salt_pos].salt_len;
303
304   const u32 pw_salt_len = pw_len + salt_len;
305
306   const u32 salt_pw_salt_len = salt_len + pw_len + salt_len;
307
308   switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_salt_len);
309
310   salt_buf0[0] |= salt_buf0_t[0];
311   salt_buf0[1] |= salt_buf0_t[1];
312   salt_buf0[2] |= salt_buf0_t[2];
313   salt_buf0[3] |= salt_buf0_t[3];
314   salt_buf1[0] |= salt_buf1_t[0];
315   salt_buf1[1] |= salt_buf1_t[1];
316   salt_buf1[2] |= salt_buf1_t[2];
317   salt_buf1[3] |= salt_buf1_t[3];
318   salt_buf2[0] |= salt_buf2_t[0];
319   salt_buf2[1] |= salt_buf2_t[1];
320   salt_buf2[2] |= salt_buf2_t[2];
321   salt_buf2[3] |= salt_buf2_t[3];
322   salt_buf3[0] |= salt_buf3_t[0];
323   salt_buf3[1] |= salt_buf3_t[1];
324   salt_buf3[2] |= salt_buf3_t[2];
325   salt_buf3[3] |= salt_buf3_t[3];
326
327   append_0x80_4x4_S (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_pw_salt_len);
328
329   /**
330    * digest
331    */
332
333   const u32 search[4] =
334   {
335     digests_buf[digests_offset].digest_buf[DGST_R0],
336     digests_buf[digests_offset].digest_buf[DGST_R1],
337     digests_buf[digests_offset].digest_buf[DGST_R2],
338     digests_buf[digests_offset].digest_buf[DGST_R3]
339   };
340
341   /**
342    * loop
343    */
344
345   u32 w0l = w0[0];
346
347   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
348   {
349     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
350
351     const u32x w0lr = w0l | w0r;
352
353     u32x t0[4];
354     u32x t1[4];
355     u32x t2[4];
356     u32x t3[4];
357
358     t0[0] = w0lr;
359     t0[1] = w0[1];
360     t0[2] = w0[2];
361     t0[3] = w0[3];
362     t1[0] = w1[0];
363     t1[1] = w1[1];
364     t1[2] = w1[2];
365     t1[3] = w1[3];
366     t2[0] = w2[0];
367     t2[1] = w2[1];
368     t2[2] = w2[2];
369     t2[3] = w2[3];
370     t3[0] = w3[0];
371     t3[1] = w3[1];
372     t3[2] = w3[2];
373     t3[3] = w3[3];
374
375     /**
376      * put the password after the first salt but before the second salt
377      */
378
379     switch_buffer_by_offset_le (t0, t1, t2, t3, salt_len);
380
381     t0[0] |= salt_buf0[0];
382     t0[1] |= salt_buf0[1];
383     t0[2] |= salt_buf0[2];
384     t0[3] |= salt_buf0[3];
385     t1[0] |= salt_buf1[0];
386     t1[1] |= salt_buf1[1];
387     t1[2] |= salt_buf1[2];
388     t1[3] |= salt_buf1[3];
389     t2[0] |= salt_buf2[0];
390     t2[1] |= salt_buf2[1];
391     t2[2] |= salt_buf2[2];
392     t2[3] |= salt_buf2[3];
393     t3[0] |= salt_buf3[0];
394     t3[1] |= salt_buf3[1];
395     t3[2]  = salt_pw_salt_len * 8;
396     t3[3]  = 0;
397
398     /**
399      * md5
400      */
401
402     u32x a = MD5M_A;
403     u32x b = MD5M_B;
404     u32x c = MD5M_C;
405     u32x d = MD5M_D;
406
407     MD5_STEP (MD5_Fo, a, b, c, d, t0[0], MD5C00, MD5S00);
408     MD5_STEP (MD5_Fo, d, a, b, c, t0[1], MD5C01, MD5S01);
409     MD5_STEP (MD5_Fo, c, d, a, b, t0[2], MD5C02, MD5S02);
410     MD5_STEP (MD5_Fo, b, c, d, a, t0[3], MD5C03, MD5S03);
411     MD5_STEP (MD5_Fo, a, b, c, d, t1[0], MD5C04, MD5S00);
412     MD5_STEP (MD5_Fo, d, a, b, c, t1[1], MD5C05, MD5S01);
413     MD5_STEP (MD5_Fo, c, d, a, b, t1[2], MD5C06, MD5S02);
414     MD5_STEP (MD5_Fo, b, c, d, a, t1[3], MD5C07, MD5S03);
415     MD5_STEP (MD5_Fo, a, b, c, d, t2[0], MD5C08, MD5S00);
416     MD5_STEP (MD5_Fo, d, a, b, c, t2[1], MD5C09, MD5S01);
417     MD5_STEP (MD5_Fo, c, d, a, b, t2[2], MD5C0a, MD5S02);
418     MD5_STEP (MD5_Fo, b, c, d, a, t2[3], MD5C0b, MD5S03);
419     MD5_STEP (MD5_Fo, a, b, c, d, t3[0], MD5C0c, MD5S00);
420     MD5_STEP (MD5_Fo, d, a, b, c, t3[1], MD5C0d, MD5S01);
421     MD5_STEP (MD5_Fo, c, d, a, b, t3[2], MD5C0e, MD5S02);
422     MD5_STEP (MD5_Fo, b, c, d, a, t3[3], MD5C0f, MD5S03);
423
424     MD5_STEP (MD5_Go, a, b, c, d, t0[1], MD5C10, MD5S10);
425     MD5_STEP (MD5_Go, d, a, b, c, t1[2], MD5C11, MD5S11);
426     MD5_STEP (MD5_Go, c, d, a, b, t2[3], MD5C12, MD5S12);
427     MD5_STEP (MD5_Go, b, c, d, a, t0[0], MD5C13, MD5S13);
428     MD5_STEP (MD5_Go, a, b, c, d, t1[1], MD5C14, MD5S10);
429     MD5_STEP (MD5_Go, d, a, b, c, t2[2], MD5C15, MD5S11);
430     MD5_STEP (MD5_Go, c, d, a, b, t3[3], MD5C16, MD5S12);
431     MD5_STEP (MD5_Go, b, c, d, a, t1[0], MD5C17, MD5S13);
432     MD5_STEP (MD5_Go, a, b, c, d, t2[1], MD5C18, MD5S10);
433     MD5_STEP (MD5_Go, d, a, b, c, t3[2], MD5C19, MD5S11);
434     MD5_STEP (MD5_Go, c, d, a, b, t0[3], MD5C1a, MD5S12);
435     MD5_STEP (MD5_Go, b, c, d, a, t2[0], MD5C1b, MD5S13);
436     MD5_STEP (MD5_Go, a, b, c, d, t3[1], MD5C1c, MD5S10);
437     MD5_STEP (MD5_Go, d, a, b, c, t0[2], MD5C1d, MD5S11);
438     MD5_STEP (MD5_Go, c, d, a, b, t1[3], MD5C1e, MD5S12);
439     MD5_STEP (MD5_Go, b, c, d, a, t3[0], MD5C1f, MD5S13);
440
441     MD5_STEP (MD5_H , a, b, c, d, t1[1], MD5C20, MD5S20);
442     MD5_STEP (MD5_H , d, a, b, c, t2[0], MD5C21, MD5S21);
443     MD5_STEP (MD5_H , c, d, a, b, t2[3], MD5C22, MD5S22);
444     MD5_STEP (MD5_H , b, c, d, a, t3[2], MD5C23, MD5S23);
445     MD5_STEP (MD5_H , a, b, c, d, t0[1], MD5C24, MD5S20);
446     MD5_STEP (MD5_H , d, a, b, c, t1[0], MD5C25, MD5S21);
447     MD5_STEP (MD5_H , c, d, a, b, t1[3], MD5C26, MD5S22);
448     MD5_STEP (MD5_H , b, c, d, a, t2[2], MD5C27, MD5S23);
449     MD5_STEP (MD5_H , a, b, c, d, t3[1], MD5C28, MD5S20);
450     MD5_STEP (MD5_H , d, a, b, c, t0[0], MD5C29, MD5S21);
451     MD5_STEP (MD5_H , c, d, a, b, t0[3], MD5C2a, MD5S22);
452     MD5_STEP (MD5_H , b, c, d, a, t1[2], MD5C2b, MD5S23);
453     MD5_STEP (MD5_H , a, b, c, d, t2[1], MD5C2c, MD5S20);
454     MD5_STEP (MD5_H , d, a, b, c, t3[0], MD5C2d, MD5S21);
455     MD5_STEP (MD5_H , c, d, a, b, t3[3], MD5C2e, MD5S22);
456     MD5_STEP (MD5_H , b, c, d, a, t0[2], MD5C2f, MD5S23);
457
458     MD5_STEP (MD5_I , a, b, c, d, t0[0], MD5C30, MD5S30);
459     MD5_STEP (MD5_I , d, a, b, c, t1[3], MD5C31, MD5S31);
460     MD5_STEP (MD5_I , c, d, a, b, t3[2], MD5C32, MD5S32);
461     MD5_STEP (MD5_I , b, c, d, a, t1[1], MD5C33, MD5S33);
462     MD5_STEP (MD5_I , a, b, c, d, t3[0], MD5C34, MD5S30);
463     MD5_STEP (MD5_I , d, a, b, c, t0[3], MD5C35, MD5S31);
464     MD5_STEP (MD5_I , c, d, a, b, t2[2], MD5C36, MD5S32);
465     MD5_STEP (MD5_I , b, c, d, a, t0[1], MD5C37, MD5S33);
466     MD5_STEP (MD5_I , a, b, c, d, t2[0], MD5C38, MD5S30);
467     MD5_STEP (MD5_I , d, a, b, c, t3[3], MD5C39, MD5S31);
468     MD5_STEP (MD5_I , c, d, a, b, t1[2], MD5C3a, MD5S32);
469     MD5_STEP (MD5_I , b, c, d, a, t3[1], MD5C3b, MD5S33);
470     MD5_STEP (MD5_I , a, b, c, d, t1[0], MD5C3c, MD5S30);
471
472     if (MATCHES_NONE_VS (a, search[0])) continue;
473
474     MD5_STEP (MD5_I , d, a, b, c, t2[3], MD5C3d, MD5S31);
475     MD5_STEP (MD5_I , c, d, a, b, t0[2], MD5C3e, MD5S32);
476     MD5_STEP (MD5_I , b, c, d, a, t2[1], MD5C3f, MD5S33);
477
478     COMPARE_S_SIMD (a, d, c, b);
479   }
480 }
481
482 __kernel void m03800_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
483 {
484   /**
485    * base
486    */
487
488   const u32 gid = get_global_id (0);
489
490   if (gid >= gid_max) return;
491
492   /**
493    * modifier
494    */
495
496   const u32 lid = get_local_id (0);
497
498   u32 w0[4];
499
500   w0[0] = pws[gid].i[ 0];
501   w0[1] = pws[gid].i[ 1];
502   w0[2] = pws[gid].i[ 2];
503   w0[3] = pws[gid].i[ 3];
504
505   u32 w1[4];
506
507   w1[0] = 0;
508   w1[1] = 0;
509   w1[2] = 0;
510   w1[3] = 0;
511
512   u32 w2[4];
513
514   w2[0] = 0;
515   w2[1] = 0;
516   w2[2] = 0;
517   w2[3] = 0;
518
519   u32 w3[4];
520
521   w3[0] = 0;
522   w3[1] = 0;
523   w3[2] = pws[gid].i[14];
524   w3[3] = 0;
525
526   const u32 pw_len = pws[gid].pw_len;
527
528   /**
529    * main
530    */
531
532   m03800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
533 }
534
535 __kernel void m03800_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
536 {
537   /**
538    * base
539    */
540
541   const u32 gid = get_global_id (0);
542
543   if (gid >= gid_max) return;
544
545   /**
546    * modifier
547    */
548
549   const u32 lid = get_local_id (0);
550
551   u32 w0[4];
552
553   w0[0] = pws[gid].i[ 0];
554   w0[1] = pws[gid].i[ 1];
555   w0[2] = pws[gid].i[ 2];
556   w0[3] = pws[gid].i[ 3];
557
558   u32 w1[4];
559
560   w1[0] = pws[gid].i[ 4];
561   w1[1] = pws[gid].i[ 5];
562   w1[2] = pws[gid].i[ 6];
563   w1[3] = pws[gid].i[ 7];
564
565   u32 w2[4];
566
567   w2[0] = 0;
568   w2[1] = 0;
569   w2[2] = 0;
570   w2[3] = 0;
571
572   u32 w3[4];
573
574   w3[0] = 0;
575   w3[1] = 0;
576   w3[2] = pws[gid].i[14];
577   w3[3] = 0;
578
579   const u32 pw_len = pws[gid].pw_len;
580
581   /**
582    * main
583    */
584
585   m03800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
586 }
587
588 __kernel void m03800_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
589 {
590   /**
591    * base
592    */
593
594   const u32 gid = get_global_id (0);
595
596   if (gid >= gid_max) return;
597
598   /**
599    * modifier
600    */
601
602   const u32 lid = get_local_id (0);
603
604   u32 w0[4];
605
606   w0[0] = pws[gid].i[ 0];
607   w0[1] = pws[gid].i[ 1];
608   w0[2] = pws[gid].i[ 2];
609   w0[3] = pws[gid].i[ 3];
610
611   u32 w1[4];
612
613   w1[0] = pws[gid].i[ 4];
614   w1[1] = pws[gid].i[ 5];
615   w1[2] = pws[gid].i[ 6];
616   w1[3] = pws[gid].i[ 7];
617
618   u32 w2[4];
619
620   w2[0] = pws[gid].i[ 8];
621   w2[1] = pws[gid].i[ 9];
622   w2[2] = pws[gid].i[10];
623   w2[3] = pws[gid].i[11];
624
625   u32 w3[4];
626
627   w3[0] = pws[gid].i[12];
628   w3[1] = pws[gid].i[13];
629   w3[2] = pws[gid].i[14];
630   w3[3] = pws[gid].i[15];
631
632   const u32 pw_len = pws[gid].pw_len;
633
634   /**
635    * main
636    */
637
638   m03800m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
639 }
640
641 __kernel void m03800_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
642 {
643   /**
644    * base
645    */
646
647   const u32 gid = get_global_id (0);
648
649   if (gid >= gid_max) return;
650
651   /**
652    * modifier
653    */
654
655   const u32 lid = get_local_id (0);
656
657   u32 w0[4];
658
659   w0[0] = pws[gid].i[ 0];
660   w0[1] = pws[gid].i[ 1];
661   w0[2] = pws[gid].i[ 2];
662   w0[3] = pws[gid].i[ 3];
663
664   u32 w1[4];
665
666   w1[0] = 0;
667   w1[1] = 0;
668   w1[2] = 0;
669   w1[3] = 0;
670
671   u32 w2[4];
672
673   w2[0] = 0;
674   w2[1] = 0;
675   w2[2] = 0;
676   w2[3] = 0;
677
678   u32 w3[4];
679
680   w3[0] = 0;
681   w3[1] = 0;
682   w3[2] = pws[gid].i[14];
683   w3[3] = 0;
684
685   const u32 pw_len = pws[gid].pw_len;
686
687   /**
688    * main
689    */
690
691   m03800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
692 }
693
694 __kernel void m03800_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
695 {
696   /**
697    * base
698    */
699
700   const u32 gid = get_global_id (0);
701
702   if (gid >= gid_max) return;
703
704   /**
705    * modifier
706    */
707
708   const u32 lid = get_local_id (0);
709
710   u32 w0[4];
711
712   w0[0] = pws[gid].i[ 0];
713   w0[1] = pws[gid].i[ 1];
714   w0[2] = pws[gid].i[ 2];
715   w0[3] = pws[gid].i[ 3];
716
717   u32 w1[4];
718
719   w1[0] = pws[gid].i[ 4];
720   w1[1] = pws[gid].i[ 5];
721   w1[2] = pws[gid].i[ 6];
722   w1[3] = pws[gid].i[ 7];
723
724   u32 w2[4];
725
726   w2[0] = 0;
727   w2[1] = 0;
728   w2[2] = 0;
729   w2[3] = 0;
730
731   u32 w3[4];
732
733   w3[0] = 0;
734   w3[1] = 0;
735   w3[2] = pws[gid].i[14];
736   w3[3] = 0;
737
738   const u32 pw_len = pws[gid].pw_len;
739
740   /**
741    * main
742    */
743
744   m03800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
745 }
746
747 __kernel void m03800_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
748 {
749   /**
750    * base
751    */
752
753   const u32 gid = get_global_id (0);
754
755   if (gid >= gid_max) return;
756
757   /**
758    * modifier
759    */
760
761   const u32 lid = get_local_id (0);
762
763   u32 w0[4];
764
765   w0[0] = pws[gid].i[ 0];
766   w0[1] = pws[gid].i[ 1];
767   w0[2] = pws[gid].i[ 2];
768   w0[3] = pws[gid].i[ 3];
769
770   u32 w1[4];
771
772   w1[0] = pws[gid].i[ 4];
773   w1[1] = pws[gid].i[ 5];
774   w1[2] = pws[gid].i[ 6];
775   w1[3] = pws[gid].i[ 7];
776
777   u32 w2[4];
778
779   w2[0] = pws[gid].i[ 8];
780   w2[1] = pws[gid].i[ 9];
781   w2[2] = pws[gid].i[10];
782   w2[3] = pws[gid].i[11];
783
784   u32 w3[4];
785
786   w3[0] = pws[gid].i[12];
787   w3[1] = pws[gid].i[13];
788   w3[2] = pws[gid].i[14];
789   w3[3] = pws[gid].i[15];
790
791   const u32 pw_len = pws[gid].pw_len;
792
793   /**
794    * main
795    */
796
797   m03800s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
798 }