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