Add mangle to mode 100 attack 1
[hashcat.git] / OpenCL / m00100_a1_m.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _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 #include "mangle.cl"
17
18 __kernel void m00100_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)
19 {
20   /**
21    * modifier
22    */
23
24   const u32 lid = get_local_id (0);
25
26   /**
27    * base
28    */
29
30   const u32 gid = get_global_id (0);
31
32   if (gid >= gid_max) return;
33
34   u32 pw_buf0[4];
35   u32 pw_buf1[4];
36
37   pw_buf0[0] = pws[gid].i[0];
38   pw_buf0[1] = pws[gid].i[1];
39   pw_buf0[2] = pws[gid].i[2];
40   pw_buf0[3] = pws[gid].i[3];
41   pw_buf1[0] = pws[gid].i[4];
42   pw_buf1[1] = pws[gid].i[5];
43   pw_buf1[2] = pws[gid].i[6];
44   pw_buf1[3] = pws[gid].i[7];
45
46   const u32 pw_l_len = pws[gid].pw_len;
47
48   /**
49    * loop
50    */
51
52   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
53   {
54     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
55
56     u32x pw_len = pw_l_len + pw_r_len;
57
58     /**
59      * concat password candidate
60      */
61
62     u32x wordl0[4] = { 0 };
63     u32x wordl1[4] = { 0 };
64     u32x wordl2[4] = { 0 };
65     u32x wordl3[4] = { 0 };
66
67     wordl0[0] = pw_buf0[0];
68     wordl0[1] = pw_buf0[1];
69     wordl0[2] = pw_buf0[2];
70     wordl0[3] = pw_buf0[3];
71     wordl1[0] = pw_buf1[0];
72     wordl1[1] = pw_buf1[1];
73     wordl1[2] = pw_buf1[2];
74     wordl1[3] = pw_buf1[3];
75
76     u32x wordr0[4] = { 0 };
77     u32x wordr1[4] = { 0 };
78     u32x wordr2[4] = { 0 };
79     u32x wordr3[4] = { 0 };
80
81     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
82     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
83     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
84     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
85     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
86     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
87     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
88     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
89
90     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
91     {
92       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
93     }
94     else
95     {
96       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
97     }
98
99     u32x w0[4];
100     u32x w1[4];
101     u32x w2[4];
102     u32x w3[4];
103
104     w0[0] = wordl0[0] | wordr0[0];
105     w0[1] = wordl0[1] | wordr0[1];
106     w0[2] = wordl0[2] | wordr0[2];
107     w0[3] = wordl0[3] | wordr0[3];
108     w1[0] = wordl1[0] | wordr1[0];
109     w1[1] = wordl1[1] | wordr1[1];
110     w1[2] = wordl1[2] | wordr1[2];
111     w1[3] = wordl1[3] | wordr1[3];
112
113     pw_len = mangle(w0, w1, pw_len);
114     append_0x80_2x4_VV (w0, w1, pw_len);
115
116     w2[0] = 0;
117     w2[1] = 0;
118     w2[2] = 0;
119     w2[3] = 0;
120     w3[0] = 0;
121     w3[1] = 0;
122     w3[2] = 0;
123     w3[3] = 0;
124
125     //w2[0] = wordl2[0] | wordr2[0];
126     //w2[1] = wordl2[1] | wordr2[1];
127     //w2[2] = wordl2[2] | wordr2[2];
128     //w2[3] = wordl2[3] | wordr2[3];
129     //w3[0] = wordl3[0] | wordr3[0];
130     //w3[1] = wordl3[1] | wordr3[1];
131     //w3[2] = wordl3[2] | wordr3[2];
132     //w3[3] = wordl3[3] | wordr3[3];
133
134     /**
135      * sha1
136      */
137
138     u32x w0_t = swap32 (w0[0]);
139     u32x w1_t = swap32 (w0[1]);
140     u32x w2_t = swap32 (w0[2]);
141     u32x w3_t = swap32 (w0[3]);
142     u32x w4_t = swap32 (w1[0]);
143     u32x w5_t = swap32 (w1[1]);
144     u32x w6_t = swap32 (w1[2]);
145     u32x w7_t = swap32 (w1[3]);
146     u32x w8_t = swap32 (w2[0]);
147     u32x w9_t = swap32 (w2[1]);
148     u32x wa_t = swap32 (w2[2]);
149     u32x wb_t = swap32 (w2[3]);
150     u32x wc_t = swap32 (w3[0]);
151     u32x wd_t = swap32 (w3[1]);
152     u32x we_t = 0;
153     u32x wf_t = pw_len * 8;
154
155     u32x a = SHA1M_A;
156     u32x b = SHA1M_B;
157     u32x c = SHA1M_C;
158     u32x d = SHA1M_D;
159     u32x e = SHA1M_E;
160
161     #undef K
162     #define K SHA1C00
163
164     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
165     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
166     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
167     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
168     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
169     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
170     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
171     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
172     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
173     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
174     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
175     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
176     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
177     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
178     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
179     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
180     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
181     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
182     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
183     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
184
185     #undef K
186     #define K SHA1C01
187
188     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
189     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
190     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
191     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
192     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
193     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
194     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
195     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
196     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
197     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
198     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
199     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
200     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
201     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
202     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
203     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
204     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
205     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
206     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
207     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
208
209     #undef K
210     #define K SHA1C02
211
212     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
213     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
214     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
215     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
216     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
217     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
218     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
219     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
220     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
221     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
222     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
223     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
224     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
225     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
226     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
227     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
228     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
229     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
230     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
231     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
232
233     #undef K
234     #define K SHA1C03
235
236     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
237     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
238     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
239     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
240     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
241     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
242     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
243     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
244     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
245     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
246     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
247     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
248     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
249     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
250     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
251     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
252     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
253     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
254     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
255     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
256
257     COMPARE_M_SIMD (d, e, c, b);
258   }
259 }
260
261 __kernel void m00100_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)
262 {
263 }
264
265 __kernel void m00100_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)
266 {
267 }
268
269 __kernel void m00100_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)
270 {
271   /**
272    * modifier
273    */
274
275   const u32 lid = get_local_id (0);
276
277   /**
278    * base
279    */
280
281   const u32 gid = get_global_id (0);
282
283   if (gid >= gid_max) return;
284
285   u32 pw_buf0[4];
286   u32 pw_buf1[4];
287
288   pw_buf0[0] = pws[gid].i[0];
289   pw_buf0[1] = pws[gid].i[1];
290   pw_buf0[2] = pws[gid].i[2];
291   pw_buf0[3] = pws[gid].i[3];
292   pw_buf1[0] = pws[gid].i[4];
293   pw_buf1[1] = pws[gid].i[5];
294   pw_buf1[2] = pws[gid].i[6];
295   pw_buf1[3] = pws[gid].i[7];
296
297   const u32 pw_l_len = pws[gid].pw_len;
298
299   /**
300    * digest
301    */
302
303   const u32 search[4] =
304   {
305     digests_buf[digests_offset].digest_buf[DGST_R0],
306     digests_buf[digests_offset].digest_buf[DGST_R1],
307     digests_buf[digests_offset].digest_buf[DGST_R2],
308     digests_buf[digests_offset].digest_buf[DGST_R3]
309   };
310
311   /**
312    * reverse
313    */
314
315   const u32 e_rev = rotl32_S (search[1], 2u);
316
317   /**
318    * loop
319    */
320
321   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
322   {
323     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
324
325     u32x pw_len = pw_l_len + pw_r_len;
326
327     /**
328      * concat password candidate
329      */
330
331     u32x wordl0[4] = { 0 };
332     u32x wordl1[4] = { 0 };
333     u32x wordl2[4] = { 0 };
334     u32x wordl3[4] = { 0 };
335
336     wordl0[0] = pw_buf0[0];
337     wordl0[1] = pw_buf0[1];
338     wordl0[2] = pw_buf0[2];
339     wordl0[3] = pw_buf0[3];
340     wordl1[0] = pw_buf1[0];
341     wordl1[1] = pw_buf1[1];
342     wordl1[2] = pw_buf1[2];
343     wordl1[3] = pw_buf1[3];
344
345     u32x wordr0[4] = { 0 };
346     u32x wordr1[4] = { 0 };
347     u32x wordr2[4] = { 0 };
348     u32x wordr3[4] = { 0 };
349
350     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
351     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
352     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
353     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
354     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
355     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
356     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
357     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
358
359     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
360     {
361       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
362     }
363     else
364     {
365       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
366     }
367
368     u32x w0[4];
369     u32x w1[4];
370     u32x w2[4];
371     u32x w3[4];
372
373     w0[0] = wordl0[0] | wordr0[0];
374     w0[1] = wordl0[1] | wordr0[1];
375     w0[2] = wordl0[2] | wordr0[2];
376     w0[3] = wordl0[3] | wordr0[3];
377     w1[0] = wordl1[0] | wordr1[0];
378     w1[1] = wordl1[1] | wordr1[1];
379     w1[2] = wordl1[2] | wordr1[2];
380     w1[3] = wordl1[3] | wordr1[3];
381
382     pw_len = mangle(w0, w1, pw_len);
383     append_0x80_2x4_VV (w0, w1, pw_len);
384
385     w2[0] = 0;
386     w2[1] = 0;
387     w2[2] = 0;
388     w2[3] = 0;
389     w3[0] = 0;
390     w3[1] = 0;
391     w3[2] = 0;
392     w3[3] = 0;
393
394     //w2[0] = wordl2[0] | wordr2[0];
395     //w2[1] = wordl2[1] | wordr2[1];
396     //w2[2] = wordl2[2] | wordr2[2];
397     //w2[3] = wordl2[3] | wordr2[3];
398     //w3[0] = wordl3[0] | wordr3[0];
399     //w3[1] = wordl3[1] | wordr3[1];
400     //w3[2] = wordl3[2] | wordr3[2];
401     //w3[3] = wordl3[3] | wordr3[3];
402
403     /**
404      * sha1
405      */
406
407     u32x w0_t = swap32 (w0[0]);
408     u32x w1_t = swap32 (w0[1]);
409     u32x w2_t = swap32 (w0[2]);
410     u32x w3_t = swap32 (w0[3]);
411     u32x w4_t = swap32 (w1[0]);
412     u32x w5_t = swap32 (w1[1]);
413     u32x w6_t = swap32 (w1[2]);
414     u32x w7_t = swap32 (w1[3]);
415     u32x w8_t = swap32 (w2[0]);
416     u32x w9_t = swap32 (w2[1]);
417     u32x wa_t = swap32 (w2[2]);
418     u32x wb_t = swap32 (w2[3]);
419     u32x wc_t = swap32 (w3[0]);
420     u32x wd_t = swap32 (w3[1]);
421     u32x we_t = 0;
422     u32x wf_t = pw_len * 8;
423
424     u32x a = SHA1M_A;
425     u32x b = SHA1M_B;
426     u32x c = SHA1M_C;
427     u32x d = SHA1M_D;
428     u32x e = SHA1M_E;
429
430     #undef K
431     #define K SHA1C00
432
433     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
434     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
435     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
436     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
437     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
438     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
439     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
440     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
441     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
442     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
443     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
444     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
445     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
446     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
447     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
448     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
449     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
450     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
451     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
452     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
453
454     #undef K
455     #define K SHA1C01
456
457     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
458     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
459     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
460     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
461     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
462     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
463     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
464     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
465     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
466     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
467     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
468     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
469     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
470     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
471     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
472     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
473     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
474     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
475     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
476     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
477
478     #undef K
479     #define K SHA1C02
480
481     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
482     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
483     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
484     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
485     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
486     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
487     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
488     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
489     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
490     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
491     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
492     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
493     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
494     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
495     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
496     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
497     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
498     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
499     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
500     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
501
502     #undef K
503     #define K SHA1C03
504
505     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
506     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
507     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
508     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
509     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
510     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
511     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
512     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
513     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
514     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
515     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
516     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
517     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
518     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
519     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
520     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
521
522     if (MATCHES_NONE_VS (e, e_rev)) continue;
523
524     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
525     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
526     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
527     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
528
529     COMPARE_S_SIMD (d, e, c, b);
530   }
531 }
532
533 __kernel void m00100_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)
534 {
535 }
536
537 __kernel void m00100_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)
538 {
539 }