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