Merge branch 'master' of https://github.com/hashcat/oclHashcat
[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 "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19
20 #define COMPARE_S "OpenCL/check_single_comp4.c"
21 #define COMPARE_M "OpenCL/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 kernel_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   const u32 lsz = get_local_size (0);
236
237   /**
238    * salt
239    */
240
241   const u32 salt_buf0 = swap32 (salt_bufs[salt_pos].salt_buf[ 0]);
242   const u32 salt_buf1 = swap32 (salt_bufs[salt_pos].salt_buf[ 1]);
243   const u32 salt_buf2 = swap32 (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
244
245   /**
246    * precompute final msg blocks
247    */
248
249   for (u32 i = lid; i < 64; i += lsz)
250   {
251     w_s1[i] = 0;
252     w_s2[i] = 0;
253   }
254
255   barrier (CLK_LOCAL_MEM_FENCE);
256
257   if (lid == 0)
258   {
259     w_s1[15] =               0 | salt_buf0 >> 16;
260
261     #pragma unroll
262     for (int i = 16; i < 64; i++)
263     {
264       w_s1[i] = SHA256_EXPAND (w_s1[i - 2], w_s1[i - 7], w_s1[i - 15], w_s1[i - 16]);
265     }
266
267     w_s2[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
268     w_s2[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
269     w_s2[ 2] = salt_buf2 << 16 | 0;
270     w_s2[15] = (510 + 8) * 8;
271
272     #pragma unroll
273     for (int i = 16; i < 64; i++)
274     {
275       w_s2[i] = SHA256_EXPAND (w_s2[i - 2], w_s2[i - 7], w_s2[i - 15], w_s2[i - 16]);
276     }
277   }
278
279   barrier (CLK_LOCAL_MEM_FENCE);
280
281   if (gid >= gid_max) return;
282
283   /**
284    * modifier
285    */
286
287   w[ 1] = w[ 1] >> 8;
288   w[ 2] = w[ 2] >> 8;
289   w[ 3] = w[ 3] >> 8;
290   w[ 4] = w[ 4] >> 8;
291   w[ 5] = w[ 5] >> 8;
292   w[ 6] = w[ 6] >> 8;
293   w[ 7] = w[ 7] >> 8;
294   w[ 8] = w[ 8] >> 8;
295   w[ 9] = w[ 9] >> 8;
296   w[10] = w[10] >> 8;
297   w[11] = w[11] >> 8;
298   w[12] = w[12] >> 8;
299   w[13] = w[13] >> 8;
300   w[14] = w[14] >> 8;
301   w[15] = w[15] >> 8;
302
303   /**
304    * loop
305    */
306
307   u32 w0l = w[0];
308
309   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
310   {
311     const u32 w0r = words_buf_r[il_pos];
312
313     const u32 w0 = w0l | w0r;
314
315     w[0] = w0 >> 8;
316
317     u32 digest[8];
318
319     digest[0] = SHA256M_A;
320     digest[1] = SHA256M_B;
321     digest[2] = SHA256M_C;
322     digest[3] = SHA256M_D;
323     digest[4] = SHA256M_E;
324     digest[5] = SHA256M_F;
325     digest[6] = SHA256M_G;
326     digest[7] = SHA256M_H;
327
328     sha256_transform   (digest, w);     //   0 -  64
329     sha256_transform_z (digest);        //  64 - 128
330     sha256_transform_z (digest);        // 128 - 192
331     sha256_transform_z (digest);        // 192 - 256
332     sha256_transform_z (digest);        // 256 - 320
333     sha256_transform_z (digest);        // 320 - 384
334     sha256_transform_z (digest);        // 384 - 448
335     sha256_transform_s (digest, w_s1);  // 448 - 512
336     sha256_transform_s (digest, w_s2);  // 512 - 576
337
338     const u32 r0 = digest[3];
339     const u32 r1 = digest[7];
340     const u32 r2 = digest[2];
341     const u32 r3 = digest[6];
342
343     #include COMPARE_M
344   }
345 }
346
347 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 kernel_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)
348 {
349   /**
350    * modifier
351    */
352
353   const u32 gid = get_global_id (0);
354   const u32 lid = get_local_id (0);
355   const u32 lsz = get_local_size (0);
356
357   /**
358    * salt
359    */
360
361   const u32 salt_buf0 = swap32 (salt_bufs[salt_pos].salt_buf[ 0]);
362   const u32 salt_buf1 = swap32 (salt_bufs[salt_pos].salt_buf[ 1]);
363   const u32 salt_buf2 = swap32 (salt_bufs[salt_pos].salt_buf[ 2]); // 0x80
364
365   /**
366    * precompute final msg blocks
367    */
368
369   for (u32 i = lid; i < 64; i += lsz)
370   {
371     w_s1[i] = 0;
372     w_s2[i] = 0;
373   }
374
375   barrier (CLK_LOCAL_MEM_FENCE);
376
377   if (lid == 0)
378   {
379     w_s1[15] =               0 | salt_buf0 >> 16;
380
381     #pragma unroll
382     for (int i = 16; i < 64; i++)
383     {
384       w_s1[i] = SHA256_EXPAND (w_s1[i - 2], w_s1[i - 7], w_s1[i - 15], w_s1[i - 16]);
385     }
386
387     w_s2[ 0] = salt_buf0 << 16 | salt_buf1 >> 16;
388     w_s2[ 1] = salt_buf1 << 16 | salt_buf2 >> 16;
389     w_s2[ 2] = salt_buf2 << 16 | 0;
390     w_s2[15] = (510 + 8) * 8;
391
392     #pragma unroll
393     for (int i = 16; i < 64; i++)
394     {
395       w_s2[i] = SHA256_EXPAND (w_s2[i - 2], w_s2[i - 7], w_s2[i - 15], w_s2[i - 16]);
396     }
397   }
398
399   barrier (CLK_LOCAL_MEM_FENCE);
400
401   if (gid >= gid_max) return;
402
403   /**
404    * modifier
405    */
406
407   w[ 1] = w[ 1] >> 8;
408   w[ 2] = w[ 2] >> 8;
409   w[ 3] = w[ 3] >> 8;
410   w[ 4] = w[ 4] >> 8;
411   w[ 5] = w[ 5] >> 8;
412   w[ 6] = w[ 6] >> 8;
413   w[ 7] = w[ 7] >> 8;
414   w[ 8] = w[ 8] >> 8;
415   w[ 9] = w[ 9] >> 8;
416   w[10] = w[10] >> 8;
417   w[11] = w[11] >> 8;
418   w[12] = w[12] >> 8;
419   w[13] = w[13] >> 8;
420   w[14] = w[14] >> 8;
421   w[15] = w[15] >> 8;
422
423   /**
424    * digest
425    */
426
427   const u32 search[4] =
428   {
429     digests_buf[digests_offset].digest_buf[DGST_R0],
430     digests_buf[digests_offset].digest_buf[DGST_R1],
431     digests_buf[digests_offset].digest_buf[DGST_R2],
432     digests_buf[digests_offset].digest_buf[DGST_R3]
433   };
434
435   /**
436    * loop
437    */
438
439   u32 w0l = w[0];
440
441   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
442   {
443     const u32 w0r = words_buf_r[il_pos];
444
445     const u32 w0 = w0l | w0r;
446
447     w[0] = w0 >> 8;
448
449     u32 digest[8];
450
451     digest[0] = SHA256M_A;
452     digest[1] = SHA256M_B;
453     digest[2] = SHA256M_C;
454     digest[3] = SHA256M_D;
455     digest[4] = SHA256M_E;
456     digest[5] = SHA256M_F;
457     digest[6] = SHA256M_G;
458     digest[7] = SHA256M_H;
459
460     sha256_transform   (digest, w);     //   0 -  64
461     sha256_transform_z (digest);        //  64 - 128
462     sha256_transform_z (digest);        // 128 - 192
463     sha256_transform_z (digest);        // 192 - 256
464     sha256_transform_z (digest);        // 256 - 320
465     sha256_transform_z (digest);        // 320 - 384
466     sha256_transform_z (digest);        // 384 - 448
467     sha256_transform_s (digest, w_s1);  // 448 - 512
468     sha256_transform_s (digest, w_s2);  // 512 - 576
469
470     const u32 r0 = digest[3];
471     const u32 r1 = digest[7];
472     const u32 r2 = digest[2];
473     const u32 r3 = digest[6];
474
475     #include COMPARE_S
476   }
477 }
478
479 __kernel void m08000_m04 (__global pw_t *pws, __global kernel_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)
480 {
481   /**
482    * base
483    */
484
485   const u32 gid = get_global_id (0);
486
487   u32 w[16];
488
489   w[ 0] = pws[gid].i[ 0];
490   w[ 1] = pws[gid].i[ 1];
491   w[ 2] = pws[gid].i[ 2];
492   w[ 3] = pws[gid].i[ 3];
493   w[ 4] = 0;
494   w[ 5] = 0;
495   w[ 6] = 0;
496   w[ 7] = 0;
497   w[ 8] = 0;
498   w[ 9] = 0;
499   w[10] = 0;
500   w[11] = 0;
501   w[12] = 0;
502   w[13] = 0;
503   w[14] = 0;
504   w[15] = 0;
505
506   const u32 pw_len = pws[gid].pw_len;
507
508   __local u32 w_s1[64];
509   __local u32 w_s2[64];
510
511   /**
512    * main
513    */
514
515   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);
516 }
517
518 __kernel void m08000_m08 (__global pw_t *pws, __global kernel_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)
519 {
520   /**
521    * base
522    */
523
524   const u32 gid = get_global_id (0);
525
526   u32 w[16];
527
528   w[ 0] = pws[gid].i[ 0];
529   w[ 1] = pws[gid].i[ 1];
530   w[ 2] = pws[gid].i[ 2];
531   w[ 3] = pws[gid].i[ 3];
532   w[ 4] = pws[gid].i[ 4];
533   w[ 5] = pws[gid].i[ 5];
534   w[ 6] = pws[gid].i[ 6];
535   w[ 7] = pws[gid].i[ 7];
536   w[ 8] = 0;
537   w[ 9] = 0;
538   w[10] = 0;
539   w[11] = 0;
540   w[12] = 0;
541   w[13] = 0;
542   w[14] = 0;
543   w[15] = 0;
544
545   const u32 pw_len = pws[gid].pw_len;
546
547   __local u32 w_s1[64];
548   __local u32 w_s2[64];
549
550   /**
551    * main
552    */
553
554   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);
555 }
556
557 __kernel void m08000_m16 (__global pw_t *pws, __global kernel_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)
558 {
559   /**
560    * base
561    */
562
563   const u32 gid = get_global_id (0);
564
565   u32 w[16];
566
567   w[ 0] = pws[gid].i[ 0];
568   w[ 1] = pws[gid].i[ 1];
569   w[ 2] = pws[gid].i[ 2];
570   w[ 3] = pws[gid].i[ 3];
571   w[ 4] = pws[gid].i[ 4];
572   w[ 5] = pws[gid].i[ 5];
573   w[ 6] = pws[gid].i[ 6];
574   w[ 7] = pws[gid].i[ 7];
575   w[ 8] = pws[gid].i[ 8];
576   w[ 9] = pws[gid].i[ 9];
577   w[10] = pws[gid].i[10];
578   w[11] = pws[gid].i[11];
579   w[12] = pws[gid].i[12];
580   w[13] = pws[gid].i[13];
581   w[14] = pws[gid].i[14];
582   w[15] = pws[gid].i[15];
583
584   const u32 pw_len = pws[gid].pw_len;
585
586   __local u32 w_s1[64];
587   __local u32 w_s2[64];
588
589   /**
590    * main
591    */
592
593   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);
594 }
595
596 __kernel void m08000_s04 (__global pw_t *pws, __global kernel_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)
597 {
598   /**
599    * base
600    */
601
602   const u32 gid = get_global_id (0);
603
604   u32 w[16];
605
606   w[ 0] = pws[gid].i[ 0];
607   w[ 1] = pws[gid].i[ 1];
608   w[ 2] = pws[gid].i[ 2];
609   w[ 3] = pws[gid].i[ 3];
610   w[ 4] = 0;
611   w[ 5] = 0;
612   w[ 6] = 0;
613   w[ 7] = 0;
614   w[ 8] = 0;
615   w[ 9] = 0;
616   w[10] = 0;
617   w[11] = 0;
618   w[12] = 0;
619   w[13] = 0;
620   w[14] = 0;
621   w[15] = 0;
622
623   const u32 pw_len = pws[gid].pw_len;
624
625   __local u32 w_s1[64];
626   __local u32 w_s2[64];
627
628   /**
629    * main
630    */
631
632   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);
633 }
634
635 __kernel void m08000_s08 (__global pw_t *pws, __global kernel_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)
636 {
637   /**
638    * base
639    */
640
641   const u32 gid = get_global_id (0);
642
643   u32 w[16];
644
645   w[ 0] = pws[gid].i[ 0];
646   w[ 1] = pws[gid].i[ 1];
647   w[ 2] = pws[gid].i[ 2];
648   w[ 3] = pws[gid].i[ 3];
649   w[ 4] = pws[gid].i[ 4];
650   w[ 5] = pws[gid].i[ 5];
651   w[ 6] = pws[gid].i[ 6];
652   w[ 7] = pws[gid].i[ 7];
653   w[ 8] = 0;
654   w[ 9] = 0;
655   w[10] = 0;
656   w[11] = 0;
657   w[12] = 0;
658   w[13] = 0;
659   w[14] = 0;
660   w[15] = 0;
661
662   const u32 pw_len = pws[gid].pw_len;
663
664   __local u32 w_s1[64];
665   __local u32 w_s2[64];
666
667   /**
668    * main
669    */
670
671   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);
672 }
673
674 __kernel void m08000_s16 (__global pw_t *pws, __global kernel_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)
675 {
676   /**
677    * base
678    */
679
680   const u32 gid = get_global_id (0);
681
682   u32 w[16];
683
684   w[ 0] = pws[gid].i[ 0];
685   w[ 1] = pws[gid].i[ 1];
686   w[ 2] = pws[gid].i[ 2];
687   w[ 3] = pws[gid].i[ 3];
688   w[ 4] = pws[gid].i[ 4];
689   w[ 5] = pws[gid].i[ 5];
690   w[ 6] = pws[gid].i[ 6];
691   w[ 7] = pws[gid].i[ 7];
692   w[ 8] = pws[gid].i[ 8];
693   w[ 9] = pws[gid].i[ 9];
694   w[10] = pws[gid].i[10];
695   w[11] = pws[gid].i[11];
696   w[12] = pws[gid].i[12];
697   w[13] = pws[gid].i[13];
698   w[14] = pws[gid].i[14];
699   w[15] = pws[gid].i[15];
700
701   const u32 pw_len = pws[gid].pw_len;
702
703   __local u32 w_s1[64];
704   __local u32 w_s2[64];
705
706   /**
707    * main
708    */
709
710   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);
711 }