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