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