Converted _a3 kernels, use SIMD for CPU and GPU
[hashcat.git] / OpenCL / m01450_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _SHA256_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #define DGST_R0 3
12 #define DGST_R1 7
13 #define DGST_R2 2
14 #define DGST_R3 6
15
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/check_multi_comp4.c"
22
23 __constant u32 k_sha256[64] =
24 {
25   SHA256C00, SHA256C01, SHA256C02, SHA256C03,
26   SHA256C04, SHA256C05, SHA256C06, SHA256C07,
27   SHA256C08, SHA256C09, SHA256C0a, SHA256C0b,
28   SHA256C0c, SHA256C0d, SHA256C0e, SHA256C0f,
29   SHA256C10, SHA256C11, SHA256C12, SHA256C13,
30   SHA256C14, SHA256C15, SHA256C16, SHA256C17,
31   SHA256C18, SHA256C19, SHA256C1a, SHA256C1b,
32   SHA256C1c, SHA256C1d, SHA256C1e, SHA256C1f,
33   SHA256C20, SHA256C21, SHA256C22, SHA256C23,
34   SHA256C24, SHA256C25, SHA256C26, SHA256C27,
35   SHA256C28, SHA256C29, SHA256C2a, SHA256C2b,
36   SHA256C2c, SHA256C2d, SHA256C2e, SHA256C2f,
37   SHA256C30, SHA256C31, SHA256C32, SHA256C33,
38   SHA256C34, SHA256C35, SHA256C36, SHA256C37,
39   SHA256C38, SHA256C39, SHA256C3a, SHA256C3b,
40   SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f,
41 };
42
43 static void sha256_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[8])
44 {
45   u32 a = digest[0];
46   u32 b = digest[1];
47   u32 c = digest[2];
48   u32 d = digest[3];
49   u32 e = digest[4];
50   u32 f = digest[5];
51   u32 g = digest[6];
52   u32 h = digest[7];
53
54   u32 w0_t = w0[0];
55   u32 w1_t = w0[1];
56   u32 w2_t = w0[2];
57   u32 w3_t = w0[3];
58   u32 w4_t = w1[0];
59   u32 w5_t = w1[1];
60   u32 w6_t = w1[2];
61   u32 w7_t = w1[3];
62   u32 w8_t = w2[0];
63   u32 w9_t = w2[1];
64   u32 wa_t = w2[2];
65   u32 wb_t = w2[3];
66   u32 wc_t = w3[0];
67   u32 wd_t = w3[1];
68   u32 we_t = w3[2];
69   u32 wf_t = w3[3];
70
71   #define ROUND_EXPAND()                            \
72   {                                                 \
73     w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t);  \
74     w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t);  \
75     w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t);  \
76     w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t);  \
77     w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t);  \
78     w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t);  \
79     w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t);  \
80     w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t);  \
81     w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t);  \
82     w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t);  \
83     wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t);  \
84     wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t);  \
85     wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t);  \
86     wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t);  \
87     we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t);  \
88     wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t);  \
89   }
90
91   #define ROUND_STEP(i)                                                                   \
92   {                                                                                       \
93     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha256[i +  0]); \
94     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha256[i +  1]); \
95     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha256[i +  2]); \
96     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha256[i +  3]); \
97     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha256[i +  4]); \
98     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha256[i +  5]); \
99     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha256[i +  6]); \
100     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha256[i +  7]); \
101     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha256[i +  8]); \
102     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha256[i +  9]); \
103     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha256[i + 10]); \
104     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha256[i + 11]); \
105     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha256[i + 12]); \
106     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha256[i + 13]); \
107     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, k_sha256[i + 14]); \
108     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha256[i + 15]); \
109   }
110
111   ROUND_STEP (0);
112
113   #pragma unroll
114   for (int i = 16; i < 64; i += 16)
115   {
116     ROUND_EXPAND (); ROUND_STEP (i);
117   }
118
119   digest[0] += a;
120   digest[1] += b;
121   digest[2] += c;
122   digest[3] += d;
123   digest[4] += e;
124   digest[5] += f;
125   digest[6] += g;
126   digest[7] += h;
127 }
128
129 static void hmac_sha256_pad (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[8], u32 opad[8])
130 {
131   w0[0] = w0[0] ^ 0x36363636;
132   w0[1] = w0[1] ^ 0x36363636;
133   w0[2] = w0[2] ^ 0x36363636;
134   w0[3] = w0[3] ^ 0x36363636;
135   w1[0] = w1[0] ^ 0x36363636;
136   w1[1] = w1[1] ^ 0x36363636;
137   w1[2] = w1[2] ^ 0x36363636;
138   w1[3] = w1[3] ^ 0x36363636;
139   w2[0] = w2[0] ^ 0x36363636;
140   w2[1] = w2[1] ^ 0x36363636;
141   w2[2] = w2[2] ^ 0x36363636;
142   w2[3] = w2[3] ^ 0x36363636;
143   w3[0] = w3[0] ^ 0x36363636;
144   w3[1] = w3[1] ^ 0x36363636;
145   w3[2] = w3[2] ^ 0x36363636;
146   w3[3] = w3[3] ^ 0x36363636;
147
148   ipad[0] = SHA256M_A;
149   ipad[1] = SHA256M_B;
150   ipad[2] = SHA256M_C;
151   ipad[3] = SHA256M_D;
152   ipad[4] = SHA256M_E;
153   ipad[5] = SHA256M_F;
154   ipad[6] = SHA256M_G;
155   ipad[7] = SHA256M_H;
156
157   sha256_transform (w0, w1, w2, w3, ipad);
158
159   w0[0] = w0[0] ^ 0x6a6a6a6a;
160   w0[1] = w0[1] ^ 0x6a6a6a6a;
161   w0[2] = w0[2] ^ 0x6a6a6a6a;
162   w0[3] = w0[3] ^ 0x6a6a6a6a;
163   w1[0] = w1[0] ^ 0x6a6a6a6a;
164   w1[1] = w1[1] ^ 0x6a6a6a6a;
165   w1[2] = w1[2] ^ 0x6a6a6a6a;
166   w1[3] = w1[3] ^ 0x6a6a6a6a;
167   w2[0] = w2[0] ^ 0x6a6a6a6a;
168   w2[1] = w2[1] ^ 0x6a6a6a6a;
169   w2[2] = w2[2] ^ 0x6a6a6a6a;
170   w2[3] = w2[3] ^ 0x6a6a6a6a;
171   w3[0] = w3[0] ^ 0x6a6a6a6a;
172   w3[1] = w3[1] ^ 0x6a6a6a6a;
173   w3[2] = w3[2] ^ 0x6a6a6a6a;
174   w3[3] = w3[3] ^ 0x6a6a6a6a;
175
176   opad[0] = SHA256M_A;
177   opad[1] = SHA256M_B;
178   opad[2] = SHA256M_C;
179   opad[3] = SHA256M_D;
180   opad[4] = SHA256M_E;
181   opad[5] = SHA256M_F;
182   opad[6] = SHA256M_G;
183   opad[7] = SHA256M_H;
184
185   sha256_transform (w0, w1, w2, w3, opad);
186 }
187
188 static void hmac_sha256_run (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[8], u32 opad[8], u32 digest[8])
189 {
190   digest[0] = ipad[0];
191   digest[1] = ipad[1];
192   digest[2] = ipad[2];
193   digest[3] = ipad[3];
194   digest[4] = ipad[4];
195   digest[5] = ipad[5];
196   digest[6] = ipad[6];
197   digest[7] = ipad[7];
198
199   sha256_transform (w0, w1, w2, w3, digest);
200
201   w0[0] = digest[0];
202   w0[1] = digest[1];
203   w0[2] = digest[2];
204   w0[3] = digest[3];
205   w1[0] = digest[4];
206   w1[1] = digest[5];
207   w1[2] = digest[6];
208   w1[3] = digest[7];
209   w2[0] = 0x80000000;
210   w2[1] = 0;
211   w2[2] = 0;
212   w2[3] = 0;
213   w3[0] = 0;
214   w3[1] = 0;
215   w3[2] = 0;
216   w3[3] = (64 + 32) * 8;
217
218   digest[0] = opad[0];
219   digest[1] = opad[1];
220   digest[2] = opad[2];
221   digest[3] = opad[3];
222   digest[4] = opad[4];
223   digest[5] = opad[5];
224   digest[6] = opad[6];
225   digest[7] = opad[7];
226
227   sha256_transform (w0, w1, w2, w3, digest);
228 }
229
230 __kernel void m01450_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
231 {
232   /**
233    * modifier
234    */
235
236   const u32 lid = get_local_id (0);
237
238   /**
239    * base
240    */
241
242   const u32 gid = get_global_id (0);
243
244   if (gid >= gid_max) return;
245
246   u32 wordl0[4];
247
248   wordl0[0] = pws[gid].i[ 0];
249   wordl0[1] = pws[gid].i[ 1];
250   wordl0[2] = pws[gid].i[ 2];
251   wordl0[3] = pws[gid].i[ 3];
252
253   u32 wordl1[4];
254
255   wordl1[0] = pws[gid].i[ 4];
256   wordl1[1] = pws[gid].i[ 5];
257   wordl1[2] = pws[gid].i[ 6];
258   wordl1[3] = pws[gid].i[ 7];
259
260   u32 wordl2[4];
261
262   wordl2[0] = 0;
263   wordl2[1] = 0;
264   wordl2[2] = 0;
265   wordl2[3] = 0;
266
267   u32 wordl3[4];
268
269   wordl3[0] = 0;
270   wordl3[1] = 0;
271   wordl3[2] = 0;
272   wordl3[3] = 0;
273
274   const u32 pw_l_len = pws[gid].pw_len;
275
276   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
277   {
278     switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
279   }
280
281   /**
282    * salt
283    */
284
285   u32 salt_buf0[4];
286
287   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
288   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
289   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
290   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
291
292   u32 salt_buf1[4];
293
294   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
295   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
296   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
297   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
298
299   const u32 salt_len = salt_bufs[salt_pos].salt_len;
300
301   /**
302    * loop
303    */
304
305   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
306   {
307     const u32 pw_r_len = combs_buf[il_pos].pw_len;
308
309     const u32 pw_len = pw_l_len + pw_r_len;
310
311     u32 wordr0[4];
312
313     wordr0[0] = combs_buf[il_pos].i[0];
314     wordr0[1] = combs_buf[il_pos].i[1];
315     wordr0[2] = combs_buf[il_pos].i[2];
316     wordr0[3] = combs_buf[il_pos].i[3];
317
318     u32 wordr1[4];
319
320     wordr1[0] = combs_buf[il_pos].i[4];
321     wordr1[1] = combs_buf[il_pos].i[5];
322     wordr1[2] = combs_buf[il_pos].i[6];
323     wordr1[3] = combs_buf[il_pos].i[7];
324
325     u32 wordr2[4];
326
327     wordr2[0] = 0;
328     wordr2[1] = 0;
329     wordr2[2] = 0;
330     wordr2[3] = 0;
331
332     u32 wordr3[4];
333
334     wordr3[0] = 0;
335     wordr3[1] = 0;
336     wordr3[2] = 0;
337     wordr3[3] = 0;
338
339     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
340     {
341       switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
342     }
343
344     u32 w0[4];
345
346     w0[0] = wordl0[0] | wordr0[0];
347     w0[1] = wordl0[1] | wordr0[1];
348     w0[2] = wordl0[2] | wordr0[2];
349     w0[3] = wordl0[3] | wordr0[3];
350
351     u32 w1[4];
352
353     w1[0] = wordl1[0] | wordr1[0];
354     w1[1] = wordl1[1] | wordr1[1];
355     w1[2] = wordl1[2] | wordr1[2];
356     w1[3] = wordl1[3] | wordr1[3];
357
358     u32 w2[4];
359
360     w2[0] = wordl2[0] | wordr2[0];
361     w2[1] = wordl2[1] | wordr2[1];
362     w2[2] = wordl2[2] | wordr2[2];
363     w2[3] = wordl2[3] | wordr2[3];
364
365     u32 w3[4];
366
367     w3[0] = wordl3[0] | wordr3[0];
368     w3[1] = wordl3[1] | wordr3[1];
369     w3[2] = wordl3[2] | wordr3[2];
370     w3[3] = wordl3[3] | wordr3[3];
371
372     /**
373      * pads
374      */
375
376     u32 w0_t[4];
377
378     w0_t[0] = swap32 (w0[0]);
379     w0_t[1] = swap32 (w0[1]);
380     w0_t[2] = swap32 (w0[2]);
381     w0_t[3] = swap32 (w0[3]);
382
383     u32 w1_t[4];
384
385     w1_t[0] = swap32 (w1[0]);
386     w1_t[1] = swap32 (w1[1]);
387     w1_t[2] = swap32 (w1[2]);
388     w1_t[3] = swap32 (w1[3]);
389
390     u32 w2_t[4];
391
392     w2_t[0] = 0;
393     w2_t[1] = 0;
394     w2_t[2] = 0;
395     w2_t[3] = 0;
396
397     u32 w3_t[4];
398
399     w3_t[0] = 0;
400     w3_t[1] = 0;
401     w3_t[2] = 0;
402     w3_t[3] = 0;
403
404     u32 ipad[8];
405     u32 opad[8];
406
407     hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
408
409     w0_t[0] = swap32 (salt_buf0[0]);
410     w0_t[1] = swap32 (salt_buf0[1]);
411     w0_t[2] = swap32 (salt_buf0[2]);
412     w0_t[3] = swap32 (salt_buf0[3]);
413     w1_t[0] = swap32 (salt_buf1[0]);
414     w1_t[1] = swap32 (salt_buf1[1]);
415     w1_t[2] = swap32 (salt_buf1[2]);
416     w1_t[3] = swap32 (salt_buf1[3]);
417     w2_t[0] = 0;
418     w2_t[1] = 0;
419     w2_t[2] = 0;
420     w2_t[3] = 0;
421     w3_t[0] = 0;
422     w3_t[1] = 0;
423     w3_t[2] = 0;
424     w3_t[3] = (64 + salt_len) * 8;
425
426     u32 digest[8];
427
428     hmac_sha256_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
429
430     const u32 r0 = digest[3];
431     const u32 r1 = digest[7];
432     const u32 r2 = digest[2];
433     const u32 r3 = digest[6];
434
435     #include COMPARE_M
436   }
437 }
438
439 __kernel void m01450_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
440 {
441 }
442
443 __kernel void m01450_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
444 {
445 }
446
447 __kernel void m01450_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
448 {
449   /**
450    * modifier
451    */
452
453   const u32 lid = get_local_id (0);
454
455   /**
456    * base
457    */
458
459   const u32 gid = get_global_id (0);
460
461   if (gid >= gid_max) return;
462
463   u32 wordl0[4];
464
465   wordl0[0] = pws[gid].i[ 0];
466   wordl0[1] = pws[gid].i[ 1];
467   wordl0[2] = pws[gid].i[ 2];
468   wordl0[3] = pws[gid].i[ 3];
469
470   u32 wordl1[4];
471
472   wordl1[0] = pws[gid].i[ 4];
473   wordl1[1] = pws[gid].i[ 5];
474   wordl1[2] = pws[gid].i[ 6];
475   wordl1[3] = pws[gid].i[ 7];
476
477   u32 wordl2[4];
478
479   wordl2[0] = 0;
480   wordl2[1] = 0;
481   wordl2[2] = 0;
482   wordl2[3] = 0;
483
484   u32 wordl3[4];
485
486   wordl3[0] = 0;
487   wordl3[1] = 0;
488   wordl3[2] = 0;
489   wordl3[3] = 0;
490
491   const u32 pw_l_len = pws[gid].pw_len;
492
493   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
494   {
495     switch_buffer_by_offset_le (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
496   }
497
498   /**
499    * salt
500    */
501
502   u32 salt_buf0[4];
503
504   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
505   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
506   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
507   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
508
509   u32 salt_buf1[4];
510
511   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
512   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
513   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
514   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
515
516   const u32 salt_len = salt_bufs[salt_pos].salt_len;
517
518   /**
519    * digest
520    */
521
522   const u32 search[4] =
523   {
524     digests_buf[digests_offset].digest_buf[DGST_R0],
525     digests_buf[digests_offset].digest_buf[DGST_R1],
526     digests_buf[digests_offset].digest_buf[DGST_R2],
527     digests_buf[digests_offset].digest_buf[DGST_R3]
528   };
529
530   /**
531    * loop
532    */
533
534   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
535   {
536     const u32 pw_r_len = combs_buf[il_pos].pw_len;
537
538     const u32 pw_len = pw_l_len + pw_r_len;
539
540     u32 wordr0[4];
541
542     wordr0[0] = combs_buf[il_pos].i[0];
543     wordr0[1] = combs_buf[il_pos].i[1];
544     wordr0[2] = combs_buf[il_pos].i[2];
545     wordr0[3] = combs_buf[il_pos].i[3];
546
547     u32 wordr1[4];
548
549     wordr1[0] = combs_buf[il_pos].i[4];
550     wordr1[1] = combs_buf[il_pos].i[5];
551     wordr1[2] = combs_buf[il_pos].i[6];
552     wordr1[3] = combs_buf[il_pos].i[7];
553
554     u32 wordr2[4];
555
556     wordr2[0] = 0;
557     wordr2[1] = 0;
558     wordr2[2] = 0;
559     wordr2[3] = 0;
560
561     u32 wordr3[4];
562
563     wordr3[0] = 0;
564     wordr3[1] = 0;
565     wordr3[2] = 0;
566     wordr3[3] = 0;
567
568     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
569     {
570       switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
571     }
572
573     u32 w0[4];
574
575     w0[0] = wordl0[0] | wordr0[0];
576     w0[1] = wordl0[1] | wordr0[1];
577     w0[2] = wordl0[2] | wordr0[2];
578     w0[3] = wordl0[3] | wordr0[3];
579
580     u32 w1[4];
581
582     w1[0] = wordl1[0] | wordr1[0];
583     w1[1] = wordl1[1] | wordr1[1];
584     w1[2] = wordl1[2] | wordr1[2];
585     w1[3] = wordl1[3] | wordr1[3];
586
587     u32 w2[4];
588
589     w2[0] = wordl2[0] | wordr2[0];
590     w2[1] = wordl2[1] | wordr2[1];
591     w2[2] = wordl2[2] | wordr2[2];
592     w2[3] = wordl2[3] | wordr2[3];
593
594     u32 w3[4];
595
596     w3[0] = wordl3[0] | wordr3[0];
597     w3[1] = wordl3[1] | wordr3[1];
598     w3[2] = wordl3[2] | wordr3[2];
599     w3[3] = wordl3[3] | wordr3[3];
600
601     /**
602      * pads
603      */
604
605     u32 w0_t[4];
606
607     w0_t[0] = swap32 (w0[0]);
608     w0_t[1] = swap32 (w0[1]);
609     w0_t[2] = swap32 (w0[2]);
610     w0_t[3] = swap32 (w0[3]);
611
612     u32 w1_t[4];
613
614     w1_t[0] = swap32 (w1[0]);
615     w1_t[1] = swap32 (w1[1]);
616     w1_t[2] = swap32 (w1[2]);
617     w1_t[3] = swap32 (w1[3]);
618
619     u32 w2_t[4];
620
621     w2_t[0] = 0;
622     w2_t[1] = 0;
623     w2_t[2] = 0;
624     w2_t[3] = 0;
625
626     u32 w3_t[4];
627
628     w3_t[0] = 0;
629     w3_t[1] = 0;
630     w3_t[2] = 0;
631     w3_t[3] = 0;
632
633     u32 ipad[8];
634     u32 opad[8];
635
636     hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
637
638     w0_t[0] = swap32 (salt_buf0[0]);
639     w0_t[1] = swap32 (salt_buf0[1]);
640     w0_t[2] = swap32 (salt_buf0[2]);
641     w0_t[3] = swap32 (salt_buf0[3]);
642     w1_t[0] = swap32 (salt_buf1[0]);
643     w1_t[1] = swap32 (salt_buf1[1]);
644     w1_t[2] = swap32 (salt_buf1[2]);
645     w1_t[3] = swap32 (salt_buf1[3]);
646     w2_t[0] = 0;
647     w2_t[1] = 0;
648     w2_t[2] = 0;
649     w2_t[3] = 0;
650     w3_t[0] = 0;
651     w3_t[1] = 0;
652     w3_t[2] = 0;
653     w3_t[3] = (64 + salt_len) * 8;
654
655     u32 digest[8];
656
657     hmac_sha256_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
658
659     const u32 r0 = digest[3];
660     const u32 r1 = digest[7];
661     const u32 r2 = digest[2];
662     const u32 r3 = digest[6];
663
664     #include COMPARE_S
665   }
666 }
667
668 __kernel void m01450_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
669 {
670 }
671
672 __kernel void m01450_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
673 {
674 }