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