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