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