Initial commit
[hashcat.git] / nv / m01460_a1.cu
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 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW2
16 #define VECT_SIZE1
17 #endif
18
19 #define DGST_R0 3
20 #define DGST_R1 7
21 #define DGST_R2 2
22 #define DGST_R3 6
23
24 #include "include/kernel_functions.c"
25 #include "types_nv.c"
26 #include "common_nv.c"
27
28 #ifdef  VECT_SIZE1
29 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
30 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
31 #endif
32
33 #ifdef  VECT_SIZE2
34 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
35 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
36 #endif
37
38 #ifdef  VECT_SIZE4
39 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
40 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
41 #endif
42
43 __device__ __constant__ u32 k_sha256[64] =
44 {
45   SHA256C00, SHA256C01, SHA256C02, SHA256C03,
46   SHA256C04, SHA256C05, SHA256C06, SHA256C07,
47   SHA256C08, SHA256C09, SHA256C0a, SHA256C0b,
48   SHA256C0c, SHA256C0d, SHA256C0e, SHA256C0f,
49   SHA256C10, SHA256C11, SHA256C12, SHA256C13,
50   SHA256C14, SHA256C15, SHA256C16, SHA256C17,
51   SHA256C18, SHA256C19, SHA256C1a, SHA256C1b,
52   SHA256C1c, SHA256C1d, SHA256C1e, SHA256C1f,
53   SHA256C20, SHA256C21, SHA256C22, SHA256C23,
54   SHA256C24, SHA256C25, SHA256C26, SHA256C27,
55   SHA256C28, SHA256C29, SHA256C2a, SHA256C2b,
56   SHA256C2c, SHA256C2d, SHA256C2e, SHA256C2f,
57   SHA256C30, SHA256C31, SHA256C32, SHA256C33,
58   SHA256C34, SHA256C35, SHA256C36, SHA256C37,
59   SHA256C38, SHA256C39, SHA256C3a, SHA256C3b,
60   SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f,
61 };
62
63 __device__ __constant__ comb_t c_combs[1024];
64
65 __device__ static void sha256_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[8])
66 {
67   u32x a = digest[0];
68   u32x b = digest[1];
69   u32x c = digest[2];
70   u32x d = digest[3];
71   u32x e = digest[4];
72   u32x f = digest[5];
73   u32x g = digest[6];
74   u32x h = digest[7];
75
76   u32x w0_t = w0[0];
77   u32x w1_t = w0[1];
78   u32x w2_t = w0[2];
79   u32x w3_t = w0[3];
80   u32x w4_t = w1[0];
81   u32x w5_t = w1[1];
82   u32x w6_t = w1[2];
83   u32x w7_t = w1[3];
84   u32x w8_t = w2[0];
85   u32x w9_t = w2[1];
86   u32x wa_t = w2[2];
87   u32x wb_t = w2[3];
88   u32x wc_t = w3[0];
89   u32x wd_t = w3[1];
90   u32x we_t = w3[2];
91   u32x wf_t = w3[3];
92
93   #define ROUND_EXPAND()                            \
94   {                                                 \
95     w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t);  \
96     w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t);  \
97     w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t);  \
98     w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t);  \
99     w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t);  \
100     w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t);  \
101     w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t);  \
102     w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t);  \
103     w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t);  \
104     w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t);  \
105     wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t);  \
106     wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t);  \
107     wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t);  \
108     wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t);  \
109     we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t);  \
110     wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t);  \
111   }
112
113   #define ROUND_STEP(i)                                                                   \
114   {                                                                                       \
115     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha256[i +  0]); \
116     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha256[i +  1]); \
117     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha256[i +  2]); \
118     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha256[i +  3]); \
119     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha256[i +  4]); \
120     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha256[i +  5]); \
121     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha256[i +  6]); \
122     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha256[i +  7]); \
123     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha256[i +  8]); \
124     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha256[i +  9]); \
125     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha256[i + 10]); \
126     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha256[i + 11]); \
127     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha256[i + 12]); \
128     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha256[i + 13]); \
129     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, k_sha256[i + 14]); \
130     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha256[i + 15]); \
131   }
132
133   ROUND_STEP (0);
134
135   for (int i = 16; i < 64; i += 16)
136   {
137     ROUND_EXPAND (); ROUND_STEP (i);
138   }
139
140   digest[0] += a;
141   digest[1] += b;
142   digest[2] += c;
143   digest[3] += d;
144   digest[4] += e;
145   digest[5] += f;
146   digest[6] += g;
147   digest[7] += h;
148 }
149
150 __device__ static void hmac_sha256_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[8], u32x opad[8])
151 {
152   w0[0] = w0[0] ^ 0x36363636;
153   w0[1] = w0[1] ^ 0x36363636;
154   w0[2] = w0[2] ^ 0x36363636;
155   w0[3] = w0[3] ^ 0x36363636;
156   w1[0] = w1[0] ^ 0x36363636;
157   w1[1] = w1[1] ^ 0x36363636;
158   w1[2] = w1[2] ^ 0x36363636;
159   w1[3] = w1[3] ^ 0x36363636;
160   w2[0] = w2[0] ^ 0x36363636;
161   w2[1] = w2[1] ^ 0x36363636;
162   w2[2] = w2[2] ^ 0x36363636;
163   w2[3] = w2[3] ^ 0x36363636;
164   w3[0] = w3[0] ^ 0x36363636;
165   w3[1] = w3[1] ^ 0x36363636;
166   w3[2] = w3[2] ^ 0x36363636;
167   w3[3] = w3[3] ^ 0x36363636;
168
169   ipad[0] = SHA256M_A;
170   ipad[1] = SHA256M_B;
171   ipad[2] = SHA256M_C;
172   ipad[3] = SHA256M_D;
173   ipad[4] = SHA256M_E;
174   ipad[5] = SHA256M_F;
175   ipad[6] = SHA256M_G;
176   ipad[7] = SHA256M_H;
177
178   sha256_transform (w0, w1, w2, w3, ipad);
179
180   w0[0] = w0[0] ^ 0x6a6a6a6a;
181   w0[1] = w0[1] ^ 0x6a6a6a6a;
182   w0[2] = w0[2] ^ 0x6a6a6a6a;
183   w0[3] = w0[3] ^ 0x6a6a6a6a;
184   w1[0] = w1[0] ^ 0x6a6a6a6a;
185   w1[1] = w1[1] ^ 0x6a6a6a6a;
186   w1[2] = w1[2] ^ 0x6a6a6a6a;
187   w1[3] = w1[3] ^ 0x6a6a6a6a;
188   w2[0] = w2[0] ^ 0x6a6a6a6a;
189   w2[1] = w2[1] ^ 0x6a6a6a6a;
190   w2[2] = w2[2] ^ 0x6a6a6a6a;
191   w2[3] = w2[3] ^ 0x6a6a6a6a;
192   w3[0] = w3[0] ^ 0x6a6a6a6a;
193   w3[1] = w3[1] ^ 0x6a6a6a6a;
194   w3[2] = w3[2] ^ 0x6a6a6a6a;
195   w3[3] = w3[3] ^ 0x6a6a6a6a;
196
197   opad[0] = SHA256M_A;
198   opad[1] = SHA256M_B;
199   opad[2] = SHA256M_C;
200   opad[3] = SHA256M_D;
201   opad[4] = SHA256M_E;
202   opad[5] = SHA256M_F;
203   opad[6] = SHA256M_G;
204   opad[7] = SHA256M_H;
205
206   sha256_transform (w0, w1, w2, w3, opad);
207 }
208
209 __device__ static void hmac_sha256_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[8], u32x opad[8], u32x digest[8])
210 {
211   digest[0] = ipad[0];
212   digest[1] = ipad[1];
213   digest[2] = ipad[2];
214   digest[3] = ipad[3];
215   digest[4] = ipad[4];
216   digest[5] = ipad[5];
217   digest[6] = ipad[6];
218   digest[7] = ipad[7];
219
220   sha256_transform (w0, w1, w2, w3, digest);
221
222   w0[0] = digest[0];
223   w0[1] = digest[1];
224   w0[2] = digest[2];
225   w0[3] = digest[3];
226   w1[0] = digest[4];
227   w1[1] = digest[5];
228   w1[2] = digest[6];
229   w1[3] = digest[7];
230   w2[0] = 0x80000000;
231   w2[1] = 0;
232   w2[2] = 0;
233   w2[3] = 0;
234   w3[0] = 0;
235   w3[1] = 0;
236   w3[2] = 0;
237   w3[3] = (64 + 32) * 8;
238
239   digest[0] = opad[0];
240   digest[1] = opad[1];
241   digest[2] = opad[2];
242   digest[3] = opad[3];
243   digest[4] = opad[4];
244   digest[5] = opad[5];
245   digest[6] = opad[6];
246   digest[7] = opad[7];
247
248   sha256_transform (w0, w1, w2, w3, digest);
249 }
250
251 extern "C" __global__ void __launch_bounds__ (256, 1) m01460_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
252 {
253   /**
254    * modifier
255    */
256
257   const u32 lid = threadIdx.x;
258
259   /**
260    * base
261    */
262
263   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
264
265   if (gid >= gid_max) return;
266
267   u32x wordl0[4];
268
269   wordl0[0] = pws[gid].i[ 0];
270   wordl0[1] = pws[gid].i[ 1];
271   wordl0[2] = pws[gid].i[ 2];
272   wordl0[3] = pws[gid].i[ 3];
273
274   u32x wordl1[4];
275
276   wordl1[0] = pws[gid].i[ 4];
277   wordl1[1] = pws[gid].i[ 5];
278   wordl1[2] = pws[gid].i[ 6];
279   wordl1[3] = pws[gid].i[ 7];
280
281   u32x wordl2[4];
282
283   wordl2[0] = 0;
284   wordl2[1] = 0;
285   wordl2[2] = 0;
286   wordl2[3] = 0;
287
288   u32x wordl3[4];
289
290   wordl3[0] = 0;
291   wordl3[1] = 0;
292   wordl3[2] = 0;
293   wordl3[3] = 0;
294
295   const u32 pw_l_len = pws[gid].pw_len;
296
297   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
298   {
299     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
300   }
301
302   /**
303    * salt
304    */
305
306   u32 salt_buf0[4];
307
308   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
309   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
310   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
311   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
312
313   u32 salt_buf1[4];
314
315   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
316   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
317   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
318   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
319
320   /**
321    * pads
322    */
323
324   u32x w0_t[4];
325
326   w0_t[0] = swap_workaround (salt_buf0[0]);
327   w0_t[1] = swap_workaround (salt_buf0[1]);
328   w0_t[2] = swap_workaround (salt_buf0[2]);
329   w0_t[3] = swap_workaround (salt_buf0[3]);
330
331   u32x w1_t[4];
332
333   w1_t[0] = swap_workaround (salt_buf1[0]);
334   w1_t[1] = swap_workaround (salt_buf1[1]);
335   w1_t[2] = swap_workaround (salt_buf1[2]);
336   w1_t[3] = swap_workaround (salt_buf1[3]);
337
338   u32x w2_t[4];
339
340   w2_t[0] = 0;
341   w2_t[1] = 0;
342   w2_t[2] = 0;
343   w2_t[3] = 0;
344
345   u32x w3_t[4];
346
347   w3_t[0] = 0;
348   w3_t[1] = 0;
349   w3_t[2] = 0;
350   w3_t[3] = 0;
351
352   u32x ipad[8];
353   u32x opad[8];
354
355   hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
356
357   /**
358    * loop
359    */
360
361   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
362   {
363     const u32 pw_r_len = c_combs[il_pos].pw_len;
364
365     const u32 pw_len = pw_l_len + pw_r_len;
366
367     u32 wordr0[4];
368
369     wordr0[0] = c_combs[il_pos].i[0];
370     wordr0[1] = c_combs[il_pos].i[1];
371     wordr0[2] = c_combs[il_pos].i[2];
372     wordr0[3] = c_combs[il_pos].i[3];
373
374     u32 wordr1[4];
375
376     wordr1[0] = c_combs[il_pos].i[4];
377     wordr1[1] = c_combs[il_pos].i[5];
378     wordr1[2] = c_combs[il_pos].i[6];
379     wordr1[3] = c_combs[il_pos].i[7];
380
381     u32 wordr2[4];
382
383     wordr2[0] = 0;
384     wordr2[1] = 0;
385     wordr2[2] = 0;
386     wordr2[3] = 0;
387
388     u32 wordr3[4];
389
390     wordr3[0] = 0;
391     wordr3[1] = 0;
392     wordr3[2] = 0;
393     wordr3[3] = 0;
394
395     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
396     {
397       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
398     }
399
400     u32x w0[4];
401
402     w0[0] = wordl0[0] | wordr0[0];
403     w0[1] = wordl0[1] | wordr0[1];
404     w0[2] = wordl0[2] | wordr0[2];
405     w0[3] = wordl0[3] | wordr0[3];
406
407     u32x w1[4];
408
409     w1[0] = wordl1[0] | wordr1[0];
410     w1[1] = wordl1[1] | wordr1[1];
411     w1[2] = wordl1[2] | wordr1[2];
412     w1[3] = wordl1[3] | wordr1[3];
413
414     u32x w2[4];
415
416     w2[0] = wordl2[0] | wordr2[0];
417     w2[1] = wordl2[1] | wordr2[1];
418     w2[2] = wordl2[2] | wordr2[2];
419     w2[3] = wordl2[3] | wordr2[3];
420
421     u32x w3[4];
422
423     w3[0] = wordl3[0] | wordr3[0];
424     w3[1] = wordl3[1] | wordr3[1];
425     w3[2] = 0;
426     w3[3] = 0;
427
428     append_0x80_4 (w0, w1, w2, w3, pw_len);
429
430     w0_t[0] = swap_workaround (w0[0]);
431     w0_t[1] = swap_workaround (w0[1]);
432     w0_t[2] = swap_workaround (w0[2]);
433     w0_t[3] = swap_workaround (w0[3]);
434     w1_t[0] = swap_workaround (w1[0]);
435     w1_t[1] = swap_workaround (w1[1]);
436     w1_t[2] = swap_workaround (w1[2]);
437     w1_t[3] = swap_workaround (w1[3]);
438     w2_t[0] = swap_workaround (w2[0]);
439     w2_t[1] = swap_workaround (w2[1]);
440     w2_t[2] = swap_workaround (w2[2]);
441     w2_t[3] = swap_workaround (w2[3]);
442     w3_t[0] = swap_workaround (w3[0]);
443     w3_t[1] = swap_workaround (w3[1]);
444     w3_t[2] = 0;
445     w3_t[3] = (64 + pw_len) * 8;
446
447     u32x digest[8];
448
449     hmac_sha256_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
450
451     const u32x r0 = digest[3];
452     const u32x r1 = digest[7];
453     const u32x r2 = digest[2];
454     const u32x r3 = digest[6];
455
456     #include VECT_COMPARE_M
457   }
458 }
459
460 extern "C" __global__ void __launch_bounds__ (256, 1) m01460_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
461 {
462 }
463
464 extern "C" __global__ void __launch_bounds__ (256, 1) m01460_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
465 {
466 }
467
468 extern "C" __global__ void __launch_bounds__ (256, 1) m01460_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
469 {
470   /**
471    * modifier
472    */
473
474   const u32 lid = threadIdx.x;
475
476   /**
477    * base
478    */
479
480   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
481
482   if (gid >= gid_max) return;
483
484   u32x wordl0[4];
485
486   wordl0[0] = pws[gid].i[ 0];
487   wordl0[1] = pws[gid].i[ 1];
488   wordl0[2] = pws[gid].i[ 2];
489   wordl0[3] = pws[gid].i[ 3];
490
491   u32x wordl1[4];
492
493   wordl1[0] = pws[gid].i[ 4];
494   wordl1[1] = pws[gid].i[ 5];
495   wordl1[2] = pws[gid].i[ 6];
496   wordl1[3] = pws[gid].i[ 7];
497
498   u32x wordl2[4];
499
500   wordl2[0] = 0;
501   wordl2[1] = 0;
502   wordl2[2] = 0;
503   wordl2[3] = 0;
504
505   u32x wordl3[4];
506
507   wordl3[0] = 0;
508   wordl3[1] = 0;
509   wordl3[2] = 0;
510   wordl3[3] = 0;
511
512   const u32 pw_l_len = pws[gid].pw_len;
513
514   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
515   {
516     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
517   }
518
519   /**
520    * salt
521    */
522
523   u32 salt_buf0[4];
524
525   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
526   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
527   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
528   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
529
530   u32 salt_buf1[4];
531
532   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
533   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
534   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
535   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
536
537   /**
538    * pads
539    */
540
541   u32x w0_t[4];
542
543   w0_t[0] = swap_workaround (salt_buf0[0]);
544   w0_t[1] = swap_workaround (salt_buf0[1]);
545   w0_t[2] = swap_workaround (salt_buf0[2]);
546   w0_t[3] = swap_workaround (salt_buf0[3]);
547
548   u32x w1_t[4];
549
550   w1_t[0] = swap_workaround (salt_buf1[0]);
551   w1_t[1] = swap_workaround (salt_buf1[1]);
552   w1_t[2] = swap_workaround (salt_buf1[2]);
553   w1_t[3] = swap_workaround (salt_buf1[3]);
554
555   u32x w2_t[4];
556
557   w2_t[0] = 0;
558   w2_t[1] = 0;
559   w2_t[2] = 0;
560   w2_t[3] = 0;
561
562   u32x w3_t[4];
563
564   w3_t[0] = 0;
565   w3_t[1] = 0;
566   w3_t[2] = 0;
567   w3_t[3] = 0;
568
569   u32x ipad[8];
570   u32x opad[8];
571
572   hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
573
574   /**
575    * digest
576    */
577
578   const u32 search[4] =
579   {
580     digests_buf[digests_offset].digest_buf[DGST_R0],
581     digests_buf[digests_offset].digest_buf[DGST_R1],
582     digests_buf[digests_offset].digest_buf[DGST_R2],
583     digests_buf[digests_offset].digest_buf[DGST_R3]
584   };
585
586   /**
587    * loop
588    */
589
590   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
591   {
592     const u32 pw_r_len = c_combs[il_pos].pw_len;
593
594     const u32 pw_len = pw_l_len + pw_r_len;
595
596     u32 wordr0[4];
597
598     wordr0[0] = c_combs[il_pos].i[0];
599     wordr0[1] = c_combs[il_pos].i[1];
600     wordr0[2] = c_combs[il_pos].i[2];
601     wordr0[3] = c_combs[il_pos].i[3];
602
603     u32 wordr1[4];
604
605     wordr1[0] = c_combs[il_pos].i[4];
606     wordr1[1] = c_combs[il_pos].i[5];
607     wordr1[2] = c_combs[il_pos].i[6];
608     wordr1[3] = c_combs[il_pos].i[7];
609
610     u32 wordr2[4];
611
612     wordr2[0] = 0;
613     wordr2[1] = 0;
614     wordr2[2] = 0;
615     wordr2[3] = 0;
616
617     u32 wordr3[4];
618
619     wordr3[0] = 0;
620     wordr3[1] = 0;
621     wordr3[2] = 0;
622     wordr3[3] = 0;
623
624     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
625     {
626       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
627     }
628
629     u32x w0[4];
630
631     w0[0] = wordl0[0] | wordr0[0];
632     w0[1] = wordl0[1] | wordr0[1];
633     w0[2] = wordl0[2] | wordr0[2];
634     w0[3] = wordl0[3] | wordr0[3];
635
636     u32x w1[4];
637
638     w1[0] = wordl1[0] | wordr1[0];
639     w1[1] = wordl1[1] | wordr1[1];
640     w1[2] = wordl1[2] | wordr1[2];
641     w1[3] = wordl1[3] | wordr1[3];
642
643     u32x w2[4];
644
645     w2[0] = wordl2[0] | wordr2[0];
646     w2[1] = wordl2[1] | wordr2[1];
647     w2[2] = wordl2[2] | wordr2[2];
648     w2[3] = wordl2[3] | wordr2[3];
649
650     u32x w3[4];
651
652     w3[0] = wordl3[0] | wordr3[0];
653     w3[1] = wordl3[1] | wordr3[1];
654     w3[2] = 0;
655     w3[3] = 0;
656
657     append_0x80_4 (w0, w1, w2, w3, pw_len);
658
659     w0_t[0] = swap_workaround (w0[0]);
660     w0_t[1] = swap_workaround (w0[1]);
661     w0_t[2] = swap_workaround (w0[2]);
662     w0_t[3] = swap_workaround (w0[3]);
663     w1_t[0] = swap_workaround (w1[0]);
664     w1_t[1] = swap_workaround (w1[1]);
665     w1_t[2] = swap_workaround (w1[2]);
666     w1_t[3] = swap_workaround (w1[3]);
667     w2_t[0] = swap_workaround (w2[0]);
668     w2_t[1] = swap_workaround (w2[1]);
669     w2_t[2] = swap_workaround (w2[2]);
670     w2_t[3] = swap_workaround (w2[3]);
671     w3_t[0] = swap_workaround (w3[0]);
672     w3_t[1] = swap_workaround (w3[1]);
673     w3_t[2] = 0;
674     w3_t[3] = (64 + pw_len) * 8;
675
676     u32x digest[8];
677
678     hmac_sha256_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
679
680     const u32x r0 = digest[3];
681     const u32x r1 = digest[7];
682     const u32x r2 = digest[2];
683     const u32x r3 = digest[6];
684
685     #include VECT_COMPARE_S
686   }
687 }
688
689 extern "C" __global__ void __launch_bounds__ (256, 1) m01460_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
690 {
691 }
692
693 extern "C" __global__ void __launch_bounds__ (256, 1) m01460_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
694 {
695 }