Initial commit
[hashcat.git] / nv / m01450_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) m01450_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   const u32 salt_len = salt_bufs[salt_pos].salt_len;
321
322   /**
323    * loop
324    */
325
326   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
327   {
328     const u32 pw_r_len = c_combs[il_pos].pw_len;
329
330     const u32 pw_len = pw_l_len + pw_r_len;
331
332     u32 wordr0[4];
333
334     wordr0[0] = c_combs[il_pos].i[0];
335     wordr0[1] = c_combs[il_pos].i[1];
336     wordr0[2] = c_combs[il_pos].i[2];
337     wordr0[3] = c_combs[il_pos].i[3];
338
339     u32 wordr1[4];
340
341     wordr1[0] = c_combs[il_pos].i[4];
342     wordr1[1] = c_combs[il_pos].i[5];
343     wordr1[2] = c_combs[il_pos].i[6];
344     wordr1[3] = c_combs[il_pos].i[7];
345
346     u32 wordr2[4];
347
348     wordr2[0] = 0;
349     wordr2[1] = 0;
350     wordr2[2] = 0;
351     wordr2[3] = 0;
352
353     u32 wordr3[4];
354
355     wordr3[0] = 0;
356     wordr3[1] = 0;
357     wordr3[2] = 0;
358     wordr3[3] = 0;
359
360     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
361     {
362       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
363     }
364
365     u32x w0[4];
366
367     w0[0] = wordl0[0] | wordr0[0];
368     w0[1] = wordl0[1] | wordr0[1];
369     w0[2] = wordl0[2] | wordr0[2];
370     w0[3] = wordl0[3] | wordr0[3];
371
372     u32x w1[4];
373
374     w1[0] = wordl1[0] | wordr1[0];
375     w1[1] = wordl1[1] | wordr1[1];
376     w1[2] = wordl1[2] | wordr1[2];
377     w1[3] = wordl1[3] | wordr1[3];
378
379     u32x w2[4];
380
381     w2[0] = wordl2[0] | wordr2[0];
382     w2[1] = wordl2[1] | wordr2[1];
383     w2[2] = wordl2[2] | wordr2[2];
384     w2[3] = wordl2[3] | wordr2[3];
385
386     u32x w3[4];
387
388     w3[0] = wordl3[0] | wordr3[0];
389     w3[1] = wordl3[1] | wordr3[1];
390     w3[2] = wordl3[2] | wordr3[2];
391     w3[3] = wordl3[3] | wordr3[3];
392
393     /**
394      * pads
395      */
396
397     u32x w0_t[4];
398
399     w0_t[0] = swap_workaround (w0[0]);
400     w0_t[1] = swap_workaround (w0[1]);
401     w0_t[2] = swap_workaround (w0[2]);
402     w0_t[3] = swap_workaround (w0[3]);
403
404     u32x w1_t[4];
405
406     w1_t[0] = swap_workaround (w1[0]);
407     w1_t[1] = swap_workaround (w1[1]);
408     w1_t[2] = swap_workaround (w1[2]);
409     w1_t[3] = swap_workaround (w1[3]);
410
411     u32x w2_t[4];
412
413     w2_t[0] = 0;
414     w2_t[1] = 0;
415     w2_t[2] = 0;
416     w2_t[3] = 0;
417
418     u32x w3_t[4];
419
420     w3_t[0] = 0;
421     w3_t[1] = 0;
422     w3_t[2] = 0;
423     w3_t[3] = 0;
424
425     u32x ipad[8];
426     u32x opad[8];
427
428     hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
429
430     w0_t[0] = swap_workaround (salt_buf0[0]);
431     w0_t[1] = swap_workaround (salt_buf0[1]);
432     w0_t[2] = swap_workaround (salt_buf0[2]);
433     w0_t[3] = swap_workaround (salt_buf0[3]);
434     w1_t[0] = swap_workaround (salt_buf1[0]);
435     w1_t[1] = swap_workaround (salt_buf1[1]);
436     w1_t[2] = swap_workaround (salt_buf1[2]);
437     w1_t[3] = swap_workaround (salt_buf1[3]);
438     w2_t[0] = 0;
439     w2_t[1] = 0;
440     w2_t[2] = 0;
441     w2_t[3] = 0;
442     w3_t[0] = 0;
443     w3_t[1] = 0;
444     w3_t[2] = 0;
445     w3_t[3] = (64 + salt_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) m01450_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) m01450_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) m01450_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   const u32 salt_len = salt_bufs[salt_pos].salt_len;
538
539   /**
540    * digest
541    */
542
543   const u32 search[4] =
544   {
545     digests_buf[digests_offset].digest_buf[DGST_R0],
546     digests_buf[digests_offset].digest_buf[DGST_R1],
547     digests_buf[digests_offset].digest_buf[DGST_R2],
548     digests_buf[digests_offset].digest_buf[DGST_R3]
549   };
550
551   /**
552    * loop
553    */
554
555   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
556   {
557     const u32 pw_r_len = c_combs[il_pos].pw_len;
558
559     const u32 pw_len = pw_l_len + pw_r_len;
560
561     u32 wordr0[4];
562
563     wordr0[0] = c_combs[il_pos].i[0];
564     wordr0[1] = c_combs[il_pos].i[1];
565     wordr0[2] = c_combs[il_pos].i[2];
566     wordr0[3] = c_combs[il_pos].i[3];
567
568     u32 wordr1[4];
569
570     wordr1[0] = c_combs[il_pos].i[4];
571     wordr1[1] = c_combs[il_pos].i[5];
572     wordr1[2] = c_combs[il_pos].i[6];
573     wordr1[3] = c_combs[il_pos].i[7];
574
575     u32 wordr2[4];
576
577     wordr2[0] = 0;
578     wordr2[1] = 0;
579     wordr2[2] = 0;
580     wordr2[3] = 0;
581
582     u32 wordr3[4];
583
584     wordr3[0] = 0;
585     wordr3[1] = 0;
586     wordr3[2] = 0;
587     wordr3[3] = 0;
588
589     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
590     {
591       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
592     }
593
594     u32x w0[4];
595
596     w0[0] = wordl0[0] | wordr0[0];
597     w0[1] = wordl0[1] | wordr0[1];
598     w0[2] = wordl0[2] | wordr0[2];
599     w0[3] = wordl0[3] | wordr0[3];
600
601     u32x w1[4];
602
603     w1[0] = wordl1[0] | wordr1[0];
604     w1[1] = wordl1[1] | wordr1[1];
605     w1[2] = wordl1[2] | wordr1[2];
606     w1[3] = wordl1[3] | wordr1[3];
607
608     u32x w2[4];
609
610     w2[0] = wordl2[0] | wordr2[0];
611     w2[1] = wordl2[1] | wordr2[1];
612     w2[2] = wordl2[2] | wordr2[2];
613     w2[3] = wordl2[3] | wordr2[3];
614
615     u32x w3[4];
616
617     w3[0] = wordl3[0] | wordr3[0];
618     w3[1] = wordl3[1] | wordr3[1];
619     w3[2] = wordl3[2] | wordr3[2];
620     w3[3] = wordl3[3] | wordr3[3];
621
622     /**
623      * pads
624      */
625
626     u32x w0_t[4];
627
628     w0_t[0] = swap_workaround (w0[0]);
629     w0_t[1] = swap_workaround (w0[1]);
630     w0_t[2] = swap_workaround (w0[2]);
631     w0_t[3] = swap_workaround (w0[3]);
632
633     u32x w1_t[4];
634
635     w1_t[0] = swap_workaround (w1[0]);
636     w1_t[1] = swap_workaround (w1[1]);
637     w1_t[2] = swap_workaround (w1[2]);
638     w1_t[3] = swap_workaround (w1[3]);
639
640     u32x w2_t[4];
641
642     w2_t[0] = 0;
643     w2_t[1] = 0;
644     w2_t[2] = 0;
645     w2_t[3] = 0;
646
647     u32x w3_t[4];
648
649     w3_t[0] = 0;
650     w3_t[1] = 0;
651     w3_t[2] = 0;
652     w3_t[3] = 0;
653
654     u32x ipad[8];
655     u32x opad[8];
656
657     hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
658
659     w0_t[0] = swap_workaround (salt_buf0[0]);
660     w0_t[1] = swap_workaround (salt_buf0[1]);
661     w0_t[2] = swap_workaround (salt_buf0[2]);
662     w0_t[3] = swap_workaround (salt_buf0[3]);
663     w1_t[0] = swap_workaround (salt_buf1[0]);
664     w1_t[1] = swap_workaround (salt_buf1[1]);
665     w1_t[2] = swap_workaround (salt_buf1[2]);
666     w1_t[3] = swap_workaround (salt_buf1[3]);
667     w2_t[0] = 0;
668     w2_t[1] = 0;
669     w2_t[2] = 0;
670     w2_t[3] = 0;
671     w3_t[0] = 0;
672     w3_t[1] = 0;
673     w3_t[2] = 0;
674     w3_t[3] = (64 + salt_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 a = digest[0];
681     const u32x b = digest[1];
682     const u32x c = digest[2];
683     const u32x d = digest[3];
684     const u32x e = digest[4];
685     const u32x f = digest[5];
686     const u32x g = digest[6];
687     const u32x h = digest[7];
688
689     const u32x r0 = digest[3];
690     const u32x r1 = digest[7];
691     const u32x r2 = digest[2];
692     const u32x r3 = digest[6];
693
694     #include VECT_COMPARE_S
695   }
696 }
697
698 extern "C" __global__ void __launch_bounds__ (256, 1) m01450_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)
699 {
700 }
701
702 extern "C" __global__ void __launch_bounds__ (256, 1) m01450_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)
703 {
704 }