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