Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m04400_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_SHA1_
7
8 #define NEW_SIMD_CODE
9
10 #include "inc_vendor.cl"
11 #include "inc_hash_constants.h"
12 #include "inc_hash_functions.cl"
13 #include "inc_types.cl"
14 #include "inc_common.cl"
15 #include "inc_simd.cl"
16
17 #if   VECT_SIZE == 1
18 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
19 #elif VECT_SIZE == 2
20 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
21 #elif VECT_SIZE == 4
22 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
23 #elif VECT_SIZE == 8
24 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7])
25 #elif VECT_SIZE == 16
26 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf])
27 #endif
28
29 __kernel void m04400_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
30 {
31   /**
32    * modifier
33    */
34
35   const u32 gid = get_global_id (0);
36   const u32 lid = get_local_id (0);
37   const u32 lsz = get_local_size (0);
38
39   /**
40    * bin2asc table
41    */
42
43   __local u32 l_bin2asc[256];
44
45   for (u32 i = lid; i < 256; i += lsz)
46   {
47     const u32 i0 = (i >> 0) & 15;
48     const u32 i1 = (i >> 4) & 15;
49
50     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
51                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
52   }
53
54   barrier (CLK_LOCAL_MEM_FENCE);
55
56   if (gid >= gid_max) return;
57
58   /**
59    * base
60    */
61
62   u32 pw_buf0[4];
63   u32 pw_buf1[4];
64
65   pw_buf0[0] = pws[gid].i[0];
66   pw_buf0[1] = pws[gid].i[1];
67   pw_buf0[2] = pws[gid].i[2];
68   pw_buf0[3] = pws[gid].i[3];
69   pw_buf1[0] = pws[gid].i[4];
70   pw_buf1[1] = pws[gid].i[5];
71   pw_buf1[2] = pws[gid].i[6];
72   pw_buf1[3] = pws[gid].i[7];
73
74   const u32 pw_l_len = pws[gid].pw_len;
75
76   /**
77    * loop
78    */
79
80   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
81   {
82     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
83
84     const u32x pw_len = pw_l_len + pw_r_len;
85
86     /**
87      * concat password candidate
88      */
89
90     u32x wordl0[4] = { 0 };
91     u32x wordl1[4] = { 0 };
92     u32x wordl2[4] = { 0 };
93     u32x wordl3[4] = { 0 };
94
95     wordl0[0] = pw_buf0[0];
96     wordl0[1] = pw_buf0[1];
97     wordl0[2] = pw_buf0[2];
98     wordl0[3] = pw_buf0[3];
99     wordl1[0] = pw_buf1[0];
100     wordl1[1] = pw_buf1[1];
101     wordl1[2] = pw_buf1[2];
102     wordl1[3] = pw_buf1[3];
103
104     u32x wordr0[4] = { 0 };
105     u32x wordr1[4] = { 0 };
106     u32x wordr2[4] = { 0 };
107     u32x wordr3[4] = { 0 };
108
109     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
110     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
111     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
112     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
113     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
114     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
115     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
116     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
117
118     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
119     {
120       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
121     }
122     else
123     {
124       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
125     }
126
127     u32x w0[4];
128     u32x w1[4];
129     u32x w2[4];
130     u32x w3[4];
131
132     w0[0] = wordl0[0] | wordr0[0];
133     w0[1] = wordl0[1] | wordr0[1];
134     w0[2] = wordl0[2] | wordr0[2];
135     w0[3] = wordl0[3] | wordr0[3];
136     w1[0] = wordl1[0] | wordr1[0];
137     w1[1] = wordl1[1] | wordr1[1];
138     w1[2] = wordl1[2] | wordr1[2];
139     w1[3] = wordl1[3] | wordr1[3];
140     w2[0] = wordl2[0] | wordr2[0];
141     w2[1] = wordl2[1] | wordr2[1];
142     w2[2] = wordl2[2] | wordr2[2];
143     w2[3] = wordl2[3] | wordr2[3];
144     w3[0] = wordl3[0] | wordr3[0];
145     w3[1] = wordl3[1] | wordr3[1];
146     w3[2] = wordl3[2] | wordr3[2];
147     w3[3] = wordl3[3] | wordr3[3];
148
149     /**
150      * sha1
151      */
152
153     u32x w0_t = swap32 (w0[0]);
154     u32x w1_t = swap32 (w0[1]);
155     u32x w2_t = swap32 (w0[2]);
156     u32x w3_t = swap32 (w0[3]);
157     u32x w4_t = swap32 (w1[0]);
158     u32x w5_t = swap32 (w1[1]);
159     u32x w6_t = swap32 (w1[2]);
160     u32x w7_t = swap32 (w1[3]);
161     u32x w8_t = swap32 (w2[0]);
162     u32x w9_t = swap32 (w2[1]);
163     u32x wa_t = swap32 (w2[2]);
164     u32x wb_t = swap32 (w2[3]);
165     u32x wc_t = swap32 (w3[0]);
166     u32x wd_t = swap32 (w3[1]);
167     u32x we_t = 0;
168     u32x wf_t = pw_len * 8;
169
170     u32x a = SHA1M_A;
171     u32x b = SHA1M_B;
172     u32x c = SHA1M_C;
173     u32x d = SHA1M_D;
174     u32x e = SHA1M_E;
175
176     #undef K
177     #define K SHA1C00
178
179     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
180     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
181     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
182     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
183     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
184     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
185     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
186     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
187     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
188     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
189     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
190     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
191     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
192     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
193     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
194     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
195     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
196     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
197     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
198     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
199
200     #undef K
201     #define K SHA1C01
202
203     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
204     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
205     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
206     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
207     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
208     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
209     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
210     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
211     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
212     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
213     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
214     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
215     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
216     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
217     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
218     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
219     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
220     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
221     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
222     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
223
224     #undef K
225     #define K SHA1C02
226
227     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
228     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
229     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
230     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
231     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
232     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
233     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
234     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
235     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
236     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
237     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
238     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
239     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
240     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
241     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
242     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
243     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
244     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
245     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
246     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
247
248     #undef K
249     #define K SHA1C03
250
251     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
252     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
253     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
254     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
255     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
256     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
257     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
258     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
259     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
260     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
261     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
262     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
263     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
264     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
265     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
266     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
267     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
268     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
269     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
270     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
271
272     a += SHA1M_A;
273     b += SHA1M_B;
274     c += SHA1M_C;
275     d += SHA1M_D;
276     e += SHA1M_E;
277
278     /**
279      * md5
280      */
281
282     w0_t = uint_to_hex_lower8 ((a >> 24) & 255) <<  0
283          | uint_to_hex_lower8 ((a >> 16) & 255) << 16;
284     w1_t = uint_to_hex_lower8 ((a >>  8) & 255) <<  0
285          | uint_to_hex_lower8 ((a >>  0) & 255) << 16;
286     w2_t = uint_to_hex_lower8 ((b >> 24) & 255) <<  0
287          | uint_to_hex_lower8 ((b >> 16) & 255) << 16;
288     w3_t = uint_to_hex_lower8 ((b >>  8) & 255) <<  0
289          | uint_to_hex_lower8 ((b >>  0) & 255) << 16;
290     w4_t = uint_to_hex_lower8 ((c >> 24) & 255) <<  0
291          | uint_to_hex_lower8 ((c >> 16) & 255) << 16;
292     w5_t = uint_to_hex_lower8 ((c >>  8) & 255) <<  0
293          | uint_to_hex_lower8 ((c >>  0) & 255) << 16;
294     w6_t = uint_to_hex_lower8 ((d >> 24) & 255) <<  0
295          | uint_to_hex_lower8 ((d >> 16) & 255) << 16;
296     w7_t = uint_to_hex_lower8 ((d >>  8) & 255) <<  0
297          | uint_to_hex_lower8 ((d >>  0) & 255) << 16;
298     w8_t = uint_to_hex_lower8 ((e >> 24) & 255) <<  0
299          | uint_to_hex_lower8 ((e >> 16) & 255) << 16;
300     w9_t = uint_to_hex_lower8 ((e >>  8) & 255) <<  0
301          | uint_to_hex_lower8 ((e >>  0) & 255) << 16;
302
303     wa_t = 0x80;
304     wb_t = 0;
305     wc_t = 0;
306     wd_t = 0;
307     we_t = 40 * 8;
308     wf_t = 0;
309
310     a = MD5M_A;
311     b = MD5M_B;
312     c = MD5M_C;
313     d = MD5M_D;
314
315     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
316     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
317     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
318     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
319     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
320     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
321     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
322     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
323     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
324     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
325     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
326     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
327     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
328     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
329     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
330     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
331
332     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
333     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
334     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
335     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
336     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
337     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
338     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
339     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
340     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
341     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
342     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
343     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
344     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
345     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
346     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
347     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
348
349     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
350     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
351     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
352     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
353     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
354     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
355     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
356     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
357     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
358     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
359     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
360     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
361     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
362     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
363     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
364     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
365
366     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
367     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
368     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
369     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
370     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
371     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
372     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
373     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
374     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
375     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
376     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
377     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
378     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
379     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
380     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
381     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
382
383     COMPARE_M_SIMD (a, d, c, b);
384   }
385 }
386
387 __kernel void m04400_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
388 {
389 }
390
391 __kernel void m04400_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
392 {
393 }
394
395 __kernel void m04400_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
396 {
397   /**
398    * modifier
399    */
400
401   const u32 gid = get_global_id (0);
402   const u32 lid = get_local_id (0);
403   const u32 lsz = get_local_size (0);
404
405   /**
406    * bin2asc table
407    */
408
409   __local u32 l_bin2asc[256];
410
411   for (u32 i = lid; i < 256; i += lsz)
412   {
413     const u32 i0 = (i >> 0) & 15;
414     const u32 i1 = (i >> 4) & 15;
415
416     l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
417                  | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
418   }
419
420   barrier (CLK_LOCAL_MEM_FENCE);
421
422   if (gid >= gid_max) return;
423
424   /**
425    * base
426    */
427
428   u32 pw_buf0[4];
429   u32 pw_buf1[4];
430
431   pw_buf0[0] = pws[gid].i[0];
432   pw_buf0[1] = pws[gid].i[1];
433   pw_buf0[2] = pws[gid].i[2];
434   pw_buf0[3] = pws[gid].i[3];
435   pw_buf1[0] = pws[gid].i[4];
436   pw_buf1[1] = pws[gid].i[5];
437   pw_buf1[2] = pws[gid].i[6];
438   pw_buf1[3] = pws[gid].i[7];
439
440   const u32 pw_l_len = pws[gid].pw_len;
441
442   /**
443    * digest
444    */
445
446   const u32 search[4] =
447   {
448     digests_buf[digests_offset].digest_buf[DGST_R0],
449     digests_buf[digests_offset].digest_buf[DGST_R1],
450     digests_buf[digests_offset].digest_buf[DGST_R2],
451     digests_buf[digests_offset].digest_buf[DGST_R3]
452   };
453
454   /**
455    * loop
456    */
457
458   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
459   {
460     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
461
462     const u32x pw_len = pw_l_len + pw_r_len;
463
464     /**
465      * concat password candidate
466      */
467
468     u32x wordl0[4] = { 0 };
469     u32x wordl1[4] = { 0 };
470     u32x wordl2[4] = { 0 };
471     u32x wordl3[4] = { 0 };
472
473     wordl0[0] = pw_buf0[0];
474     wordl0[1] = pw_buf0[1];
475     wordl0[2] = pw_buf0[2];
476     wordl0[3] = pw_buf0[3];
477     wordl1[0] = pw_buf1[0];
478     wordl1[1] = pw_buf1[1];
479     wordl1[2] = pw_buf1[2];
480     wordl1[3] = pw_buf1[3];
481
482     u32x wordr0[4] = { 0 };
483     u32x wordr1[4] = { 0 };
484     u32x wordr2[4] = { 0 };
485     u32x wordr3[4] = { 0 };
486
487     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
488     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
489     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
490     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
491     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
492     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
493     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
494     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
495
496     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
497     {
498       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
499     }
500     else
501     {
502       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
503     }
504
505     u32x w0[4];
506     u32x w1[4];
507     u32x w2[4];
508     u32x w3[4];
509
510     w0[0] = wordl0[0] | wordr0[0];
511     w0[1] = wordl0[1] | wordr0[1];
512     w0[2] = wordl0[2] | wordr0[2];
513     w0[3] = wordl0[3] | wordr0[3];
514     w1[0] = wordl1[0] | wordr1[0];
515     w1[1] = wordl1[1] | wordr1[1];
516     w1[2] = wordl1[2] | wordr1[2];
517     w1[3] = wordl1[3] | wordr1[3];
518     w2[0] = wordl2[0] | wordr2[0];
519     w2[1] = wordl2[1] | wordr2[1];
520     w2[2] = wordl2[2] | wordr2[2];
521     w2[3] = wordl2[3] | wordr2[3];
522     w3[0] = wordl3[0] | wordr3[0];
523     w3[1] = wordl3[1] | wordr3[1];
524     w3[2] = wordl3[2] | wordr3[2];
525     w3[3] = wordl3[3] | wordr3[3];
526
527     /**
528      * sha1
529      */
530
531     u32x w0_t = swap32 (w0[0]);
532     u32x w1_t = swap32 (w0[1]);
533     u32x w2_t = swap32 (w0[2]);
534     u32x w3_t = swap32 (w0[3]);
535     u32x w4_t = swap32 (w1[0]);
536     u32x w5_t = swap32 (w1[1]);
537     u32x w6_t = swap32 (w1[2]);
538     u32x w7_t = swap32 (w1[3]);
539     u32x w8_t = swap32 (w2[0]);
540     u32x w9_t = swap32 (w2[1]);
541     u32x wa_t = swap32 (w2[2]);
542     u32x wb_t = swap32 (w2[3]);
543     u32x wc_t = swap32 (w3[0]);
544     u32x wd_t = swap32 (w3[1]);
545     u32x we_t = 0;
546     u32x wf_t = pw_len * 8;
547
548     u32x a = SHA1M_A;
549     u32x b = SHA1M_B;
550     u32x c = SHA1M_C;
551     u32x d = SHA1M_D;
552     u32x e = SHA1M_E;
553
554     #undef K
555     #define K SHA1C00
556
557     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
558     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
559     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
560     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
561     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
562     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
563     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
564     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
565     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
566     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
567     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
568     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
569     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
570     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
571     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
572     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
573     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
574     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
575     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
576     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
577
578     #undef K
579     #define K SHA1C01
580
581     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
582     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
583     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
584     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
585     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
586     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
587     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
588     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
589     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
590     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
591     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
592     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
593     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
594     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
595     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
596     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
597     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
598     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
599     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
600     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
601
602     #undef K
603     #define K SHA1C02
604
605     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
606     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
607     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
608     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
609     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
610     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
611     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
612     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
613     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
614     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
615     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
616     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
617     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
618     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
619     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
620     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
621     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
622     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
623     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
624     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
625
626     #undef K
627     #define K SHA1C03
628
629     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
630     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
631     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
632     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
633     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
634     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
635     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
636     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
637     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
638     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
639     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
640     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
641     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
642     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
643     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
644     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
645     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
646     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
647     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
648     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
649
650     a += SHA1M_A;
651     b += SHA1M_B;
652     c += SHA1M_C;
653     d += SHA1M_D;
654     e += SHA1M_E;
655
656     /**
657      * md5
658      */
659
660     w0_t = uint_to_hex_lower8 ((a >> 24) & 255) <<  0
661          | uint_to_hex_lower8 ((a >> 16) & 255) << 16;
662     w1_t = uint_to_hex_lower8 ((a >>  8) & 255) <<  0
663          | uint_to_hex_lower8 ((a >>  0) & 255) << 16;
664     w2_t = uint_to_hex_lower8 ((b >> 24) & 255) <<  0
665          | uint_to_hex_lower8 ((b >> 16) & 255) << 16;
666     w3_t = uint_to_hex_lower8 ((b >>  8) & 255) <<  0
667          | uint_to_hex_lower8 ((b >>  0) & 255) << 16;
668     w4_t = uint_to_hex_lower8 ((c >> 24) & 255) <<  0
669          | uint_to_hex_lower8 ((c >> 16) & 255) << 16;
670     w5_t = uint_to_hex_lower8 ((c >>  8) & 255) <<  0
671          | uint_to_hex_lower8 ((c >>  0) & 255) << 16;
672     w6_t = uint_to_hex_lower8 ((d >> 24) & 255) <<  0
673          | uint_to_hex_lower8 ((d >> 16) & 255) << 16;
674     w7_t = uint_to_hex_lower8 ((d >>  8) & 255) <<  0
675          | uint_to_hex_lower8 ((d >>  0) & 255) << 16;
676     w8_t = uint_to_hex_lower8 ((e >> 24) & 255) <<  0
677          | uint_to_hex_lower8 ((e >> 16) & 255) << 16;
678     w9_t = uint_to_hex_lower8 ((e >>  8) & 255) <<  0
679          | uint_to_hex_lower8 ((e >>  0) & 255) << 16;
680
681     wa_t = 0x80;
682     wb_t = 0;
683     wc_t = 0;
684     wd_t = 0;
685     we_t = 40 * 8;
686     wf_t = 0;
687
688     a = MD5M_A;
689     b = MD5M_B;
690     c = MD5M_C;
691     d = MD5M_D;
692
693     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
694     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
695     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
696     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
697     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
698     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
699     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
700     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
701     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
702     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
703     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
704     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
705     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
706     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
707     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
708     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
709
710     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
711     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
712     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
713     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
714     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
715     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
716     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
717     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
718     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
719     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
720     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
721     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
722     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
723     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
724     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
725     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
726
727     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
728     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
729     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
730     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
731     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
732     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
733     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
734     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
735     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
736     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
737     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
738     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
739     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
740     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
741     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
742     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
743
744     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
745     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
746     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
747     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
748     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
749     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
750     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
751     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
752     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
753     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
754     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
755     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
756     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
757
758     if (MATCHES_NONE_VS (a, search[0])) continue;
759
760     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
761     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
762     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
763
764     COMPARE_S_SIMD (a, d, c, b);
765   }
766 }
767
768 __kernel void m04400_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
769 {
770 }
771
772 __kernel void m04400_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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
773 {
774 }