Initial commit
[hashcat.git] / amd / m01000_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD4_
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  VLIW4
16 #define VECT_SIZE4
17 #endif
18
19 #ifdef  VLIW5
20 #define VECT_SIZE4
21 #endif
22
23 #define DGST_R0 0
24 #define DGST_R1 3
25 #define DGST_R2 2
26 #define DGST_R3 1
27
28 #include "include/kernel_functions.c"
29 #include "types_amd.c"
30 #include "common_amd.c"
31 #include "include/rp_gpu.h"
32 #include "rp_amd.c"
33
34 #ifdef  VECT_SIZE1
35 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
36 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
37 #endif
38
39 #ifdef  VECT_SIZE2
40 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
41 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
42 #endif
43
44 #ifdef  VECT_SIZE4
45 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
46 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
47 #endif
48
49 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01000_m04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global 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)
50 {
51   /**
52    * modifier
53    */
54
55   const u32 lid = get_local_id (0);
56
57   /**
58    * base
59    */
60
61   const u32 gid = get_global_id (0);
62
63   if (gid >= gid_max) return;
64
65   u32x pw_buf0[4];
66
67   pw_buf0[0] = pws[gid].i[ 0];
68   pw_buf0[1] = pws[gid].i[ 1];
69   pw_buf0[2] = pws[gid].i[ 2];
70   pw_buf0[3] = pws[gid].i[ 3];
71
72   u32x pw_buf1[4];
73
74   pw_buf1[0] = pws[gid].i[ 4];
75   pw_buf1[1] = pws[gid].i[ 5];
76   pw_buf1[2] = pws[gid].i[ 6];
77   pw_buf1[3] = pws[gid].i[ 7];
78
79   const u32 pw_len = pws[gid].pw_len;
80
81   /**
82    * loop
83    */
84
85   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
86   {
87     u32x w0[4];
88
89     w0[0] = pw_buf0[0];
90     w0[1] = pw_buf0[1];
91     w0[2] = pw_buf0[2];
92     w0[3] = pw_buf0[3];
93
94     u32x w1[4];
95
96     w1[0] = pw_buf1[0];
97     w1[1] = pw_buf1[1];
98     w1[2] = pw_buf1[2];
99     w1[3] = pw_buf1[3];
100
101     u32x w2[4];
102
103     w2[0] = 0;
104     w2[1] = 0;
105     w2[2] = 0;
106     w2[3] = 0;
107
108     u32x w3[4];
109
110     w3[0] = 0;
111     w3[1] = 0;
112     w3[2] = 0;
113     w3[3] = 0;
114
115     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
116
117     append_0x80_2 (w0, w1, out_len);
118
119     u32x w0_t[4];
120     u32x w1_t[4];
121     u32x w2_t[4];
122     u32x w3_t[4];
123
124     make_unicode (w0, w0_t, w1_t);
125     make_unicode (w1, w2_t, w3_t);
126
127     w3_t[2] = out_len * 8 * 2;
128
129     u32x tmp2;
130
131     u32x a = MD4M_A;
132     u32x b = MD4M_B;
133     u32x c = MD4M_C;
134     u32x d = MD4M_D;
135
136     MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
137     MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
138     MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
139     MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
140     MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
141     MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
142     MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
143     MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
144     MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
145     MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
146     MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
147     MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
148     MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
149     MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
150     MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
151     MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
152
153     MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
154     MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
155     MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
156     MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
157     MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
158     MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
159     MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
160     MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
161     MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
162     MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
163     MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
164     MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
165     MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
166     MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
167     MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
168     MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
169
170     MD4_STEP (MD4_H1, a, b, c, d, w0_t[0], MD4C02, MD4S20);
171     MD4_STEP (MD4_H2, d, a, b, c, w2_t[0], MD4C02, MD4S21);
172     MD4_STEP (MD4_H1, c, d, a, b, w1_t[0], MD4C02, MD4S22);
173     MD4_STEP (MD4_H2, b, c, d, a, w3_t[0], MD4C02, MD4S23);
174     MD4_STEP (MD4_H1, a, b, c, d, w0_t[2], MD4C02, MD4S20);
175     MD4_STEP (MD4_H2, d, a, b, c, w2_t[2], MD4C02, MD4S21);
176     MD4_STEP (MD4_H1, c, d, a, b, w1_t[2], MD4C02, MD4S22);
177     MD4_STEP (MD4_H2, b, c, d, a, w3_t[2], MD4C02, MD4S23);
178     MD4_STEP (MD4_H1, a, b, c, d, w0_t[1], MD4C02, MD4S20);
179     MD4_STEP (MD4_H2, d, a, b, c, w2_t[1], MD4C02, MD4S21);
180     MD4_STEP (MD4_H1, c, d, a, b, w1_t[1], MD4C02, MD4S22);
181     MD4_STEP (MD4_H2, b, c, d, a, w3_t[1], MD4C02, MD4S23);
182     MD4_STEP (MD4_H1, a, b, c, d, w0_t[3], MD4C02, MD4S20);
183     MD4_STEP (MD4_H2, d, a, b, c, w2_t[3], MD4C02, MD4S21);
184     MD4_STEP (MD4_H1, c, d, a, b, w1_t[3], MD4C02, MD4S22);
185     MD4_STEP (MD4_H2, b, c, d, a, w3_t[3], MD4C02, MD4S23);
186
187     const u32x r0 = a;
188     const u32x r1 = d;
189     const u32x r2 = c;
190     const u32x r3 = b;
191
192     #include VECT_COMPARE_M
193   }
194 }
195
196 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01000_m08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global 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)
197 {
198 }
199
200 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01000_m16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global 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)
201 {
202 }
203
204 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01000_s04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global 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)
205 {
206   /**
207    * modifier
208    */
209
210   const u32 lid = get_local_id (0);
211
212   /**
213    * base
214    */
215
216   const u32 gid = get_global_id (0);
217
218   if (gid >= gid_max) return;
219
220   u32x pw_buf0[4];
221
222   pw_buf0[0] = pws[gid].i[ 0];
223   pw_buf0[1] = pws[gid].i[ 1];
224   pw_buf0[2] = pws[gid].i[ 2];
225   pw_buf0[3] = pws[gid].i[ 3];
226
227   u32x pw_buf1[4];
228
229   pw_buf1[0] = pws[gid].i[ 4];
230   pw_buf1[1] = pws[gid].i[ 5];
231   pw_buf1[2] = pws[gid].i[ 6];
232   pw_buf1[3] = pws[gid].i[ 7];
233
234   const u32 pw_len = pws[gid].pw_len;
235
236   /**
237    * digest
238    */
239
240   const u32 search[4] =
241   {
242     digests_buf[digests_offset].digest_buf[DGST_R0],
243     digests_buf[digests_offset].digest_buf[DGST_R1],
244     digests_buf[digests_offset].digest_buf[DGST_R2],
245     digests_buf[digests_offset].digest_buf[DGST_R3]
246   };
247
248   /**
249    * loop
250    */
251
252   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
253   {
254     u32x w0[4];
255
256     w0[0] = pw_buf0[0];
257     w0[1] = pw_buf0[1];
258     w0[2] = pw_buf0[2];
259     w0[3] = pw_buf0[3];
260
261     u32x w1[4];
262
263     w1[0] = pw_buf1[0];
264     w1[1] = pw_buf1[1];
265     w1[2] = pw_buf1[2];
266     w1[3] = pw_buf1[3];
267
268     u32x w2[4];
269
270     w2[0] = 0;
271     w2[1] = 0;
272     w2[2] = 0;
273     w2[3] = 0;
274
275     u32x w3[4];
276
277     w3[0] = 0;
278     w3[1] = 0;
279     w3[2] = 0;
280     w3[3] = 0;
281
282     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
283
284     append_0x80_2 (w0, w1, out_len);
285
286     u32x w0_t[4];
287     u32x w1_t[4];
288     u32x w2_t[4];
289     u32x w3_t[4];
290
291     make_unicode (w0, w0_t, w1_t);
292     make_unicode (w1, w2_t, w3_t);
293
294     w3_t[2] = out_len * 8 * 2;
295
296     u32x tmp2;
297
298     u32x a = MD4M_A;
299     u32x b = MD4M_B;
300     u32x c = MD4M_C;
301     u32x d = MD4M_D;
302
303     MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
304     MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
305     MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
306     MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
307     MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
308     MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
309     MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
310     MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
311     MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
312     MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
313     MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
314     MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
315     MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
316     MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
317     MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
318     MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
319
320     MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
321     MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
322     MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
323     MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
324     MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
325     MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
326     MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
327     MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
328     MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
329     MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
330     MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
331     MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
332     MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
333     MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
334     MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
335     MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
336
337     MD4_STEP (MD4_H1, a, b, c, d, w0_t[0], MD4C02, MD4S20);
338     MD4_STEP (MD4_H2, d, a, b, c, w2_t[0], MD4C02, MD4S21);
339     MD4_STEP (MD4_H1, c, d, a, b, w1_t[0], MD4C02, MD4S22);
340     MD4_STEP (MD4_H2, b, c, d, a, w3_t[0], MD4C02, MD4S23);
341     MD4_STEP (MD4_H1, a, b, c, d, w0_t[2], MD4C02, MD4S20);
342     MD4_STEP (MD4_H2, d, a, b, c, w2_t[2], MD4C02, MD4S21);
343     MD4_STEP (MD4_H1, c, d, a, b, w1_t[2], MD4C02, MD4S22);
344     MD4_STEP (MD4_H2, b, c, d, a, w3_t[2], MD4C02, MD4S23);
345     MD4_STEP (MD4_H1, a, b, c, d, w0_t[1], MD4C02, MD4S20);
346     MD4_STEP (MD4_H2, d, a, b, c, w2_t[1], MD4C02, MD4S21);
347     MD4_STEP (MD4_H1, c, d, a, b, w1_t[1], MD4C02, MD4S22);
348     MD4_STEP (MD4_H2, b, c, d, a, w3_t[1], MD4C02, MD4S23);
349     MD4_STEP (MD4_H1, a, b, c, d, w0_t[3], MD4C02, MD4S20);
350     MD4_STEP (MD4_H2, d, a, b, c, w2_t[3], MD4C02, MD4S21);
351     MD4_STEP (MD4_H1, c, d, a, b, w1_t[3], MD4C02, MD4S22);
352     MD4_STEP (MD4_H2, b, c, d, a, w3_t[3], MD4C02, MD4S23);
353
354     const u32x r0 = a;
355     const u32x r1 = d;
356     const u32x r2 = c;
357     const u32x r3 = b;
358
359     #include VECT_COMPARE_S
360   }
361 }
362
363 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01000_s08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global 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)
364 {
365 }
366
367 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m01000_s16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global 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)
368 {
369 }