Merge branch 'master' into GetRidOfCUDA
[hashcat.git] / OpenCL / m08000_a3.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 static void sha256_transform_z (u32 digest[8])
130 {
131   u32 a = digest[0];
132   u32 b = digest[1];
133   u32 c = digest[2];
134   u32 d = digest[3];
135   u32 e = digest[4];
136   u32 f = digest[5];
137   u32 g = digest[6];
138   u32 h = digest[7];
139
140   #define ROUND_STEP_Z(i)                                                                 \
141   {                                                                                       \
142     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, 0, k_sha256[i +  0]); \
143     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, 0, k_sha256[i +  1]); \
144     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, 0, k_sha256[i +  2]); \
145     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, 0, k_sha256[i +  3]); \
146     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, 0, k_sha256[i +  4]); \
147     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, 0, k_sha256[i +  5]); \
148     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, 0, k_sha256[i +  6]); \
149     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, 0, k_sha256[i +  7]); \
150     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, 0, k_sha256[i +  8]); \
151     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, 0, k_sha256[i +  9]); \
152     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, 0, k_sha256[i + 10]); \
153     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, 0, k_sha256[i + 11]); \
154     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, 0, k_sha256[i + 12]); \
155     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, 0, k_sha256[i + 13]); \
156     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, 0, k_sha256[i + 14]); \
157     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, 0, k_sha256[i + 15]); \
158   }
159
160   ROUND_STEP_Z (0);
161
162   #pragma unroll
163   for (int i = 16; i < 64; i += 16)
164   {
165     ROUND_STEP_Z (i);
166   }
167
168   digest[0] += a;
169   digest[1] += b;
170   digest[2] += c;
171   digest[3] += d;
172   digest[4] += e;
173   digest[5] += f;
174   digest[6] += g;
175   digest[7] += h;
176 }
177
178 static void sha256_transform_s (u32 digest[8], __local u32 w[64])
179 {
180   u32 a = digest[0];
181   u32 b = digest[1];
182   u32 c = digest[2];
183   u32 d = digest[3];
184   u32 e = digest[4];
185   u32 f = digest[5];
186   u32 g = digest[6];
187   u32 h = digest[7];
188
189   #define ROUND_STEP_S(i)                                                                      \
190   {                                                                                            \
191     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w[i +  0], k_sha256[i +  0]); \
192     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w[i +  1], k_sha256[i +  1]); \
193     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w[i +  2], k_sha256[i +  2]); \
194     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w[i +  3], k_sha256[i +  3]); \
195     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w[i +  4], k_sha256[i +  4]); \
196     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w[i +  5], k_sha256[i +  5]); \
197     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w[i +  6], k_sha256[i +  6]); \
198     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w[i +  7], k_sha256[i +  7]); \
199     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w[i +  8], k_sha256[i +  8]); \
200     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w[i +  9], k_sha256[i +  9]); \
201     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w[i + 10], k_sha256[i + 10]); \
202     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w[i + 11], k_sha256[i + 11]); \
203     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w[i + 12], k_sha256[i + 12]); \
204     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w[i + 13], k_sha256[i + 13]); \
205     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w[i + 14], k_sha256[i + 14]); \
206     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w[i + 15], k_sha256[i + 15]); \
207   }
208
209   ROUND_STEP_S (0);
210
211   #pragma unroll
212   for (int i = 16; i < 64; i += 16)
213   {
214     ROUND_STEP_S (i);
215   }
216
217   digest[0] += a;
218   digest[1] += b;
219   digest[2] += c;
220   digest[3] += d;
221   digest[4] += e;
222   digest[5] += f;
223   digest[6] += g;
224   digest[7] += h;
225 }
226
227 static void m08000m (__local u32 w_s1[64], __local u32 w_s2[64], u32 w[16], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 gid_max)
228 {
229   /**
230    * modifier
231    */
232
233   const u32 gid = get_global_id (0);
234   const u32 lid = get_local_id (0);
235
236   w[ 1] = w[ 1] >> 8;
237   w[ 2] = w[ 2] >> 8;
238   w[ 3] = w[ 3] >> 8;
239   w[ 4] = w[ 4] >> 8;
240   w[ 5] = w[ 5] >> 8;
241   w[ 6] = w[ 6] >> 8;
242   w[ 7] = w[ 7] >> 8;
243   w[ 8] = w[ 8] >> 8;
244   w[ 9] = w[ 9] >> 8;
245   w[10] = w[10] >> 8;
246   w[11] = w[11] >> 8;
247   w[12] = w[12] >> 8;
248   w[13] = w[13] >> 8;
249   w[14] = w[14] >> 8;
250   w[15] = w[15] >> 8;
251
252   /**
253    * salt
254    */
255
256   const u32 salt_buf0 = swap32 (salt_bufs[salt_pos].salt_buf[ 0]);
257   const u32 salt_buf1 = swap32 (salt_bufs[salt_pos].salt_buf[ 1]);
258   const u32 salt_buf2 = swap32 (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
259
260   /**
261    * precompute final msg blocks
262    */
263
264   w_s1[lid] = 0;
265   w_s2[lid] = 0;
266
267   barrier (CLK_LOCAL_MEM_FENCE);
268
269   if (lid == 0)
270   {
271     w_s1[15] =               0 | salt_buf0 >> 16;
272
273     #pragma unroll
274     for (int i = 16; i < 64; i++)
275     {
276       w_s1[i] = SHA256_EXPAND (w_s1[i - 2], w_s1[i - 7], w_s1[i - 15], w_s1[i - 16]);
277     }
278   }
279   else if (lid == 1)
280   {
281     w_s2[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
282     w_s2[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
283     w_s2[ 2] = salt_buf2 << 16 | 0;
284     w_s2[15] = (510 + 8) * 8;
285
286     #pragma unroll
287     for (int i = 16; i < 64; i++)
288     {
289       w_s2[i] = SHA256_EXPAND (w_s2[i - 2], w_s2[i - 7], w_s2[i - 15], w_s2[i - 16]);
290     }
291   }
292
293   barrier (CLK_LOCAL_MEM_FENCE);
294
295   if (gid >= gid_max) return;
296
297   /**
298    * loop
299    */
300
301   u32 w0l = w[0];
302
303   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
304   {
305     const u32 w0r = words_buf_r[il_pos];
306
307     const u32 w0 = w0l | w0r;
308
309     w[0] = w0 >> 8;
310
311     u32 digest[8];
312
313     digest[0] = SHA256M_A;
314     digest[1] = SHA256M_B;
315     digest[2] = SHA256M_C;
316     digest[3] = SHA256M_D;
317     digest[4] = SHA256M_E;
318     digest[5] = SHA256M_F;
319     digest[6] = SHA256M_G;
320     digest[7] = SHA256M_H;
321
322     sha256_transform   (digest, w);     //   0 -  64
323     sha256_transform_z (digest);        //  64 - 128
324     sha256_transform_z (digest);        // 128 - 192
325     sha256_transform_z (digest);        // 192 - 256
326     sha256_transform_z (digest);        // 256 - 320
327     sha256_transform_z (digest);        // 320 - 384
328     sha256_transform_z (digest);        // 384 - 448
329     sha256_transform_s (digest, w_s1);  // 448 - 512
330     sha256_transform_s (digest, w_s2);  // 512 - 576
331
332     const u32 r0 = digest[3];
333     const u32 r1 = digest[7];
334     const u32 r2 = digest[2];
335     const u32 r3 = digest[6];
336
337     #include COMPARE_M
338   }
339 }
340
341 static void m08000s (__local u32 w_s1[64], __local u32 w_s2[64], u32 w[16], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 gid_max)
342 {
343   /**
344    * modifier
345    */
346
347   const u32 gid = get_global_id (0);
348   const u32 lid = get_local_id (0);
349
350   w[ 1] = w[ 1] >> 8;
351   w[ 2] = w[ 2] >> 8;
352   w[ 3] = w[ 3] >> 8;
353   w[ 4] = w[ 4] >> 8;
354   w[ 5] = w[ 5] >> 8;
355   w[ 6] = w[ 6] >> 8;
356   w[ 7] = w[ 7] >> 8;
357   w[ 8] = w[ 8] >> 8;
358   w[ 9] = w[ 9] >> 8;
359   w[10] = w[10] >> 8;
360   w[11] = w[11] >> 8;
361   w[12] = w[12] >> 8;
362   w[13] = w[13] >> 8;
363   w[14] = w[14] >> 8;
364   w[15] = w[15] >> 8;
365
366   /**
367    * salt
368    */
369
370   const u32 salt_buf0 = swap32 (salt_bufs[salt_pos].salt_buf[ 0]);
371   const u32 salt_buf1 = swap32 (salt_bufs[salt_pos].salt_buf[ 1]);
372   const u32 salt_buf2 = swap32 (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
373
374   /**
375    * precompute final msg blocks
376    */
377
378   w_s1[lid] = 0;
379   w_s2[lid] = 0;
380
381   barrier (CLK_LOCAL_MEM_FENCE);
382
383   if (lid == 0)
384   {
385     w_s1[15] =               0 | salt_buf0 >> 16;
386
387     #pragma unroll
388     for (int i = 16; i < 64; i++)
389     {
390       w_s1[i] = SHA256_EXPAND (w_s1[i - 2], w_s1[i - 7], w_s1[i - 15], w_s1[i - 16]);
391     }
392   }
393   else if (lid == 1)
394   {
395     w_s2[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
396     w_s2[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
397     w_s2[ 2] = salt_buf2 << 16 | 0;
398     w_s2[15] = (510 + 8) * 8;
399
400     #pragma unroll
401     for (int i = 16; i < 64; i++)
402     {
403       w_s2[i] = SHA256_EXPAND (w_s2[i - 2], w_s2[i - 7], w_s2[i - 15], w_s2[i - 16]);
404     }
405   }
406
407   barrier (CLK_LOCAL_MEM_FENCE);
408
409   if (gid >= gid_max) return;
410
411   /**
412    * digest
413    */
414
415   const u32 search[4] =
416   {
417     digests_buf[digests_offset].digest_buf[DGST_R0],
418     digests_buf[digests_offset].digest_buf[DGST_R1],
419     digests_buf[digests_offset].digest_buf[DGST_R2],
420     digests_buf[digests_offset].digest_buf[DGST_R3]
421   };
422
423   /**
424    * loop
425    */
426
427   u32 w0l = w[0];
428
429   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
430   {
431     const u32 w0r = words_buf_r[il_pos];
432
433     const u32 w0 = w0l | w0r;
434
435     w[0] = w0 >> 8;
436
437     u32 digest[8];
438
439     digest[0] = SHA256M_A;
440     digest[1] = SHA256M_B;
441     digest[2] = SHA256M_C;
442     digest[3] = SHA256M_D;
443     digest[4] = SHA256M_E;
444     digest[5] = SHA256M_F;
445     digest[6] = SHA256M_G;
446     digest[7] = SHA256M_H;
447
448     sha256_transform   (digest, w);     //   0 -  64
449     sha256_transform_z (digest);        //  64 - 128
450     sha256_transform_z (digest);        // 128 - 192
451     sha256_transform_z (digest);        // 192 - 256
452     sha256_transform_z (digest);        // 256 - 320
453     sha256_transform_z (digest);        // 320 - 384
454     sha256_transform_z (digest);        // 384 - 448
455     sha256_transform_s (digest, w_s1);  // 448 - 512
456     sha256_transform_s (digest, w_s2);  // 512 - 576
457
458     const u32 r0 = digest[3];
459     const u32 r1 = digest[7];
460     const u32 r2 = digest[2];
461     const u32 r3 = digest[6];
462
463     #include COMPARE_S
464   }
465 }
466
467 __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, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
468 {
469   /**
470    * base
471    */
472
473   const u32 gid = get_global_id (0);
474
475   u32 w[16];
476
477   w[ 0] = pws[gid].i[ 0];
478   w[ 1] = pws[gid].i[ 1];
479   w[ 2] = pws[gid].i[ 2];
480   w[ 3] = pws[gid].i[ 3];
481   w[ 4] = 0;
482   w[ 5] = 0;
483   w[ 6] = 0;
484   w[ 7] = 0;
485   w[ 8] = 0;
486   w[ 9] = 0;
487   w[10] = 0;
488   w[11] = 0;
489   w[12] = 0;
490   w[13] = 0;
491   w[14] = 0;
492   w[15] = 0;
493
494   const u32 pw_len = pws[gid].pw_len;
495
496   __local u32 w_s1[64];
497   __local u32 w_s2[64];
498
499   /**
500    * main
501    */
502
503   m08000m (w_s1, w_s2, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, gid_max);
504 }
505
506 __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, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
507 {
508   /**
509    * base
510    */
511
512   const u32 gid = get_global_id (0);
513
514   u32 w[16];
515
516   w[ 0] = pws[gid].i[ 0];
517   w[ 1] = pws[gid].i[ 1];
518   w[ 2] = pws[gid].i[ 2];
519   w[ 3] = pws[gid].i[ 3];
520   w[ 4] = pws[gid].i[ 4];
521   w[ 5] = pws[gid].i[ 5];
522   w[ 6] = pws[gid].i[ 6];
523   w[ 7] = pws[gid].i[ 7];
524   w[ 8] = 0;
525   w[ 9] = 0;
526   w[10] = 0;
527   w[11] = 0;
528   w[12] = 0;
529   w[13] = 0;
530   w[14] = 0;
531   w[15] = 0;
532
533   const u32 pw_len = pws[gid].pw_len;
534
535   __local u32 w_s1[64];
536   __local u32 w_s2[64];
537
538   /**
539    * main
540    */
541
542   m08000m (w_s1, w_s2, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, gid_max);
543 }
544
545 __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, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
546 {
547   /**
548    * base
549    */
550
551   const u32 gid = get_global_id (0);
552
553   u32 w[16];
554
555   w[ 0] = pws[gid].i[ 0];
556   w[ 1] = pws[gid].i[ 1];
557   w[ 2] = pws[gid].i[ 2];
558   w[ 3] = pws[gid].i[ 3];
559   w[ 4] = pws[gid].i[ 4];
560   w[ 5] = pws[gid].i[ 5];
561   w[ 6] = pws[gid].i[ 6];
562   w[ 7] = pws[gid].i[ 7];
563   w[ 8] = pws[gid].i[ 8];
564   w[ 9] = pws[gid].i[ 9];
565   w[10] = pws[gid].i[10];
566   w[11] = pws[gid].i[11];
567   w[12] = pws[gid].i[12];
568   w[13] = pws[gid].i[13];
569   w[14] = pws[gid].i[14];
570   w[15] = pws[gid].i[15];
571
572   const u32 pw_len = pws[gid].pw_len;
573
574   __local u32 w_s1[64];
575   __local u32 w_s2[64];
576
577   /**
578    * main
579    */
580
581   m08000m (w_s1, w_s2, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, gid_max);
582 }
583
584 __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, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
585 {
586   /**
587    * base
588    */
589
590   const u32 gid = get_global_id (0);
591
592   u32 w[16];
593
594   w[ 0] = pws[gid].i[ 0];
595   w[ 1] = pws[gid].i[ 1];
596   w[ 2] = pws[gid].i[ 2];
597   w[ 3] = pws[gid].i[ 3];
598   w[ 4] = 0;
599   w[ 5] = 0;
600   w[ 6] = 0;
601   w[ 7] = 0;
602   w[ 8] = 0;
603   w[ 9] = 0;
604   w[10] = 0;
605   w[11] = 0;
606   w[12] = 0;
607   w[13] = 0;
608   w[14] = 0;
609   w[15] = 0;
610
611   const u32 pw_len = pws[gid].pw_len;
612
613   __local u32 w_s1[64];
614   __local u32 w_s2[64];
615
616   /**
617    * main
618    */
619
620   m08000s (w_s1, w_s2, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, gid_max);
621 }
622
623 __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, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
624 {
625   /**
626    * base
627    */
628
629   const u32 gid = get_global_id (0);
630
631   u32 w[16];
632
633   w[ 0] = pws[gid].i[ 0];
634   w[ 1] = pws[gid].i[ 1];
635   w[ 2] = pws[gid].i[ 2];
636   w[ 3] = pws[gid].i[ 3];
637   w[ 4] = pws[gid].i[ 4];
638   w[ 5] = pws[gid].i[ 5];
639   w[ 6] = pws[gid].i[ 6];
640   w[ 7] = pws[gid].i[ 7];
641   w[ 8] = 0;
642   w[ 9] = 0;
643   w[10] = 0;
644   w[11] = 0;
645   w[12] = 0;
646   w[13] = 0;
647   w[14] = 0;
648   w[15] = 0;
649
650   const u32 pw_len = pws[gid].pw_len;
651
652   __local u32 w_s1[64];
653   __local u32 w_s2[64];
654
655   /**
656    * main
657    */
658
659   m08000s (w_s1, w_s2, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, gid_max);
660 }
661
662 __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, __constant u32 * words_buf_r, __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 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
663 {
664   /**
665    * base
666    */
667
668   const u32 gid = get_global_id (0);
669
670   u32 w[16];
671
672   w[ 0] = pws[gid].i[ 0];
673   w[ 1] = pws[gid].i[ 1];
674   w[ 2] = pws[gid].i[ 2];
675   w[ 3] = pws[gid].i[ 3];
676   w[ 4] = pws[gid].i[ 4];
677   w[ 5] = pws[gid].i[ 5];
678   w[ 6] = pws[gid].i[ 6];
679   w[ 7] = pws[gid].i[ 7];
680   w[ 8] = pws[gid].i[ 8];
681   w[ 9] = pws[gid].i[ 9];
682   w[10] = pws[gid].i[10];
683   w[11] = pws[gid].i[11];
684   w[12] = pws[gid].i[12];
685   w[13] = pws[gid].i[13];
686   w[14] = pws[gid].i[14];
687   w[15] = pws[gid].i[15];
688
689   const u32 pw_len = pws[gid].pw_len;
690
691   __local u32 w_s1[64];
692   __local u32 w_s2[64];
693
694   /**
695    * main
696    */
697
698   m08000s (w_s1, w_s2, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset, gid_max);
699 }