Initial commit
[hashcat.git] / amd / m01760_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _SHA512_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW4
16 #define VECT_SIZE1
17 #endif
18
19 #ifdef  VLIW5
20 #define VECT_SIZE1
21 #endif
22
23 #define DGST_R0 14
24 #define DGST_R1 15
25 #define DGST_R2 6
26 #define DGST_R3 7
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 u64 k_sha512[80] =
48 {
49   SHA512C00, SHA512C01, SHA512C02, SHA512C03,
50   SHA512C04, SHA512C05, SHA512C06, SHA512C07,
51   SHA512C08, SHA512C09, SHA512C0a, SHA512C0b,
52   SHA512C0c, SHA512C0d, SHA512C0e, SHA512C0f,
53   SHA512C10, SHA512C11, SHA512C12, SHA512C13,
54   SHA512C14, SHA512C15, SHA512C16, SHA512C17,
55   SHA512C18, SHA512C19, SHA512C1a, SHA512C1b,
56   SHA512C1c, SHA512C1d, SHA512C1e, SHA512C1f,
57   SHA512C20, SHA512C21, SHA512C22, SHA512C23,
58   SHA512C24, SHA512C25, SHA512C26, SHA512C27,
59   SHA512C28, SHA512C29, SHA512C2a, SHA512C2b,
60   SHA512C2c, SHA512C2d, SHA512C2e, SHA512C2f,
61   SHA512C30, SHA512C31, SHA512C32, SHA512C33,
62   SHA512C34, SHA512C35, SHA512C36, SHA512C37,
63   SHA512C38, SHA512C39, SHA512C3a, SHA512C3b,
64   SHA512C3c, SHA512C3d, SHA512C3e, SHA512C3f,
65   SHA512C40, SHA512C41, SHA512C42, SHA512C43,
66   SHA512C44, SHA512C45, SHA512C46, SHA512C47,
67   SHA512C48, SHA512C49, SHA512C4a, SHA512C4b,
68   SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f,
69 };
70
71 static void sha512_transform (const u64x w0[4], const u64x w1[4], const u64x w2[4], const u64x w3[4], u64x digest[8])
72 {
73   u64x w0_t = w0[0];
74   u64x w1_t = w0[1];
75   u64x w2_t = w0[2];
76   u64x w3_t = w0[3];
77   u64x w4_t = w1[0];
78   u64x w5_t = w1[1];
79   u64x w6_t = w1[2];
80   u64x w7_t = w1[3];
81   u64x w8_t = w2[0];
82   u64x w9_t = w2[1];
83   u64x wa_t = w2[2];
84   u64x wb_t = w2[3];
85   u64x wc_t = w3[0];
86   u64x wd_t = w3[1];
87   u64x we_t = w3[2];
88   u64x wf_t = w3[3];
89
90   u64x a = digest[0];
91   u64x b = digest[1];
92   u64x c = digest[2];
93   u64x d = digest[3];
94   u64x e = digest[4];
95   u64x f = digest[5];
96   u64x g = digest[6];
97   u64x h = digest[7];
98
99   #define ROUND_EXPAND()                            \
100   {                                                 \
101     w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t);  \
102     w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t);  \
103     w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t);  \
104     w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t);  \
105     w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t);  \
106     w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t);  \
107     w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t);  \
108     w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t);  \
109     w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t);  \
110     w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t);  \
111     wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t);  \
112     wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t);  \
113     wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t);  \
114     wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t);  \
115     we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t);  \
116     wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t);  \
117   }
118
119   #define ROUND_STEP(i)                                                                   \
120   {                                                                                       \
121     SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha512[i +  0]); \
122     SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha512[i +  1]); \
123     SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha512[i +  2]); \
124     SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha512[i +  3]); \
125     SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha512[i +  4]); \
126     SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha512[i +  5]); \
127     SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha512[i +  6]); \
128     SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha512[i +  7]); \
129     SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha512[i +  8]); \
130     SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha512[i +  9]); \
131     SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha512[i + 10]); \
132     SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha512[i + 11]); \
133     SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha512[i + 12]); \
134     SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha512[i + 13]); \
135     SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k_sha512[i + 14]); \
136     SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha512[i + 15]); \
137   }
138
139   ROUND_STEP (0);
140
141   //#pragma unroll // kernel fails if used
142   for (int i = 16; i < 80; i += 16)
143   {
144     ROUND_EXPAND (); ROUND_STEP (i);
145   }
146
147   digest[0] += a;
148   digest[1] += b;
149   digest[2] += c;
150   digest[3] += d;
151   digest[4] += e;
152   digest[5] += f;
153   digest[6] += g;
154   digest[7] += h;
155 }
156
157 static void hmac_sha512_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u64x ipad[8], u64x opad[8])
158 {
159   u64x w0_t[4];
160   u64x w1_t[4];
161   u64x w2_t[4];
162   u64x w3_t[4];
163
164   w0_t[0] = hl32_to_64 (w0[0], w0[1]) ^ 0x3636363636363636;
165   w0_t[1] = hl32_to_64 (w0[2], w0[3]) ^ 0x3636363636363636;
166   w0_t[2] = hl32_to_64 (w1[0], w1[1]) ^ 0x3636363636363636;
167   w0_t[3] = hl32_to_64 (w1[2], w1[3]) ^ 0x3636363636363636;
168   w1_t[0] = hl32_to_64 (w2[0], w2[1]) ^ 0x3636363636363636;
169   w1_t[1] = hl32_to_64 (w2[2], w2[3]) ^ 0x3636363636363636;
170   w1_t[2] = hl32_to_64 (w3[0], w3[1]) ^ 0x3636363636363636;
171   w1_t[3] = hl32_to_64 (w3[2], w3[3]) ^ 0x3636363636363636;
172   w2_t[0] =                                 0 ^ 0x3636363636363636;
173   w2_t[1] =                                 0 ^ 0x3636363636363636;
174   w2_t[2] =                                 0 ^ 0x3636363636363636;
175   w2_t[3] =                                 0 ^ 0x3636363636363636;
176   w3_t[0] =                                 0 ^ 0x3636363636363636;
177   w3_t[1] =                                 0 ^ 0x3636363636363636;
178   w3_t[2] =                                 0 ^ 0x3636363636363636;
179   w3_t[3] =                                 0 ^ 0x3636363636363636;
180
181   ipad[0] = SHA512M_A;
182   ipad[1] = SHA512M_B;
183   ipad[2] = SHA512M_C;
184   ipad[3] = SHA512M_D;
185   ipad[4] = SHA512M_E;
186   ipad[5] = SHA512M_F;
187   ipad[6] = SHA512M_G;
188   ipad[7] = SHA512M_H;
189
190   sha512_transform (w0_t, w1_t, w2_t, w3_t, ipad);
191
192   w0_t[0] = hl32_to_64 (w0[0], w0[1]) ^ 0x5c5c5c5c5c5c5c5c;
193   w0_t[1] = hl32_to_64 (w0[2], w0[3]) ^ 0x5c5c5c5c5c5c5c5c;
194   w0_t[2] = hl32_to_64 (w1[0], w1[1]) ^ 0x5c5c5c5c5c5c5c5c;
195   w0_t[3] = hl32_to_64 (w1[2], w1[3]) ^ 0x5c5c5c5c5c5c5c5c;
196   w1_t[0] = hl32_to_64 (w2[0], w2[1]) ^ 0x5c5c5c5c5c5c5c5c;
197   w1_t[1] = hl32_to_64 (w2[2], w2[3]) ^ 0x5c5c5c5c5c5c5c5c;
198   w1_t[2] = hl32_to_64 (w3[0], w3[1]) ^ 0x5c5c5c5c5c5c5c5c;
199   w1_t[3] = hl32_to_64 (w3[2], w3[3]) ^ 0x5c5c5c5c5c5c5c5c;
200   w2_t[0] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
201   w2_t[1] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
202   w2_t[2] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
203   w2_t[3] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
204   w3_t[0] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
205   w3_t[1] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
206   w3_t[2] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
207   w3_t[3] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
208
209   opad[0] = SHA512M_A;
210   opad[1] = SHA512M_B;
211   opad[2] = SHA512M_C;
212   opad[3] = SHA512M_D;
213   opad[4] = SHA512M_E;
214   opad[5] = SHA512M_F;
215   opad[6] = SHA512M_G;
216   opad[7] = SHA512M_H;
217
218   sha512_transform (w0_t, w1_t, w2_t, w3_t, opad);
219 }
220
221 static void hmac_sha512_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u64x ipad[8], u64x opad[8], u64x digest[8])
222 {
223   u64x w0_t[4];
224   u64x w1_t[4];
225   u64x w2_t[4];
226   u64x w3_t[4];
227
228   w0_t[0] = hl32_to_64 (w0[0], w0[1]);
229   w0_t[1] = hl32_to_64 (w0[2], w0[3]);
230   w0_t[2] = hl32_to_64 (w1[0], w1[1]);
231   w0_t[3] = hl32_to_64 (w1[2], w1[3]);
232   w1_t[0] = hl32_to_64 (w2[0], w2[1]);
233   w1_t[1] = hl32_to_64 (w2[2], w2[3]);
234   w1_t[2] = hl32_to_64 (w3[0], w3[1]);
235   w1_t[3] = 0;
236   w2_t[0] = 0;
237   w2_t[1] = 0;
238   w2_t[2] = 0;
239   w2_t[3] = 0;
240   w3_t[0] = 0;
241   w3_t[1] = 0;
242   w3_t[2] = 0;
243   w3_t[3] = hl32_to_64 (w3[2], w3[3]);
244
245   digest[0] = ipad[0];
246   digest[1] = ipad[1];
247   digest[2] = ipad[2];
248   digest[3] = ipad[3];
249   digest[4] = ipad[4];
250   digest[5] = ipad[5];
251   digest[6] = ipad[6];
252   digest[7] = ipad[7];
253
254   sha512_transform (w0_t, w1_t, w2_t, w3_t, digest);
255
256   w0_t[0] = digest[0];
257   w0_t[1] = digest[1];
258   w0_t[2] = digest[2];
259   w0_t[3] = digest[3];
260   w1_t[0] = digest[4];
261   w1_t[1] = digest[5];
262   w1_t[2] = digest[6];
263   w1_t[3] = digest[7];
264   w2_t[0] = 0x8000000000000000;
265   w2_t[1] = 0;
266   w2_t[2] = 0;
267   w2_t[3] = 0;
268   w3_t[0] = 0;
269   w3_t[1] = 0;
270   w3_t[2] = 0;
271   w3_t[3] = (128 + 64) * 8;
272
273   digest[0] = opad[0];
274   digest[1] = opad[1];
275   digest[2] = opad[2];
276   digest[3] = opad[3];
277   digest[4] = opad[4];
278   digest[5] = opad[5];
279   digest[6] = opad[6];
280   digest[7] = opad[7];
281
282   sha512_transform (w0_t, w1_t, w2_t, w3_t, digest);
283 }
284
285 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01760_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)
286 {
287   /**
288    * modifier
289    */
290
291   const u32 lid = get_local_id (0);
292
293   /**
294    * base
295    */
296
297   const u32 gid = get_global_id (0);
298
299   if (gid >= gid_max) return;
300
301   u32x wordl0[4];
302
303   wordl0[0] = pws[gid].i[ 0];
304   wordl0[1] = pws[gid].i[ 1];
305   wordl0[2] = pws[gid].i[ 2];
306   wordl0[3] = pws[gid].i[ 3];
307
308   u32x wordl1[4];
309
310   wordl1[0] = pws[gid].i[ 4];
311   wordl1[1] = pws[gid].i[ 5];
312   wordl1[2] = pws[gid].i[ 6];
313   wordl1[3] = pws[gid].i[ 7];
314
315   u32x wordl2[4];
316
317   wordl2[0] = 0;
318   wordl2[1] = 0;
319   wordl2[2] = 0;
320   wordl2[3] = 0;
321
322   u32x wordl3[4];
323
324   wordl3[0] = 0;
325   wordl3[1] = 0;
326   wordl3[2] = 0;
327   wordl3[3] = 0;
328
329   const u32 pw_l_len = pws[gid].pw_len;
330
331   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
332   {
333     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
334   }
335
336   /**
337    * salt
338    */
339
340   u32 salt_buf0[4];
341
342   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
343   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
344   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
345   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
346
347   u32 salt_buf1[4];
348
349   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
350   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
351   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
352   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
353
354   /**
355    * pads
356    */
357
358   u32x w0_t[4];
359
360   w0_t[0] = swap_workaround (salt_buf0[0]);
361   w0_t[1] = swap_workaround (salt_buf0[1]);
362   w0_t[2] = swap_workaround (salt_buf0[2]);
363   w0_t[3] = swap_workaround (salt_buf0[3]);
364
365   u32x w1_t[4];
366
367   w1_t[0] = swap_workaround (salt_buf1[0]);
368   w1_t[1] = swap_workaround (salt_buf1[1]);
369   w1_t[2] = swap_workaround (salt_buf1[2]);
370   w1_t[3] = swap_workaround (salt_buf1[3]);
371
372   u32x w2_t[4];
373
374   w2_t[0] = 0;
375   w2_t[1] = 0;
376   w2_t[2] = 0;
377   w2_t[3] = 0;
378
379   u32x w3_t[4];
380
381   w3_t[0] = 0;
382   w3_t[1] = 0;
383   w3_t[2] = 0;
384   w3_t[3] = 0;
385
386   u64x ipad[8];
387   u64x opad[8];
388
389   hmac_sha512_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
390
391   /**
392    * loop
393    */
394
395   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
396   {
397     const u32 pw_r_len = combs_buf[il_pos].pw_len;
398
399     const u32 pw_len = pw_l_len + pw_r_len;
400
401     u32 wordr0[4];
402
403     wordr0[0] = combs_buf[il_pos].i[0];
404     wordr0[1] = combs_buf[il_pos].i[1];
405     wordr0[2] = combs_buf[il_pos].i[2];
406     wordr0[3] = combs_buf[il_pos].i[3];
407
408     u32 wordr1[4];
409
410     wordr1[0] = combs_buf[il_pos].i[4];
411     wordr1[1] = combs_buf[il_pos].i[5];
412     wordr1[2] = combs_buf[il_pos].i[6];
413     wordr1[3] = combs_buf[il_pos].i[7];
414
415     u32 wordr2[4];
416
417     wordr2[0] = 0;
418     wordr2[1] = 0;
419     wordr2[2] = 0;
420     wordr2[3] = 0;
421
422     u32 wordr3[4];
423
424     wordr3[0] = 0;
425     wordr3[1] = 0;
426     wordr3[2] = 0;
427     wordr3[3] = 0;
428
429     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
430     {
431       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
432     }
433
434     u32x w0[4];
435
436     w0[0] = wordl0[0] | wordr0[0];
437     w0[1] = wordl0[1] | wordr0[1];
438     w0[2] = wordl0[2] | wordr0[2];
439     w0[3] = wordl0[3] | wordr0[3];
440
441     u32x w1[4];
442
443     w1[0] = wordl1[0] | wordr1[0];
444     w1[1] = wordl1[1] | wordr1[1];
445     w1[2] = wordl1[2] | wordr1[2];
446     w1[3] = wordl1[3] | wordr1[3];
447
448     u32x w2[4];
449
450     w2[0] = wordl2[0] | wordr2[0];
451     w2[1] = wordl2[1] | wordr2[1];
452     w2[2] = wordl2[2] | wordr2[2];
453     w2[3] = wordl2[3] | wordr2[3];
454
455     u32x w3[4];
456
457     w3[0] = wordl3[0] | wordr3[0];
458     w3[1] = wordl3[1] | wordr3[1];
459     w3[2] = 0;
460     w3[3] = 0;
461
462     append_0x80_4 (w0, w1, w2, w3, pw_len);
463
464     w0_t[0] = swap_workaround (w0[0]);
465     w0_t[1] = swap_workaround (w0[1]);
466     w0_t[2] = swap_workaround (w0[2]);
467     w0_t[3] = swap_workaround (w0[3]);
468     w1_t[0] = swap_workaround (w1[0]);
469     w1_t[1] = swap_workaround (w1[1]);
470     w1_t[2] = swap_workaround (w1[2]);
471     w1_t[3] = swap_workaround (w1[3]);
472     w2_t[0] = swap_workaround (w2[0]);
473     w2_t[1] = swap_workaround (w2[1]);
474     w2_t[2] = swap_workaround (w2[2]);
475     w2_t[3] = swap_workaround (w2[3]);
476     w3_t[0] = swap_workaround (w3[0]);
477     w3_t[1] = swap_workaround (w3[1]);
478     w3_t[2] = 0;
479     w3_t[3] = (128 + pw_len) * 8;
480
481     u64x digest[8];
482
483     hmac_sha512_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
484
485
486     const u32x r0 = l32_from_64 (digest[7]);
487     const u32x r1 = h32_from_64 (digest[7]);
488     const u32x r2 = l32_from_64 (digest[3]);
489     const u32x r3 = h32_from_64 (digest[3]);
490
491     #include VECT_COMPARE_M
492   }
493 }
494
495 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01760_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)
496 {
497 }
498
499 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01760_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)
500 {
501 }
502
503 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01760_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)
504 {
505   /**
506    * modifier
507    */
508
509   const u32 lid = get_local_id (0);
510
511   /**
512    * base
513    */
514
515   const u32 gid = get_global_id (0);
516
517   if (gid >= gid_max) return;
518
519   u32x wordl0[4];
520
521   wordl0[0] = pws[gid].i[ 0];
522   wordl0[1] = pws[gid].i[ 1];
523   wordl0[2] = pws[gid].i[ 2];
524   wordl0[3] = pws[gid].i[ 3];
525
526   u32x wordl1[4];
527
528   wordl1[0] = pws[gid].i[ 4];
529   wordl1[1] = pws[gid].i[ 5];
530   wordl1[2] = pws[gid].i[ 6];
531   wordl1[3] = pws[gid].i[ 7];
532
533   u32x wordl2[4];
534
535   wordl2[0] = 0;
536   wordl2[1] = 0;
537   wordl2[2] = 0;
538   wordl2[3] = 0;
539
540   u32x wordl3[4];
541
542   wordl3[0] = 0;
543   wordl3[1] = 0;
544   wordl3[2] = 0;
545   wordl3[3] = 0;
546
547   const u32 pw_l_len = pws[gid].pw_len;
548
549   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
550   {
551     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
552   }
553
554   /**
555    * salt
556    */
557
558   u32 salt_buf0[4];
559
560   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
561   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
562   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
563   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
564
565   u32 salt_buf1[4];
566
567   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
568   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
569   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
570   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
571
572   /**
573    * pads
574    */
575
576   u32x w0_t[4];
577
578   w0_t[0] = swap_workaround (salt_buf0[0]);
579   w0_t[1] = swap_workaround (salt_buf0[1]);
580   w0_t[2] = swap_workaround (salt_buf0[2]);
581   w0_t[3] = swap_workaround (salt_buf0[3]);
582
583   u32x w1_t[4];
584
585   w1_t[0] = swap_workaround (salt_buf1[0]);
586   w1_t[1] = swap_workaround (salt_buf1[1]);
587   w1_t[2] = swap_workaround (salt_buf1[2]);
588   w1_t[3] = swap_workaround (salt_buf1[3]);
589
590   u32x w2_t[4];
591
592   w2_t[0] = 0;
593   w2_t[1] = 0;
594   w2_t[2] = 0;
595   w2_t[3] = 0;
596
597   u32x w3_t[4];
598
599   w3_t[0] = 0;
600   w3_t[1] = 0;
601   w3_t[2] = 0;
602   w3_t[3] = 0;
603
604   u64x ipad[8];
605   u64x opad[8];
606
607   hmac_sha512_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
608
609   /**
610    * digest
611    */
612
613   const u32 search[4] =
614   {
615     digests_buf[digests_offset].digest_buf[DGST_R0],
616     digests_buf[digests_offset].digest_buf[DGST_R1],
617     digests_buf[digests_offset].digest_buf[DGST_R2],
618     digests_buf[digests_offset].digest_buf[DGST_R3]
619   };
620
621   /**
622    * loop
623    */
624
625   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
626   {
627     const u32 pw_r_len = combs_buf[il_pos].pw_len;
628
629     const u32 pw_len = pw_l_len + pw_r_len;
630
631     u32 wordr0[4];
632
633     wordr0[0] = combs_buf[il_pos].i[0];
634     wordr0[1] = combs_buf[il_pos].i[1];
635     wordr0[2] = combs_buf[il_pos].i[2];
636     wordr0[3] = combs_buf[il_pos].i[3];
637
638     u32 wordr1[4];
639
640     wordr1[0] = combs_buf[il_pos].i[4];
641     wordr1[1] = combs_buf[il_pos].i[5];
642     wordr1[2] = combs_buf[il_pos].i[6];
643     wordr1[3] = combs_buf[il_pos].i[7];
644
645     u32 wordr2[4];
646
647     wordr2[0] = 0;
648     wordr2[1] = 0;
649     wordr2[2] = 0;
650     wordr2[3] = 0;
651
652     u32 wordr3[4];
653
654     wordr3[0] = 0;
655     wordr3[1] = 0;
656     wordr3[2] = 0;
657     wordr3[3] = 0;
658
659     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
660     {
661       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
662     }
663
664     u32x w0[4];
665
666     w0[0] = wordl0[0] | wordr0[0];
667     w0[1] = wordl0[1] | wordr0[1];
668     w0[2] = wordl0[2] | wordr0[2];
669     w0[3] = wordl0[3] | wordr0[3];
670
671     u32x w1[4];
672
673     w1[0] = wordl1[0] | wordr1[0];
674     w1[1] = wordl1[1] | wordr1[1];
675     w1[2] = wordl1[2] | wordr1[2];
676     w1[3] = wordl1[3] | wordr1[3];
677
678     u32x w2[4];
679
680     w2[0] = wordl2[0] | wordr2[0];
681     w2[1] = wordl2[1] | wordr2[1];
682     w2[2] = wordl2[2] | wordr2[2];
683     w2[3] = wordl2[3] | wordr2[3];
684
685     u32x w3[4];
686
687     w3[0] = wordl3[0] | wordr3[0];
688     w3[1] = wordl3[1] | wordr3[1];
689     w3[2] = 0;
690     w3[3] = 0;
691
692     append_0x80_4 (w0, w1, w2, w3, pw_len);
693
694     w0_t[0] = swap_workaround (w0[0]);
695     w0_t[1] = swap_workaround (w0[1]);
696     w0_t[2] = swap_workaround (w0[2]);
697     w0_t[3] = swap_workaround (w0[3]);
698     w1_t[0] = swap_workaround (w1[0]);
699     w1_t[1] = swap_workaround (w1[1]);
700     w1_t[2] = swap_workaround (w1[2]);
701     w1_t[3] = swap_workaround (w1[3]);
702     w2_t[0] = swap_workaround (w2[0]);
703     w2_t[1] = swap_workaround (w2[1]);
704     w2_t[2] = swap_workaround (w2[2]);
705     w2_t[3] = swap_workaround (w2[3]);
706     w3_t[0] = swap_workaround (w3[0]);
707     w3_t[1] = swap_workaround (w3[1]);
708     w3_t[2] = 0;
709     w3_t[3] = (128 + pw_len) * 8;
710
711     u64x digest[8];
712
713     hmac_sha512_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
714
715
716     const u32x r0 = l32_from_64 (digest[7]);
717     const u32x r1 = h32_from_64 (digest[7]);
718     const u32x r2 = l32_from_64 (digest[3]);
719     const u32x r3 = h32_from_64 (digest[3]);
720
721     #include VECT_COMPARE_S
722   }
723 }
724
725 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01760_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)
726 {
727 }
728
729 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01760_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)
730 {
731 }