Initial commit
[hashcat.git] / amd / 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 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW4
16 #define VECT_SIZE1
17 #endif
18
19 #ifdef  VLIW5
20 #define VECT_SIZE1
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))) m01450_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   const u32 salt_len = salt_bufs[salt_pos].salt_len;
324
325   /**
326    * loop
327    */
328
329   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
330   {
331     const u32 pw_r_len = combs_buf[il_pos].pw_len;
332
333     const u32 pw_len = pw_l_len + pw_r_len;
334
335     u32 wordr0[4];
336
337     wordr0[0] = combs_buf[il_pos].i[0];
338     wordr0[1] = combs_buf[il_pos].i[1];
339     wordr0[2] = combs_buf[il_pos].i[2];
340     wordr0[3] = combs_buf[il_pos].i[3];
341
342     u32 wordr1[4];
343
344     wordr1[0] = combs_buf[il_pos].i[4];
345     wordr1[1] = combs_buf[il_pos].i[5];
346     wordr1[2] = combs_buf[il_pos].i[6];
347     wordr1[3] = combs_buf[il_pos].i[7];
348
349     u32 wordr2[4];
350
351     wordr2[0] = 0;
352     wordr2[1] = 0;
353     wordr2[2] = 0;
354     wordr2[3] = 0;
355
356     u32 wordr3[4];
357
358     wordr3[0] = 0;
359     wordr3[1] = 0;
360     wordr3[2] = 0;
361     wordr3[3] = 0;
362
363     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
364     {
365       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
366     }
367
368     u32x w0[4];
369
370     w0[0] = wordl0[0] | wordr0[0];
371     w0[1] = wordl0[1] | wordr0[1];
372     w0[2] = wordl0[2] | wordr0[2];
373     w0[3] = wordl0[3] | wordr0[3];
374
375     u32x w1[4];
376
377     w1[0] = wordl1[0] | wordr1[0];
378     w1[1] = wordl1[1] | wordr1[1];
379     w1[2] = wordl1[2] | wordr1[2];
380     w1[3] = wordl1[3] | wordr1[3];
381
382     u32x w2[4];
383
384     w2[0] = wordl2[0] | wordr2[0];
385     w2[1] = wordl2[1] | wordr2[1];
386     w2[2] = wordl2[2] | wordr2[2];
387     w2[3] = wordl2[3] | wordr2[3];
388
389     u32x w3[4];
390
391     w3[0] = wordl3[0] | wordr3[0];
392     w3[1] = wordl3[1] | wordr3[1];
393     w3[2] = wordl3[2] | wordr3[2];
394     w3[3] = wordl3[3] | wordr3[3];
395
396     /**
397      * pads
398      */
399
400     u32x w0_t[4];
401
402     w0_t[0] = swap_workaround (w0[0]);
403     w0_t[1] = swap_workaround (w0[1]);
404     w0_t[2] = swap_workaround (w0[2]);
405     w0_t[3] = swap_workaround (w0[3]);
406
407     u32x w1_t[4];
408
409     w1_t[0] = swap_workaround (w1[0]);
410     w1_t[1] = swap_workaround (w1[1]);
411     w1_t[2] = swap_workaround (w1[2]);
412     w1_t[3] = swap_workaround (w1[3]);
413
414     u32x w2_t[4];
415
416     w2_t[0] = 0;
417     w2_t[1] = 0;
418     w2_t[2] = 0;
419     w2_t[3] = 0;
420
421     u32x w3_t[4];
422
423     w3_t[0] = 0;
424     w3_t[1] = 0;
425     w3_t[2] = 0;
426     w3_t[3] = 0;
427
428     u32x ipad[8];
429     u32x opad[8];
430
431     hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
432
433     w0_t[0] = swap_workaround (salt_buf0[0]);
434     w0_t[1] = swap_workaround (salt_buf0[1]);
435     w0_t[2] = swap_workaround (salt_buf0[2]);
436     w0_t[3] = swap_workaround (salt_buf0[3]);
437     w1_t[0] = swap_workaround (salt_buf1[0]);
438     w1_t[1] = swap_workaround (salt_buf1[1]);
439     w1_t[2] = swap_workaround (salt_buf1[2]);
440     w1_t[3] = swap_workaround (salt_buf1[3]);
441     w2_t[0] = 0;
442     w2_t[1] = 0;
443     w2_t[2] = 0;
444     w2_t[3] = 0;
445     w3_t[0] = 0;
446     w3_t[1] = 0;
447     w3_t[2] = 0;
448     w3_t[3] = (64 + salt_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))) m01450_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))) m01450_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))) m01450_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   const u32 salt_len = salt_bufs[salt_pos].salt_len;
541
542   /**
543    * digest
544    */
545
546   const u32 search[4] =
547   {
548     digests_buf[digests_offset].digest_buf[DGST_R0],
549     digests_buf[digests_offset].digest_buf[DGST_R1],
550     digests_buf[digests_offset].digest_buf[DGST_R2],
551     digests_buf[digests_offset].digest_buf[DGST_R3]
552   };
553
554   /**
555    * loop
556    */
557
558   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
559   {
560     const u32 pw_r_len = combs_buf[il_pos].pw_len;
561
562     const u32 pw_len = pw_l_len + pw_r_len;
563
564     u32 wordr0[4];
565
566     wordr0[0] = combs_buf[il_pos].i[0];
567     wordr0[1] = combs_buf[il_pos].i[1];
568     wordr0[2] = combs_buf[il_pos].i[2];
569     wordr0[3] = combs_buf[il_pos].i[3];
570
571     u32 wordr1[4];
572
573     wordr1[0] = combs_buf[il_pos].i[4];
574     wordr1[1] = combs_buf[il_pos].i[5];
575     wordr1[2] = combs_buf[il_pos].i[6];
576     wordr1[3] = combs_buf[il_pos].i[7];
577
578     u32 wordr2[4];
579
580     wordr2[0] = 0;
581     wordr2[1] = 0;
582     wordr2[2] = 0;
583     wordr2[3] = 0;
584
585     u32 wordr3[4];
586
587     wordr3[0] = 0;
588     wordr3[1] = 0;
589     wordr3[2] = 0;
590     wordr3[3] = 0;
591
592     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
593     {
594       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
595     }
596
597     u32x w0[4];
598
599     w0[0] = wordl0[0] | wordr0[0];
600     w0[1] = wordl0[1] | wordr0[1];
601     w0[2] = wordl0[2] | wordr0[2];
602     w0[3] = wordl0[3] | wordr0[3];
603
604     u32x w1[4];
605
606     w1[0] = wordl1[0] | wordr1[0];
607     w1[1] = wordl1[1] | wordr1[1];
608     w1[2] = wordl1[2] | wordr1[2];
609     w1[3] = wordl1[3] | wordr1[3];
610
611     u32x w2[4];
612
613     w2[0] = wordl2[0] | wordr2[0];
614     w2[1] = wordl2[1] | wordr2[1];
615     w2[2] = wordl2[2] | wordr2[2];
616     w2[3] = wordl2[3] | wordr2[3];
617
618     u32x w3[4];
619
620     w3[0] = wordl3[0] | wordr3[0];
621     w3[1] = wordl3[1] | wordr3[1];
622     w3[2] = wordl3[2] | wordr3[2];
623     w3[3] = wordl3[3] | wordr3[3];
624
625     /**
626      * pads
627      */
628
629     u32x w0_t[4];
630
631     w0_t[0] = swap_workaround (w0[0]);
632     w0_t[1] = swap_workaround (w0[1]);
633     w0_t[2] = swap_workaround (w0[2]);
634     w0_t[3] = swap_workaround (w0[3]);
635
636     u32x w1_t[4];
637
638     w1_t[0] = swap_workaround (w1[0]);
639     w1_t[1] = swap_workaround (w1[1]);
640     w1_t[2] = swap_workaround (w1[2]);
641     w1_t[3] = swap_workaround (w1[3]);
642
643     u32x w2_t[4];
644
645     w2_t[0] = 0;
646     w2_t[1] = 0;
647     w2_t[2] = 0;
648     w2_t[3] = 0;
649
650     u32x w3_t[4];
651
652     w3_t[0] = 0;
653     w3_t[1] = 0;
654     w3_t[2] = 0;
655     w3_t[3] = 0;
656
657     u32x ipad[8];
658     u32x opad[8];
659
660     hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
661
662     w0_t[0] = swap_workaround (salt_buf0[0]);
663     w0_t[1] = swap_workaround (salt_buf0[1]);
664     w0_t[2] = swap_workaround (salt_buf0[2]);
665     w0_t[3] = swap_workaround (salt_buf0[3]);
666     w1_t[0] = swap_workaround (salt_buf1[0]);
667     w1_t[1] = swap_workaround (salt_buf1[1]);
668     w1_t[2] = swap_workaround (salt_buf1[2]);
669     w1_t[3] = swap_workaround (salt_buf1[3]);
670     w2_t[0] = 0;
671     w2_t[1] = 0;
672     w2_t[2] = 0;
673     w2_t[3] = 0;
674     w3_t[0] = 0;
675     w3_t[1] = 0;
676     w3_t[2] = 0;
677     w3_t[3] = (64 + salt_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))) m01450_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))) m01450_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 }