Initial commit
[hashcat.git] / nv / m06500.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 0
20 #define DGST_R1 1
21 #define DGST_R2 2
22 #define DGST_R3 3
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_M "check_multi_vect1_comp4.c"
30 #endif
31
32 #ifdef  VECT_SIZE2
33 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
34 #endif
35
36 __device__ __constant__ u64 k[80] =
37 {
38   SHA512C00, SHA512C01, SHA512C02, SHA512C03,
39   SHA512C04, SHA512C05, SHA512C06, SHA512C07,
40   SHA512C08, SHA512C09, SHA512C0a, SHA512C0b,
41   SHA512C0c, SHA512C0d, SHA512C0e, SHA512C0f,
42   SHA512C10, SHA512C11, SHA512C12, SHA512C13,
43   SHA512C14, SHA512C15, SHA512C16, SHA512C17,
44   SHA512C18, SHA512C19, SHA512C1a, SHA512C1b,
45   SHA512C1c, SHA512C1d, SHA512C1e, SHA512C1f,
46   SHA512C20, SHA512C21, SHA512C22, SHA512C23,
47   SHA512C24, SHA512C25, SHA512C26, SHA512C27,
48   SHA512C28, SHA512C29, SHA512C2a, SHA512C2b,
49   SHA512C2c, SHA512C2d, SHA512C2e, SHA512C2f,
50   SHA512C30, SHA512C31, SHA512C32, SHA512C33,
51   SHA512C34, SHA512C35, SHA512C36, SHA512C37,
52   SHA512C38, SHA512C39, SHA512C3a, SHA512C3b,
53   SHA512C3c, SHA512C3d, SHA512C3e, SHA512C3f,
54   SHA512C40, SHA512C41, SHA512C42, SHA512C43,
55   SHA512C44, SHA512C45, SHA512C46, SHA512C47,
56   SHA512C48, SHA512C49, SHA512C4a, SHA512C4b,
57   SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f,
58 };
59
60 #define ROUND_EXPAND()                            \
61 {                                                 \
62   w0_t = SHA512_EXPAND (we_t, w9_t, w1_t, w0_t);  \
63   w1_t = SHA512_EXPAND (wf_t, wa_t, w2_t, w1_t);  \
64   w2_t = SHA512_EXPAND (w0_t, wb_t, w3_t, w2_t);  \
65   w3_t = SHA512_EXPAND (w1_t, wc_t, w4_t, w3_t);  \
66   w4_t = SHA512_EXPAND (w2_t, wd_t, w5_t, w4_t);  \
67   w5_t = SHA512_EXPAND (w3_t, we_t, w6_t, w5_t);  \
68   w6_t = SHA512_EXPAND (w4_t, wf_t, w7_t, w6_t);  \
69   w7_t = SHA512_EXPAND (w5_t, w0_t, w8_t, w7_t);  \
70   w8_t = SHA512_EXPAND (w6_t, w1_t, w9_t, w8_t);  \
71   w9_t = SHA512_EXPAND (w7_t, w2_t, wa_t, w9_t);  \
72   wa_t = SHA512_EXPAND (w8_t, w3_t, wb_t, wa_t);  \
73   wb_t = SHA512_EXPAND (w9_t, w4_t, wc_t, wb_t);  \
74   wc_t = SHA512_EXPAND (wa_t, w5_t, wd_t, wc_t);  \
75   wd_t = SHA512_EXPAND (wb_t, w6_t, we_t, wd_t);  \
76   we_t = SHA512_EXPAND (wc_t, w7_t, wf_t, we_t);  \
77   wf_t = SHA512_EXPAND (wd_t, w8_t, w0_t, wf_t);  \
78 }
79
80 #define ROUND_STEP(i)                                                             \
81 {                                                                                 \
82   SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w0_t, k[i +  0]);  \
83   SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w1_t, k[i +  1]);  \
84   SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, w2_t, k[i +  2]);  \
85   SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, w3_t, k[i +  3]);  \
86   SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, w4_t, k[i +  4]);  \
87   SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, w5_t, k[i +  5]);  \
88   SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, w6_t, k[i +  6]);  \
89   SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, w7_t, k[i +  7]);  \
90   SHA512_STEP (SHA512_F0o, SHA512_F1o, a, b, c, d, e, f, g, h, w8_t, k[i +  8]);  \
91   SHA512_STEP (SHA512_F0o, SHA512_F1o, h, a, b, c, d, e, f, g, w9_t, k[i +  9]);  \
92   SHA512_STEP (SHA512_F0o, SHA512_F1o, g, h, a, b, c, d, e, f, wa_t, k[i + 10]);  \
93   SHA512_STEP (SHA512_F0o, SHA512_F1o, f, g, h, a, b, c, d, e, wb_t, k[i + 11]);  \
94   SHA512_STEP (SHA512_F0o, SHA512_F1o, e, f, g, h, a, b, c, d, wc_t, k[i + 12]);  \
95   SHA512_STEP (SHA512_F0o, SHA512_F1o, d, e, f, g, h, a, b, c, wd_t, k[i + 13]);  \
96   SHA512_STEP (SHA512_F0o, SHA512_F1o, c, d, e, f, g, h, a, b, we_t, k[i + 14]);  \
97   SHA512_STEP (SHA512_F0o, SHA512_F1o, b, c, d, e, f, g, h, a, wf_t, k[i + 15]);  \
98 }
99
100 __device__ static void sha512_transform (const u64x w0[4], const u64x w1[4], const u64x w2[4], const u64x w3[4], u64x digest[8])
101 {
102   u64x a = digest[0];
103   u64x b = digest[1];
104   u64x c = digest[2];
105   u64x d = digest[3];
106   u64x e = digest[4];
107   u64x f = digest[5];
108   u64x g = digest[6];
109   u64x h = digest[7];
110
111   u64x w0_t = w0[0];
112   u64x w1_t = w0[1];
113   u64x w2_t = w0[2];
114   u64x w3_t = w0[3];
115   u64x w4_t = w1[0];
116   u64x w5_t = w1[1];
117   u64x w6_t = w1[2];
118   u64x w7_t = w1[3];
119   u64x w8_t = w2[0];
120   u64x w9_t = w2[1];
121   u64x wa_t = w2[2];
122   u64x wb_t = w2[3];
123   u64x wc_t = w3[0];
124   u64x wd_t = w3[1];
125   u64x we_t = w3[2];
126   u64x wf_t = w3[3];
127
128   ROUND_STEP (0);
129
130   for (int i = 16; i < 80; i += 16)
131   {
132     ROUND_EXPAND (); ROUND_STEP (i);
133   }
134
135   digest[0] += a;
136   digest[1] += b;
137   digest[2] += c;
138   digest[3] += d;
139   digest[4] += e;
140   digest[5] += f;
141   digest[6] += g;
142   digest[7] += h;
143 }
144
145 __device__ static void hmac_sha512_pad (u64x w0[4], u64x w1[4], u64x w2[4], u64x w3[4], u64x ipad[8], u64x opad[8])
146 {
147   w0[0] = w0[0] ^ 0x3636363636363636;
148   w0[1] = w0[1] ^ 0x3636363636363636;
149   w0[2] = w0[2] ^ 0x3636363636363636;
150   w0[3] = w0[3] ^ 0x3636363636363636;
151   w1[0] = w1[0] ^ 0x3636363636363636;
152   w1[1] = w1[1] ^ 0x3636363636363636;
153   w1[2] = w1[2] ^ 0x3636363636363636;
154   w1[3] = w1[3] ^ 0x3636363636363636;
155   w2[0] = w2[0] ^ 0x3636363636363636;
156   w2[1] = w2[1] ^ 0x3636363636363636;
157   w2[2] = w2[2] ^ 0x3636363636363636;
158   w2[3] = w2[3] ^ 0x3636363636363636;
159   w3[0] = w3[0] ^ 0x3636363636363636;
160   w3[1] = w3[1] ^ 0x3636363636363636;
161   w3[2] = w3[2] ^ 0x3636363636363636;
162   w3[3] = w3[3] ^ 0x3636363636363636;
163
164   ipad[0] = SHA512M_A;
165   ipad[1] = SHA512M_B;
166   ipad[2] = SHA512M_C;
167   ipad[3] = SHA512M_D;
168   ipad[4] = SHA512M_E;
169   ipad[5] = SHA512M_F;
170   ipad[6] = SHA512M_G;
171   ipad[7] = SHA512M_H;
172
173   sha512_transform (w0, w1, w2, w3, ipad);
174
175   w0[0] = w0[0] ^ 0x6a6a6a6a6a6a6a6a;
176   w0[1] = w0[1] ^ 0x6a6a6a6a6a6a6a6a;
177   w0[2] = w0[2] ^ 0x6a6a6a6a6a6a6a6a;
178   w0[3] = w0[3] ^ 0x6a6a6a6a6a6a6a6a;
179   w1[0] = w1[0] ^ 0x6a6a6a6a6a6a6a6a;
180   w1[1] = w1[1] ^ 0x6a6a6a6a6a6a6a6a;
181   w1[2] = w1[2] ^ 0x6a6a6a6a6a6a6a6a;
182   w1[3] = w1[3] ^ 0x6a6a6a6a6a6a6a6a;
183   w2[0] = w2[0] ^ 0x6a6a6a6a6a6a6a6a;
184   w2[1] = w2[1] ^ 0x6a6a6a6a6a6a6a6a;
185   w2[2] = w2[2] ^ 0x6a6a6a6a6a6a6a6a;
186   w2[3] = w2[3] ^ 0x6a6a6a6a6a6a6a6a;
187   w3[0] = w3[0] ^ 0x6a6a6a6a6a6a6a6a;
188   w3[1] = w3[1] ^ 0x6a6a6a6a6a6a6a6a;
189   w3[2] = w3[2] ^ 0x6a6a6a6a6a6a6a6a;
190   w3[3] = w3[3] ^ 0x6a6a6a6a6a6a6a6a;
191
192   opad[0] = SHA512M_A;
193   opad[1] = SHA512M_B;
194   opad[2] = SHA512M_C;
195   opad[3] = SHA512M_D;
196   opad[4] = SHA512M_E;
197   opad[5] = SHA512M_F;
198   opad[6] = SHA512M_G;
199   opad[7] = SHA512M_H;
200
201   sha512_transform (w0, w1, w2, w3, opad);
202 }
203
204 __device__ static void hmac_sha512_run (u64x w0[4], u64x w1[4], u64x w2[4], u64x w3[4], u64x ipad[8], u64x opad[8], u64x digest[8])
205 {
206   digest[0] = ipad[0];
207   digest[1] = ipad[1];
208   digest[2] = ipad[2];
209   digest[3] = ipad[3];
210   digest[4] = ipad[4];
211   digest[5] = ipad[5];
212   digest[6] = ipad[6];
213   digest[7] = ipad[7];
214
215   sha512_transform (w0, w1, w2, w3, digest);
216
217   w0[0] = digest[0];
218   w0[1] = digest[1];
219   w0[2] = digest[2];
220   w0[3] = digest[3];
221   w1[0] = digest[4];
222   w1[1] = digest[5];
223   w1[2] = digest[6];
224   w1[3] = digest[7];
225   w2[0] = 0x8000000000000000;
226   w2[1] = 0;
227   w2[2] = 0;
228   w2[3] = 0;
229   w3[0] = 0;
230   w3[1] = 0;
231   w3[2] = 0;
232   w3[3] = (128 + 64) * 8;
233
234   digest[0] = opad[0];
235   digest[1] = opad[1];
236   digest[2] = opad[2];
237   digest[3] = opad[3];
238   digest[4] = opad[4];
239   digest[5] = opad[5];
240   digest[6] = opad[6];
241   digest[7] = opad[7];
242
243   sha512_transform (w0, w1, w2, w3, digest);
244 }
245
246 extern "C" __global__ void __launch_bounds__ (256, 1) m06500_init (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, sha512aix_tmp_t *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)
247 {
248   /**
249    * base
250    */
251
252   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
253
254   if (gid >= gid_max) return;
255
256   u32x w0[4];
257
258   w0[0] = pws[gid].i[ 0];
259   w0[1] = pws[gid].i[ 1];
260   w0[2] = pws[gid].i[ 2];
261   w0[3] = pws[gid].i[ 3];
262
263   u32x w1[4];
264
265   w1[0] = pws[gid].i[ 4];
266   w1[1] = pws[gid].i[ 5];
267   w1[2] = pws[gid].i[ 6];
268   w1[3] = pws[gid].i[ 7];
269
270   u32x w2[4];
271
272   w2[0] = pws[gid].i[ 8];
273   w2[1] = pws[gid].i[ 9];
274   w2[2] = pws[gid].i[10];
275   w2[3] = pws[gid].i[11];
276
277   u32x w3[4];
278
279   w3[0] = pws[gid].i[12];
280   w3[1] = pws[gid].i[13];
281   w3[2] = pws[gid].i[14];
282   w3[3] = pws[gid].i[15];
283
284   /**
285    * salt
286    */
287
288   u32 salt_len = salt_bufs[salt_pos].salt_len;
289
290   u32 salt_buf0[4];
291
292   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
293   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
294   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
295   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
296
297   u32 salt_buf1[4];
298
299   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
300   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
301   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
302   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
303
304   u32 salt_buf2[4];
305
306   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
307   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
308   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
309   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
310
311   u32 salt_buf3[4];
312
313   salt_buf3[0] = 0;
314   salt_buf3[1] = 0;
315   salt_buf3[2] = 0;
316   salt_buf3[3] = 0;
317
318   append_0x01_4 (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_len + 3);
319
320   append_0x80_4 (salt_buf0, salt_buf1, salt_buf2, salt_buf3, salt_len + 4);
321
322   /**
323    * pads
324    */
325
326   w0[0] = swap_workaround (w0[0]);
327   w0[1] = swap_workaround (w0[1]);
328   w0[2] = swap_workaround (w0[2]);
329   w0[3] = swap_workaround (w0[3]);
330   w1[0] = swap_workaround (w1[0]);
331   w1[1] = swap_workaround (w1[1]);
332   w1[2] = swap_workaround (w1[2]);
333   w1[3] = swap_workaround (w1[3]);
334   w2[0] = swap_workaround (w2[0]);
335   w2[1] = swap_workaround (w2[1]);
336   w2[2] = swap_workaround (w2[2]);
337   w2[3] = swap_workaround (w2[3]);
338   w3[0] = swap_workaround (w3[0]);
339   w3[1] = swap_workaround (w3[1]);
340   w3[2] = swap_workaround (w3[2]);
341   w3[3] = swap_workaround (w3[3]);
342
343   u64x w0l[4];
344   u64x w1l[4];
345   u64x w2l[4];
346   u64x w3l[4];
347
348   w0l[0] = (u64x) (w0[0]) << 32 | (u64x) (w0[1]);
349   w0l[1] = (u64x) (w0[2]) << 32 | (u64x) (w0[3]);
350   w0l[2] = (u64x) (w1[0]) << 32 | (u64x) (w1[1]);
351   w0l[3] = (u64x) (w1[2]) << 32 | (u64x) (w1[3]);
352   w1l[0] = (u64x) (w2[0]) << 32 | (u64x) (w2[1]);
353   w1l[1] = (u64x) (w2[2]) << 32 | (u64x) (w2[3]);
354   w1l[2] = (u64x) (w3[0]) << 32 | (u64x) (w3[1]);
355   w1l[3] = (u64x) (w3[2]) << 32 | (u64x) (w3[3]);
356   w2l[0] = 0;
357   w2l[1] = 0;
358   w2l[2] = 0;
359   w2l[3] = 0;
360   w3l[0] = 0;
361   w3l[1] = 0;
362   w3l[2] = 0;
363   w3l[3] = 0;
364
365   u64x ipad[8];
366   u64x opad[8];
367
368   hmac_sha512_pad (w0l, w1l, w2l, w3l, ipad, opad);
369
370   tmps[gid].ipad[0] = ipad[0];
371   tmps[gid].ipad[1] = ipad[1];
372   tmps[gid].ipad[2] = ipad[2];
373   tmps[gid].ipad[3] = ipad[3];
374   tmps[gid].ipad[4] = ipad[4];
375   tmps[gid].ipad[5] = ipad[5];
376   tmps[gid].ipad[6] = ipad[6];
377   tmps[gid].ipad[7] = ipad[7];
378
379   tmps[gid].opad[0] = opad[0];
380   tmps[gid].opad[1] = opad[1];
381   tmps[gid].opad[2] = opad[2];
382   tmps[gid].opad[3] = opad[3];
383   tmps[gid].opad[4] = opad[4];
384   tmps[gid].opad[5] = opad[5];
385   tmps[gid].opad[6] = opad[6];
386   tmps[gid].opad[7] = opad[7];
387
388   w0l[0] = (u64x) salt_buf0[1] << 32 | (u64x) salt_buf0[0];
389   w0l[1] = (u64x) salt_buf0[3] << 32 | (u64x) salt_buf0[2];
390   w0l[2] = (u64x) salt_buf1[1] << 32 | (u64x) salt_buf1[0];
391   w0l[3] = (u64x) salt_buf1[3] << 32 | (u64x) salt_buf1[2];
392   w1l[0] = (u64x) salt_buf2[1] << 32 | (u64x) salt_buf2[0];
393   w1l[1] = (u64x) salt_buf2[3] << 32 | (u64x) salt_buf2[2];
394   w1l[2] = (u64x) salt_buf3[1] << 32 | (u64x) salt_buf3[0];
395   w1l[3] = (u64x) salt_buf3[3] << 32 | (u64x) salt_buf3[2];
396   w2l[0] = 0;
397   w2l[1] = 0;
398   w2l[2] = 0;
399   w2l[3] = 0;
400   w3l[0] = 0;
401   w3l[1] = 0;
402   w3l[2] = 0;
403   w3l[3] = 0;
404
405   w0l[0] = swap_workaround (w0l[0]);
406   w0l[1] = swap_workaround (w0l[1]);
407   w0l[2] = swap_workaround (w0l[2]);
408   w0l[3] = swap_workaround (w0l[3]);
409   w1l[0] = swap_workaround (w1l[0]);
410   w1l[1] = swap_workaround (w1l[1]);
411   w1l[2] = swap_workaround (w1l[2]);
412   w1l[3] = swap_workaround (w1l[3]);
413   w2l[0] = 0;
414   w2l[1] = 0;
415   w2l[2] = 0;
416   w2l[3] = 0;
417   w3l[0] = 0;
418   w3l[1] = 0;
419   w3l[2] = 0;
420   w3l[3] = (128 + salt_len + 4) * 8;
421
422   u64x dgst[8];
423
424   hmac_sha512_run (w0l, w1l, w2l, w3l, ipad, opad, dgst);
425
426   tmps[gid].dgst[0] = dgst[0];
427   tmps[gid].dgst[1] = dgst[1];
428   tmps[gid].dgst[2] = dgst[2];
429   tmps[gid].dgst[3] = dgst[3];
430   tmps[gid].dgst[4] = dgst[4];
431   tmps[gid].dgst[5] = dgst[5];
432   tmps[gid].dgst[6] = dgst[6];
433   tmps[gid].dgst[7] = dgst[7];
434
435   tmps[gid].out[0] = dgst[0];
436   tmps[gid].out[1] = dgst[1];
437   tmps[gid].out[2] = dgst[2];
438   tmps[gid].out[3] = dgst[3];
439   tmps[gid].out[4] = dgst[4];
440   tmps[gid].out[5] = dgst[5];
441   tmps[gid].out[6] = dgst[6];
442   tmps[gid].out[7] = dgst[7];
443 }
444
445 extern "C" __global__ void __launch_bounds__ (256, 1) m06500_loop (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, sha512aix_tmp_t *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)
446 {
447   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
448
449   if (gid >= gid_max) return;
450
451   u64x ipad[8];
452   u64x opad[8];
453
454   ipad[0] = tmps[gid].ipad[0];
455   ipad[1] = tmps[gid].ipad[1];
456   ipad[2] = tmps[gid].ipad[2];
457   ipad[3] = tmps[gid].ipad[3];
458   ipad[4] = tmps[gid].ipad[4];
459   ipad[5] = tmps[gid].ipad[5];
460   ipad[6] = tmps[gid].ipad[6];
461   ipad[7] = tmps[gid].ipad[7];
462
463   opad[0] = tmps[gid].opad[0];
464   opad[1] = tmps[gid].opad[1];
465   opad[2] = tmps[gid].opad[2];
466   opad[3] = tmps[gid].opad[3];
467   opad[4] = tmps[gid].opad[4];
468   opad[5] = tmps[gid].opad[5];
469   opad[6] = tmps[gid].opad[6];
470   opad[7] = tmps[gid].opad[7];
471
472   u64x dgst[8];
473   u64x out[8];
474
475   dgst[0] = tmps[gid].dgst[0];
476   dgst[1] = tmps[gid].dgst[1];
477   dgst[2] = tmps[gid].dgst[2];
478   dgst[3] = tmps[gid].dgst[3];
479   dgst[4] = tmps[gid].dgst[4];
480   dgst[5] = tmps[gid].dgst[5];
481   dgst[6] = tmps[gid].dgst[6];
482   dgst[7] = tmps[gid].dgst[7];
483
484   out[0] = tmps[gid].out[0];
485   out[1] = tmps[gid].out[1];
486   out[2] = tmps[gid].out[2];
487   out[3] = tmps[gid].out[3];
488   out[4] = tmps[gid].out[4];
489   out[5] = tmps[gid].out[5];
490   out[6] = tmps[gid].out[6];
491   out[7] = tmps[gid].out[7];
492
493   for (u32 j = 0; j < loop_cnt; j++)
494   {
495     u64x w0[4];
496     u64x w1[4];
497     u64x w2[4];
498     u64x w3[4];
499
500     w0[0] = dgst[0];
501     w0[1] = dgst[1];
502     w0[2] = dgst[2];
503     w0[3] = dgst[3];
504     w1[0] = dgst[4];
505     w1[1] = dgst[5];
506     w1[2] = dgst[6];
507     w1[3] = dgst[7];
508     w2[0] = 0x8000000000000000;
509     w2[1] = 0;
510     w2[2] = 0;
511     w2[3] = 0;
512     w3[0] = 0;
513     w3[1] = 0;
514     w3[2] = 0;
515     w3[3] = (128 + 64) * 8;
516
517     hmac_sha512_run (w0, w1, w2, w3, ipad, opad, dgst);
518
519     out[0] ^= dgst[0];
520     out[1] ^= dgst[1];
521     out[2] ^= dgst[2];
522     out[3] ^= dgst[3];
523     out[4] ^= dgst[4];
524     out[5] ^= dgst[5];
525     out[6] ^= dgst[6];
526     out[7] ^= dgst[7];
527   }
528
529   tmps[gid].dgst[0] = dgst[0];
530   tmps[gid].dgst[1] = dgst[1];
531   tmps[gid].dgst[2] = dgst[2];
532   tmps[gid].dgst[3] = dgst[3];
533   tmps[gid].dgst[4] = dgst[4];
534   tmps[gid].dgst[5] = dgst[5];
535   tmps[gid].dgst[6] = dgst[6];
536   tmps[gid].dgst[7] = dgst[7];
537
538   tmps[gid].out[0] = out[0];
539   tmps[gid].out[1] = out[1];
540   tmps[gid].out[2] = out[2];
541   tmps[gid].out[3] = out[3];
542   tmps[gid].out[4] = out[4];
543   tmps[gid].out[5] = out[5];
544   tmps[gid].out[6] = out[6];
545   tmps[gid].out[7] = out[7];
546 }
547
548 extern "C" __global__ void __launch_bounds__ (256, 1) m06500_comp (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, sha512aix_tmp_t *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)
549 {
550   /**
551    * base
552    */
553
554   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
555
556   if (gid >= gid_max) return;
557
558   const u32 lid = threadIdx.x;
559
560   /**
561    * digest
562    */
563
564   /*
565   u64x a = tmps[gid].out[0];
566   u64x b = tmps[gid].out[1];
567   u64x c = tmps[gid].out[2];
568   u64x d = tmps[gid].out[3];
569   u64x e = tmps[gid].out[4];
570   u64x f = tmps[gid].out[5];
571   u64x g = tmps[gid].out[6];
572   u64x h = tmps[gid].out[7] & 0xffffffffffffff00;
573   */
574
575   const u32x r0 = l32_from_64 (tmps[gid].out[0]);
576   const u32x r1 = h32_from_64 (tmps[gid].out[0]);
577   const u32x r2 = l32_from_64 (tmps[gid].out[1]);
578   const u32x r3 = h32_from_64 (tmps[gid].out[1]);
579
580   #define il_pos 0
581
582   #include VECT_COMPARE_M
583 }