Initial commit
[hashcat.git] / nv / m04310_a0.cu
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
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 3
21 #define DGST_R2 2
22 #define DGST_R3 1
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 #ifdef VECT_SIZE1
48 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
49 #endif
50
51 #ifdef VECT_SIZE2
52 #define uint_to_hex_lower8(i) u32x (l_bin2asc[(i).x], l_bin2asc[(i).y])
53 #endif
54
55 #ifdef VECT_SIZE4
56 #define uint_to_hex_lower8(i) u32x (l_bin2asc[(i).x], l_bin2asc[(i).y], l_bin2asc[(i).z], l_bin2asc[(i).w])
57 #endif
58
59 __device__ __constant__ char c_bin2asc[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
60
61 __device__ __shared__ short l_bin2asc[256];
62
63 extern "C" __global__ void __launch_bounds__ (256, 1) m04310_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)
64 {
65   /**
66    * modifier
67    */
68
69   const u32 lid = threadIdx.x;
70
71   /**
72    * base
73    */
74
75   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
76
77   u32x pw_buf0[4];
78
79   pw_buf0[0] = pws[gid].i[ 0];
80   pw_buf0[1] = pws[gid].i[ 1];
81   pw_buf0[2] = pws[gid].i[ 2];
82   pw_buf0[3] = pws[gid].i[ 3];
83
84   u32x pw_buf1[4];
85
86   pw_buf1[0] = pws[gid].i[ 4];
87   pw_buf1[1] = pws[gid].i[ 5];
88   pw_buf1[2] = pws[gid].i[ 6];
89   pw_buf1[3] = pws[gid].i[ 7];
90
91   const u32 pw_len = pws[gid].pw_len;
92
93   /**
94    * salt
95    */
96
97   const u32 salt_len = salt_bufs[salt_pos].salt_len;
98
99   u32 s[8];
100
101   s[0] = salt_bufs[salt_pos].salt_buf[0];
102   s[1] = salt_bufs[salt_pos].salt_buf[1];
103   s[2] = salt_bufs[salt_pos].salt_buf[2];
104   s[3] = salt_bufs[salt_pos].salt_buf[3];
105   s[4] = salt_bufs[salt_pos].salt_buf[4];
106   s[5] = salt_bufs[salt_pos].salt_buf[5];
107   s[6] = (32 + salt_len) * 8;
108   s[7] = 0;
109
110   /**
111    * bin2asc table
112    */
113
114   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
115                  | c_bin2asc[(lid >> 4) & 15] << 0;
116
117   __syncthreads ();
118
119   if (gid >= gid_max) return;
120
121   /**
122    * loop
123    */
124
125   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
126   {
127     u32x w0[4];
128
129     w0[0] = pw_buf0[0];
130     w0[1] = pw_buf0[1];
131     w0[2] = pw_buf0[2];
132     w0[3] = pw_buf0[3];
133
134     u32x w1[4];
135
136     w1[0] = pw_buf1[0];
137     w1[1] = pw_buf1[1];
138     w1[2] = pw_buf1[2];
139     w1[3] = pw_buf1[3];
140
141     u32x w2[4];
142
143     w2[0] = 0;
144     w2[1] = 0;
145     w2[2] = 0;
146     w2[3] = 0;
147
148     u32x w3[4];
149
150     w3[0] = 0;
151     w3[1] = 0;
152     w3[2] = 0;
153     w3[3] = 0;
154
155     const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
156
157     append_0x80_2 (w0, w1, out_len);
158
159     w3[2] = out_len * 8;
160
161     u32x a = MD5M_A;
162     u32x b = MD5M_B;
163     u32x c = MD5M_C;
164     u32x d = MD5M_D;
165
166     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
167     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
168     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
169     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
170     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
171     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
172     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
173     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
174     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
175     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
176     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
177     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
178     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
179     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
180     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
181     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
182
183     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
184     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
185     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
186     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
187     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
188     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
189     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
190     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
191     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
192     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
193     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
194     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
195     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
196     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
197     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
198     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
199
200     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
201     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
202     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
203     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
204     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
205     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
206     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
207     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
208     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
209     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
210     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
211     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
212     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
213     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
214     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
215     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
216
217     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
218     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
219     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
220     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
221     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
222     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
223     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
224     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
225     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
226     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
227     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
228     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
229     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
230     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
231     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
232     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
233
234     a += MD5M_A;
235     b += MD5M_B;
236     c += MD5M_C;
237     d += MD5M_D;
238
239     const u32x w0_t = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
240                      | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
241     const u32x w1_t = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
242                      | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
243     const u32x w2_t = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
244                      | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
245     const u32x w3_t = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
246                      | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
247     const u32x w4_t = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
248                      | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
249     const u32x w5_t = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
250                      | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
251     const u32x w6_t = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
252                      | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
253     const u32x w7_t = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
254                      | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
255
256     const u32 w8_t = s[0];
257     const u32 w9_t = s[1];
258     const u32 wa_t = s[2];
259     const u32 wb_t = s[3];
260     const u32 wc_t = s[4];
261     const u32 wd_t = s[5];
262     const u32 we_t = s[6];
263     const u32 wf_t = s[7];
264
265     a = MD5M_A;
266     b = MD5M_B;
267     c = MD5M_C;
268     d = MD5M_D;
269
270     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
271     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
272     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
273     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
274     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
275     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
276     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
277     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
278     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
279     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
280     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
281     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
282     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
283     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
284     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
285     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
286
287     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
288     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
289     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
290     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
291     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
292     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
293     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
294     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
295     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
296     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
297     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
298     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
299     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
300     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
301     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
302     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
303
304     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
305     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
306     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
307     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
308     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
309     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
310     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
311     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
312     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
313     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
314     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
315     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
316     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
317     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
318     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
319     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
320
321     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
322     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
323     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
324     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
325     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
326     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
327     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
328     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
329     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
330     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
331     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
332     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
333     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
334     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
335     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
336     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
337
338     const u32x r0 = a;
339     const u32x r1 = d;
340     const u32x r2 = c;
341     const u32x r3 = b;
342
343     #include VECT_COMPARE_M
344   }
345 }
346
347 extern "C" __global__ void __launch_bounds__ (256, 1) m04310_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)
348 {
349 }
350
351 extern "C" __global__ void __launch_bounds__ (256, 1) m04310_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)
352 {
353 }
354
355 extern "C" __global__ void __launch_bounds__ (256, 1) m04310_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)
356 {
357   /**
358    * modifier
359    */
360
361   const u32 lid = threadIdx.x;
362
363   /**
364    * base
365    */
366
367   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
368
369   u32x pw_buf0[4];
370
371   pw_buf0[0] = pws[gid].i[ 0];
372   pw_buf0[1] = pws[gid].i[ 1];
373   pw_buf0[2] = pws[gid].i[ 2];
374   pw_buf0[3] = pws[gid].i[ 3];
375
376   u32x pw_buf1[4];
377
378   pw_buf1[0] = pws[gid].i[ 4];
379   pw_buf1[1] = pws[gid].i[ 5];
380   pw_buf1[2] = pws[gid].i[ 6];
381   pw_buf1[3] = pws[gid].i[ 7];
382
383   const u32 pw_len = pws[gid].pw_len;
384
385   /**
386    * salt
387    */
388
389   const u32 salt_len = salt_bufs[salt_pos].salt_len;
390
391   u32 s[8];
392
393   s[0] = salt_bufs[salt_pos].salt_buf[0];
394   s[1] = salt_bufs[salt_pos].salt_buf[1];
395   s[2] = salt_bufs[salt_pos].salt_buf[2];
396   s[3] = salt_bufs[salt_pos].salt_buf[3];
397   s[4] = salt_bufs[salt_pos].salt_buf[4];
398   s[5] = salt_bufs[salt_pos].salt_buf[5];
399   s[6] = (32 + salt_len) * 8;
400   s[7] = 0;
401
402   /**
403    * digest
404    */
405
406   const u32 search[4] =
407   {
408     digests_buf[digests_offset].digest_buf[DGST_R0],
409     digests_buf[digests_offset].digest_buf[DGST_R1],
410     digests_buf[digests_offset].digest_buf[DGST_R2],
411     digests_buf[digests_offset].digest_buf[DGST_R3]
412   };
413
414   /**
415    * bin2asc table
416    */
417
418   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
419                  | c_bin2asc[(lid >> 4) & 15] << 0;
420
421   __syncthreads ();
422
423   if (gid >= gid_max) return;
424
425   /**
426    * loop
427    */
428
429   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
430   {
431     u32x w0[4];
432
433     w0[0] = pw_buf0[0];
434     w0[1] = pw_buf0[1];
435     w0[2] = pw_buf0[2];
436     w0[3] = pw_buf0[3];
437
438     u32x w1[4];
439
440     w1[0] = pw_buf1[0];
441     w1[1] = pw_buf1[1];
442     w1[2] = pw_buf1[2];
443     w1[3] = pw_buf1[3];
444
445     u32x w2[4];
446
447     w2[0] = 0;
448     w2[1] = 0;
449     w2[2] = 0;
450     w2[3] = 0;
451
452     u32x w3[4];
453
454     w3[0] = 0;
455     w3[1] = 0;
456     w3[2] = 0;
457     w3[3] = 0;
458
459     const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
460
461     append_0x80_2 (w0, w1, out_len);
462
463     w3[2] = out_len * 8;
464
465     u32x a = MD5M_A;
466     u32x b = MD5M_B;
467     u32x c = MD5M_C;
468     u32x d = MD5M_D;
469
470     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
471     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
472     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
473     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
474     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
475     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
476     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
477     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
478     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
479     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
480     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
481     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
482     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
483     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
484     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
485     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
486
487     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
488     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
489     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
490     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
491     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
492     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
493     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
494     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
495     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
496     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
497     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
498     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
499     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
500     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
501     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
502     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
503
504     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
505     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
506     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
507     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
508     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
509     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
510     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
511     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
512     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
513     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
514     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
515     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
516     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
517     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
518     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
519     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
520
521     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
522     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
523     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
524     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
525     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
526     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
527     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
528     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
529     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
530     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
531     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
532     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
533     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
534     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
535     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
536     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
537
538     a += MD5M_A;
539     b += MD5M_B;
540     c += MD5M_C;
541     d += MD5M_D;
542
543     const u32x w0_t = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
544                      | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
545     const u32x w1_t = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
546                      | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
547     const u32x w2_t = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
548                      | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
549     const u32x w3_t = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
550                      | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
551     const u32x w4_t = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
552                      | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
553     const u32x w5_t = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
554                      | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
555     const u32x w6_t = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
556                      | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
557     const u32x w7_t = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
558                      | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
559
560     const u32 w8_t = s[0];
561     const u32 w9_t = s[1];
562     const u32 wa_t = s[2];
563     const u32 wb_t = s[3];
564     const u32 wc_t = s[4];
565     const u32 wd_t = s[5];
566     const u32 we_t = s[6];
567     const u32 wf_t = s[7];
568
569     a = MD5M_A;
570     b = MD5M_B;
571     c = MD5M_C;
572     d = MD5M_D;
573
574     MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
575     MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
576     MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
577     MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
578     MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
579     MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
580     MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
581     MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
582     MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
583     MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
584     MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
585     MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
586     MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
587     MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
588     MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
589     MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
590
591     MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
592     MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
593     MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
594     MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
595     MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
596     MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
597     MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
598     MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
599     MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
600     MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
601     MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
602     MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
603     MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
604     MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
605     MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
606     MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
607
608     MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
609     MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
610     MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
611     MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
612     MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
613     MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
614     MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
615     MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
616     MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
617     MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
618     MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
619     MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
620     MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
621     MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
622     MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
623     MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
624
625     MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
626     MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
627     MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
628     MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
629     MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
630     MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
631     MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
632     MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
633     MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
634     MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
635     MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
636     MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
637     MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
638     MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
639     MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
640     MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
641
642     const u32x r0 = a;
643     const u32x r1 = d;
644     const u32x r2 = c;
645     const u32x r3 = b;
646
647     #include VECT_COMPARE_S
648   }
649 }
650
651 extern "C" __global__ void __launch_bounds__ (256, 1) m04310_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)
652 {
653 }
654
655 extern "C" __global__ void __launch_bounds__ (256, 1) m04310_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)
656 {
657 }