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