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