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