Initial commit
[hashcat.git] / nv / m01760_a0.cu
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  VLIW2
16 #define VECT_SIZE1
17 #endif
18
19 #define DGST_R0 14
20 #define DGST_R1 15
21 #define DGST_R2 6
22 #define DGST_R3 7
23
24 #include "include/kernel_functions.c"
25 #include "types_nv.c"
26 #include "common_nv.c"
27 #include "include/rp_gpu.h"
28 #include "rp_nv.c"
29
30 #ifdef  VECT_SIZE1
31 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
32 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
33 #endif
34
35 #ifdef  VECT_SIZE2
36 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
37 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
38 #endif
39
40 #ifdef  VECT_SIZE4
41 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
42 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
43 #endif
44
45 __device__ __constant__ gpu_rule_t c_rules[1024];
46
47 __device__ __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 __device__ 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   for (int i = 16; i < 80; i += 16)
142   {
143     ROUND_EXPAND (); ROUND_STEP (i);
144   }
145
146   digest[0] += a;
147   digest[1] += b;
148   digest[2] += c;
149   digest[3] += d;
150   digest[4] += e;
151   digest[5] += f;
152   digest[6] += g;
153   digest[7] += h;
154 }
155
156 __device__ static void hmac_sha512_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u64x ipad[8], u64x opad[8])
157 {
158   u64x w0_t[4];
159   u64x w1_t[4];
160   u64x w2_t[4];
161   u64x w3_t[4];
162
163   w0_t[0] = hl32_to_64 (w0[0], w0[1]) ^ 0x3636363636363636;
164   w0_t[1] = hl32_to_64 (w0[2], w0[3]) ^ 0x3636363636363636;
165   w0_t[2] = hl32_to_64 (w1[0], w1[1]) ^ 0x3636363636363636;
166   w0_t[3] = hl32_to_64 (w1[2], w1[3]) ^ 0x3636363636363636;
167   w1_t[0] = hl32_to_64 (w2[0], w2[1]) ^ 0x3636363636363636;
168   w1_t[1] = hl32_to_64 (w2[2], w2[3]) ^ 0x3636363636363636;
169   w1_t[2] = hl32_to_64 (w3[0], w3[1]) ^ 0x3636363636363636;
170   w1_t[3] = hl32_to_64 (w3[2], w3[3]) ^ 0x3636363636363636;
171   w2_t[0] =                                 0 ^ 0x3636363636363636;
172   w2_t[1] =                                 0 ^ 0x3636363636363636;
173   w2_t[2] =                                 0 ^ 0x3636363636363636;
174   w2_t[3] =                                 0 ^ 0x3636363636363636;
175   w3_t[0] =                                 0 ^ 0x3636363636363636;
176   w3_t[1] =                                 0 ^ 0x3636363636363636;
177   w3_t[2] =                                 0 ^ 0x3636363636363636;
178   w3_t[3] =                                 0 ^ 0x3636363636363636;
179
180   ipad[0] = SHA512M_A;
181   ipad[1] = SHA512M_B;
182   ipad[2] = SHA512M_C;
183   ipad[3] = SHA512M_D;
184   ipad[4] = SHA512M_E;
185   ipad[5] = SHA512M_F;
186   ipad[6] = SHA512M_G;
187   ipad[7] = SHA512M_H;
188
189   sha512_transform (w0_t, w1_t, w2_t, w3_t, ipad);
190
191   w0_t[0] = hl32_to_64 (w0[0], w0[1]) ^ 0x5c5c5c5c5c5c5c5c;
192   w0_t[1] = hl32_to_64 (w0[2], w0[3]) ^ 0x5c5c5c5c5c5c5c5c;
193   w0_t[2] = hl32_to_64 (w1[0], w1[1]) ^ 0x5c5c5c5c5c5c5c5c;
194   w0_t[3] = hl32_to_64 (w1[2], w1[3]) ^ 0x5c5c5c5c5c5c5c5c;
195   w1_t[0] = hl32_to_64 (w2[0], w2[1]) ^ 0x5c5c5c5c5c5c5c5c;
196   w1_t[1] = hl32_to_64 (w2[2], w2[3]) ^ 0x5c5c5c5c5c5c5c5c;
197   w1_t[2] = hl32_to_64 (w3[0], w3[1]) ^ 0x5c5c5c5c5c5c5c5c;
198   w1_t[3] = hl32_to_64 (w3[2], w3[3]) ^ 0x5c5c5c5c5c5c5c5c;
199   w2_t[0] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
200   w2_t[1] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
201   w2_t[2] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
202   w2_t[3] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
203   w3_t[0] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
204   w3_t[1] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
205   w3_t[2] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
206   w3_t[3] =                                 0 ^ 0x5c5c5c5c5c5c5c5c;
207
208   opad[0] = SHA512M_A;
209   opad[1] = SHA512M_B;
210   opad[2] = SHA512M_C;
211   opad[3] = SHA512M_D;
212   opad[4] = SHA512M_E;
213   opad[5] = SHA512M_F;
214   opad[6] = SHA512M_G;
215   opad[7] = SHA512M_H;
216
217   sha512_transform (w0_t, w1_t, w2_t, w3_t, opad);
218 }
219
220 __device__ 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])
221 {
222   u64x w0_t[4];
223   u64x w1_t[4];
224   u64x w2_t[4];
225   u64x w3_t[4];
226
227   w0_t[0] = hl32_to_64 (w0[0], w0[1]);
228   w0_t[1] = hl32_to_64 (w0[2], w0[3]);
229   w0_t[2] = hl32_to_64 (w1[0], w1[1]);
230   w0_t[3] = hl32_to_64 (w1[2], w1[3]);
231   w1_t[0] = hl32_to_64 (w2[0], w2[1]);
232   w1_t[1] = hl32_to_64 (w2[2], w2[3]);
233   w1_t[2] = hl32_to_64 (w3[0], w3[1]);
234   w1_t[3] = 0;
235   w2_t[0] = 0;
236   w2_t[1] = 0;
237   w2_t[2] = 0;
238   w2_t[3] = 0;
239   w3_t[0] = 0;
240   w3_t[1] = 0;
241   w3_t[2] = 0;
242   w3_t[3] = hl32_to_64 (w3[2], w3[3]);
243
244   digest[0] = ipad[0];
245   digest[1] = ipad[1];
246   digest[2] = ipad[2];
247   digest[3] = ipad[3];
248   digest[4] = ipad[4];
249   digest[5] = ipad[5];
250   digest[6] = ipad[6];
251   digest[7] = ipad[7];
252
253   sha512_transform (w0_t, w1_t, w2_t, w3_t, digest);
254
255   w0_t[0] = digest[0];
256   w0_t[1] = digest[1];
257   w0_t[2] = digest[2];
258   w0_t[3] = digest[3];
259   w1_t[0] = digest[4];
260   w1_t[1] = digest[5];
261   w1_t[2] = digest[6];
262   w1_t[3] = digest[7];
263   w2_t[0] = 0x8000000000000000;
264   w2_t[1] = 0;
265   w2_t[2] = 0;
266   w2_t[3] = 0;
267   w3_t[0] = 0;
268   w3_t[1] = 0;
269   w3_t[2] = 0;
270   w3_t[3] = (128 + 64) * 8;
271
272   digest[0] = opad[0];
273   digest[1] = opad[1];
274   digest[2] = opad[2];
275   digest[3] = opad[3];
276   digest[4] = opad[4];
277   digest[5] = opad[5];
278   digest[6] = opad[6];
279   digest[7] = opad[7];
280
281   sha512_transform (w0_t, w1_t, w2_t, w3_t, digest);
282 }
283
284 extern "C" __global__ void __launch_bounds__ (256, 1) m01760_m04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
285 {
286   /**
287    * modifier
288    */
289
290   const u32 lid = threadIdx.x;
291
292   /**
293    * base
294    */
295
296   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
297
298   if (gid >= gid_max) return;
299
300   u32x pw_buf0[4];
301
302   pw_buf0[0] = pws[gid].i[ 0];
303   pw_buf0[1] = pws[gid].i[ 1];
304   pw_buf0[2] = pws[gid].i[ 2];
305   pw_buf0[3] = pws[gid].i[ 3];
306
307   u32x pw_buf1[4];
308
309   pw_buf1[0] = pws[gid].i[ 4];
310   pw_buf1[1] = pws[gid].i[ 5];
311   pw_buf1[2] = pws[gid].i[ 6];
312   pw_buf1[3] = pws[gid].i[ 7];
313
314   const u32 pw_len = pws[gid].pw_len;
315
316   /**
317    * salt
318    */
319
320   u32 salt_buf0[4];
321
322   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
323   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
324   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
325   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
326
327   u32 salt_buf1[4];
328
329   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
330   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
331   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
332   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
333
334   /**
335    * pads
336    */
337
338   u32x w0_t[4];
339
340   w0_t[0] = swap_workaround (salt_buf0[0]);
341   w0_t[1] = swap_workaround (salt_buf0[1]);
342   w0_t[2] = swap_workaround (salt_buf0[2]);
343   w0_t[3] = swap_workaround (salt_buf0[3]);
344
345   u32x w1_t[4];
346
347   w1_t[0] = swap_workaround (salt_buf1[0]);
348   w1_t[1] = swap_workaround (salt_buf1[1]);
349   w1_t[2] = swap_workaround (salt_buf1[2]);
350   w1_t[3] = swap_workaround (salt_buf1[3]);
351
352   u32x w2_t[4];
353
354   w2_t[0] = 0;
355   w2_t[1] = 0;
356   w2_t[2] = 0;
357   w2_t[3] = 0;
358
359   u32x w3_t[4];
360
361   w3_t[0] = 0;
362   w3_t[1] = 0;
363   w3_t[2] = 0;
364   w3_t[3] = 0;
365
366   u64x ipad[8];
367   u64x opad[8];
368
369   hmac_sha512_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
370
371   /**
372    * loop
373    */
374
375   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
376   {
377     u32x w0[4];
378
379     w0[0] = pw_buf0[0];
380     w0[1] = pw_buf0[1];
381     w0[2] = pw_buf0[2];
382     w0[3] = pw_buf0[3];
383
384     u32x w1[4];
385
386     w1[0] = pw_buf1[0];
387     w1[1] = pw_buf1[1];
388     w1[2] = pw_buf1[2];
389     w1[3] = pw_buf1[3];
390
391     u32x w2[4];
392
393     w2[0] = 0;
394     w2[1] = 0;
395     w2[2] = 0;
396     w2[3] = 0;
397
398     u32x w3[4];
399
400     w3[0] = 0;
401     w3[1] = 0;
402     w3[2] = 0;
403     w3[3] = 0;
404
405     const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
406
407     append_0x80_2 (w0, w1, out_len);
408
409     w0_t[0] = swap_workaround (w0[0]);
410     w0_t[1] = swap_workaround (w0[1]);
411     w0_t[2] = swap_workaround (w0[2]);
412     w0_t[3] = swap_workaround (w0[3]);
413     w1_t[0] = swap_workaround (w1[0]);
414     w1_t[1] = swap_workaround (w1[1]);
415     w1_t[2] = swap_workaround (w1[2]);
416     w1_t[3] = swap_workaround (w1[3]);
417     w2_t[0] = 0;
418     w2_t[1] = 0;
419     w2_t[2] = 0;
420     w2_t[3] = 0;
421     w3_t[0] = 0;
422     w3_t[1] = 0;
423     w3_t[2] = 0;
424     w3_t[3] = (128 + out_len) * 8;
425
426     u64x digest[8];
427
428     hmac_sha512_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
429
430
431     const u32x r0 = l32_from_64 (digest[7]);
432     const u32x r1 = h32_from_64 (digest[7]);
433     const u32x r2 = l32_from_64 (digest[3]);
434     const u32x r3 = h32_from_64 (digest[3]);
435
436     #include VECT_COMPARE_M
437   }
438 }
439
440 extern "C" __global__ void __launch_bounds__ (256, 1) m01760_m08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
441 {
442 }
443
444 extern "C" __global__ void __launch_bounds__ (256, 1) m01760_m16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
445 {
446 }
447
448 extern "C" __global__ void __launch_bounds__ (256, 1) m01760_s04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
449 {
450   /**
451    * modifier
452    */
453
454   const u32 lid = threadIdx.x;
455
456   /**
457    * base
458    */
459
460   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
461
462   if (gid >= gid_max) return;
463
464   u32x pw_buf0[4];
465
466   pw_buf0[0] = pws[gid].i[ 0];
467   pw_buf0[1] = pws[gid].i[ 1];
468   pw_buf0[2] = pws[gid].i[ 2];
469   pw_buf0[3] = pws[gid].i[ 3];
470
471   u32x pw_buf1[4];
472
473   pw_buf1[0] = pws[gid].i[ 4];
474   pw_buf1[1] = pws[gid].i[ 5];
475   pw_buf1[2] = pws[gid].i[ 6];
476   pw_buf1[3] = pws[gid].i[ 7];
477
478   const u32 pw_len = pws[gid].pw_len;
479
480   /**
481    * salt
482    */
483
484   u32 salt_buf0[4];
485
486   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
487   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
488   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
489   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
490
491   u32 salt_buf1[4];
492
493   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
494   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
495   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
496   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
497
498   /**
499    * pads
500    */
501
502   u32x w0_t[4];
503
504   w0_t[0] = swap_workaround (salt_buf0[0]);
505   w0_t[1] = swap_workaround (salt_buf0[1]);
506   w0_t[2] = swap_workaround (salt_buf0[2]);
507   w0_t[3] = swap_workaround (salt_buf0[3]);
508
509   u32x w1_t[4];
510
511   w1_t[0] = swap_workaround (salt_buf1[0]);
512   w1_t[1] = swap_workaround (salt_buf1[1]);
513   w1_t[2] = swap_workaround (salt_buf1[2]);
514   w1_t[3] = swap_workaround (salt_buf1[3]);
515
516   u32x w2_t[4];
517
518   w2_t[0] = 0;
519   w2_t[1] = 0;
520   w2_t[2] = 0;
521   w2_t[3] = 0;
522
523   u32x w3_t[4];
524
525   w3_t[0] = 0;
526   w3_t[1] = 0;
527   w3_t[2] = 0;
528   w3_t[3] = 0;
529
530   u64x ipad[8];
531   u64x opad[8];
532
533   hmac_sha512_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
534
535   /**
536    * digest
537    */
538
539   const u32 search[4] =
540   {
541     digests_buf[digests_offset].digest_buf[DGST_R0],
542     digests_buf[digests_offset].digest_buf[DGST_R1],
543     digests_buf[digests_offset].digest_buf[DGST_R2],
544     digests_buf[digests_offset].digest_buf[DGST_R3]
545   };
546
547   /**
548    * loop
549    */
550
551   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
552   {
553     u32x w0[4];
554
555     w0[0] = pw_buf0[0];
556     w0[1] = pw_buf0[1];
557     w0[2] = pw_buf0[2];
558     w0[3] = pw_buf0[3];
559
560     u32x w1[4];
561
562     w1[0] = pw_buf1[0];
563     w1[1] = pw_buf1[1];
564     w1[2] = pw_buf1[2];
565     w1[3] = pw_buf1[3];
566
567     u32x w2[4];
568
569     w2[0] = 0;
570     w2[1] = 0;
571     w2[2] = 0;
572     w2[3] = 0;
573
574     u32x w3[4];
575
576     w3[0] = 0;
577     w3[1] = 0;
578     w3[2] = 0;
579     w3[3] = 0;
580
581     const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
582
583     append_0x80_2 (w0, w1, out_len);
584
585     w0_t[0] = swap_workaround (w0[0]);
586     w0_t[1] = swap_workaround (w0[1]);
587     w0_t[2] = swap_workaround (w0[2]);
588     w0_t[3] = swap_workaround (w0[3]);
589     w1_t[0] = swap_workaround (w1[0]);
590     w1_t[1] = swap_workaround (w1[1]);
591     w1_t[2] = swap_workaround (w1[2]);
592     w1_t[3] = swap_workaround (w1[3]);
593     w2_t[0] = 0;
594     w2_t[1] = 0;
595     w2_t[2] = 0;
596     w2_t[3] = 0;
597     w3_t[0] = 0;
598     w3_t[1] = 0;
599     w3_t[2] = 0;
600     w3_t[3] = (128 + out_len) * 8;
601
602     u64x digest[8];
603
604     hmac_sha512_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
605
606
607     const u32x r0 = l32_from_64 (digest[7]);
608     const u32x r1 = h32_from_64 (digest[7]);
609     const u32x r2 = l32_from_64 (digest[3]);
610     const u32x r3 = h32_from_64 (digest[3]);
611
612     #include VECT_COMPARE_S
613   }
614 }
615
616 extern "C" __global__ void __launch_bounds__ (256, 1) m01760_s08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
617 {
618 }
619
620 extern "C" __global__ void __launch_bounds__ (256, 1) m01760_s16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const void *esalt_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
621 {
622 }