Initial commit
[hashcat.git] / amd / m08000_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 (u32x digest[8], const u32x w[16])
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 = w[ 0];
79   u32x w1_t = w[ 1];
80   u32x w2_t = w[ 2];
81   u32x w3_t = w[ 3];
82   u32x w4_t = w[ 4];
83   u32x w5_t = w[ 5];
84   u32x w6_t = w[ 6];
85   u32x w7_t = w[ 7];
86   u32x w8_t = w[ 8];
87   u32x w9_t = w[ 9];
88   u32x wa_t = w[10];
89   u32x wb_t = w[11];
90   u32x wc_t = w[12];
91   u32x wd_t = w[13];
92   u32x we_t = w[14];
93   u32x wf_t = w[15];
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 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m08000_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)
154 {
155   /**
156    * modifier
157    */
158
159   const u32 lid = get_local_id (0);
160
161   /**
162    * base
163    */
164
165   const u32 gid = get_global_id (0);
166
167   if (gid >= gid_max) return;
168
169   u32x wordl0[4];
170
171   wordl0[0] = pws[gid].i[ 0];
172   wordl0[1] = pws[gid].i[ 1];
173   wordl0[2] = pws[gid].i[ 2];
174   wordl0[3] = pws[gid].i[ 3];
175
176   u32x wordl1[4];
177
178   wordl1[0] = pws[gid].i[ 4];
179   wordl1[1] = pws[gid].i[ 5];
180   wordl1[2] = pws[gid].i[ 6];
181   wordl1[3] = pws[gid].i[ 7];
182
183   u32x wordl2[4];
184
185   wordl2[0] = 0;
186   wordl2[1] = 0;
187   wordl2[2] = 0;
188   wordl2[3] = 0;
189
190   u32x wordl3[4];
191
192   wordl3[0] = 0;
193   wordl3[1] = 0;
194   wordl3[2] = 0;
195   wordl3[3] = 0;
196
197   const u32 pw_l_len = pws[gid].pw_len;
198
199   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
200   {
201     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
202   }
203
204   /**
205    * salt
206    */
207
208   const u32 salt_buf0 = swap_workaround (salt_bufs[salt_pos].salt_buf[ 0]);
209   const u32 salt_buf1 = swap_workaround (salt_bufs[salt_pos].salt_buf[ 1]);
210   const u32 salt_buf2 = swap_workaround (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
211
212   /**
213    * loop
214    */
215
216   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
217   {
218     u32 wordr0[4];
219     u32 wordr1[4];
220     u32 wordr2[4];
221     u32 wordr3[4];
222
223     wordr0[0] = combs_buf[il_pos].i[0];
224     wordr0[1] = combs_buf[il_pos].i[1];
225     wordr0[2] = combs_buf[il_pos].i[2];
226     wordr0[3] = combs_buf[il_pos].i[3];
227     wordr1[0] = combs_buf[il_pos].i[4];
228     wordr1[1] = combs_buf[il_pos].i[5];
229     wordr1[2] = combs_buf[il_pos].i[6];
230     wordr1[3] = combs_buf[il_pos].i[7];
231     wordr2[0] = 0;
232     wordr2[1] = 0;
233     wordr2[2] = 0;
234     wordr2[3] = 0;
235     wordr3[0] = 0;
236     wordr3[1] = 0;
237     wordr3[2] = 0;
238     wordr3[3] = 0;
239
240     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
241     {
242       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
243     }
244
245     u32x w0[4];
246     u32x w1[4];
247     u32x w2[4];
248     u32x w3[4];
249
250     w0[0] = wordl0[0] | wordr0[0];
251     w0[1] = wordl0[1] | wordr0[1];
252     w0[2] = wordl0[2] | wordr0[2];
253     w0[3] = wordl0[3] | wordr0[3];
254     w1[0] = wordl1[0] | wordr1[0];
255     w1[1] = wordl1[1] | wordr1[1];
256     w1[2] = wordl1[2] | wordr1[2];
257     w1[3] = wordl1[3] | wordr1[3];
258     w2[0] = wordl2[0] | wordr2[0];
259     w2[1] = wordl2[1] | wordr2[1];
260     w2[2] = wordl2[2] | wordr2[2];
261     w2[3] = wordl2[3] | wordr2[3];
262     w3[0] = wordl3[0] | wordr3[0];
263     w3[1] = wordl3[1] | wordr3[1];
264     w3[2] = wordl3[2] | wordr3[2];
265     w3[3] = wordl3[3] | wordr3[3];
266
267     u32x w0_t[4];
268     u32x w1_t[4];
269     u32x w2_t[4];
270     u32x w3_t[4];
271
272     make_unicode (w0, w0_t, w1_t);
273
274     make_unicode (w1, w2_t, w3_t);
275
276     u32x w_t[16];
277
278     w_t[ 0] = swap_workaround (w0_t[0]);
279     w_t[ 1] = swap_workaround (w0_t[1]);
280     w_t[ 2] = swap_workaround (w0_t[2]);
281     w_t[ 3] = swap_workaround (w0_t[3]);
282     w_t[ 4] = swap_workaround (w1_t[0]);
283     w_t[ 5] = swap_workaround (w1_t[1]);
284     w_t[ 6] = swap_workaround (w1_t[2]);
285     w_t[ 7] = swap_workaround (w1_t[3]);
286     w_t[ 8] = swap_workaround (w2_t[0]);
287     w_t[ 9] = swap_workaround (w2_t[1]);
288     w_t[10] = swap_workaround (w2_t[2]);
289     w_t[11] = swap_workaround (w2_t[3]);
290     w_t[12] = swap_workaround (w3_t[0]);
291     w_t[13] = swap_workaround (w3_t[1]);
292     w_t[14] = swap_workaround (w3_t[2]);
293     w_t[15] = swap_workaround (w3_t[3]);
294
295     w_t[ 0] = w_t[ 0] >> 8;
296     w_t[ 1] = w_t[ 1] >> 8;
297     w_t[ 2] = w_t[ 2] >> 8;
298     w_t[ 3] = w_t[ 3] >> 8;
299     w_t[ 4] = w_t[ 4] >> 8;
300     w_t[ 5] = w_t[ 5] >> 8;
301     w_t[ 6] = w_t[ 6] >> 8;
302     w_t[ 7] = w_t[ 7] >> 8;
303     w_t[ 8] = w_t[ 8] >> 8;
304     w_t[ 9] = w_t[ 9] >> 8;
305     w_t[10] = w_t[10] >> 8;
306     w_t[11] = w_t[11] >> 8;
307     w_t[12] = w_t[12] >> 8;
308     w_t[13] = w_t[13] >> 8;
309     w_t[14] = w_t[14] >> 8;
310     w_t[15] = w_t[15] >> 8;
311
312     u32x digest[8];
313
314     digest[0] = SHA256M_A;
315     digest[1] = SHA256M_B;
316     digest[2] = SHA256M_C;
317     digest[3] = SHA256M_D;
318     digest[4] = SHA256M_E;
319     digest[5] = SHA256M_F;
320     digest[6] = SHA256M_G;
321     digest[7] = SHA256M_H;
322
323     sha256_transform (digest, w_t); //   0 - 64
324
325     w_t[ 0] = 0;
326     w_t[ 1] = 0;
327     w_t[ 2] = 0;
328     w_t[ 3] = 0;
329     w_t[ 4] = 0;
330     w_t[ 5] = 0;
331     w_t[ 6] = 0;
332     w_t[ 7] = 0;
333     w_t[ 8] = 0;
334     w_t[ 9] = 0;
335     w_t[10] = 0;
336     w_t[11] = 0;
337     w_t[12] = 0;
338     w_t[13] = 0;
339     w_t[14] = 0;
340     w_t[15] = 0;
341
342     sha256_transform (digest, w_t); //  64 - 128
343     sha256_transform (digest, w_t); // 128 - 192
344     sha256_transform (digest, w_t); // 192 - 256
345     sha256_transform (digest, w_t); // 256 - 320
346     sha256_transform (digest, w_t); // 320 - 384
347     sha256_transform (digest, w_t); // 384 - 448
348
349     w_t[15] =               0 | salt_buf0 >> 16;
350
351     sha256_transform (digest, w_t); // 448 - 512
352
353     w_t[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
354     w_t[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
355     w_t[ 2] = salt_buf2 << 16 | 0;
356     w_t[15] = (510 + 8) * 8;
357
358     sha256_transform (digest, w_t); // 512 - 576
359
360     const u32x r0 = digest[3];
361     const u32x r1 = digest[7];
362     const u32x r2 = digest[2];
363     const u32x r3 = digest[6];
364
365     #include VECT_COMPARE_M
366   }
367 }
368
369 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m08000_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)
370 {
371 }
372
373 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m08000_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)
374 {
375 }
376
377 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m08000_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)
378 {
379   /**
380    * modifier
381    */
382
383   const u32 lid = get_local_id (0);
384
385   /**
386    * base
387    */
388
389   const u32 gid = get_global_id (0);
390
391   if (gid >= gid_max) return;
392
393   u32x wordl0[4];
394
395   wordl0[0] = pws[gid].i[ 0];
396   wordl0[1] = pws[gid].i[ 1];
397   wordl0[2] = pws[gid].i[ 2];
398   wordl0[3] = pws[gid].i[ 3];
399
400   u32x wordl1[4];
401
402   wordl1[0] = pws[gid].i[ 4];
403   wordl1[1] = pws[gid].i[ 5];
404   wordl1[2] = pws[gid].i[ 6];
405   wordl1[3] = pws[gid].i[ 7];
406
407   u32x wordl2[4];
408
409   wordl2[0] = 0;
410   wordl2[1] = 0;
411   wordl2[2] = 0;
412   wordl2[3] = 0;
413
414   u32x wordl3[4];
415
416   wordl3[0] = 0;
417   wordl3[1] = 0;
418   wordl3[2] = 0;
419   wordl3[3] = 0;
420
421   const u32 pw_l_len = pws[gid].pw_len;
422
423   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
424   {
425     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
426   }
427
428   /**
429    * salt
430    */
431
432   const u32 salt_buf0 = swap_workaround (salt_bufs[salt_pos].salt_buf[ 0]);
433   const u32 salt_buf1 = swap_workaround (salt_bufs[salt_pos].salt_buf[ 1]);
434   const u32 salt_buf2 = swap_workaround (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
435
436   /**
437    * digest
438    */
439
440   const u32 search[4] =
441   {
442     digests_buf[digests_offset].digest_buf[DGST_R0],
443     digests_buf[digests_offset].digest_buf[DGST_R1],
444     digests_buf[digests_offset].digest_buf[DGST_R2],
445     digests_buf[digests_offset].digest_buf[DGST_R3]
446   };
447
448   /**
449    * loop
450    */
451
452   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
453   {
454     u32 wordr0[4];
455     u32 wordr1[4];
456     u32 wordr2[4];
457     u32 wordr3[4];
458
459     wordr0[0] = combs_buf[il_pos].i[0];
460     wordr0[1] = combs_buf[il_pos].i[1];
461     wordr0[2] = combs_buf[il_pos].i[2];
462     wordr0[3] = combs_buf[il_pos].i[3];
463     wordr1[0] = combs_buf[il_pos].i[4];
464     wordr1[1] = combs_buf[il_pos].i[5];
465     wordr1[2] = combs_buf[il_pos].i[6];
466     wordr1[3] = combs_buf[il_pos].i[7];
467     wordr2[0] = 0;
468     wordr2[1] = 0;
469     wordr2[2] = 0;
470     wordr2[3] = 0;
471     wordr3[0] = 0;
472     wordr3[1] = 0;
473     wordr3[2] = 0;
474     wordr3[3] = 0;
475
476     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
477     {
478       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
479     }
480
481     u32x w0[4];
482     u32x w1[4];
483     u32x w2[4];
484     u32x w3[4];
485
486     w0[0] = wordl0[0] | wordr0[0];
487     w0[1] = wordl0[1] | wordr0[1];
488     w0[2] = wordl0[2] | wordr0[2];
489     w0[3] = wordl0[3] | wordr0[3];
490     w1[0] = wordl1[0] | wordr1[0];
491     w1[1] = wordl1[1] | wordr1[1];
492     w1[2] = wordl1[2] | wordr1[2];
493     w1[3] = wordl1[3] | wordr1[3];
494     w2[0] = wordl2[0] | wordr2[0];
495     w2[1] = wordl2[1] | wordr2[1];
496     w2[2] = wordl2[2] | wordr2[2];
497     w2[3] = wordl2[3] | wordr2[3];
498     w3[0] = wordl3[0] | wordr3[0];
499     w3[1] = wordl3[1] | wordr3[1];
500     w3[2] = wordl3[2] | wordr3[2];
501     w3[3] = wordl3[3] | wordr3[3];
502
503     u32x w0_t[4];
504     u32x w1_t[4];
505     u32x w2_t[4];
506     u32x w3_t[4];
507
508     make_unicode (w0, w0_t, w1_t);
509
510     make_unicode (w1, w2_t, w3_t);
511
512     u32x w_t[16];
513
514     w_t[ 0] = swap_workaround (w0_t[0]);
515     w_t[ 1] = swap_workaround (w0_t[1]);
516     w_t[ 2] = swap_workaround (w0_t[2]);
517     w_t[ 3] = swap_workaround (w0_t[3]);
518     w_t[ 4] = swap_workaround (w1_t[0]);
519     w_t[ 5] = swap_workaround (w1_t[1]);
520     w_t[ 6] = swap_workaround (w1_t[2]);
521     w_t[ 7] = swap_workaround (w1_t[3]);
522     w_t[ 8] = swap_workaround (w2_t[0]);
523     w_t[ 9] = swap_workaround (w2_t[1]);
524     w_t[10] = swap_workaround (w2_t[2]);
525     w_t[11] = swap_workaround (w2_t[3]);
526     w_t[12] = swap_workaround (w3_t[0]);
527     w_t[13] = swap_workaround (w3_t[1]);
528     w_t[14] = swap_workaround (w3_t[2]);
529     w_t[15] = swap_workaround (w3_t[3]);
530
531     w_t[ 0] = w_t[ 0] >> 8;
532     w_t[ 1] = w_t[ 1] >> 8;
533     w_t[ 2] = w_t[ 2] >> 8;
534     w_t[ 3] = w_t[ 3] >> 8;
535     w_t[ 4] = w_t[ 4] >> 8;
536     w_t[ 5] = w_t[ 5] >> 8;
537     w_t[ 6] = w_t[ 6] >> 8;
538     w_t[ 7] = w_t[ 7] >> 8;
539     w_t[ 8] = w_t[ 8] >> 8;
540     w_t[ 9] = w_t[ 9] >> 8;
541     w_t[10] = w_t[10] >> 8;
542     w_t[11] = w_t[11] >> 8;
543     w_t[12] = w_t[12] >> 8;
544     w_t[13] = w_t[13] >> 8;
545     w_t[14] = w_t[14] >> 8;
546     w_t[15] = w_t[15] >> 8;
547
548     u32x digest[8];
549
550     digest[0] = SHA256M_A;
551     digest[1] = SHA256M_B;
552     digest[2] = SHA256M_C;
553     digest[3] = SHA256M_D;
554     digest[4] = SHA256M_E;
555     digest[5] = SHA256M_F;
556     digest[6] = SHA256M_G;
557     digest[7] = SHA256M_H;
558
559     sha256_transform (digest, w_t); //   0 - 64
560
561     w_t[ 0] = 0;
562     w_t[ 1] = 0;
563     w_t[ 2] = 0;
564     w_t[ 3] = 0;
565     w_t[ 4] = 0;
566     w_t[ 5] = 0;
567     w_t[ 6] = 0;
568     w_t[ 7] = 0;
569     w_t[ 8] = 0;
570     w_t[ 9] = 0;
571     w_t[10] = 0;
572     w_t[11] = 0;
573     w_t[12] = 0;
574     w_t[13] = 0;
575     w_t[14] = 0;
576     w_t[15] = 0;
577
578     sha256_transform (digest, w_t); //  64 - 128
579     sha256_transform (digest, w_t); // 128 - 192
580     sha256_transform (digest, w_t); // 192 - 256
581     sha256_transform (digest, w_t); // 256 - 320
582     sha256_transform (digest, w_t); // 320 - 384
583     sha256_transform (digest, w_t); // 384 - 448
584
585     w_t[15] =               0 | salt_buf0 >> 16;
586
587     sha256_transform (digest, w_t); // 448 - 512
588
589     w_t[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
590     w_t[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
591     w_t[ 2] = salt_buf2 << 16 | 0;
592     w_t[15] = (510 + 8) * 8;
593
594     sha256_transform (digest, w_t); // 512 - 576
595
596     const u32x r0 = digest[3];
597     const u32x r1 = digest[7];
598     const u32x r2 = digest[2];
599     const u32x r3 = digest[6];
600
601     #include VECT_COMPARE_S
602   }
603 }
604
605 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m08000_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)
606 {
607 }
608
609 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m08000_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)
610 {
611 }