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