Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m11100_a3.cl
1 /**
2  * Authors.....: Jens Steube <jens.steube@gmail.com>
3  *               Gabriele Gristina <matrix@hashcat.net>
4  *               magnum <john.magnum@hushmail.com>
5  *
6  * License.....: MIT
7  */
8
9 #define _MD5_
10
11 #define NEW_SIMD_CODE
12
13 #include "inc_vendor.cl"
14 #include "inc_hash_constants.h"
15 #include "inc_hash_functions.cl"
16 #include "inc_types.cl"
17 #include "inc_common.cl"
18 #include "inc_simd.cl"
19
20 #if   VECT_SIZE == 1
21 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
22 #elif VECT_SIZE == 2
23 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
24 #elif VECT_SIZE == 4
25 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
26 #elif VECT_SIZE == 8
27 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7])
28 #elif VECT_SIZE == 16
29 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf])
30 #endif
31
32 void m11100m (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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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, __local u32 *l_bin2asc)
33 {
34   /**
35    * modifier
36    */
37
38   const u32 gid = get_global_id (0);
39   const u32 lid = get_local_id (0);
40
41   /**
42    * challenge
43    */
44
45   u32 challenge;
46
47   challenge = salt_bufs[salt_pos].salt_buf[0];
48
49   /**
50    * salt
51    */
52
53   u32 salt_buf0[4];
54   u32 salt_buf1[4];
55
56   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
57   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
58   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
59   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
60   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
61   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
62   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
63   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
64
65   const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
66
67   u32 s0[4];
68   u32 s1[4];
69   u32 s2[4];
70   u32 s3[4];
71
72   s0[0] = salt_buf0[0];
73   s0[1] = salt_buf0[1];
74   s0[2] = salt_buf0[2];
75   s0[3] = salt_buf0[3];
76   s1[0] = salt_buf1[0];
77   s1[1] = salt_buf1[1];
78   s1[2] = salt_buf1[2];
79   s1[3] = salt_buf1[3];
80   s2[0] = 0;
81   s2[1] = 0;
82   s2[2] = 0;
83   s2[3] = 0;
84   s3[0] = 0;
85   s3[1] = 0;
86   s3[2] = 0;
87   s3[3] = 0;
88
89   switch_buffer_by_offset_le_S (s0, s1, s2, s3, pw_len);
90
91   const u32 pw_salt_len = pw_len + salt_len;
92
93   w0[0] |= s0[0];
94   w0[1] |= s0[1];
95   w0[2] |= s0[2];
96   w0[3] |= s0[3];
97   w1[0] |= s1[0];
98   w1[1] |= s1[1];
99   w1[2] |= s1[2];
100   w1[3] |= s1[3];
101   w2[0] |= s2[0];
102   w2[1] |= s2[1];
103   w2[2] |= s2[2];
104   w2[3] |= s2[3];
105   w3[0] |= s3[0];
106   w3[1] |= s3[1];
107   w3[2]  = pw_salt_len * 8;
108   w3[3]  = 0;
109
110   /**
111    * loop
112    */
113
114   u32 w0l = w0[0];
115
116   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
117   {
118     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
119
120     const u32x w0lr = w0l | w0r;
121
122     u32x w0_t[4];
123     u32x w1_t[4];
124     u32x w2_t[4];
125     u32x w3_t[4];
126
127     w0_t[0] = w0lr;
128     w0_t[1] = w0[1];
129     w0_t[2] = w0[2];
130     w0_t[3] = w0[3];
131     w1_t[0] = w1[0];
132     w1_t[1] = w1[1];
133     w1_t[2] = w1[2];
134     w1_t[3] = w1[3];
135     w2_t[0] = w2[0];
136     w2_t[1] = w2[1];
137     w2_t[2] = w2[2];
138     w2_t[3] = w2[3];
139     w3_t[0] = w3[0];
140     w3_t[1] = w3[1];
141     w3_t[2] = w3[2];
142     w3_t[3] = w3[3];
143
144     /*
145      * md5 ($pass.$salt)
146      */
147
148     u32x a = MD5M_A;
149     u32x b = MD5M_B;
150     u32x c = MD5M_C;
151     u32x d = MD5M_D;
152
153     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
154     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
155     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
156     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
157     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
158     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
159     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
160     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
161     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
162     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
163     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
164     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
165     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
166     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
167     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
168     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
169
170     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
171     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
172     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
173     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
174     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
175     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
176     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
177     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
178     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
179     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
180     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
181     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
182     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
183     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
184     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
185     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
186
187     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
188     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
189     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
190     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
191     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
192     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
193     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
194     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
195     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
196     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
197     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
198     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
199     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
200     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
201     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
202     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
203
204     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
205     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
206     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
207     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
208     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
209     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
210     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
211     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
212     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
213     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
214     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
215     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
216     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
217     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
218     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
219     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
220
221     a += MD5M_A;
222     b += MD5M_B;
223     c += MD5M_C;
224     d += MD5M_D;
225
226     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
227             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
228     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
229             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
230     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
231             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
232     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
233             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
234     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
235             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
236     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
237             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
238     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
239             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
240     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
241             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
242
243     // add the 4 byte challenge here
244
245     w2_t[0] = challenge;
246     w2_t[1] = 0x00000080;
247     w2_t[2] = 0;
248     w2_t[3] = 0;
249     w3_t[0] = 0;
250     w3_t[1] = 0;
251     w3_t[2] = (32 + 4) * 8;
252     w3_t[3] = 0;
253
254     /**
255      * md5 ($hash.$challenge)
256      */
257
258     a = MD5M_A;
259     b = MD5M_B;
260     c = MD5M_C;
261     d = MD5M_D;
262
263     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
264     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
265     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
266     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
267     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
268     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
269     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
270     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
271     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
272     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
273     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
274     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
275     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
276     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
277     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
278     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
279
280     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
281     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
282     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
283     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
284     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
285     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
286     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
287     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
288     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
289     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
290     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
291     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
292     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
293     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
294     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
295     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
296
297     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
298     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
299     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
300     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
301     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
302     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
303     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
304     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
305     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
306     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
307     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
308     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
309     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
310     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
311     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
312     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
313
314     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
315     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
316     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
317     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
318     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
319     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
320     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
321     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
322     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
323     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
324     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
325     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
326     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
327     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
328     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
329     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
330
331     COMPARE_M_SIMD (a, d, c, b);
332   }
333 }
334
335 void m11100s (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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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, __local u32 *l_bin2asc)
336 {
337   /**
338    * modifier
339    */
340
341   const u32 gid = get_global_id (0);
342   const u32 lid = get_local_id (0);
343
344   /**
345    * challenge
346    */
347
348   u32 challenge;
349
350   challenge = salt_bufs[salt_pos].salt_buf[0];
351
352   /**
353    * salt
354    */
355
356   u32 salt_buf0[4];
357   u32 salt_buf1[4];
358
359   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
360   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
361   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
362   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
363   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
364   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
365   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
366   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
367
368   const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
369
370   u32 s0[4];
371   u32 s1[4];
372   u32 s2[4];
373   u32 s3[4];
374
375   s0[0] = salt_buf0[0];
376   s0[1] = salt_buf0[1];
377   s0[2] = salt_buf0[2];
378   s0[3] = salt_buf0[3];
379   s1[0] = salt_buf1[0];
380   s1[1] = salt_buf1[1];
381   s1[2] = salt_buf1[2];
382   s1[3] = salt_buf1[3];
383   s2[0] = 0;
384   s2[1] = 0;
385   s2[2] = 0;
386   s2[3] = 0;
387   s3[0] = 0;
388   s3[1] = 0;
389   s3[2] = 0;
390   s3[3] = 0;
391
392   switch_buffer_by_offset_le_S (s0, s1, s2, s3, pw_len);
393
394   const u32 pw_salt_len = pw_len + salt_len;
395
396   w0[0] |= s0[0];
397   w0[1] |= s0[1];
398   w0[2] |= s0[2];
399   w0[3] |= s0[3];
400   w1[0] |= s1[0];
401   w1[1] |= s1[1];
402   w1[2] |= s1[2];
403   w1[3] |= s1[3];
404   w2[0] |= s2[0];
405   w2[1] |= s2[1];
406   w2[2] |= s2[2];
407   w2[3] |= s2[3];
408   w3[0] |= s3[0];
409   w3[1] |= s3[1];
410   w3[2]  = pw_salt_len * 8;
411   w3[3]  = 0;
412
413   /**
414    * digest
415    */
416
417   const u32 search[4] =
418   {
419     digests_buf[digests_offset].digest_buf[DGST_R0],
420     digests_buf[digests_offset].digest_buf[DGST_R1],
421     digests_buf[digests_offset].digest_buf[DGST_R2],
422     digests_buf[digests_offset].digest_buf[DGST_R3]
423   };
424
425   /**
426    * loop
427    */
428
429   u32 w0l = w0[0];
430
431   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
432   {
433     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
434
435     const u32x w0lr = w0l | w0r;
436
437     u32x w0_t[4];
438     u32x w1_t[4];
439     u32x w2_t[4];
440     u32x w3_t[4];
441
442     w0_t[0] = w0lr;
443     w0_t[1] = w0[1];
444     w0_t[2] = w0[2];
445     w0_t[3] = w0[3];
446     w1_t[0] = w1[0];
447     w1_t[1] = w1[1];
448     w1_t[2] = w1[2];
449     w1_t[3] = w1[3];
450     w2_t[0] = w2[0];
451     w2_t[1] = w2[1];
452     w2_t[2] = w2[2];
453     w2_t[3] = w2[3];
454     w3_t[0] = w3[0];
455     w3_t[1] = w3[1];
456     w3_t[2] = w3[2];
457     w3_t[3] = w3[3];
458
459     /*
460      * md5 ($pass.$salt)
461      */
462
463     u32x a = MD5M_A;
464     u32x b = MD5M_B;
465     u32x c = MD5M_C;
466     u32x d = MD5M_D;
467
468     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
469     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
470     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
471     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
472     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
473     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
474     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
475     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
476     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
477     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
478     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
479     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
480     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
481     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
482     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
483     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
484
485     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
486     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
487     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
488     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
489     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
490     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
491     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
492     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
493     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
494     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
495     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
496     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
497     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
498     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
499     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
500     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
501
502     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
503     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
504     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
505     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
506     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
507     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
508     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
509     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
510     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
511     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
512     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
513     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
514     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
515     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
516     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
517     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
518
519     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
520     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
521     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
522     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
523     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
524     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
525     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
526     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
527     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
528     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
529     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
530     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
531     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
532     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
533     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
534     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
535
536     a += MD5M_A;
537     b += MD5M_B;
538     c += MD5M_C;
539     d += MD5M_D;
540
541     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
542             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
543     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
544             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
545     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
546             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
547     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
548             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
549     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
550             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
551     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
552             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
553     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
554             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
555     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
556             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
557
558     // add the 4 byte challenge here
559
560     w2_t[0] = challenge;
561     w2_t[1] = 0x00000080;
562     w2_t[2] = 0;
563     w2_t[3] = 0;
564     w3_t[0] = 0;
565     w3_t[1] = 0;
566     w3_t[2] = (32 + 4) * 8;
567     w3_t[3] = 0;
568
569     /**
570      * md5 ($hash.$challenge)
571      */
572
573     a = MD5M_A;
574     b = MD5M_B;
575     c = MD5M_C;
576     d = MD5M_D;
577
578     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
579     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
580     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
581     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
582     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
583     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
584     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
585     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
586     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
587     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
588     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
589     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
590     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
591     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
592     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
593     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
594
595     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
596     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
597     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
598     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
599     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
600     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
601     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
602     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
603     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
604     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
605     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
606     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
607     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
608     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
609     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
610     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
611
612     MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
613     MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
614     MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
615     MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
616     MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
617     MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
618     MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
619     MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
620     MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
621     MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
622     MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
623     MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
624     MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
625     MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
626     MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
627     MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
628
629     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
630     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
631     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
632     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
633     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
634     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
635     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
636     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
637     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
638     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
639     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
640     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
641     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
642
643     if (MATCHES_NONE_VS (a, search[0])) continue;
644
645     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
646     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
647     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
648
649     COMPARE_S_SIMD (a, d, c, b);
650   }
651 }
652
653 __kernel void m11100_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
654 {
655   /**
656    * base
657    */
658
659   const u32 gid = get_global_id (0);
660   const u32 lid = get_local_id (0);
661   const u32 lsz = get_local_size (0);
662
663   /**
664    * bin2asc table
665    */
666
667   __local u32 l_bin2asc[256];
668
669   for (u32 i = lid; i < 256; i += lsz)
670   {
671     const u32 i0 = (i >> 0) & 15;
672     const u32 i1 = (i >> 4) & 15;
673
674     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
675                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
676   }
677
678   barrier (CLK_LOCAL_MEM_FENCE);
679
680   if (gid >= gid_max) return;
681
682   /**
683    * modifier
684    */
685
686   u32 w0[4];
687
688   w0[0] = pws[gid].i[ 0];
689   w0[1] = pws[gid].i[ 1];
690   w0[2] = pws[gid].i[ 2];
691   w0[3] = pws[gid].i[ 3];
692
693   u32 w1[4];
694
695   w1[0] = 0;
696   w1[1] = 0;
697   w1[2] = 0;
698   w1[3] = 0;
699
700   u32 w2[4];
701
702   w2[0] = 0;
703   w2[1] = 0;
704   w2[2] = 0;
705   w2[3] = 0;
706
707   u32 w3[4];
708
709   w3[0] = 0;
710   w3[1] = 0;
711   w3[2] = pws[gid].i[14];
712   w3[3] = 0;
713
714   const u32 pw_len = pws[gid].pw_len;
715
716   /**
717    * main
718    */
719
720   m11100m (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
721 }
722
723 __kernel void m11100_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
724 {
725   /**
726    * base
727    */
728
729   const u32 gid = get_global_id (0);
730   const u32 lid = get_local_id (0);
731   const u32 lsz = get_local_size (0);
732
733   /**
734    * bin2asc table
735    */
736
737   __local u32 l_bin2asc[256];
738
739   for (u32 i = lid; i < 256; i += lsz)
740   {
741     const u32 i0 = (i >> 0) & 15;
742     const u32 i1 = (i >> 4) & 15;
743
744     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
745                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
746   }
747
748   barrier (CLK_LOCAL_MEM_FENCE);
749
750   if (gid >= gid_max) return;
751
752   /**
753    * modifier
754    */
755
756   u32 w0[4];
757
758   w0[0] = pws[gid].i[ 0];
759   w0[1] = pws[gid].i[ 1];
760   w0[2] = pws[gid].i[ 2];
761   w0[3] = pws[gid].i[ 3];
762
763   u32 w1[4];
764
765   w1[0] = pws[gid].i[ 4];
766   w1[1] = pws[gid].i[ 5];
767   w1[2] = pws[gid].i[ 6];
768   w1[3] = pws[gid].i[ 7];
769
770   u32 w2[4];
771
772   w2[0] = 0;
773   w2[1] = 0;
774   w2[2] = 0;
775   w2[3] = 0;
776
777   u32 w3[4];
778
779   w3[0] = 0;
780   w3[1] = 0;
781   w3[2] = pws[gid].i[14];
782   w3[3] = 0;
783
784   const u32 pw_len = pws[gid].pw_len;
785
786   /**
787    * main
788    */
789
790   m11100m (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
791 }
792
793 __kernel void m11100_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
794 {
795   /**
796    * base
797    */
798
799   const u32 gid = get_global_id (0);
800   const u32 lid = get_local_id (0);
801   const u32 lsz = get_local_size (0);
802
803   /**
804    * bin2asc table
805    */
806
807   __local u32 l_bin2asc[256];
808
809   for (u32 i = lid; i < 256; i += lsz)
810   {
811     const u32 i0 = (i >> 0) & 15;
812     const u32 i1 = (i >> 4) & 15;
813
814     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
815                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
816   }
817
818   barrier (CLK_LOCAL_MEM_FENCE);
819
820   if (gid >= gid_max) return;
821
822   /**
823    * modifier
824    */
825
826   u32 w0[4];
827
828   w0[0] = pws[gid].i[ 0];
829   w0[1] = pws[gid].i[ 1];
830   w0[2] = pws[gid].i[ 2];
831   w0[3] = pws[gid].i[ 3];
832
833   u32 w1[4];
834
835   w1[0] = pws[gid].i[ 4];
836   w1[1] = pws[gid].i[ 5];
837   w1[2] = pws[gid].i[ 6];
838   w1[3] = pws[gid].i[ 7];
839
840   u32 w2[4];
841
842   w2[0] = pws[gid].i[ 8];
843   w2[1] = pws[gid].i[ 9];
844   w2[2] = pws[gid].i[10];
845   w2[3] = pws[gid].i[11];
846
847   u32 w3[4];
848
849   w3[0] = pws[gid].i[12];
850   w3[1] = pws[gid].i[13];
851   w3[2] = pws[gid].i[14];
852   w3[3] = pws[gid].i[15];
853
854   const u32 pw_len = pws[gid].pw_len;
855
856   /**
857    * main
858    */
859
860   m11100m (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
861 }
862
863 __kernel void m11100_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
864 {
865   /**
866    * base
867    */
868
869   const u32 gid = get_global_id (0);
870   const u32 lid = get_local_id (0);
871   const u32 lsz = get_local_size (0);
872
873   /**
874    * bin2asc table
875    */
876
877   __local u32 l_bin2asc[256];
878
879   for (u32 i = lid; i < 256; i += lsz)
880   {
881     const u32 i0 = (i >> 0) & 15;
882     const u32 i1 = (i >> 4) & 15;
883
884     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
885                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
886   }
887
888   barrier (CLK_LOCAL_MEM_FENCE);
889
890   if (gid >= gid_max) return;
891
892   /**
893    * modifier
894    */
895
896   u32 w0[4];
897
898   w0[0] = pws[gid].i[ 0];
899   w0[1] = pws[gid].i[ 1];
900   w0[2] = pws[gid].i[ 2];
901   w0[3] = pws[gid].i[ 3];
902
903   u32 w1[4];
904
905   w1[0] = 0;
906   w1[1] = 0;
907   w1[2] = 0;
908   w1[3] = 0;
909
910   u32 w2[4];
911
912   w2[0] = 0;
913   w2[1] = 0;
914   w2[2] = 0;
915   w2[3] = 0;
916
917   u32 w3[4];
918
919   w3[0] = 0;
920   w3[1] = 0;
921   w3[2] = pws[gid].i[14];
922   w3[3] = 0;
923
924   const u32 pw_len = pws[gid].pw_len;
925
926   /**
927    * main
928    */
929
930   m11100s (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
931 }
932
933 __kernel void m11100_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
934 {
935   /**
936    * base
937    */
938
939   const u32 gid = get_global_id (0);
940   const u32 lid = get_local_id (0);
941   const u32 lsz = get_local_size (0);
942
943   /**
944    * bin2asc table
945    */
946
947   __local u32 l_bin2asc[256];
948
949   for (u32 i = lid; i < 256; i += lsz)
950   {
951     const u32 i0 = (i >> 0) & 15;
952     const u32 i1 = (i >> 4) & 15;
953
954     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
955                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
956   }
957
958   barrier (CLK_LOCAL_MEM_FENCE);
959
960   if (gid >= gid_max) return;
961
962   /**
963    * modifier
964    */
965
966   u32 w0[4];
967
968   w0[0] = pws[gid].i[ 0];
969   w0[1] = pws[gid].i[ 1];
970   w0[2] = pws[gid].i[ 2];
971   w0[3] = pws[gid].i[ 3];
972
973   u32 w1[4];
974
975   w1[0] = pws[gid].i[ 4];
976   w1[1] = pws[gid].i[ 5];
977   w1[2] = pws[gid].i[ 6];
978   w1[3] = pws[gid].i[ 7];
979
980   u32 w2[4];
981
982   w2[0] = 0;
983   w2[1] = 0;
984   w2[2] = 0;
985   w2[3] = 0;
986
987   u32 w3[4];
988
989   w3[0] = 0;
990   w3[1] = 0;
991   w3[2] = pws[gid].i[14];
992   w3[3] = 0;
993
994   const u32 pw_len = pws[gid].pw_len;
995
996   /**
997    * main
998    */
999
1000   m11100s (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
1001 }
1002
1003 __kernel void m11100_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
1004 {
1005   /**
1006    * base
1007    */
1008
1009   const u32 gid = get_global_id (0);
1010   const u32 lid = get_local_id (0);
1011   const u32 lsz = get_local_size (0);
1012
1013   /**
1014    * bin2asc table
1015    */
1016
1017   __local u32 l_bin2asc[256];
1018
1019   for (u32 i = lid; i < 256; i += lsz)
1020   {
1021     const u32 i0 = (i >> 0) & 15;
1022     const u32 i1 = (i >> 4) & 15;
1023
1024     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
1025                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
1026   }
1027
1028   barrier (CLK_LOCAL_MEM_FENCE);
1029
1030   if (gid >= gid_max) return;
1031
1032   /**
1033    * modifier
1034    */
1035
1036   u32 w0[4];
1037
1038   w0[0] = pws[gid].i[ 0];
1039   w0[1] = pws[gid].i[ 1];
1040   w0[2] = pws[gid].i[ 2];
1041   w0[3] = pws[gid].i[ 3];
1042
1043   u32 w1[4];
1044
1045   w1[0] = pws[gid].i[ 4];
1046   w1[1] = pws[gid].i[ 5];
1047   w1[2] = pws[gid].i[ 6];
1048   w1[3] = pws[gid].i[ 7];
1049
1050   u32 w2[4];
1051
1052   w2[0] = pws[gid].i[ 8];
1053   w2[1] = pws[gid].i[ 9];
1054   w2[2] = pws[gid].i[10];
1055   w2[3] = pws[gid].i[11];
1056
1057   u32 w3[4];
1058
1059   w3[0] = pws[gid].i[12];
1060   w3[1] = pws[gid].i[13];
1061   w3[2] = pws[gid].i[14];
1062   w3[3] = pws[gid].i[15];
1063
1064   const u32 pw_len = pws[gid].pw_len;
1065
1066   /**
1067    * main
1068    */
1069
1070   m11100s (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_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset, l_bin2asc);
1071 }