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